@dcupl/common 0.0.81-beta.1 → 0.0.81-beta.3

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 (39) hide show
  1. package/dist/lib-cjs/getFacets.d.ts +2 -0
  2. package/dist/lib-cjs/getFacets.js +140 -0
  3. package/dist/lib-cjs/getFacets.js.map +1 -0
  4. package/dist/lib-cjs/index.d.ts +2 -0
  5. package/dist/lib-cjs/index.js +2 -0
  6. package/dist/lib-cjs/index.js.map +1 -1
  7. package/dist/lib-cjs/query-builder.d.ts +22 -0
  8. package/dist/lib-cjs/query-builder.js +229 -0
  9. package/dist/lib-cjs/query-builder.js.map +1 -0
  10. package/dist/lib-cjs/queryData.d.ts +2 -2
  11. package/dist/lib-cjs/queryData.js +284 -70
  12. package/dist/lib-cjs/queryData.js.map +1 -1
  13. package/dist/lib-cjs/tsconfig-cjs.tsbuildinfo +1 -1
  14. package/dist/lib-cjs/types/dcupl.types.d.ts +44 -13
  15. package/dist/lib-cjs/types/dcupl.types.js +12 -0
  16. package/dist/lib-cjs/types/dcupl.types.js.map +1 -1
  17. package/dist/lib-cjs/types/filter.types.d.ts +4 -3
  18. package/dist/lib-cjs/types/filter.types.js.map +1 -1
  19. package/dist/lib-cjs/types/list.types.d.ts +2 -2
  20. package/dist/lib-esm/getFacets.d.ts +2 -0
  21. package/dist/lib-esm/getFacets.js +136 -0
  22. package/dist/lib-esm/getFacets.js.map +1 -0
  23. package/dist/lib-esm/index.d.ts +2 -0
  24. package/dist/lib-esm/index.js +2 -0
  25. package/dist/lib-esm/index.js.map +1 -1
  26. package/dist/lib-esm/query-builder.d.ts +22 -0
  27. package/dist/lib-esm/query-builder.js +226 -0
  28. package/dist/lib-esm/query-builder.js.map +1 -0
  29. package/dist/lib-esm/queryData.d.ts +2 -2
  30. package/dist/lib-esm/queryData.js +285 -71
  31. package/dist/lib-esm/queryData.js.map +1 -1
  32. package/dist/lib-esm/tsconfig.tsbuildinfo +1 -1
  33. package/dist/lib-esm/types/dcupl.types.d.ts +44 -13
  34. package/dist/lib-esm/types/dcupl.types.js +11 -1
  35. package/dist/lib-esm/types/dcupl.types.js.map +1 -1
  36. package/dist/lib-esm/types/filter.types.d.ts +4 -3
  37. package/dist/lib-esm/types/filter.types.js.map +1 -1
  38. package/dist/lib-esm/types/list.types.d.ts +2 -2
  39. package/package.json +1 -1
@@ -50,29 +50,60 @@ export type DcuplGlobalQueryOptions<T> = DcuplItemsOptions<T> & {
50
50
  listKey: string;
51
51
  query: FilterOptions[];
52
52
  };
53
- type DcuplQueryTransformOptions = 'none' | 'lowercase' | 'uppercase' | 'trim' | 'removeWhitespace';
53
+ export type DcuplQueryTransformOptions = 'lowercase' | 'trim' | 'removeWhitespace';
54
54
  type DcuplQueryOptions = {
55
- transform: DcuplQueryTransformOptions[];
55
+ transform?: DcuplQueryTransformOptions[];
56
+ /**
57
+ * Invert possible for eq, typeof
58
+ */
59
+ invert?: boolean;
56
60
  };
57
- type DcuplQueryArrayOperators = 'in' | 'nin';
58
- type DcuplQueryStringOperators = 'startsWith' | 'endsWith' | 'includes' | 'notIncludes';
59
- type DcuplQueryGeneralOperators = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
60
- type DcuplQueryFalsy = 'isUndefined' | 'isNotUndefined' | 'isNull' | 'isNotNull' | 'isFalsy' | 'isTruthy';
61
- export type DcuplQueryOperator = DcuplQueryGeneralOperators | DcuplQueryArrayOperators | DcuplQueryFalsy | DcuplQueryStringOperators;
61
+ export declare const DcuplQueryOperatorsAsArray: readonly ["eq", "find", "gt", "gte", "lt", "lte", "typeof", "isTruthy", "size"];
62
+ export type DcuplQueryOperator = (typeof DcuplQueryOperatorsAsArray)[number];
62
63
  export type DcuplQueryType = 'and' | 'or';
63
- export type DcuplQuery = {
64
+ type DcuplQueryBase = {
65
+ /**
66
+ * title, something.key someArray[0].key
67
+ * */
64
68
  attribute: string;
65
- operator: DcuplQueryOperator;
66
- value: any;
67
69
  options?: DcuplQueryOptions;
68
70
  };
69
- export type DcuplQueryGroup = {
71
+ type DcuplQueryEq = DcuplQueryBase & {
72
+ operator: 'eq';
73
+ /**
74
+ * You may search for any value but
75
+ * only values of type string and { key:string } may be used for indexed search
76
+ */
77
+ value: any;
78
+ };
79
+ type DcuplQueryFind = DcuplQueryBase & {
80
+ operator: 'find';
81
+ value: Record<string, unknown> | string;
82
+ };
83
+ type DcuplQueryNumbers = DcuplQueryBase & {
84
+ operator: 'gt' | 'lt' | 'gte' | 'lte';
85
+ value: string | number | Date;
86
+ };
87
+ type DcuplQueryTypeOf = DcuplQueryBase & {
88
+ operator: 'typeof';
89
+ value: string;
90
+ };
91
+ type DcuplQueryIsTruthy = DcuplQueryBase & {
92
+ operator: 'isTruthy';
93
+ value: boolean;
94
+ };
95
+ type DcuplQuerySize = DcuplQueryBase & {
96
+ operator: 'size';
97
+ value: number;
98
+ };
99
+ export type DcuplQuery = DcuplQueryEq | DcuplQueryNumbers | DcuplQueryTypeOf | DcuplQueryIsTruthy | DcuplQuerySize | DcuplQueryFind;
100
+ export type DcuplQueryGroup<QueryType extends DcuplQuery | DcuplQueryGroup = DcuplQuery> = {
70
101
  queryType?: DcuplQueryType;
71
102
  queryKey?: string;
72
- query: Array<DcuplQuery> | Array<DcuplQueryGroup>;
103
+ query: Array<QueryType>;
73
104
  options?: DcuplQueryOptions;
74
105
  };
75
106
  export type DcuplGlobalQueryOptionsNew<T> = DcuplItemsOptions<T> & {
76
107
  listKey: string;
77
- } & DcuplQueryGroup;
108
+ } & DcuplQueryGroup<DcuplQueryGroup<DcuplQuery>>;
78
109
  export {};
@@ -1,2 +1,12 @@
1
- export {};
1
+ export var DcuplQueryOperatorsAsArray = [
2
+ 'eq',
3
+ 'find',
4
+ 'gt',
5
+ 'gte',
6
+ 'lt',
7
+ 'lte',
8
+ 'typeof',
9
+ 'isTruthy',
10
+ 'size',
11
+ ];
2
12
  //# sourceMappingURL=dcupl.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dcupl.types.js","sourceRoot":"","sources":["../../../src/types/dcupl.types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"dcupl.types.js","sourceRoot":"","sources":["../../../src/types/dcupl.types.ts"],"names":[],"mappings":"AAkEA,MAAM,CAAC,IAAM,0BAA0B,GAAG;IACxC,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,UAAU;IACV,MAAM;CACE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { ListItem } from '.';
1
+ import { DcuplQueryGroup, ListItem } from '.';
2
2
  import { CatalogApiOptions } from './list.types';
3
3
  import { FilterComparisonType } from './model.types';
4
4
  export type ConstraintTypes = 'referenceConstraint' | 'textConstraint' | 'numberConstraint' | 'dateConstraint' | 'booleanConstraint';
@@ -7,6 +7,7 @@ export type ConstraintBase = {
7
7
  filterKey: string;
8
8
  attributeKey: string;
9
9
  type: ConstraintTypes;
10
+ query?: any;
10
11
  };
11
12
  export type ReferenceConstraint = ConstraintBase & {
12
13
  type: 'referenceConstraint';
@@ -90,12 +91,12 @@ export type BooleanFilterItem = FilterItemBase & {
90
91
  export type FilterItemNumberRangeValue = {
91
92
  available: FilterEntryNumberRange;
92
93
  initial: FilterEntryNumberRange;
93
- selected: NumberConstraintOperators[];
94
+ relatedQuery: DcuplQueryGroup | undefined;
94
95
  };
95
96
  export type FilterItemDateRangeValue = {
96
97
  available: FilterEntryDateRange;
97
98
  initial: FilterEntryDateRange;
98
- selected: DateConstraintOperators[];
99
+ relatedQuery: DcuplQueryGroup | undefined;
99
100
  };
100
101
  export type ReferenceFilterItem = FilterItemBase & {
101
102
  type: 'reference';
@@ -1 +1 @@
1
- {"version":3,"file":"filter.types.js","sourceRoot":"","sources":["../../../src/types/filter.types.ts"],"names":[],"mappings":"AAoDA,MAAM,CAAC,IAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"filter.types.js","sourceRoot":"","sources":["../../../src/types/filter.types.ts"],"names":[],"mappings":"AAqDA,MAAM,CAAC,IAAM,eAAe,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FilterConstraint } from './filter.types';
1
+ import { DcuplGlobalQueryOptionsNew } from './dcupl.types';
2
2
  import { ViewDefinition, ModelAttribute } from './model.types';
3
3
  import { Projection, SortingProjection } from './projection.types';
4
4
  export type DcuplItemsOptions<T> = {
@@ -52,7 +52,7 @@ export type ListMetadata = {
52
52
  key: string;
53
53
  currentSize: number;
54
54
  initialSize: number;
55
- appliedFilters: FilterConstraint[];
55
+ appliedQuery: DcuplGlobalQueryOptionsNew<any>;
56
56
  attributes: ModelAttribute[];
57
57
  itemOptions: DcuplItemsOptions<any>;
58
58
  views: ViewDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcupl/common",
3
- "version": "0.0.81-beta.1",
3
+ "version": "0.0.81-beta.3",
4
4
  "description": "Dcupl Common Code",
5
5
  "main": "dist/lib-cjs/index.js",
6
6
  "module": "dist/lib-esm/index.js",