@webiny/api-headless-cms-ddb-es 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
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/configurations.d.ts +13 -6
- package/configurations.js +18 -12
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -3
- package/definitions/entry.js +108 -16
- package/definitions/entry.js.map +1 -1
- package/definitions/entryElasticsearch.d.ts +4 -3
- package/definitions/entryElasticsearch.js +11 -12
- package/definitions/entryElasticsearch.js.map +1 -1
- package/definitions/group.d.ts +4 -3
- package/definitions/group.js +8 -12
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -3
- package/definitions/model.js +30 -12
- package/definitions/model.js.map +1 -1
- package/definitions/system.d.ts +4 -3
- package/definitions/system.js +8 -12
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +5 -5
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -1
- package/definitions/tableElasticsearch.d.ts +5 -5
- package/definitions/tableElasticsearch.js +7 -6
- package/definitions/tableElasticsearch.js.map +1 -1
- package/dynamoDb/index.d.ts +2 -1
- package/dynamoDb/index.js +8 -8
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +13 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -6
- package/dynamoDb/storage/richText.js +26 -95
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
- package/elasticsearch/createElasticsearchIndex.js +19 -39
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/deleteElasticsearchIndex.js +5 -10
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.js +2 -5
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +8 -23
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.js +4 -10
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
- package/elasticsearch/indexing/jsonIndexing.js +28 -0
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
- package/elasticsearch/indexing/longTextIndexing.js +16 -10
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +2 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +23 -45
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +2 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.js +3 -5
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.js +2 -4
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/indices/japanese.js +3 -5
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +4 -5
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.js +6 -8
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +60 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/elasticsearch/search/timeSearch.js +3 -9
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +3 -3
- package/helpers/entryIndexHelpers.js +51 -65
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +6 -0
- package/helpers/fieldIdentifier.js +43 -0
- package/helpers/fieldIdentifier.js.map +1 -0
- package/helpers/index.d.ts +1 -1
- package/helpers/index.js +11 -13
- package/helpers/index.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +50 -93
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +10 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -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 +52 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +62 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +40 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +16 -37
- package/operations/entry/dataLoaders.js +54 -303
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +142 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +10 -0
- package/operations/entry/elasticsearch/fields.js +315 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +175 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
- package/operations/entry/elasticsearch/filtering/path.js +48 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +25 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +24 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +106 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +36 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +39 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -8
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +89 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +7 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/index.d.ts +4 -6
- package/operations/entry/index.js +1211 -596
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +2 -9
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +20 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +38 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +29 -0
- package/operations/entry/transformations/index.js +127 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
- package/operations/entry/transformations/modifyEntryValues.js +28 -0
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
- package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
- package/operations/entry/transformations/transformEntryKeys.js +27 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
- package/operations/entry/transformations/transformEntryToIndex.js +31 -0
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
- package/operations/group/index.d.ts +3 -3
- package/operations/group/index.js +38 -54
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +26 -47
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +18 -23
- package/operations/system/index.js.map +1 -1
- package/operations/system/indexes.d.ts +10 -0
- package/operations/system/indexes.js +41 -0
- package/operations/system/indexes.js.map +1 -0
- package/package.json +37 -34
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +8 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +5 -9
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +12 -15
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +8 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +8 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +22 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +3 -1
- package/plugins/index.js +36 -24
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +67 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
- package/types.d.ts +27 -22
- package/types.js +5 -10
- package/types.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +20 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -58
- package/definitions/settings.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -2
- package/dynamoDb/storage/date.js +0 -99
- package/dynamoDb/storage/date.js.map +0 -1
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -611
- package/helpers/createElasticsearchQueryBody.js.map +0 -1
- package/helpers/fields.d.ts +0 -19
- package/helpers/fields.js +0 -205
- package/helpers/fields.js.map +0 -1
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/searchPluginsList.js.map +0 -1
- package/helpers/transformValueForSearch.d.ts +0 -12
- package/helpers/transformValueForSearch.js +0 -29
- package/helpers/transformValueForSearch.js.map +0 -1
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -38
- package/operations/entry/elasticsearchFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -135
- package/operations/settings/index.js.map +0 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
package/definitions/system.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createSystemEntity = void 0;
|
|
9
|
-
|
|
10
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
14
8
|
const createSystemEntity = params => {
|
|
15
9
|
const {
|
|
16
10
|
entityName,
|
|
17
11
|
attributes,
|
|
18
12
|
table
|
|
19
13
|
} = params;
|
|
20
|
-
return new
|
|
14
|
+
return new _toolbox.Entity({
|
|
21
15
|
name: entityName,
|
|
22
16
|
table,
|
|
23
|
-
attributes:
|
|
17
|
+
attributes: {
|
|
24
18
|
PK: {
|
|
25
19
|
partitionKey: true
|
|
26
20
|
},
|
|
@@ -38,9 +32,11 @@ const createSystemEntity = params => {
|
|
|
38
32
|
},
|
|
39
33
|
readAPIKey: {
|
|
40
34
|
type: "string"
|
|
41
|
-
}
|
|
42
|
-
|
|
35
|
+
},
|
|
36
|
+
...(attributes || {})
|
|
37
|
+
}
|
|
43
38
|
});
|
|
44
39
|
};
|
|
40
|
+
exports.createSystemEntity = createSystemEntity;
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey"],"sources":["system.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey","exports"],"sources":["system.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\nexport interface CreateSystemEntityParams {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: CreateSystemEntityParams): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n readAPIKey: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAgC,IAAkB;EACjF,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,UAAU,EAAE;QACRH,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
package/definitions/table.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TableModifier } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
import { Table } from "dynamodb
|
|
1
|
+
import type { TableModifier } from "../types";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
3
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
4
4
|
export interface CreateTableParams {
|
|
5
5
|
table?: TableModifier;
|
|
6
|
-
documentClient:
|
|
6
|
+
documentClient: DynamoDBDocument;
|
|
7
7
|
}
|
|
8
|
-
export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table
|
|
8
|
+
export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table<string, string, string>;
|
package/definitions/table.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createTable = void 0;
|
|
7
|
-
|
|
8
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
9
|
-
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createTable = ({
|
|
11
9
|
table,
|
|
12
10
|
documentClient
|
|
@@ -15,10 +13,13 @@ const createTable = ({
|
|
|
15
13
|
name: process.env.DB_TABLE_HEADLESS_CMS || process.env.DB_TABLE,
|
|
16
14
|
partitionKey: "PK",
|
|
17
15
|
sortKey: "SK",
|
|
18
|
-
DocumentClient: documentClient
|
|
16
|
+
DocumentClient: documentClient,
|
|
17
|
+
autoExecute: true,
|
|
18
|
+
autoParse: true
|
|
19
19
|
};
|
|
20
20
|
const config = typeof table === "function" ? table(tableConfig) : tableConfig;
|
|
21
|
-
return new
|
|
21
|
+
return new _toolbox.Table(config);
|
|
22
22
|
};
|
|
23
|
+
exports.createTable = createTable;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
//# sourceMappingURL=table.js.map
|
package/definitions/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_HEADLESS_CMS","DB_TABLE","partitionKey","sortKey","DocumentClient","config","Table"],"sources":["table.ts"],"sourcesContent":["import { TableModifier } from \"~/types\";\nimport {
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_HEADLESS_CMS","DB_TABLE","partitionKey","sortKey","DocumentClient","autoExecute","autoParse","config","Table","exports"],"sources":["table.ts"],"sourcesContent":["import type { TableModifier } from \"~/types\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\n\nexport interface CreateTableParams {\n table?: TableModifier;\n documentClient: DynamoDBDocument;\n}\nexport const createTable = ({\n table,\n documentClient\n}: CreateTableParams): Table<string, string, string> => {\n const tableConfig: TableConstructor<string, string, string> = {\n name: process.env.DB_TABLE_HEADLESS_CMS || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n autoExecute: true,\n autoParse: true\n };\n\n const config = typeof table === \"function\" ? table(tableConfig) : tableConfig;\n\n return new Table(config);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMO,MAAMC,WAAW,GAAGA,CAAC;EACxBC,KAAK;EACLC;AACe,CAAC,KAAoC;EACpD,MAAMC,WAAqD,GAAG;IAC1DC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,qBAAqB,IAAKF,OAAO,CAACC,GAAG,CAACE,QAAmB;IAC3EC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAET,cAAc;IAC9BU,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC;EAED,MAAMC,MAAM,GAAG,OAAOb,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACE,WAAW,CAAC,GAAGA,WAAW;EAE7E,OAAO,IAAIY,cAAK,CAACD,MAAM,CAAC;AAC5B,CAAC;AAACE,OAAA,CAAAhB,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { TableModifier } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
import { Table } from "dynamodb
|
|
1
|
+
import type { TableModifier } from "../types";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
3
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
4
4
|
export interface CreateElasticsearchTableParams {
|
|
5
5
|
table?: TableModifier;
|
|
6
|
-
documentClient:
|
|
6
|
+
documentClient: DynamoDBDocument;
|
|
7
7
|
}
|
|
8
|
-
export declare const createElasticsearchTable: ({ table, documentClient }: CreateElasticsearchTableParams) => Table
|
|
8
|
+
export declare const createElasticsearchTable: ({ table, documentClient }: CreateElasticsearchTableParams) => Table<string, string, string>;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createElasticsearchTable = void 0;
|
|
7
|
-
|
|
8
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
9
|
-
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createElasticsearchTable = ({
|
|
11
9
|
table,
|
|
12
10
|
documentClient
|
|
@@ -15,10 +13,13 @@ const createElasticsearchTable = ({
|
|
|
15
13
|
name: process.env.DB_TABLE_ELASTICSEARCH,
|
|
16
14
|
partitionKey: "PK",
|
|
17
15
|
sortKey: "SK",
|
|
18
|
-
DocumentClient: documentClient
|
|
16
|
+
DocumentClient: documentClient,
|
|
17
|
+
autoExecute: true,
|
|
18
|
+
autoParse: true
|
|
19
19
|
};
|
|
20
20
|
const config = typeof table === "function" ? table(tableConfig) : tableConfig;
|
|
21
|
-
return new
|
|
21
|
+
return new _toolbox.Table(config);
|
|
22
22
|
};
|
|
23
|
+
exports.createElasticsearchTable = createElasticsearchTable;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
//# sourceMappingURL=tableElasticsearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createElasticsearchTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_ELASTICSEARCH","partitionKey","sortKey","DocumentClient","config","Table"],"sources":["tableElasticsearch.ts"],"sourcesContent":["import { TableModifier } from \"~/types\";\nimport {
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createElasticsearchTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_ELASTICSEARCH","partitionKey","sortKey","DocumentClient","autoExecute","autoParse","config","Table","exports"],"sources":["tableElasticsearch.ts"],"sourcesContent":["import type { TableModifier } from \"~/types\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\n\nexport interface CreateElasticsearchTableParams {\n table?: TableModifier;\n documentClient: DynamoDBDocument;\n}\nexport const createElasticsearchTable = ({\n table,\n documentClient\n}: CreateElasticsearchTableParams): Table<string, string, string> => {\n const tableConfig: TableConstructor<string, string, string> = {\n name: process.env.DB_TABLE_ELASTICSEARCH as string,\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n autoExecute: true,\n autoParse: true\n };\n\n const config = typeof table === \"function\" ? table(tableConfig) : tableConfig;\n\n return new Table(config);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GAAGA,CAAC;EACrCC,KAAK;EACLC;AAC4B,CAAC,KAAoC;EACjE,MAAMC,WAAqD,GAAG;IAC1DC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,sBAAgC;IAClDC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAER,cAAc;IAC9BS,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC;EAED,MAAMC,MAAM,GAAG,OAAOZ,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACE,WAAW,CAAC,GAAGA,WAAW;EAE7E,OAAO,IAAIW,cAAK,CAACD,MAAM,CAAC;AAC5B,CAAC;AAACE,OAAA,CAAAf,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
package/dynamoDb/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
declare const _default: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any>[];
|
|
1
|
+
declare const _default: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>[];
|
|
2
2
|
export default _default;
|
|
3
|
+
export declare const createDynamoDbPlugins: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>[];
|
package/dynamoDb/index.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
6
|
+
exports.default = exports.createDynamoDbPlugins = void 0;
|
|
8
7
|
var _richText = require("./storage/richText");
|
|
9
|
-
|
|
10
8
|
var _longText = require("./storage/longText");
|
|
9
|
+
var _default = () => createDynamoDbPlugins();
|
|
10
|
+
exports.default = _default;
|
|
11
|
+
const createDynamoDbPlugins = () => {
|
|
12
|
+
return [(0, _richText.createRichTextStorageTransformPlugin)(), (0, _longText.createLongTextStorageTransformPlugin)()];
|
|
13
|
+
};
|
|
14
|
+
exports.createDynamoDbPlugins = createDynamoDbPlugins;
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var _default = () => [(0, _richText.createRichTextStorageTransformPlugin)(), (0, _longText.createLongTextStorageTransformPlugin)(), (0, _date.createDateStorageTransformPlugin)()];
|
|
15
|
-
|
|
16
|
-
exports.default = _default;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/dynamoDb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_richText","require","_longText","_default","createDynamoDbPlugins","exports","default","createRichTextStorageTransformPlugin","createLongTextStorageTransformPlugin"],"sources":["index.ts"],"sourcesContent":["import { createRichTextStorageTransformPlugin } from \"./storage/richText\";\nimport { createLongTextStorageTransformPlugin } from \"./storage/longText\";\n\nexport default () => createDynamoDbPlugins();\n\nexport const createDynamoDbPlugins = () => {\n return [createRichTextStorageTransformPlugin(), createLongTextStorageTransformPlugin()];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAA0E,IAAAE,QAAA,GAE3DA,CAAA,KAAMC,qBAAqB,CAAC,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAH,QAAA;AAErC,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,CAAC,IAAAG,8CAAoC,EAAC,CAAC,EAAE,IAAAC,8CAAoC,EAAC,CAAC,CAAC;AAC3F,CAAC;AAACH,OAAA,CAAAD,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -7,4 +7,4 @@ export interface StorageValue {
|
|
|
7
7
|
value: string;
|
|
8
8
|
isArray?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue>;
|
|
10
|
+
export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,48 +1,40 @@
|
|
|
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.createLongTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
var _gzip = require("@webiny/utils/compression/gzip");
|
|
13
|
-
|
|
14
10
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* File is @internal
|
|
18
13
|
*/
|
|
14
|
+
|
|
19
15
|
const GZIP = "gzip";
|
|
20
16
|
const TO_STORAGE_ENCODING = "base64";
|
|
21
17
|
const FROM_STORAGE_ENCODING = "utf8";
|
|
22
|
-
|
|
23
18
|
const convertToBuffer = value => {
|
|
24
19
|
if (typeof value === "string") {
|
|
25
20
|
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
return value;
|
|
29
23
|
};
|
|
30
|
-
|
|
31
24
|
const createLongTextStorageTransformPlugin = () => {
|
|
32
|
-
|
|
25
|
+
const plugin = new _apiHeadlessCms.StorageTransformPlugin({
|
|
26
|
+
name: "headless-cms.storage-transform.long-text.default",
|
|
33
27
|
fieldType: "long-text",
|
|
34
28
|
fromStorage: async ({
|
|
35
29
|
field,
|
|
36
30
|
value: storageValue
|
|
37
31
|
}) => {
|
|
38
32
|
const typeOf = typeof storageValue;
|
|
39
|
-
|
|
40
33
|
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
41
34
|
return storageValue;
|
|
42
35
|
} else if (typeOf !== "object") {
|
|
43
36
|
throw new _error.default(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
const {
|
|
47
39
|
compression,
|
|
48
40
|
value,
|
|
@@ -51,7 +43,6 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
51
43
|
/**
|
|
52
44
|
* Check if possibly undefined, null, empty...
|
|
53
45
|
*/
|
|
54
|
-
|
|
55
46
|
if (!compression) {
|
|
56
47
|
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
57
48
|
value: storageValue
|
|
@@ -61,15 +52,12 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
61
52
|
compression
|
|
62
53
|
});
|
|
63
54
|
}
|
|
64
|
-
|
|
65
55
|
try {
|
|
66
56
|
const buf = await (0, _gzip.decompress)(convertToBuffer(value));
|
|
67
57
|
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
68
|
-
|
|
69
58
|
if (!isArray) {
|
|
70
59
|
return result;
|
|
71
60
|
}
|
|
72
|
-
|
|
73
61
|
return JSON.parse(result);
|
|
74
62
|
} catch (ex) {
|
|
75
63
|
console.log("Error while transforming long-text.");
|
|
@@ -80,6 +68,12 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
80
68
|
toStorage: async ({
|
|
81
69
|
value: initialValue
|
|
82
70
|
}) => {
|
|
71
|
+
/**
|
|
72
|
+
* There is a possibility that we are trying to compress already compressed value.
|
|
73
|
+
*/
|
|
74
|
+
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
75
|
+
return initialValue;
|
|
76
|
+
}
|
|
83
77
|
const isArray = Array.isArray(initialValue);
|
|
84
78
|
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
85
79
|
const compressedValue = await (0, _gzip.compress)(value);
|
|
@@ -87,15 +81,16 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
87
81
|
compression: GZIP,
|
|
88
82
|
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
89
83
|
};
|
|
90
|
-
|
|
91
84
|
if (!isArray) {
|
|
92
85
|
return result;
|
|
93
86
|
}
|
|
94
|
-
|
|
95
87
|
result.isArray = isArray;
|
|
96
88
|
return result;
|
|
97
89
|
}
|
|
98
90
|
});
|
|
91
|
+
plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;
|
|
92
|
+
return plugin;
|
|
99
93
|
};
|
|
94
|
+
exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
//# sourceMappingURL=longText.js.map
|
|
@@ -1 +1 @@
|
|
|
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","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
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","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","exports"],"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 const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\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 unknown as StorageValue;\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 plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,MAAMG,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OA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in } from "@webiny/api-headless-cms";
|
|
2
|
-
export declare
|
|
3
|
-
export interface StorageValue {
|
|
4
|
-
compression: string;
|
|
5
|
-
value: any;
|
|
6
|
-
}
|
|
7
|
-
export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any>;
|
|
2
|
+
export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,128 +1,59 @@
|
|
|
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.createRichTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _jsonpack = _interopRequireDefault(require("jsonpack"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Remove when jsonpack gets PR with a fix merged
|
|
18
|
-
* https://github.com/rgcl/jsonpack/pull/25/files
|
|
19
|
-
* NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
|
|
20
|
-
*/
|
|
21
|
-
// TODO @ts-refactor figure better type
|
|
22
|
-
const transformArray = value => {
|
|
23
|
-
if (!value) {
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let isArray = Array.isArray(value);
|
|
28
|
-
const shouldBeArray = value instanceof Array === false && isArray;
|
|
29
|
-
|
|
30
|
-
if (shouldBeArray) {
|
|
31
|
-
value = Array.from(value);
|
|
32
|
-
isArray = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof value === "object" || isArray) {
|
|
36
|
-
for (const k in value) {
|
|
37
|
-
value[k] = transformArray(value[k]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return value;
|
|
42
|
-
};
|
|
43
|
-
|
|
10
|
+
var _api = require("@webiny/api");
|
|
44
11
|
const createRichTextStorageTransformPlugin = () => {
|
|
45
|
-
|
|
12
|
+
const plugin = new _apiHeadlessCms.StorageTransformPlugin({
|
|
13
|
+
name: "headless-cms.storage-transform.rich-text.default",
|
|
46
14
|
fieldType: "rich-text",
|
|
47
15
|
fromStorage: async ({
|
|
48
16
|
field,
|
|
49
|
-
value: storageValue
|
|
17
|
+
value: storageValue,
|
|
18
|
+
plugins
|
|
50
19
|
}) => {
|
|
51
20
|
if (!storageValue) {
|
|
52
21
|
return storageValue;
|
|
53
22
|
} else if (typeof storageValue !== "object") {
|
|
54
|
-
throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}".`);
|
|
23
|
+
throw new _error.default(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
55
24
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (storageValue.hasOwnProperty("compression") === false) {
|
|
25
|
+
let compressor;
|
|
26
|
+
try {
|
|
27
|
+
compressor = plugins.oneByType(_api.CompressorPlugin.type);
|
|
28
|
+
} catch (ex) {
|
|
63
29
|
return storageValue;
|
|
64
30
|
}
|
|
65
|
-
|
|
66
|
-
const {
|
|
67
|
-
compression,
|
|
68
|
-
value
|
|
69
|
-
} = storageValue;
|
|
70
|
-
|
|
71
|
-
if (!compression) {
|
|
72
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
73
|
-
value: storageValue
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (compression !== "jsonpack") {
|
|
78
|
-
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
79
|
-
compression
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
31
|
try {
|
|
84
|
-
return
|
|
85
|
-
} catch
|
|
86
|
-
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log("Error while decompressing rich-text.");
|
|
91
|
-
console.log(ex.message);
|
|
92
|
-
return null;
|
|
32
|
+
return await compressor.getCompressor().decompress(storageValue);
|
|
33
|
+
} catch {
|
|
34
|
+
return storageValue;
|
|
93
35
|
}
|
|
94
36
|
},
|
|
95
37
|
toStorage: async ({
|
|
96
|
-
value
|
|
38
|
+
value,
|
|
39
|
+
plugins
|
|
97
40
|
}) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (value && value.hasOwnProperty("compression") === true) {
|
|
41
|
+
let compressor;
|
|
42
|
+
try {
|
|
43
|
+
compressor = plugins.oneByType(_api.CompressorPlugin.type);
|
|
44
|
+
} catch (ex) {
|
|
103
45
|
return value;
|
|
104
46
|
}
|
|
105
|
-
|
|
106
|
-
value = transformArray(value);
|
|
107
|
-
let jsonValue = null;
|
|
108
|
-
|
|
109
47
|
try {
|
|
110
|
-
|
|
111
|
-
} catch
|
|
112
|
-
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log("Error while compressing rich-text.");
|
|
117
|
-
console.log(ex.message);
|
|
48
|
+
return await compressor.getCompressor().compress(value);
|
|
49
|
+
} catch {
|
|
50
|
+
return value;
|
|
118
51
|
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
compression: "jsonpack",
|
|
122
|
-
value: jsonValue
|
|
123
|
-
};
|
|
124
52
|
}
|
|
125
53
|
});
|
|
54
|
+
plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;
|
|
55
|
+
return plugin;
|
|
126
56
|
};
|
|
57
|
+
exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
|
|
127
58
|
|
|
128
|
-
|
|
59
|
+
//# sourceMappingURL=richText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","_api","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","name","fieldType","fromStorage","field","value","storageValue","plugins","WebinyError","storageId","fieldId","compressor","oneByType","CompressorPlugin","type","ex","getCompressor","decompress","toStorage","compress","exports"],"sources":["richText.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue, plugins }) => {\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 let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch (ex) {\n return storageValue;\n }\n\n try {\n return await compressor.getCompressor().decompress(storageValue);\n } catch {\n return storageValue;\n }\n },\n toStorage: async ({ value, plugins }) => {\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch (ex) {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAEO,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC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A","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Client } from "@elastic/elasticsearch";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
4
|
export interface CreateElasticsearchIndexParams {
|
|
5
|
-
|
|
5
|
+
client: Client;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
model: CmsModel;
|
|
8
8
|
}
|