@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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 +6 -4
- package/definitions/entry.js +111 -20
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -4
- package/definitions/group.js +8 -16
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -4
- package/definitions/model.js +30 -16
- package/definitions/model.js.map +1 -0
- package/definitions/system.d.ts +6 -4
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +7 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +9 -18
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +43 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +2 -3
- package/dynamoDb/path/plainObject.js +26 -24
- package/dynamoDb/path/plainObject.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +74 -63
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +49 -98
- package/dynamoDb/storage/richText.js.map +1 -0
- package/dynamoDb/transformValue/datetime.d.ts +5 -3
- package/dynamoDb/transformValue/datetime.js +29 -29
- package/dynamoDb/transformValue/datetime.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +56 -54
- package/index.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -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 +10 -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 +25 -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 +45 -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 +56 -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 +56 -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 +62 -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 +40 -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 +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +18 -29
- package/operations/entry/dataLoaders.js +59 -246
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +178 -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 +108 -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 +69 -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 +158 -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 +50 -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 +66 -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 +33 -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 +45 -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 +16 -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 +90 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +80 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +71 -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 +90 -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 +18 -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 +7 -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 +24 -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 +35 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +5 -5
- package/operations/entry/index.js +920 -437
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +9 -14
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +35 -59
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +5 -4
- package/operations/model/index.js +35 -46
- package/operations/model/index.js.map +1 -0
- package/operations/system/index.d.ts +5 -4
- package/operations/system/index.js +20 -31
- package/operations/system/index.js.map +1 -0
- package/package.json +23 -29
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +23 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js +48 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +27 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +27 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +51 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +21 -45
- package/types.js +5 -6
- package/types.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- 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
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
|
@@ -1,64 +1,57 @@
|
|
|
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.createModelsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
10
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
11
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
12
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
24
13
|
const createPartitionKey = params => {
|
|
25
14
|
const {
|
|
26
15
|
tenant,
|
|
27
16
|
locale
|
|
28
17
|
} = params;
|
|
18
|
+
if (!tenant) {
|
|
19
|
+
throw new _error.default(`Missing tenant variable when creating model partitionKey.`);
|
|
20
|
+
} else if (!locale) {
|
|
21
|
+
throw new _error.default(`Missing locale variable when creating model partitionKey.`);
|
|
22
|
+
}
|
|
29
23
|
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
30
24
|
};
|
|
31
|
-
|
|
32
25
|
const createSortKey = params => {
|
|
33
26
|
return params.modelId;
|
|
34
27
|
};
|
|
35
|
-
|
|
36
28
|
const createKeys = params => {
|
|
37
29
|
return {
|
|
38
30
|
PK: createPartitionKey(params),
|
|
39
31
|
SK: createSortKey(params)
|
|
40
32
|
};
|
|
41
33
|
};
|
|
42
|
-
|
|
43
34
|
const createType = () => {
|
|
44
35
|
return "cms.model";
|
|
45
36
|
};
|
|
46
|
-
|
|
47
37
|
const createModelsStorageOperations = params => {
|
|
48
38
|
const {
|
|
49
39
|
entity
|
|
50
40
|
} = params;
|
|
51
|
-
|
|
52
41
|
const create = async params => {
|
|
53
42
|
const {
|
|
54
43
|
model
|
|
55
44
|
} = params;
|
|
56
45
|
const keys = createKeys(model);
|
|
57
|
-
|
|
58
46
|
try {
|
|
59
|
-
await
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
await (0, _dbDynamodb.put)({
|
|
48
|
+
entity,
|
|
49
|
+
item: {
|
|
50
|
+
...(0, _cleanup.cleanupItem)(entity, model),
|
|
51
|
+
...keys,
|
|
52
|
+
TYPE: createType()
|
|
53
|
+
}
|
|
54
|
+
});
|
|
62
55
|
return model;
|
|
63
56
|
} catch (ex) {
|
|
64
57
|
throw new _error.default(`Could not create CMS Content Model.`, "CREATE_MODEL_ERROR", {
|
|
@@ -68,64 +61,62 @@ const createModelsStorageOperations = params => {
|
|
|
68
61
|
});
|
|
69
62
|
}
|
|
70
63
|
};
|
|
71
|
-
|
|
72
64
|
const update = async params => {
|
|
73
65
|
const {
|
|
74
|
-
original,
|
|
75
66
|
model
|
|
76
67
|
} = params;
|
|
77
68
|
const keys = createKeys(model);
|
|
78
|
-
|
|
79
69
|
try {
|
|
80
|
-
await
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
await (0, _dbDynamodb.put)({
|
|
71
|
+
entity,
|
|
72
|
+
item: {
|
|
73
|
+
...(0, _cleanup.cleanupItem)(entity, model),
|
|
74
|
+
...keys,
|
|
75
|
+
TYPE: createType()
|
|
76
|
+
}
|
|
77
|
+
});
|
|
83
78
|
return model;
|
|
84
79
|
} catch (ex) {
|
|
85
|
-
throw new _error.default(ex.
|
|
80
|
+
throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
86
81
|
error: ex,
|
|
87
82
|
model,
|
|
88
|
-
original,
|
|
89
83
|
keys
|
|
90
84
|
});
|
|
91
85
|
}
|
|
92
86
|
};
|
|
93
|
-
|
|
94
87
|
const deleteModel = async params => {
|
|
95
88
|
const {
|
|
96
89
|
model
|
|
97
90
|
} = params;
|
|
98
91
|
const keys = createKeys(model);
|
|
99
|
-
|
|
100
92
|
try {
|
|
101
|
-
await
|
|
93
|
+
await (0, _dbDynamodb.deleteItem)({
|
|
94
|
+
entity,
|
|
95
|
+
keys
|
|
96
|
+
});
|
|
102
97
|
return model;
|
|
103
98
|
} catch (ex) {
|
|
104
|
-
throw new _error.default(ex.
|
|
99
|
+
throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
105
100
|
error: ex,
|
|
106
101
|
model,
|
|
107
102
|
keys
|
|
108
103
|
});
|
|
109
104
|
}
|
|
110
105
|
};
|
|
111
|
-
|
|
112
106
|
const get = async params => {
|
|
113
107
|
const keys = createKeys(params);
|
|
114
|
-
|
|
115
108
|
try {
|
|
116
|
-
|
|
109
|
+
return await (0, _get.getClean)({
|
|
117
110
|
entity,
|
|
118
111
|
keys
|
|
119
112
|
});
|
|
120
|
-
return (0, _cleanup.cleanupItem)(entity, item);
|
|
121
113
|
} catch (ex) {
|
|
122
|
-
throw new _error.default(ex.
|
|
114
|
+
throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
123
115
|
error: ex,
|
|
124
116
|
keys
|
|
125
117
|
});
|
|
126
118
|
}
|
|
127
119
|
};
|
|
128
|
-
|
|
129
120
|
const list = async params => {
|
|
130
121
|
const {
|
|
131
122
|
where
|
|
@@ -137,18 +128,15 @@ const createModelsStorageOperations = params => {
|
|
|
137
128
|
gte: " "
|
|
138
129
|
}
|
|
139
130
|
};
|
|
140
|
-
|
|
141
131
|
try {
|
|
142
|
-
|
|
143
|
-
return (0, _cleanup.cleanupItems)(entity, items);
|
|
132
|
+
return await (0, _query.queryAllClean)(queryAllParams);
|
|
144
133
|
} catch (ex) {
|
|
145
|
-
throw new _error.default(ex.
|
|
134
|
+
throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
146
135
|
error: ex,
|
|
147
136
|
partitionKey: queryAllParams.partitionKey
|
|
148
137
|
});
|
|
149
138
|
}
|
|
150
139
|
};
|
|
151
|
-
|
|
152
140
|
return {
|
|
153
141
|
create,
|
|
154
142
|
update,
|
|
@@ -157,5 +145,6 @@ const createModelsStorageOperations = params => {
|
|
|
157
145
|
list
|
|
158
146
|
};
|
|
159
147
|
};
|
|
148
|
+
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
160
149
|
|
|
161
|
-
|
|
150
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_get","_cleanup","_query","_dbDynamodb","createPartitionKey","params","tenant","locale","WebinyError","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","create","model","keys","put","item","cleanupItem","TYPE","ex","error","update","message","code","deleteModel","deleteItem","get","getClean","list","where","queryAllParams","partitionKey","options","gte","queryAllClean","delete","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } from \"@webiny/db-dynamodb/utils/query\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\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 put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\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 put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\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 deleteItem({\n entity,\n keys\n });\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 return await getClean<CmsModel>({\n entity,\n keys\n });\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 return await queryAllClean<CmsModel>(queryAllParams);\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAMA,MAAMK,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,IAAI,CAACC,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CAAC,2DAA2D,CAAC;EACtF,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;IAChB,MAAM,IAAIC,cAAW,CAAC,2DAA2D,CAAC;EACtF;EACA,OAAO,KAAKF,MAAM,MAAMC,MAAM,SAAS;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,GAAGA,CAAA,KAAc;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,CAAC;IAE9B,IA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GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACQ,OAAA,CAAA1B,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb
|
|
3
|
-
|
|
1
|
+
import type { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
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,43 @@
|
|
|
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
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
|
-
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
|
-
|
|
10
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
22
11
|
const createPartitionKey = ({
|
|
23
12
|
tenant
|
|
24
13
|
}) => {
|
|
25
14
|
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
26
15
|
};
|
|
27
|
-
|
|
28
16
|
const createSortKey = () => {
|
|
29
17
|
return "CMS";
|
|
30
18
|
};
|
|
31
|
-
|
|
32
19
|
const createKeys = params => {
|
|
33
20
|
return {
|
|
34
21
|
PK: createPartitionKey(params),
|
|
35
22
|
SK: createSortKey()
|
|
36
23
|
};
|
|
37
24
|
};
|
|
38
|
-
|
|
39
25
|
const createSystemStorageOperations = params => {
|
|
40
26
|
const {
|
|
41
27
|
entity
|
|
42
28
|
} = params;
|
|
43
|
-
|
|
44
29
|
const create = async ({
|
|
45
30
|
system
|
|
46
31
|
}) => {
|
|
47
32
|
const keys = createKeys(system);
|
|
48
|
-
|
|
49
33
|
try {
|
|
50
|
-
await
|
|
34
|
+
await (0, _dbDynamodb.put)({
|
|
35
|
+
entity,
|
|
36
|
+
item: {
|
|
37
|
+
...system,
|
|
38
|
+
...keys
|
|
39
|
+
}
|
|
40
|
+
});
|
|
51
41
|
return system;
|
|
52
42
|
} catch (ex) {
|
|
53
43
|
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
@@ -57,36 +47,35 @@ const createSystemStorageOperations = params => {
|
|
|
57
47
|
});
|
|
58
48
|
}
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
const update = async params => {
|
|
62
51
|
const {
|
|
63
|
-
system
|
|
64
|
-
original
|
|
52
|
+
system
|
|
65
53
|
} = params;
|
|
66
54
|
const keys = createKeys(system);
|
|
67
|
-
|
|
68
55
|
try {
|
|
69
|
-
await
|
|
56
|
+
await (0, _dbDynamodb.put)({
|
|
57
|
+
entity,
|
|
58
|
+
item: {
|
|
59
|
+
...system,
|
|
60
|
+
...keys
|
|
61
|
+
}
|
|
62
|
+
});
|
|
70
63
|
return system;
|
|
71
64
|
} catch (ex) {
|
|
72
65
|
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
66
|
error: ex,
|
|
74
67
|
system,
|
|
75
|
-
original,
|
|
76
68
|
keys
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
71
|
};
|
|
80
|
-
|
|
81
72
|
const get = async params => {
|
|
82
73
|
const keys = createKeys(params);
|
|
83
|
-
|
|
84
74
|
try {
|
|
85
|
-
|
|
75
|
+
return await (0, _get.getClean)({
|
|
86
76
|
entity,
|
|
87
77
|
keys
|
|
88
78
|
});
|
|
89
|
-
return (0, _cleanup.cleanupItem)(entity, system);
|
|
90
79
|
} catch (ex) {
|
|
91
80
|
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
92
81
|
error: ex,
|
|
@@ -94,12 +83,12 @@ const createSystemStorageOperations = params => {
|
|
|
94
83
|
});
|
|
95
84
|
}
|
|
96
85
|
};
|
|
97
|
-
|
|
98
86
|
return {
|
|
99
87
|
create,
|
|
100
88
|
update,
|
|
101
89
|
get
|
|
102
90
|
};
|
|
103
91
|
};
|
|
92
|
+
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
104
93
|
|
|
105
|
-
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","item","ex","WebinyError","message","code","error","update","get","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\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 put({\n entity,\n item: {\n ...system,\n ...keys\n }\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 put({\n entity,\n item: {\n ...system,\n ...keys\n }\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 return await getClean<CmsSystem>({\n entity,\n keys\n });\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,MAAMG,kBAAkB,GAAGA,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAO,KAAKA,MAAM,CAACC,WAAW,CAAC,CAAC,SAAS;AAC7C,CAAC;AACD,MAAMC,aAAa,GAAGA,CAAA,KAAc;EAChC,OAAO,KAAK;AAChB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa,CAAC;EACtB,CAAC;AACL,CAAC;AAEM,MAAMK,6BAA6B,GACtCH,MAA2C,IACd;EAC7B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,MAAAA,CAAO;IAAEC;EAA+C,CAAC,KAAK;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAC/B,IAAI;MACA,MAAM,IAAAE,eAAG,EAAC;QACNJ,MAAM;QACNK,IAAI,EAAE;UACF,GAAGH,MAAM;UACT,GAAGC;QACP;MACJ,CAAC,CAAC;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACT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.06b2ede40f",
|
|
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,41 +22,34 @@
|
|
|
21
22
|
],
|
|
22
23
|
"license": "MIT",
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"
|
|
31
|
-
"dataloader": "2.
|
|
32
|
-
"dot-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"lodash.sortby": "4.7.0"
|
|
25
|
+
"@webiny/api": "0.0.0-unstable.06b2ede40f",
|
|
26
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.06b2ede40f",
|
|
27
|
+
"@webiny/aws-sdk": "0.0.0-unstable.06b2ede40f",
|
|
28
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.06b2ede40f",
|
|
29
|
+
"@webiny/error": "0.0.0-unstable.06b2ede40f",
|
|
30
|
+
"@webiny/handler-db": "0.0.0-unstable.06b2ede40f",
|
|
31
|
+
"@webiny/utils": "0.0.0-unstable.06b2ede40f",
|
|
32
|
+
"dataloader": "2.2.3",
|
|
33
|
+
"dot-object": "2.1.5",
|
|
34
|
+
"dot-prop": "6.0.1",
|
|
35
|
+
"lodash": "4.17.21"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"@webiny/project-utils": "^0.0.0-mt-2",
|
|
46
|
-
"jest": "^26.6.3",
|
|
47
|
-
"jest-dynalite": "^3.2.0",
|
|
48
|
-
"jest-environment-node": "^26.6.2",
|
|
49
|
-
"ttypescript": "^1.5.12",
|
|
50
|
-
"typescript": "^4.1.3"
|
|
38
|
+
"@types/dot-object": "2.1.6",
|
|
39
|
+
"@types/jsonpack": "1.1.6",
|
|
40
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f",
|
|
41
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
42
|
+
"jest": "29.7.0",
|
|
43
|
+
"jest-dynalite": "3.6.1",
|
|
44
|
+
"typescript": "5.3.3"
|
|
51
45
|
},
|
|
52
46
|
"publishConfig": {
|
|
53
47
|
"access": "public",
|
|
54
48
|
"directory": "dist"
|
|
55
49
|
},
|
|
56
50
|
"scripts": {
|
|
57
|
-
"build": "
|
|
58
|
-
"watch": "
|
|
51
|
+
"build": "node ../cli/bin.js run build",
|
|
52
|
+
"watch": "node ../cli/bin.js run watch"
|
|
59
53
|
},
|
|
60
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
61
55
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import type { 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,48 @@
|
|
|
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 _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
10
|
+
class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
|
|
11
|
+
static type = "cms-field-filter-path";
|
|
12
|
+
get fieldType() {
|
|
13
|
+
return this.config.fieldType;
|
|
14
|
+
}
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super();
|
|
17
|
+
this.config = config;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* We expect error here because we know that `this.constructor.type` is defined, but TS does not.
|
|
21
|
+
*/
|
|
22
|
+
// @ts-expect-error
|
|
23
|
+
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
24
|
+
}
|
|
25
|
+
canUse(field, parents) {
|
|
26
|
+
if (field.type !== this.config.fieldType) {
|
|
27
|
+
return false;
|
|
28
|
+
} else if (this.config.canUse) {
|
|
29
|
+
return this.config.canUse(field, parents);
|
|
30
|
+
}
|
|
31
|
+
const fieldId = this.config.fieldId;
|
|
32
|
+
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return fieldId.includes(field.fieldId);
|
|
36
|
+
}
|
|
37
|
+
createPath(params) {
|
|
38
|
+
if (typeof this.config.path === "function") {
|
|
39
|
+
return this.config.path(params);
|
|
40
|
+
} else if (typeof this.config.path === "string") {
|
|
41
|
+
return this.config.path;
|
|
42
|
+
}
|
|
43
|
+
throw new _error.default(`Missing path in "${this.name}" plugin.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=CmsEntryFieldFilterPathPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_Plugin","CmsEntryFieldFilterPathPlugin","Plugin","type","fieldType","config","constructor","name","canUse","field","parents","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError","exports"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { 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 /**\n * We expect error here because we know that `this.constructor.type` is defined, but TS does not.\n */\n // @ts-expect-error\n this.name = `${this.constructor.type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">, parents: string[]): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n } else if (this.config.canUse) {\n return this.config.canUse(field, parents);\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAgBO,MAAME,6BAA6B,SAASC,cAAM,CAAC;EACtD,OAAgCC,IAAI,GAAW,uBAAuB;EAItE,IAAWC,SAASA,CAAA,EAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAWA,CAACD,MAA2C,EAAE;IAC5D,KAAK,CAAC,CAAC;IAEP,IAAI,CAACA,MAAM,GAAGA,MAAM;;IAEpB;AACR;AACA;IACQ;IACA,IAAI,CAACE,IAAI,GAAG,GAAG,IAAI,CAACD,WAAW,CAACH,IAAI,IAAI,IAAI,CAACE,MAAM,CAACD,SAAS,EAAE;EACnE;EAEOI,MAAMA,CAACC,KAA8C,EAAEC,OAAiB,EAAW;IACtF,IAAID,KAAK,CAACN,IAAI,KAAK,IAAI,CAACE,MAAM,CAACD,SAAS,EAAE;MACtC,OAAO,KAAK;IAChB,CAAC,MAAM,IAAI,IAAI,CAACC,MAAM,CAACG,MAAM,EAAE;MAC3B,OAAO,IAAI,CAACH,MAAM,CAACG,MAAM,CAACC,KAAK,EAAEC,OAAO,CAAC;IAC7C;IACA,MAAMC,OAAO,GAAG,IAAI,CAACN,MAAM,CAACM,OAAO;IACnC,IAAI,CAACA,OAAO,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAAC,KAAK,KAAK,IAAIA,OAAO,CAACG,MAAM,KAAK,CAAC,EAAE;MACtE,OAAO,IAAI;IACf;IACA,OAAOH,OAAO,CAACI,QAAQ,CAACN,KAAK,CAACE,OAAO,CAAC;EAC1C;EAEOK,UAAUA,CAACC,MAAgC,EAAU;IACxD,IAAI,OAAO,IAAI,CAACZ,MAAM,CAACa,IAAI,KAAK,UAAU,EAAE;MACxC,OAAO,IAAI,CAACb,MAAM,CAACa,IAAI,CAACD,MAAM,CAAC;IACnC,CAAC,MAAM,IAAI,OAAO,IAAI,CAACZ,MAAM,CAACa,IAAI,KAAK,QAAQ,EAAE;MAC7C,OAAO,IAAI,CAACb,MAAM,CAACa,IAAI;IAC3B;IACA,MAAM,IAAIC,cAAW,CAAC,oBAAoB,IAAI,CAACZ,IAAI,WAAW,CAAC;EACnE;AACJ;AAACa,OAAA,CAAAnB,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
3
|
+
import type { Field } from "../operations/entry/filtering/types";
|
|
4
|
+
import type { 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<T = any> {
|
|
10
|
+
fieldType: string;
|
|
11
|
+
create: (params: CmsEntryFieldFilterPluginCreateParams<T>) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];
|
|
12
|
+
}
|
|
13
|
+
interface CmsEntryFieldFilterPluginCreateParams<T = any> {
|
|
14
|
+
key: string;
|
|
15
|
+
value: T;
|
|
16
|
+
field: Field;
|
|
17
|
+
fields: Record<string, Field>;
|
|
18
|
+
operation: string;
|
|
19
|
+
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<T = any> extends Plugin {
|
|
36
|
+
static readonly type: string;
|
|
37
|
+
static readonly ALL: string;
|
|
38
|
+
private readonly config;
|
|
39
|
+
readonly fieldType: string;
|
|
40
|
+
constructor(config: CmsEntryFieldFilterPluginParams<T>);
|
|
41
|
+
create(params: CmsEntryFieldFilterPluginCreateParams<T>): CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[] | null;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CmsEntryFieldFilterPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
/**
|
|
9
|
+
* This plugin is used to create the filter.
|
|
10
|
+
* Internally we have default one + the one for the reference field - because it is actually an object when filtering.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
|
|
14
|
+
static type = "cms.dynamodb.entry.field.filter";
|
|
15
|
+
static ALL = "*";
|
|
16
|
+
constructor(config) {
|
|
17
|
+
super();
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.fieldType = this.config.fieldType;
|
|
20
|
+
}
|
|
21
|
+
create(params) {
|
|
22
|
+
return this.config.create(params);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=CmsEntryFieldFilterPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","CmsEntryFieldFilterPlugin","Plugin","type","ALL","constructor","config","fieldType","create","params","exports"],"sources":["CmsEntryFieldFilterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport type { Field } from \"~/operations/entry/filtering/types\";\nimport type { 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<T = any> {\n fieldType: string;\n create: (\n params: CmsEntryFieldFilterPluginCreateParams<T>\n ) => null | CmsEntryFieldFilterPluginCreateResponse | CmsEntryFieldFilterPluginCreateResponse[];\n}\n\ninterface CmsEntryFieldFilterPluginCreateParams<T = any> {\n key: string;\n value: T;\n field: Field;\n fields: Record<string, Field>;\n operation: string;\n 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<T = any> extends Plugin {\n public static override readonly type: string = \"cms.dynamodb.entry.field.filter\";\n public static readonly ALL: string = \"*\";\n\n private readonly config: CmsEntryFieldFilterPluginParams<T>;\n\n public readonly fieldType: string;\n\n public constructor(config: CmsEntryFieldFilterPluginParams<T>) {\n super();\n this.config = config;\n this.fieldType = this.config.fieldType;\n }\n\n public create(params: CmsEntryFieldFilterPluginCreateParams<T>) {\n return this.config.create(params);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAKA;AACA;AACA;AACA;;AAiCO,MAAMC,yBAAyB,SAAkBC,eAAM,CAAC;EAC3D,OAAgCC,IAAI,GAAW,iCAAiC;EAChF,OAAuBC,GAAG,GAAW,GAAG;EAMjCC,WAAWA,CAACC,MAA0C,EAAE;IAC3D,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,SAAS,GAAG,IAAI,CAACD,MAAM,CAACC,SAAS;EAC1C;EAEOC,MAAMA,CAACC,MAAgD,EAAE;IAC5D,OAAO,IAAI,CAACH,MAAM,CAACE,MAAM,CAACC,MAAM,CAAC;EACrC;AACJ;AAACC,OAAA,CAAAT,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { Field } from "../operations/entry/filtering/types";
|
|
3
|
+
import type { 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 {};
|