@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.40876133bb
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 +2 -2
- package/configurations.js +18 -7
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +2 -2
- package/definitions/entry.js +6 -7
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +2 -2
- package/definitions/entryElasticsearch.js +3 -7
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +2 -2
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -2
- package/definitions/model.js +3 -7
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -2
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -2
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -2
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -2
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -6
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +2 -3
- package/dynamoDb/storage/date.js +80 -46
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +72 -54
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -3
- package/dynamoDb/storage/richText.js +85 -67
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +43 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +1 -1
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +1 -1
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
- package/elasticsearch/indexing/objectIndexing.js +32 -9
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +15 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +16 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +3 -5
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +25 -16
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +22 -14
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/createElasticsearchQueryBody.js +320 -84
- package/helpers/createElasticsearchQueryBody.js.map +1 -0
- package/helpers/entryIndexHelpers.js +33 -18
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/fields.d.ts +4 -62
- package/helpers/fields.js +39 -8
- package/helpers/fields.js.map +1 -0
- package/helpers/index.js.map +1 -0
- package/helpers/searchPluginsList.d.ts +2 -2
- package/helpers/searchPluginsList.js +1 -1
- package/helpers/searchPluginsList.js.map +1 -0
- package/helpers/transformValueForSearch.d.ts +5 -2
- package/helpers/transformValueForSearch.js +3 -0
- package/helpers/transformValueForSearch.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +126 -29
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +6 -2
- package/operations/entry/dataLoaders.js +31 -13
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearchFields.js +6 -0
- package/operations/entry/elasticsearchFields.js.map +1 -0
- package/operations/entry/index.d.ts +2 -2
- package/operations/entry/index.js +445 -331
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +8 -15
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +38 -39
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +7 -13
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +5 -11
- package/operations/system/index.js.map +1 -0
- package/package.json +24 -29
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +6 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +7 -34
- package/types.js +0 -13
- package/types.js.map +1 -0
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTITIES"],"sources":["types.ts"],"sourcesContent":["import { Plugin, PluginCollection } from \"@webiny/plugins/types\";\nimport {\n CmsContext as BaseCmsContext,\n CmsEntry,\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\n/**\n * A definition of the entry that is being prepared for the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\nexport interface CmsIndexEntry extends CmsEntry {\n /**\n * Values that are not going to be indexed.\n */\n rawValues: Record<string, any>;\n /**\n * A first part of the ID, without the revision.\n * For example, we can search for all the revisions of the given entry.\n */\n primaryId: string;\n /**\n * Dev can add what ever keys they want and need. Just need to be careful not to break the entry.\n */\n [key: string]: any;\n}\n\n/**\n * Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchToParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n /**\n * Raw value on the entry - before prepare for storage.\n */\n rawValue: any;\n /**\n * Value prepared for storage received from base api-headless-cms package.\n */\n value: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * Arguments for the method that is transforming content entry from Elasticsearch into the original one.\n *\n * @category Elasticsearch\n * @category CmsEntry\n */\ninterface CmsModelFieldToElasticsearchFromParams {\n plugins: PluginsContainer;\n model: CmsModel;\n field: CmsModelField;\n value: any;\n rawValue: any;\n getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;\n getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;\n}\n\ninterface ToIndexValue {\n /**\n * Use this key to store value for indexing.\n */\n value?: any;\n /**\n * Use this key to tell ES that this value should not be indexed.\n */\n rawValue?: any;\n}\n\n/**\n * A plugin defining transformation of entry for Elasticsearch.\n *\n * @category Plugin\n * @category ContentModelField\n * @category CmsEntry\n * @category Elasticsearch\n */\nexport interface CmsModelFieldToElasticsearchPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-elastic-search\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * If you need to define a type when building an Elasticsearch query.\n * Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.\n *\n * ```ts\n * unmappedType: \"date\"\n * ```\n */\n unmappedType?: (field: CmsModelField) => string;\n /**\n * This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.\n * It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.\n *\n * ```ts\n * toIndex({ value }) {\n * return {\n * value: value, // This will be stored and indexed\n * rawValue: JSON.stringify(value) // This will be stored but excluded from indexing\n * };\n * }\n * ```\n */\n toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;\n /**\n * This is meant to revert a transformation done in the `toIndex` method.\n * You have access to \"value\" or a \"rawValue\", depending on what you returned from `toIndex`.\n *\n * ```ts\n * fromIndex({ value, rawValue }) {\n * return JSON.parse(rawValue);\n * }\n * ```\n */\n fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n SETTINGS = \"CmsSettings\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\",\n ENTRIES_ES = \"CmsEntriesElasticsearch\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n elasticsearch: Client;\n table?: TableModifier;\n esTable?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: PluginCollection;\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations<CmsContext> {\n getTable: () => Table;\n getEsTable: () => Table;\n getEntities: () => Record<\n \"system\" | \"settings\" | \"groups\" | \"models\" | \"entries\" | \"entriesEs\",\n Entity<any>\n >;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsContext extends BaseCmsContext {\n [key: string]: any;\n}\n"],"mappings":";;;;;;;AAmBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IAsDYA,Q;;;WAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;EAAAA,Q;GAAAA,Q,wBAAAA,Q"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
interface OperatorPlugins {
|
|
4
|
-
[operator: string]: ElasticsearchQueryBuilderOperatorPlugin;
|
|
5
|
-
}
|
|
6
|
-
export declare const operatorPluginsList: (plugins: PluginsContainer) => OperatorPlugins;
|
|
7
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.operatorPluginsList = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _ElasticsearchQueryBuilderOperatorPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin");
|
|
13
|
-
|
|
14
|
-
const operatorPluginsList = plugins => {
|
|
15
|
-
return plugins.byType(_ElasticsearchQueryBuilderOperatorPlugin.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((plugins, plugin) => {
|
|
16
|
-
const operator = plugin.getOperator();
|
|
17
|
-
|
|
18
|
-
if (plugins[operator]) {
|
|
19
|
-
throw new _error.default("There is a ElasticsearchQueryBuilderOperatorPlugin defined for the operator.", "PLUGIN_ALREADY_EXISTS", {
|
|
20
|
-
operator: operator,
|
|
21
|
-
name: plugin.name || "unknown"
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
plugins[operator] = plugin;
|
|
26
|
-
return plugins;
|
|
27
|
-
}, {});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.operatorPluginsList = operatorPluginsList;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { CmsEntryElasticsearchFieldPlugin } from "../../plugins/CmsEntryElasticsearchFieldPlugin";
|
|
3
|
-
export declare const createElasticsearchFields: (model: CmsModel) => Record<string, CmsEntryElasticsearchFieldPlugin>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createElasticsearchFields = void 0;
|
|
7
|
-
|
|
8
|
-
var _CmsEntryElasticsearchFieldPlugin = require("../../plugins/CmsEntryElasticsearchFieldPlugin");
|
|
9
|
-
|
|
10
|
-
const fieldsWithKeywords = ["text", "long-text", "rich-text", "id", "ref"];
|
|
11
|
-
/**
|
|
12
|
-
* We need to map entry system fields that have different paths, no keyword or not sortable.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const systemFields = {
|
|
16
|
-
createdBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
17
|
-
field: "createdBy",
|
|
18
|
-
path: "createdBy.id",
|
|
19
|
-
searchable: true,
|
|
20
|
-
keyword: true,
|
|
21
|
-
sortable: false
|
|
22
|
-
}),
|
|
23
|
-
ownedBy: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
24
|
-
field: "ownedBy",
|
|
25
|
-
path: "ownedBy.id",
|
|
26
|
-
searchable: true,
|
|
27
|
-
keyword: true,
|
|
28
|
-
sortable: false
|
|
29
|
-
}),
|
|
30
|
-
createdOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
31
|
-
field: "createdOn",
|
|
32
|
-
path: "createdOn",
|
|
33
|
-
searchable: true,
|
|
34
|
-
keyword: false,
|
|
35
|
-
sortable: false,
|
|
36
|
-
unmappedType: "date"
|
|
37
|
-
}),
|
|
38
|
-
savedOn: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
39
|
-
field: "savedOn",
|
|
40
|
-
path: "savedOn",
|
|
41
|
-
searchable: true,
|
|
42
|
-
keyword: false,
|
|
43
|
-
sortable: false,
|
|
44
|
-
unmappedType: "date"
|
|
45
|
-
})
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const createElasticsearchFields = model => {
|
|
49
|
-
return model.fields.reduce((fields, field) => {
|
|
50
|
-
fields[field.fieldId] = new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
51
|
-
field: field.fieldId,
|
|
52
|
-
path: `values.${field.fieldId}`,
|
|
53
|
-
searchable: true,
|
|
54
|
-
keyword: fieldsWithKeywords.includes(field.type)
|
|
55
|
-
});
|
|
56
|
-
return fields;
|
|
57
|
-
}, systemFields);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.createElasticsearchFields = createElasticsearchFields;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createElasticsearchTemplate = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
const createElasticsearchTemplate = async params => {
|
|
13
|
-
const {
|
|
14
|
-
elasticsearch
|
|
15
|
-
} = params;
|
|
16
|
-
const options = {
|
|
17
|
-
name: "headless-cms-entries-index",
|
|
18
|
-
body: {
|
|
19
|
-
index_patterns: ["*headless-cms*"],
|
|
20
|
-
settings: {
|
|
21
|
-
analysis: {
|
|
22
|
-
analyzer: {
|
|
23
|
-
lowercase_analyzer: {
|
|
24
|
-
type: "custom",
|
|
25
|
-
filter: ["lowercase", "trim"],
|
|
26
|
-
tokenizer: "keyword"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
mappings: {
|
|
32
|
-
properties: {
|
|
33
|
-
property: {
|
|
34
|
-
type: "text",
|
|
35
|
-
fields: {
|
|
36
|
-
keyword: {
|
|
37
|
-
type: "keyword",
|
|
38
|
-
ignore_above: 256
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
analyzer: "lowercase_analyzer"
|
|
42
|
-
},
|
|
43
|
-
rawValues: {
|
|
44
|
-
type: "object",
|
|
45
|
-
enabled: false
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
await elasticsearch.indices.putTemplate(options);
|
|
54
|
-
} catch (ex) {
|
|
55
|
-
throw new _error.default(ex.message || "Could not create Elasticsearch index template for the Headless CMS.", ex.code || "CMS_ELASTICSEARCH_TEMPLATE_ERROR", {
|
|
56
|
-
error: ex,
|
|
57
|
-
options
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
exports.createElasticsearchTemplate = createElasticsearchTemplate;
|
package/upgrades/index.d.ts
DELETED
package/upgrades/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _index = _interopRequireDefault(require("./v5.0.0/index"));
|
|
11
|
-
|
|
12
|
-
var _index2 = _interopRequireDefault(require("./v5.8.0/index"));
|
|
13
|
-
|
|
14
|
-
var _default = () => [(0, _index.default)(), (0, _index2.default)()];
|
|
15
|
-
|
|
16
|
-
exports.default = _default;
|
package/upgrades/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const paginateBatch: (items: any, perPage: any, execute: any) => Promise<void>;
|
package/upgrades/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.paginateBatch = void 0;
|
|
7
|
-
|
|
8
|
-
const paginateBatch = async (items, perPage, execute) => {
|
|
9
|
-
const pages = Math.ceil(items.length / perPage);
|
|
10
|
-
|
|
11
|
-
for (let i = 0; i < pages; i++) {
|
|
12
|
-
await execute(items.slice(i * perPage, i * perPage + perPage));
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.paginateBatch = paginateBatch;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.cleanDatabaseRecord = void 0;
|
|
9
|
-
|
|
10
|
-
var _lodash = _interopRequireDefault(require("lodash.omit"));
|
|
11
|
-
|
|
12
|
-
const cleanDatabaseRecord = record => {
|
|
13
|
-
return (0, _lodash.default)(record, ["PK", "SK", "TYPE"]);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports.cleanDatabaseRecord = cleanDatabaseRecord;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createOldVersionIndiceName = void 0;
|
|
7
|
-
|
|
8
|
-
const createOldVersionIndiceName = context => {
|
|
9
|
-
return `${context.tenancy.getCurrentTenant().id}-headless-cms`;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.createOldVersionIndiceName = createOldVersionIndiceName;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ModelFieldFinder } from "./fieldFinder";
|
|
2
|
-
import { CmsIndexEntry } from "../../types";
|
|
3
|
-
import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
-
export declare const entryValueFixer: (_: CmsModel, finder: ModelFieldFinder, target: CmsIndexEntry) => CmsEntry;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.entryValueFixer = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _cleanDatabaseRecord = require("./cleanDatabaseRecord");
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
|
-
const convertTimeToNumber = time => {
|
|
19
|
-
if (!time) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const [hours, minutes, seconds = 0] = time.split(":").map(Number);
|
|
24
|
-
return hours * 60 * 60 + minutes * 60 + seconds;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const fixRawValues = (target, finder) => {
|
|
28
|
-
const entry = _objectSpread({}, target);
|
|
29
|
-
|
|
30
|
-
for (const fieldId in entry.rawValues) {
|
|
31
|
-
// if field is ref field then continue, otherwise break
|
|
32
|
-
const field = finder.findById(target.modelId, fieldId);
|
|
33
|
-
|
|
34
|
-
if (field.type !== "ref") {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const existingValue = entry.values[fieldId];
|
|
39
|
-
const rawValue = entry.rawValues[fieldId]; // always remove from rawValue
|
|
40
|
-
|
|
41
|
-
delete entry.rawValues[fieldId]; // if there is something in values - do not switch it
|
|
42
|
-
|
|
43
|
-
if (typeof existingValue !== "undefined" || rawValue === undefined || rawValue === null) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
entry.values[fieldId] = rawValue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return entry;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const fixTime = (field, time) => {
|
|
54
|
-
if (isNaN(time) === false) {
|
|
55
|
-
return parseInt(time);
|
|
56
|
-
} // lets not reinvent the wheel
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
return convertTimeToNumber(time);
|
|
61
|
-
} catch (err) {
|
|
62
|
-
console.log(`fixTime on field "${field.fieldId}" failed`, err);
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const fixDateTime = (field, dateTime) => {
|
|
68
|
-
switch (field.settings.type) {
|
|
69
|
-
case "time":
|
|
70
|
-
return fixTime(field, dateTime);
|
|
71
|
-
|
|
72
|
-
case "date":
|
|
73
|
-
return new Date(dateTime).toISOString();
|
|
74
|
-
|
|
75
|
-
case "dateTimeWithoutTimezone":
|
|
76
|
-
return new Date(dateTime).toISOString();
|
|
77
|
-
|
|
78
|
-
default:
|
|
79
|
-
return dateTime;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const fixNumber = (_, value) => {
|
|
84
|
-
if (value === undefined || value === null) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return parseFloat(value);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const fieldFixMethods = {
|
|
92
|
-
datetime: fixDateTime,
|
|
93
|
-
number: fixNumber
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const fixFieldValues = (target, finder) => {
|
|
97
|
-
const entry = _objectSpread({}, target);
|
|
98
|
-
|
|
99
|
-
for (const fieldId in target.values) {
|
|
100
|
-
const field = finder.findById(target.modelId, fieldId);
|
|
101
|
-
|
|
102
|
-
if (!field) {
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const fixMethod = fieldFixMethods[field.type];
|
|
107
|
-
|
|
108
|
-
if (!fixMethod) {
|
|
109
|
-
continue;
|
|
110
|
-
} else if (target.values[fieldId] === null || target.values[fieldId] === undefined) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
target.values[fieldId] = fixMethod(field, target.values[fieldId]);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return entry;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const entryValueFixer = (_, finder, target) => {
|
|
121
|
-
return (0, _cleanDatabaseRecord.cleanDatabaseRecord)(fixFieldValues(fixRawValues(target, finder), finder));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
exports.entryValueFixer = entryValueFixer;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
|
-
export interface ModelFieldFinder {
|
|
3
|
-
findById: (model: CmsModel | string, fieldId: string) => CmsModelField;
|
|
4
|
-
findByType: (model: CmsModel | string, type: string) => CmsModelField[];
|
|
5
|
-
}
|
|
6
|
-
export declare const createFieldFinder: (models: CmsModel[]) => ModelFieldFinder;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createFieldFinder = void 0;
|
|
7
|
-
|
|
8
|
-
const createFieldFinder = models => {
|
|
9
|
-
const modelsList = {};
|
|
10
|
-
|
|
11
|
-
for (const model of models) {
|
|
12
|
-
const values = {
|
|
13
|
-
id: {},
|
|
14
|
-
type: {}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
for (const field of model.fields) {
|
|
18
|
-
values.id[field.fieldId] = field;
|
|
19
|
-
|
|
20
|
-
if (!values.type[field.type]) {
|
|
21
|
-
values.type[field.type] = [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
values.type[field.type].push(field);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
modelsList[model.modelId] = values;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
findById: (model, fieldId) => {
|
|
32
|
-
const modelId = typeof model === "string" ? model : model.modelId;
|
|
33
|
-
return modelsList[modelId].id[fieldId];
|
|
34
|
-
},
|
|
35
|
-
findByType: (model, type) => {
|
|
36
|
-
const modelId = typeof model === "string" ? model : model.modelId;
|
|
37
|
-
return modelsList[modelId].type[type];
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.createFieldFinder = createFieldFinder;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _cleanDatabaseRecord = require("./cleanDatabaseRecord");
|
|
8
|
-
|
|
9
|
-
Object.keys(_cleanDatabaseRecord).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _cleanDatabaseRecord[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _cleanDatabaseRecord[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _entryValueFixer = require("./entryValueFixer");
|
|
21
|
-
|
|
22
|
-
Object.keys(_entryValueFixer).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _entryValueFixer[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _entryValueFixer[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _fieldFinder = require("./fieldFinder");
|
|
34
|
-
|
|
35
|
-
Object.keys(_fieldFinder).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _fieldFinder[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _fieldFinder[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _createOldVersionIndiceName = require("./createOldVersionIndiceName");
|
|
47
|
-
|
|
48
|
-
Object.keys(_createOldVersionIndiceName).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _createOldVersionIndiceName[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _createOldVersionIndiceName[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|