@webiny/api-headless-cms-ddb-es 6.3.0 → 6.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.js +27 -35
- package/configurations.js.map +1 -1
- package/definitions/entry.js +7 -9
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +7 -9
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +7 -9
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +1 -0
- package/definitions/types.js +0 -3
- package/elasticsearch/createElasticsearchIndex.js +50 -67
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +18 -26
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/exports/api/cms/opensearch.js +2 -4
- package/feature.js +144 -153
- package/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchBodyModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +33 -27
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +0 -3
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/constants.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/feature.js +15 -12
- package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +48 -65
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +5 -2
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +24 -30
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +15 -16
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +15 -18
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +24 -29
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +4 -2
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +95 -146
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +15 -16
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +14 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +39 -0
- package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
- package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -2
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +26 -28
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +2 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +2 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/constants.js +2 -1
- package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/feature.js +9 -8
- package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +18 -15
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +35 -53
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +27 -40
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/index.js +0 -2
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -2
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +10 -9
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/feature.js +6 -5
- package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/index.js +0 -2
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchSortModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +24 -20
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +2 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +2 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/feature.js +9 -8
- package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +14 -16
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +31 -42
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +15 -17
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/index.js +0 -2
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -2
- package/helpers/entryIndexHelpers.d.ts +1 -1
- package/helpers/entryIndexHelpers.js +69 -123
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.js +18 -30
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.js +0 -2
- package/index.js +0 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -1
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -37
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -37
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +32 -46
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js +8 -9
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.js +0 -3
- package/operations/entry/dataLoaders.js +81 -99
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.js +74 -125
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields/createSystemField.js +6 -7
- package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -1
- package/operations/entry/elasticsearch/fields/live.js +45 -40
- package/operations/entry/elasticsearch/fields/live.js.map +1 -1
- package/operations/entry/elasticsearch/fields/location.js +45 -40
- package/operations/entry/elasticsearch/fields/location.js.map +1 -1
- package/operations/entry/elasticsearch/fields/state.js +99 -88
- package/operations/entry/elasticsearch/fields/state.js.map +1 -1
- package/operations/entry/elasticsearch/fields.js +193 -217
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js +85 -114
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +0 -2
- package/operations/entry/elasticsearch/filtering/path.js +24 -33
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +8 -14
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +11 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js +43 -80
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.js +37 -80
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.js +13 -27
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.js +9 -20
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +69 -92
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.js +9 -14
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.js +0 -3
- package/operations/entry/index.js +1313 -1709
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +43 -63
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +4 -9
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.js +21 -26
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +0 -2
- package/operations/entry/transformations/index.js +84 -114
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
- package/operations/entry/transformations/modifyEntryValues.js +12 -17
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.js +13 -16
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +0 -2
- package/operations/entry/transformations/transformEntryToIndex.js +16 -22
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.js +113 -134
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +128 -156
- package/operations/model/index.js.map +1 -1
- package/package.json +24 -24
- package/tasks/createIndexTaskPlugin.js +35 -38
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.js +7 -13
- package/types.js.map +1 -1
- package/values/NoValueContainer.js +8 -10
- package/values/NoValueContainer.js.map +1 -1
- package/definitions/types.js.map +0 -1
- package/exports/api/cms/opensearch.js.map +0 -1
- package/features/CmsEntryOpenSearchBodyModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFieldIndex/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFilter/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +0 -1
- package/features/CmsEntryOpenSearchIndex/index.js.map +0 -1
- package/features/CmsEntryOpenSearchQueryModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchSortModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchValueSearch/index.js.map +0 -1
- package/features/CmsEntryOpenSearchValuesModifier/index.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/index.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
- package/operations/entry/elasticsearch/types.js.map +0 -1
package/configurations.js
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getOpenSearchIndexPrefix, isSharedOpenSearchIndex
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { getOpenSearchIndexPrefix, isSharedOpenSearchIndex } from "@webiny/api-opensearch";
|
|
3
|
+
const configurations = {
|
|
4
|
+
es ({ model }) {
|
|
5
|
+
const { tenant } = model;
|
|
6
|
+
if (!tenant) throw new error('Missing "tenant" parameter when trying to create Elasticsearch index name.', "TENANT_ERROR");
|
|
7
|
+
const sharedIndex = isSharedOpenSearchIndex();
|
|
8
|
+
const index = [
|
|
9
|
+
sharedIndex ? "root" : tenant,
|
|
10
|
+
"headless-cms",
|
|
11
|
+
model.modelId
|
|
12
|
+
].join("-").toLowerCase();
|
|
13
|
+
const prefix = getOpenSearchIndexPrefix();
|
|
14
|
+
if (!prefix) return {
|
|
15
|
+
index
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
index: prefix + index
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
indexSettings: ({ indexConfigs, model })=>{
|
|
22
|
+
const usable = indexConfigs.filter((c)=>c.canUse({
|
|
23
|
+
model
|
|
24
|
+
}));
|
|
25
|
+
if (0 === usable.length) return {};
|
|
26
|
+
return usable[usable.length - 1].body;
|
|
12
27
|
}
|
|
13
|
-
const sharedIndex = isSharedElasticsearchIndex();
|
|
14
|
-
const index = [sharedIndex ? "root" : tenant, "headless-cms", model.modelId].join("-").toLowerCase();
|
|
15
|
-
const prefix = getOpenSearchIndexPrefix();
|
|
16
|
-
if (!prefix) {
|
|
17
|
-
return {
|
|
18
|
-
index
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
index: prefix + index
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
indexSettings: ({
|
|
26
|
-
indexConfigs,
|
|
27
|
-
model
|
|
28
|
-
}) => {
|
|
29
|
-
const usable = indexConfigs.filter(c => c.canUse({
|
|
30
|
-
model
|
|
31
|
-
}));
|
|
32
|
-
if (usable.length === 0) {
|
|
33
|
-
return {};
|
|
34
|
-
}
|
|
35
|
-
return usable[usable.length - 1].body;
|
|
36
|
-
}
|
|
37
28
|
};
|
|
29
|
+
export { configurations };
|
|
38
30
|
|
|
39
31
|
//# sourceMappingURL=configurations.js.map
|
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"configurations.js","sources":["../src/configurations.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport {\n getOpenSearchIndexPrefix,\n isSharedOpenSearchIndex as isSharedElasticsearchIndex\n} from \"@webiny/api-opensearch\";\nimport type { OpenSearchIndexRequestBody } from \"@webiny/api-opensearch/types.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\ninterface ConfigurationsElasticsearch {\n index: string;\n}\n\nexport interface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport interface ConfigurationsIndexSettingsParams {\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: Pick<CmsModel, \"tenant\" | \"modelId\" | \"group\">;\n}\n\nexport interface Configurations {\n es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;\n indexSettings: (\n params: ConfigurationsIndexSettingsParams\n ) => Partial<OpenSearchIndexRequestBody>;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n }\n\n const sharedIndex = isSharedElasticsearchIndex();\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = getOpenSearchIndexPrefix();\n\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n },\n indexSettings: ({ indexConfigs, model }) => {\n const usable = indexConfigs.filter(c => c.canUse({ model }));\n if (usable.length === 0) {\n return {};\n }\n return usable[usable.length - 1].body;\n }\n};\n"],"names":["configurations","model","tenant","WebinyError","sharedIndex","isSharedElasticsearchIndex","index","prefix","getOpenSearchIndexPrefix","indexConfigs","usable","c"],"mappings":";;AA6BO,MAAMA,iBAAiC;IAC1C,IAAG,EAAEC,KAAK,EAAE;QACR,MAAM,EAAEC,MAAM,EAAE,GAAGD;QAEnB,IAAI,CAACC,QACD,MAAM,IAAIC,MACN,8EACA;QAIR,MAAMC,cAAcC;QACpB,MAAMC,QAAQ;YAACF,cAAc,SAASF;YAAQ;YAAgBD,MAAM,OAAO;SAAC,CACvE,IAAI,CAAC,KACL,WAAW;QAEhB,MAAMM,SAASC;QAEf,IAAI,CAACD,QACD,OAAO;YACHD;QACJ;QAEJ,OAAO;YACH,OAAOC,SAASD;QACpB;IACJ;IACA,eAAe,CAAC,EAAEG,YAAY,EAAER,KAAK,EAAE;QACnC,MAAMS,SAASD,aAAa,MAAM,CAACE,CAAAA,IAAKA,EAAE,MAAM,CAAC;gBAAEV;YAAM;QACzD,IAAIS,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,CAAC;QAEZ,OAAOA,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE,CAAC,IAAI;IACzC;AACJ"}
|
package/definitions/entry.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createStandardEntity } from "@webiny/db-dynamodb";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: entityName,
|
|
9
|
-
table: table.table
|
|
10
|
-
});
|
|
2
|
+
const createEntryEntity = (params)=>{
|
|
3
|
+
const { table, entityName } = params;
|
|
4
|
+
return createStandardEntity({
|
|
5
|
+
name: entityName,
|
|
6
|
+
table: table.table
|
|
7
|
+
});
|
|
11
8
|
};
|
|
9
|
+
export { createEntryEntity };
|
|
12
10
|
|
|
13
11
|
//# sourceMappingURL=entry.js.map
|
package/definitions/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"definitions/entry.js","sources":["../../src/definitions/entry.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IEntryEntity, IEntryEntityAttributesData } from \"~/definitions/types.js\";\n\nexport interface CreateEntryEntityParams {\n table: ITable;\n entityName: string;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): IEntryEntity => {\n const { table, entityName } = params;\n return createStandardEntity<IEntryEntityAttributesData>({\n name: entityName,\n table: table.table\n });\n};\n"],"names":["createEntryEntity","params","table","entityName","createStandardEntity"],"mappings":";AAOO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAAiD;QACpD,MAAMD;QACN,OAAOD,MAAM,KAAK;IACtB;AACJ"}
|
package/definitions/group.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createStandardEntity } from "@webiny/db-dynamodb";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
table: table.table,
|
|
9
|
-
name: entityName
|
|
10
|
-
});
|
|
2
|
+
const createGroupEntity = (params)=>{
|
|
3
|
+
const { table, entityName } = params;
|
|
4
|
+
return createStandardEntity({
|
|
5
|
+
table: table.table,
|
|
6
|
+
name: entityName
|
|
7
|
+
});
|
|
11
8
|
};
|
|
9
|
+
export { createGroupEntity };
|
|
12
10
|
|
|
13
11
|
//# sourceMappingURL=group.js.map
|
package/definitions/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"definitions/group.js","sources":["../../src/definitions/group.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IGroupEntity } from \"~/definitions/types.js\";\nimport type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\nexport const createGroupEntity = (params: Params): IGroupEntity => {\n const { table, entityName } = params;\n return createStandardEntity<CmsGroup>({\n table: table.table,\n name: entityName\n });\n};\n"],"names":["createGroupEntity","params","table","entityName","createStandardEntity"],"mappings":";AAQO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAA+B;QAClC,OAAOF,MAAM,KAAK;QAClB,MAAMC;IACV;AACJ"}
|
package/definitions/model.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createStandardEntity } from "@webiny/db-dynamodb";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
table: table.table,
|
|
9
|
-
name: entityName
|
|
10
|
-
});
|
|
2
|
+
const createModelEntity = (params)=>{
|
|
3
|
+
const { table, entityName } = params;
|
|
4
|
+
return createStandardEntity({
|
|
5
|
+
table: table.table,
|
|
6
|
+
name: entityName
|
|
7
|
+
});
|
|
11
8
|
};
|
|
9
|
+
export { createModelEntity };
|
|
12
10
|
|
|
13
11
|
//# sourceMappingURL=model.js.map
|
package/definitions/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"definitions/model.js","sources":["../../src/definitions/model.ts"],"sourcesContent":["import { createStandardEntity, type ITable } from \"@webiny/db-dynamodb\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\nimport type { StorageCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n table: ITable;\n entityName: string;\n}\n\nexport const createModelEntity = (params: Params): IModelEntity => {\n const { table, entityName } = params;\n return createStandardEntity<StorageCmsModel>({\n table: table.table,\n name: entityName\n });\n};\n"],"names":["createModelEntity","params","table","entityName","createStandardEntity"],"mappings":";AASO,MAAMA,oBAAoB,CAACC;IAC9B,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGF;IAC9B,OAAOG,qBAAsC;QACzC,OAAOF,MAAM,KAAK;QAClB,MAAMC;IACV;AACJ"}
|
package/definitions/types.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface IEntryEntityAttributesData {
|
|
|
53
53
|
meta?: GenericRecord;
|
|
54
54
|
system?: ICmsEntrySystem;
|
|
55
55
|
live: ICmsEntryLive | null;
|
|
56
|
+
revisionDescription: string | undefined;
|
|
56
57
|
}
|
|
57
58
|
export type IEntryEntityAttributes = IStandardEntityAttributes<IEntryEntityAttributesData>;
|
|
58
59
|
export type IModelEntity = IEntity<IStandardEntityAttributes<StorageCmsModel>>;
|
package/definitions/types.js
CHANGED
|
@@ -1,74 +1,57 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { configurations } from "../configurations.js";
|
|
3
|
-
const getLastUsable = params
|
|
4
|
-
|
|
5
|
-
configs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (usable.length === 0) {
|
|
9
|
-
throw new WebinyError("Could not find a single usable CmsEntryOpenSearchIndex.", "OPENSEARCH_INDEX_TEMPLATE_ERROR");
|
|
10
|
-
}
|
|
11
|
-
return usable[usable.length - 1];
|
|
3
|
+
const getLastUsable = (params)=>{
|
|
4
|
+
const { configs } = params;
|
|
5
|
+
const usable = configs.filter((c)=>c.canUse(params));
|
|
6
|
+
if (0 === usable.length) throw new error("Could not find a single usable CmsEntryOpenSearchIndex.", "OPENSEARCH_INDEX_TEMPLATE_ERROR");
|
|
7
|
+
return usable[usable.length - 1];
|
|
12
8
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
model
|
|
18
|
-
} = params;
|
|
19
|
-
const {
|
|
20
|
-
index
|
|
21
|
-
} = configurations.es({
|
|
22
|
-
model
|
|
23
|
-
});
|
|
24
|
-
const config = getLastUsable({
|
|
25
|
-
configs: indexConfigs,
|
|
26
|
-
model
|
|
27
|
-
});
|
|
28
|
-
if (!config) {
|
|
29
|
-
/**
|
|
30
|
-
* This can happen only while development as we have a base index setting that is always usable.
|
|
31
|
-
*/
|
|
32
|
-
throw new Error(`Could not find a usable CmsEntryOpenSearchIndex for the CMS model "${model.name}".`);
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
const response = await client.indices.exists({
|
|
36
|
-
index,
|
|
37
|
-
ignore_unavailable: false,
|
|
38
|
-
allow_no_indices: true,
|
|
39
|
-
include_defaults: true,
|
|
40
|
-
flat_settings: false,
|
|
41
|
-
local: false
|
|
9
|
+
const createElasticsearchIndex = async (params)=>{
|
|
10
|
+
const { client, indexConfigs, model } = params;
|
|
11
|
+
const { index } = configurations.es({
|
|
12
|
+
model
|
|
42
13
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
console.error(`Could not determine if the index "${index}" exists.`);
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
await client.indices.create({
|
|
52
|
-
index,
|
|
53
|
-
body: {
|
|
54
|
-
...config.body
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
} catch (ex) {
|
|
58
|
-
console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
|
|
59
|
-
console.error(ex);
|
|
60
|
-
throw new WebinyError(ex.message || "Could not create OpenSearch index for the CMS entry.", ex.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
|
|
61
|
-
error: {
|
|
62
|
-
...ex,
|
|
63
|
-
message: ex.message,
|
|
64
|
-
code: ex.code,
|
|
65
|
-
data: ex.data
|
|
66
|
-
},
|
|
67
|
-
tenant: model.tenant,
|
|
68
|
-
index,
|
|
69
|
-
body: config.body
|
|
14
|
+
const config = getLastUsable({
|
|
15
|
+
configs: indexConfigs,
|
|
16
|
+
model
|
|
70
17
|
});
|
|
71
|
-
|
|
18
|
+
if (!config) throw new Error(`Could not find a usable CmsEntryOpenSearchIndex for the CMS model "${model.name}".`);
|
|
19
|
+
try {
|
|
20
|
+
const response = await client.indices.exists({
|
|
21
|
+
index,
|
|
22
|
+
ignore_unavailable: false,
|
|
23
|
+
allow_no_indices: true,
|
|
24
|
+
include_defaults: true,
|
|
25
|
+
flat_settings: false,
|
|
26
|
+
local: false
|
|
27
|
+
});
|
|
28
|
+
if (response.body) return void console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
|
|
29
|
+
} catch {
|
|
30
|
+
console.error(`Could not determine if the index "${index}" exists.`);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await client.indices.create({
|
|
34
|
+
index,
|
|
35
|
+
body: {
|
|
36
|
+
...config.body
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (ex) {
|
|
40
|
+
console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
|
|
41
|
+
console.error(ex);
|
|
42
|
+
throw new error(ex.message || "Could not create OpenSearch index for the CMS entry.", ex.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
|
|
43
|
+
error: {
|
|
44
|
+
...ex,
|
|
45
|
+
message: ex.message,
|
|
46
|
+
code: ex.code,
|
|
47
|
+
data: ex.data
|
|
48
|
+
},
|
|
49
|
+
tenant: model.tenant,
|
|
50
|
+
index,
|
|
51
|
+
body: config.body
|
|
52
|
+
});
|
|
53
|
+
}
|
|
72
54
|
};
|
|
55
|
+
export { createElasticsearchIndex };
|
|
73
56
|
|
|
74
57
|
//# sourceMappingURL=createElasticsearchIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"elasticsearch/createElasticsearchIndex.js","sources":["../../src/elasticsearch/createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport WebinyError from \"@webiny/error\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsEntryOpenSearchIndex } from \"~/features/CmsEntryOpenSearchIndex/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n indexConfigs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\ninterface IGetLastUsableParams {\n configs: CmsEntryOpenSearchIndex.Interface[];\n model: CmsModel;\n}\n\nconst getLastUsable = (params: IGetLastUsableParams): CmsEntryOpenSearchIndex.Interface => {\n const { configs } = params;\n const usable = configs.filter(c => c.canUse(params));\n if (usable.length === 0) {\n throw new WebinyError(\n \"Could not find a single usable CmsEntryOpenSearchIndex.\",\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\"\n );\n }\n return usable[usable.length - 1];\n};\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, indexConfigs, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const config = getLastUsable({\n configs: indexConfigs,\n model\n });\n if (!config) {\n /**\n * This can happen only while development as we have a base index setting that is always usable.\n */\n throw new Error(\n `Could not find a usable CmsEntryOpenSearchIndex for the CMS model \"${model.name}\".`\n );\n }\n\n try {\n const response = await client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n if (response.body) {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n return;\n }\n } catch {\n console.error(`Could not determine if the index \"${index}\" exists.`);\n }\n\n try {\n await client.indices.create({\n index,\n body: {\n ...config.body\n }\n });\n } catch (ex) {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n throw new WebinyError(\n ex.message || \"Could not create OpenSearch index for the CMS entry.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: {\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n },\n tenant: model.tenant,\n index,\n body: config.body\n }\n );\n }\n};\n"],"names":["getLastUsable","params","configs","usable","c","WebinyError","createElasticsearchIndex","client","indexConfigs","model","index","configurations","config","Error","response","console","ex"],"mappings":";;AAiBA,MAAMA,gBAAgB,CAACC;IACnB,MAAM,EAAEC,OAAO,EAAE,GAAGD;IACpB,MAAME,SAASD,QAAQ,MAAM,CAACE,CAAAA,IAAKA,EAAE,MAAM,CAACH;IAC5C,IAAIE,AAAkB,MAAlBA,OAAO,MAAM,EACb,MAAM,IAAIE,MACN,2DACA;IAGR,OAAOF,MAAM,CAACA,OAAO,MAAM,GAAG,EAAE;AACpC;AAEO,MAAMG,2BAA2B,OAAOL;IAC3C,MAAM,EAAEM,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGR;IAExC,MAAM,EAAES,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;QAChCF;IACJ;IAEA,MAAMG,SAASZ,cAAc;QACzB,SAASQ;QACTC;IACJ;IACA,IAAI,CAACG,QAID,MAAM,IAAIC,MACN,CAAC,mEAAmE,EAAEJ,MAAM,IAAI,CAAC,EAAE,CAAC;IAI5F,IAAI;QACA,MAAMK,WAAW,MAAMP,OAAO,OAAO,CAAC,MAAM,CAAC;YACzCG;YACA,oBAAoB;YACpB,kBAAkB;YAClB,kBAAkB;YAClB,eAAe;YACf,OAAO;QACX;QACA,IAAII,SAAS,IAAI,EAAE,YACfC,QAAQ,GAAG,CACP,CAAC,qBAAqB,EAAEL,MAAM,qBAAqB,EAAED,MAAM,IAAI,CAAC,iBAAiB,CAAC;IAI9F,EAAE,OAAM;QACJM,QAAQ,KAAK,CAAC,CAAC,kCAAkC,EAAEL,MAAM,SAAS,CAAC;IACvE;IAEA,IAAI;QACA,MAAMH,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBG;YACA,MAAM;gBACF,GAAGE,OAAO,IAAI;YAClB;QACJ;IACJ,EAAE,OAAOI,IAAI;QACTD,QAAQ,KAAK,CACT,CAAC,sCAAsC,EAAEL,MAAM,qBAAqB,EAAED,MAAM,IAAI,CAAC,EAAE,CAAC;QAExFM,QAAQ,KAAK,CAACC;QACd,MAAM,IAAIX,MACNW,GAAG,OAAO,IAAI,wDACdA,GAAG,IAAI,IAAI,iCACX;YACI,OAAO;gBACH,GAAGA,EAAE;gBACL,SAASA,GAAG,OAAO;gBACnB,MAAMA,GAAG,IAAI;gBACb,MAAMA,GAAG,IAAI;YACjB;YACA,QAAQP,MAAM,MAAM;YACpBC;YACA,MAAME,OAAO,IAAI;QACrB;IAER;AACJ"}
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
import { configurations } from "../configurations.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = params;
|
|
7
|
-
const {
|
|
8
|
-
index
|
|
9
|
-
} = configurations.es({
|
|
10
|
-
model
|
|
11
|
-
});
|
|
12
|
-
const {
|
|
13
|
-
body: exists
|
|
14
|
-
} = await client.indices.exists({
|
|
15
|
-
index
|
|
16
|
-
});
|
|
17
|
-
if (!exists) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
await client.indices.delete({
|
|
22
|
-
index,
|
|
23
|
-
ignore_unavailable: true
|
|
2
|
+
const deleteElasticsearchIndex = async (params)=>{
|
|
3
|
+
const { client, model } = params;
|
|
4
|
+
const { index } = configurations.es({
|
|
5
|
+
model
|
|
24
6
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
const { body: exists } = await client.indices.exists({
|
|
8
|
+
index
|
|
9
|
+
});
|
|
10
|
+
if (!exists) return;
|
|
11
|
+
try {
|
|
12
|
+
await client.indices.delete({
|
|
13
|
+
index,
|
|
14
|
+
ignore_unavailable: true
|
|
15
|
+
});
|
|
16
|
+
} catch (ex) {
|
|
17
|
+
console.log(`Could not delete Elasticsearch index "${index}". Please do it manually.`);
|
|
18
|
+
console.log(ex.message);
|
|
19
|
+
}
|
|
29
20
|
};
|
|
21
|
+
export { deleteElasticsearchIndex };
|
|
30
22
|
|
|
31
23
|
//# sourceMappingURL=deleteElasticsearchIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"elasticsearch/deleteElasticsearchIndex.js","sources":["../../src/elasticsearch/deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"names":["deleteElasticsearchIndex","params","client","model","index","configurations","exists","ex","console"],"mappings":";AASO,MAAMA,2BAA2B,OACpCC;IAEA,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGF;IAE1B,MAAM,EAAEG,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;QAChCF;IACJ;IACA,MAAM,EAAE,MAAMG,MAAM,EAAE,GAAG,MAAMJ,OAAO,OAAO,CAAC,MAAM,CAAC;QACjDE;IACJ;IACA,IAAI,CAACE,QACD;IAGJ,IAAI;QACA,MAAMJ,OAAO,OAAO,CAAC,MAAM,CAAC;YACxBE;YACA,oBAAoB;QACxB;IACJ,EAAE,OAAOG,IAAI;QACTC,QAAQ,GAAG,CAAC,CAAC,sCAAsC,EAAEJ,MAAM,yBAAyB,CAAC;QACrFI,QAAQ,GAAG,CAACD,GAAG,OAAO;IAC1B;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { CmsEntryOpenSearchFieldIndex, CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
|
|
2
|
+
export { CmsEntryOpenSearchFilter, CmsEntryOpenSearchFilterRegistry } from "../../../features/CmsEntryOpenSearchFilter/index.js";
|
|
3
3
|
export { CmsEntryOpenSearchBodyModifier } from "../../../features/CmsEntryOpenSearchBodyModifier/index.js";
|
|
4
4
|
export { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSearchSortModifier/index.js";
|
|
5
5
|
export { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
|
|
@@ -7,5 +7,3 @@ export { CmsEntryOpenSearchValueSearch, CmsEntryOpenSearchValueSearchRegistry }
|
|
|
7
7
|
export { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
|
|
8
8
|
export { CmsEntryOpenSearchIndex } from "../../../features/CmsEntryOpenSearchIndex/index.js";
|
|
9
9
|
export { CmsEntryOpenSearchValuesModifier } from "../../../features/CmsEntryOpenSearchValuesModifier/index.js";
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=opensearch.js.map
|