@webiny/api-headless-cms-ddb 0.0.0-unstable.496cf268ac → 0.0.0-unstable.5387e5f7c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -20
- package/abstractions/CmsDdbDataLoaders.d.ts +5 -0
- package/abstractions/CmsDdbDataLoaders.js +5 -0
- package/abstractions/CmsDdbDataLoaders.js.map +1 -0
- package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
- package/abstractions/CmsDdbEntryEntity.js +5 -0
- package/abstractions/CmsDdbEntryEntity.js.map +1 -0
- package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
- package/abstractions/CmsDdbGroupEntity.js +5 -0
- package/abstractions/CmsDdbGroupEntity.js.map +1 -0
- package/abstractions/CmsDdbModelEntity.d.ts +5 -0
- package/abstractions/CmsDdbModelEntity.js +5 -0
- package/abstractions/CmsDdbModelEntity.js.map +1 -0
- package/abstractions/CmsDdbTable.d.ts +5 -0
- package/abstractions/CmsDdbTable.js +5 -0
- package/abstractions/CmsDdbTable.js.map +1 -0
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +10 -93
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +10 -64
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +10 -108
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +4 -6
- package/definitions/table.js +7 -26
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/index.d.ts +10 -3
- package/index.js +45 -129
- package/index.js.map +1 -1
- package/operations/entry/DdbCreateEntry.d.ts +16 -0
- package/operations/entry/DdbCreateEntry.js +77 -0
- package/operations/entry/DdbCreateEntry.js.map +1 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/DdbDeleteEntry.d.ts +16 -0
- package/operations/entry/DdbDeleteEntry.js +65 -0
- package/operations/entry/DdbDeleteEntry.js.map +1 -0
- package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
- package/operations/entry/DdbDeleteEntryRevision.js +91 -0
- package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
- package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
- package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
- package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetEntriesByIds.js +31 -0
- package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetEntry.d.ts +14 -0
- package/operations/entry/DdbGetEntry.js +27 -0
- package/operations/entry/DdbGetEntry.js.map +1 -0
- package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
- package/operations/entry/DdbGetPreviousRevision.js +53 -0
- package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetRevisionById.d.ts +14 -0
- package/operations/entry/DdbGetRevisionById.js +34 -0
- package/operations/entry/DdbGetRevisionById.js.map +1 -0
- package/operations/entry/DdbGetRevisions.d.ts +14 -0
- package/operations/entry/DdbGetRevisions.js +33 -0
- package/operations/entry/DdbGetRevisions.js.map +1 -0
- package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
- package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
- package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/DdbListEntries.d.ts +28 -0
- package/operations/entry/DdbListEntries.js +124 -0
- package/operations/entry/DdbListEntries.js.map +1 -0
- package/operations/entry/DdbMoveEntry.d.ts +14 -0
- package/operations/entry/DdbMoveEntry.js +57 -0
- package/operations/entry/DdbMoveEntry.js.map +1 -0
- package/operations/entry/DdbMoveToBin.d.ts +16 -0
- package/operations/entry/DdbMoveToBin.js +77 -0
- package/operations/entry/DdbMoveToBin.js.map +1 -0
- package/operations/entry/DdbPublishEntry.d.ts +18 -0
- package/operations/entry/DdbPublishEntry.js +162 -0
- package/operations/entry/DdbPublishEntry.js.map +1 -0
- package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
- package/operations/entry/DdbRestoreFromBin.js +78 -0
- package/operations/entry/DdbRestoreFromBin.js.map +1 -0
- package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
- package/operations/entry/DdbUnpublishEntry.js +112 -0
- package/operations/entry/DdbUnpublishEntry.js.map +1 -0
- package/operations/entry/DdbUpdateEntry.d.ts +17 -0
- package/operations/entry/DdbUpdateEntry.js +105 -0
- package/operations/entry/DdbUpdateEntry.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +42 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +16 -31
- package/operations/entry/dataLoaders.js +92 -272
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +46 -2
- package/operations/entry/keys.js +54 -49
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/storageEntryUtils.d.ts +8 -0
- package/operations/entry/storageEntryUtils.js +25 -0
- package/operations/entry/storageEntryUtils.js.map +1 -0
- package/operations/group/DdbCreateGroup.d.ts +12 -0
- package/operations/group/DdbCreateGroup.js +35 -0
- package/operations/group/DdbCreateGroup.js.map +1 -0
- package/operations/group/DdbDeleteGroup.d.ts +12 -0
- package/operations/group/DdbDeleteGroup.js +31 -0
- package/operations/group/DdbDeleteGroup.js.map +1 -0
- package/operations/group/DdbGetGroup.d.ts +12 -0
- package/operations/group/DdbGetGroup.js +31 -0
- package/operations/group/DdbGetGroup.js.map +1 -0
- package/operations/group/DdbListGroups.d.ts +14 -0
- package/operations/group/DdbListGroups.js +52 -0
- package/operations/group/DdbListGroups.js.map +1 -0
- package/operations/group/DdbUpdateGroup.d.ts +12 -0
- package/operations/group/DdbUpdateGroup.js +35 -0
- package/operations/group/DdbUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/keys.d.ts +15 -0
- package/operations/group/keys.js +17 -0
- package/operations/group/keys.js.map +1 -0
- package/operations/model/DdbCreateModel.d.ts +12 -0
- package/operations/model/DdbCreateModel.js +37 -0
- package/operations/model/DdbCreateModel.js.map +1 -0
- package/operations/model/DdbDeleteModel.d.ts +12 -0
- package/operations/model/DdbDeleteModel.js +31 -0
- package/operations/model/DdbDeleteModel.js.map +1 -0
- package/operations/model/DdbGetModel.d.ts +12 -0
- package/operations/model/DdbGetModel.js +30 -0
- package/operations/model/DdbGetModel.js.map +1 -0
- package/operations/model/DdbListModels.d.ts +12 -0
- package/operations/model/DdbListModels.js +36 -0
- package/operations/model/DdbListModels.js.map +1 -0
- package/operations/model/DdbUpdateModel.d.ts +12 -0
- package/operations/model/DdbUpdateModel.js +36 -0
- package/operations/model/DdbUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/keys.d.ts +15 -0
- package/operations/model/keys.js +16 -0
- package/operations/model/keys.js.map +1 -0
- package/package.json +30 -33
- package/types.d.ts +12 -45
- package/types.js +8 -14
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -41
- package/definitions/system.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -13
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -33
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -91
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -95
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -45
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -176
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -14
- package/operations/entry/filtering/createFields.js +0 -105
- package/operations/entry/filtering/createFields.js.map +0 -1
- package/operations/entry/filtering/extractSort.d.ts +0 -17
- package/operations/entry/filtering/extractSort.js +0 -67
- package/operations/entry/filtering/extractSort.js.map +0 -1
- package/operations/entry/filtering/filter.d.ts +0 -15
- package/operations/entry/filtering/filter.js +0 -143
- package/operations/entry/filtering/filter.js.map +0 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
- package/operations/entry/filtering/fullTextSearch.js +0 -48
- package/operations/entry/filtering/fullTextSearch.js.map +0 -1
- package/operations/entry/filtering/getValue.d.ts +0 -5
- package/operations/entry/filtering/getValue.js +0 -63
- package/operations/entry/filtering/getValue.js.map +0 -1
- package/operations/entry/filtering/index.d.ts +0 -2
- package/operations/entry/filtering/index.js +0 -19
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/mapPlugins.d.ts +0 -8
- package/operations/entry/filtering/mapPlugins.js +0 -31
- package/operations/entry/filtering/mapPlugins.js.map +0 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/filtering/plugins/index.js +0 -13
- package/operations/entry/filtering/plugins/index.js.map +0 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -69
- package/operations/entry/filtering/sort.js.map +0 -1
- package/operations/entry/filtering/systemFields.d.ts +0 -4
- package/operations/entry/filtering/systemFields.js +0 -70
- package/operations/entry/filtering/systemFields.js.map +0 -1
- package/operations/entry/filtering/transform.d.ts +0 -6
- package/operations/entry/filtering/transform.js +0 -16
- package/operations/entry/filtering/transform.js.map +0 -1
- package/operations/entry/filtering/types.d.ts +0 -40
- package/operations/entry/filtering/types.js +0 -5
- package/operations/entry/filtering/types.js.map +0 -1
- package/operations/entry/filtering/values.d.ts +0 -2
- package/operations/entry/filtering/values.js +0 -22
- package/operations/entry/filtering/values.js.map +0 -1
- package/operations/entry/filtering/where.d.ts +0 -5
- package/operations/entry/filtering/where.js +0 -32
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/index.d.ts +0 -8
- package/operations/entry/index.js +0 -787
- package/operations/entry/index.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -72
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/group/index.d.ts +0 -9
- package/operations/group/index.js +0 -162
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -7
- package/operations/model/index.js +0 -137
- package/operations/model/index.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -82
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -4
- package/plugins/index.js +0 -49
- package/plugins/index.js.map +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createPlainObjectPathPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
|
|
10
|
-
/**
|
|
11
|
-
* File is @internal
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const createPath = ({
|
|
15
|
-
field
|
|
16
|
-
}) => {
|
|
17
|
-
const {
|
|
18
|
-
path
|
|
19
|
-
} = field.settings || {};
|
|
20
|
-
if (!path) {
|
|
21
|
-
throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
|
|
22
|
-
field
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return path;
|
|
26
|
-
};
|
|
27
|
-
const createPlainObjectPathPlugin = () => {
|
|
28
|
-
return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
|
|
29
|
-
fieldType: "plainObject",
|
|
30
|
-
path: createPath
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
exports.createPlainObjectPathPlugin = createPlainObjectPathPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPath","field","path","settings","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAOA,MAAMA,UAA8B,GAAG,CAAC;EAAEC;AAAM,CAAC,KAAK;EAClD,MAAM;IAAEC;EAAK,CAAC,GAAGD,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;EACrC,IAAI,CAACD,IAAI,EAAE;IACP,MAAM,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,2BAA2B,GAAG,MAAqC;EAC5E,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,aAAa;IACxBL,IAAI,EAAEF;EACV,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/dynamoDb/storage/date.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createDateStorageTransformPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
10
|
-
/**
|
|
11
|
-
* File is @internal
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const excludeTypes = ["time", "dateTimeWithTimezone"];
|
|
15
|
-
const convertFromStorage = (field, value) => {
|
|
16
|
-
try {
|
|
17
|
-
if (field.multipleValues) {
|
|
18
|
-
const result = [];
|
|
19
|
-
for (const v of value) {
|
|
20
|
-
if (!v) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
result.push(new Date(v));
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
return new Date(value);
|
|
30
|
-
} catch {
|
|
31
|
-
console.log(`Could not transform from storage for field type`);
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const convertValueToStorage = (field, value) => {
|
|
36
|
-
if (value.toISOString) {
|
|
37
|
-
return value.toISOString();
|
|
38
|
-
} else if (typeof value === "string") {
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
|
|
42
|
-
value: value,
|
|
43
|
-
fieldId: field.fieldId,
|
|
44
|
-
storageId: field.storageId
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const createDateStorageTransformPlugin = () => {
|
|
48
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
49
|
-
fieldType: "datetime",
|
|
50
|
-
fromStorage: async ({
|
|
51
|
-
value,
|
|
52
|
-
field
|
|
53
|
-
}) => {
|
|
54
|
-
const {
|
|
55
|
-
type
|
|
56
|
-
} = field.settings || {};
|
|
57
|
-
if (!value || !type || excludeTypes.includes(type)) {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
return convertFromStorage(field, value);
|
|
61
|
-
},
|
|
62
|
-
toStorage: async ({
|
|
63
|
-
value,
|
|
64
|
-
field
|
|
65
|
-
}) => {
|
|
66
|
-
const {
|
|
67
|
-
type
|
|
68
|
-
} = field.settings || {};
|
|
69
|
-
if (!value || !type || excludeTypes.includes(type)) {
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
if (field.multipleValues) {
|
|
73
|
-
const multipleValues = value;
|
|
74
|
-
return (multipleValues || []).filter(v => !!v).map(v => {
|
|
75
|
-
return convertValueToStorage(field, v);
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (value.toISOString) {
|
|
79
|
-
return value.toISOString();
|
|
80
|
-
} else if (typeof value === "string") {
|
|
81
|
-
return value;
|
|
82
|
-
}
|
|
83
|
-
throw new _error.default("Error converting value to a storage type.", "TO_STORAGE_ERROR", {
|
|
84
|
-
value,
|
|
85
|
-
fieldId: field.fieldId,
|
|
86
|
-
storageId: field.storageId
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
exports.createDateStorageTransformPlugin = createDateStorageTransformPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","result","v","push","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","filter","map"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (\n field: Pick<CmsModelField, \"multipleValues\">,\n value: string | string[]\n) => {\n try {\n if (field.multipleValues) {\n const result: Date[] = [];\n for (const v of value) {\n if (!v) {\n continue;\n }\n try {\n result.push(new Date(v));\n } catch {}\n }\n return result;\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORA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
* File is @internal
|
|
3
|
-
*/
|
|
4
|
-
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
5
|
-
export interface StorageValue {
|
|
6
|
-
compression: string;
|
|
7
|
-
value: string;
|
|
8
|
-
isArray?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createLongTextStorageTransformPlugin = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _gzip = require("@webiny/utils/compression/gzip");
|
|
10
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
11
|
-
/**
|
|
12
|
-
* File is @internal
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const GZIP = "gzip";
|
|
16
|
-
const TO_STORAGE_ENCODING = "base64";
|
|
17
|
-
const FROM_STORAGE_ENCODING = "utf8";
|
|
18
|
-
const convertToBuffer = value => {
|
|
19
|
-
if (typeof value === "string") {
|
|
20
|
-
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
const createLongTextStorageTransformPlugin = () => {
|
|
25
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
26
|
-
fieldType: "long-text",
|
|
27
|
-
fromStorage: async ({
|
|
28
|
-
field,
|
|
29
|
-
value: storageValue
|
|
30
|
-
}) => {
|
|
31
|
-
const typeOf = typeof storageValue;
|
|
32
|
-
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
33
|
-
return storageValue;
|
|
34
|
-
} else if (typeOf !== "object") {
|
|
35
|
-
throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
36
|
-
}
|
|
37
|
-
const {
|
|
38
|
-
compression,
|
|
39
|
-
value,
|
|
40
|
-
isArray
|
|
41
|
-
} = storageValue;
|
|
42
|
-
/**
|
|
43
|
-
* Check if possibly undefined, null, empty...
|
|
44
|
-
*/
|
|
45
|
-
if (!compression) {
|
|
46
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
47
|
-
value: storageValue
|
|
48
|
-
});
|
|
49
|
-
} else if (compression !== GZIP) {
|
|
50
|
-
throw new _error.default(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
51
|
-
compression
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
const buf = await (0, _gzip.decompress)(convertToBuffer(value));
|
|
56
|
-
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
57
|
-
if (!isArray) {
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
return JSON.parse(result);
|
|
61
|
-
} catch (ex) {
|
|
62
|
-
console.log("Error while transforming long-text.");
|
|
63
|
-
console.log(ex.message);
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
toStorage: async ({
|
|
68
|
-
value: initialValue
|
|
69
|
-
}) => {
|
|
70
|
-
/**
|
|
71
|
-
* There is a possibility that we are trying to compress already compressed value.
|
|
72
|
-
*/
|
|
73
|
-
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
74
|
-
return initialValue;
|
|
75
|
-
}
|
|
76
|
-
const isArray = Array.isArray(initialValue);
|
|
77
|
-
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
78
|
-
const compressedValue = await (0, _gzip.compress)(value);
|
|
79
|
-
const result = {
|
|
80
|
-
compression: GZIP,
|
|
81
|
-
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
82
|
-
};
|
|
83
|
-
if (!isArray) {
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
result.isArray = isArray;
|
|
87
|
-
return result;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as any;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":";;;;;;;AAIA;AACA;AACA;AANA;AACA;AACA;;AAMA,MAAMA,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAQM,MAAMG,oCAAoC,GAAG,MAAM;EACtD,OAAO,IAAIC,sCAAsB,CAAkC;IA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AqC,CAAC;QAClDD,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;QACvB,OAAO,EAAE;MACb;IACJ,CAAC;IACDC,SAAS,EAAE,OAAO;MAAE3B,KAAK,EAAE4B;IAAa,CAAC,KAAK;MAC1C;AACZ;AACA;MACY,IAAIA,YAAY,IAAIA,YAAY,CAACC,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACrE,OAAOD,YAAY;MACvB;MACA,MAAMjB,OAAO,GAAGD,KAAK,CAACC,OAAO,CAACiB,YAAY,CAAC;MAC3C,MAAM5B,KAAK,GAAGW,OAAO,GAAGK,IAAI,CAACC,SAAS,CAACW,YAAY,CAAC,GAAGA,YAAY;MACnE,MAAME,eAAe,GAAG,MAAM,IAAAC,cAAI,EAAC/B,KAAK,CAAC;MAEzC,MAAMoB,MAAoB,GAAG;QACzBL,WAAW,EAAEnB,IAAI;QACjBI,KAAK,EAAE8B,eAAe,CAACT,QAAQ,CAACxB,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACc,OAAO,EAAE;QACV,OAAOS,MAAM;MACjB;MACAA,MAAM,CAACT,OAAO,GAAGA,OAAO;MACxB,OAAOS,MAAM;IACjB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createRichTextStorageTransformPlugin = void 0;
|
|
8
|
-
var _jsonpack = _interopRequireDefault(require("jsonpack"));
|
|
9
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
11
|
-
/**
|
|
12
|
-
* File is @internal
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Remove when jsonpack gets PR with a fix merged
|
|
17
|
-
* https://github.com/rgcl/jsonpack/pull/25/files
|
|
18
|
-
* NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
|
|
19
|
-
*/
|
|
20
|
-
// TODO @ts-refactor figure better type
|
|
21
|
-
const transformArray = value => {
|
|
22
|
-
if (!value) {
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
let isArray = Array.isArray(value);
|
|
26
|
-
const shouldBeArray = value instanceof Array === false && isArray;
|
|
27
|
-
if (shouldBeArray) {
|
|
28
|
-
value = Array.from(value);
|
|
29
|
-
isArray = true;
|
|
30
|
-
}
|
|
31
|
-
if (typeof value === "object" || isArray) {
|
|
32
|
-
for (const k in value) {
|
|
33
|
-
value[k] = transformArray(value[k]);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
};
|
|
38
|
-
const createRichTextStorageTransformPlugin = () => {
|
|
39
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
40
|
-
fieldType: "rich-text",
|
|
41
|
-
fromStorage: async ({
|
|
42
|
-
field,
|
|
43
|
-
value: storageValue
|
|
44
|
-
}) => {
|
|
45
|
-
if (!storageValue) {
|
|
46
|
-
return storageValue;
|
|
47
|
-
} else if (typeof storageValue !== "object") {
|
|
48
|
-
throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* This is to circumvent a bug introduced with 5.8.0 storage operations.
|
|
52
|
-
* Do not remove.
|
|
53
|
-
*/
|
|
54
|
-
if (storageValue.hasOwnProperty("compression") === false) {
|
|
55
|
-
return storageValue;
|
|
56
|
-
}
|
|
57
|
-
const {
|
|
58
|
-
compression,
|
|
59
|
-
value
|
|
60
|
-
} = storageValue;
|
|
61
|
-
if (!compression) {
|
|
62
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.fieldId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
63
|
-
value: storageValue
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (compression !== "jsonpack") {
|
|
67
|
-
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
68
|
-
compression
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
return _jsonpack.default.unpack(value);
|
|
73
|
-
} catch {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
toStorage: async ({
|
|
78
|
-
value
|
|
79
|
-
}) => {
|
|
80
|
-
/**
|
|
81
|
-
* There is a possibility that we are trying to compress already compressed value.
|
|
82
|
-
* Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.
|
|
83
|
-
*/
|
|
84
|
-
if (value && value.hasOwnProperty("compression") === true) {
|
|
85
|
-
return value;
|
|
86
|
-
}
|
|
87
|
-
value = transformArray(value);
|
|
88
|
-
return {
|
|
89
|
-
compression: "jsonpack",
|
|
90
|
-
value: value ? _jsonpack.default.pack(value) : value
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","fieldId","hasOwnProperty","compression","JSON","stringify","jsonpack","unpack","toStorage","pack"],"sources":["richText.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (storageValue.hasOwnProperty(\"compression\") === false) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.fieldId\n }\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n }\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n return jsonpack.unpack(value);\n } catch {\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (value && value.hasOwnProperty(\"compression\") === true) {\n return value;\n }\n value = transformArray(value);\n return {\n compression: \"jsonpack\",\n value: value ? jsonpack.pack(value) : value\n };\n }\n });\n};\n"],"mappings":";;;;;;;AAGA;AACA;AACA;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAIC,KAAU,IAAK;EACnC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;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KAAK,UAAU,EAAE;QAC5B,MAAM,IAAIJ,cAAW,CAChB,oEAAmE,EACpE,mBAAmB,EACnB;UACII;QACJ,CAAC,CACJ;MACL;MACA,IAAI;QACA,OAAOG,iBAAQ,CAACC,MAAM,CAACpB,KAAK,CAAC;MACjC,CAAC,CAAC,MAAM;QACJ,OAAO,IAAI;MACf;IACJ,CAAC;IACDqB,SAAS,EAAE,OAAO;MAAErB;IAAM,CAAC,KAAK;MAC5B;AACZ;AACA;AACA;MACY,IAAIA,KAAK,IAAIA,KAAK,CAACe,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACvD,OAAOf,KAAK;MAChB;MACAA,KAAK,GAAGD,cAAc,CAACC,KAAK,CAAC;MAC7B,OAAO;QACHgB,WAAW,EAAE,UAAU;QACvBhB,KAAK,EAAEA,KAAK,GAAGmB,iBAAQ,CAACG,IAAI,CAACtB,KAAK,CAAC,GAAGA;MAC1C,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDatetimeTransformValuePlugin = void 0;
|
|
7
|
-
var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
|
|
8
|
-
var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
|
|
9
|
-
/**
|
|
10
|
-
* File is @internal
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const timeTransformer = new _TimeTransformPlugin.TimeTransformPlugin({
|
|
14
|
-
fields: ["*"]
|
|
15
|
-
});
|
|
16
|
-
const dateTimeTransformer = new _DateTimeTransformPlugin.DateTimeTransformPlugin({
|
|
17
|
-
fields: ["*"]
|
|
18
|
-
});
|
|
19
|
-
const createDatetimeTransformValuePlugin = () => {
|
|
20
|
-
return {
|
|
21
|
-
type: "cms-field-filter-value-transform",
|
|
22
|
-
name: "cms-field-value-filter-transform-datetime",
|
|
23
|
-
fieldType: "datetime",
|
|
24
|
-
/**
|
|
25
|
-
* Always transform into the milliseconds.
|
|
26
|
-
*/
|
|
27
|
-
transform: ({
|
|
28
|
-
field,
|
|
29
|
-
value
|
|
30
|
-
}) => {
|
|
31
|
-
const {
|
|
32
|
-
type
|
|
33
|
-
} = field.settings || {};
|
|
34
|
-
if (type === "time") {
|
|
35
|
-
return timeTransformer.transform({
|
|
36
|
-
value
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return dateTimeTransformer.transform({
|
|
40
|
-
value
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
exports.createDatetimeTransformValuePlugin = createDatetimeTransformValuePlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["timeTransformer","TimeTransformPlugin","fields","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"mappings":";;;;;;AAIA;AACA;AALA;AACA;AACA;;AAKA,MAAMA,eAAe,GAAG,IAAIC,wCAAmB,CAAC;EAC5CC,MAAM,EAAE,CAAC,GAAG;AAChB,CAAC,CAAC;AACF,MAAMC,mBAAmB,GAAG,IAAIC,gDAAuB,CAAC;EACpDF,MAAM,EAAE,CAAC,GAAG;AAChB,CAAC,CAAC;AAEK,MAAMG,kCAAkC,GAAG,MAA0C;EACxF,OAAO;IACHC,IAAI,EAAE,kCAAkC;IACxCC,IAAI,EAAE,2CAA2C;IACjDC,SAAS,EAAE,UAAU;IACrB;AACR;AACA;IACQC,SAAS,EAAE,CAAC;MAAEC,KAAK;MAAEC;IAAM,CAAC,KAAK;MAC7B,MAAM;QAAEL;MAAK,CAAC,GAAGI,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;MACrC,IAAIN,IAAI,KAAK,MAAM,EAAE;QACjB,OAAON,eAAe,CAACS,SAAS,CAAC;UAC7BE;QACJ,CAAC,CAAC;MACN;MACA,OAAOR,mBAAmB,CAACM,SAAS,CAAC;QACjCE;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
3
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
import { Field } from "./types";
|
|
5
|
-
interface Params {
|
|
6
|
-
plugins: PluginsContainer;
|
|
7
|
-
where: Partial<CmsEntryListWhere>;
|
|
8
|
-
fields: Record<string, Field>;
|
|
9
|
-
}
|
|
10
|
-
export declare type ExpressionCondition = "AND" | "OR";
|
|
11
|
-
export interface Expression {
|
|
12
|
-
expressions: Expression[];
|
|
13
|
-
filters: Filter[];
|
|
14
|
-
condition: ExpressionCondition;
|
|
15
|
-
}
|
|
16
|
-
export interface Filter {
|
|
17
|
-
field: Field;
|
|
18
|
-
path: string;
|
|
19
|
-
fieldPathId: string;
|
|
20
|
-
plugin: ValueFilterPlugin;
|
|
21
|
-
negate: boolean;
|
|
22
|
-
compareValue: any;
|
|
23
|
-
transformValue: <I = any, O = any>(value: I) => O;
|
|
24
|
-
}
|
|
25
|
-
export declare const createExpressions: (params: Params) => Expression;
|
|
26
|
-
export {};
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createExpressions = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
|
|
10
|
-
var _mapPlugins = require("./mapPlugins");
|
|
11
|
-
var _where = require("./where");
|
|
12
|
-
var _transform = require("./transform");
|
|
13
|
-
var _CmsEntryFieldFilterPlugin = require("../../../plugins/CmsEntryFieldFilterPlugin");
|
|
14
|
-
var _values = require("./values");
|
|
15
|
-
const createExpressions = params => {
|
|
16
|
-
const {
|
|
17
|
-
where,
|
|
18
|
-
plugins,
|
|
19
|
-
fields
|
|
20
|
-
} = params;
|
|
21
|
-
const filterPlugins = (0, _mapPlugins.getMappedPlugins)({
|
|
22
|
-
plugins,
|
|
23
|
-
type: _ValueFilterPlugin.ValueFilterPlugin.type,
|
|
24
|
-
property: "operation"
|
|
25
|
-
});
|
|
26
|
-
const transformValuePlugins = (0, _mapPlugins.getMappedPlugins)({
|
|
27
|
-
plugins,
|
|
28
|
-
type: "cms-field-filter-value-transform",
|
|
29
|
-
property: "fieldType"
|
|
30
|
-
});
|
|
31
|
-
const fieldFilterCreatePlugins = (0, _mapPlugins.getMappedPlugins)({
|
|
32
|
-
plugins,
|
|
33
|
-
type: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.type,
|
|
34
|
-
property: "fieldType"
|
|
35
|
-
});
|
|
36
|
-
const defaultFilterCreatePlugin = fieldFilterCreatePlugins["*"];
|
|
37
|
-
const getFilterCreatePlugin = type => {
|
|
38
|
-
const filterCreatePlugin = fieldFilterCreatePlugins[type] || defaultFilterCreatePlugin;
|
|
39
|
-
if (filterCreatePlugin) {
|
|
40
|
-
return filterCreatePlugin;
|
|
41
|
-
}
|
|
42
|
-
throw new _error.default(`There is no filter create plugin for the field type "${type}".`, "MISSING_FILTER_CREATE_PLUGIN", {
|
|
43
|
-
type
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
const createExpression = ({
|
|
47
|
-
where,
|
|
48
|
-
condition
|
|
49
|
-
}) => {
|
|
50
|
-
const expression = {
|
|
51
|
-
filters: [],
|
|
52
|
-
expressions: [],
|
|
53
|
-
condition
|
|
54
|
-
};
|
|
55
|
-
for (const key in where) {
|
|
56
|
-
const value = where[key];
|
|
57
|
-
if (value === undefined) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* If there are "AND" or "OR" keys, let's sort them out first.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* AND conditional
|
|
66
|
-
*/
|
|
67
|
-
if (key === "AND") {
|
|
68
|
-
const childWhereList = (0, _values.getWhereValues)(value, key);
|
|
69
|
-
const childExpression = {
|
|
70
|
-
condition: "AND",
|
|
71
|
-
filters: [],
|
|
72
|
-
expressions: []
|
|
73
|
-
};
|
|
74
|
-
for (const childWhere of childWhereList) {
|
|
75
|
-
const result = createExpression({
|
|
76
|
-
where: childWhere,
|
|
77
|
-
condition: "AND"
|
|
78
|
-
});
|
|
79
|
-
childExpression.expressions.push(result);
|
|
80
|
-
}
|
|
81
|
-
expression.expressions.push(childExpression);
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* OR conditional
|
|
86
|
-
*/
|
|
87
|
-
if (key === "OR") {
|
|
88
|
-
const childWhereList = (0, _values.getWhereValues)(value, key);
|
|
89
|
-
const childExpression = {
|
|
90
|
-
condition: "OR",
|
|
91
|
-
filters: [],
|
|
92
|
-
expressions: []
|
|
93
|
-
};
|
|
94
|
-
for (const childWhere of childWhereList) {
|
|
95
|
-
const result = createExpression({
|
|
96
|
-
where: childWhere,
|
|
97
|
-
condition: "AND"
|
|
98
|
-
});
|
|
99
|
-
childExpression.expressions.push(result);
|
|
100
|
-
}
|
|
101
|
-
expression.expressions.push(childExpression);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const whereParams = (0, _where.extractWhereParams)(key);
|
|
105
|
-
if (!whereParams) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const {
|
|
109
|
-
fieldId,
|
|
110
|
-
operation,
|
|
111
|
-
negate
|
|
112
|
-
} = whereParams;
|
|
113
|
-
const field = fields[fieldId];
|
|
114
|
-
if (!field) {
|
|
115
|
-
throw new _error.default(`There is no field with the fieldId "${fieldId}".`, "FIELD_ERROR", {
|
|
116
|
-
fieldId
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* We need a filter create plugin for this type.
|
|
122
|
-
*/
|
|
123
|
-
const filterCreatePlugin = getFilterCreatePlugin(field.type);
|
|
124
|
-
const transformValuePlugin = transformValuePlugins[field.type];
|
|
125
|
-
const transformValueCallable = value => {
|
|
126
|
-
if (!transformValuePlugin) {
|
|
127
|
-
return value;
|
|
128
|
-
}
|
|
129
|
-
return transformValuePlugin.transform({
|
|
130
|
-
field,
|
|
131
|
-
value
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
const result = filterCreatePlugin.create({
|
|
135
|
-
key,
|
|
136
|
-
value,
|
|
137
|
-
valueFilterPlugins: filterPlugins,
|
|
138
|
-
transformValuePlugins,
|
|
139
|
-
getFilterCreatePlugin,
|
|
140
|
-
operation,
|
|
141
|
-
negate,
|
|
142
|
-
field,
|
|
143
|
-
fields,
|
|
144
|
-
compareValue: (0, _transform.transformValue)({
|
|
145
|
-
value,
|
|
146
|
-
transform: transformValueCallable
|
|
147
|
-
}),
|
|
148
|
-
transformValue: transformValueCallable
|
|
149
|
-
});
|
|
150
|
-
/**
|
|
151
|
-
* There is a possibility of
|
|
152
|
-
* - no result
|
|
153
|
-
* - result being an array
|
|
154
|
-
* - result being an object
|
|
155
|
-
*/
|
|
156
|
-
if (!result || Array.isArray(result) && result.length === 0) {
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
expression.filters.push(...(Array.isArray(result) ? result : [result]));
|
|
160
|
-
}
|
|
161
|
-
return expression;
|
|
162
|
-
};
|
|
163
|
-
const expression = createExpression({
|
|
164
|
-
where,
|
|
165
|
-
condition: "AND"
|
|
166
|
-
});
|
|
167
|
-
/**
|
|
168
|
-
* If the first expression has no filters and has only one expression, put that expression as main one.
|
|
169
|
-
* This will mostly be used when having an OR condition as the single expression in the root level of the where
|
|
170
|
-
*/
|
|
171
|
-
if (expression.filters.length > 0 || expression.expressions.length !== 1) {
|
|
172
|
-
return expression;
|
|
173
|
-
}
|
|
174
|
-
return expression.expressions[0];
|
|
175
|
-
};
|
|
176
|
-
exports.createExpressions = createExpressions;
|