@webiny/api-headless-cms-ddb 5.34.8 → 5.35.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.js +3 -5
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +0 -5
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +17 -5
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +0 -5
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +0 -5
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.js +0 -7
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/plainObject.js +1 -8
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -19
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +1 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +0 -18
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.js +1 -8
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.js +6 -30
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +1 -44
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.js +2 -39
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.js +0 -18
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.js +0 -10
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.js +1 -36
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.js +0 -12
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +0 -18
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.js +0 -2
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.js +0 -8
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -7
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.js +0 -5
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -21
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -18
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/sort.js +0 -15
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.js +0 -2
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.js +0 -3
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/values.js +0 -6
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +0 -6
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.js +58 -116
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +0 -18
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/systemFields.js +0 -2
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/group/index.js +2 -32
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +0 -25
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +0 -24
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +0 -17
- package/operations/system/index.js.map +1 -1
- package/package.json +13 -13
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -14
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -7
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -10
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- 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 +1 -0
- package/plugins/index.js +11 -6
- package/plugins/index.js.map +1 -1
- package/types.js +0 -1
- package/types.js.map +1 -1
|
@@ -1,63 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createModelsStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
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
12
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
|
-
|
|
20
13
|
const createPartitionKey = params => {
|
|
21
14
|
const {
|
|
22
15
|
tenant,
|
|
23
16
|
locale
|
|
24
17
|
} = params;
|
|
25
|
-
|
|
26
18
|
if (!tenant) {
|
|
27
19
|
throw new _error.default(`Missing tenant variable when creating model partitionKey.`);
|
|
28
20
|
} else if (!locale) {
|
|
29
21
|
throw new _error.default(`Missing locale variable when creating model partitionKey.`);
|
|
30
22
|
}
|
|
31
|
-
|
|
32
23
|
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
33
24
|
};
|
|
34
|
-
|
|
35
25
|
const createSortKey = params => {
|
|
36
26
|
return params.modelId;
|
|
37
27
|
};
|
|
38
|
-
|
|
39
28
|
const createKeys = params => {
|
|
40
29
|
return {
|
|
41
30
|
PK: createPartitionKey(params),
|
|
42
31
|
SK: createSortKey(params)
|
|
43
32
|
};
|
|
44
33
|
};
|
|
45
|
-
|
|
46
34
|
const createType = () => {
|
|
47
35
|
return "cms.model";
|
|
48
36
|
};
|
|
49
|
-
|
|
50
37
|
const createModelsStorageOperations = params => {
|
|
51
38
|
const {
|
|
52
39
|
entity
|
|
53
40
|
} = params;
|
|
54
|
-
|
|
55
41
|
const create = async params => {
|
|
56
42
|
const {
|
|
57
43
|
model
|
|
58
44
|
} = params;
|
|
59
45
|
const keys = createKeys(model);
|
|
60
|
-
|
|
61
46
|
try {
|
|
62
47
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
63
48
|
TYPE: createType()
|
|
@@ -71,13 +56,11 @@ const createModelsStorageOperations = params => {
|
|
|
71
56
|
});
|
|
72
57
|
}
|
|
73
58
|
};
|
|
74
|
-
|
|
75
59
|
const update = async params => {
|
|
76
60
|
const {
|
|
77
61
|
model
|
|
78
62
|
} = params;
|
|
79
63
|
const keys = createKeys(model);
|
|
80
|
-
|
|
81
64
|
try {
|
|
82
65
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
83
66
|
TYPE: createType()
|
|
@@ -91,13 +74,11 @@ const createModelsStorageOperations = params => {
|
|
|
91
74
|
});
|
|
92
75
|
}
|
|
93
76
|
};
|
|
94
|
-
|
|
95
77
|
const deleteModel = async params => {
|
|
96
78
|
const {
|
|
97
79
|
model
|
|
98
80
|
} = params;
|
|
99
81
|
const keys = createKeys(model);
|
|
100
|
-
|
|
101
82
|
try {
|
|
102
83
|
await entity.delete(keys);
|
|
103
84
|
return model;
|
|
@@ -109,10 +90,8 @@ const createModelsStorageOperations = params => {
|
|
|
109
90
|
});
|
|
110
91
|
}
|
|
111
92
|
};
|
|
112
|
-
|
|
113
93
|
const get = async params => {
|
|
114
94
|
const keys = createKeys(params);
|
|
115
|
-
|
|
116
95
|
try {
|
|
117
96
|
const item = await (0, _get.get)({
|
|
118
97
|
entity,
|
|
@@ -126,7 +105,6 @@ const createModelsStorageOperations = params => {
|
|
|
126
105
|
});
|
|
127
106
|
}
|
|
128
107
|
};
|
|
129
|
-
|
|
130
108
|
const list = async params => {
|
|
131
109
|
const {
|
|
132
110
|
where
|
|
@@ -138,7 +116,6 @@ const createModelsStorageOperations = params => {
|
|
|
138
116
|
gte: " "
|
|
139
117
|
}
|
|
140
118
|
};
|
|
141
|
-
|
|
142
119
|
try {
|
|
143
120
|
const items = await (0, _query.queryAll)(queryAllParams);
|
|
144
121
|
return (0, _cleanup.cleanupItems)(entity, items);
|
|
@@ -149,7 +126,6 @@ const createModelsStorageOperations = params => {
|
|
|
149
126
|
});
|
|
150
127
|
}
|
|
151
128
|
};
|
|
152
|
-
|
|
153
129
|
return {
|
|
154
130
|
create,
|
|
155
131
|
update,
|
|
@@ -158,5 +134,4 @@ const createModelsStorageOperations = params => {
|
|
|
158
134
|
list
|
|
159
135
|
};
|
|
160
136
|
};
|
|
161
|
-
|
|
162
137
|
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
@@ -1 +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 {\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
|
|
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;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R,EAAE,EAAE;MACT,MAAM,IAAIf,cAAW,CACjBe,EAAE,CAACG,OAAO,IAAI,sBAAsB,EACpCH,EAAE,CAACI,IAAI,IAAI,iBAAiB,EAC5B;QACIH,KAAK,EAAED,EAAE;QACTJ;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMc,IAAI,GAAG,MAAO5B,MAA2C,IAAK;IAChE,MAAM;MAAE6B;IAAM,CAAC,GAAG7B,MAAM;IACxB,MAAM8B,cAA8B,GAAG;MACnCnB,MAAM;MACNoB,YAAY,EAAEhC,kBAAkB,CAAC8B,KAAK,CAAC;MACvCG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IACD,IAAI;MACA,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAWL,cAAc,CAAC;MAEtD,OAAO,IAAAM,qBAAY,EAACzB,MAAM,EAAEuB,KAAK,CAAC;IACtC,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACT,MAAM,IAAIf,cAAW,CACjBe,EAAE,CAACG,OAAO,IAAI,wBAAwB,EACtCH,EAAE,CAACI,IAAI,IAAI,kBAAkB,EAC7B;QACIH,KAAK,EAAED,EAAE;QACTa,YAAY,EAAED,cAAc,CAACC;MACjC,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACHnB,MAAM;IACNQ,MAAM;IACNI,MAAM,EAAED,WAAW;IACnBE,GAAG;IACHG;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,74 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSettingsStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
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
12
|
const convertToDbData = settings => {
|
|
19
13
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
20
14
|
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
21
15
|
});
|
|
22
16
|
};
|
|
23
|
-
|
|
24
17
|
const convertFromDbData = settings => {
|
|
25
18
|
if (!settings) {
|
|
26
19
|
return null;
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
let contentModelLastChange;
|
|
30
|
-
|
|
31
22
|
try {
|
|
32
23
|
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
33
24
|
} catch {
|
|
34
25
|
contentModelLastChange = new Date();
|
|
35
26
|
}
|
|
36
|
-
|
|
37
27
|
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
38
28
|
contentModelLastChange
|
|
39
29
|
});
|
|
40
30
|
};
|
|
41
|
-
|
|
42
31
|
const createPartitionKey = ({
|
|
43
32
|
tenant,
|
|
44
33
|
locale
|
|
45
34
|
}) => {
|
|
46
35
|
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
47
36
|
};
|
|
48
|
-
|
|
49
37
|
const createSortKey = () => {
|
|
50
38
|
return "settings";
|
|
51
39
|
};
|
|
52
|
-
|
|
53
40
|
const createKeys = params => {
|
|
54
41
|
return {
|
|
55
42
|
PK: createPartitionKey(params),
|
|
56
43
|
SK: createSortKey()
|
|
57
44
|
};
|
|
58
45
|
};
|
|
59
|
-
|
|
60
46
|
const createSettingsStorageOperations = params => {
|
|
61
47
|
const {
|
|
62
48
|
entity
|
|
63
49
|
} = params;
|
|
64
|
-
|
|
65
50
|
const create = async params => {
|
|
66
51
|
const {
|
|
67
52
|
settings
|
|
68
53
|
} = params;
|
|
69
54
|
const keys = createKeys(settings);
|
|
70
55
|
const dbSettings = convertToDbData(settings);
|
|
71
|
-
|
|
72
56
|
try {
|
|
73
57
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
74
58
|
return settings;
|
|
@@ -81,14 +65,12 @@ const createSettingsStorageOperations = params => {
|
|
|
81
65
|
});
|
|
82
66
|
}
|
|
83
67
|
};
|
|
84
|
-
|
|
85
68
|
const update = async params => {
|
|
86
69
|
const {
|
|
87
70
|
settings
|
|
88
71
|
} = params;
|
|
89
72
|
const keys = createKeys(settings);
|
|
90
73
|
const dbSettings = convertToDbData(settings);
|
|
91
|
-
|
|
92
74
|
try {
|
|
93
75
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
94
76
|
return settings;
|
|
@@ -101,20 +83,16 @@ const createSettingsStorageOperations = params => {
|
|
|
101
83
|
});
|
|
102
84
|
}
|
|
103
85
|
};
|
|
104
|
-
|
|
105
86
|
const get = async params => {
|
|
106
87
|
const keys = createKeys(params);
|
|
107
|
-
|
|
108
88
|
try {
|
|
109
89
|
const record = await (0, _get.get)({
|
|
110
90
|
entity,
|
|
111
91
|
keys
|
|
112
92
|
});
|
|
113
|
-
|
|
114
93
|
if (!record) {
|
|
115
94
|
return null;
|
|
116
95
|
}
|
|
117
|
-
|
|
118
96
|
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
119
97
|
return convertFromDbData(settings);
|
|
120
98
|
} catch (ex) {
|
|
@@ -124,12 +102,10 @@ const createSettingsStorageOperations = params => {
|
|
|
124
102
|
});
|
|
125
103
|
}
|
|
126
104
|
};
|
|
127
|
-
|
|
128
105
|
return {
|
|
129
106
|
create,
|
|
130
107
|
get,
|
|
131
108
|
update
|
|
132
109
|
};
|
|
133
110
|
};
|
|
134
|
-
|
|
135
111
|
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AAMA,MAAMA,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,mEACOA,QAAQ;IACXC,sBAAsB,EAAED,QAAQ,CAACC,sBAAsB,CAACC,WAAW;EAAE;AAE7E,CAAC;AAED,MAAMC,iBAAiB,GAAIH,QAAwB,IAAyB;EACxE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,IAAIC,sBAAsB;EAC1B,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAI,CAACJ,QAAQ,CAACC,sBAAsB,CAAC;EACtE,CAAC,CAAC,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAI,EAAE;EACvC;EACA,mEACOJ,QAAQ;IACXC;EAAsB;AAE9B,CAAC;AAOD,MAAMI,kBAAkB,GAAG,CAAC;EAAEC,MAAM;EAAEC;AAA2B,CAAC,KAAa;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAAc;AACjD,CAAC;AAED,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,UAAU;AACrB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IA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AAU;QACVD;MACJ,CAAC,CACJ;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOf,MAA6C,IAAK;IACjE,MAAMM,IAAI,GAAGP,UAAU,CAACC,MAAM,CAAC;IAC/B,IAAI;MACA,MAAMgB,MAAM,GAAG,MAAM,IAAAC,QAAS,EAAgB;QAC1Cb,MAAM;QACNE;MACJ,CAAC,CAAC;MACF,IAAI,CAACU,MAAM,EAAE;QACT,OAAO,IAAI;MACf;MACA,MAAM1B,QAAQ,GAAG,IAAA4B,oBAAW,EAACd,MAAM,EAAEY,MAAM,CAAkB;MAC7D,OAAOvB,iBAAiB,CAACH,QAAQ,CAAC;IACtC,CAAC,CAAC,OAAOmB,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,47 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSystemStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
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
12
|
const createPartitionKey = ({
|
|
19
13
|
tenant
|
|
20
14
|
}) => {
|
|
21
15
|
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
22
16
|
};
|
|
23
|
-
|
|
24
17
|
const createSortKey = () => {
|
|
25
18
|
return "CMS";
|
|
26
19
|
};
|
|
27
|
-
|
|
28
20
|
const createKeys = params => {
|
|
29
21
|
return {
|
|
30
22
|
PK: createPartitionKey(params),
|
|
31
23
|
SK: createSortKey()
|
|
32
24
|
};
|
|
33
25
|
};
|
|
34
|
-
|
|
35
26
|
const createSystemStorageOperations = params => {
|
|
36
27
|
const {
|
|
37
28
|
entity
|
|
38
29
|
} = params;
|
|
39
|
-
|
|
40
30
|
const create = async ({
|
|
41
31
|
system
|
|
42
32
|
}) => {
|
|
43
33
|
const keys = createKeys(system);
|
|
44
|
-
|
|
45
34
|
try {
|
|
46
35
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
47
36
|
return system;
|
|
@@ -53,13 +42,11 @@ const createSystemStorageOperations = params => {
|
|
|
53
42
|
});
|
|
54
43
|
}
|
|
55
44
|
};
|
|
56
|
-
|
|
57
45
|
const update = async params => {
|
|
58
46
|
const {
|
|
59
47
|
system
|
|
60
48
|
} = params;
|
|
61
49
|
const keys = createKeys(system);
|
|
62
|
-
|
|
63
50
|
try {
|
|
64
51
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
65
52
|
return system;
|
|
@@ -71,10 +58,8 @@ const createSystemStorageOperations = params => {
|
|
|
71
58
|
});
|
|
72
59
|
}
|
|
73
60
|
};
|
|
74
|
-
|
|
75
61
|
const get = async params => {
|
|
76
62
|
const keys = createKeys(params);
|
|
77
|
-
|
|
78
63
|
try {
|
|
79
64
|
const system = await (0, _get.get)({
|
|
80
65
|
entity,
|
|
@@ -88,12 +73,10 @@ const createSystemStorageOperations = params => {
|
|
|
88
73
|
});
|
|
89
74
|
}
|
|
90
75
|
};
|
|
91
|
-
|
|
92
76
|
return {
|
|
93
77
|
create,
|
|
94
78
|
update,
|
|
95
79
|
get
|
|
96
80
|
};
|
|
97
81
|
};
|
|
98
|
-
|
|
99
82
|
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await entity.put({\n ...system,\n ...keys\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;;AAQA;AACA;AACA;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAW,EAAG,SAAQ;AAC7C,CAAC;AACD,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAK;AAChB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa;EACrB,CAAC;AACL,CAAC;AAEM,MAAMK,6BAA6B,GACtCH,MAA2C,IACd;EAC7B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAA+C,CAAC,KAAK;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAM,C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;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNS,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.35.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@webiny/api-headless-cms": "5.
|
|
26
|
-
"@webiny/db-dynamodb": "5.
|
|
27
|
-
"@webiny/error": "5.
|
|
28
|
-
"@webiny/handler-db": "5.
|
|
29
|
-
"@webiny/utils": "5.
|
|
30
|
-
"aws-sdk": "2.
|
|
31
|
-
"dataloader": "2.1
|
|
24
|
+
"@babel/runtime": "7.20.13",
|
|
25
|
+
"@webiny/api-headless-cms": "5.35.0-beta.1",
|
|
26
|
+
"@webiny/db-dynamodb": "5.35.0-beta.1",
|
|
27
|
+
"@webiny/error": "5.35.0-beta.1",
|
|
28
|
+
"@webiny/handler-db": "5.35.0-beta.1",
|
|
29
|
+
"@webiny/utils": "5.35.0-beta.1",
|
|
30
|
+
"aws-sdk": "2.1310.0",
|
|
31
|
+
"dataloader": "2.2.1",
|
|
32
32
|
"dot-prop": "6.0.1",
|
|
33
33
|
"dynamodb-toolbox": "0.3.5",
|
|
34
34
|
"jsonpack": "1.1.5",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/core": "^7.19.3",
|
|
40
40
|
"@babel/preset-env": "^7.19.4",
|
|
41
41
|
"@types/jsonpack": "^1.1.0",
|
|
42
|
-
"@webiny/cli": "^5.
|
|
43
|
-
"@webiny/plugins": "^5.
|
|
44
|
-
"@webiny/project-utils": "^5.
|
|
42
|
+
"@webiny/cli": "^5.35.0-beta.1",
|
|
43
|
+
"@webiny/plugins": "^5.35.0-beta.1",
|
|
44
|
+
"@webiny/project-utils": "^5.35.0-beta.1",
|
|
45
45
|
"jest": "^28.1.0",
|
|
46
46
|
"jest-dynalite": "^3.2.0",
|
|
47
47
|
"jest-environment-node": "^27.2.4",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"build": "yarn webiny run build",
|
|
57
57
|
"watch": "yarn webiny run watch"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6b376faedf02e056efbbf1e4d46d537850773ce0"
|
|
60
60
|
}
|
|
@@ -1,55 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CmsEntryFieldFilterPathPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
10
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
15
|
-
|
|
16
11
|
class CmsEntryFieldFilterPathPlugin extends _Plugin.Plugin {
|
|
17
12
|
get fieldType() {
|
|
18
13
|
return this.config.fieldType;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
15
|
constructor(config) {
|
|
22
16
|
super();
|
|
23
17
|
(0, _defineProperty2.default)(this, "config", void 0);
|
|
24
18
|
this.config = config;
|
|
25
19
|
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
canUse(field) {
|
|
29
22
|
if (field.type !== this.config.fieldType) {
|
|
30
23
|
return false;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
const fieldId = this.config.fieldId;
|
|
34
|
-
|
|
35
26
|
if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {
|
|
36
27
|
return true;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
return fieldId.includes(field.fieldId);
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
createPath(params) {
|
|
43
32
|
if (typeof this.config.path === "function") {
|
|
44
33
|
return this.config.path(params);
|
|
45
34
|
} else if (typeof this.config.path === "string") {
|
|
46
35
|
return this.config.path;
|
|
47
36
|
}
|
|
48
|
-
|
|
49
37
|
throw new _error.default(`Missing path in "${this.name}" plugin.`);
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
}
|
|
53
|
-
|
|
54
40
|
exports.CmsEntryFieldFilterPathPlugin = CmsEntryFieldFilterPathPlugin;
|
|
55
41
|
(0, _defineProperty2.default)(CmsEntryFieldFilterPathPlugin, "type", "cms-field-filter-path");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams {\n field: Partial<CmsModelField> & Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\">;\n index?: number;\n}\nexport interface CreatePathCallable {\n (params: CreatePathCallableParams): string;\n}\nexport interface CmsEntryFieldFilterPathPluginParams {\n fieldType: string;\n fieldId?: string[];\n path: string | CreatePathCallable;\n}\nexport class CmsEntryFieldFilterPathPlugin extends Plugin {\n public static override readonly type: string = \"cms-field-filter-path\";\n\n private readonly config: CmsEntryFieldFilterPathPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(config: CmsEntryFieldFilterPathPluginParams) {\n super();\n\n this.config = config;\n\n this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldFilterPathPlugin","Plugin","fieldType","config","constructor","name","type","canUse","field","fieldId","Array","isArray","length","includes","createPath","params","path","WebinyError"],"sources":["CmsEntryFieldFilterPathPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nexport interface CreatePathCallableParams {\n field: Partial<CmsModelField> & Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\">;\n index?: number;\n}\nexport interface CreatePathCallable {\n (params: CreatePathCallableParams): string;\n}\nexport interface CmsEntryFieldFilterPathPluginParams {\n fieldType: string;\n fieldId?: string[];\n path: string | CreatePathCallable;\n}\nexport class CmsEntryFieldFilterPathPlugin extends Plugin {\n public static override readonly type: string = \"cms-field-filter-path\";\n\n private readonly config: CmsEntryFieldFilterPathPluginParams;\n\n public get fieldType(): string {\n return this.config.fieldType;\n }\n\n public constructor(config: CmsEntryFieldFilterPathPluginParams) {\n super();\n\n this.config = config;\n\n this.name = `${(this.constructor as any).type}-${this.config.fieldType}`;\n }\n\n public canUse(field: Pick<CmsModelField, \"fieldId\" | \"type\">): boolean {\n if (field.type !== this.config.fieldType) {\n return false;\n }\n const fieldId = this.config.fieldId;\n if (!fieldId || Array.isArray(fieldId) === false || fieldId.length === 0) {\n return true;\n }\n return fieldId.includes(field.fieldId);\n }\n\n public createPath(params: CreatePathCallableParams): string {\n if (typeof this.config.path === \"function\") {\n return this.config.path(params);\n } else if (typeof this.config.path === \"string\") {\n return this.config.path;\n }\n throw new WebinyError(`Missing path in \"${this.name}\" plugin.`);\n }\n}\n"],"mappings":";;;;;;;;AAAA;AACA;AAeO,MAAMA,6BAA6B,SAASC,cAAM,CAAC;EAKtD,IAAWC,SAAS,GAAW;IAC3B,OAAO,IAAI,CAACC,MAAM,CAACD,SAAS;EAChC;EAEOE,WAAW,CAACD,MAA2C,EAAE;IAC5D,KAAK,EAAE;IAAC;IAER,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAI,CAACE,IAAI,GAAI,GAAG,IAAI,CAACD,WAAW,CAASE,IAAK,IAAG,IAAI,CAACH,MAAM,CAACD,SAAU,EAAC;EAC5E;EAEOK,MAAM,CAACC,KAA8C,EAAW;IACnE,IAAIA,KAAK,CAACF,IAAI,KAAK,IAAI,CAACH,MAAM,CAACD,SAAS,EAAE;MACtC,OAAO,KAAK;IAChB;IACA,MAAMO,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,CAACL,KAAK,CAACC,OAAO,CAAC;EAC1C;EAEOK,UAAU,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,CAAE,oBAAmB,IAAI,CAACZ,IAAK,WAAU,CAAC;EACnE;AACJ;AAAC;AAAA,8BApCYL,6BAA6B,UACS,uBAAuB"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CmsEntryFieldFilterPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
|
|
15
11
|
constructor(config) {
|
|
16
12
|
super();
|
|
@@ -19,13 +15,10 @@ class CmsEntryFieldFilterPlugin extends _plugins.Plugin {
|
|
|
19
15
|
this.config = config;
|
|
20
16
|
this.fieldType = this.config.fieldType;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
create(params) {
|
|
24
19
|
return this.config.create(params);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
exports.CmsEntryFieldFilterPlugin = CmsEntryFieldFilterPlugin;
|
|
30
23
|
(0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "type", "cms.dynamodb.entry.field.filter");
|
|
31
24
|
(0, _defineProperty2.default)(CmsEntryFieldFilterPlugin, "ALL", "*");
|
|
@@ -1 +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":"
|
|
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"}
|