@webiny/api-headless-cms-ddb 0.0.0-unstable.611c5af35e → 0.0.0-unstable.615a930a68
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/definitions/entry.js +5 -0
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +5 -0
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +5 -0
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +5 -0
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +5 -0
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +3 -0
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.js +7 -0
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/plainObject.js +8 -1
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/date.js +29 -4
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +17 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +18 -0
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.js +8 -1
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.js +32 -5
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +44 -1
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +18 -0
- package/operations/entry/filtering/createFields.js +124 -0
- package/operations/entry/filtering/createFields.js.map +1 -0
- package/operations/entry/filtering/createFilters.d.ts +20 -0
- package/operations/entry/filtering/createFilters.js +155 -0
- package/operations/entry/filtering/createFilters.js.map +1 -0
- package/operations/entry/filtering/extractSort.d.ts +13 -0
- package/operations/entry/filtering/extractSort.js +55 -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 +137 -0
- package/operations/entry/filtering/filter.js.map +1 -0
- package/operations/entry/filtering/fullTextSearch.d.ts +18 -0
- package/operations/entry/filtering/fullTextSearch.js +64 -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 +81 -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 +21 -0
- package/operations/entry/filtering/index.js.map +1 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +39 -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 +48 -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 +18 -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 +107 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +89 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +9 -0
- package/operations/entry/filtering/sort.js +80 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +4 -0
- package/operations/entry/filtering/systemFields.js +72 -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 +19 -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 +5 -0
- package/operations/entry/filtering/types.js.map +1 -0
- package/operations/entry/filtering/where.d.ts +5 -0
- package/operations/entry/filtering/where.js +38 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.js +98 -13
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +18 -0
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/systemFields.js +2 -0
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/entry/utils.js +121 -3
- package/operations/entry/utils.js.map +1 -1
- package/operations/group/index.js +32 -2
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +25 -0
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +24 -0
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +17 -0
- package/operations/system/index.js.map +1 -1
- package/package.json +12 -12
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js +14 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +31 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/index.js +2 -0
- package/plugins/index.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js +1 -0
- package/types.js.map +1 -1
|
@@ -1,58 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.createSettingsStorageOperations = void 0;
|
|
9
|
+
|
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
9
12
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
13
|
+
|
|
10
14
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
11
16
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
+
|
|
12
18
|
const convertToDbData = settings => {
|
|
13
19
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
14
20
|
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
15
21
|
});
|
|
16
22
|
};
|
|
23
|
+
|
|
17
24
|
const convertFromDbData = settings => {
|
|
18
25
|
if (!settings) {
|
|
19
26
|
return null;
|
|
20
27
|
}
|
|
28
|
+
|
|
21
29
|
let contentModelLastChange;
|
|
30
|
+
|
|
22
31
|
try {
|
|
23
32
|
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
24
33
|
} catch {
|
|
25
34
|
contentModelLastChange = new Date();
|
|
26
35
|
}
|
|
36
|
+
|
|
27
37
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
28
38
|
contentModelLastChange
|
|
29
39
|
});
|
|
30
40
|
};
|
|
41
|
+
|
|
31
42
|
const createPartitionKey = ({
|
|
32
43
|
tenant,
|
|
33
44
|
locale
|
|
34
45
|
}) => {
|
|
35
46
|
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
36
47
|
};
|
|
48
|
+
|
|
37
49
|
const createSortKey = () => {
|
|
38
50
|
return "settings";
|
|
39
51
|
};
|
|
52
|
+
|
|
40
53
|
const createKeys = params => {
|
|
41
54
|
return {
|
|
42
55
|
PK: createPartitionKey(params),
|
|
43
56
|
SK: createSortKey()
|
|
44
57
|
};
|
|
45
58
|
};
|
|
59
|
+
|
|
46
60
|
const createSettingsStorageOperations = params => {
|
|
47
61
|
const {
|
|
48
62
|
entity
|
|
49
63
|
} = params;
|
|
64
|
+
|
|
50
65
|
const create = async params => {
|
|
51
66
|
const {
|
|
52
67
|
settings
|
|
53
68
|
} = params;
|
|
54
69
|
const keys = createKeys(settings);
|
|
55
70
|
const dbSettings = convertToDbData(settings);
|
|
71
|
+
|
|
56
72
|
try {
|
|
57
73
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
58
74
|
return settings;
|
|
@@ -65,12 +81,14 @@ const createSettingsStorageOperations = params => {
|
|
|
65
81
|
});
|
|
66
82
|
}
|
|
67
83
|
};
|
|
84
|
+
|
|
68
85
|
const update = async params => {
|
|
69
86
|
const {
|
|
70
87
|
settings
|
|
71
88
|
} = params;
|
|
72
89
|
const keys = createKeys(settings);
|
|
73
90
|
const dbSettings = convertToDbData(settings);
|
|
91
|
+
|
|
74
92
|
try {
|
|
75
93
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
76
94
|
return settings;
|
|
@@ -83,16 +101,20 @@ const createSettingsStorageOperations = params => {
|
|
|
83
101
|
});
|
|
84
102
|
}
|
|
85
103
|
};
|
|
104
|
+
|
|
86
105
|
const get = async params => {
|
|
87
106
|
const keys = createKeys(params);
|
|
107
|
+
|
|
88
108
|
try {
|
|
89
109
|
const record = await (0, _get.get)({
|
|
90
110
|
entity,
|
|
91
111
|
keys
|
|
92
112
|
});
|
|
113
|
+
|
|
93
114
|
if (!record) {
|
|
94
115
|
return null;
|
|
95
116
|
}
|
|
117
|
+
|
|
96
118
|
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
97
119
|
return convertFromDbData(settings);
|
|
98
120
|
} catch (ex) {
|
|
@@ -102,10 +124,12 @@ const createSettingsStorageOperations = params => {
|
|
|
102
124
|
});
|
|
103
125
|
}
|
|
104
126
|
};
|
|
127
|
+
|
|
105
128
|
return {
|
|
106
129
|
create,
|
|
107
130
|
get,
|
|
108
131
|
update
|
|
109
132
|
};
|
|
110
133
|
};
|
|
134
|
+
|
|
111
135
|
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;AAMA,MAAMA,eAAe,GAAIC,QAAD,IAA0C;EAC9D,mEACOA,QADP;IAEIC,sBAAsB,EAAED,QAAQ,CAACC,sBAAT,CAAgCC,WAAhC;EAF5B;AAIH,CALD;;AAOA,MAAMC,iBAAiB,GAAIH,QAAD,IAAkD;EACxE,IAAI,CAACA,QAAL,EAAe;IACX,OAAO,IAAP;EACH;;EACD,IAAIC,sBAAJ;;EACA,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAJ,CAASJ,QAAQ,CAACC,sBAAlB,CAAzB;EACH,CAFD,CAEE,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAJ,EAAzB;EACH;;EACD,mEACOJ,QADP;IAEIC;EAFJ;AAIH,CAdD;;AAqBA,MAAMI,kBAAkB,GAAG,CAAC;EAAEC,MAAF;EAAUC;AAAV,CAAD,KAAoD;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAA/B;AACH,CAFD;;AAIA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,UAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;IAEHE,EAAE,EAAEJ,aAAa;EAFd,CAAP;AAIH,CALD;;AAWO,MAAMK,+BAA+B,GACxCH,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AAMgB,MAAM,GAAG,MAAM,IAAAC,QAAA,EAAyB;QAC1Cb,MAD0C;QAE1CE;MAF0C,CAAzB,CAArB;;MAIA,IAAI,CAACU,MAAL,EAAa;QACT,OAAO,IAAP;MACH;;MACD,MAAM1B,QAAQ,GAAG,IAAA4B,oBAAA,EAAYd,MAAZ,EAAoBY,MAApB,CAAjB;MACA,OAAOvB,iBAAiB,CAACH,QAAD,CAAxB;IACH,CAVD,CAUE,OAAOmB,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,yBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,oBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIH;MAFJ,CAHE,CAAN;IAQH;EACJ,CAtBD;;EAwBA,OAAO;IACHD,MADG;IAEHU,GAFG;IAGHD;EAHG,CAAP;AAKH,CAvFM"}
|
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.createSystemStorageOperations = void 0;
|
|
9
|
+
|
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
9
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
10
14
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
+
|
|
11
16
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
+
|
|
12
18
|
const createPartitionKey = ({
|
|
13
19
|
tenant
|
|
14
20
|
}) => {
|
|
15
21
|
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
16
22
|
};
|
|
23
|
+
|
|
17
24
|
const createSortKey = () => {
|
|
18
25
|
return "CMS";
|
|
19
26
|
};
|
|
27
|
+
|
|
20
28
|
const createKeys = params => {
|
|
21
29
|
return {
|
|
22
30
|
PK: createPartitionKey(params),
|
|
23
31
|
SK: createSortKey()
|
|
24
32
|
};
|
|
25
33
|
};
|
|
34
|
+
|
|
26
35
|
const createSystemStorageOperations = params => {
|
|
27
36
|
const {
|
|
28
37
|
entity
|
|
29
38
|
} = params;
|
|
39
|
+
|
|
30
40
|
const create = async ({
|
|
31
41
|
system
|
|
32
42
|
}) => {
|
|
33
43
|
const keys = createKeys(system);
|
|
44
|
+
|
|
34
45
|
try {
|
|
35
46
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
36
47
|
return system;
|
|
@@ -42,11 +53,13 @@ const createSystemStorageOperations = params => {
|
|
|
42
53
|
});
|
|
43
54
|
}
|
|
44
55
|
};
|
|
56
|
+
|
|
45
57
|
const update = async params => {
|
|
46
58
|
const {
|
|
47
59
|
system
|
|
48
60
|
} = params;
|
|
49
61
|
const keys = createKeys(system);
|
|
62
|
+
|
|
50
63
|
try {
|
|
51
64
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
52
65
|
return system;
|
|
@@ -58,8 +71,10 @@ const createSystemStorageOperations = params => {
|
|
|
58
71
|
});
|
|
59
72
|
}
|
|
60
73
|
};
|
|
74
|
+
|
|
61
75
|
const get = async params => {
|
|
62
76
|
const keys = createKeys(params);
|
|
77
|
+
|
|
63
78
|
try {
|
|
64
79
|
const system = await (0, _get.get)({
|
|
65
80
|
entity,
|
|
@@ -73,10 +88,12 @@ const createSystemStorageOperations = params => {
|
|
|
73
88
|
});
|
|
74
89
|
}
|
|
75
90
|
};
|
|
91
|
+
|
|
76
92
|
return {
|
|
77
93
|
create,
|
|
78
94
|
update,
|
|
79
95
|
get
|
|
80
96
|
};
|
|
81
97
|
};
|
|
98
|
+
|
|
82
99
|
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA4C;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;IAEHE,EAAE,EAAEJ,aAAa;EAFd,CAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;EAC7B,MAAM;IAAEI;EAAF,IAAaJ,MAAnB;;EAEA,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAAF,CAAP,KAA8D;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAD,CAAvB;;IACA,IAAI;MACA,MAAMF,MAAM,CAACI,GAAP,6DACCF,MADD,GAECC,IAFD,EAAN;MAIA,OAAOD,MAAP;IACH,CAND,CAME,OAAOG,EAAP,EAAW;MACT,MAAM,IA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
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.615a930a68",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
26
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
27
|
-
"@webiny/error": "0.0.0-unstable.
|
|
28
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
29
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
30
|
-
"aws-sdk": "2.
|
|
24
|
+
"@babel/runtime": "7.19.0",
|
|
25
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.615a930a68",
|
|
26
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.615a930a68",
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.615a930a68",
|
|
28
|
+
"@webiny/handler-db": "0.0.0-unstable.615a930a68",
|
|
29
|
+
"@webiny/utils": "0.0.0-unstable.615a930a68",
|
|
30
|
+
"aws-sdk": "2.1230.0",
|
|
31
31
|
"dataloader": "2.1.0",
|
|
32
32
|
"dot-prop": "6.0.1",
|
|
33
33
|
"dynamodb-toolbox": "0.3.5",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/core": "^7.19.3",
|
|
40
40
|
"@babel/preset-env": "^7.19.4",
|
|
41
41
|
"@types/jsonpack": "^1.1.0",
|
|
42
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
43
|
-
"@webiny/plugins": "^0.0.0-unstable.
|
|
44
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
42
|
+
"@webiny/cli": "^0.0.0-unstable.615a930a68",
|
|
43
|
+
"@webiny/plugins": "^0.0.0-unstable.615a930a68",
|
|
44
|
+
"@webiny/project-utils": "^0.0.0-unstable.615a930a68",
|
|
45
45
|
"jest": "^28.1.0",
|
|
46
46
|
"jest-dynalite": "^3.2.0",
|
|
47
47
|
"jest-environment-node": "^27.2.4",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"build": "yarn webiny run build",
|
|
57
57
|
"watch": "yarn webiny run watch"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "615a930a68d692c832e4f100405eeb3f5a8874af"
|
|
60
60
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
2
|
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
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 {
|
|
@@ -17,6 +17,6 @@ export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
|
17
17
|
private readonly config;
|
|
18
18
|
get fieldType(): string;
|
|
19
19
|
constructor(config: CmsEntryFieldFilterPathPluginParams);
|
|
20
|
-
canUse(field: CmsModelField): boolean;
|
|
20
|
+
canUse(field: Pick<CmsModelField, "fieldId" | "type">): boolean;
|
|
21
21
|
createPath(params: CreatePathCallableParams): string;
|
|
22
22
|
}
|
|
@@ -1,41 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.CmsEntryFieldFilterPathPlugin = void 0;
|
|
9
|
+
|
|
8
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
9
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
10
14
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
15
|
+
|
|
11
16
|
class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
|
|
12
17
|
get fieldType() {
|
|
13
18
|
return this.config.fieldType;
|
|
14
19
|
}
|
|
20
|
+
|
|
15
21
|
constructor(config) {
|
|
16
22
|
super();
|
|
17
23
|
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
24
|
this.config = config;
|
|
19
25
|
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
20
26
|
}
|
|
27
|
+
|
|
21
28
|
canUse(field) {
|
|
22
29
|
if (field.type !== this.config.fieldType) {
|
|
23
30
|
return false;
|
|
24
31
|
}
|
|
32
|
+
|
|
25
33
|
const fieldId = this.config.fieldId;
|
|
34
|
+
|
|
26
35
|
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
27
36
|
return true;
|
|
28
37
|
}
|
|
38
|
+
|
|
29
39
|
return fieldId.includes(field.fieldId);
|
|
30
40
|
}
|
|
41
|
+
|
|
31
42
|
createPath(params) {
|
|
32
43
|
if (typeof this.config.path === "function") {
|
|
33
44
|
return this.config.path(params);
|
|
34
45
|
} else if (typeof this.config.path === "string") {
|
|
35
46
|
return this.config.path;
|
|
36
47
|
}
|
|
48
|
+
|
|
37
49
|
throw new _error.default(`Missing path in "${this.name}" plugin.`);
|
|
38
50
|
}
|
|
51
|
+
|
|
39
52
|
}
|
|
53
|
+
|
|
40
54
|
exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
|
|
41
55
|
(0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams {\n field: CmsModelField
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\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}\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 this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\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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ugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
3
|
+
import { Field } from "../operations/entry/filtering/types";
|
|
4
|
+
import { CmsFieldFilterValueTransformPlugin } from "../types";
|
|
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 {
|
|
10
|
+
fieldType: string;
|
|
11
|
+
create: (params: CmsEntryFieldFilterPluginCreateParams) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
|
|
12
|
+
}
|
|
13
|
+
interface CmsEntryFieldFilterPluginCreateParams {
|
|
14
|
+
key: string;
|
|
15
|
+
value: any;
|
|
16
|
+
field: Field;
|
|
17
|
+
fields: Record<string, Field>;
|
|
18
|
+
operation: string;
|
|
19
|
+
valueFilterPlugins: Record<string, ValueFilterPlugin>;
|
|
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
|
+
plugin: ValueFilterPlugin;
|
|
31
|
+
negate: boolean;
|
|
32
|
+
compareValue: any;
|
|
33
|
+
transformValue: <I = any, O = any>(value: I) => O;
|
|
34
|
+
}
|
|
35
|
+
export declare class CmsEntryFieldFilterPlugin extends Plugin {
|
|
36
|
+
static readonly type: string;
|
|
37
|
+
static readonly ALL: string;
|
|
38
|
+
private readonly config;
|
|
39
|
+
readonly fieldType: string;
|
|
40
|
+
constructor(config: CmsEntryFieldFilterPluginParams);
|
|
41
|
+
create(params: CmsEntryFieldFilterPluginCreateParams): CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[] | null;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsEntryFieldFilterPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("@webiny/plugins");
|
|
13
|
+
|
|
14
|
+
class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "fieldType", void 0);
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.fieldType = this.config.fieldType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
create(params) {
|
|
24
|
+
return this.config.create(params);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
|
|
30
|
+
(0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "type", "cms.dynamodb.entry.field.filter");
|
|
31
|
+
(0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "ALL", "*");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldFilterPlugin","Plugin","constructor","config","fieldType","create","params"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\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 {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams {\n key: string;\n value: any;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n valueFilterPlugins: Record<string, ValueFilterPlugin>;\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 plugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport class CmsEntryFieldFilterPlugin 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;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams) {\n return this.config.create(params);\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AAyCO,MAAMA,yBAAN,SAAwCC,eAAxC,CAA+C;EAQ3CC,WAAW,CAACC,MAAD,EAA0C;IACxD;IADwD;IAAA;IAExD,KAAKA,MAAL,GAAcA,MAAd;IACA,KAAKC,SAAL,GAAiB,KAAKD,MAAL,CAAYC,SAA7B;EACH;;EAEMC,MAAM,CAACC,MAAD,EAAgD;IACzD,OAAO,KAAKH,MAAL,CAAYE,MAAZ,CAAmBC,MAAnB,CAAP;EACH;;AAhBiD;;;8BAAzCN,yB,UACsC,iC;8BADtCA,yB,SAE4B,G"}
|
package/plugins/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
|
|
6
7
|
var _CmsEntryFieldFilterPathPlugin = require("./CmsEntryFieldFilterPathPlugin");
|
|
8
|
+
|
|
7
9
|
Object.keys(_CmsEntryFieldFilterPathPlugin).forEach(function (key) {
|
|
8
10
|
if (key === "default" || key === "__esModule") return;
|
|
9
11
|
if (key in exports && exports[key] === _CmsEntryFieldFilterPathPlugin[key]) return;
|
package/plugins/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsEntryFieldFilterPathPlugin\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./CmsEntryFieldFilterPathPlugin\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ interface CmsFieldFilterValueTransformParams {
|
|
|
8
8
|
/**
|
|
9
9
|
* A field which value we are transforming.
|
|
10
10
|
*/
|
|
11
|
-
field: CmsModelField
|
|
11
|
+
field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
|
|
12
12
|
value: any;
|
|
13
13
|
}
|
|
14
14
|
export interface CmsFieldFilterValueTransformPlugin extends Plugin {
|
package/types.js
CHANGED
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: CmsModelField
|
|
1
|
+
{"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\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 type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEntities: () => Record<\"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n"],"mappings":";;;;;;IAyCYA,Q;;;WAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;GAAAA,Q,wBAAAA,Q"}
|