New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trapi/query

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trapi/query - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

dist/parameter/pagination/build.d.ts

30

dist/build/module.js

@@ -14,3 +14,2 @@ "use strict";

function buildQuery(input, options) {
var _a, _b, _c, _d, _e;
if (typeof input === 'undefined' ||

@@ -23,23 +22,34 @@ input === null) {

typeof input[constants_1.URLParameter.FIELDS] !== 'undefined') {
const fields = (_a = input[constants_1.Parameter.FIELDS]) !== null && _a !== void 0 ? _a : input[constants_1.URLParameter.FIELDS];
query[constants_1.URLParameter.FIELDS] = (0, parameter_1.buildQueryFields)(fields);
query[constants_1.URLParameter.FIELDS] = (0, parameter_1.buildQueryFieldsForMany)([
...(input[constants_1.Parameter.FIELDS] ? [input[constants_1.Parameter.FIELDS]] : []),
...(input[constants_1.URLParameter.FIELDS] ? [input[constants_1.URLParameter.FIELDS]] : []),
]);
}
if (typeof input[constants_1.Parameter.FILTERS] !== 'undefined' ||
typeof input[constants_1.URLParameter.FILTERS] !== 'undefined') {
const value = (_b = input[constants_1.Parameter.FILTERS]) !== null && _b !== void 0 ? _b : input[constants_1.URLParameter.FILTERS];
query[constants_1.URLParameter.FILTERS] = (0, parameter_1.buildQueryFilters)(value);
query[constants_1.URLParameter.FILTERS] = (0, parameter_1.buildQueryFiltersForMany)([
...(input[constants_1.Parameter.FILTERS] ? [input[constants_1.Parameter.FILTERS]] : []),
...(input[constants_1.URLParameter.FILTERS] ? [input[constants_1.URLParameter.FILTERS]] : []),
]);
}
if (typeof input[constants_1.Parameter.PAGINATION] !== 'undefined' ||
typeof input[constants_1.URLParameter.PAGINATION] !== 'undefined') {
query[constants_1.URLParameter.PAGINATION] = (_c = input[constants_1.Parameter.PAGINATION]) !== null && _c !== void 0 ? _c : input[constants_1.URLParameter.PAGINATION];
query[constants_1.URLParameter.PAGINATION] = (0, parameter_1.buildQueryPaginationForMany)([
...(input[constants_1.Parameter.PAGINATION] ? [input[constants_1.Parameter.PAGINATION]] : []),
...(input[constants_1.URLParameter.PAGINATION] ? [input[constants_1.URLParameter.PAGINATION]] : []),
]);
}
if (typeof input[constants_1.Parameter.RELATIONS] !== 'undefined' ||
typeof input[constants_1.URLParameter.RELATIONS] !== 'undefined') {
const value = (_d = input[constants_1.Parameter.RELATIONS]) !== null && _d !== void 0 ? _d : input[constants_1.URLParameter.RELATIONS];
query[constants_1.URLParameter.RELATIONS] = (0, parameter_1.buildQueryRelations)(value);
query[constants_1.URLParameter.RELATIONS] = (0, parameter_1.buildQueryRelationsForMany)([
...(input[constants_1.Parameter.RELATIONS] ? [input[constants_1.Parameter.RELATIONS]] : []),
...(input[constants_1.URLParameter.RELATIONS] ? [input[constants_1.URLParameter.RELATIONS]] : []),
]);
}
if (typeof input[constants_1.Parameter.SORT] !== 'undefined' ||
typeof input[constants_1.URLParameter.SORT] !== 'undefined') {
const value = (_e = input[constants_1.Parameter.SORT]) !== null && _e !== void 0 ? _e : input[constants_1.URLParameter.SORT];
query[constants_1.URLParameter.SORT] = (0, parameter_1.buildQuerySort)(value);
query[constants_1.URLParameter.SORT] = (0, parameter_1.buildQuerySortForMany)([
...(input[constants_1.Parameter.SORT] ? [input[constants_1.Parameter.SORT]] : []),
...(input[constants_1.URLParameter.SORT] ? [input[constants_1.URLParameter.SORT]] : []),
]);
}

@@ -46,0 +56,0 @@ return (0, utils_1.buildURLQueryString)(query);

import { FieldsBuildInput } from './type';
export declare function buildQueryFieldsForMany<T>(inputs: FieldsBuildInput<T>[]): Record<string, any> | string | string[];
export declare function buildQueryFields<T>(data: FieldsBuildInput<T>): Record<string, any> | string | string[];
//# sourceMappingURL=build.d.ts.map

@@ -9,4 +9,24 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildQueryFields = void 0;
exports.buildQueryFields = exports.buildQueryFieldsForMany = void 0;
const utils_1 = require("../utils");
const utils_2 = require("../../utils");
function buildQueryFieldsForMany(inputs) {
let data;
for (let i = 0; i < inputs.length; i++) {
if (data) {
const current = inputs[i];
if (typeof data === 'string' || typeof current === 'string') {
data = inputs[i];
}
else {
data = (0, utils_2.mergeDeep)(data, current);
}
}
else {
data = inputs[i];
}
}
return buildQueryFields(data);
}
exports.buildQueryFieldsForMany = buildQueryFieldsForMany;
function buildQueryFields(data) {

@@ -13,0 +33,0 @@ switch (true) {

@@ -9,3 +9,3 @@ import { Parameter } from '../../constants';

declare type FieldWithOperator<T extends Record<string, any>> = KeyWithOptionalPrefix<keyof T, FieldOperator> | KeyWithOptionalPrefix<keyof T, FieldOperator>[];
export declare type FieldsBuildInput<T> = {
export declare type FieldsBuildInput<T extends Record<string, any>> = {
[K in keyof T]?: T[K] extends OnlyObject<T[K]> ? (FieldsBuildInput<Flatten<T[K]>> | FieldWithOperator<Flatten<T[K]>>) : never;

@@ -12,0 +12,0 @@ } | {

import { FiltersBuildInput } from './type';
export declare function buildQueryFiltersForMany<T>(input: FiltersBuildInput<T>[]): Record<string, string>;
export declare function buildQueryFilters<T>(data: FiltersBuildInput<T>): Record<string, string>;
//# sourceMappingURL=build.d.ts.map

@@ -9,6 +9,20 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildQueryFilters = void 0;
exports.buildQueryFilters = exports.buildQueryFiltersForMany = void 0;
const utils_1 = require("../utils");
const constants_1 = require("./constants");
const utils_2 = require("./utils");
const utils_3 = require("../../utils");
function buildQueryFiltersForMany(input) {
let data;
for (let i = 0; i < input.length; i++) {
if (data) {
data = (0, utils_3.mergeDeep)(data, input[i]);
}
else {
data = input[i];
}
}
return buildQueryFilters(data);
}
exports.buildQueryFiltersForMany = buildQueryFiltersForMany;
function buildQueryFilters(data) {

@@ -15,0 +29,0 @@ return (0, utils_1.flattenNestedProperties)(transformOperatorConfigToValue(data));

@@ -0,3 +1,4 @@

export * from './build';
export * from './parse';
export * from './type';
//# sourceMappingURL=index.d.ts.map

@@ -23,4 +23,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./build"), exports);
__exportStar(require("./parse"), exports);
__exportStar(require("./type"), exports);
//# sourceMappingURL=index.js.map
import { RelationsBuildInput } from './type';
export declare function buildQueryRelationsForMany<T>(input: RelationsBuildInput<T>[]): string[];
export declare function buildQueryRelations<T>(data: RelationsBuildInput<T>): string[];
//# sourceMappingURL=build.d.ts.map

@@ -9,4 +9,18 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildQueryRelations = void 0;
exports.buildQueryRelations = exports.buildQueryRelationsForMany = void 0;
const utils_1 = require("../utils");
const utils_2 = require("../../utils");
function buildQueryRelationsForMany(input) {
let data;
for (let i = 0; i < input.length; i++) {
if (data) {
data = (0, utils_2.mergeDeep)(data, input[i]);
}
else {
data = input[i];
}
}
return buildQueryRelations(data);
}
exports.buildQueryRelationsForMany = buildQueryRelationsForMany;
function buildQueryRelations(data) {

@@ -13,0 +27,0 @@ const properties = (0, utils_1.flattenNestedProperties)(data);

import { SortBuildInput } from './type';
export declare function buildQuerySortForMany<T>(inputs: SortBuildInput<T>[]): Record<string, any> | import("..").KeyWithOptionalPrefix<keyof T, "-">;
export declare function buildQuerySort<T>(data: SortBuildInput<T>): Record<string, any> | import("..").KeyWithOptionalPrefix<keyof T, "-">;
//# sourceMappingURL=build.d.ts.map

@@ -9,4 +9,25 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.buildQuerySort = void 0;
exports.buildQuerySort = exports.buildQuerySortForMany = void 0;
const utils_1 = require("../utils");
const utils_2 = require("../../utils");
function buildQuerySortForMany(inputs) {
let data;
for (let i = 0; i < inputs.length; i++) {
if (data) {
const current = inputs[i];
if (typeof data === 'string' ||
typeof current === 'string') {
data = inputs[i];
}
else {
data = (0, utils_2.mergeDeep)(data, current);
}
}
else {
data = inputs[i];
}
}
return buildQuerySort(data);
}
exports.buildQuerySortForMany = buildQuerySortForMany;
function buildQuerySort(data) {

@@ -13,0 +34,0 @@ switch (true) {

export * from './field';
export * from './relation';
export * from './merge-deep';
export * from './object';

@@ -4,0 +5,0 @@ export * from './simple';

@@ -25,2 +25,3 @@ "use strict";

__exportStar(require("./relation"), exports);
__exportStar(require("./merge-deep"), exports);
__exportStar(require("./object"), exports);

@@ -27,0 +28,0 @@ __exportStar(require("./simple"), exports);

{
"name": "@trapi/query",
"version": "2.1.1",
"version": "2.1.2",
"description": "A tiny library which provides utility types/functions for request and response query handling.",

@@ -44,15 +44,2 @@ "main": "./dist/index.js",

"homepage": "https://github.com/Tada5hi/typescript-rest-api#readme",
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"codecov": "^3.8.3",
"cross-env": "^7.0.3",
"jest": "^27.5.1",
"minimatch": "^5.0.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.7.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^4.6.2"
},
"dependencies": {

@@ -64,3 +51,3 @@ "minimatch": "^5.0.1"

},
"gitHead": "502f3d8795041a84fbdac49851cc7b6166a92aa4"
"gitHead": "81b7c352dd1dd988e922adb377d3ff70e3098be7"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc