@webiny/api-headless-cms-ddb-es 6.0.0 → 6.1.0-beta.0
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 +2 -2
- package/configurations.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/createElasticsearchIndex.js +1 -1
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +0 -6
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indices/base.js +1 -1
- package/elasticsearch/indices/base.js.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -5
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +5 -2
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +5 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +5 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +5 -1
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -0
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.js +3 -1
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +1 -1
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +3 -3
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/exec.js +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +3 -3
- package/operations/entry/elasticsearch/initialQuery.js +1 -1
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/operator.js +2 -2
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +2 -2
- package/operations/entry/elasticsearch/sort.js +4 -4
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +4 -4
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +2 -2
- package/operations/entry/index.js +1 -1
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/transformations/index.js +1 -1
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/model/index.d.ts +1 -1
- package/operations/model/index.js.map +1 -1
- package/package.json +22 -23
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +2 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
package/configurations.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
2
|
import type { CmsContext } from "./types.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { OpenSearchIndexRequestBody } from "@webiny/api-opensearch/types.js";
|
|
4
4
|
interface ConfigurationsElasticsearch {
|
|
5
5
|
index: string;
|
|
6
6
|
}
|
|
@@ -12,7 +12,7 @@ export interface ConfigurationsIndexSettingsParams {
|
|
|
12
12
|
}
|
|
13
13
|
export interface Configurations {
|
|
14
14
|
es: (params: CmsElasticsearchParams) => ConfigurationsElasticsearch;
|
|
15
|
-
indexSettings: (params: ConfigurationsIndexSettingsParams) => Partial<
|
|
15
|
+
indexSettings: (params: ConfigurationsIndexSettingsParams) => Partial<OpenSearchIndexRequestBody>;
|
|
16
16
|
}
|
|
17
17
|
export declare const configurations: Configurations;
|
|
18
18
|
export {};
|
package/configurations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import WebinyError from "@webiny/error";
|
|
2
|
-
import {
|
|
2
|
+
import { getOpenSearchIndexPrefix, getLastAddedIndexPlugin, isSharedOpenSearchIndex as isSharedElasticsearchIndex } from "@webiny/api-opensearch";
|
|
3
3
|
import { CmsEntryElasticsearchIndexPlugin } from "./plugins/index.js";
|
|
4
4
|
export const configurations = {
|
|
5
5
|
es({
|
|
@@ -13,7 +13,7 @@ export const configurations = {
|
|
|
13
13
|
}
|
|
14
14
|
const sharedIndex = isSharedElasticsearchIndex();
|
|
15
15
|
const index = [sharedIndex ? "root" : tenant, "headless-cms", model.modelId].join("-").toLowerCase();
|
|
16
|
-
const prefix =
|
|
16
|
+
const prefix = getOpenSearchIndexPrefix();
|
|
17
17
|
if (!prefix) {
|
|
18
18
|
return {
|
|
19
19
|
index
|
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","
|
|
1
|
+
{"version":3,"names":["WebinyError","getOpenSearchIndexPrefix","getLastAddedIndexPlugin","isSharedOpenSearchIndex","isSharedElasticsearchIndex","CmsEntryElasticsearchIndexPlugin","configurations","es","model","tenant","sharedIndex","index","modelId","join","toLowerCase","prefix","indexSettings","context","plugin","container","plugins","type","body"],"sources":["configurations.ts"],"sourcesContent":["import type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsContext } from \"~/types.js\";\nimport {\n getOpenSearchIndexPrefix as getOpenSearchIndexPrefix,\n getLastAddedIndexPlugin,\n isSharedOpenSearchIndex as isSharedElasticsearchIndex\n} from \"@webiny/api-opensearch\";\nimport type { OpenSearchIndexRequestBody } from \"@webiny/api-opensearch/types.js\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/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 context: CmsContext;\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: ({ context }) => {\n const plugin = getLastAddedIndexPlugin<CmsEntryElasticsearchIndexPlugin>({\n container: context.plugins,\n type: CmsEntryElasticsearchIndexPlugin.type\n });\n\n return plugin ? plugin.body : {};\n }\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SACIC,wBAAoD,EACpDC,uBAAuB,EACvBC,uBAAuB,IAAIC,0BAA0B,QAClD,wBAAwB;AAE/B,SAASC,gCAAgC;AAqBzC,OAAO,MAAMC,cAA8B,GAAG;EAC1CC,EAAEA,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC;IAAO,CAAC,GAAGD,KAAK;IAExB,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIT,WAAW,CACjB,4EAA4E,EAC5E,cACJ,CAAC;IACL;IAEA,MAAMU,WAAW,GAAGN,0BAA0B,CAAC,CAAC;IAChD,MAAMO,KAAK,GAAG,CAACD,WAAW,GAAG,MAAM,GAAGD,MAAM,EAAE,cAAc,EAAED,KAAK,CAACI,OAAO,CAAC,CACvEC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,CAAC,CAAC;IAElB,MAAMC,MAAM,GAAGd,wBAAwB,CAAC,CAAC;IAEzC,IAAI,CAACc,MAAM,EAAE;MACT,OAAO;QACHJ;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEI,MAAM,GAAGJ;IACpB,CAAC;EACL,CAAC;EACDK,aAAa,EAAEA,CAAC;IAAEC;EAAQ,CAAC,KAAK;IAC5B,MAAMC,MAAM,GAAGhB,uBAAuB,CAAmC;MACrEiB,SAAS,EAAEF,OAAO,CAACG,OAAO;MAC1BC,IAAI,EAAEhB,gCAAgC,CAACgB;IAC3C,CAAC,CAAC;IAEF,OAAOH,MAAM,GAAGA,MAAM,CAACI,IAAI,GAAG,CAAC,CAAC;EACpC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Client } from "@
|
|
1
|
+
import type { Client } from "@webiny/api-opensearch";
|
|
2
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
3
|
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
export interface CreateElasticsearchIndexParams {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmsEntryElasticsearchIndexPlugin } from "../plugins/CmsEntryElasticsearchIndexPlugin.js";
|
|
2
|
-
import { createIndex } from "@webiny/api-
|
|
2
|
+
import { createIndex } from "@webiny/api-opensearch";
|
|
3
3
|
import { configurations } from "../configurations.js";
|
|
4
4
|
export const createElasticsearchIndex = async params => {
|
|
5
5
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsEntryElasticsearchIndexPlugin","createIndex","configurations","createElasticsearchIndex","params","client","plugins","model","index","es","type","tenant","onExists","console","log","name","onError","ex","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchIndexPlugin","createIndex","configurations","createElasticsearchIndex","params","client","plugins","model","index","es","type","tenant","onExists","console","log","name","onError","ex","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@webiny/api-opensearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin.js\";\nimport { createIndex } from \"@webiny/api-opensearch\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":"AAEA,SAASA,gCAAgC;AACzC,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,cAAc;AASvB,OAAO,MAAMC,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGN,cAAc,CAACO,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EAEF,MAAMN,WAAW,CAAC;IACdI,MAAM;IACNG,KAAK;IACLE,IAAI,EAAEV,gCAAgC,CAACU,IAAI;IAC3CC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBL,OAAO;IACPM,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACP,wBAAwBN,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,mBACnE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACT,yCAAyCV,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,IACpF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["configurations","deleteElasticsearchIndex","params","client","model","index","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@
|
|
1
|
+
{"version":3,"names":["configurations","deleteElasticsearchIndex","params","client","model","index","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"sources":["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"],"mappings":"AAEA,SAASA,cAAc;AAOvB,OAAO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGL,cAAc,CAACM,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EACF,MAAM;IAAEG,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAML,MAAM,CAACM,OAAO,CAACD,MAAM,CAAC;IACjDH;EACJ,CAAC,CAAC;EACF,IAAI,CAACG,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAML,MAAM,CAACM,OAAO,CAACC,MAAM,CAAC;MACxBL,KAAK;MACLM,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,yCAAyCT,KAAK,2BAA2B,CAAC;IACtFQ,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC","ignoreList":[]}
|
|
@@ -9,12 +9,6 @@ const convertNumberToTime = value => {
|
|
|
9
9
|
if (value === undefined || value === null) {
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
-
// TODO remove when v5 goes out
|
|
13
|
-
// this is a fix for pre beta.5
|
|
14
|
-
if (String(value).match(/^([0-9]{2}):([0-9]{2})/) !== null) {
|
|
15
|
-
return String(value);
|
|
16
|
-
}
|
|
17
|
-
//
|
|
18
12
|
const hours = Math.floor(value / 60 / 60);
|
|
19
13
|
const minutes = Math.floor((value - hours * 60 * 60) / 60);
|
|
20
14
|
const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","
|
|
1
|
+
{"version":3,"names":["convertTimeToNumber","time","hours","minutes","seconds","split","map","Number","convertNumberToTime","value","undefined","Math","floor","v","String","padStart","join","convertValueFromIndex","field","type","settings","dateValue","Date","toISOString","slice","convertValueToIndex","name","fieldType","unmappedType","toIndex","Array","isArray","fromIndex"],"sources":["dateTimeIndexing.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsModelFieldToElasticsearchPlugin } from \"~/types.js\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n\n const hours = Math.floor(value / 60 / 60);\n\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-datetime\",\n fieldType: \"datetime\",\n unmappedType: () => {\n return \"date\";\n },\n toIndex({ field, value }) {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n const dateValue = convertValueToIndex(value, field as CmsModelDateTimeField);\n return {\n value: dateValue\n };\n },\n fromIndex({ field, value }) {\n if (Array.isArray(value)) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n});\n"],"mappings":"AAGA,MAAMA,mBAAmB,GAAIC,IAAa,IAAoB;EAC1D,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf;EACA,MAAM,CAACC,KAAK,EAAEC,OAAO,EAAEC,OAAO,GAAG,CAAC,CAAC,GAAGH,IAAI,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EACjE,OAAOL,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,GAAGC,OAAO;AACnD,CAAC;AAED,MAAMI,mBAAmB,GAAIC,KAAc,IAAoB;EAC3D,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,IAAI;EACf;EAEA,MAAMP,KAAK,GAAGS,IAAI,CAACC,KAAK,CAACH,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC;EAEzC,MAAMN,OAAO,GAAGQ,IAAI,CAACC,KAAK,CAAC,CAACH,KAAK,GAAGP,KAAK,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;EAE1D,MAAME,OAAO,GAAGO,IAAI,CAACC,KAAK,CAACH,KAAK,GAAGP,KAAK,GAAG,EAAE,GAAG,EAAE,GAAGC,OAAO,GAAG,EAAE,CAAC;EAElE,OAAO,CAACD,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC,CAACE,GAAG,CAACO,CAAC,IAAIC,MAAM,CAACD,CAAC,CAAC,CAACE,QAAQ,CAAC,C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QACHA,KAAK,EAAEA,KAAK,CAACH,GAAG,CAAEO,CAAS,IAAK;UAC5B,OAAOY,mBAAmB,CAACZ,CAAC,EAAEK,KAA8B,CAAC;QACjE,CAAC;MACL,CAAC;IACL;IACA,MAAMG,SAAS,GAAGI,mBAAmB,CAAChB,KAAK,EAAES,KAA8B,CAAC;IAC5E,OAAO;MACHT,KAAK,EAAEY;IACX,CAAC;EACL,CAAC;EACDW,SAASA,CAAC;IAAEd,KAAK;IAAET;EAAM,CAAC,EAAE;IACxB,IAAIqB,KAAK,CAACC,OAAO,CAACtB,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK,CAACH,GAAG,CAAEO,CAAS,IAAK;QAC5B,OAAOI,qBAAqB,CAACJ,CAAC,EAAEK,KAA8B,CAAC;MACnE,CAAC,CAAC;IACN;IACA,OAAOD,qBAAqB,CAACR,KAAK,EAAES,KAA8B,CAAC;EACvE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBaseConfiguration } from "@webiny/api-
|
|
1
|
+
import { getBaseConfiguration } from "@webiny/api-opensearch";
|
|
2
2
|
import { CmsEntryElasticsearchIndexPlugin } from "../../plugins/CmsEntryElasticsearchIndexPlugin.js";
|
|
3
3
|
export const base = new CmsEntryElasticsearchIndexPlugin({
|
|
4
4
|
body: getBaseConfiguration()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getBaseConfiguration","CmsEntryElasticsearchIndexPlugin","base","body"],"sources":["base.ts"],"sourcesContent":["import { getBaseConfiguration } from \"@webiny/api-
|
|
1
|
+
{"version":3,"names":["getBaseConfiguration","CmsEntryElasticsearchIndexPlugin","base","body"],"sources":["base.ts"],"sourcesContent":["import { getBaseConfiguration } from \"@webiny/api-opensearch\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin.js\";\n\nexport const base = new CmsEntryElasticsearchIndexPlugin({\n body: getBaseConfiguration()\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,gCAAgC;AAEzC,OAAO,MAAMC,IAAI,GAAG,IAAID,gCAAgC,CAAC;EACrDE,IAAI,EAAEH,oBAAoB,CAAC;AAC/B,CAAC,CAAC","ignoreList":[]}
|
package/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createEntryEntity } from "./definitions/entry.js";
|
|
|
10
10
|
import { createElasticsearchIndex } from "./elasticsearch/createElasticsearchIndex.js";
|
|
11
11
|
import { PluginsContainer } from "@webiny/plugins";
|
|
12
12
|
import { createGroupsStorageOperations } from "./operations/group/index.js";
|
|
13
|
-
import {
|
|
13
|
+
import { createOpenSearchEntity, createOpenSearchTable, OpenSearchQueryBuilderOperatorPlugin } from "@webiny/api-opensearch";
|
|
14
14
|
import { elasticsearchIndexPlugins } from "./elasticsearch/indices/index.js";
|
|
15
15
|
import { deleteElasticsearchIndex } from "./elasticsearch/deleteElasticsearchIndex.js";
|
|
16
16
|
import { CmsElasticsearchModelFieldPlugin, CmsEntryElasticsearchBodyModifierPlugin, CmsEntryElasticsearchFullTextSearchPlugin, CmsEntryElasticsearchIndexPlugin, CmsEntryElasticsearchQueryBuilderValueSearchPlugin, CmsEntryElasticsearchQueryModifierPlugin, CmsEntryElasticsearchSortModifierPlugin, CmsEntryElasticsearchValuesModifier } from "./plugins/index.js";
|
|
@@ -36,7 +36,7 @@ export const createStorageOperations = params => {
|
|
|
36
36
|
name: table || process.env.DB_TABLE,
|
|
37
37
|
documentClient
|
|
38
38
|
});
|
|
39
|
-
const tableElasticsearchInstance =
|
|
39
|
+
const tableElasticsearchInstance = createOpenSearchTable({
|
|
40
40
|
name: esTable,
|
|
41
41
|
documentClient
|
|
42
42
|
});
|
|
@@ -53,7 +53,7 @@ export const createStorageOperations = params => {
|
|
|
53
53
|
entityName: ENTITIES.ENTRIES,
|
|
54
54
|
table: tableInstance
|
|
55
55
|
}),
|
|
56
|
-
entriesEs:
|
|
56
|
+
entriesEs: createOpenSearchEntity({
|
|
57
57
|
entityName: ENTITIES.ENTRIES_ES,
|
|
58
58
|
table: tableElasticsearchInstance
|
|
59
59
|
})
|
|
@@ -106,8 +106,8 @@ export const createStorageOperations = params => {
|
|
|
106
106
|
/**
|
|
107
107
|
* Attach the elasticsearch into context if it is not already attached.
|
|
108
108
|
*/
|
|
109
|
-
if (!context.
|
|
110
|
-
context.
|
|
109
|
+
if (!context.opensearch) {
|
|
110
|
+
context.opensearch = elasticsearch;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
@@ -123,7 +123,7 @@ export const createStorageOperations = params => {
|
|
|
123
123
|
* We need to fetch all the plugin types in the list from the main container.
|
|
124
124
|
* This way we do not need to register plugins in the storage plugins contains.
|
|
125
125
|
*/
|
|
126
|
-
const types = [
|
|
126
|
+
const types = [OpenSearchQueryBuilderOperatorPlugin.type,
|
|
127
127
|
// Headless CMS
|
|
128
128
|
"cms-model-field-to-graphql", CmsEntryFilterPlugin.type, CmsEntryElasticsearchBodyModifierPlugin.type, CmsEntryElasticsearchFullTextSearchPlugin.type, CmsEntryElasticsearchIndexPlugin.type, CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, CmsEntryElasticsearchQueryModifierPlugin.type, CmsEntryElasticsearchSortModifierPlugin.type, CmsElasticsearchModelFieldPlugin.type, StorageOperationsCmsModelPlugin.type, StorageTransformPlugin.type, CmsEntryElasticsearchValuesModifier.type, CompressorPlugin.type];
|
|
129
129
|
for (const type of types) {
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["dynamoDbValueFilters","elasticsearchPlugins","dynamoDbPlugins","createModelsStorageOperations","createEntriesStorageOperations","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","createElasticsearchIndex","PluginsContainer","createGroupsStorageOperations","createElasticsearchEntity","createElasticsearchTable","ElasticsearchQueryBuilderOperatorPlugin","elasticsearchIndexPlugins","deleteElasticsearchIndex","CmsElasticsearchModelFieldPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchValuesModifier","createFilterPlugins","CmsEntryFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","createCreateIndexTask","CompressorPlugin","ModelAfterCreateEventHandler","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","createTable","createStorageOperations","params","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","name","process","env","DB_TABLE","tableElasticsearchInstance","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entriesEs","ENTRIES_ES","entity","esEntity","beforeInit","context","db","registry","register","item","app","tags","types","type","mergeByType","dataLoaders","clearAll","init","container","registerFactory","handle","event","model","payload","client","getEntities","getTable","getEsTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport elasticsearchPlugins from \"./elasticsearch/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport type { StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport {\n createElasticsearchEntity,\n createElasticsearchTable,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices/index.js\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins/index.js\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins/index.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createCreateIndexTask } from \"~/tasks/createIndexTaskPlugin.js\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { createTable } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, esTable, documentClient, elasticsearch, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n\n /**\n * This registers the task implementation\n */\n createCreateIndexTask(context);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CmsEntryElasticsearchValuesModifier.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * TODO @pavel\n * Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.\n */\n context.container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n }\n }));\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,oBAAoB;AAC3B,OAAOC,eAAe;AACtB,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AAEvC,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,6BAA6B;AACtC,SACIC,yBAAyB,EACzBC,wBAAwB,EACxBC,uCAAuC,QACpC,2BAA2B;AAClC,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;AACjC,SACIC,gCAAgC,EAChCC,uCAAuC,EACvCC,yCAAyC,EACzCC,gCAAgC,EAChCC,kDAAkD,EAClDC,wCAAwC,EACxCC,uCAAuC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AAwB,CAAC;YAC3BwE,MAAM,EAAEzC,aAAa;YACrBuC,KAAK;YACLtC;UACJ,CAAC,CAAC;QACN;MACJ,CAAC,CAAC,CAAC;MAEHqB,OAAO,CAACa,SAAS,CAACC,eAAe,CAAC3C,4BAA4B,EAAE,OAAO;QACnE,MAAM4C,MAAMA,CAACC,KAAK,EAAE;UAChB,MAAM;YAAEC;UAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;UAC/B,MAAMhE,wBAAwB,CAAC;YAC3BiE,MAAM,EAAEzC,aAAa;YACrBuC;UACJ,CAAC,CAAC;QACN;MACJ,CAAC,CAAC,CAAC;IACP,CAAC;IACDG,WAAW,EAAEA,CAAA,KAAMjC,QAAQ;IAC3BkC,QAAQ,EAAEA,CAAA,KAAMxC,aAAa;IAC7ByC,UAAU,EAAEA,CAAA,KAAMpC,0BAA0B;IAC5CE,MAAM,EAAEvC,6BAA6B,CAAC;MAClCgD,MAAM,EAAEV,QAAQ,CAACC,MAAM;MACvBT;IACJ,CAAC,CAAC;IACFY,MAAM,EAAElD,6BAA6B,CAAC;MAClCwD,MAAM,EAAEV,QAAQ,CAACI,MAAM;MACvBb;IACJ,CAAC,CAAC;IACFe;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["dynamoDbValueFilters","elasticsearchPlugins","dynamoDbPlugins","createModelsStorageOperations","createEntriesStorageOperations","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","createElasticsearchIndex","PluginsContainer","createGroupsStorageOperations","createOpenSearchEntity","createOpenSearchTable","OpenSearchQueryBuilderOperatorPlugin","elasticsearchIndexPlugins","deleteElasticsearchIndex","CmsElasticsearchModelFieldPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchValuesModifier","createFilterPlugins","CmsEntryFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","createCreateIndexTask","CompressorPlugin","ModelAfterCreateEventHandler","ModelAfterCreateFromEventHandler","ModelAfterDeleteEventHandler","createTable","createStorageOperations","params","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","name","process","env","DB_TABLE","tableElasticsearchInstance","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entriesEs","ENTRIES_ES","entity","esEntity","beforeInit","context","db","registry","register","item","app","tags","opensearch","types","type","mergeByType","dataLoaders","clearAll","init","container","registerFactory","handle","event","model","payload","client","getEntities","getTable","getEsTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport elasticsearchPlugins from \"./elasticsearch/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport { createModelsStorageOperations } from \"./operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport type { StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex.js\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport {\n createOpenSearchEntity,\n createOpenSearchTable,\n OpenSearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-opensearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices/index.js\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex.js\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins/index.js\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins/index.js\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createCreateIndexTask } from \"~/tasks/createIndexTaskPlugin.js\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { ModelAfterCreateEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModel/index.js\";\nimport { ModelAfterCreateFromEventHandler } from \"@webiny/api-headless-cms/features/contentModel/CreateModelFrom/events.js\";\nimport { ModelAfterDeleteEventHandler } from \"@webiny/api-headless-cms/features/contentModel/DeleteModel/events.js\";\nimport { createTable } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, esTable, documentClient, elasticsearch, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table || (process.env.DB_TABLE as string),\n documentClient\n });\n const tableElasticsearchInstance = createOpenSearchTable({\n name: esTable,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n }),\n entriesEs: createOpenSearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.opensearch) {\n context.opensearch = elasticsearch;\n }\n\n /**\n * This registers the task implementation\n */\n createCreateIndexTask(context);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins(), elasticsearchIndexPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n OpenSearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CmsEntryElasticsearchValuesModifier.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * TODO @pavel\n * Moved operations to AFTER create/from because at in before the model does not have modelId - to create the index.\n */\n context.container.registerFactory(ModelAfterCreateEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterCreateFromEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n }\n }));\n\n context.container.registerFactory(ModelAfterDeleteEventHandler, () => ({\n async handle(event) {\n const { model } = event.payload;\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n }\n }));\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":"AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,oBAAoB;AAC3B,OAAOC,eAAe;AACtB,SAASC,6BAA6B;AACtC,SAASC,8BAA8B;AAEvC,SAASC,QAAQ;AACjB,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB;AAC1B,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,6BAA6B;AACtC,SACIC,sBAAsB,EACtBC,qBAAqB,EACrBC,oCAAoC,QACjC,wBAAwB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,wBAAwB;AACjC,SACIC,gCAAgC,EAChCC,uCAAuC,EACvCC,yCAAyC,EACzCC,gCAAgC,EAChCC,kDAAkD,EAClDC,wCAAwC,EACxCC,uCAAuC,EACvCC,mCAAmC;AAEvC,SAASC,mBAAmB;AAC5B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B,EAAEC,sBAAsB,QAAQ,0BAA0B;AAClG,SAASC,qBAAqB;AAC9B,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,4BAA4B,QAAQ,qEAAqE;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,EAAE;UAChB,MAAM;YAAEC;UAAM,CAAC,GAAGD,KAAK,CAACE,OAAO;UAC/B,MAAMjE,wBAAwB,CAAC;YAC3BkE,MAAM,EAAE1C,aAAa;YACrBwC;UACJ,CAAC,CAAC;QACN;MACJ,CAAC,CAAC,CAAC;IACP,CAAC;IACDG,WAAW,EAAEA,CAAA,KAAMlC,QAAQ;IAC3BmC,QAAQ,EAAEA,CAAA,KAAMzC,aAAa;IAC7B0C,UAAU,EAAEA,CAAA,KAAMrC,0BAA0B;IAC5CE,MAAM,EAAEvC,6BAA6B,CAAC;MAClCgD,MAAM,EAAEV,QAAQ,CAACC,MAAM;MACvBT;IACJ,CAAC,CAAC;IACFY,MAAM,EAAElD,6BAA6B,CAAC;MAClCwD,MAAM,EAAEV,QAAQ,CAACI,MAAM;MACvBb;IACJ,CAAC,CAAC;IACFe;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -15,10 +15,7 @@ export class DataLoaderCache {
|
|
|
15
15
|
}
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const key =
|
|
19
|
-
...params,
|
|
20
|
-
name: ""
|
|
21
|
-
});
|
|
18
|
+
const key = `${params.tenant}_`;
|
|
22
19
|
for (const current in this.cache) {
|
|
23
20
|
if (current.startsWith(key) === false) {
|
|
24
21
|
continue;
|
|
@@ -27,7 +24,7 @@ export class DataLoaderCache {
|
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
createKey(params) {
|
|
30
|
-
return `${params.tenant}_${params.name}`;
|
|
27
|
+
return `${params.tenant}_${params.modelId}_${params.name}`;
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","
|
|
1
|
+
{"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","tenant","startsWith","modelId","name"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"mappings":"AAYA,OAAO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,GAAGD,MAAM,CAACO,MAAM,GAAG;IAC/B,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACO,MAAM,IAAIP,MAAM,CAACS,OAAO,IAAIT,MAAM,CAACU,IAAI,EAAE;EAC9D;AACJ","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
|
4
4
|
export const createGetAllEntryRevisions = params => {
|
|
5
5
|
const {
|
|
6
6
|
entity,
|
|
7
|
-
tenant
|
|
7
|
+
tenant,
|
|
8
|
+
modelId
|
|
8
9
|
} = params;
|
|
9
10
|
return new DataLoader(async ids => {
|
|
10
11
|
const results = {};
|
|
@@ -22,7 +23,9 @@ export const createGetAllEntryRevisions = params => {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
return ids.map(entryId => {
|
|
25
|
-
return results[entryId] || []
|
|
26
|
+
return (results[entryId] || []).filter(item => {
|
|
27
|
+
return item.modelId === modelId;
|
|
28
|
+
});
|
|
26
29
|
});
|
|
27
30
|
}, {
|
|
28
31
|
batchScheduleFn: createBatchScheduleFn()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","item","data","entryId","batchScheduleFn"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(item => {\n return item.data;\n });\n }\n\n return ids.map(entryId => {\n return results[entryId] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC;
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","modelId","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(item => {\n return item.data;\n });\n }\n\n return ids.map(entryId => {\n return (results[entryId] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAC1C,OAAO,IAAIJ,UAAU,CACjB,MAAMQ,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAML,MAAM,CAACM,aAAa,CAAC;QACvBC,YAAY,EAAEX,kBAAkB,CAAC;UAC7BK,MAAM;UACNI;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,IAAI,IAAI;QACV,OAAOA,IAAI,CAACC,IAAI;MACpB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACG,OAAO,IAAI;MACtB,OAAO,CAACT,OAAO,CAACS,OAAO,CAAC,IAAI,EAAE,EAAEC,MAAM,CAACH,IAAI,IAAI;QAC3C,OAAOA,IAAI,CAACT,OAAO,KAAKA,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIa,eAAe,EAAElB,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ import { createLatestSortKey, createPartitionKey } from "../keys.js";
|
|
|
4
4
|
export const createGetLatestRevisionByEntryId = params => {
|
|
5
5
|
const {
|
|
6
6
|
entity,
|
|
7
|
-
tenant
|
|
7
|
+
tenant,
|
|
8
|
+
modelId
|
|
8
9
|
} = params;
|
|
9
10
|
const latestKey = createLatestSortKey();
|
|
10
11
|
return new DataLoader(async ids => {
|
|
@@ -29,6 +30,9 @@ export const createGetLatestRevisionByEntryId = params => {
|
|
|
29
30
|
});
|
|
30
31
|
return ids.map(entryId => {
|
|
31
32
|
return items.filter(item => {
|
|
33
|
+
if (item.modelId !== modelId) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
32
36
|
return entryId === item.entryId;
|
|
33
37
|
});
|
|
34
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoader","createBatchScheduleFn","createLatestSortKey","createPartitionKey","createGetLatestRevisionByEntryId","params","entity","tenant","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAGhD,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC;
|
|
1
|
+
{"version":3,"names":["DataLoader","createBatchScheduleFn","createLatestSortKey","createPartitionKey","createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAGhD,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,MAAMI,SAAS,GAAGP,mBAAmB,CAAC,CAAC;EAEvC,OAAO,IAAIF,UAAU,CACjB,MAAMU,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGL,MAAM,CAACM,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGb,kBAAkB,CAAC;QACpCI,MAAM;QACNQ;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MACtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,KAAK,GAAG,CAAC,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI,IAAI;MAC/C,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOhB,GAAG,CAACc,GAAG,CAACG,OAAO,IAAI;MACtB,OAAOL,KAAK,CAACM,MAAM,CAACH,IAAI,IAAI;QACxB,IAAIA,IAAI,CAACjB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOmB,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE5B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,8 @@ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
|
4
4
|
export const createGetPublishedRevisionByEntryId = params => {
|
|
5
5
|
const {
|
|
6
6
|
entity,
|
|
7
|
-
tenant
|
|
7
|
+
tenant,
|
|
8
|
+
modelId
|
|
8
9
|
} = params;
|
|
9
10
|
const publishedKey = createPublishedSortKey();
|
|
10
11
|
return new DataLoader(async ids => {
|
|
@@ -29,6 +30,9 @@ export const createGetPublishedRevisionByEntryId = params => {
|
|
|
29
30
|
});
|
|
30
31
|
return ids.map(entryId => {
|
|
31
32
|
return items.filter(item => {
|
|
33
|
+
if (item.modelId !== modelId) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
32
36
|
return entryId === item.entryId;
|
|
33
37
|
});
|
|
34
38
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoader","createPartitionKey","createPublishedSortKey","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB,EAAEC,sBAAsB;AAEnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,mCAAmC,GAAIC,MAAyB,IAAK;EAC9E,MAAM;IAAEC,MAAM;IAAEC;
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createPublishedSortKey","createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","tenant","modelId","publishedKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","items","execute","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetPublishedRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: publishedKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB,EAAEC,sBAAsB;AAEnD,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,mCAAmC,GAAIC,MAAyB,IAAK;EAC9E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE1C,MAAMI,YAAY,GAAGP,sBAAsB,CAAC,CAAC;EAC7C,OAAO,IAAIF,UAAU,CACjB,MAAMU,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGL,MAAM,CAACM,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGf,kBAAkB,CAAC;QACpCM,MAAM;QACNQ;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MACtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,KAAK,GAAG,CAAC,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC,EAAEC,GAAG,CAACC,IAAI,IAAI;MAC/C,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOhB,GAAG,CAACc,GAAG,CAACG,OAAO,IAAI;MACtB,OAAOL,KAAK,CAACM,MAAM,CAACH,IAAI,IAAI;QACxB,IAAIA,IAAI,CAACjB,OAAO,KAAKA,OAAO,EAAE;UAC1B,OAAO,KAAK;QAChB;QACA,OAAOmB,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE1B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -5,7 +5,8 @@ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
|
|
|
5
5
|
export const createGetRevisionById = params => {
|
|
6
6
|
const {
|
|
7
7
|
entity,
|
|
8
|
-
tenant
|
|
8
|
+
tenant,
|
|
9
|
+
modelId
|
|
9
10
|
} = params;
|
|
10
11
|
return new DataLoader(async ids => {
|
|
11
12
|
const reader = entity.createEntityReader();
|
|
@@ -39,6 +40,9 @@ export const createGetRevisionById = params => {
|
|
|
39
40
|
});
|
|
40
41
|
return ids.map(id => {
|
|
41
42
|
return items.filter(item => {
|
|
43
|
+
if (item.modelId !== modelId) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
42
46
|
return id === item.id;
|
|
43
47
|
});
|
|
44
48
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoader","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","items","execute","map","item","data","filter","batchScheduleFn"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB,EAAEC,qBAAqB;AAElD,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,qBAAqB,GAAIC,MAAyB,IAAK;EAChE,MAAM;IAAEC,MAAM;IAAEC;
|
|
1
|
+
{"version":3,"names":["DataLoader","createPartitionKey","createRevisionSortKey","parseIdentifier","createBatchScheduleFn","createGetRevisionById","params","entity","tenant","modelId","ids","reader","createEntityReader","keys","Set","id","partitionKey","version","sortKey","key","has","add","get","PK","SK","items","execute","map","item","data","filter","batchScheduleFn"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB,EAAEC,qBAAqB;AAEl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A,OAAOM,EAAE,KAAKa,IAAI,CAACb,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIgB,eAAe,EAAE3B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntryEntity } from \"~/definitions/types.js\";\n\nexport interface IDataLoaderParams {\n entity: IEntryEntity;\n tenant: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntryEntity } from \"~/definitions/types.js\";\n\nexport interface IDataLoaderParams {\n entity: IEntryEntity;\n tenant: string;\n modelId: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -48,6 +48,7 @@ export class DataLoadersHandler {
|
|
|
48
48
|
} = params;
|
|
49
49
|
const cacheParams = {
|
|
50
50
|
tenant: model.tenant,
|
|
51
|
+
modelId: model.modelId,
|
|
51
52
|
name
|
|
52
53
|
};
|
|
53
54
|
let loader = this.cache.getDataLoader(cacheParams);
|
|
@@ -57,7 +58,8 @@ export class DataLoadersHandler {
|
|
|
57
58
|
const factory = getDataLoaderFactory(name);
|
|
58
59
|
loader = factory({
|
|
59
60
|
entity: this.entity,
|
|
60
|
-
tenant: model.tenant
|
|
61
|
+
tenant: model.tenant,
|
|
62
|
+
modelId: model.modelId
|
|
61
63
|
});
|
|
62
64
|
this.cache.setDataLoader(cacheParams, loader);
|
|
63
65
|
return loader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","DataLoaderCache","getDataLoaderFactory","parseIdentifier","DataLoadersHandler","cache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","loader","getDataLoader","factory","setDataLoader","results","Array","isArray","reduce","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport type { IEntryEntity } from \"~/definitions/types.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: CmsStorageEntry<T>[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce<CmsStorageEntry<T>[]>((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,SAASC,eAAe;AAExB,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,eAAe;AAqB/C,OAAO,MAAMC,kBAAkB,CAAgC;EAE1CC,KAAK,GAAG,IAAIJ,eAAe,CAAC,CAAC;EAEvCK,WAAWA,CAACC,MAAiC,EAAE;IAClD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoBA,CAC7BF,MAAwB,EACK;IAC7B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAGV,eAAe,CAACS,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACC,QAAQ,CAAI,sBAAsB,EAAEP,MAAM,EAAEG,GAAG,CAAC;EACtE;EAEA,MAAaK,eAAeA,CACxBR,MAAwB,EACK;IAC7B,OAAO,MAAM,IAAI,CAACO,QAAQ,CAAI,iBAAiB,EAAEP,MAAM,EAAEA,MAAM,CAACG,GAAG,CAAC;EACxE;EAEA,MAAaM,6BAA6BA,CACtCT,MAAwB,EACK;IAC7B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAGV,eAAe,CAACS,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACC,QAAQ,CAAI,+BAA+B,EAAEP,MAAM,EAAEG,GAAG,CAAC;EAC/E;EAEA,MAAaO,0BAA0BA,CACnCV,MAAwB,EACK;IAC7B,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAGV,eAAe,CAACS,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACC,QAAQ,CAAI,4BAA4B,EAAEP,MAAM,EAAEG,GAAG,CAAC;EAC5E;;EAEA;AACJ;AACA;AACA;EACYQ,SAASA,CAACC,IAAiB,EAAEZ,MAAuB,EAAwB;IAChF,MAAM;MAAEa;IAAM,CAAC,GAAGb,MAAM;IACxB,MAAMc,WAA2B,GAAG;MAChCC,MAAM,EAAEF,KAAK,CAACE,MAAM;
|
|
1
|
+
{"version":3,"names":["WebinyError","DataLoaderCache","getDataLoaderFactory","parseIdentifier","DataLoadersHandler","cache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","modelId","loader","getDataLoader","factory","setDataLoader","results","Array","isArray","reduce","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport type { IEntryEntity } from \"~/definitions/types.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: CmsStorageEntry<T>[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce<CmsStorageEntry<T>[]>((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params?.model);\n }\n}\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,SAASC,eAAe;AAExB,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,eAAe;AAqB/C,OAAO,MAAMC,kBAAkB,CAAgC;EAE1CC,KAAK,GAAG,IAAIJ,eAAe,CAAC,CAAC;EAEvCK,WAAWA,CAACC,MAAiC,EAAE;IAClD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoB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AAM,IAAIpC,WAAW,CACjB,uFAAuF,EACvF,2BAA2B,EAC3B;cACI,GAAGO,MAAM;cACTiB;YACJ,CACJ,CAAC;UACL;UACAQ,GAAG,CAACO,IAAI,CAAC,GAAGN,GAAG,CAAC;UAChB,OAAOD,GAAG;QACd,CAAC,EAAE,EAAE,CAAC;MACV;IACJ,CAAC,CAAC,OAAOQ,EAAE,EAAE;MACT,MAAM,IAAIxC,WAAW,CACjBwC,EAAE,CAACN,OAAO,IAAI,oBAAoB,EAClCM,EAAE,CAACL,IAAI,IAAI,mBAAmB,EAC9B;QACIM,KAAK,EAAED,EAAE;QACT,GAAGjC,MAAM;QACTiB,MAAM;QACNd;MACJ,CACJ,CAAC;IACL;IACA,MAAM,IAAIV,WAAW,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIwB,MAAM;MACNd,GAAG;MACHkB;IACJ,CACJ,CAAC;EACL;EAEOc,QAAQA,CAACnC,MAAkD,EAAQ;IACtE,IAAI,CAACF,KAAK,CAACqC,QAAQ,CAACnC,MAAM,EAAEa,KAAK,CAAC;EACtC;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoolQueryConfig } from "@webiny/api-
|
|
1
|
+
import type { QueryDslBoolQuery as BoolQueryConfig } from "@webiny/api-opensearch/types.js";
|
|
2
2
|
/**
|
|
3
3
|
* This function will assign a minimum_should_match for the query if conditions are met:
|
|
4
4
|
* * should is an array
|