@webiny/api-headless-cms-ddb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9
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.
- package/README.md +6 -20
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +9 -94
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +9 -68
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +9 -90
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +8 -30
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +11 -20
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +21 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +13 -37
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +27 -50
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -3
- package/index.js +83 -139
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +42 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +14 -30
- package/operations/entry/dataLoaders.js +83 -314
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +27 -0
- package/operations/entry/filtering/createExpressions.js +124 -0
- package/operations/entry/filtering/createExpressions.js.map +1 -0
- package/operations/entry/filtering/createFields.d.ts +16 -0
- package/operations/entry/filtering/createFields.js +93 -0
- package/operations/entry/filtering/createFields.js.map +1 -0
- package/operations/entry/filtering/extractSort.d.ts +17 -0
- package/operations/entry/filtering/extractSort.js +60 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +16 -0
- package/operations/entry/filtering/filter.js +85 -0
- package/operations/entry/filtering/filter.js.map +1 -0
- package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
- package/operations/entry/filtering/fullTextSearch.js +25 -0
- package/operations/entry/filtering/fullTextSearch.js.map +1 -0
- package/operations/entry/filtering/getValue.d.ts +5 -0
- package/operations/entry/filtering/getValue.js +37 -0
- package/operations/entry/filtering/getValue.js.map +1 -0
- package/operations/entry/filtering/index.d.ts +2 -0
- package/operations/entry/filtering/index.js +2 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +18 -0
- package/operations/entry/filtering/mapPlugins.js.map +1 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +33 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/filtering/plugins/index.js +13 -0
- package/operations/entry/filtering/plugins/index.js.map +1 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js +68 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +63 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +49 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +41 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +2 -0
- package/operations/entry/filtering/systemFields.js +149 -0
- package/operations/entry/filtering/systemFields.js.map +1 -0
- package/operations/entry/filtering/transform.d.ts +6 -0
- package/operations/entry/filtering/transform.js +7 -0
- package/operations/entry/filtering/transform.js.map +1 -0
- package/operations/entry/filtering/types.d.ts +40 -0
- package/operations/entry/filtering/types.js +0 -0
- package/operations/entry/filtering/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +15 -0
- package/operations/entry/filtering/values.js.map +1 -0
- package/operations/entry/filtering/where.d.ts +5 -0
- package/operations/entry/filtering/where.js +22 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +931 -845
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +53 -66
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -5
- package/operations/group/index.js +116 -187
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +102 -158
- package/operations/model/index.js.map +1 -1
- package/package.json +34 -33
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +5 -4
- package/plugins/CmsEntryFieldFilterPathPlugin.js +25 -50
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +20 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +20 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +19 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -1
- package/plugins/index.js +4 -18
- package/types.d.ts +28 -21
- package/types.js +8 -15
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -58
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -46
- package/definitions/system.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -2
- package/dynamoDb/storage/date.js +0 -99
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -101
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -113
- package/dynamoDb/storage/richText.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -74
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/entry/utils.d.ts +0 -36
- package/operations/entry/utils.js +0 -680
- package/operations/entry/utils.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -135
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -99
- package/operations/system/index.js.map +0 -1
- package/plugins/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"operations/model/index.js","sources":["../../../src/operations/model/index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { convertException } from \"@webiny/utils\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating model partitionKey.`);\n }\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\ninterface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\n}\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(`Could not create CMS Content Model.`, \"CREATE_MODEL_ERROR\", {\n error: convertException(ex),\n model,\n keys\n });\n }\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n\n const partitionKey = createPartitionKey(where);\n\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result.map(item => {\n return item.data;\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"names":["createPartitionKey","params","tenant","WebinyError","createSortKey","createKeys","createType","createModelsStorageOperations","entity","create","model","keys","ex","convertException","update","deleteModel","get","result","list","where","partitionKey","item"],"mappings":";;AAeA,MAAMA,qBAAqB,CAACC;IACxB,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,IAAI,CAACC,QACD,MAAM,IAAIC,MAAY;IAE1B,OAAO,CAAC,EAAE,EAAED,OAAO,OAAO,CAAC;AAC/B;AAKA,MAAME,gBAAgB,CAACH,SACZA,OAAO,OAAO;AAQzB,MAAMI,aAAa,CAACJ,SACT;QACH,IAAID,mBAAmBC;QACvB,IAAIG,cAAcH;QAClB,YAAYA,OAAO,MAAM;IAC7B;AAGJ,MAAMK,aAAa,IACR;AAMJ,MAAMC,gCAAgC,CACzCN;IAEA,MAAM,EAAEO,MAAM,EAAE,GAAGP;IAEnB,MAAMQ,SAAS,OAAOR;QAClB,MAAM,EAAES,KAAK,EAAE,GAAGT;QAElB,MAAMU,OAAON,WAAWK;QAExB,IAAI;YACA,MAAMF,OAAO,GAAG,CAAC;gBACb,MAAME;gBACN,GAAGC,IAAI;gBACP,MAAML;YACV;YACA,OAAOI;QACX,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIT,MAAY,uCAAuC,sBAAsB;gBAC/E,OAAOU,iBAAiBD;gBACxBF;gBACAC;YACJ;QACJ;IACJ;IAEA,MAAMG,SAAS,OAAOb;QAClB,MAAM,EAAES,KAAK,EAAE,GAAGT;QAElB,MAAMU,OAAON,WAAWK;QAExB,IAAI;YACA,MAAMF,OAAO,GAAG,CAAC;gBACb,MAAME;gBACN,GAAGC,IAAI;gBACP,MAAML;YACV;YACA,OAAOI;QACX,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIT,MACNS,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPF;gBACAC;YACJ;QAER;IACJ;IAEA,MAAMI,cAAc,OAAOd;QACvB,MAAM,EAAES,KAAK,EAAE,GAAGT;QAClB,MAAMU,OAAON,WAAWK;QAExB,IAAI;YACA,MAAMF,OAAO,MAAM,CAACG;QACxB,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIT,MACNS,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBACI,OAAOA;gBACPF;gBACAC;YACJ;QAER;IACJ;IAEA,MAAMK,MAAM,OAAOf;QACf,MAAMU,OAAON,WAAWJ;QAExB,IAAI;YACA,MAAMgB,SAAS,MAAMT,OAAO,GAAG,CAACG;YAChC,OAAOM,QAAQ,QAAQ;QAC3B,EAAE,OAAOL,IAAI;YACT,MAAM,IAAIT,MACNS,GAAG,OAAO,IAAI,wBACdA,GAAG,IAAI,IAAI,mBACX;gBACI,OAAOA;gBACPD;YACJ;QAER;IACJ;IAEA,MAAMO,OAAO,OAAOjB;QAChB,MAAM,EAAEkB,KAAK,EAAE,GAAGlB;QAElB,MAAMmB,eAAepB,mBAAmBmB;QAExC,IAAI;YACA,MAAMF,SAAS,MAAMT,OAAO,QAAQ,CAAC;gBACjCY;gBACA,SAAS;oBACL,KAAK;gBACT;YACJ;YACA,OAAOH,OAAO,GAAG,CAACI,CAAAA,OACPA,KAAK,IAAI;QAExB,EAAE,OAAOT,IAAI;YACT,MAAM,IAAIT,MACNS,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBACI,OAAOA;gBACPQ;YACJ;QAER;IACJ;IAEA,OAAO;QACHX;QACAK;QACA,QAAQC;QACRC;QACAE;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"keywords": [
|
|
6
10
|
"@webiny/api-headless-cms",
|
|
7
11
|
"storage-operations",
|
|
8
12
|
"dynamodb",
|
|
13
|
+
"ddb",
|
|
9
14
|
"cms:ddb"
|
|
10
15
|
],
|
|
11
16
|
"repository": {
|
|
@@ -21,40 +26,36 @@
|
|
|
21
26
|
],
|
|
22
27
|
"license": "MIT",
|
|
23
28
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
29
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
30
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
|
|
31
|
+
"@webiny/aws-sdk": "0.0.0-unstable.7be00a75a9",
|
|
32
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7be00a75a9",
|
|
33
|
+
"@webiny/error": "0.0.0-unstable.7be00a75a9",
|
|
34
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
35
|
+
"@webiny/handler": "0.0.0-unstable.7be00a75a9",
|
|
36
|
+
"@webiny/handler-db": "0.0.0-unstable.7be00a75a9",
|
|
37
|
+
"@webiny/utils": "0.0.0-unstable.7be00a75a9",
|
|
38
|
+
"dataloader": "2.2.3",
|
|
39
|
+
"dot-object": "2.1.5",
|
|
40
|
+
"dot-prop": "10.1.0",
|
|
41
|
+
"lodash": "4.18.1"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@webiny/
|
|
43
|
-
"@webiny/
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"jest-environment-node": "^27.2.4",
|
|
48
|
-
"ttypescript": "^1.5.12",
|
|
49
|
-
"typescript": "4.7.4"
|
|
44
|
+
"@types/dot-object": "2.1.6",
|
|
45
|
+
"@types/jsonpack": "1.1.6",
|
|
46
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
47
|
+
"@webiny/di": "0.0.0-unstable.7be00a75a9",
|
|
48
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9",
|
|
49
|
+
"@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
|
|
50
|
+
"jest-dynalite": "3.6.1",
|
|
51
|
+
"typescript": "6.0.3",
|
|
52
|
+
"vitest": "4.1.7"
|
|
50
53
|
},
|
|
51
54
|
"publishConfig": {
|
|
52
|
-
"access": "public"
|
|
53
|
-
"directory": "dist"
|
|
54
|
-
},
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "yarn webiny run build",
|
|
57
|
-
"watch": "yarn webiny run watch"
|
|
55
|
+
"access": "public"
|
|
58
56
|
},
|
|
59
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
|
|
58
|
+
"webiny": {
|
|
59
|
+
"publishFrom": "dist"
|
|
60
|
+
}
|
|
60
61
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
export interface CreatePathCallableParams {
|
|
4
|
-
field: CmsModelField
|
|
4
|
+
field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id">;
|
|
5
5
|
index?: number;
|
|
6
6
|
}
|
|
7
7
|
export interface CreatePathCallable {
|
|
@@ -11,12 +11,13 @@ export interface CmsEntryFieldFilterPathPluginParams {
|
|
|
11
11
|
fieldType: string;
|
|
12
12
|
fieldId?: string[];
|
|
13
13
|
path: string | CreatePathCallable;
|
|
14
|
+
canUse?: (field: Pick<CmsModelField, "fieldId" | "type">, parents?: string[]) => boolean;
|
|
14
15
|
}
|
|
15
16
|
export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
16
17
|
static readonly type: string;
|
|
17
18
|
private readonly config;
|
|
18
19
|
get fieldType(): string;
|
|
19
20
|
constructor(config: CmsEntryFieldFilterPathPluginParams);
|
|
20
|
-
canUse(field: CmsModelField): boolean;
|
|
21
|
+
canUse(field: Pick<CmsModelField, "fieldId" | "type">, parents: string[]): boolean;
|
|
21
22
|
createPath(params: CreatePathCallableParams): string;
|
|
22
23
|
}
|
|
@@ -1,55 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.CmsEntryFieldFilterPathPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
15
|
-
|
|
16
|
-
class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
|
|
17
|
-
get fieldType() {
|
|
18
|
-
return this.config.fieldType;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
constructor(config) {
|
|
22
|
-
super();
|
|
23
|
-
(0, _defineProperty2.default)(this, "config", void 0);
|
|
24
|
-
this.config = config;
|
|
25
|
-
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
canUse(field) {
|
|
29
|
-
if (field.type !== this.config.fieldType) {
|
|
30
|
-
return false;
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
3
|
+
class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
4
|
+
static{
|
|
5
|
+
this.type = "cms-field-filter-path";
|
|
31
6
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
36
|
-
return true;
|
|
7
|
+
get fieldType() {
|
|
8
|
+
return this.config.fieldType;
|
|
37
9
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
10
|
+
constructor(config){
|
|
11
|
+
super();
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
14
|
+
}
|
|
15
|
+
canUse(field, parents) {
|
|
16
|
+
if (field.type !== this.config.fieldType) return false;
|
|
17
|
+
if (this.config.canUse) return this.config.canUse(field, parents);
|
|
18
|
+
const fieldId = this.config.fieldId;
|
|
19
|
+
if (!fieldId || false === Array.isArray(fieldId) || 0 === fieldId.length) return true;
|
|
20
|
+
return fieldId.includes(field.fieldId);
|
|
21
|
+
}
|
|
22
|
+
createPath(params) {
|
|
23
|
+
if ("function" == typeof this.config.path) return this.config.path(params);
|
|
24
|
+
if ("string" == typeof this.config.path) return this.config.path;
|
|
25
|
+
throw new error(`Missing path in "${this.name}" plugin.`);
|
|
47
26
|
}
|
|
48
|
-
|
|
49
|
-
throw new _error.default(`Missing path in "${this.name}" plugin.`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
27
|
}
|
|
28
|
+
export { CmsEntryFieldFilterPathPlugin };
|
|
53
29
|
|
|
54
|
-
|
|
55
|
-
(0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
|
|
30
|
+
//# sourceMappingURL=CmsEntryFieldFilterPathPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/CmsEntryFieldFilterPathPlugin.js","sources":["../../src/plugins/CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface CreatePathCallableParams {\n field: Partial<CmsModelField> & Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\">;\n index?: number;\n}\nexport interface CreatePathCallable {\n (params: CreatePathCallableParams): string;\n}\nexport interface CmsEntryFieldFilterPathPluginParams {\n fieldType: string;\n fieldId?: string[];\n path: string | CreatePathCallable;\n canUse?: (field: Pick<CmsModelField, \"fieldId\" | \"type\">, parents?: string[]) => boolean;\n}\nexport class CmsEntryFieldFilterPathPlugin extends Plugin {\n public static override readonly type: string = \"cms-field-filter-path\";\n\n private readonly config: CmsEntryFieldFilterPathPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(config: CmsEntryFieldFilterPathPluginParams) {\n super();\n\n this.config = config;\n\n /**\n * We expect error here because we know that `this.constructor.type` is defined, but TS does not.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">, parents: string[]): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n } else if (this.config.canUse) {\n return this.config.canUse(field, parents);\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"names":["CmsEntryFieldFilterPathPlugin","Plugin","config","field","parents","fieldId","Array","params","WebinyError"],"mappings":";;AAiBO,MAAMA,sCAAsCC;;aACf,IAAI,GAAW;;IAI/C,IAAW,YAAoB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS;IAChC;IAEA,YAAmBC,MAA2C,CAAE;QAC5D,KAAK;QAEL,IAAI,CAAC,MAAM,GAAGA;QAMd,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;IACnE;IAEO,OAAOC,KAA8C,EAAEC,OAAiB,EAAW;QACtF,IAAID,MAAM,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,SAAS,EACpC,OAAO;QACJ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EACzB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAACA,OAAOC;QAErC,MAAMC,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO;QACnC,IAAI,CAACA,WAAWC,AAA2B,UAA3BA,MAAM,OAAO,CAACD,YAAsBA,AAAmB,MAAnBA,QAAQ,MAAM,EAC9D,OAAO;QAEX,OAAOA,QAAQ,QAAQ,CAACF,MAAM,OAAO;IACzC;IAEO,WAAWI,MAAgC,EAAU;QACxD,IAAI,AAA4B,cAA5B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EACvB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAACA;QACrB,IAAI,AAA4B,YAA5B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI;QAE3B,MAAM,IAAIC,MAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAClE;AACJ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Field } from "../operations/entry/filtering/types.js";
|
|
3
|
+
import type { CmsFieldFilterValueTransformPlugin } from "../types.js";
|
|
4
|
+
import { ValueFilterRegistry } from "@webiny/db-dynamodb/feature/ValueFilter/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* This plugin is used to create the filter.
|
|
7
|
+
* Internally we have default one + the one for the reference field - because it is actually an object when filtering.
|
|
8
|
+
*/
|
|
9
|
+
interface CmsEntryFieldFilterPluginParams<T = any> {
|
|
10
|
+
fieldType: string;
|
|
11
|
+
create: (params: CmsEntryFieldFilterPluginCreateParams<T>) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
|
|
12
|
+
}
|
|
13
|
+
interface CmsEntryFieldFilterPluginCreateParams<T = any> {
|
|
14
|
+
key: string;
|
|
15
|
+
value: T;
|
|
16
|
+
field: Field;
|
|
17
|
+
fields: Record<string, Field>;
|
|
18
|
+
operation: string;
|
|
19
|
+
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
20
|
+
transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;
|
|
21
|
+
getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;
|
|
22
|
+
negate: boolean;
|
|
23
|
+
compareValue: any;
|
|
24
|
+
transformValue: <I = any, O = any>(value: I) => O;
|
|
25
|
+
}
|
|
26
|
+
export interface CmsEntryFieldFilterPluginCreateResponse {
|
|
27
|
+
field: Field;
|
|
28
|
+
path: string;
|
|
29
|
+
fieldPathId: string;
|
|
30
|
+
filter: ValueFilterRegistry.Filter;
|
|
31
|
+
negate: boolean;
|
|
32
|
+
compareValue: any;
|
|
33
|
+
transformValue: <I = any, O = any>(value: I) => O;
|
|
34
|
+
}
|
|
35
|
+
export declare class CmsEntryFieldFilterPlugin<T = any> extends Plugin {
|
|
36
|
+
static readonly type: string;
|
|
37
|
+
static readonly ALL: string;
|
|
38
|
+
private readonly config;
|
|
39
|
+
readonly fieldType: string;
|
|
40
|
+
constructor(config: CmsEntryFieldFilterPluginParams<T>);
|
|
41
|
+
create(params: CmsEntryFieldFilterPluginCreateParams<T>): CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[] | null;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class CmsEntryFieldFilterPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "cms.dynamodb.entry.field.filter";
|
|
5
|
+
}
|
|
6
|
+
static{
|
|
7
|
+
this.ALL = "*";
|
|
8
|
+
}
|
|
9
|
+
constructor(config){
|
|
10
|
+
super();
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.fieldType = this.config.fieldType;
|
|
13
|
+
}
|
|
14
|
+
create(params) {
|
|
15
|
+
return this.config.create(params);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export { CmsEntryFieldFilterPlugin };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=CmsEntryFieldFilterPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/CmsEntryFieldFilterPlugin.js","sources":["../../src/plugins/CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Field } from \"~/operations/entry/filtering/types.js\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { ValueFilterRegistry } from \"@webiny/db-dynamodb/feature/ValueFilter/index.js\";\n\n/**\n * This plugin is used to create the filter.\n * Internally we have default one + the one for the reference field - because it is actually an object when filtering.\n */\n\ninterface CmsEntryFieldFilterPluginParams<T = any> {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams<T>\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams<T = any> {\n key: string;\n value: T;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n valueFilterRegistry: ValueFilterRegistry.Interface;\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n getFilterCreatePlugin: (type: string) => CmsEntryFieldFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport interface CmsEntryFieldFilterPluginCreateResponse {\n field: Field;\n path: string;\n fieldPathId: string;\n filter: ValueFilterRegistry.Filter;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFieldFilterPlugin<T = any> extends Plugin {\n public static override readonly type: string = \"cms.dynamodb.entry.field.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFieldFilterPluginParams<T>;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams<T>) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams<T>) {\n return this.config.create(params);\n }\n}\n"],"names":["CmsEntryFieldFilterPlugin","Plugin","config","params"],"mappings":";AAyCO,MAAMA,kCAA2CC;;aACpB,IAAI,GAAW;;;aACxB,GAAG,GAAW;;IAMrC,YAAmBC,MAA0C,CAAE;QAC3D,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS;IAC1C;IAEO,OAAOC,MAAgD,EAAE;QAC5D,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAACA;IAC9B;AACJ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Field } from "../operations/entry/filtering/types.js";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
|
+
interface CmsEntryFieldSortingPluginCanUseParams {
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
field?: Field;
|
|
7
|
+
fieldId: string;
|
|
8
|
+
order: "ASC" | "DESC";
|
|
9
|
+
/**
|
|
10
|
+
* Combination of fieldId and sortBy
|
|
11
|
+
*
|
|
12
|
+
* example: id_ASC or createdBy_DESC
|
|
13
|
+
*/
|
|
14
|
+
sortBy: string;
|
|
15
|
+
}
|
|
16
|
+
interface CmsEntryFieldSortingPluginCreateSortParams {
|
|
17
|
+
model: CmsModel;
|
|
18
|
+
fieldId: string;
|
|
19
|
+
order: "ASC" | "DESC";
|
|
20
|
+
sortBy: string;
|
|
21
|
+
fields: Record<string, Field>;
|
|
22
|
+
field?: Field;
|
|
23
|
+
}
|
|
24
|
+
interface CmsEntryFieldSortingPluginCreateSortResult {
|
|
25
|
+
valuePath: string;
|
|
26
|
+
reverse: boolean;
|
|
27
|
+
fieldId: string;
|
|
28
|
+
field: Field;
|
|
29
|
+
}
|
|
30
|
+
interface CmsEntryFieldSortingPluginConfig {
|
|
31
|
+
createSort: (params: CmsEntryFieldSortingPluginCreateSortParams) => CmsEntryFieldSortingPluginCreateSortResult;
|
|
32
|
+
canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class CmsEntryFieldSortingPlugin extends Plugin {
|
|
35
|
+
static readonly type: string;
|
|
36
|
+
private readonly config;
|
|
37
|
+
constructor(config: CmsEntryFieldSortingPluginConfig);
|
|
38
|
+
canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean;
|
|
39
|
+
createSort(params: CmsEntryFieldSortingPluginCreateSortParams): CmsEntryFieldSortingPluginCreateSortResult;
|
|
40
|
+
}
|
|
41
|
+
export declare const createCmsEntryFieldSortingPlugin: (config: CmsEntryFieldSortingPluginConfig) => CmsEntryFieldSortingPlugin;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class CmsEntryFieldSortingPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "cms.entry.field.sorting";
|
|
5
|
+
}
|
|
6
|
+
constructor(config){
|
|
7
|
+
super();
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
canUse(params) {
|
|
11
|
+
return this.config.canUse(params);
|
|
12
|
+
}
|
|
13
|
+
createSort(params) {
|
|
14
|
+
return this.config.createSort(params);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const createCmsEntryFieldSortingPlugin = (config)=>new CmsEntryFieldSortingPlugin(config);
|
|
18
|
+
export { CmsEntryFieldSortingPlugin, createCmsEntryFieldSortingPlugin };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=CmsEntryFieldSortingPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/CmsEntryFieldSortingPlugin.js","sources":["../../src/plugins/CmsEntryFieldSortingPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { Field } from \"~/operations/entry/filtering/types.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface CmsEntryFieldSortingPluginCanUseParams {\n model: CmsModel;\n field?: Field;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n /**\n * Combination of fieldId and sortBy\n *\n * example: id_ASC or createdBy_DESC\n */\n sortBy: string;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortParams {\n model: CmsModel;\n fieldId: string;\n order: \"ASC\" | \"DESC\";\n sortBy: string;\n fields: Record<string, Field>;\n field?: Field;\n}\n\ninterface CmsEntryFieldSortingPluginCreateSortResult {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface CmsEntryFieldSortingPluginConfig {\n createSort: (\n params: CmsEntryFieldSortingPluginCreateSortParams\n ) => CmsEntryFieldSortingPluginCreateSortResult;\n canUse: (params: CmsEntryFieldSortingPluginCanUseParams) => boolean;\n}\n\nexport class CmsEntryFieldSortingPlugin extends Plugin {\n public static override readonly type: string = \"cms.entry.field.sorting\";\n private readonly config: CmsEntryFieldSortingPluginConfig;\n\n public constructor(config: CmsEntryFieldSortingPluginConfig) {\n super();\n this.config = config;\n }\n\n public canUse(params: CmsEntryFieldSortingPluginCanUseParams): boolean {\n return this.config.canUse(params);\n }\n\n public createSort(\n params: CmsEntryFieldSortingPluginCreateSortParams\n ): CmsEntryFieldSortingPluginCreateSortResult {\n return this.config.createSort(params);\n }\n}\n\nexport const createCmsEntryFieldSortingPlugin = (config: CmsEntryFieldSortingPluginConfig) => {\n return new CmsEntryFieldSortingPlugin(config);\n};\n"],"names":["CmsEntryFieldSortingPlugin","Plugin","config","params","createCmsEntryFieldSortingPlugin"],"mappings":";AAwCO,MAAMA,mCAAmCC;;aACZ,IAAI,GAAW;;IAG/C,YAAmBC,MAAwC,CAAE;QACzD,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEO,OAAOC,MAA8C,EAAW;QACnE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAACA;IAC9B;IAEO,WACHA,MAAkD,EACR;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAACA;IAClC;AACJ;AAEO,MAAMC,mCAAmC,CAACF,SACtC,IAAIF,2BAA2BE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { CmsFieldFilterValueTransformPlugin as CmsFieldFilterValueTransformPluginInterface } from "../types.js";
|
|
3
|
+
type CmsFieldFilterValueTransformPluginParams = Omit<CmsFieldFilterValueTransformPluginInterface, "type">;
|
|
4
|
+
export declare class CmsFieldFilterValueTransformPlugin extends Plugin implements Omit<CmsFieldFilterValueTransformPluginInterface, "type"> {
|
|
5
|
+
static type: string;
|
|
6
|
+
private config;
|
|
7
|
+
get fieldType(): string;
|
|
8
|
+
get transform(): CmsFieldFilterValueTransformPluginParams["transform"];
|
|
9
|
+
constructor(config: CmsFieldFilterValueTransformPluginParams);
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
class CmsFieldFilterValueTransformPlugin extends Plugin {
|
|
3
|
+
static{
|
|
4
|
+
this.type = "cms-field-filter-value-transform";
|
|
5
|
+
}
|
|
6
|
+
get fieldType() {
|
|
7
|
+
return this.config.fieldType;
|
|
8
|
+
}
|
|
9
|
+
get transform() {
|
|
10
|
+
return this.config.transform;
|
|
11
|
+
}
|
|
12
|
+
constructor(config){
|
|
13
|
+
super();
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { CmsFieldFilterValueTransformPlugin };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=CmsFieldFilterValueTransformPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins/CmsFieldFilterValueTransformPlugin.js","sources":["../../src/plugins/CmsFieldFilterValueTransformPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { CmsFieldFilterValueTransformPlugin as CmsFieldFilterValueTransformPluginInterface } from \"~/types.js\";\n\ntype CmsFieldFilterValueTransformPluginParams = Omit<\n CmsFieldFilterValueTransformPluginInterface,\n \"type\"\n>;\nexport class CmsFieldFilterValueTransformPlugin\n extends Plugin\n implements Omit<CmsFieldFilterValueTransformPluginInterface, \"type\">\n{\n public static override type = \"cms-field-filter-value-transform\";\n\n private config: CmsFieldFilterValueTransformPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public get transform(): CmsFieldFilterValueTransformPluginParams[\"transform\"] {\n return this.config.transform;\n }\n\n public constructor(config: CmsFieldFilterValueTransformPluginParams) {\n super();\n this.config = config;\n }\n}\n"],"names":["CmsFieldFilterValueTransformPlugin","Plugin","config"],"mappings":";AAOO,MAAMA,2CACDC;;aAGe,IAAI,GAAG;;IAI9B,IAAW,YAAoB;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS;IAChC;IAEA,IAAW,YAAmE;QAC1E,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS;IAChC;IAEA,YAAmBC,MAAgD,CAAE;QACjE,KAAK;QACL,IAAI,CAAC,MAAM,GAAGA;IAClB;AACJ"}
|
package/plugins/index.d.ts
CHANGED
package/plugins/index.js
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
|
|
8
|
-
|
|
9
|
-
Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _CmsEntryFieldFilterPathPlugin[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
1
|
+
export * from "./CmsEntryFieldFilterPathPlugin.js";
|
|
2
|
+
export * from "./CmsEntryFieldSortingPlugin.js";
|
|
3
|
+
export * from "./CmsEntryFieldFilterPlugin.js";
|
|
4
|
+
export * from "./CmsFieldFilterValueTransformPlugin.js";
|
package/types.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
-
import { CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { type Plugin, PluginsContainer } from "@webiny/plugins/types.js";
|
|
2
|
+
import type { CmsContext, CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
4
|
+
import type { IEntryEntity, IGroupEntity, IModelEntity } from "./definitions/types.js";
|
|
5
|
+
import type { ITable } from "@webiny/db-dynamodb";
|
|
6
|
+
export type { CmsContext };
|
|
7
|
+
export type { IGroupEntity, IModelEntity, IEntryEntity };
|
|
7
8
|
interface CmsFieldFilterValueTransformParams {
|
|
8
9
|
/**
|
|
9
10
|
* A field which value we are transforming.
|
|
10
11
|
*/
|
|
11
|
-
field: CmsModelField
|
|
12
|
+
field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
|
|
12
13
|
value: any;
|
|
13
14
|
}
|
|
14
15
|
export interface CmsFieldFilterValueTransformPlugin extends Plugin {
|
|
@@ -25,29 +26,35 @@ export interface CmsFieldFilterValueTransformPlugin extends Plugin {
|
|
|
25
26
|
*/
|
|
26
27
|
transform: (params: CmsFieldFilterValueTransformParams) => any;
|
|
27
28
|
}
|
|
28
|
-
export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
|
|
29
|
-
export declare type Attributes = Record<string, AttributeDefinition>;
|
|
30
29
|
export declare enum ENTITIES {
|
|
31
|
-
SYSTEM = "CmsSystem",
|
|
32
|
-
SETTINGS = "CmsSettings",
|
|
33
30
|
GROUPS = "CmsGroups",
|
|
34
31
|
MODELS = "CmsModels",
|
|
35
32
|
ENTRIES = "CmsEntries"
|
|
36
33
|
}
|
|
37
|
-
export interface TableModifier {
|
|
38
|
-
(table: TableConstructor): TableConstructor;
|
|
39
|
-
}
|
|
40
34
|
export interface StorageOperationsFactoryParams {
|
|
41
|
-
documentClient:
|
|
42
|
-
table?:
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
documentClient: DynamoDBDocument;
|
|
36
|
+
table?: string;
|
|
37
|
+
plugins: PluginsContainer;
|
|
38
|
+
container: CmsContext["container"];
|
|
39
|
+
}
|
|
40
|
+
export interface IHeadlessCmsStorageOperationsGetEntitiesResult {
|
|
41
|
+
groups: IGroupEntity;
|
|
42
|
+
models: IModelEntity;
|
|
43
|
+
entries: IEntryEntity;
|
|
45
44
|
}
|
|
46
45
|
export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
|
|
47
|
-
getTable: () =>
|
|
48
|
-
getEntities: () =>
|
|
46
|
+
getTable: () => ITable;
|
|
47
|
+
getEntities: () => IHeadlessCmsStorageOperationsGetEntitiesResult;
|
|
49
48
|
}
|
|
50
49
|
export interface StorageOperationsFactory {
|
|
51
50
|
(params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
|
|
52
51
|
}
|
|
53
|
-
export {
|
|
52
|
+
export interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {
|
|
53
|
+
dataLoaders: IDataLoadersHandler;
|
|
54
|
+
}
|
|
55
|
+
export interface DataLoadersHandlerInterfaceClearAllParams {
|
|
56
|
+
model: Pick<CmsModel, "tenant">;
|
|
57
|
+
}
|
|
58
|
+
export interface IDataLoadersHandler {
|
|
59
|
+
clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
|
|
60
|
+
}
|
package/types.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
|
|
2
|
+
ENTITIES["GROUPS"] = "CmsGroups";
|
|
3
|
+
ENTITIES["MODELS"] = "CmsModels";
|
|
4
|
+
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
5
|
+
return ENTITIES;
|
|
6
|
+
}({});
|
|
7
|
+
export { types_ENTITIES as ENTITIES };
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ENTITIES = void 0;
|
|
7
|
-
let ENTITIES;
|
|
8
|
-
exports.ENTITIES = ENTITIES;
|
|
9
|
-
|
|
10
|
-
(function (ENTITIES) {
|
|
11
|
-
ENTITIES["SYSTEM"] = "CmsSystem";
|
|
12
|
-
ENTITIES["SETTINGS"] = "CmsSettings";
|
|
13
|
-
ENTITIES["GROUPS"] = "CmsGroups";
|
|
14
|
-
ENTITIES["MODELS"] = "CmsModels";
|
|
15
|
-
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
16
|
-
})(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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 CmsModel,\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 model: Pick<CmsModel, \"tenant\">;\n}\nexport interface IDataLoadersHandler {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAwCO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
|
-
import { Attributes } from "../types";
|
|
3
|
-
interface Params {
|
|
4
|
-
table: Table;
|
|
5
|
-
entityName: string;
|
|
6
|
-
attributes: Attributes;
|
|
7
|
-
}
|
|
8
|
-
export declare const createSettingsEntity: (params: Params) => Entity<any>;
|
|
9
|
-
export {};
|