@webiny/api-headless-cms-ddb 6.4.12-beta.5 → 6.5.0-beta.1

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 (88) hide show
  1. package/dynamoDb/index.d.ts +1 -1
  2. package/dynamoDb/index.js +1 -3
  3. package/dynamoDb/index.js.map +1 -1
  4. package/index.js +11 -7
  5. package/index.js.map +1 -1
  6. package/operations/entry/index.js +38 -43
  7. package/operations/entry/index.js.map +1 -1
  8. package/package.json +19 -19
  9. package/plugins/index.d.ts +2 -4
  10. package/plugins/index.js +1 -4
  11. package/types.d.ts +2 -25
  12. package/types.js.map +1 -1
  13. package/dynamoDb/path/locationFolderId.d.ts +0 -2
  14. package/dynamoDb/path/locationFolderId.js +0 -21
  15. package/dynamoDb/path/locationFolderId.js.map +0 -1
  16. package/dynamoDb/path/plainObject.d.ts +0 -2
  17. package/dynamoDb/path/plainObject.js +0 -16
  18. package/dynamoDb/path/plainObject.js.map +0 -1
  19. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  20. package/dynamoDb/transformValue/datetime.js +0 -29
  21. package/dynamoDb/transformValue/datetime.js.map +0 -1
  22. package/operations/entry/filtering/createExpressions.d.ts +0 -27
  23. package/operations/entry/filtering/createExpressions.js +0 -124
  24. package/operations/entry/filtering/createExpressions.js.map +0 -1
  25. package/operations/entry/filtering/createFields.d.ts +0 -16
  26. package/operations/entry/filtering/createFields.js +0 -93
  27. package/operations/entry/filtering/createFields.js.map +0 -1
  28. package/operations/entry/filtering/extractSort.d.ts +0 -17
  29. package/operations/entry/filtering/extractSort.js +0 -60
  30. package/operations/entry/filtering/extractSort.js.map +0 -1
  31. package/operations/entry/filtering/filter.d.ts +0 -16
  32. package/operations/entry/filtering/filter.js +0 -85
  33. package/operations/entry/filtering/filter.js.map +0 -1
  34. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  35. package/operations/entry/filtering/fullTextSearch.js +0 -25
  36. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  37. package/operations/entry/filtering/getValue.d.ts +0 -5
  38. package/operations/entry/filtering/getValue.js +0 -37
  39. package/operations/entry/filtering/getValue.js.map +0 -1
  40. package/operations/entry/filtering/index.d.ts +0 -2
  41. package/operations/entry/filtering/index.js +0 -2
  42. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  43. package/operations/entry/filtering/mapPlugins.js +0 -18
  44. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  45. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  46. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -33
  47. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  48. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  49. package/operations/entry/filtering/plugins/index.js +0 -13
  50. package/operations/entry/filtering/plugins/index.js.map +0 -1
  51. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  52. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -68
  53. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  54. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
  55. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -63
  56. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  57. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
  58. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -56
  59. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
  60. package/operations/entry/filtering/sort.d.ts +0 -12
  61. package/operations/entry/filtering/sort.js +0 -41
  62. package/operations/entry/filtering/sort.js.map +0 -1
  63. package/operations/entry/filtering/systemFields.d.ts +0 -2
  64. package/operations/entry/filtering/systemFields.js +0 -149
  65. package/operations/entry/filtering/systemFields.js.map +0 -1
  66. package/operations/entry/filtering/transform.d.ts +0 -6
  67. package/operations/entry/filtering/transform.js +0 -7
  68. package/operations/entry/filtering/transform.js.map +0 -1
  69. package/operations/entry/filtering/types.d.ts +0 -40
  70. package/operations/entry/filtering/types.js +0 -0
  71. package/operations/entry/filtering/values.d.ts +0 -2
  72. package/operations/entry/filtering/values.js +0 -15
  73. package/operations/entry/filtering/values.js.map +0 -1
  74. package/operations/entry/filtering/where.d.ts +0 -5
  75. package/operations/entry/filtering/where.js +0 -22
  76. package/operations/entry/filtering/where.js.map +0 -1
  77. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
  78. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -30
  79. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  80. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  81. package/plugins/CmsEntryFieldFilterPlugin.js +0 -20
  82. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  83. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  84. package/plugins/CmsEntryFieldSortingPlugin.js +0 -20
  85. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  86. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  87. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -19
  88. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb",
3
- "version": "6.4.12-beta.5",
3
+ "version": "6.5.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -26,28 +26,28 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@webiny/api": "6.4.12-beta.5",
30
- "@webiny/api-headless-cms": "6.4.12-beta.5",
31
- "@webiny/aws-sdk": "6.4.12-beta.5",
32
- "@webiny/db-dynamodb": "6.4.12-beta.5",
33
- "@webiny/error": "6.4.12-beta.5",
34
- "@webiny/feature": "6.4.12-beta.5",
35
- "@webiny/handler": "6.4.12-beta.5",
36
- "@webiny/handler-db": "6.4.12-beta.5",
37
- "@webiny/utils": "6.4.12-beta.5",
38
- "dataloader": "2.2.3",
39
- "dot-prop": "10.2.0",
40
- "lodash": "4.18.1"
29
+ "@webiny/api": "6.5.0-beta.1",
30
+ "@webiny/api-headless-cms": "6.5.0-beta.1",
31
+ "@webiny/api-headless-cms-storage": "6.5.0-beta.1",
32
+ "@webiny/aws-sdk": "6.5.0-beta.1",
33
+ "@webiny/db-dynamodb": "6.5.0-beta.1",
34
+ "@webiny/db-utils": "6.5.0-beta.1",
35
+ "@webiny/error": "6.5.0-beta.1",
36
+ "@webiny/feature": "6.5.0-beta.1",
37
+ "@webiny/handler": "6.5.0-beta.1",
38
+ "@webiny/handler-db": "6.5.0-beta.1",
39
+ "@webiny/plugins": "6.5.0-beta.1",
40
+ "@webiny/utils": "6.5.0-beta.1",
41
+ "dataloader": "2.2.3"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@types/jsonpack": "1.1.6",
44
- "@webiny/build-tools": "6.4.12-beta.5",
45
- "@webiny/di": "1.1.0",
46
- "@webiny/plugins": "6.4.12-beta.5",
47
- "@webiny/project-utils": "6.4.12-beta.5",
45
+ "@webiny/build-tools": "6.5.0-beta.1",
46
+ "@webiny/di": "1.0.2",
47
+ "@webiny/project-utils": "6.5.0-beta.1",
48
48
  "jest-dynalite": "3.6.1",
49
- "typescript": "6.0.3",
50
- "vitest": "5.0.1"
49
+ "typescript": "7.0.2",
50
+ "vitest": "4.1.10"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -1,4 +1,2 @@
1
- export * from "./CmsEntryFieldFilterPathPlugin.js";
2
- export * from "./CmsEntryFieldSortingPlugin.js";
3
- export * from "./CmsEntryFieldFilterPlugin.js";
4
- export * from "./CmsFieldFilterValueTransformPlugin.js";
1
+ export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldSortingPlugin, createCmsEntryFieldSortingPlugin, CmsEntryFieldFilterPlugin, CmsFieldFilterValueTransformPlugin } from "@webiny/api-headless-cms-storage";
2
+ export type { CreatePathCallable, CmsEntryFieldFilterPluginCreateResponse } from "@webiny/api-headless-cms-storage";
package/plugins/index.js CHANGED
@@ -1,4 +1 @@
1
- export * from "./CmsEntryFieldFilterPathPlugin.js";
2
- export * from "./CmsEntryFieldSortingPlugin.js";
3
- export * from "./CmsEntryFieldFilterPlugin.js";
4
- export * from "./CmsFieldFilterValueTransformPlugin.js";
1
+ export { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin, createCmsEntryFieldSortingPlugin } from "@webiny/api-headless-cms-storage";
package/types.d.ts CHANGED
@@ -1,38 +1,15 @@
1
- import { type Plugin, PluginsContainer } from "@webiny/plugins/types.js";
2
- import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
3
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
1
+ import { PluginsContainer } from "@webiny/plugins/types.js";
2
+ import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
4
3
  import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
5
4
  import type { ITable } from "@webiny/db-dynamodb";
6
5
  export type { CmsContext };
7
6
  export type { IGroupEntity, IModelEntity, IEntryEntity };
8
- interface CmsFieldFilterValueTransformParams {
9
- /**
10
- * A field which value we are transforming.
11
- */
12
- field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
13
- value: any;
14
- }
15
- export interface CmsFieldFilterValueTransformPlugin extends Plugin {
16
- /**
17
- * A plugin type.
18
- */
19
- type: "cms-field-filter-value-transform";
20
- /**
21
- * A field type this plugin is for.
22
- */
23
- fieldType: string;
24
- /**
25
- * Transform method which expect field definition and value to transform.
26
- */
27
- transform: (params: CmsFieldFilterValueTransformParams) => any;
28
- }
29
7
  export declare enum ENTITIES {
30
8
  GROUPS = "CmsGroups",
31
9
  MODELS = "CmsModels",
32
10
  ENTRIES = "CmsEntries"
33
11
  }
34
12
  export interface StorageOperationsFactoryParams {
35
- documentClient: DynamoDBDocument;
36
13
  table?: string;
37
14
  plugins: PluginsContainer;
38
15
  container: CmsContext["container"];
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import { type Plugin, PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\nexport type { CmsContext };\n\nexport type { IGroupEntity, IModelEntity, IEntryEntity };\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n table?: string;\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n}\n\nexport interface IHeadlessCmsStorageOperationsGetEntitiesResult {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => ITable;\n getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAuCO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins/types.js\";\nimport type {\n CmsContext,\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IEntryEntity, IGroupEntity, IModelEntity } from \"~/definitions/types.js\";\nimport type { ITable } from \"@webiny/db-dynamodb\";\n\nexport type { CmsContext };\n\nexport type { IGroupEntity, IModelEntity, IEntryEntity };\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface StorageOperationsFactoryParams {\n table?: string;\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n}\n\nexport interface IHeadlessCmsStorageOperationsGetEntitiesResult {\n groups: IGroupEntity;\n models: IModelEntity;\n entries: IEntryEntity;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => ITable;\n getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: IDataLoadersHandler;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAaO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
@@ -1,2 +0,0 @@
1
- import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
2
- export declare const createLocationFolderIdPathPlugin: () => CmsEntryFieldFilterPathPlugin;
@@ -1,21 +0,0 @@
1
- import error from "@webiny/error";
2
- import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
3
- const createPath = ({ field })=>{
4
- const { path } = field.settings || {};
5
- if (!path) throw new error("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
6
- field
7
- });
8
- return path;
9
- };
10
- const createLocationFolderIdPathPlugin = ()=>new CmsEntryFieldFilterPathPlugin({
11
- fieldType: "text",
12
- path: createPath,
13
- canUse: (field, parents)=>{
14
- if ("folderId" !== field.fieldId) return false;
15
- else if (!parents?.length) return false;
16
- return "wbyAco_location" === parents[0];
17
- }
18
- });
19
- export { createLocationFolderIdPathPlugin };
20
-
21
- //# sourceMappingURL=locationFolderId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamoDb/path/locationFolderId.js","sources":["../../../src/dynamoDb/path/locationFolderId.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createLocationFolderIdPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"text\",\n path: createPath,\n canUse: (field, parents) => {\n if (field.fieldId !== \"folderId\") {\n return false;\n } else if (!parents?.length) {\n return false;\n }\n return parents[0] === \"wbyAco_location\";\n }\n });\n};\n"],"names":["createPath","field","path","WebinyError","createLocationFolderIdPathPlugin","CmsEntryFieldFilterPathPlugin","parents"],"mappings":";;AAOA,MAAMA,aAAiC,CAAC,EAAEC,KAAK,EAAE;IAC7C,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAM,QAAQ,IAAI,CAAC;IACpC,IAAI,CAACC,MACD,MAAM,IAAIC,MAAY,gCAAgC,wBAAwB;QAC1EF;IACJ;IAEJ,OAAOC;AACX;AAEO,MAAME,mCAAmC,IACrC,IAAIC,8BAA8B;QACrC,WAAW;QACX,MAAML;QACN,QAAQ,CAACC,OAAOK;YACZ,IAAIL,AAAkB,eAAlBA,MAAM,OAAO,EACb,OAAO;iBACJ,IAAI,CAACK,SAAS,QACjB,OAAO;YAEX,OAAOA,AAAe,sBAAfA,OAAO,CAAC,EAAE;QACrB;IACJ"}
@@ -1,2 +0,0 @@
1
- import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
2
- export declare const createPlainObjectPathPlugin: () => CmsEntryFieldFilterPathPlugin;
@@ -1,16 +0,0 @@
1
- import error from "@webiny/error";
2
- import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
3
- const createPath = ({ field })=>{
4
- const { path } = field.settings || {};
5
- if (!path) throw new error("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
6
- field
7
- });
8
- return path;
9
- };
10
- const createPlainObjectPathPlugin = ()=>new CmsEntryFieldFilterPathPlugin({
11
- fieldType: "plainObject",
12
- path: createPath
13
- });
14
- export { createPlainObjectPathPlugin };
15
-
16
- //# sourceMappingURL=plainObject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamoDb/path/plainObject.js","sources":["../../../src/dynamoDb/path/plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"names":["createPath","field","path","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin"],"mappings":";;AAOA,MAAMA,aAAiC,CAAC,EAAEC,KAAK,EAAE;IAC7C,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAM,QAAQ,IAAI,CAAC;IACpC,IAAI,CAACC,MACD,MAAM,IAAIC,MAAY,gCAAgC,wBAAwB;QAC1EF;IACJ;IAEJ,OAAOC;AACX;AAEO,MAAME,8BAA8B,IAChC,IAAIC,8BAA8B;QACrC,WAAW;QACX,MAAML;IACV"}
@@ -1,5 +0,0 @@
1
- /**
2
- * File is @internal
3
- */
4
- import type { CmsFieldFilterValueTransformPlugin } from "../../types.js";
5
- export declare const createDatetimeTransformValuePlugin: () => CmsFieldFilterValueTransformPlugin;
@@ -1,29 +0,0 @@
1
- import { TimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js";
2
- import { DateTimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js";
3
- const timeTransformer = new TimeTransformPlugin({
4
- fields: [
5
- "*"
6
- ]
7
- });
8
- const dateTimeTransformer = new DateTimeTransformPlugin({
9
- fields: [
10
- "*"
11
- ]
12
- });
13
- const createDatetimeTransformValuePlugin = ()=>({
14
- type: "cms-field-filter-value-transform",
15
- name: "cms-field-value-filter-transform-datetime",
16
- fieldType: "datetime",
17
- transform: ({ field, value })=>{
18
- const { type } = field.settings || {};
19
- if ("time" === type) return timeTransformer.transform({
20
- value
21
- });
22
- return dateTimeTransformer.transform({
23
- value
24
- });
25
- }
26
- });
27
- export { createDatetimeTransformValuePlugin };
28
-
29
- //# sourceMappingURL=datetime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamoDb/transformValue/datetime.js","sources":["../../../src/dynamoDb/transformValue/datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"names":["timeTransformer","TimeTransformPlugin","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","field","value","type"],"mappings":";;AAOA,MAAMA,kBAAkB,IAAIC,oBAAoB;IAC5C,QAAQ;QAAC;KAAI;AACjB;AACA,MAAMC,sBAAsB,IAAIC,wBAAwB;IACpD,QAAQ;QAAC;KAAI;AACjB;AAEO,MAAMC,qCAAqC,IACvC;QACH,MAAM;QACN,MAAM;QACN,WAAW;QAIX,WAAW,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE;YACxB,MAAM,EAAEC,IAAI,EAAE,GAAGF,MAAM,QAAQ,IAAI,CAAC;YACpC,IAAIE,AAAS,WAATA,MACA,OAAOP,gBAAgB,SAAS,CAAC;gBAC7BM;YACJ;YAEJ,OAAOJ,oBAAoB,SAAS,CAAC;gBACjCI;YACJ;QACJ;IACJ"}
@@ -1,27 +0,0 @@
1
- import type { CmsContext, CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
2
- import type { PluginsContainer } from "@webiny/plugins";
3
- import type { Field } from "./types.js";
4
- import { ValueFilter } from "@webiny/db-dynamodb/feature/ValueFilter/index.js";
5
- interface ICreateExpressionsParams {
6
- plugins: PluginsContainer;
7
- container: CmsContext["container"];
8
- where: Partial<CmsEntryListWhere>;
9
- fields: Record<string, Field>;
10
- }
11
- export type ExpressionCondition = "AND" | "OR";
12
- export interface Expression {
13
- expressions: Expression[];
14
- filters: Filter[];
15
- condition: ExpressionCondition;
16
- }
17
- export interface Filter {
18
- field: Field;
19
- path: string;
20
- fieldPathId: string;
21
- filter: ValueFilter.Interface;
22
- negate: boolean;
23
- compareValue: any;
24
- transformValue: <I = any, O = any>(value: I) => O;
25
- }
26
- export declare const createExpressions: (params: ICreateExpressionsParams) => Expression;
27
- export {};
@@ -1,124 +0,0 @@
1
- import error from "@webiny/error";
2
- import { getMappedPlugins } from "./mapPlugins.js";
3
- import { extractWhereParams } from "./where.js";
4
- import { transformValue } from "./transform.js";
5
- import { CmsEntryFieldFilterPlugin } from "../../../plugins/CmsEntryFieldFilterPlugin.js";
6
- import { getWhereValues } from "./values.js";
7
- import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
8
- import { ValueFilterRegistry } from "@webiny/db-dynamodb/exports/api/db.js";
9
- const createExpressions = (params)=>{
10
- const { where, plugins, fields, container } = params;
11
- const valueFilterRegistry = container.resolve(ValueFilterRegistry);
12
- const transformValuePlugins = getMappedPlugins({
13
- plugins,
14
- type: "cms-field-filter-value-transform",
15
- property: "fieldType"
16
- });
17
- const fieldFilterCreatePlugins = getMappedPlugins({
18
- plugins,
19
- type: CmsEntryFieldFilterPlugin.type,
20
- property: "fieldType"
21
- });
22
- const defaultFilterCreatePlugin = fieldFilterCreatePlugins["*"];
23
- const getFilterCreatePlugin = (type)=>{
24
- const fieldType = getBaseFieldType({
25
- type
26
- });
27
- const filterCreatePlugin = fieldFilterCreatePlugins[fieldType] || defaultFilterCreatePlugin;
28
- if (filterCreatePlugin) return filterCreatePlugin;
29
- throw new error(`There is no filter create plugin for the field type "${fieldType}".`, "MISSING_FILTER_CREATE_PLUGIN", {
30
- fieldType
31
- });
32
- };
33
- const createExpression = ({ where, condition })=>{
34
- const expression = {
35
- filters: [],
36
- expressions: [],
37
- condition
38
- };
39
- for(const key in where){
40
- const value = where[key];
41
- if (void 0 === value) continue;
42
- if ("AND" === key) {
43
- const childWhereList = getWhereValues(value, key);
44
- const childExpression = {
45
- condition: "AND",
46
- filters: [],
47
- expressions: []
48
- };
49
- for (const childWhere of childWhereList){
50
- const result = createExpression({
51
- where: childWhere,
52
- condition: "AND"
53
- });
54
- childExpression.expressions.push(result);
55
- }
56
- expression.expressions.push(childExpression);
57
- continue;
58
- }
59
- if ("OR" === key) {
60
- const childWhereList = getWhereValues(value, key);
61
- const childExpression = {
62
- condition: "OR",
63
- filters: [],
64
- expressions: []
65
- };
66
- for (const childWhere of childWhereList){
67
- const result = createExpression({
68
- where: childWhere,
69
- condition: "AND"
70
- });
71
- childExpression.expressions.push(result);
72
- }
73
- expression.expressions.push(childExpression);
74
- continue;
75
- }
76
- const whereParams = extractWhereParams(key);
77
- if (!whereParams) continue;
78
- const { fieldId, operation, negate } = whereParams;
79
- const field = fields[fieldId];
80
- if (!field) throw new error(`There is no field with the fieldId "${fieldId}".`, "FIELD_ERROR", {
81
- fieldId
82
- });
83
- const filterCreatePlugin = getFilterCreatePlugin(field.type);
84
- const fieldType = getBaseFieldType(field);
85
- const transformValuePlugin = transformValuePlugins[fieldType];
86
- const transformValueCallable = (value)=>{
87
- if (!transformValuePlugin) return value;
88
- return transformValuePlugin.transform({
89
- field,
90
- value
91
- });
92
- };
93
- const result = filterCreatePlugin.create({
94
- key,
95
- value,
96
- valueFilterRegistry,
97
- transformValuePlugins,
98
- getFilterCreatePlugin,
99
- operation,
100
- negate,
101
- field,
102
- fields,
103
- compareValue: transformValue({
104
- value,
105
- transform: transformValueCallable
106
- }),
107
- transformValue: transformValueCallable
108
- });
109
- if (!(!result || Array.isArray(result) && 0 === result.length)) expression.filters.push(...Array.isArray(result) ? result : [
110
- result
111
- ]);
112
- }
113
- return expression;
114
- };
115
- const expression = createExpression({
116
- where,
117
- condition: "AND"
118
- });
119
- if (expression.filters.length > 0 || 1 !== expression.expressions.length) return expression;
120
- return expression.expressions[0];
121
- };
122
- export { createExpressions };
123
-
124
- //# sourceMappingURL=createExpressions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations/entry/filtering/createExpressions.js","sources":["../../../../src/operations/entry/filtering/createExpressions.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsContext, CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { Field } from \"./types.js\";\nimport { getMappedPlugins } from \"./mapPlugins.js\";\nimport { extractWhereParams } from \"./where.js\";\nimport { transformValue } from \"./transform.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { getWhereValues } from \"~/operations/entry/filtering/values.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\nimport { ValueFilter } from \"@webiny/db-dynamodb/feature/ValueFilter/index.js\";\nimport { ValueFilterRegistry } from \"@webiny/db-dynamodb/exports/api/db.js\";\n\ninterface CreateExpressionParams {\n where: Partial<CmsEntryListWhere>;\n condition: ExpressionCondition;\n}\n\ninterface ICreateExpressionsParams {\n plugins: PluginsContainer;\n container: CmsContext[\"container\"];\n where: Partial<CmsEntryListWhere>;\n fields: Record<string, Field>;\n}\n\nexport type ExpressionCondition = \"AND\" | \"OR\";\n\nexport interface Expression {\n expressions: Expression[];\n filters: Filter[];\n condition: ExpressionCondition;\n}\n\nexport interface Filter {\n field: Field;\n path: string;\n fieldPathId: string;\n filter: ValueFilter.Interface;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport const createExpressions = (params: ICreateExpressionsParams): Expression => {\n const { where, plugins, fields, container } = params;\n const valueFilterRegistry = container.resolve(ValueFilterRegistry);\n\n const transformValuePlugins = getMappedPlugins<CmsFieldFilterValueTransformPlugin>({\n plugins,\n type: \"cms-field-filter-value-transform\",\n property: \"fieldType\"\n });\n const fieldFilterCreatePlugins = getMappedPlugins<CmsEntryFieldFilterPlugin>({\n plugins,\n type: CmsEntryFieldFilterPlugin.type,\n property: \"fieldType\"\n });\n\n const defaultFilterCreatePlugin = fieldFilterCreatePlugins[\"*\"] as CmsEntryFieldFilterPlugin;\n\n const getFilterCreatePlugin = (type: string) => {\n const fieldType = getBaseFieldType({\n type\n });\n const filterCreatePlugin = fieldFilterCreatePlugins[fieldType] || defaultFilterCreatePlugin;\n if (filterCreatePlugin) {\n return filterCreatePlugin;\n }\n throw new WebinyError(\n `There is no filter create plugin for the field type \"${fieldType}\".`,\n \"MISSING_FILTER_CREATE_PLUGIN\",\n {\n fieldType\n }\n );\n };\n\n const createExpression = ({ where, condition }: CreateExpressionParams): Expression => {\n const expression: Expression = {\n filters: [],\n expressions: [],\n condition\n };\n\n for (const key in where) {\n const value = where[key as keyof typeof where];\n if (value === undefined) {\n continue;\n }\n\n /**\n * If there are \"AND\" or \"OR\" keys, let's sort them out first.\n *\n *\n * AND conditional\n */\n if (key === \"AND\") {\n const childWhereList = getWhereValues(value, key);\n const childExpression: Expression = {\n condition: \"AND\",\n filters: [],\n expressions: []\n };\n for (const childWhere of childWhereList) {\n const result = createExpression({\n where: childWhere,\n condition: \"AND\"\n });\n childExpression.expressions.push(result);\n }\n expression.expressions.push(childExpression);\n continue;\n }\n /**\n * OR conditional\n */\n if (key === \"OR\") {\n const childWhereList = getWhereValues(value, key);\n\n const childExpression: Expression = {\n condition: \"OR\",\n filters: [],\n expressions: []\n };\n for (const childWhere of childWhereList) {\n const result = createExpression({\n where: childWhere,\n condition: \"AND\"\n });\n childExpression.expressions.push(result);\n }\n expression.expressions.push(childExpression);\n continue;\n }\n\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n\n const { fieldId, operation, negate } = whereParams;\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(\n `There is no field with the fieldId \"${fieldId}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n /**\n * We need a filter create plugin for this type.\n */\n const filterCreatePlugin = getFilterCreatePlugin(field.type);\n\n const fieldType = getBaseFieldType(field);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterRegistry,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n /**\n * There is a possibility of\n * - no result\n * - result being an array\n * - result being an object\n */\n if (!result || (Array.isArray(result) && result.length === 0)) {\n continue;\n }\n\n expression.filters.push(...(Array.isArray(result) ? result : [result]));\n }\n\n return expression;\n };\n\n const expression = createExpression({\n where,\n condition: \"AND\"\n });\n /**\n * If the first expression has no filters and has only one expression, put that expression as main one.\n * This will mostly be used when having an OR condition as the single expression in the root level of the where\n */\n if (expression.filters.length > 0 || expression.expressions.length !== 1) {\n return expression;\n }\n return expression.expressions[0];\n};\n"],"names":["createExpressions","params","where","plugins","fields","container","valueFilterRegistry","ValueFilterRegistry","transformValuePlugins","getMappedPlugins","fieldFilterCreatePlugins","CmsEntryFieldFilterPlugin","defaultFilterCreatePlugin","getFilterCreatePlugin","type","fieldType","getBaseFieldType","filterCreatePlugin","WebinyError","createExpression","condition","expression","key","value","undefined","childWhereList","getWhereValues","childExpression","childWhere","result","whereParams","extractWhereParams","fieldId","operation","negate","field","transformValuePlugin","transformValueCallable","transformValue","Array"],"mappings":"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"}
@@ -1,16 +0,0 @@
1
- import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
- import type { Field } from "./types.js";
3
- import type { PluginsContainer } from "@webiny/plugins";
4
- interface Params {
5
- fields: CmsModelField[];
6
- plugins: PluginsContainer;
7
- }
8
- /**
9
- * This method will map the fieldId (fieldId -> field) to the actual field.
10
- *
11
- * In case of nested fields, fieldId is all the parent fieldIds + current one, joined by the dot (.).
12
- */
13
- export declare const createFields: (params: Params) => {
14
- [x: string]: Field;
15
- };
16
- export {};
@@ -1,93 +0,0 @@
1
- import { createSystemFields } from "./systemFields.js";
2
- import { CmsEntryFieldFilterPathPlugin } from "../../../plugins/index.js";
3
- import { getMappedPlugins } from "./mapPlugins.js";
4
- import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
5
- const createFieldCollection = (params)=>{
6
- const { fields, parents, transformValuePlugins, valuePathPlugins, system } = params;
7
- return fields.reduce((collection, field)=>{
8
- const fieldType = getBaseFieldType(field);
9
- const transformPlugin = transformValuePlugins[fieldType];
10
- const valuePathPlugin = valuePathPlugins[fieldType];
11
- const fieldId = [
12
- ...parents,
13
- {
14
- fieldId: field.fieldId,
15
- list: field.list
16
- }
17
- ].map((f)=>f.fieldId).join(".");
18
- collection[fieldId] = {
19
- ...field,
20
- parents,
21
- system,
22
- createPath: (params)=>{
23
- if (valuePathPlugin && valuePathPlugin.canUse(field, parents.map((p)=>p.fieldId))) return valuePathPlugin.createPath(params);
24
- return parents.map((parent)=>parent.fieldId).concat([
25
- params.field.fieldId
26
- ]).join(".");
27
- },
28
- transform: (value)=>{
29
- if (!transformPlugin) return value;
30
- return transformPlugin.transform({
31
- field,
32
- value
33
- });
34
- }
35
- };
36
- const childFields = field.settings?.fields;
37
- if (!childFields?.length) return collection;
38
- const result = createFieldCollection({
39
- fields: childFields,
40
- parents: [
41
- ...parents,
42
- {
43
- fieldId: field.fieldId,
44
- list: field.list
45
- }
46
- ],
47
- transformValuePlugins,
48
- valuePathPlugins,
49
- system
50
- });
51
- Object.assign(collection, result);
52
- return collection;
53
- }, {});
54
- };
55
- const createFields = (params)=>{
56
- const { fields, plugins } = params;
57
- const transformValuePlugins = getMappedPlugins({
58
- plugins,
59
- type: "cms-field-filter-value-transform",
60
- property: "fieldType"
61
- });
62
- const valuePathPlugins = getMappedPlugins({
63
- plugins,
64
- type: CmsEntryFieldFilterPathPlugin.type,
65
- property: "fieldType"
66
- });
67
- const collection = createFieldCollection({
68
- fields: createSystemFields(),
69
- transformValuePlugins,
70
- valuePathPlugins,
71
- parents: [],
72
- system: true
73
- });
74
- const result = createFieldCollection({
75
- fields,
76
- transformValuePlugins,
77
- valuePathPlugins,
78
- parents: [
79
- {
80
- fieldId: "values",
81
- list: false
82
- }
83
- ],
84
- system: false
85
- });
86
- return {
87
- ...collection,
88
- ...result
89
- };
90
- };
91
- export { createFields };
92
-
93
- //# sourceMappingURL=createFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations/entry/filtering/createFields.js","sources":["../../../../src/operations/entry/filtering/createFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createSystemFields } from \"./systemFields.js\";\nimport type { Field, FieldParent } from \"./types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/index.js\";\nimport { getMappedPlugins } from \"./mapPlugins.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\ninterface Params {\n fields: CmsModelField[];\n plugins: PluginsContainer;\n}\n\ninterface FieldCollection {\n [key: string]: Field;\n}\n\ninterface AddFieldsToCollectionParams {\n fields: CmsModelField[];\n parents: FieldParent[];\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n valuePathPlugins: Record<string, CmsEntryFieldFilterPathPlugin>;\n system: boolean;\n}\n\nconst createFieldCollection = (params: AddFieldsToCollectionParams): FieldCollection => {\n const { fields, parents, transformValuePlugins, valuePathPlugins, system } = params;\n return fields.reduce<FieldCollection>((collection, field) => {\n const fieldType = getBaseFieldType(field);\n const transformPlugin = transformValuePlugins[fieldType];\n const valuePathPlugin = valuePathPlugins[fieldType];\n\n /**\n * The required fieldId is a product of all of its parents and its own fieldId.\n */\n const fieldId = [\n ...parents,\n {\n fieldId: field.fieldId,\n list: field.list\n }\n ]\n .map(f => f.fieldId)\n .join(\".\");\n\n collection[fieldId] = {\n ...field,\n parents,\n system,\n createPath: params => {\n if (\n valuePathPlugin &&\n valuePathPlugin.canUse(\n field,\n parents.map(p => p.fieldId)\n )\n ) {\n return valuePathPlugin.createPath(params);\n }\n\n return parents\n .map(parent => parent.fieldId)\n .concat([params.field.fieldId])\n .join(\".\");\n },\n transform: value => {\n if (!transformPlugin) {\n return value;\n }\n return transformPlugin.transform({\n field,\n value\n });\n }\n };\n const childFields = field.settings?.fields;\n if (!childFields?.length) {\n return collection;\n }\n\n const result = createFieldCollection({\n fields: childFields,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n list: field.list\n }\n ],\n transformValuePlugins,\n valuePathPlugins,\n system\n });\n Object.assign(collection, result);\n return collection;\n }, {});\n};\n/**\n * This method will map the fieldId (fieldId -> field) to the actual field.\n *\n * In case of nested fields, fieldId is all the parent fieldIds + current one, joined by the dot (.).\n */\nexport const createFields = (params: Params) => {\n const { fields, plugins } = params;\n\n const transformValuePlugins = getMappedPlugins<CmsFieldFilterValueTransformPlugin>({\n plugins,\n type: \"cms-field-filter-value-transform\",\n property: \"fieldType\"\n });\n const valuePathPlugins = getMappedPlugins<CmsEntryFieldFilterPathPlugin>({\n plugins,\n type: CmsEntryFieldFilterPathPlugin.type,\n property: \"fieldType\"\n });\n\n const collection = createFieldCollection({\n fields: createSystemFields(),\n transformValuePlugins,\n valuePathPlugins,\n parents: [],\n system: true\n });\n\n const result = createFieldCollection({\n fields,\n transformValuePlugins,\n valuePathPlugins,\n parents: [\n {\n fieldId: \"values\",\n list: false\n }\n ],\n system: false\n });\n\n return {\n ...collection,\n ...result\n };\n};\n"],"names":["createFieldCollection","params","fields","parents","transformValuePlugins","valuePathPlugins","system","collection","field","fieldType","getBaseFieldType","transformPlugin","valuePathPlugin","fieldId","f","p","parent","value","childFields","result","Object","createFields","plugins","getMappedPlugins","CmsEntryFieldFilterPathPlugin","createSystemFields"],"mappings":";;;;AA0BA,MAAMA,wBAAwB,CAACC;IAC3B,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,qBAAqB,EAAEC,gBAAgB,EAAEC,MAAM,EAAE,GAAGL;IAC7E,OAAOC,OAAO,MAAM,CAAkB,CAACK,YAAYC;QAC/C,MAAMC,YAAYC,iBAAiBF;QACnC,MAAMG,kBAAkBP,qBAAqB,CAACK,UAAU;QACxD,MAAMG,kBAAkBP,gBAAgB,CAACI,UAAU;QAKnD,MAAMI,UAAU;eACTV;YACH;gBACI,SAASK,MAAM,OAAO;gBACtB,MAAMA,MAAM,IAAI;YACpB;SACH,CACI,GAAG,CAACM,CAAAA,IAAKA,EAAE,OAAO,EAClB,IAAI,CAAC;QAEVP,UAAU,CAACM,QAAQ,GAAG;YAClB,GAAGL,KAAK;YACRL;YACAG;YACA,YAAYL,CAAAA;gBACR,IACIW,mBACAA,gBAAgB,MAAM,CAClBJ,OACAL,QAAQ,GAAG,CAACY,CAAAA,IAAKA,EAAE,OAAO,IAG9B,OAAOH,gBAAgB,UAAU,CAACX;gBAGtC,OAAOE,QACF,GAAG,CAACa,CAAAA,SAAUA,OAAO,OAAO,EAC5B,MAAM,CAAC;oBAACf,OAAO,KAAK,CAAC,OAAO;iBAAC,EAC7B,IAAI,CAAC;YACd;YACA,WAAWgB,CAAAA;gBACP,IAAI,CAACN,iBACD,OAAOM;gBAEX,OAAON,gBAAgB,SAAS,CAAC;oBAC7BH;oBACAS;gBACJ;YACJ;QACJ;QACA,MAAMC,cAAcV,MAAM,QAAQ,EAAE;QACpC,IAAI,CAACU,aAAa,QACd,OAAOX;QAGX,MAAMY,SAASnB,sBAAsB;YACjC,QAAQkB;YACR,SAAS;mBACFf;gBACH;oBACI,SAASK,MAAM,OAAO;oBACtB,MAAMA,MAAM,IAAI;gBACpB;aACH;YACDJ;YACAC;YACAC;QACJ;QACAc,OAAO,MAAM,CAACb,YAAYY;QAC1B,OAAOZ;IACX,GAAG,CAAC;AACR;AAMO,MAAMc,eAAe,CAACpB;IACzB,MAAM,EAAEC,MAAM,EAAEoB,OAAO,EAAE,GAAGrB;IAE5B,MAAMG,wBAAwBmB,iBAAqD;QAC/ED;QACA,MAAM;QACN,UAAU;IACd;IACA,MAAMjB,mBAAmBkB,iBAAgD;QACrED;QACA,MAAME,8BAA8B,IAAI;QACxC,UAAU;IACd;IAEA,MAAMjB,aAAaP,sBAAsB;QACrC,QAAQyB;QACRrB;QACAC;QACA,SAAS,EAAE;QACX,QAAQ;IACZ;IAEA,MAAMc,SAASnB,sBAAsB;QACjCE;QACAE;QACAC;QACA,SAAS;YACL;gBACI,SAAS;gBACT,MAAM;YACV;SACH;QACD,QAAQ;IACZ;IAEA,OAAO;QACH,GAAGE,UAAU;QACb,GAAGY,MAAM;IACb;AACJ"}
@@ -1,17 +0,0 @@
1
- import type { Field } from "./types.js";
2
- import type { PluginsContainer } from "@webiny/plugins";
3
- import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
- interface IResponse {
5
- valuePath: string;
6
- reverse: boolean;
7
- fieldId: string;
8
- field: Field;
9
- }
10
- interface IParams {
11
- model: CmsModel;
12
- sortBy: string;
13
- fields: Record<string, Field>;
14
- plugins: PluginsContainer;
15
- }
16
- export declare const extractSort: (params: IParams) => IResponse;
17
- export {};
@@ -1,60 +0,0 @@
1
- import error from "@webiny/error";
2
- import { CmsEntryFieldSortingPlugin } from "../../../plugins/index.js";
3
- const extractSortInfo = (sortBy)=>{
4
- const rootSorting = sortBy.match(/^([a-zA-Z]+)_(ASC|DESC)$/);
5
- if (rootSorting) return {
6
- fieldId: rootSorting[1],
7
- isValues: false,
8
- order: rootSorting[2]
9
- };
10
- const valuesSorting = sortBy.match(/^values_([a-zA-Z0-9]+)_(ASC|DESC)$/);
11
- if (valuesSorting) return {
12
- fieldId: valuesSorting[1],
13
- isValues: true,
14
- order: valuesSorting[2]
15
- };
16
- throw new error("Problem in determining the sorting for the entry items.", "SORT_EXTRACT_ERROR", {
17
- sortBy
18
- });
19
- };
20
- const extractSort = (params)=>{
21
- const { model, sortBy, fields, plugins } = params;
22
- const { fieldId, isValues: isValuesSorting, order } = extractSortInfo(sortBy);
23
- const field = Object.values(fields).find((f)=>{
24
- const isValues = f.parents[0]?.fieldId === "values";
25
- if (isValues && isValuesSorting) return f.fieldId === fieldId;
26
- if (f.parents.length > 0) return false;
27
- return f.fieldId === fieldId;
28
- });
29
- const plugin = plugins.byType(CmsEntryFieldSortingPlugin.type).reverse().find((plugin)=>plugin.canUse({
30
- model,
31
- field,
32
- fieldId,
33
- order,
34
- sortBy
35
- }));
36
- if (plugin) return plugin.createSort({
37
- model,
38
- fieldId,
39
- order,
40
- sortBy,
41
- field,
42
- fields
43
- });
44
- else if (!field) throw new error("Sorting field does not exist in the content model.", "SORTING_FIELD_ERROR", {
45
- fieldId,
46
- fields
47
- });
48
- const valuePath = field.createPath({
49
- field
50
- });
51
- return {
52
- field,
53
- fieldId,
54
- valuePath,
55
- reverse: "DESC" === order
56
- };
57
- };
58
- export { extractSort };
59
-
60
- //# sourceMappingURL=extractSort.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operations/entry/filtering/extractSort.js","sources":["../../../../src/operations/entry/filtering/extractSort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { Field } from \"./types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryFieldSortingPlugin } from \"~/plugins/index.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst extractSortInfo = (sortBy: string) => {\n const rootSorting = sortBy.match(/^([a-zA-Z]+)_(ASC|DESC)$/);\n if (rootSorting) {\n return {\n fieldId: rootSorting[1],\n isValues: false,\n order: rootSorting[2] as \"ASC\" | \"DESC\"\n };\n }\n const valuesSorting = sortBy.match(/^values_([a-zA-Z0-9]+)_(ASC|DESC)$/);\n if (valuesSorting) {\n return {\n fieldId: valuesSorting[1],\n isValues: true,\n order: valuesSorting[2] as \"ASC\" | \"DESC\"\n };\n }\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_EXTRACT_ERROR\",\n {\n sortBy\n }\n );\n};\n\ninterface IResponse {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface IParams {\n model: CmsModel;\n sortBy: string;\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\nexport const extractSort = (params: IParams): IResponse => {\n const { model, sortBy, fields, plugins } = params;\n const { fieldId, isValues: isValuesSorting, order } = extractSortInfo(sortBy);\n\n const field = Object.values(fields).find(f => {\n /**\n * We do not support sorting by nested fields.\n */\n const isValues = f.parents[0]?.fieldId === \"values\";\n if (isValues && isValuesSorting) {\n return f.fieldId === fieldId;\n }\n if (f.parents.length > 0) {\n return false;\n }\n return f.fieldId === fieldId;\n });\n\n const plugin = plugins\n .byType<CmsEntryFieldSortingPlugin>(CmsEntryFieldSortingPlugin.type)\n .reverse()\n .find(plugin => {\n return plugin.canUse({\n model,\n field,\n fieldId,\n order,\n sortBy\n });\n });\n\n if (plugin) {\n return plugin.createSort({\n model,\n fieldId,\n order,\n sortBy,\n field,\n fields\n });\n } else if (!field) {\n throw new WebinyError(\n \"Sorting field does not exist in the content model.\",\n \"SORTING_FIELD_ERROR\",\n {\n fieldId,\n fields\n }\n );\n }\n const valuePath = field.createPath({\n field\n });\n return {\n field,\n fieldId,\n valuePath,\n reverse: order === \"DESC\"\n };\n};\n"],"names":["extractSortInfo","sortBy","rootSorting","valuesSorting","WebinyError","extractSort","params","model","fields","plugins","fieldId","isValuesSorting","order","field","Object","f","isValues","plugin","CmsEntryFieldSortingPlugin","valuePath"],"mappings":";;AAMA,MAAMA,kBAAkB,CAACC;IACrB,MAAMC,cAAcD,OAAO,KAAK,CAAC;IACjC,IAAIC,aACA,OAAO;QACH,SAASA,WAAW,CAAC,EAAE;QACvB,UAAU;QACV,OAAOA,WAAW,CAAC,EAAE;IACzB;IAEJ,MAAMC,gBAAgBF,OAAO,KAAK,CAAC;IACnC,IAAIE,eACA,OAAO;QACH,SAASA,aAAa,CAAC,EAAE;QACzB,UAAU;QACV,OAAOA,aAAa,CAAC,EAAE;IAC3B;IAEJ,MAAM,IAAIC,MACN,2DACA,sBACA;QACIH;IACJ;AAER;AAgBO,MAAMI,cAAc,CAACC;IACxB,MAAM,EAAEC,KAAK,EAAEN,MAAM,EAAEO,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAC3C,MAAM,EAAEI,OAAO,EAAE,UAAUC,eAAe,EAAEC,KAAK,EAAE,GAAGZ,gBAAgBC;IAEtE,MAAMY,QAAQC,OAAO,MAAM,CAACN,QAAQ,IAAI,CAACO,CAAAA;QAIrC,MAAMC,WAAWD,EAAE,OAAO,CAAC,EAAE,EAAE,YAAY;QAC3C,IAAIC,YAAYL,iBACZ,OAAOI,EAAE,OAAO,KAAKL;QAEzB,IAAIK,EAAE,OAAO,CAAC,MAAM,GAAG,GACnB,OAAO;QAEX,OAAOA,EAAE,OAAO,KAAKL;IACzB;IAEA,MAAMO,SAASR,QACV,MAAM,CAA6BS,2BAA2B,IAAI,EAClE,OAAO,GACP,IAAI,CAACD,CAAAA,SACKA,OAAO,MAAM,CAAC;YACjBV;YACAM;YACAH;YACAE;YACAX;QACJ;IAGR,IAAIgB,QACA,OAAOA,OAAO,UAAU,CAAC;QACrBV;QACAG;QACAE;QACAX;QACAY;QACAL;IACJ;SACG,IAAI,CAACK,OACR,MAAM,IAAIT,MACN,sDACA,uBACA;QACIM;QACAF;IACJ;IAGR,MAAMW,YAAYN,MAAM,UAAU,CAAC;QAC/BA;IACJ;IACA,OAAO;QACHA;QACAH;QACAS;QACA,SAASP,AAAU,WAAVA;IACb;AACJ"}