@leyyo/query 1.3.1 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/error/index.d.ts +2 -2
  2. package/dist/error/index.js +2 -18
  3. package/dist/error/index.types.js +1 -2
  4. package/dist/error/invalid-query-value.error.d.ts +1 -1
  5. package/dist/error/invalid-query-value.error.js +4 -6
  6. package/dist/field/index.d.ts +1 -1
  7. package/dist/field/index.js +1 -17
  8. package/dist/field/index.types.js +1 -2
  9. package/dist/group-by/index.d.ts +1 -1
  10. package/dist/group-by/index.js +1 -17
  11. package/dist/group-by/index.types.d.ts +1 -1
  12. package/dist/group-by/index.types.js +1 -2
  13. package/dist/index.d.ts +12 -10
  14. package/dist/index.foretell.d.ts +1 -0
  15. package/dist/index.foretell.js +17 -0
  16. package/dist/index.js +12 -26
  17. package/dist/index.loader.d.ts +1 -0
  18. package/dist/index.loader.js +12 -0
  19. package/dist/internal.d.ts +1 -0
  20. package/dist/internal.js +2 -0
  21. package/dist/operation/index.d.ts +1 -1
  22. package/dist/operation/index.js +1 -17
  23. package/dist/operation/operation-type.js +2 -5
  24. package/dist/order-by/index.d.ts +1 -1
  25. package/dist/order-by/index.js +1 -17
  26. package/dist/order-by/index.types.d.ts +2 -2
  27. package/dist/order-by/index.types.js +1 -2
  28. package/dist/order-type/index.d.ts +1 -0
  29. package/dist/order-type/index.js +1 -0
  30. package/dist/order-type/order-type.d.ts +7 -0
  31. package/dist/order-type/order-type.js +2 -0
  32. package/dist/pagination/index.d.ts +1 -1
  33. package/dist/pagination/index.js +1 -17
  34. package/dist/pagination/index.types.js +1 -2
  35. package/dist/parser/index.d.ts +2 -2
  36. package/dist/parser/index.js +2 -18
  37. package/dist/parser/index.types.d.ts +1 -1
  38. package/dist/parser/index.types.js +1 -2
  39. package/dist/parser/query.parser.d.ts +1 -1
  40. package/dist/parser/query.parser.js +57 -60
  41. package/dist/query/index.d.ts +1 -1
  42. package/dist/query/index.js +1 -17
  43. package/dist/query/index.types.d.ts +5 -5
  44. package/dist/query/index.types.js +1 -2
  45. package/dist/select/index.d.ts +1 -1
  46. package/dist/select/index.js +1 -17
  47. package/dist/select/index.types.d.ts +1 -1
  48. package/dist/select/index.types.js +1 -2
  49. package/dist/where/index.d.ts +1 -1
  50. package/dist/where/index.js +1 -17
  51. package/dist/where/index.types.d.ts +2 -2
  52. package/dist/where/index.types.js +1 -2
  53. package/package.json +4 -5
  54. package/dist/assets/.gitkeep +0 -0
@@ -1,2 +1,2 @@
1
- export * from './invalid-query-value.error';
2
- export * from './index.types';
1
+ export * from './invalid-query-value.error.js';
2
+ export * from './index.types.js';
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./invalid-query-value.error"), exports);
18
- __exportStar(require("./index.types"), exports);
1
+ export * from './invalid-query-value.error.js';
2
+ export * from './index.types.js';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { QueryErrorCode } from "./index.types";
1
+ import { QueryErrorCode } from "./index.types.js";
2
2
  import { LeyyoError } from "@leyyo/common";
3
3
  export declare class InvalidQueryValueError extends LeyyoError {
4
4
  readonly message: string;
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidQueryValueError = void 0;
4
- const common_1 = require("@leyyo/common");
5
- class InvalidQueryValueError extends common_1.LeyyoError {
1
+ import { LeyyoError } from "@leyyo/common";
2
+ export class InvalidQueryValueError extends LeyyoError {
3
+ message;
4
+ path;
6
5
  constructor(code, message, path) {
7
6
  super(`[${code}] ${message} at ${path}`);
8
7
  this.message = message;
9
8
  this.path = path;
10
9
  }
11
10
  }
12
- exports.InvalidQueryValueError = InvalidQueryValueError;
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,4 +1,4 @@
1
- import { FieldRaw, FieldRegular } from "../field";
1
+ import { FieldRaw, FieldRegular } from "../field/index.js";
2
2
  export type GroupByAny<K extends string> = Array<K | GroupByGivenRegular<K> | GroupByGivenRaw>;
3
3
  export type GroupByGivenRegular<K extends string> = FieldRegular<K>;
4
4
  export type GroupByGivenRaw = FieldRaw;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
- export * from './operation';
2
- export * from './error';
3
- export * from './field';
4
- export * from './group-by';
5
- export * from './order-by';
6
- export * from './pagination';
7
- export * from './parser';
8
- export * from './query';
9
- export * from './select';
10
- export * from './where';
1
+ export * from './operation/index.js';
2
+ export * from './error/index.js';
3
+ export * from './field/index.js';
4
+ export * from './group-by/index.js';
5
+ export * from './order-by/index.js';
6
+ export * from './pagination/index.js';
7
+ export * from './parser/index.js';
8
+ export * from './query/index.js';
9
+ export * from './select/index.js';
10
+ export * from './where/index.js';
11
+ export * from './index.foretell.js';
12
+ export * from './index.loader.js';
@@ -0,0 +1 @@
1
+ export declare const foretell_leyyoQuery: (() => void)[];
@@ -0,0 +1,17 @@
1
+ import { FQN } from "./internal.js";
2
+ import { errorPool, foretell_leyyoCommon, literalPool } from "@leyyo/common";
3
+ // noinspection JSUnusedGlobalSymbols
4
+ export const foretell_leyyoQuery = [
5
+ // dependencies
6
+ ...foretell_leyyoCommon,
7
+ // errors
8
+ () => errorPool.lazy(FQN, 'InvalidQueryValueError', import('./error/invalid-query-value.error.js').then(m => m.InvalidQueryValueError), { i18n: true, emit: true }),
9
+ // enums
10
+ () => literalPool.register({
11
+ name: 'OperationType',
12
+ fqn: FQN,
13
+ i18n: true,
14
+ lazyTarget: import('./operation/operation-type.js').then(m => m.OperationTypeItems),
15
+ lazyAlt: import('./operation/operation-type.js').then(m => m.OperationTypeMap),
16
+ }),
17
+ ];
package/dist/index.js CHANGED
@@ -1,26 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./operation"), exports);
18
- __exportStar(require("./error"), exports);
19
- __exportStar(require("./field"), exports);
20
- __exportStar(require("./group-by"), exports);
21
- __exportStar(require("./order-by"), exports);
22
- __exportStar(require("./pagination"), exports);
23
- __exportStar(require("./parser"), exports);
24
- __exportStar(require("./query"), exports);
25
- __exportStar(require("./select"), exports);
26
- __exportStar(require("./where"), exports);
1
+ export * from './operation/index.js';
2
+ export * from './error/index.js';
3
+ export * from './field/index.js';
4
+ export * from './group-by/index.js';
5
+ export * from './order-by/index.js';
6
+ export * from './pagination/index.js';
7
+ export * from './parser/index.js';
8
+ export * from './query/index.js';
9
+ export * from './select/index.js';
10
+ export * from './where/index.js';
11
+ export * from './index.foretell.js';
12
+ export * from './index.loader.js';
@@ -0,0 +1 @@
1
+ export declare const loader_leyyoQuery: import("@leyyo/common").LoaderLike;
@@ -0,0 +1,12 @@
1
+ import { defineLoader, loader_leyyoCommon } from "@leyyo/common";
2
+ import { FQN } from "./internal.js";
3
+ // noinspection JSUnusedGlobalSymbols
4
+ export const loader_leyyoQuery = defineLoader(FQN,
5
+ // dependencies
6
+ ...loader_leyyoCommon,
7
+ // errors
8
+ () => import('./error/invalid-query-value.error.js').then(m => m.InvalidQueryValueError),
9
+ // enums
10
+ () => import('./operation/operation-type.js').then(m => m.OperationTypeItems),
11
+ // classes
12
+ () => import('./parser/query.parser.js').then(m => m.queryParser));
@@ -0,0 +1 @@
1
+ export declare const NME: string, FQN: string, VER: string, CNF: import("@leyyo/common").LeyyoConfig;
@@ -0,0 +1,2 @@
1
+ import { sysAll } from '@leyyo/common';
2
+ export const { pck: { name: NME, fqn: FQN, version: VER }, config: CNF } = sysAll(import.meta.url);
@@ -1 +1 @@
1
- export * from './operation-type';
1
+ export * from './operation-type.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./operation-type"), exports);
1
+ export * from './operation-type.js';
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OperationTypeMap = exports.OperationTypeItems = void 0;
4
1
  const literals = [
5
2
  // all
6
3
  'eq',
@@ -41,9 +38,9 @@ const literals = [
41
38
  'exists',
42
39
  '!exists',
43
40
  ];
44
- exports.OperationTypeItems = literals;
41
+ export const OperationTypeItems = literals;
45
42
  // noinspection JSUnusedGlobalSymbols
46
- exports.OperationTypeMap = {
43
+ export const OperationTypeMap = {
47
44
  // all
48
45
  '=': 'eq',
49
46
  '==': 'eq',
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,5 +1,5 @@
1
- import { FieldRaw, FieldRegular } from "../field";
2
- export type OrderType = 'asc' | 'desc';
1
+ import { FieldRaw, FieldRegular } from "../field/index.js";
2
+ import { OrderType } from "../order-type/index.js";
3
3
  export type OrderByAny<K extends string> = K | Array<OrderByGiven<K> | K | OrderByGivenRaw> | OrderByValue<K>;
4
4
  export type OrderByValue<K extends string> = {
5
5
  [field in K]: boolean | OrderType;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './order-type.js';
@@ -0,0 +1 @@
1
+ export * from './order-type.js';
@@ -0,0 +1,7 @@
1
+ declare const literals: readonly ["asc", "desc"];
2
+ /**
3
+ * Order Type
4
+ * */
5
+ export type OrderType = typeof literals[number];
6
+ export declare const OrderTypeItems: ReadonlyArray<OrderType>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ const literals = ['asc', 'desc'];
2
+ export const OrderTypeItems = literals;
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1,2 @@
1
- export * from './index.types';
2
- export * from './query.parser';
1
+ export * from './index.types.js';
2
+ export * from './query.parser.js';
@@ -1,18 +1,2 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
18
- __exportStar(require("./query.parser"), exports);
1
+ export * from './index.types.js';
2
+ export * from './query.parser.js';
@@ -1,4 +1,4 @@
1
- import { QueryAny, QueryRegular } from "../query";
1
+ import { QueryAny, QueryRegular } from "../query/index.js";
2
2
  import { BasicType } from "@leyyo/common";
3
3
  export interface QueryParserLike {
4
4
  exec<K extends string>(query: QueryAny<K>, availableFields: Array<K | string>, name?: string): QueryRegular<K>;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { QueryParserLike } from "./index.types";
1
+ import { QueryParserLike } from "./index.types.js";
2
2
  export declare const queryParser: QueryParserLike;
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryParser = void 0;
4
- const common_1 = require("@leyyo/common");
5
- const operation_1 = require("../operation");
6
- const error_1 = require("../error");
7
- const type_1 = require("@leyyo/type");
1
+ import { isEmpty, isFilledObj, isText, setFqn } from "@leyyo/common";
2
+ import { OperationTypeItems, OperationTypeMap } from "../operation/index.js";
3
+ import { InvalidQueryValueError } from "../error/index.js";
4
+ import { FQN } from "../internal.js";
8
5
  class QueryParser {
9
6
  // region private
10
7
  _error(code, message, path) {
11
- return new error_1.InvalidQueryValueError(code, message, path);
8
+ return new InvalidQueryValueError(code, message, path);
12
9
  }
13
10
  _invalid(value, path, expected, code) {
14
11
  const ex = Array.isArray(expected) ? `[${expected.join(', ')}]` : expected;
15
12
  return this._error(code, `It's expected as ${ex}, but it's type: ${typeof value}`, path);
16
13
  }
17
14
  _emptyOrInvalid(value, path, expected, empty, invalid) {
18
- if ((0, common_1.isEmpty)(value)) {
15
+ if (isEmpty(value)) {
19
16
  return this._error(empty, `It's empty`, path);
20
17
  }
21
18
  if (typeof value === 'string' && value.trim() === '') {
@@ -24,13 +21,13 @@ class QueryParser {
24
21
  return this._invalid(value, path, expected, invalid);
25
22
  }
26
23
  _asc(value, path) {
27
- if ((0, common_1.isEmpty)(value)) {
24
+ if (isEmpty(value)) {
28
25
  return true;
29
26
  }
30
27
  if (typeof value === 'boolean') {
31
28
  return value;
32
29
  }
33
- else if ((0, common_1.isText)(value)) {
30
+ else if (isText(value)) {
34
31
  if (value.toLowerCase() === 'asc') {
35
32
  return true;
36
33
  }
@@ -42,37 +39,37 @@ class QueryParser {
42
39
  throw this._invalid(value, path, ['boolean', 'string'], 'asc:invalid-type');
43
40
  }
44
41
  _field(value, path) {
45
- if ((0, common_1.isText)(value)) {
42
+ if (isText(value)) {
46
43
  return value;
47
44
  }
48
45
  throw this._emptyOrInvalid(value, path, 'string', 'field:empty', 'field:invalid');
49
46
  }
50
47
  _raw(value, path) {
51
- if ((0, common_1.isText)(value)) {
48
+ if (isText(value)) {
52
49
  return value;
53
50
  }
54
51
  throw this._emptyOrInvalid(value, path, 'string', 'raw:empty', 'raw:invalid');
55
52
  }
56
53
  _as(value, path) {
57
- if ((0, common_1.isEmpty)(value)) {
54
+ if (isEmpty(value)) {
58
55
  return undefined;
59
56
  }
60
- else if ((0, common_1.isText)(value)) {
57
+ else if (isText(value)) {
61
58
  return value;
62
59
  }
63
60
  throw this._invalid(value, path, 'string', 'as:invalid');
64
61
  }
65
62
  _operation(value, path) {
66
- if ((0, common_1.isEmpty)(value)) {
63
+ if (isEmpty(value)) {
67
64
  return 'eq';
68
65
  }
69
- else if ((0, common_1.isText)(value)) {
66
+ else if (isText(value)) {
70
67
  const key = value;
71
- if ((0, common_1.isText)(key) && operation_1.OperationTypeItems.includes(key)) {
68
+ if (isText(key) && OperationTypeItems.includes(key)) {
72
69
  return key;
73
70
  }
74
- if (operation_1.OperationTypeMap[key] !== undefined) {
75
- return operation_1.OperationTypeMap[key];
71
+ if (OperationTypeMap[key] !== undefined) {
72
+ return OperationTypeMap[key];
76
73
  }
77
74
  throw this._error('op:invalid-key', `It should be [@see operations], but it's value: ${value}`, path);
78
75
  }
@@ -99,7 +96,7 @@ class QueryParser {
99
96
  if (Array.isArray(value)) {
100
97
  let index = 0;
101
98
  for (const item of value) {
102
- if (!(0, common_1.isText)(item) && typeof value !== 'number' && typeof value !== 'boolean') {
99
+ if (!isText(item) && typeof value !== 'number' && typeof value !== 'boolean') {
103
100
  throw this._invalid(item, `${path}[${index}]`, ['string', 'number', 'boolean', 'array', 'number'], 'value:invalid-item');
104
101
  }
105
102
  index++;
@@ -111,7 +108,7 @@ class QueryParser {
111
108
  throw this._invalid(value, path, ['string', 'number', 'boolean', 'array', 'number'], 'value:invalid-type');
112
109
  }
113
110
  _num(value, path, min) {
114
- if ((0, common_1.isEmpty)(value)) {
111
+ if (isEmpty(value)) {
115
112
  return undefined;
116
113
  }
117
114
  else if (Number.isSafeInteger(value)) {
@@ -133,7 +130,7 @@ class QueryParser {
133
130
  // endregion private
134
131
  // region parts
135
132
  _select(given, _availableFields, _name) {
136
- if ((0, common_1.isEmpty)(given)) {
133
+ if (isEmpty(given)) {
137
134
  return { all: true };
138
135
  }
139
136
  // Cases:
@@ -152,7 +149,7 @@ class QueryParser {
152
149
  const arr = given;
153
150
  arr.forEach((item, index) => {
154
151
  // Case 2A: K
155
- if ((0, common_1.isText)(item)) {
152
+ if (isText(item)) {
156
153
  newSelect.fields.push({
157
154
  field: item,
158
155
  });
@@ -165,15 +162,15 @@ class QueryParser {
165
162
  newSelect.fields.push({ field, as, });
166
163
  }
167
164
  // Case 2C: SelectGiven<K> | SelectGivenRaw
168
- else if ((0, type_1.isBareObject)(item)) {
165
+ else if (isFilledObj(item)) {
169
166
  let as;
170
167
  let field;
171
168
  let raw;
172
169
  const obj = item;
173
- if (!(0, common_1.isEmpty)(obj.raw)) {
170
+ if (!isEmpty(obj.raw)) {
174
171
  raw = this._raw(obj.raw, `select[${index}].raw`);
175
172
  }
176
- if (!(0, common_1.isEmpty)(obj.field)) {
173
+ if (!isEmpty(obj.field)) {
177
174
  field = this._field(obj.field, `select[${index}].field`);
178
175
  }
179
176
  this._fieldXorRaw(field, raw, `select[${index}].field`);
@@ -198,7 +195,7 @@ class QueryParser {
198
195
  return newSelect;
199
196
  }
200
197
  _where(scope, given, _availableFields, _name) {
201
- if ((0, common_1.isEmpty)(given)) {
198
+ if (isEmpty(given)) {
202
199
  return [];
203
200
  }
204
201
  // Cases:
@@ -206,7 +203,7 @@ class QueryParser {
206
203
  // 2 - Array<WhereGiven<K>|WhereGivenRaw|[K, unknown]>
207
204
  const newWhere = [];
208
205
  // case 1: WhereValue<K>
209
- if ((0, type_1.isBareObject)(given)) {
206
+ if (isFilledObj(given)) {
210
207
  let index = 0;
211
208
  for (let [k, v] of Object.entries(given)) {
212
209
  const field = this._field(k, `${scope}(key=${index})`);
@@ -223,22 +220,22 @@ class QueryParser {
223
220
  const arr = given;
224
221
  arr.forEach((item, index) => {
225
222
  // Case 2A: WhereGiven<K>|WhereGivenRaw
226
- if ((0, type_1.isBareObject)(item)) {
223
+ if (isFilledObj(item)) {
227
224
  let field;
228
225
  let raw;
229
226
  let op;
230
227
  let value;
231
228
  let fullRaw;
232
229
  const obj = item;
233
- if (!(0, common_1.isEmpty)(obj.raw)) {
230
+ if (!isEmpty(obj.raw)) {
234
231
  raw = this._raw(obj.raw, `${scope}[${index}].raw`);
235
232
  }
236
- if (!(0, common_1.isEmpty)(obj.field)) {
233
+ if (!isEmpty(obj.field)) {
237
234
  field = this._field(obj.field, `${scope}[${index}].field`);
238
235
  }
239
236
  this._fieldXorRaw(field, raw, `${scope}[${index}].field`);
240
237
  const whereItem = obj;
241
- if (raw && (0, common_1.isEmpty)(whereItem.op) && (0, common_1.isEmpty)(whereItem.value)) {
238
+ if (raw && isEmpty(whereItem.op) && isEmpty(whereItem.value)) {
242
239
  fullRaw = true;
243
240
  }
244
241
  op = this._operation(whereItem.op, `${scope}[${index}].op`);
@@ -270,7 +267,7 @@ class QueryParser {
270
267
  return newWhere;
271
268
  }
272
269
  _groupBy(given, _availableFields, _name) {
273
- if ((0, common_1.isEmpty)(given)) {
270
+ if (isEmpty(given)) {
274
271
  return [];
275
272
  }
276
273
  // Cases:
@@ -284,14 +281,14 @@ class QueryParser {
284
281
  const arr = given;
285
282
  arr.forEach((item, index) => {
286
283
  // Case 2A: GroupByGivenRegular<K> | GroupByGivenRaw
287
- if ((0, type_1.isBareObject)(item)) {
284
+ if (isFilledObj(item)) {
288
285
  let field;
289
286
  let raw;
290
287
  const obj = item;
291
- if (!(0, common_1.isEmpty)(obj.raw)) {
288
+ if (!isEmpty(obj.raw)) {
292
289
  raw = this._raw(obj.raw, `groupBy[${index}].raw`);
293
290
  }
294
- if (!(0, common_1.isEmpty)(obj.field)) {
291
+ if (!isEmpty(obj.field)) {
295
292
  field = this._field(obj.field, `groupBy[${index}].field`);
296
293
  }
297
294
  this._fieldXorRaw(field, raw, `groupBy[${index}].field`);
@@ -303,7 +300,7 @@ class QueryParser {
303
300
  }
304
301
  }
305
302
  // Case 2B: K
306
- else if ((0, common_1.isText)(item)) {
303
+ else if (isText(item)) {
307
304
  newGroup.push({ field: item });
308
305
  }
309
306
  else {
@@ -318,7 +315,7 @@ class QueryParser {
318
315
  return newGroup;
319
316
  }
320
317
  _orderBy(given, _availableFields, _name) {
321
- if ((0, common_1.isEmpty)(given)) {
318
+ if (isEmpty(given)) {
322
319
  return [];
323
320
  }
324
321
  // Cases:
@@ -327,7 +324,7 @@ class QueryParser {
327
324
  // 3 - OrderByValue<K>
328
325
  const newOrder = [];
329
326
  // case 1: string as K
330
- if ((0, common_1.isText)(given)) {
327
+ if (isText(given)) {
331
328
  newOrder.push({ field: given, asc: true });
332
329
  }
333
330
  // case 2: array as Array<OrderByGiven<K>|K|OrderByGivenRaw>
@@ -338,15 +335,15 @@ class QueryParser {
338
335
  const arr = given;
339
336
  arr.forEach((item, index) => {
340
337
  // Case 2A: OrderByGiven<K>|OrderByGivenRaw
341
- if ((0, type_1.isBareObject)(item)) {
338
+ if (isFilledObj(item)) {
342
339
  let asc;
343
340
  let field;
344
341
  let raw;
345
342
  const obj = item;
346
- if (!(0, common_1.isEmpty)(obj.raw)) {
343
+ if (!isEmpty(obj.raw)) {
347
344
  raw = this._raw(obj.raw, `orderBy[${index}].raw`);
348
345
  }
349
- if (!(0, common_1.isEmpty)(obj.field)) {
346
+ if (!isEmpty(obj.field)) {
350
347
  field = this._field(obj.field, `orderBy[${index}].field`);
351
348
  }
352
349
  this._fieldXorRaw(field, raw, `orderBy[${index}].field`);
@@ -359,7 +356,7 @@ class QueryParser {
359
356
  }
360
357
  }
361
358
  // Case 2B: K
362
- else if ((0, common_1.isText)(item)) {
359
+ else if (isText(item)) {
363
360
  newOrder.push({ field: this._field(item, ''), asc: true });
364
361
  }
365
362
  // other
@@ -369,7 +366,7 @@ class QueryParser {
369
366
  });
370
367
  }
371
368
  // case 3: {'id': true, name: true, ...} as OrderByValue<K>
372
- else if ((0, type_1.isBareObject)(given)) {
369
+ else if (isFilledObj(given)) {
373
370
  let index = 0;
374
371
  for (let [k, v] of Object.entries(given)) {
375
372
  const field = this._field(k, `orderBy(key=${index})`);
@@ -385,8 +382,7 @@ class QueryParser {
385
382
  return newOrder;
386
383
  }
387
384
  _pagination(given, _name) {
388
- var _a;
389
- if ((0, common_1.isEmpty)(given)) {
385
+ if (isEmpty(given)) {
390
386
  return {};
391
387
  }
392
388
  // Case 1: PaginationLiteral
@@ -400,16 +396,16 @@ class QueryParser {
400
396
  };
401
397
  }
402
398
  // Case 2: PaginationPage | PaginationLimit
403
- else if ((0, type_1.isBareObject)(given)) {
399
+ else if (isFilledObj(given)) {
404
400
  if (Object.keys(given).length < 1) {
405
401
  return {};
406
402
  }
407
403
  const obj = given;
408
- if (!(0, common_1.isEmpty)(obj.page)) {
404
+ if (!isEmpty(obj.page)) {
409
405
  const page = this._num(obj.page, `pagination.page`, 1);
410
- const size = (_a = this._num(obj.size, `pagination.size`, 1)) !== null && _a !== void 0 ? _a : 50;
406
+ const size = this._num(obj.size, `pagination.size`, 1) ?? 50;
411
407
  ['limit', 'offset'].forEach(f => {
412
- if (!(0, common_1.isEmpty)(given[f])) {
408
+ if (!isEmpty(given[f])) {
413
409
  throw this._error('page:conflict', 'If you give page; limit and offset can not be used anymore', `pagination.page`);
414
410
  }
415
411
  });
@@ -418,9 +414,9 @@ class QueryParser {
418
414
  offset: (page - 1) * size
419
415
  };
420
416
  }
421
- if (!(0, common_1.isEmpty)(obj.limit)) {
417
+ if (!isEmpty(obj.limit)) {
422
418
  ['page', 'size'].forEach(f => {
423
- if (!(0, common_1.isEmpty)(obj[f])) {
419
+ if (!isEmpty(obj[f])) {
424
420
  throw this._error('limit:conflict', 'If you give limit; page and size can not be used anymore', `pagination.limit`);
425
421
  }
426
422
  });
@@ -436,14 +432,15 @@ class QueryParser {
436
432
  // endregion parts
437
433
  exec(query, availableFields, name) {
438
434
  return {
439
- select: this._select(query === null || query === void 0 ? void 0 : query.select, availableFields, name),
440
- where: this._where('where', query === null || query === void 0 ? void 0 : query.where, availableFields, name),
441
- having: this._where('having', query === null || query === void 0 ? void 0 : query.having, availableFields, name),
442
- groupBy: this._groupBy(query === null || query === void 0 ? void 0 : query.groupBy, availableFields, name),
443
- orderBy: this._orderBy(query === null || query === void 0 ? void 0 : query.orderBy, availableFields, name),
444
- pagination: this._pagination(query === null || query === void 0 ? void 0 : query.pagination, name),
435
+ select: this._select(query?.select, availableFields, name),
436
+ where: this._where('where', query?.where, availableFields, name),
437
+ having: this._where('having', query?.having, availableFields, name),
438
+ groupBy: this._groupBy(query?.groupBy, availableFields, name),
439
+ orderBy: this._orderBy(query?.orderBy, availableFields, name),
440
+ pagination: this._pagination(query?.pagination, name),
445
441
  };
446
442
  }
447
443
  }
444
+ setFqn(QueryParser, FQN);
448
445
  // noinspection JSUnusedGlobalSymbols
449
- exports.queryParser = new QueryParser();
446
+ export const queryParser = new QueryParser();
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,8 +1,8 @@
1
- import { Select, SelectAny } from "../select";
2
- import { Where, WhereAny } from "../where";
3
- import { GroupBy, GroupByAny } from "../group-by";
4
- import { OrderBy, OrderByAny } from "../order-by";
5
- import { PaginationAny, PaginationLimit } from "../pagination";
1
+ import { Select, SelectAny } from "../select/index.js";
2
+ import { Where, WhereAny } from "../where/index.js";
3
+ import { GroupBy, GroupByAny } from "../group-by/index.js";
4
+ import { OrderBy, OrderByAny } from "../order-by/index.js";
5
+ import { PaginationAny, PaginationLimit } from "../pagination/index.js";
6
6
  export interface QueryAny<K extends string> {
7
7
  select?: SelectAny<K>;
8
8
  where?: WhereAny<K>;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,4 +1,4 @@
1
- import { FieldAs, FieldRaw, FieldRegular } from "../field";
1
+ import { FieldAs, FieldRaw, FieldRegular } from "../field/index.js";
2
2
  export type SelectAny<K extends string> = '*' | Array<K | [K, string] | SelectGiven<K> | SelectGivenRaw>;
3
3
  export type SelectGiven<K extends string> = FieldRegular<K> & FieldAs;
4
4
  export type SelectGivenRaw = FieldRaw & FieldAs;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1 +1 @@
1
- export * from './index.types';
1
+ export * from './index.types.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./index.types"), exports);
1
+ export * from './index.types.js';
@@ -1,5 +1,5 @@
1
- import { OperationType } from "../operation";
2
- import { FieldRaw, FieldRegular } from "../field";
1
+ import { OperationType } from "../operation/index.js";
2
+ import { FieldRaw, FieldRegular } from "../field/index.js";
3
3
  export type WhereValue<K extends string> = {
4
4
  [P in K]: unknown;
5
5
  };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leyyo/query",
3
- "version": "1.3.1",
3
+ "version": "1.3.4",
4
4
  "description": "Query common component",
5
5
  "keywords": [
6
6
  "Query"
@@ -19,13 +19,13 @@
19
19
  "email": "mustafayelmer@gmail.com"
20
20
  },
21
21
  "main": "dist/index.js",
22
- "type": "commonjs",
22
+ "type": "module",
23
23
  "scripts": {
24
24
  "clear": "rimraf dist && rimraf coverage",
25
25
  "clear:nm": "rimraf node_modules && npm run clear",
26
26
  "lint": "eslint src/**/*.ts --quiet",
27
27
  "lint:verbose": "eslint src/**/*.ts",
28
- "asset": "node -r ts-node/register commands/assets.ts",
28
+ "asset": "node -r ts-node/register commands/assets.js",
29
29
  "build": "npm run clear && tsc && npm run asset",
30
30
  "test": "jest --config=jest.json --detectOpenHandles",
31
31
  "coverage": "rimraf coverage && jest --config=jest.json --coverage --coverageDirectory=coverage",
@@ -66,7 +66,6 @@
66
66
  }
67
67
  },
68
68
  "dependencies": {
69
- "@leyyo/common": "^1.3.7",
70
- "@leyyo/type": "^1.3.3"
69
+ "@leyyo/common": "^1.3.12"
71
70
  }
72
71
  }
File without changes