@webiny/db-dynamodb 6.1.0 → 6.2.0-beta.0

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 (133) hide show
  1. package/exports/api/db.d.ts +2 -0
  2. package/exports/api/db.js +4 -0
  3. package/exports/api/db.js.map +1 -0
  4. package/feature/FilterUtil/FilterUtil.d.ts +11 -0
  5. package/feature/FilterUtil/FilterUtil.js +28 -0
  6. package/feature/FilterUtil/FilterUtil.js.map +1 -0
  7. package/feature/FilterUtil/abstractions/FilterUtil.d.ts +17 -0
  8. package/feature/FilterUtil/abstractions/FilterUtil.js +4 -0
  9. package/feature/FilterUtil/abstractions/FilterUtil.js.map +1 -0
  10. package/feature/FilterUtil/createFilters.d.ts +22 -0
  11. package/{utils/filter.js → feature/FilterUtil/createFilters.js} +20 -64
  12. package/feature/FilterUtil/createFilters.js.map +1 -0
  13. package/feature/FilterUtil/extractWhereArgs.d.ts +7 -0
  14. package/feature/FilterUtil/extractWhereArgs.js +24 -0
  15. package/feature/FilterUtil/extractWhereArgs.js.map +1 -0
  16. package/feature/FilterUtil/feature.d.ts +1 -0
  17. package/feature/FilterUtil/feature.js +10 -0
  18. package/feature/FilterUtil/feature.js.map +1 -0
  19. package/feature/FilterUtil/index.d.ts +2 -0
  20. package/feature/FilterUtil/index.js +4 -0
  21. package/feature/FilterUtil/index.js.map +1 -0
  22. package/feature/ValueFilter/ValueFilterRegistry.d.ts +12 -0
  23. package/feature/ValueFilter/ValueFilterRegistry.js +23 -0
  24. package/feature/ValueFilter/ValueFilterRegistry.js.map +1 -0
  25. package/feature/ValueFilter/abstractions/ValueFilter.d.ts +22 -0
  26. package/feature/ValueFilter/abstractions/ValueFilter.js +4 -0
  27. package/feature/ValueFilter/abstractions/ValueFilter.js.map +1 -0
  28. package/feature/ValueFilter/abstractions/ValueFilterRegistry.d.ts +10 -0
  29. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js +4 -0
  30. package/feature/ValueFilter/abstractions/ValueFilterRegistry.js.map +1 -0
  31. package/feature/ValueFilter/feature.d.ts +1 -0
  32. package/feature/ValueFilter/feature.js +32 -0
  33. package/feature/ValueFilter/feature.js.map +1 -0
  34. package/feature/ValueFilter/filters/AndInFilter.d.ts +11 -0
  35. package/feature/ValueFilter/filters/AndInFilter.js +32 -0
  36. package/feature/ValueFilter/filters/AndInFilter.js.map +1 -0
  37. package/feature/ValueFilter/filters/BetweenFilter.d.ts +11 -0
  38. package/{plugins/filters/between.js → feature/ValueFilter/filters/BetweenFilter.js} +17 -9
  39. package/feature/ValueFilter/filters/BetweenFilter.js.map +1 -0
  40. package/feature/ValueFilter/filters/ContainsFilter.d.ts +11 -0
  41. package/{plugins/filters/contains.js → feature/ValueFilter/filters/ContainsFilter.js} +16 -8
  42. package/feature/ValueFilter/filters/ContainsFilter.js.map +1 -0
  43. package/feature/ValueFilter/filters/EqFilter.d.ts +11 -0
  44. package/{plugins/filters/eq.js → feature/ValueFilter/filters/EqFilter.js} +16 -8
  45. package/feature/ValueFilter/filters/EqFilter.js.map +1 -0
  46. package/feature/ValueFilter/filters/FuzzyFilter.d.ts +11 -0
  47. package/{plugins/filters/fuzzy.js → feature/ValueFilter/filters/FuzzyFilter.js} +16 -8
  48. package/feature/ValueFilter/filters/FuzzyFilter.js.map +1 -0
  49. package/feature/ValueFilter/filters/GtFilter.d.ts +11 -0
  50. package/feature/ValueFilter/filters/GtFilter.js +22 -0
  51. package/feature/ValueFilter/filters/GtFilter.js.map +1 -0
  52. package/feature/ValueFilter/filters/GteFilter.d.ts +11 -0
  53. package/feature/ValueFilter/filters/GteFilter.js +22 -0
  54. package/feature/ValueFilter/filters/GteFilter.js.map +1 -0
  55. package/feature/ValueFilter/filters/InFilter.d.ts +11 -0
  56. package/feature/ValueFilter/filters/InFilter.js +32 -0
  57. package/feature/ValueFilter/filters/InFilter.js.map +1 -0
  58. package/feature/ValueFilter/filters/LtFilter.d.ts +11 -0
  59. package/feature/ValueFilter/filters/LtFilter.js +22 -0
  60. package/feature/ValueFilter/filters/LtFilter.js.map +1 -0
  61. package/feature/ValueFilter/filters/LteFilter.d.ts +11 -0
  62. package/feature/ValueFilter/filters/LteFilter.js +22 -0
  63. package/feature/ValueFilter/filters/LteFilter.js.map +1 -0
  64. package/feature/ValueFilter/filters/StartsWithFilter.d.ts +11 -0
  65. package/{plugins/filters/startsWith.js → feature/ValueFilter/filters/StartsWithFilter.js} +22 -11
  66. package/feature/ValueFilter/filters/StartsWithFilter.js.map +1 -0
  67. package/feature/ValueFilter/index.d.ts +3 -0
  68. package/feature/ValueFilter/index.js +5 -0
  69. package/feature/ValueFilter/index.js.map +1 -0
  70. package/index.d.ts +1 -0
  71. package/index.js +9 -0
  72. package/index.js.map +1 -1
  73. package/package.json +16 -13
  74. package/plugins/definitions/ValueTransformPlugin.d.ts +1 -6
  75. package/plugins/definitions/ValueTransformPlugin.js +0 -6
  76. package/plugins/definitions/ValueTransformPlugin.js.map +1 -1
  77. package/plugins/index.d.ts +0 -5
  78. package/plugins/index.js +0 -10
  79. package/plugins/index.js.map +1 -1
  80. package/utils/index.d.ts +1 -5
  81. package/utils/index.js +1 -5
  82. package/utils/index.js.map +1 -1
  83. package/plugins/definitions/AttributePlugin.d.ts +0 -18
  84. package/plugins/definitions/AttributePlugin.js +0 -38
  85. package/plugins/definitions/AttributePlugin.js.map +0 -1
  86. package/plugins/definitions/FieldPathPlugin.d.ts +0 -22
  87. package/plugins/definitions/FieldPathPlugin.js +0 -26
  88. package/plugins/definitions/FieldPathPlugin.js.map +0 -1
  89. package/plugins/definitions/ValueFilterPlugin.d.ts +0 -22
  90. package/plugins/definitions/ValueFilterPlugin.js +0 -35
  91. package/plugins/definitions/ValueFilterPlugin.js.map +0 -1
  92. package/plugins/filters/andIn.d.ts +0 -3
  93. package/plugins/filters/andIn.js +0 -24
  94. package/plugins/filters/andIn.js.map +0 -1
  95. package/plugins/filters/between.d.ts +0 -3
  96. package/plugins/filters/between.js.map +0 -1
  97. package/plugins/filters/contains.d.ts +0 -3
  98. package/plugins/filters/contains.js.map +0 -1
  99. package/plugins/filters/eq.d.ts +0 -3
  100. package/plugins/filters/eq.js.map +0 -1
  101. package/plugins/filters/fuzzy.d.ts +0 -3
  102. package/plugins/filters/fuzzy.js.map +0 -1
  103. package/plugins/filters/gt.d.ts +0 -3
  104. package/plugins/filters/gt.js +0 -14
  105. package/plugins/filters/gt.js.map +0 -1
  106. package/plugins/filters/gte.d.ts +0 -3
  107. package/plugins/filters/gte.js +0 -14
  108. package/plugins/filters/gte.js.map +0 -1
  109. package/plugins/filters/in.d.ts +0 -3
  110. package/plugins/filters/in.js +0 -24
  111. package/plugins/filters/in.js.map +0 -1
  112. package/plugins/filters/index.d.ts +0 -2
  113. package/plugins/filters/index.js +0 -14
  114. package/plugins/filters/index.js.map +0 -1
  115. package/plugins/filters/lt.d.ts +0 -3
  116. package/plugins/filters/lt.js +0 -14
  117. package/plugins/filters/lt.js.map +0 -1
  118. package/plugins/filters/lte.d.ts +0 -3
  119. package/plugins/filters/lte.js +0 -14
  120. package/plugins/filters/lte.js.map +0 -1
  121. package/plugins/filters/startsWith.d.ts +0 -3
  122. package/plugins/filters/startsWith.js.map +0 -1
  123. package/utils/attributes.d.ts +0 -10
  124. package/utils/attributes.js +0 -19
  125. package/utils/attributes.js.map +0 -1
  126. package/utils/filter.d.ts +0 -12
  127. package/utils/filter.js.map +0 -1
  128. package/utils/listResponse.d.ts +0 -13
  129. package/utils/listResponse.js +0 -25
  130. package/utils/listResponse.js.map +0 -1
  131. package/utils/update.d.ts +0 -12
  132. package/utils/update.js +0 -12
  133. package/utils/update.js.map +0 -1
@@ -1,10 +1,5 @@
1
1
  export * from "./definitions/assignFields.js";
2
- export * from "./definitions/AttributePlugin.js";
3
2
  export * from "./definitions/DateTimeTransformPlugin.js";
4
- export * from "./definitions/FieldPathPlugin.js";
5
3
  export * from "./definitions/FieldPlugin.js";
6
4
  export * from "./definitions/TimeTransformPlugin.js";
7
- export * from "./definitions/ValueFilterPlugin.js";
8
5
  export * from "./definitions/ValueTransformPlugin.js";
9
- declare const _default: () => import("./definitions/ValueFilterPlugin.js").ValueFilterPlugin<any, any>[][];
10
- export default _default;
package/plugins/index.js CHANGED
@@ -1,17 +1,7 @@
1
1
  export * from "./definitions/assignFields.js";
2
- export * from "./definitions/AttributePlugin.js";
3
2
  export * from "./definitions/DateTimeTransformPlugin.js";
4
- export * from "./definitions/FieldPathPlugin.js";
5
3
  export * from "./definitions/FieldPlugin.js";
6
4
  export * from "./definitions/TimeTransformPlugin.js";
7
- export * from "./definitions/ValueFilterPlugin.js";
8
5
  export * from "./definitions/ValueTransformPlugin.js";
9
- /**
10
- * List everything that needs to be loaded by default.
11
- */
12
- import filterPlugins from "./filters/index.js";
13
- export default () => {
14
- return [filterPlugins()];
15
- };
16
6
 
17
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["filterPlugins"],"sources":["index.ts"],"sourcesContent":["export * from \"./definitions/assignFields.js\";\nexport * from \"./definitions/AttributePlugin.js\";\nexport * from \"./definitions/DateTimeTransformPlugin.js\";\nexport * from \"./definitions/FieldPathPlugin.js\";\nexport * from \"./definitions/FieldPlugin.js\";\nexport * from \"./definitions/TimeTransformPlugin.js\";\nexport * from \"./definitions/ValueFilterPlugin.js\";\nexport * from \"./definitions/ValueTransformPlugin.js\";\n/**\n * List everything that needs to be loaded by default.\n */\nimport filterPlugins from \"./filters/index.js\";\n\nexport default () => {\n return [filterPlugins()];\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,aAAa;AAEpB,eAAe,MAAM;EACjB,OAAO,CAACA,aAAa,CAAC,CAAC,CAAC;AAC5B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./definitions/assignFields.js\";\nexport * from \"./definitions/DateTimeTransformPlugin.js\";\nexport * from \"./definitions/FieldPlugin.js\";\nexport * from \"./definitions/TimeTransformPlugin.js\";\nexport * from \"./definitions/ValueTransformPlugin.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
package/utils/index.d.ts CHANGED
@@ -1,17 +1,13 @@
1
1
  export * from "./cleanup.js";
2
2
  export * from "./createEntity.js";
3
3
  export * from "./createTable.js";
4
- export * from "./cursor.js";
5
- export * from "./filter.js";
4
+ export { decodeCursor, encodeCursor } from "./cursor.js";
6
5
  export * from "./get.js";
7
6
  export * from "./delete.js";
8
7
  export * from "./put.js";
9
- export * from "./listResponse.js";
10
8
  export * from "./query.js";
11
- export * from "./count.js";
12
9
  export * from "./scan.js";
13
10
  export * from "./sort.js";
14
- export * from "./update.js";
15
11
  export * from "./batch/index.js";
16
12
  export * from "./entity/index.js";
17
13
  export * from "./table/index.js";
package/utils/index.js CHANGED
@@ -1,17 +1,13 @@
1
1
  export * from "./cleanup.js";
2
2
  export * from "./createEntity.js";
3
3
  export * from "./createTable.js";
4
- export * from "./cursor.js";
5
- export * from "./filter.js";
4
+ export { decodeCursor, encodeCursor } from "./cursor.js";
6
5
  export * from "./get.js";
7
6
  export * from "./delete.js";
8
7
  export * from "./put.js";
9
- export * from "./listResponse.js";
10
8
  export * from "./query.js";
11
- export * from "./count.js";
12
9
  export * from "./scan.js";
13
10
  export * from "./sort.js";
14
- export * from "./update.js";
15
11
  export * from "./batch/index.js";
16
12
  export * from "./entity/index.js";
17
13
  export * from "./table/index.js";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./cleanup.js\";\nexport * from \"./createEntity.js\";\nexport * from \"./createTable.js\";\nexport * from \"./cursor.js\";\nexport * from \"./filter.js\";\nexport * from \"./get.js\";\nexport * from \"./delete.js\";\nexport * from \"./put.js\";\nexport * from \"./listResponse.js\";\nexport * from \"./query.js\";\nexport * from \"./count.js\";\nexport * from \"./scan.js\";\nexport * from \"./sort.js\";\nexport * from \"./update.js\";\nexport * from \"./batch/index.js\";\nexport * from \"./entity/index.js\";\nexport * from \"./table/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["decodeCursor","encodeCursor"],"sources":["index.ts"],"sourcesContent":["export * from \"./cleanup.js\";\nexport * from \"./createEntity.js\";\nexport * from \"./createTable.js\";\nexport { decodeCursor, encodeCursor } from \"./cursor.js\";\nexport * from \"./get.js\";\nexport * from \"./delete.js\";\nexport * from \"./put.js\";\nexport * from \"./query.js\";\nexport * from \"./scan.js\";\nexport * from \"./sort.js\";\nexport * from \"./batch/index.js\";\nexport * from \"./entity/index.js\";\nexport * from \"./table/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,EAAEC,YAAY;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1,18 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import type { AttributeDefinition } from "../../toolbox.js";
3
- export interface AttributePluginParams {
4
- entity: string;
5
- attribute: string;
6
- params: AttributeDefinition;
7
- }
8
- export declare abstract class AttributePlugin extends Plugin {
9
- static readonly type: string;
10
- private readonly _entity;
11
- private readonly _attribute;
12
- private readonly _params;
13
- get entity(): string;
14
- get attribute(): string;
15
- constructor({ entity, attribute, params }: AttributePluginParams);
16
- getDefinition(): Record<string, AttributeDefinition>;
17
- private validateReserved;
18
- }
@@ -1,38 +0,0 @@
1
- import WebinyError from "@webiny/error";
2
- import { Plugin } from "@webiny/plugins";
3
- const reservedFields = ["PK", "SK", "index", "data"];
4
- export class AttributePlugin extends Plugin {
5
- static type = "db.dynamodb.attribute";
6
- get entity() {
7
- return this._entity;
8
- }
9
- get attribute() {
10
- return this._attribute;
11
- }
12
- constructor({
13
- entity,
14
- attribute,
15
- params
16
- }) {
17
- super();
18
- this.validateReserved(attribute);
19
- this._entity = entity;
20
- this._attribute = attribute;
21
- this._params = params;
22
- }
23
- getDefinition() {
24
- return {
25
- [this.attribute]: this._params
26
- };
27
- }
28
- validateReserved(attribute) {
29
- if (reservedFields.includes(attribute) === false) {
30
- return;
31
- }
32
- throw new WebinyError(`Attribute name "${attribute}" is not allowed.`, "ATTRIBUTE_NOT_ALLOWED", {
33
- attribute
34
- });
35
- }
36
- }
37
-
38
- //# sourceMappingURL=AttributePlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["WebinyError","Plugin","reservedFields","AttributePlugin","type","entity","_entity","attribute","_attribute","constructor","params","validateReserved","_params","getDefinition","includes"],"sources":["AttributePlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { AttributeDefinition } from \"~/toolbox.js\";\n\nconst reservedFields = [\"PK\", \"SK\", \"index\", \"data\"];\n\nexport interface AttributePluginParams {\n entity: string;\n attribute: string;\n params: AttributeDefinition;\n}\n\nexport abstract class AttributePlugin extends Plugin {\n public static override readonly type: string = \"db.dynamodb.attribute\";\n private readonly _entity: string;\n private readonly _attribute: string;\n private readonly _params: AttributeDefinition;\n\n public get entity(): string {\n return this._entity;\n }\n\n public get attribute(): string {\n return this._attribute;\n }\n\n public constructor({ entity, attribute, params }: AttributePluginParams) {\n super();\n\n this.validateReserved(attribute);\n\n this._entity = entity;\n this._attribute = attribute;\n this._params = params;\n }\n\n public getDefinition(): Record<string, AttributeDefinition> {\n return {\n [this.attribute]: this._params\n };\n }\n\n private validateReserved(attribute: string): void {\n if (reservedFields.includes(attribute) === false) {\n return;\n }\n throw new WebinyError(\n `Attribute name \"${attribute}\" is not allowed.`,\n \"ATTRIBUTE_NOT_ALLOWED\",\n {\n attribute\n }\n );\n }\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAAQ,iBAAiB;AAGxC,MAAMC,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;AAQpD,OAAO,MAAeC,eAAe,SAASF,MAAM,CAAC;EACjD,OAAgCG,IAAI,GAAW,uBAAuB;EAKtE,IAAWC,MAAMA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACC,OAAO;EACvB;EAEA,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,UAAU;EAC1B;EAEOC,WAAWA,CAAC;IAAEJ,MAAM;IAAEE,SAAS;IAAEG;EAA8B,CAAC,EAAE;IACrE,KAAK,CAAC,CAAC;IAEP,IAAI,CAACC,gBAAgB,CAACJ,SAAS,CAAC;IAEhC,IAAI,CAACD,OAAO,GAAGD,MAAM;IACrB,IAAI,CAACG,UAAU,GAAGD,SAAS;IAC3B,IAAI,CAACK,OAAO,GAAGF,MAAM;EACzB;EAEOG,aAAaA,CAAA,EAAwC;IACxD,OAAO;MACH,CAAC,IAAI,CAACN,SAAS,GAAG,IAAI,CAACK;IAC3B,CAAC;EACL;EAEQD,gBAAgBA,CAACJ,SAAiB,EAAQ;IAC9C,IAAIL,cAAc,CAACY,QAAQ,CAACP,SAAS,CAAC,KAAK,KAAK,EAAE;MAC9C;IACJ;IACA,MAAM,IAAIP,WAAW,CACjB,mBAAmBO,SAAS,mBAAmB,EAC/C,uBAAuB,EACvB;MACIA;IACJ,CACJ,CAAC;EACL;AACJ","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- export interface CreatePath {
3
- (field: string): string;
4
- }
5
- export interface FieldPathPluginParams {
6
- /**
7
- * Which field(s) is this plugin for.
8
- */
9
- fields: string | string[];
10
- /**
11
- * Create a path for given field.
12
- * Field is passed because it can be a multi-field plugin.
13
- */
14
- createPath: CreatePath;
15
- }
16
- export declare class FieldPathPlugin extends Plugin {
17
- static readonly type: string;
18
- private readonly _params;
19
- constructor(params: FieldPathPluginParams);
20
- canCreate(field: string): boolean;
21
- createPath(field: string): string;
22
- }
@@ -1,26 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import WebinyError from "@webiny/error";
3
- import { assignFields } from "./assignFields.js";
4
- export class FieldPathPlugin extends Plugin {
5
- static type = "dynamodb.value.path";
6
- constructor(params) {
7
- super();
8
- this._params = {
9
- ...params,
10
- fields: assignFields(params.fields)
11
- };
12
- }
13
- canCreate(field) {
14
- return this._params.fields.includes(field);
15
- }
16
- createPath(field) {
17
- if (!this._params.createPath) {
18
- throw new WebinyError(`Missing "createPath" in the plugin.`, "TRANSFORM_ERROR", {
19
- fields: this._params.fields
20
- });
21
- }
22
- return this._params.createPath(field);
23
- }
24
- }
25
-
26
- //# sourceMappingURL=FieldPathPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Plugin","WebinyError","assignFields","FieldPathPlugin","type","constructor","params","_params","fields","canCreate","field","includes","createPath"],"sources":["FieldPathPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\nimport { assignFields } from \"./assignFields.js\";\n\nexport interface CreatePath {\n (field: string): string;\n}\nexport interface FieldPathPluginParams {\n /**\n * Which field(s) is this plugin for.\n */\n fields: string | string[];\n /**\n * Create a path for given field.\n * Field is passed because it can be a multi-field plugin.\n */\n createPath: CreatePath;\n}\n\nexport class FieldPathPlugin extends Plugin {\n public static override readonly type: string = \"dynamodb.value.path\";\n private readonly _params: Omit<FieldPathPluginParams, \"fields\"> & { fields: string[] };\n\n public constructor(params: FieldPathPluginParams) {\n super();\n this._params = {\n ...params,\n fields: assignFields(params.fields)\n };\n }\n\n public canCreate(field: string): boolean {\n return this._params.fields.includes(field);\n }\n\n public createPath(field: string): string {\n if (!this._params.createPath) {\n throw new WebinyError(`Missing \"createPath\" in the plugin.`, \"TRANSFORM_ERROR\", {\n fields: this._params.fields\n });\n }\n return this._params.createPath(field);\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,YAAY;AAiBrB,OAAO,MAAMC,eAAe,SAASH,MAAM,CAAC;EACxC,OAAgCI,IAAI,GAAW,qBAAqB;EAG7DC,WAAWA,CAACC,MAA6B,EAAE;IAC9C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,OAAO,GAAG;MACX,GAAGD,MAAM;MACTE,MAAM,EAAEN,YAAY,CAACI,MAAM,CAACE,MAAM;IACtC,CAAC;EACL;EAEOC,SAASA,CAACC,KAAa,EAAW;IACrC,OAAO,IAAI,CAACH,OAAO,CAACC,MAAM,CAACG,QAAQ,CAACD,KAAK,CAAC;EAC9C;EAEOE,UAAUA,CAACF,KAAa,EAAU;IACrC,IAAI,CAAC,IAAI,CAACH,OAAO,CAACK,UAAU,EAAE;MAC1B,MAAM,IAAIX,WAAW,CAAC,qCAAqC,EAAE,iBAAiB,EAAE;QAC5EO,MAAM,EAAE,IAAI,CAACD,OAAO,CAACC;MACzB,CAAC,CAAC;IACN;IACA,OAAO,IAAI,CAACD,OAAO,CAACK,UAAU,CAACF,KAAK,CAAC;EACzC;AACJ","ignoreList":[]}
@@ -1,22 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- export interface ValueFilterPluginParamsMatchesParams<V = any, C = any> {
3
- value: V;
4
- compareValue: C;
5
- }
6
- export interface ValueFilterPluginParamsMatches {
7
- (params: ValueFilterPluginParamsMatchesParams): boolean;
8
- }
9
- export interface ValueFilterPluginParams {
10
- operation: string;
11
- canUse?: (params: ValueFilterPluginParamsMatchesParams) => boolean;
12
- matches: ValueFilterPluginParamsMatches;
13
- }
14
- export declare class ValueFilterPlugin<V = any, C = any> extends Plugin {
15
- static readonly type: string;
16
- private readonly _params;
17
- get operation(): string;
18
- constructor(params: ValueFilterPluginParams);
19
- canUse(params: ValueFilterPluginParamsMatchesParams<V, C>): boolean;
20
- matches(params: ValueFilterPluginParamsMatchesParams): boolean;
21
- getOperation(): string;
22
- }
@@ -1,35 +0,0 @@
1
- import { Plugin } from "@webiny/plugins";
2
- import WebinyError from "@webiny/error";
3
- export class ValueFilterPlugin extends Plugin {
4
- static type = "dynamodb.value.filter";
5
- get operation() {
6
- return this.getOperation();
7
- }
8
- constructor(params) {
9
- super();
10
- this._params = params;
11
- }
12
- canUse(params) {
13
- if (!this._params.canUse) {
14
- return true;
15
- }
16
- return this._params.canUse(params);
17
- }
18
- matches(params) {
19
- if (!this._params || !this._params.matches) {
20
- throw new WebinyError(`Missing "matches" in the plugin.`, "MATCHES_ERROR", {
21
- plugin: this,
22
- params
23
- });
24
- }
25
- return this._params.matches(params);
26
- }
27
- getOperation() {
28
- if (!this._params || !this._params.operation) {
29
- throw new WebinyError(`Missing "operation" in the plugin.`, "OPERATION_ERROR");
30
- }
31
- return this._params.operation;
32
- }
33
- }
34
-
35
- //# sourceMappingURL=ValueFilterPlugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Plugin","WebinyError","ValueFilterPlugin","type","operation","getOperation","constructor","params","_params","canUse","matches","plugin"],"sources":["ValueFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\nexport interface ValueFilterPluginParamsMatchesParams<V = any, C = any> {\n value: V;\n compareValue: C;\n}\n\nexport interface ValueFilterPluginParamsMatches {\n (params: ValueFilterPluginParamsMatchesParams): boolean;\n}\n\nexport interface ValueFilterPluginParams {\n operation: string;\n canUse?: (params: ValueFilterPluginParamsMatchesParams) => boolean;\n matches: ValueFilterPluginParamsMatches;\n}\nexport class ValueFilterPlugin<V = any, C = any> extends Plugin {\n public static override readonly type: string = \"dynamodb.value.filter\";\n private readonly _params: ValueFilterPluginParams;\n\n public get operation(): string {\n return this.getOperation();\n }\n\n public constructor(params: ValueFilterPluginParams) {\n super();\n this._params = params;\n }\n\n public canUse(params: ValueFilterPluginParamsMatchesParams<V, C>): boolean {\n if (!this._params.canUse) {\n return true;\n }\n return this._params.canUse(params);\n }\n\n public matches(params: ValueFilterPluginParamsMatchesParams): boolean {\n if (!this._params || !this._params.matches) {\n throw new WebinyError(`Missing \"matches\" in the plugin.`, \"MATCHES_ERROR\", {\n plugin: this,\n params\n });\n }\n return this._params.matches(params);\n }\n\n public getOperation(): string {\n if (!this._params || !this._params.operation) {\n throw new WebinyError(`Missing \"operation\" in the plugin.`, \"OPERATION_ERROR\");\n }\n return this._params.operation;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AACxC,OAAOC,WAAW,MAAM,eAAe;AAgBvC,OAAO,MAAMC,iBAAiB,SAA2BF,MAAM,CAAC;EAC5D,OAAgCG,IAAI,GAAW,uBAAuB;EAGtE,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,YAAY,CAAC,CAAC;EAC9B;EAEOC,WAAWA,CAACC,MAA+B,EAAE;IAChD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,OAAO,GAAGD,MAAM;EACzB;EAEOE,MAAMA,CAACF,MAAkD,EAAW;IACvE,IAAI,CAAC,IAAI,CAACC,OAAO,CAACC,MAAM,EAAE;MACtB,OAAO,IAAI;IACf;IACA,OAAO,IAAI,CAACD,OAAO,CAACC,MAAM,CAACF,MAAM,CAAC;EACtC;EAEOG,OAAOA,CAACH,MAA4C,EAAW;IAClE,IAAI,CAAC,IAAI,CAACC,OAAO,IAAI,CAAC,IAAI,CAACA,OAAO,CAACE,OAAO,EAAE;MACxC,MAAM,IAAIT,WAAW,CAAC,kCAAkC,EAAE,eAAe,EAAE;QACvEU,MAAM,EAAE,IAAI;QACZJ;MACJ,CAAC,CAAC;IACN;IACA,OAAO,IAAI,CAACC,OAAO,CAACE,OAAO,CAACH,MAAM,CAAC;EACvC;EAEOF,YAAYA,CAAA,EAAW;IAC1B,IAAI,CAAC,IAAI,CAACG,OAAO,IAAI,CAAC,IAAI,CAACA,OAAO,CAACJ,SAAS,EAAE;MAC1C,MAAM,IAAIH,WAAW,CAAC,oCAAoC,EAAE,iBAAiB,CAAC;IAClF;IACA,OAAO,IAAI,CAACO,OAAO,CAACJ,SAAS;EACjC;AACJ","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,24 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- import WebinyError from "@webiny/error";
3
- const plugin = new ValueFilterPlugin({
4
- operation: "and_in",
5
- matches: ({
6
- value,
7
- compareValue
8
- }) => {
9
- if (!compareValue || Array.isArray(compareValue) === false) {
10
- throw new WebinyError(`The value given as "compareValue" must be an array!`, "COMPARE_VALUE_ERROR", {
11
- value,
12
- compareValue
13
- });
14
- }
15
- if (Array.isArray(value) === true) {
16
- return compareValue.every(c => value.includes(c));
17
- }
18
- return compareValue.includes(value);
19
- }
20
- });
21
- plugin.name = "dynamodb.value.filter.and_in";
22
- export default plugin;
23
-
24
- //# sourceMappingURL=andIn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","WebinyError","plugin","operation","matches","value","compareValue","Array","isArray","every","c","includes","name"],"sources":["andIn.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\nconst plugin = new ValueFilterPlugin({\n operation: \"and_in\",\n matches: ({ value, compareValue }: MatchesParams) => {\n if (!compareValue || Array.isArray(compareValue) === false) {\n throw new WebinyError(\n `The value given as \"compareValue\" must be an array!`,\n \"COMPARE_VALUE_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n if (Array.isArray(value) === true) {\n return compareValue.every(c => value.includes(c));\n }\n return compareValue.includes(value);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.and_in\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,OAAOC,WAAW,MAAM,eAAe;AAOvC,MAAMC,MAAM,GAAG,IAAIF,iBAAiB,CAAC;EACjCG,SAAS,EAAE,QAAQ;EACnBC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAA4B,CAAC,KAAK;IACjD,IAAI,CAACA,YAAY,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,KAAK,EAAE;MACxD,MAAM,IAAIL,WAAW,CACjB,qDAAqD,EACrD,qBAAqB,EACrB;QACII,KAAK;QACLC;MACJ,CACJ,CAAC;IACL;IACA,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOC,YAAY,CAACG,KAAK,CAACC,CAAC,IAAIL,KAAK,CAACM,QAAQ,CAACD,CAAC,CAAC,CAAC;IACrD;IACA,OAAOJ,YAAY,CAACK,QAAQ,CAACN,KAAK,CAAC;EACvC;AACJ,CAAC,CAAC;AAEFH,MAAM,CAACU,IAAI,GAAG,8BAA8B;AAE5C,eAAeV,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["WebinyError","ValueFilterPlugin","plugin","operation","matches","value","compareValue","Array","isArray","length","from","to","name"],"sources":["between.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"between\",\n matches: ({ value, compareValue }) => {\n if (Array.isArray(compareValue)) {\n if (compareValue.length !== 2) {\n throw new WebinyError(\n \"When comparing between and you give an array, there must be two items in it.\",\n \"FILTER_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n const [from, to] = compareValue;\n return value >= from && value <= to;\n }\n return value >= compareValue && value <= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.between\";\n\nexport default plugin;\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,SAAS;EACpBC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;MAC7B,IAAIA,YAAY,CAACG,MAAM,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAIT,WAAW,CACjB,8EAA8E,EAC9E,cAAc,EACd;UACIK,KAAK;UACLC;QACJ,CACJ,CAAC;MACL;MACA,MAAM,CAACI,IAAI,EAAEC,EAAE,CAAC,GAAGL,YAAY;MAC/B,OAAOD,KAAK,IAAIK,IAAI,IAAIL,KAAK,IAAIM,EAAE;IACvC;IACA,OAAON,KAAK,IAAIC,YAAY,IAAID,KAAK,IAAIC,YAAY;EACzD;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACU,IAAI,GAAG,+BAA+B;AAE7C,eAAeV,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","createValues","initialValue","Array","isArray","flat","map","v","toString","filter","Boolean","result","traverse","node","push","forEach","Object","values","createCompareValues","value","replace","trim","split","val","length","plugin","operation","matches","compareValue","initialCompareValue","undefined","compareValues","some","target","every","match","RegExp","name"],"sources":["contains.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst createValues = (initialValue: string | string[] | object): string[] => {\n if (typeof initialValue === \"string\") {\n return [initialValue];\n }\n\n if (Array.isArray(initialValue)) {\n return initialValue\n .flat()\n .map(v => v.toString())\n .filter(Boolean);\n }\n\n const result: string[] = [];\n\n const traverse = (node: any): void => {\n if (node == null) {\n return;\n }\n if (typeof node === \"string\" || typeof node === \"number\") {\n result.push(node.toString());\n } else if (Array.isArray(node)) {\n node.forEach(traverse);\n } else if (typeof node === \"object\") {\n Object.values(node).forEach(traverse);\n }\n };\n\n traverse(initialValue);\n\n return result.filter(Boolean);\n};\n\nconst createCompareValues = (value: string) => {\n return value\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\?/g, `\\\\?`)\n .replace(/\\//g, `\\\\/`)\n .replace(/:/g, ``)\n .replace(/\\-/g, `\\\\-`)\n .split(\" \")\n .filter(val => {\n return val.length > 0;\n });\n};\n\nconst plugin = new ValueFilterPlugin({\n operation: \"contains\",\n matches: ({ value: initialValue, compareValue: initialCompareValue }) => {\n if (!initialValue || (Array.isArray(initialValue) && initialValue.length === 0)) {\n return false;\n } else if (initialCompareValue === undefined || initialCompareValue === null) {\n return true;\n }\n const values = createValues(initialValue);\n const compareValues = createCompareValues(initialCompareValue);\n return values.some(target => {\n return compareValues.every(compareValue => {\n return target.match(new RegExp(compareValue, \"gi\")) !== null;\n });\n });\n }\n});\n\nplugin.name = \"dynamodb.value.filter.contains\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,YAAY,GAAIC,YAAwC,IAAe;EACzE,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;IAClC,OAAO,CAACA,YAAY,CAAC;EACzB;EAEA,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,EAAE;IAC7B,OAAOA,YAAY,CACdG,IAAI,CAAC,CAAC,CACNC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAC,CACtBC,MAAM,CAACC,OAAO,CAAC;EACxB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAE3B,MAAMC,QAAQ,GAAIC,IAAS,IAAW;IAClC,IAAIA,IAAI,IAAI,IAAI,EAAE;MACd;IACJ;IACA,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACtDF,MAAM,CAACG,IAAI,CAACD,IAAI,CAACL,QAAQ,CAAC,CAAC,CAAC;IAChC,CAAC,MAAM,IAAIL,KAAK,CAACC,OAAO,CAACS,IAAI,CAAC,EAAE;MAC5BA,IAAI,CAACE,OAAO,CAACH,QAAQ,CAAC;IAC1B,CAAC,MAAM,IAAI,OAAOC,IAAI,KAAK,QAAQ,EAAE;MACjCG,MAAM,CAACC,MAAM,CAACJ,IAAI,CAAC,CAACE,OAAO,CAACH,QAAQ,CAAC;IACzC;EACJ,CAAC;EAEDA,QAAQ,CAACV,YAAY,CAAC;EAEtB,OAAOS,MAAM,CAACF,MAAM,CAACC,OAAO,CAAC;AACjC,CAAC;AAED,MAAMQ,mBAAmB,GAAIC,KAAa,IAAK;EAC3C,OAAOA,KAAK,CACPC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CACpBC,IAAI,CAAC,CAAC,CACND,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACrBA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACrBA,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CACjBA,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CACrBE,KAAK,CAAC,GAAG,CAAC,CACVb,MAAM,CAACc,GAAG,IAAI;IACX,OAAOA,GAAG,CAACC,MAAM,GAAG,CAAC;EACzB,CAAC,CAAC;AACV,CAAC;AAED,MAAMC,MAAM,GAAG,IAAIzB,iBAAiB,CAAC;EACjC0B,SAAS,EAAE,UAAU;EACrBC,OAAO,EAAEA,CAAC;IAAER,KAAK,EAAEjB,YAAY;IAAE0B,YAAY,EAAEC;EAAoB,CAAC,KAAK;IACrE,IAAI,CAAC3B,YAAY,IAAKC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,IAAIA,YAAY,CAACsB,MAAM,KAAK,CAAE,EAAE;MAC7E,OAAO,KAAK;IAChB,CAAC,MAAM,IAAIK,mBAAmB,KAAKC,SAAS,IAAID,mBAAmB,KAAK,IAAI,EAAE;MAC1E,OAAO,IAAI;IACf;IACA,MAAMZ,MAAM,GAAGhB,YAAY,CAACC,YAAY,CAAC;IACzC,MAAM6B,aAAa,GAAGb,mBAAmB,CAACW,mBAAmB,CAAC;IAC9D,OAAOZ,MAAM,CAACe,IAAI,CAACC,MAAM,IAAI;MACzB,OAAOF,aAAa,CAACG,KAAK,CAACN,YAAY,IAAI;QACvC,OAAOK,MAAM,CAACE,KAAK,CAAC,IAAIC,MAAM,CAACR,YAAY,EAAE,IAAI,CAAC,CAAC,KAAK,IAAI;MAChE,CAAC,CAAC;IACN,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AAEFH,MAAM,CAACY,IAAI,GAAG,gCAAgC;AAE9C,eAAeZ,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","matches","value","compareValue","Array","isArray","some","v","includes","every","name"],"sources":["eq.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"eq\",\n matches: ({ value, compareValue }) => {\n /**\n * Possibility that either input value or one from the system is array.\n */\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return Array.isArray(compareValue) ? compareValue.includes(v) : compareValue === v;\n });\n } else if (Array.isArray(compareValue) === true) {\n return compareValue.every((v: string) => {\n return value == v;\n });\n }\n return value == compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.eq\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,IAAI;EACfC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC;AACR;AACA;IACQ,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOA,KAAK,CAACI,IAAI,CAAEC,CAAS,IAAK;QAC7B,OAAOH,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,GAAGA,YAAY,CAACK,QAAQ,CAACD,CAAC,CAAC,GAAGJ,YAAY,KAAKI,CAAC;MACtF,CAAC,CAAC;IACN,CAAC,MAAM,IAAIH,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,IAAI,EAAE;MAC7C,OAAOA,YAAY,CAACM,KAAK,CAAEF,CAAS,IAAK;QACrC,OAAOL,KAAK,IAAIK,CAAC;MACrB,CAAC,CAAC;IACN;IACA,OAAOL,KAAK,IAAIC,YAAY;EAChC;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACW,IAAI,GAAG,0BAA0B;AAExC,eAAeX,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["Fuse","ValueFilterPlugin","plugin","operation","matches","value","initialValue","compareValue","initialCompareValue","replaceAll","f","includeScore","minMatchCharLength","threshold","isCaseSensitive","findAllMatches","ignoreLocation","result","search","length","name"],"sources":["fuzzy.ts"],"sourcesContent":["import Fuse from \"fuse.js\";\nimport type { ValueFilterPluginParamsMatchesParams } from \"../definitions/ValueFilterPlugin.js\";\nimport { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"fuzzy\",\n matches: ({\n value: initialValue,\n compareValue: initialCompareValue\n }: ValueFilterPluginParamsMatchesParams<\n string | null | undefined,\n string | null | undefined\n >) => {\n if (typeof initialValue !== \"string\" || typeof initialCompareValue !== \"string\") {\n return false;\n }\n const value = initialValue.replaceAll(\"/\", \" \");\n const compareValue = initialCompareValue.replaceAll(\"/\", \" \");\n\n const f = new Fuse([value], {\n includeScore: true,\n minMatchCharLength: 3,\n threshold: 0.5,\n isCaseSensitive: false,\n findAllMatches: true,\n ignoreLocation: true\n });\n const result = f.search(compareValue);\n\n return result.length > 0;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.fuzzy\";\n\nexport default plugin;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAE1B,SAASC,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,OAAO;EAClBC,OAAO,EAAEA,CAAC;IACNC,KAAK,EAAEC,YAAY;IACnBC,YAAY,EAAEC;EAIlB,CAAC,KAAK;IACF,IAAI,OAAOF,YAAY,KAAK,QAAQ,IAAI,OAAOE,mBAAmB,KAAK,QAAQ,EAAE;MAC7E,OAAO,KAAK;IAChB;IACA,MAAMH,KAAK,GAAGC,YAAY,CAACG,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;IAC/C,MAAMF,YAAY,GAAGC,mBAAmB,CAACC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;IAE7D,MAAMC,CAAC,GAAG,IAAIV,IAAI,CAAC,CAACK,KAAK,CAAC,EAAE;MACxBM,YAAY,EAAE,IAAI;MAClBC,kBAAkB,EAAE,CAAC;MACrBC,SAAS,EAAE,GAAG;MACdC,eAAe,EAAE,KAAK;MACtBC,cAAc,EAAE,IAAI;MACpBC,cAAc,EAAE;IACpB,CAAC,CAAC;IACF,MAAMC,MAAM,GAAGP,CAAC,CAACQ,MAAM,CAACX,YAAY,CAAC;IAErC,OAAOU,MAAM,CAACE,MAAM,GAAG,CAAC;EAC5B;AACJ,CAAC,CAAC;AAEFjB,MAAM,CAACkB,IAAI,GAAG,6BAA6B;AAE3C,eAAelB,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,14 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- const plugin = new ValueFilterPlugin({
3
- operation: "gt",
4
- matches: ({
5
- value,
6
- compareValue
7
- }) => {
8
- return value > compareValue;
9
- }
10
- });
11
- plugin.name = "dynamodb.value.filter.gt";
12
- export default plugin;
13
-
14
- //# sourceMappingURL=gt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","matches","value","compareValue","name"],"sources":["gt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"gt\",\n matches: ({ value, compareValue }) => {\n return value > compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.gt\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,IAAI;EACfC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,GAAGC,YAAY;EAC/B;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACK,IAAI,GAAG,0BAA0B;AAExC,eAAeL,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,14 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- const plugin = new ValueFilterPlugin({
3
- operation: "gte",
4
- matches: ({
5
- value,
6
- compareValue
7
- }) => {
8
- return value >= compareValue;
9
- }
10
- });
11
- plugin.name = "dynamodb.value.filter.gte";
12
- export default plugin;
13
-
14
- //# sourceMappingURL=gte.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","matches","value","compareValue","name"],"sources":["gte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"gte\",\n matches: ({ value, compareValue }) => {\n return value >= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.gte\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,KAAK;EAChBC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,IAAIC,YAAY;EAChC;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACK,IAAI,GAAG,2BAA2B;AAEzC,eAAeL,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,24 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- import WebinyError from "@webiny/error";
3
- const plugin = new ValueFilterPlugin({
4
- operation: "in",
5
- matches: ({
6
- value,
7
- compareValue
8
- }) => {
9
- if (!compareValue || Array.isArray(compareValue) === false) {
10
- throw new WebinyError(`The value given as "compareValue" must be an array!`, "COMPARE_VALUE_ERROR", {
11
- value,
12
- compareValue
13
- });
14
- }
15
- if (Array.isArray(value) === true) {
16
- return compareValue.some(c => value.includes(c));
17
- }
18
- return compareValue.includes(value);
19
- }
20
- });
21
- plugin.name = "dynamodb.value.filter.in";
22
- export default plugin;
23
-
24
- //# sourceMappingURL=in.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","WebinyError","plugin","operation","matches","value","compareValue","Array","isArray","some","c","includes","name"],"sources":["in.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface MatchesParams {\n value: any[];\n compareValue?: any[];\n}\n\nconst plugin = new ValueFilterPlugin({\n operation: \"in\",\n matches: ({ value, compareValue }: MatchesParams) => {\n if (!compareValue || Array.isArray(compareValue) === false) {\n throw new WebinyError(\n `The value given as \"compareValue\" must be an array!`,\n \"COMPARE_VALUE_ERROR\",\n {\n value,\n compareValue\n }\n );\n }\n if (Array.isArray(value) === true) {\n return compareValue.some(c => value.includes(c));\n }\n return compareValue.includes(value);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.in\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,OAAOC,WAAW,MAAM,eAAe;AAOvC,MAAMC,MAAM,GAAG,IAAIF,iBAAiB,CAAC;EACjCG,SAAS,EAAE,IAAI;EACfC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAA4B,CAAC,KAAK;IACjD,IAAI,CAACA,YAAY,IAAIC,KAAK,CAACC,OAAO,CAACF,YAAY,CAAC,KAAK,KAAK,EAAE;MACxD,MAAM,IAAIL,WAAW,CACjB,qDAAqD,EACrD,qBAAqB,EACrB;QACII,KAAK;QACLC;MACJ,CACJ,CAAC;IACL;IACA,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,IAAI,EAAE;MAC/B,OAAOC,YAAY,CAACG,IAAI,CAACC,CAAC,IAAIL,KAAK,CAACM,QAAQ,CAACD,CAAC,CAAC,CAAC;IACpD;IACA,OAAOJ,YAAY,CAACK,QAAQ,CAACN,KAAK,CAAC;EACvC;AACJ,CAAC,CAAC;AAEFH,MAAM,CAACU,IAAI,GAAG,0BAA0B;AAExC,eAAeV,MAAM","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- declare const _default: () => import("../index.js").ValueFilterPlugin<any, any>[];
2
- export default _default;
@@ -1,14 +0,0 @@
1
- import eqFilter from "./eq.js";
2
- import betweenFilter from "./between.js";
3
- import andInFilter from "./andIn.js";
4
- import inFilter from "./in.js";
5
- import gtFilter from "./gt.js";
6
- import gteFilter from "./gte.js";
7
- import ltFilter from "./lt.js";
8
- import lteFilter from "./lte.js";
9
- import containsFilter from "./contains.js";
10
- import fuzzyFilter from "./fuzzy.js";
11
- import startsWithFilter from "./startsWith.js";
12
- export default () => [eqFilter, andInFilter, inFilter, gtFilter, ltFilter, gteFilter, lteFilter, betweenFilter, containsFilter, fuzzyFilter, startsWithFilter];
13
-
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["eqFilter","betweenFilter","andInFilter","inFilter","gtFilter","gteFilter","ltFilter","lteFilter","containsFilter","fuzzyFilter","startsWithFilter"],"sources":["index.ts"],"sourcesContent":["import eqFilter from \"./eq.js\";\nimport betweenFilter from \"./between.js\";\nimport andInFilter from \"./andIn.js\";\nimport inFilter from \"./in.js\";\nimport gtFilter from \"./gt.js\";\nimport gteFilter from \"./gte.js\";\nimport ltFilter from \"./lt.js\";\nimport lteFilter from \"./lte.js\";\nimport containsFilter from \"./contains.js\";\nimport fuzzyFilter from \"./fuzzy.js\";\nimport startsWithFilter from \"./startsWith.js\";\n\nexport default () => [\n eqFilter,\n andInFilter,\n inFilter,\n gtFilter,\n ltFilter,\n gteFilter,\n lteFilter,\n betweenFilter,\n containsFilter,\n fuzzyFilter,\n startsWithFilter\n];\n"],"mappings":"AAAA,OAAOA,QAAQ;AACf,OAAOC,aAAa;AACpB,OAAOC,WAAW;AAClB,OAAOC,QAAQ;AACf,OAAOC,QAAQ;AACf,OAAOC,SAAS;AAChB,OAAOC,QAAQ;AACf,OAAOC,SAAS;AAChB,OAAOC,cAAc;AACrB,OAAOC,WAAW;AAClB,OAAOC,gBAAgB;AAEvB,eAAe,MAAM,CACjBV,QAAQ,EACRE,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRE,QAAQ,EACRD,SAAS,EACTE,SAAS,EACTN,aAAa,EACbO,cAAc,EACdC,WAAW,EACXC,gBAAgB,CACnB","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,14 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- const plugin = new ValueFilterPlugin({
3
- operation: "lt",
4
- matches: ({
5
- value,
6
- compareValue
7
- }) => {
8
- return value < compareValue;
9
- }
10
- });
11
- plugin.name = "dynamodb.value.filter.lt";
12
- export default plugin;
13
-
14
- //# sourceMappingURL=lt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","matches","value","compareValue","name"],"sources":["lt.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"lt\",\n matches: ({ value, compareValue }) => {\n return value < compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.lt\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,IAAI;EACfC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,GAAGC,YAAY;EAC/B;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACK,IAAI,GAAG,0BAA0B;AAExC,eAAeL,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1,14 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- const plugin = new ValueFilterPlugin({
3
- operation: "lte",
4
- matches: ({
5
- value,
6
- compareValue
7
- }) => {
8
- return value <= compareValue;
9
- }
10
- });
11
- plugin.name = "dynamodb.value.filter.lte";
12
- export default plugin;
13
-
14
- //# sourceMappingURL=lte.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","matches","value","compareValue","name"],"sources":["lte.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"lte\",\n matches: ({ value, compareValue }) => {\n return value <= compareValue;\n }\n});\n\nplugin.name = \"dynamodb.value.filter.lte\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,KAAK;EAChBC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAa,CAAC,KAAK;IAClC,OAAOD,KAAK,IAAIC,YAAY;EAChC;AACJ,CAAC,CAAC;AAEFJ,MAAM,CAACK,IAAI,GAAG,2BAA2B;AAEzC,eAAeL,MAAM","ignoreList":[]}
@@ -1,3 +0,0 @@
1
- import { ValueFilterPlugin } from "../definitions/ValueFilterPlugin.js";
2
- declare const plugin: ValueFilterPlugin<any, any>;
3
- export default plugin;
@@ -1 +0,0 @@
1
- {"version":3,"names":["ValueFilterPlugin","plugin","operation","canUse","compareValue","undefined","matches","value","compareValueInLowerCase","toLowerCase","Array","isArray","some","v","startsWith","name"],"sources":["startsWith.ts"],"sourcesContent":["import { ValueFilterPlugin } from \"../definitions/ValueFilterPlugin.js\";\n\nconst plugin = new ValueFilterPlugin({\n operation: \"startsWith\",\n canUse: ({ compareValue }) => {\n if (compareValue === \"\" || compareValue === null || compareValue === undefined) {\n return false;\n }\n return true;\n },\n matches: ({ value, compareValue }) => {\n /**\n * We do \"case-insensitive\" comparison.\n */\n const compareValueInLowerCase = compareValue.toLowerCase();\n\n if (typeof value !== \"string\") {\n if (Array.isArray(value) === true) {\n return value.some((v: string) => {\n return v.toLowerCase().startsWith(compareValueInLowerCase);\n });\n }\n return false;\n }\n\n return value.toLowerCase().startsWith(compareValueInLowerCase);\n }\n});\n\nplugin.name = \"dynamodb.value.filter.startsWith\";\n\nexport default plugin;\n"],"mappings":"AAAA,SAASA,iBAAiB;AAE1B,MAAMC,MAAM,GAAG,IAAID,iBAAiB,CAAC;EACjCE,SAAS,EAAE,YAAY;EACvBC,MAAM,EAAEA,CAAC;IAAEC;EAAa,CAAC,KAAK;IAC1B,IAAIA,YAAY,KAAK,EAAE,IAAIA,YAAY,KAAK,IAAI,IAAIA,YAAY,KAAKC,SAAS,EAAE;MAC5E,OAAO,KAAK;IAChB;IACA,OAAO,IAAI;EACf,CAAC;EACDC,OAAO,EAAEA,CAAC;IAAEC,KAAK;IAAEH;EAAa,CAAC,KAAK;IAClC;AACR;AACA;IACQ,MAAMI,uBAAuB,GAAGJ,YAAY,CAACK,WAAW,CAAC,CAAC;IAE1D,IAAI,OAAOF,KAAK,KAAK,QAAQ,EAAE;MAC3B,IAAIG,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,KAAK,IAAI,EAAE;QAC/B,OAAOA,KAAK,CAACK,IAAI,CAAEC,CAAS,IAAK;UAC7B,OAAOA,CAAC,CAACJ,WAAW,CAAC,CAAC,CAACK,UAAU,CAACN,uBAAuB,CAAC;QAC9D,CAAC,CAAC;MACN;MACA,OAAO,KAAK;IAChB;IAEA,OAAOD,KAAK,CAACE,WAAW,CAAC,CAAC,CAACK,UAAU,CAACN,uBAAuB,CAAC;EAClE;AACJ,CAAC,CAAC;AAEFP,MAAM,CAACc,IAAI,GAAG,kCAAkC;AAEhD,eAAed,MAAM","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- import type { Context } from "@webiny/api/types.js";
2
- import { AttributePlugin } from "../plugins/definitions/AttributePlugin.js";
3
- import type { PluginsContainer } from "@webiny/plugins";
4
- /**
5
- * Will be removed in favor of directly assigning attributes to a certain entity when creating the storage operations.
6
- *
7
- * @deprecated
8
- */
9
- export declare const getExtraAttributes: (context: Context, entity: string) => Record<string, AttributePlugin["_params"]>;
10
- export declare const getExtraAttributesFromPlugins: (plugins: PluginsContainer, entity: string) => Record<string, AttributePlugin["_params"]>;
@@ -1,19 +0,0 @@
1
- import { AttributePlugin } from "../plugins/definitions/AttributePlugin.js";
2
- /**
3
- * Will be removed in favor of directly assigning attributes to a certain entity when creating the storage operations.
4
- *
5
- * @deprecated
6
- */
7
- export const getExtraAttributes = (context, entity) => {
8
- return getExtraAttributesFromPlugins(context.plugins, entity);
9
- };
10
- export const getExtraAttributesFromPlugins = (plugins, entity) => {
11
- return plugins.byType(AttributePlugin.type).filter(plugin => plugin.entity === entity).reduce((attributes, plugin) => {
12
- return {
13
- ...attributes,
14
- ...plugin.getDefinition()
15
- };
16
- }, {});
17
- };
18
-
19
- //# sourceMappingURL=attributes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["AttributePlugin","getExtraAttributes","context","entity","getExtraAttributesFromPlugins","plugins","byType","type","filter","plugin","reduce","attributes","getDefinition"],"sources":["attributes.ts"],"sourcesContent":["import type { Context } from \"@webiny/api/types.js\";\nimport { AttributePlugin } from \"~/plugins/definitions/AttributePlugin.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * Will be removed in favor of directly assigning attributes to a certain entity when creating the storage operations.\n *\n * @deprecated\n */\nexport const getExtraAttributes = (\n context: Context,\n entity: string\n): Record<string, AttributePlugin[\"_params\"]> => {\n return getExtraAttributesFromPlugins(context.plugins, entity);\n};\n\nexport const getExtraAttributesFromPlugins = (\n plugins: PluginsContainer,\n entity: string\n): Record<string, AttributePlugin[\"_params\"]> => {\n return plugins\n .byType<AttributePlugin>(AttributePlugin.type)\n .filter(plugin => plugin.entity === entity)\n .reduce((attributes, plugin) => {\n return {\n ...attributes,\n ...plugin.getDefinition()\n };\n }, {});\n};\n"],"mappings":"AACA,SAASA,eAAe;AAGxB;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAC9BC,OAAgB,EAChBC,MAAc,KAC+B;EAC7C,OAAOC,6BAA6B,CAACF,OAAO,CAACG,OAAO,EAAEF,MAAM,CAAC;AACjE,CAAC;AAED,OAAO,MAAMC,6BAA6B,GAAGA,CACzCC,OAAyB,EACzBF,MAAc,KAC+B;EAC7C,OAAOE,OAAO,CACTC,MAAM,CAAkBN,eAAe,CAACO,IAAI,CAAC,CAC7CC,MAAM,CAACC,MAAM,IAAIA,MAAM,CAACN,MAAM,KAAKA,MAAM,CAAC,CAC1CO,MAAM,CAAC,CAACC,UAAU,EAAEF,MAAM,KAAK;IAC5B,OAAO;MACH,GAAGE,UAAU;MACb,GAAGF,MAAM,CAACG,aAAa,CAAC;IAC5B,CAAC;EACL,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}
package/utils/filter.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { PluginsContainer } from "@webiny/plugins";
2
- import type { FieldPlugin } from "../plugins/definitions/FieldPlugin.js";
3
- export interface Params<T = any> {
4
- plugins: PluginsContainer;
5
- items: T[];
6
- where: Record<string, any>;
7
- /**
8
- * An array of fields that require some special operation.
9
- */
10
- fields: FieldPlugin[];
11
- }
12
- export declare function filterItems<T = any>(params: Params<T>): T[];