@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.085ff6572f
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.d.ts +2 -1
- package/definitions/entry.js +12 -12
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +2 -1
- package/definitions/group.js +3 -12
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -1
- package/definitions/model.js +25 -12
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -1
- package/definitions/settings.js +3 -12
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -1
- package/definitions/system.js +3 -12
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +7 -17
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +41 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +2 -3
- package/dynamoDb/path/plainObject.js +25 -25
- package/dynamoDb/path/plainObject.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +3 -3
- package/dynamoDb/storage/date.js +71 -54
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +72 -64
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +62 -77
- package/dynamoDb/storage/richText.js.map +1 -0
- package/dynamoDb/transformValue/datetime.d.ts +4 -2
- package/dynamoDb/transformValue/datetime.js +28 -30
- package/dynamoDb/transformValue/datetime.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +54 -45
- package/index.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +43 -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 +9 -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 +23 -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 +43 -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 +57 -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 +57 -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 +63 -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 +38 -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 +5 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +17 -28
- package/operations/entry/dataLoaders.js +51 -239
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +176 -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 +105 -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 +67 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +15 -0
- package/operations/entry/filtering/filter.js +143 -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 +48 -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 +63 -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 +19 -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 +31 -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 +43 -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 +88 -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 +73 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +69 -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 +88 -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 +16 -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/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +22 -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 +33 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +3 -3
- package/operations/entry/index.js +425 -330
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +7 -14
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +3 -2
- package/operations/group/index.js +9 -45
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +3 -2
- package/operations/model/index.js +13 -37
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +3 -2
- package/operations/settings/index.js +7 -37
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +3 -2
- package/operations/system/index.js +5 -28
- package/operations/system/index.js.map +1 -0
- package/package.json +25 -26
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +23 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js +43 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +24 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +28 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +49 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +11 -33
- package/types.js +0 -1
- package/types.js.map +1 -0
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -50
- package/operations/entry/utils.d.ts +0 -31
- package/operations/entry/utils.js +0 -406
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","WebinyError","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","create","model","keys","put","cleanupItem","TYPE","ex","error","update","message","code","deleteModel","delete","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating model partitionKey.`);\n } else if (!locale) {\n throw new WebinyError(`Missing locale variable when creating model partitionKey.`);\n }\n return `T#${tenant}#L#${locale}#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}\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\ninterface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\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 ...cleanupItem(entity, 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: 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 ...cleanupItem(entity, 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 return model;\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 item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\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 const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\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: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAWA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,IAAI,CAACC,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CAAE,2DAA0D,CAAC;EACtF,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;IAChB,MAAM,IAAIC,cAAW,CAAE,2DAA0D,CAAC;EACtF;EACA,OAAQ,KAAIF,MAAO,MAAKC,MAAO,SAAQ;AAC3C,CAAC;AAKD,MAAME,aAAa,GAAIJ,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACK,OAAO;AACzB,CAAC;AAMD,MAAMC,UAAU,GAAIN,MAA2C,IAAW;EACtE,OAAO;IACHO,EAAE,EAAER,kBAAkB,CAACC,MAAM,CAAC;IAC9BQ,EAAE,EAAEJ,aAAa,CAACJ,MAAM;EAC5B,CAAC;AACL,CAAC;AAED,MAAMS,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAKM,MAAMC,6BAA6B,GACtCV,MAA2C,IACf;EAC5B,MAAM;IAAEW;EAAO,CAAC,GAAGX,MAAM;EAEzB,MAAMY,MAAM,GAAG,MAAOZ,MAA6C,IAAK;IACpE,MAAM;MAAEa;IAAM,CAAC,GAAGb,MAAM;IAExB,MAAMc,IAAI,GAAGR,UAAU,CAACO,KAAK,CA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IACnBE,GAAG;IACHG;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
|
|
3
|
+
interface CreateSettingsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSettingsStorageOperations: (params:
|
|
6
|
+
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -1,80 +1,60 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSettingsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
12
|
const convertToDbData = settings => {
|
|
23
|
-
return
|
|
13
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
24
14
|
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
25
15
|
});
|
|
26
16
|
};
|
|
27
|
-
|
|
28
17
|
const convertFromDbData = settings => {
|
|
29
18
|
if (!settings) {
|
|
30
19
|
return null;
|
|
31
20
|
}
|
|
32
|
-
|
|
33
21
|
let contentModelLastChange;
|
|
34
|
-
|
|
35
22
|
try {
|
|
36
23
|
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
37
24
|
} catch {
|
|
38
25
|
contentModelLastChange = new Date();
|
|
39
26
|
}
|
|
40
|
-
|
|
41
|
-
return _objectSpread(_objectSpread({}, settings), {}, {
|
|
27
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
42
28
|
contentModelLastChange
|
|
43
29
|
});
|
|
44
30
|
};
|
|
45
|
-
|
|
46
31
|
const createPartitionKey = ({
|
|
47
32
|
tenant,
|
|
48
33
|
locale
|
|
49
34
|
}) => {
|
|
50
35
|
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
51
36
|
};
|
|
52
|
-
|
|
53
37
|
const createSortKey = () => {
|
|
54
38
|
return "settings";
|
|
55
39
|
};
|
|
56
|
-
|
|
57
40
|
const createKeys = params => {
|
|
58
41
|
return {
|
|
59
42
|
PK: createPartitionKey(params),
|
|
60
43
|
SK: createSortKey()
|
|
61
44
|
};
|
|
62
45
|
};
|
|
63
|
-
|
|
64
46
|
const createSettingsStorageOperations = params => {
|
|
65
47
|
const {
|
|
66
48
|
entity
|
|
67
49
|
} = params;
|
|
68
|
-
|
|
69
50
|
const create = async params => {
|
|
70
51
|
const {
|
|
71
52
|
settings
|
|
72
53
|
} = params;
|
|
73
54
|
const keys = createKeys(settings);
|
|
74
55
|
const dbSettings = convertToDbData(settings);
|
|
75
|
-
|
|
76
56
|
try {
|
|
77
|
-
await entity.put(
|
|
57
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
78
58
|
return settings;
|
|
79
59
|
} catch (ex) {
|
|
80
60
|
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
@@ -85,42 +65,34 @@ const createSettingsStorageOperations = params => {
|
|
|
85
65
|
});
|
|
86
66
|
}
|
|
87
67
|
};
|
|
88
|
-
|
|
89
68
|
const update = async params => {
|
|
90
69
|
const {
|
|
91
|
-
settings
|
|
92
|
-
original
|
|
70
|
+
settings
|
|
93
71
|
} = params;
|
|
94
72
|
const keys = createKeys(settings);
|
|
95
73
|
const dbSettings = convertToDbData(settings);
|
|
96
|
-
|
|
97
74
|
try {
|
|
98
|
-
await entity.put(
|
|
75
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
99
76
|
return settings;
|
|
100
77
|
} catch (ex) {
|
|
101
78
|
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
102
79
|
error: ex,
|
|
103
80
|
settings,
|
|
104
81
|
dbSettings,
|
|
105
|
-
original,
|
|
106
82
|
keys
|
|
107
83
|
});
|
|
108
84
|
}
|
|
109
85
|
};
|
|
110
|
-
|
|
111
86
|
const get = async params => {
|
|
112
87
|
const keys = createKeys(params);
|
|
113
|
-
|
|
114
88
|
try {
|
|
115
89
|
const record = await (0, _get.get)({
|
|
116
90
|
entity,
|
|
117
91
|
keys
|
|
118
92
|
});
|
|
119
|
-
|
|
120
93
|
if (!record) {
|
|
121
94
|
return null;
|
|
122
95
|
}
|
|
123
|
-
|
|
124
96
|
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
125
97
|
return convertFromDbData(settings);
|
|
126
98
|
} catch (ex) {
|
|
@@ -130,12 +102,10 @@ const createSettingsStorageOperations = params => {
|
|
|
130
102
|
});
|
|
131
103
|
}
|
|
132
104
|
};
|
|
133
|
-
|
|
134
105
|
return {
|
|
135
106
|
create,
|
|
136
107
|
get,
|
|
137
108
|
update
|
|
138
109
|
};
|
|
139
110
|
};
|
|
140
|
-
|
|
141
111
|
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -0,0 +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 || \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,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,yBAAyB,EACvCF,EAAE,CAACG,IAAI,IAAI,oBAAoB,EAC/B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHD,MAAM;IACNU,GAAG;IACHD;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
|
|
3
|
+
interface CreateSystemStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSystemStorageOperations: (params:
|
|
6
|
+
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -1,53 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSystemStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
10
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
11
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
12
|
const createPartitionKey = ({
|
|
23
13
|
tenant
|
|
24
14
|
}) => {
|
|
25
15
|
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
26
16
|
};
|
|
27
|
-
|
|
28
17
|
const createSortKey = () => {
|
|
29
18
|
return "CMS";
|
|
30
19
|
};
|
|
31
|
-
|
|
32
20
|
const createKeys = params => {
|
|
33
21
|
return {
|
|
34
22
|
PK: createPartitionKey(params),
|
|
35
23
|
SK: createSortKey()
|
|
36
24
|
};
|
|
37
25
|
};
|
|
38
|
-
|
|
39
26
|
const createSystemStorageOperations = params => {
|
|
40
27
|
const {
|
|
41
28
|
entity
|
|
42
29
|
} = params;
|
|
43
|
-
|
|
44
30
|
const create = async ({
|
|
45
31
|
system
|
|
46
32
|
}) => {
|
|
47
33
|
const keys = createKeys(system);
|
|
48
|
-
|
|
49
34
|
try {
|
|
50
|
-
await entity.put(
|
|
35
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
51
36
|
return system;
|
|
52
37
|
} catch (ex) {
|
|
53
38
|
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
@@ -57,30 +42,24 @@ const createSystemStorageOperations = params => {
|
|
|
57
42
|
});
|
|
58
43
|
}
|
|
59
44
|
};
|
|
60
|
-
|
|
61
45
|
const update = async params => {
|
|
62
46
|
const {
|
|
63
|
-
system
|
|
64
|
-
original
|
|
47
|
+
system
|
|
65
48
|
} = params;
|
|
66
49
|
const keys = createKeys(system);
|
|
67
|
-
|
|
68
50
|
try {
|
|
69
|
-
await entity.put(
|
|
51
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
70
52
|
return system;
|
|
71
53
|
} catch (ex) {
|
|
72
54
|
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
55
|
error: ex,
|
|
74
56
|
system,
|
|
75
|
-
original,
|
|
76
57
|
keys
|
|
77
58
|
});
|
|
78
59
|
}
|
|
79
60
|
};
|
|
80
|
-
|
|
81
61
|
const get = async params => {
|
|
82
62
|
const keys = createKeys(params);
|
|
83
|
-
|
|
84
63
|
try {
|
|
85
64
|
const system = await (0, _get.get)({
|
|
86
65
|
entity,
|
|
@@ -94,12 +73,10 @@ const createSystemStorageOperations = params => {
|
|
|
94
73
|
});
|
|
95
74
|
}
|
|
96
75
|
};
|
|
97
|
-
|
|
98
76
|
return {
|
|
99
77
|
create,
|
|
100
78
|
update,
|
|
101
79
|
get
|
|
102
80
|
};
|
|
103
81
|
};
|
|
104
|
-
|
|
105
82
|
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
@@ -0,0 +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":";;;;;;;;AAQA;AACA;AACA;AASA,MAAMA,kBAAkB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E;QACTH,MAAM;QACNC;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMQ,GAAG,GAAG,MAAOf,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,MAAMM,MAAM,GAAG,MAAM,IAAAU,QAAS,EAAY;QACtCZ,MAAM;QACNG;MACJ,CAAC,CAAC;MACF,OAAO,IAAAU,oBAAW,EAACb,MAAM,EAAEE,MAAM,CAAC;IACtC,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTF;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNS,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.085ff6572f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
7
7
|
"storage-operations",
|
|
8
8
|
"dynamodb",
|
|
9
|
+
"ddb",
|
|
9
10
|
"cms:ddb"
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
@@ -21,33 +22,31 @@
|
|
|
21
22
|
],
|
|
22
23
|
"license": "MIT",
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-
|
|
26
|
-
"@webiny/db-dynamodb": "0.0.0-
|
|
27
|
-
"@webiny/error": "0.0.0-
|
|
28
|
-
"@webiny/handler-db": "0.0.0-
|
|
29
|
-
"@webiny/utils": "0.0.0-
|
|
30
|
-
"aws-sdk": "2.
|
|
31
|
-
"dataloader": "2.
|
|
32
|
-
"dot-prop": "
|
|
33
|
-
"dynamodb-toolbox": "0.3.
|
|
25
|
+
"@babel/runtime": "7.20.13",
|
|
26
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.085ff6572f",
|
|
27
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.085ff6572f",
|
|
28
|
+
"@webiny/error": "0.0.0-unstable.085ff6572f",
|
|
29
|
+
"@webiny/handler-db": "0.0.0-unstable.085ff6572f",
|
|
30
|
+
"@webiny/utils": "0.0.0-unstable.085ff6572f",
|
|
31
|
+
"aws-sdk": "2.1310.0",
|
|
32
|
+
"dataloader": "2.2.1",
|
|
33
|
+
"dot-prop": "6.0.1",
|
|
34
|
+
"dynamodb-toolbox": "0.3.5",
|
|
34
35
|
"jsonpack": "1.1.5",
|
|
35
|
-
"lodash
|
|
36
|
+
"lodash": "4.17.21"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@babel/cli": "
|
|
39
|
-
"@babel/core": "
|
|
40
|
-
"@babel/preset-env": "
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@webiny/
|
|
44
|
-
"@webiny/
|
|
45
|
-
"
|
|
46
|
-
"jest": "
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"ttypescript": "^1.5.12",
|
|
50
|
-
"typescript": "^4.1.3"
|
|
39
|
+
"@babel/cli": "7.20.7",
|
|
40
|
+
"@babel/core": "7.20.12",
|
|
41
|
+
"@babel/preset-env": "7.20.2",
|
|
42
|
+
"@types/jsonpack": "1.1.2",
|
|
43
|
+
"@webiny/cli": "0.0.0-unstable.085ff6572f",
|
|
44
|
+
"@webiny/plugins": "0.0.0-unstable.085ff6572f",
|
|
45
|
+
"@webiny/project-utils": "0.0.0-unstable.085ff6572f",
|
|
46
|
+
"jest": "29.5.0",
|
|
47
|
+
"jest-dynalite": "3.6.1",
|
|
48
|
+
"ttypescript": "1.5.15",
|
|
49
|
+
"typescript": "4.7.4"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"access": "public",
|
|
@@ -57,5 +56,5 @@
|
|
|
57
56
|
"build": "yarn webiny run build",
|
|
58
57
|
"watch": "yarn webiny run watch"
|
|
59
58
|
},
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "085ff6572f6bb6a76d218088b06d9f4ef92bbea7"
|
|
61
60
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface CreatePathCallableParams {
|
|
4
|
+
field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id">;
|
|
5
|
+
index?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CreatePathCallable {
|
|
8
|
+
(params: CreatePathCallableParams): string;
|
|
9
|
+
}
|
|
10
|
+
export interface CmsEntryFieldFilterPathPluginParams {
|
|
11
|
+
fieldType: string;
|
|
12
|
+
fieldId?: string[];
|
|
13
|
+
path: string | CreatePathCallable;
|
|
14
|
+
canUse?: (field: Pick<CmsModelField, "fieldId" | "type">, parents?: string[]) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
17
|
+
static readonly type: string;
|
|
18
|
+
private readonly config;
|
|
19
|
+
get fieldType(): string;
|
|
20
|
+
constructor(config: CmsEntryFieldFilterPathPluginParams);
|
|
21
|
+
canUse(field: Pick<CmsModelField, "fieldId" | "type">, parents: string[]): boolean;
|
|
22
|
+
createPath(params: CreatePathCallableParams): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CmsEntryFieldFilterPathPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
11
|
+
class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
|
|
12
|
+
get fieldType() {
|
|
13
|
+
return this.config.fieldType;
|
|
14
|
+
}
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "config", void 0);
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
20
|
+
}
|
|
21
|
+
canUse(field, parents) {
|
|
22
|
+
if (field.type !== this.config.fieldType) {
|
|
23
|
+
return false;
|
|
24
|
+
} else if (this.config.canUse) {
|
|
25
|
+
return this.config.canUse(field, parents);
|
|
26
|
+
}
|
|
27
|
+
const fieldId = this.config.fieldId;
|
|
28
|
+
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return fieldId.includes(field.fieldId);
|
|
32
|
+
}
|
|
33
|
+
createPath(params) {
|
|
34
|
+
if (typeof this.config.path === "function") {
|
|
35
|
+
return this.config.path(params);
|
|
36
|
+
} else if (typeof this.config.path === "string") {
|
|
37
|
+
return this.config.path;
|
|
38
|
+
}
|
|
39
|
+
throw new _error.default(`Missing path in "${this.name}" plugin.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
|
|
43
|
+
(0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","parents","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 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 this.name = `${(this.constructor as any).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"],"mappings":";;;;;;;;AAAA;AACA;AAgBO,MAAMA,6BAA6B,SAASC,cAAM,CAAC;EAKtD,IAAWC,SAAS,GAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,S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from "@webiny/plugins";
|
|
2
|
+
import { ValueFilterPlugin } 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,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CmsEntryFieldFilterPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "config", void 0);
|
|
14
|
+
(0, _defineProperty2.default)(this, "fieldType", void 0);
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.fieldType = this.config.fieldType;
|
|
17
|
+
}
|
|
18
|
+
create(params) {
|
|
19
|
+
return this.config.create(params);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
|
|
23
|
+
(0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "type", "cms.dynamodb.entry.field.filter");
|
|
24
|
+
(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,yBAAyB,SAASC,eAAM,CAAC;EAQ3CC,WAAW,CAACC,MAAuC,EAAE;IACxD,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,MAAM,CAACC,MAA6C,EAAE;IACzD,OAAO,IAAI,CAACH,MAAM,CAACE,MAAM,CAACC,MAAM,CAAC;EACrC;AACJ;AAAC;AAAA,8BAjBYN,yBAAyB,UACa,iCAAiC;AAAA,8BADvEA,yBAAyB,SAEG,GAAG"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { Field } from "../operations/entry/filtering/types";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
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,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createCmsEntryFieldSortingPlugin = exports.CmsEntryFieldSortingPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class CmsEntryFieldSortingPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "config", void 0);
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
canUse(params) {
|
|
17
|
+
return this.config.canUse(params);
|
|
18
|
+
}
|
|
19
|
+
createSort(params) {
|
|
20
|
+
return this.config.createSort(params);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CmsEntryFieldSortingPlugin = CmsEntryFieldSortingPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryFieldSortingPlugin, "type", "cms.entry.field.sorting");
|
|
25
|
+
const createCmsEntryFieldSortingPlugin = config => {
|
|
26
|
+
return new CmsEntryFieldSortingPlugin(config);
|
|
27
|
+
};
|
|
28
|
+
exports.createCmsEntryFieldSortingPlugin = createCmsEntryFieldSortingPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldSortingPlugin","Plugin","constructor","config","canUse","params","createSort","createCmsEntryFieldSortingPlugin"],"sources":["CmsEntryFieldSortingPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Field } from \"~/operations/entry/filtering/types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\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"],"mappings":";;;;;;;;AAAA;AAwCO,MAAMA,0BAA0B,SAASC,eAAM,CAAC;EAI5CC,WAAW,CAACC,MAAwC,EAAE;IACzD,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEOC,MAAM,CAACC,MAA8C,EAAW;IACnE,OAAO,IAAI,CAACF,MAAM,CAACC,MAAM,CAACC,MAAM,CAAC;EACrC;EAEOC,UAAU,CACbD,MAAkD,EACR;IAC1C,OAAO,IAAI,CAACF,MAAM,CAACG,UAAU,CAACD,MAAM,CAAC;EACzC;AACJ;AAAC;AAAA,8BAlBYL,0BAA0B,UACY,yBAAyB;AAmBrE,MAAMO,gCAAgC,GAAIJ,MAAwC,IAAK;EAC1F,OAAO,IAAIH,0BAA0B,CAACG,MAAM,CAAC;AACjD,CAAC;AAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsFieldFilterValueTransformPlugin as CmsFieldFilterValueTransformPluginInterface } from "../types";
|
|
3
|
+
declare 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 {};
|