@webiny/api-page-builder-so-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.5e7233243f
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 +9 -0
- package/configurations.js +49 -0
- package/configurations.js.map +1 -0
- package/definitions/categoryEntity.d.ts +7 -4
- package/definitions/categoryEntity.js +8 -11
- package/definitions/categoryEntity.js.map +1 -0
- package/definitions/menuEntity.d.ts +7 -4
- package/definitions/menuEntity.js +8 -11
- package/definitions/menuEntity.js.map +1 -0
- package/definitions/pageElasticsearchEntity.d.ts +7 -4
- package/definitions/pageElasticsearchEntity.js +8 -11
- package/definitions/pageElasticsearchEntity.js.map +1 -0
- package/definitions/pageElementEntity.d.ts +7 -4
- package/definitions/pageElementEntity.js +8 -11
- package/definitions/pageElementEntity.js.map +1 -0
- package/definitions/pageEntity.d.ts +7 -4
- package/definitions/pageEntity.js +8 -20
- package/definitions/pageEntity.js.map +1 -0
- package/definitions/settingsEntity.d.ts +7 -4
- package/definitions/settingsEntity.js +13 -12
- package/definitions/settingsEntity.js.map +1 -0
- package/definitions/systemEntity.d.ts +7 -4
- package/definitions/systemEntity.js +11 -11
- package/definitions/systemEntity.js.map +1 -0
- package/definitions/table.d.ts +7 -4
- package/definitions/table.js +12 -18
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +8 -4
- package/definitions/tableElasticsearch.js +12 -25
- package/definitions/tableElasticsearch.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +23 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +24 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/index.d.ts +2 -8
- package/index.js +177 -8
- package/index.js.map +1 -0
- package/operations/category/{CategoryDataLoader.d.ts → dataLoader.d.ts} +4 -8
- package/operations/category/{CategoryDataLoader.js → dataLoader.js} +10 -8
- package/operations/category/dataLoader.js.map +1 -0
- package/operations/category/fields.d.ts +1 -2
- package/operations/category/fields.js +3 -3
- package/operations/category/fields.js.map +1 -0
- package/operations/category/index.d.ts +6 -3
- package/operations/category/index.js +198 -14
- package/operations/category/index.js.map +1 -0
- package/operations/category/keys.d.ts +9 -0
- package/operations/category/keys.js +25 -0
- package/operations/category/keys.js.map +1 -0
- package/operations/menu/fields.d.ts +1 -2
- package/operations/menu/fields.js +18 -16
- package/operations/menu/fields.js.map +1 -0
- package/operations/menu/index.d.ts +6 -3
- package/operations/menu/index.js +207 -14
- package/operations/menu/index.js.map +1 -0
- package/operations/pageElement/fields.d.ts +1 -2
- package/operations/pageElement/fields.js +3 -3
- package/operations/pageElement/fields.js.map +1 -0
- package/operations/pageElement/index.d.ts +6 -5
- package/operations/pageElement/index.js +197 -14
- package/operations/pageElement/index.js.map +1 -0
- package/operations/pages/elasticsearchQueryBody.d.ts +5 -11
- package/operations/pages/elasticsearchQueryBody.js +17 -37
- package/operations/pages/elasticsearchQueryBody.js.map +1 -0
- package/operations/pages/fields.d.ts +3 -2
- package/operations/pages/fields.js +15 -3
- package/operations/pages/fields.js.map +1 -0
- package/operations/pages/helpers.d.ts +6 -14
- package/operations/pages/helpers.js +12 -12
- package/operations/pages/helpers.js.map +1 -0
- package/operations/pages/index.d.ts +9 -3
- package/operations/pages/index.js +943 -16
- package/operations/pages/index.js.map +1 -0
- package/operations/pages/keys.d.ts +24 -0
- package/operations/pages/keys.js +79 -0
- package/operations/pages/keys.js.map +1 -0
- package/operations/settings/index.d.ts +4 -5
- package/operations/settings/index.js +171 -12
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +4 -3
- package/operations/system/index.js +97 -18
- package/operations/system/index.js.map +1 -0
- package/package.json +27 -27
- package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js.map +1 -0
- package/plugins/definitions/IndexPageDataPlugin.d.ts +3 -4
- package/plugins/definitions/IndexPageDataPlugin.js.map +1 -0
- package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js.map +1 -0
- package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.d.ts +4 -0
- package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js +17 -0
- package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/definitions/PageElasticsearchFieldPlugin.d.ts +1 -2
- package/plugins/definitions/PageElasticsearchFieldPlugin.js +1 -6
- package/plugins/definitions/PageElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/definitions/PageElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/definitions/PageElasticsearchIndexPlugin.js +17 -0
- package/plugins/definitions/PageElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/definitions/PageElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js.map +1 -0
- package/plugins/definitions/SearchLatestPagesPlugin.d.ts +1 -1
- package/plugins/definitions/SearchLatestPagesPlugin.js.map +1 -0
- package/plugins/definitions/SearchPagesPlugin.d.ts +3 -4
- package/plugins/definitions/SearchPagesPlugin.js.map +1 -0
- package/plugins/definitions/SearchPublishedPagesPlugin.d.ts +1 -1
- package/plugins/definitions/SearchPublishedPagesPlugin.js.map +1 -0
- package/types.d.ts +37 -0
- package/types.js +18 -0
- package/types.js.map +1 -0
- package/upgrades/index.js.map +1 -0
- package/upgrades/v5.15.0/category.js +4 -3
- package/upgrades/v5.15.0/category.js.map +1 -0
- package/upgrades/v5.15.0/index.js.map +1 -0
- package/upgrades/v5.15.0/menu.js +4 -3
- package/upgrades/v5.15.0/menu.js.map +1 -0
- package/upgrades/v5.15.0/pageElement.js +4 -3
- package/upgrades/v5.15.0/pageElement.js.map +1 -0
- package/operations/category/CategoryStorageOperations.d.ts +0 -29
- package/operations/category/CategoryStorageOperations.js +0 -243
- package/operations/configurations.d.ts +0 -36
- package/operations/configurations.js +0 -71
- package/operations/menu/MenuStorageOperations.d.ts +0 -23
- package/operations/menu/MenuStorageOperations.js +0 -235
- package/operations/pageElement/PageElementStorageOperations.d.ts +0 -23
- package/operations/pageElement/PageElementStorageOperations.js +0 -234
- package/operations/pages/PageStorageOperations.d.ts +0 -79
- package/operations/pages/PageStorageOperations.js +0 -1117
- package/operations/settings/SettingsStorageOperations.d.ts +0 -35
- package/operations/settings/SettingsStorageOperations.js +0 -191
- package/operations/system/InstallationDdbEsPlugin.d.ts +0 -2
- package/operations/system/InstallationDdbEsPlugin.js +0 -73
- package/operations/system/SystemStorageOperations.d.ts +0 -16
- package/operations/system/SystemStorageOperations.js +0 -114
package/definitions/table.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.
|
|
6
|
+
exports.createTable = void 0;
|
|
9
7
|
|
|
10
8
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const defineTable = params => {
|
|
19
|
-
const {
|
|
20
|
-
context
|
|
21
|
-
} = params;
|
|
22
|
-
return new _dynamodbToolbox.Table({
|
|
23
|
-
name: _configurations.default.db().table || (0, _table.getTable)(context),
|
|
10
|
+
const createTable = ({
|
|
11
|
+
table,
|
|
12
|
+
documentClient
|
|
13
|
+
}) => {
|
|
14
|
+
const tableConfig = {
|
|
15
|
+
name: process.env.DB_PAGE_BUILDER || process.env.DB_TABLE,
|
|
24
16
|
partitionKey: "PK",
|
|
25
17
|
sortKey: "SK",
|
|
26
|
-
DocumentClient:
|
|
27
|
-
}
|
|
18
|
+
DocumentClient: documentClient
|
|
19
|
+
};
|
|
20
|
+
const config = typeof table === "function" ? table(tableConfig) : tableConfig;
|
|
21
|
+
return new _dynamodbToolbox.Table(config);
|
|
28
22
|
};
|
|
29
23
|
|
|
30
|
-
exports.
|
|
24
|
+
exports.createTable = createTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createTable","table","documentClient","tableConfig","name","process","env","DB_PAGE_BUILDER","DB_TABLE","partitionKey","sortKey","DocumentClient","config","Table"],"sources":["table.ts"],"sourcesContent":["import { TableModifier } from \"~/types\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\n\ninterface Params {\n table?: TableModifier;\n documentClient: DocumentClient;\n}\nexport const createTable = ({ table, documentClient }: Params): Table => {\n const tableConfig: TableConstructor = {\n name: process.env.DB_PAGE_BUILDER || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient\n };\n\n const config = typeof table === \"function\" ? table(tableConfig) : tableConfig;\n\n return new Table(config);\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,WAAW,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAA8C;EACrE,MAAMC,WAA6B,GAAG;IAClCC,IAAI,EAAEC,OAAO,CAACC,GAAR,CAAYC,eAAZ,IAAgCF,OAAO,CAACC,GAAR,CAAYE,QADhB;IAElCC,YAAY,EAAE,IAFoB;IAGlCC,OAAO,EAAE,IAHyB;IAIlCC,cAAc,EAAET;EAJkB,CAAtC;EAOA,MAAMU,MAAM,GAAG,OAAOX,KAAP,KAAiB,UAAjB,GAA8BA,KAAK,CAACE,WAAD,CAAnC,GAAmDA,WAAlE;EAEA,OAAO,IAAIU,sBAAJ,CAAUD,MAAV,CAAP;AACH,CAXM"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { TableModifier } from "../types";
|
|
2
|
+
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
1
3
|
import { Table } from "dynamodb-toolbox";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
4
|
+
interface Params {
|
|
5
|
+
table?: TableModifier;
|
|
6
|
+
documentClient: DocumentClient;
|
|
7
|
+
}
|
|
8
|
+
export declare const createElasticsearchTable: ({ table, documentClient }: Params) => Table;
|
|
9
|
+
export {};
|
|
@@ -1,37 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.
|
|
6
|
+
exports.createElasticsearchTable = void 0;
|
|
9
7
|
|
|
10
8
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const defineTableElasticsearch = params => {
|
|
19
|
-
const {
|
|
20
|
-
context
|
|
21
|
-
} = params;
|
|
22
|
-
|
|
23
|
-
const tableName = _configurations.default.esDb().table;
|
|
24
|
-
|
|
25
|
-
if (!tableName) {
|
|
26
|
-
throw new _error.default(`Missing Elasticsearch table in the configuration.`, "TABLE_NAME_ERROR");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return new _dynamodbToolbox.Table({
|
|
30
|
-
name: tableName,
|
|
10
|
+
const createElasticsearchTable = ({
|
|
11
|
+
table,
|
|
12
|
+
documentClient
|
|
13
|
+
}) => {
|
|
14
|
+
const tableConfig = {
|
|
15
|
+
name: process.env.DB_TABLE_ELASTICSEARCH,
|
|
31
16
|
partitionKey: "PK",
|
|
32
17
|
sortKey: "SK",
|
|
33
|
-
DocumentClient:
|
|
34
|
-
}
|
|
18
|
+
DocumentClient: documentClient
|
|
19
|
+
};
|
|
20
|
+
const config = typeof table === "function" ? table(tableConfig) : tableConfig;
|
|
21
|
+
return new _dynamodbToolbox.Table(config);
|
|
35
22
|
};
|
|
36
23
|
|
|
37
|
-
exports.
|
|
24
|
+
exports.createElasticsearchTable = createElasticsearchTable;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElasticsearchTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_ELASTICSEARCH","partitionKey","sortKey","DocumentClient","config","Table"],"sources":["tableElasticsearch.ts"],"sourcesContent":["import { TableModifier } from \"~/types\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Table } from \"dynamodb-toolbox\";\nimport { TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\n\ninterface Params {\n table?: TableModifier;\n documentClient: DocumentClient;\n}\nexport const createElasticsearchTable = ({ table, documentClient }: Params): Table => {\n const tableConfig: TableConstructor = {\n name: process.env.DB_TABLE_ELASTICSEARCH as string,\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient\n };\n\n const config = typeof table === \"function\" ? table(tableConfig) : tableConfig;\n\n return new Table(config);\n};\n"],"mappings":";;;;;;;AAEA;;AAOO,MAAMA,wBAAwB,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAA8C;EAClF,MAAMC,WAA6B,GAAG;IAClCC,IAAI,EAAEC,OAAO,CAACC,GAAR,CAAYC,sBADgB;IAElCC,YAAY,EAAE,IAFoB;IAGlCC,OAAO,EAAE,IAHyB;IAIlCC,cAAc,EAAER;EAJkB,CAAtC;EAOA,MAAMS,MAAM,GAAG,OAAOV,KAAP,KAAiB,UAAjB,GAA8BA,KAAK,CAACE,WAAD,CAAnC,GAAmDA,WAAlE;EAEA,OAAO,IAAIS,sBAAJ,CAAUD,MAAV,CAAP;AACH,CAXM"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
export interface ExecOnBeforeInstallParams {
|
|
4
|
+
elasticsearch: Client;
|
|
5
|
+
plugins: PluginsContainer;
|
|
6
|
+
tenant: string;
|
|
7
|
+
locale: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const createElasticsearchIndex: (params: ExecOnBeforeInstallParams) => Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createElasticsearchIndex = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _indices = require("@webiny/api-elasticsearch/indices");
|
|
13
|
+
|
|
14
|
+
var _PageElasticsearchIndexPlugin = require("../plugins/definitions/PageElasticsearchIndexPlugin");
|
|
15
|
+
|
|
16
|
+
var _configurations = require("../configurations");
|
|
17
|
+
|
|
18
|
+
const createElasticsearchIndex = async params => {
|
|
19
|
+
const {
|
|
20
|
+
elasticsearch,
|
|
21
|
+
plugins: container,
|
|
22
|
+
locale,
|
|
23
|
+
tenant
|
|
24
|
+
} = params;
|
|
25
|
+
const plugin = (0, _indices.getLastAddedIndexPlugin)({
|
|
26
|
+
container,
|
|
27
|
+
type: _PageElasticsearchIndexPlugin.PageElasticsearchIndexPlugin.type,
|
|
28
|
+
locale
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
index
|
|
33
|
+
} = _configurations.configurations.es({
|
|
34
|
+
locale,
|
|
35
|
+
tenant
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const response = await elasticsearch.indices.exists({
|
|
40
|
+
index
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (response.body) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
await elasticsearch.indices.create({
|
|
48
|
+
index,
|
|
49
|
+
body: plugin.body
|
|
50
|
+
});
|
|
51
|
+
} catch (ex) {
|
|
52
|
+
throw new _error.default(ex.message || "Could not create Elasticsearch index template for the Page Builder Pages.", ex.code || "PB_ELASTICSEARCH_TEMPLATE_ERROR", {
|
|
53
|
+
error: ex,
|
|
54
|
+
locale,
|
|
55
|
+
body: plugin.body
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.createElasticsearchIndex = createElasticsearchIndex;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createElasticsearchIndex","params","elasticsearch","plugins","container","locale","tenant","plugin","getLastAddedIndexPlugin","type","PageElasticsearchIndexPlugin","index","configurations","es","response","indices","exists","body","create","ex","WebinyError","message","code","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { getLastAddedIndexPlugin } from \"@webiny/api-elasticsearch/indices\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { PageElasticsearchIndexPlugin } from \"~/plugins/definitions/PageElasticsearchIndexPlugin\";\nimport { configurations } from \"~/configurations\";\n\nexport interface ExecOnBeforeInstallParams {\n elasticsearch: Client;\n plugins: PluginsContainer;\n tenant: string;\n locale: string;\n}\nexport const createElasticsearchIndex = async (\n params: ExecOnBeforeInstallParams\n): Promise<void> => {\n const { elasticsearch, plugins: container, locale, tenant } = params;\n\n const plugin = getLastAddedIndexPlugin<PageElasticsearchIndexPlugin>({\n container,\n type: PageElasticsearchIndexPlugin.type,\n locale\n });\n\n const { index } = configurations.es({\n locale,\n tenant\n });\n\n try {\n const response = await elasticsearch.indices.exists({\n index\n });\n if (response.body) {\n return;\n }\n await elasticsearch.indices.create({\n index,\n body: plugin.body\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not create Elasticsearch index template for the Page Builder Pages.\",\n ex.code || \"PB_ELASTICSEARCH_TEMPLATE_ERROR\",\n {\n error: ex,\n locale,\n body: plugin.body\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AAEA;;AACA;;AAQO,MAAMA,wBAAwB,GAAG,MACpCC,MADoC,IAEpB;EAChB,MAAM;IAAEC,aAAF;IAAiBC,OAAO,EAAEC,SAA1B;IAAqCC,MAArC;IAA6CC;EAA7C,IAAwDL,MAA9D;EAEA,MAAMM,MAAM,GAAG,IAAAC,gCAAA,EAAsD;IACjEJ,SADiE;IAEjEK,IAAI,EAAEC,0DAAA,CAA6BD,IAF8B;IAGjEJ;EAHiE,CAAtD,CAAf;;EAMA,MAAM;IAAEM;EAAF,IAAYC,8BAAA,CAAeC,EAAf,CAAkB;IAChCR,MADgC;IAEhCC;EAFgC,CAAlB,CAAlB;;EAKA,IAAI;IACA,MAAMQ,QAAQ,GAAG,MAAMZ,aAAa,CAACa,OAAd,CAAsBC,MAAtB,CAA6B;MAChDL;IADgD,CAA7B,CAAvB;;IAGA,IAAIG,QAAQ,CAACG,IAAb,EAAmB;MACf;IACH;;IACD,MAAMf,aAAa,CAACa,OAAd,CAAsBG,MAAtB,CAA6B;MAC/BP,KAD+B;MAE/BM,IAAI,EAAEV,MAAM,CAACU;IAFkB,CAA7B,CAAN;EAIH,CAXD,CAWE,OAAOE,EAAP,EAAW;IACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IACI,2EAFF,EAGFF,EAAE,CAACG,IAAH,IAAW,iCAHT,EAIF;MACIC,KAAK,EAAEJ,EADX;MAEId,MAFJ;MAGIY,IAAI,EAAEV,MAAM,CAACU;IAHjB,CAJE,CAAN;EAUH;AACJ,CAvCM"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.base = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _base = require("@webiny/api-elasticsearch/indexConfiguration/base");
|
|
13
|
+
|
|
14
|
+
var _PageElasticsearchIndexPlugin = require("../../plugins/definitions/PageElasticsearchIndexPlugin");
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
const base = new _PageElasticsearchIndexPlugin.PageElasticsearchIndexPlugin({
|
|
21
|
+
body: _objectSpread({}, _base.base)
|
|
22
|
+
});
|
|
23
|
+
exports.base = base;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["base","PageElasticsearchIndexPlugin","body","baseConfiguration"],"sources":["base.ts"],"sourcesContent":["import { base as baseConfiguration } from \"@webiny/api-elasticsearch/indexConfiguration/base\";\nimport { PageElasticsearchIndexPlugin } from \"~/plugins/definitions/PageElasticsearchIndexPlugin\";\n\nexport const base = new PageElasticsearchIndexPlugin({\n body: {\n ...baseConfiguration\n }\n});\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,IAAI,GAAG,IAAIC,0DAAJ,CAAiC;EACjDC,IAAI,oBACGC,UADH;AAD6C,CAAjC,CAAb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const elasticsearchIndexPlugins: () => import("../../plugins/definitions/PageElasticsearchIndexPlugin").PageElasticsearchIndexPlugin[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.elasticsearchIndexPlugins = void 0;
|
|
7
|
+
|
|
8
|
+
var _base = require("./base");
|
|
9
|
+
|
|
10
|
+
var _japanese = require("./japanese");
|
|
11
|
+
|
|
12
|
+
const elasticsearchIndexPlugins = () => {
|
|
13
|
+
return [_base.base, _japanese.japanese];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.elasticsearchIndexPlugins = elasticsearchIndexPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["elasticsearchIndexPlugins","base","japanese"],"sources":["index.ts"],"sourcesContent":["import { base } from \"./base\";\nimport { japanese } from \"./japanese\";\n\nexport const elasticsearchIndexPlugins = () => {\n return [base, japanese];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAACC,UAAD,EAAOC,kBAAP,CAAP;AACH,CAFM"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.japanese = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _japanese = require("@webiny/api-elasticsearch/indexConfiguration/japanese");
|
|
13
|
+
|
|
14
|
+
var _PageElasticsearchIndexPlugin = require("../../plugins/definitions/PageElasticsearchIndexPlugin");
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
const japanese = new _PageElasticsearchIndexPlugin.PageElasticsearchIndexPlugin({
|
|
21
|
+
body: _objectSpread({}, _japanese.japanese),
|
|
22
|
+
locales: ["ja", "ja-jp"]
|
|
23
|
+
});
|
|
24
|
+
exports.japanese = japanese;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["japanese","PageElasticsearchIndexPlugin","body","japaneseConfiguration","locales"],"sources":["japanese.ts"],"sourcesContent":["import { japanese as japaneseConfiguration } from \"@webiny/api-elasticsearch/indexConfiguration/japanese\";\nimport { PageElasticsearchIndexPlugin } from \"~/plugins/definitions/PageElasticsearchIndexPlugin\";\n\nexport const japanese = new PageElasticsearchIndexPlugin({\n body: {\n ...japaneseConfiguration\n },\n locales: [\"ja\", \"ja-jp\"]\n});\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;;;;;AAEO,MAAMA,QAAQ,GAAG,IAAIC,0DAAJ,CAAiC;EACrDC,IAAI,oBACGC,kBADH,CADiD;EAIrDC,OAAO,EAAE,CAAC,IAAD,EAAO,OAAP;AAJ4C,CAAjC,CAAjB"}
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { PageElementStorageOperationsDdbEsProviderPlugin } from "./operations/pageElement";
|
|
4
|
-
import { PageStorageOperationsDdbEsProviderPlugin } from "./operations/pages";
|
|
5
|
-
import { SystemStorageOperationsDdbEsProviderPlugin } from "./operations/system";
|
|
6
|
-
import { SettingsStorageOperationsDdbEsProviderPlugin } from "./operations/settings";
|
|
7
|
-
declare const _default: () => (CategoryStorageOperationsDdbEsProviderPlugin | MenuStorageOperationsDdbEsProviderPlugin | PageElementStorageOperationsDdbEsProviderPlugin | PageStorageOperationsDdbEsProviderPlugin | SystemStorageOperationsDdbEsProviderPlugin | SettingsStorageOperationsDdbEsProviderPlugin | import("@webiny/api-upgrade").UpgradePlugin<import("@webiny/api-page-builder/types").PbContext>[])[];
|
|
8
|
-
export default _default;
|
|
1
|
+
import { StorageOperationsFactory } from "./types";
|
|
2
|
+
export declare const createStorageOperations: StorageOperationsFactory;
|
package/index.js
CHANGED
|
@@ -5,22 +5,191 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.createStorageOperations = void 0;
|
|
9
|
+
|
|
10
|
+
var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
|
|
11
|
+
|
|
12
|
+
var _system = require("./operations/system");
|
|
13
|
+
|
|
14
|
+
var _types = require("./types");
|
|
15
|
+
|
|
16
|
+
var _table = require("./definitions/table");
|
|
17
|
+
|
|
18
|
+
var _tableElasticsearch = require("./definitions/tableElasticsearch");
|
|
19
|
+
|
|
20
|
+
var _settingsEntity = require("./definitions/settingsEntity");
|
|
21
|
+
|
|
22
|
+
var _systemEntity = require("./definitions/systemEntity");
|
|
23
|
+
|
|
24
|
+
var _categoryEntity = require("./definitions/categoryEntity");
|
|
25
|
+
|
|
26
|
+
var _menuEntity = require("./definitions/menuEntity");
|
|
27
|
+
|
|
28
|
+
var _pageElementEntity = require("./definitions/pageElementEntity");
|
|
29
|
+
|
|
30
|
+
var _pageEntity = require("./definitions/pageEntity");
|
|
31
|
+
|
|
32
|
+
var _pageElasticsearchEntity = require("./definitions/pageElasticsearchEntity");
|
|
33
|
+
|
|
34
|
+
var _plugins = require("@webiny/plugins");
|
|
35
|
+
|
|
36
|
+
var _operators = require("@webiny/api-elasticsearch/operators");
|
|
37
|
+
|
|
38
|
+
var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
|
|
39
|
+
|
|
40
|
+
var _settings = require("./operations/settings");
|
|
41
|
+
|
|
42
|
+
var _fields = require("./operations/category/fields");
|
|
9
43
|
|
|
10
44
|
var _category = require("./operations/category");
|
|
11
45
|
|
|
46
|
+
var _fields2 = require("./operations/menu/fields");
|
|
47
|
+
|
|
12
48
|
var _menu = require("./operations/menu");
|
|
13
49
|
|
|
14
|
-
var
|
|
50
|
+
var _fields3 = require("./operations/pageElement/fields");
|
|
15
51
|
|
|
16
|
-
var
|
|
52
|
+
var _pageElement = require("./operations/pageElement");
|
|
17
53
|
|
|
18
|
-
var
|
|
54
|
+
var _fields4 = require("./operations/pages/fields");
|
|
19
55
|
|
|
20
|
-
var
|
|
56
|
+
var _pages = require("./operations/pages");
|
|
21
57
|
|
|
22
|
-
var
|
|
58
|
+
var _indices = require("./elasticsearch/indices");
|
|
23
59
|
|
|
24
|
-
|
|
60
|
+
const createStorageOperations = params => {
|
|
61
|
+
const {
|
|
62
|
+
documentClient,
|
|
63
|
+
elasticsearch,
|
|
64
|
+
table,
|
|
65
|
+
esTable,
|
|
66
|
+
attributes,
|
|
67
|
+
plugins: userPlugins
|
|
68
|
+
} = params;
|
|
69
|
+
const tableInstance = (0, _table.createTable)({
|
|
70
|
+
table,
|
|
71
|
+
documentClient
|
|
72
|
+
});
|
|
73
|
+
const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
|
|
74
|
+
table: esTable,
|
|
75
|
+
documentClient
|
|
76
|
+
});
|
|
77
|
+
const plugins = new _plugins.PluginsContainer([
|
|
78
|
+
/**
|
|
79
|
+
* User defined custom plugins.
|
|
80
|
+
*/
|
|
81
|
+
...(userPlugins || []),
|
|
82
|
+
/**
|
|
83
|
+
* DynamoDB filter plugins for the where conditions.
|
|
84
|
+
*/
|
|
85
|
+
(0, _filters.default)(),
|
|
86
|
+
/**
|
|
87
|
+
* Elasticsearch operators.
|
|
88
|
+
*/
|
|
89
|
+
(0, _operators.getElasticsearchOperators)(),
|
|
90
|
+
/**
|
|
91
|
+
* Category fields required for filtering/sorting.
|
|
92
|
+
*/
|
|
93
|
+
(0, _fields.createCategoryDynamoDbFields)(),
|
|
94
|
+
/**
|
|
95
|
+
* Menu fields required for filtering/sorting.
|
|
96
|
+
*/
|
|
97
|
+
(0, _fields2.createMenuDynamoDbFields)(),
|
|
98
|
+
/**
|
|
99
|
+
* Page element fields required for filtering/sorting.
|
|
100
|
+
*/
|
|
101
|
+
(0, _fields3.createPageElementDynamoDbFields)(),
|
|
102
|
+
/**
|
|
103
|
+
* Page fields required for filtering/sorting.
|
|
104
|
+
*/
|
|
105
|
+
(0, _fields4.createPagesElasticsearchFields)(),
|
|
106
|
+
/**
|
|
107
|
+
* Page fields required for filtering/sorting when using dynamodb.
|
|
108
|
+
*/
|
|
109
|
+
(0, _fields4.createPagesDynamoDbFields)(),
|
|
110
|
+
/**
|
|
111
|
+
* Built-in Elasticsearch index templates
|
|
112
|
+
*/
|
|
113
|
+
(0, _indices.elasticsearchIndexPlugins)()]);
|
|
114
|
+
const entities = {
|
|
115
|
+
settings: (0, _settingsEntity.createSettingsEntity)({
|
|
116
|
+
entityName: _types.ENTITIES.SETTINGS,
|
|
117
|
+
table: tableInstance,
|
|
118
|
+
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
119
|
+
}),
|
|
120
|
+
system: (0, _systemEntity.createSystemEntity)({
|
|
121
|
+
entityName: _types.ENTITIES.SYSTEM,
|
|
122
|
+
table: tableInstance,
|
|
123
|
+
attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
|
|
124
|
+
}),
|
|
125
|
+
categories: (0, _categoryEntity.createCategoryEntity)({
|
|
126
|
+
entityName: _types.ENTITIES.CATEGORIES,
|
|
127
|
+
table: tableInstance,
|
|
128
|
+
attributes: attributes ? attributes[_types.ENTITIES.CATEGORIES] : {}
|
|
129
|
+
}),
|
|
130
|
+
menus: (0, _menuEntity.createMenuEntity)({
|
|
131
|
+
entityName: _types.ENTITIES.MENUS,
|
|
132
|
+
table: tableInstance,
|
|
133
|
+
attributes: attributes ? attributes[_types.ENTITIES.MENUS] : {}
|
|
134
|
+
}),
|
|
135
|
+
pageElements: (0, _pageElementEntity.createPageElementEntity)({
|
|
136
|
+
entityName: _types.ENTITIES.PAGE_ELEMENTS,
|
|
137
|
+
table: tableInstance,
|
|
138
|
+
attributes: attributes ? attributes[_types.ENTITIES.PAGE_ELEMENTS] : {}
|
|
139
|
+
}),
|
|
140
|
+
pages: (0, _pageEntity.createPageEntity)({
|
|
141
|
+
entityName: _types.ENTITIES.PAGES,
|
|
142
|
+
table: tableInstance,
|
|
143
|
+
attributes: attributes ? attributes[_types.ENTITIES.PAGES] : {}
|
|
144
|
+
}),
|
|
145
|
+
pagesEs: (0, _pageElasticsearchEntity.createPageElasticsearchEntity)({
|
|
146
|
+
entityName: _types.ENTITIES.PAGES_ES,
|
|
147
|
+
table: tableElasticsearchInstance,
|
|
148
|
+
attributes: attributes ? attributes[_types.ENTITIES.PAGES_ES] : {}
|
|
149
|
+
})
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
init: async context => {
|
|
153
|
+
context.i18n.locales.onBeforeCreate.subscribe(async ({
|
|
154
|
+
locale,
|
|
155
|
+
tenant
|
|
156
|
+
}) => {
|
|
157
|
+
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
158
|
+
elasticsearch,
|
|
159
|
+
plugins,
|
|
160
|
+
locale: locale.code,
|
|
161
|
+
tenant
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
getEntities: () => entities,
|
|
166
|
+
getTable: () => tableInstance,
|
|
167
|
+
getEsTable: () => tableElasticsearchInstance,
|
|
168
|
+
system: (0, _system.createSystemStorageOperations)({
|
|
169
|
+
entity: entities.system
|
|
170
|
+
}),
|
|
171
|
+
settings: (0, _settings.createSettingsStorageOperations)({
|
|
172
|
+
entity: entities.settings
|
|
173
|
+
}),
|
|
174
|
+
categories: (0, _category.createCategoryStorageOperations)({
|
|
175
|
+
entity: entities.categories,
|
|
176
|
+
plugins
|
|
177
|
+
}),
|
|
178
|
+
menus: (0, _menu.createMenuStorageOperations)({
|
|
179
|
+
entity: entities.menus,
|
|
180
|
+
plugins
|
|
181
|
+
}),
|
|
182
|
+
pageElements: (0, _pageElement.createPageElementStorageOperations)({
|
|
183
|
+
entity: entities.pageElements,
|
|
184
|
+
plugins
|
|
185
|
+
}),
|
|
186
|
+
pages: (0, _pages.createPageStorageOperations)({
|
|
187
|
+
entity: entities.pages,
|
|
188
|
+
esEntity: entities.pagesEs,
|
|
189
|
+
elasticsearch,
|
|
190
|
+
plugins
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
};
|
|
25
194
|
|
|
26
|
-
exports.
|
|
195
|
+
exports.createStorageOperations = createStorageOperations;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStorageOperations","params","documentClient","elasticsearch","table","esTable","attributes","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","PluginsContainer","dynamoDbValueFilters","getElasticsearchOperators","createCategoryDynamoDbFields","createMenuDynamoDbFields","createPageElementDynamoDbFields","createPagesElasticsearchFields","createPagesDynamoDbFields","elasticsearchIndexPlugins","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","categories","createCategoryEntity","CATEGORIES","menus","createMenuEntity","MENUS","pageElements","createPageElementEntity","PAGE_ELEMENTS","pages","createPageEntity","PAGES","pagesEs","createPageElasticsearchEntity","PAGES_ES","init","context","i18n","locales","onBeforeCreate","subscribe","locale","tenant","createElasticsearchIndex","code","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createCategoryStorageOperations","createMenuStorageOperations","createPageElementStorageOperations","createPageStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createSettingsEntity } from \"~/definitions/settingsEntity\";\nimport { createSystemEntity } from \"./definitions/systemEntity\";\nimport { createCategoryEntity } from \"~/definitions/categoryEntity\";\nimport { createMenuEntity } from \"~/definitions/menuEntity\";\nimport { createPageElementEntity } from \"~/definitions/pageElementEntity\";\nimport { createPageEntity } from \"~/definitions/pageEntity\";\nimport { createPageElasticsearchEntity } from \"~/definitions/pageElasticsearchEntity\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { getElasticsearchOperators } from \"@webiny/api-elasticsearch/operators\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createCategoryDynamoDbFields } from \"~/operations/category/fields\";\nimport { createCategoryStorageOperations } from \"~/operations/category\";\nimport { createMenuDynamoDbFields } from \"~/operations/menu/fields\";\nimport { createMenuStorageOperations } from \"~/operations/menu\";\nimport { createPageElementDynamoDbFields } from \"~/operations/pageElement/fields\";\nimport { createPageElementStorageOperations } from \"~/operations/pageElement\";\nimport {\n createPagesElasticsearchFields,\n createPagesDynamoDbFields\n} from \"~/operations/pages/fields\";\nimport { createPageStorageOperations } from \"~/operations/pages\";\nimport { elasticsearchIndexPlugins } from \"~/elasticsearch/indices\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n documentClient,\n elasticsearch,\n table,\n esTable,\n attributes,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const plugins = new PluginsContainer([\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || []),\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\n /**\n * Category fields required for filtering/sorting.\n */\n createCategoryDynamoDbFields(),\n /**\n * Menu fields required for filtering/sorting.\n */\n createMenuDynamoDbFields(),\n /**\n * Page element fields required for filtering/sorting.\n */\n createPageElementDynamoDbFields(),\n /**\n * Page fields required for filtering/sorting.\n */\n createPagesElasticsearchFields(),\n /**\n * Page fields required for filtering/sorting when using dynamodb.\n */\n createPagesDynamoDbFields(),\n /**\n * Built-in Elasticsearch index templates\n */\n elasticsearchIndexPlugins()\n ]);\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n categories: createCategoryEntity({\n entityName: ENTITIES.CATEGORIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.CATEGORIES] : {}\n }),\n menus: createMenuEntity({\n entityName: ENTITIES.MENUS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MENUS] : {}\n }),\n pageElements: createPageElementEntity({\n entityName: ENTITIES.PAGE_ELEMENTS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.PAGE_ELEMENTS] : {}\n }),\n pages: createPageEntity({\n entityName: ENTITIES.PAGES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.PAGES] : {}\n }),\n pagesEs: createPageElasticsearchEntity({\n entityName: ENTITIES.PAGES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.PAGES_ES] : {}\n })\n };\n\n return {\n init: async context => {\n context.i18n.locales.onBeforeCreate.subscribe(async ({ locale, tenant }) => {\n await createElasticsearchIndex({\n elasticsearch,\n plugins,\n locale: locale.code,\n tenant\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n categories: createCategoryStorageOperations({\n entity: entities.categories,\n plugins\n }),\n menus: createMenuStorageOperations({\n entity: entities.menus,\n plugins\n }),\n pageElements: createPageElementStorageOperations({\n entity: entities.pageElements,\n plugins\n }),\n pages: createPageStorageOperations({\n entity: entities.pages,\n esEntity: entities.pagesEs,\n elasticsearch,\n plugins\n })\n };\n};\n"],"mappings":"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"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { CategoryStorageOperationsDdbEs } from "./CategoryStorageOperations";
|
|
2
1
|
import { Category } from "@webiny/api-page-builder/types";
|
|
2
|
+
import { Entity } from "dynamodb-toolbox";
|
|
3
3
|
interface Params {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
interface DataLoaderGetItem {
|
|
7
|
-
slug: string;
|
|
8
|
-
tenant: string;
|
|
9
|
-
locale: string;
|
|
4
|
+
entity: Entity<any>;
|
|
10
5
|
}
|
|
6
|
+
declare type DataLoaderGetItem = Pick<Category, "slug" | "tenant" | "locale">;
|
|
11
7
|
export declare class CategoryDataLoader {
|
|
12
|
-
private readonly storageOperations;
|
|
13
8
|
private _getDataLoader;
|
|
9
|
+
private readonly entity;
|
|
14
10
|
constructor(params: Params);
|
|
15
11
|
getOne(item: DataLoaderGetItem): Promise<Category>;
|
|
16
12
|
getAll(items: DataLoaderGetItem[]): Promise<Category[]>;
|
|
@@ -15,11 +15,13 @@ var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
|
15
15
|
|
|
16
16
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
17
|
|
|
18
|
+
var _keys = require("./keys");
|
|
19
|
+
|
|
18
20
|
class CategoryDataLoader {
|
|
19
21
|
constructor(params) {
|
|
20
|
-
(0, _defineProperty2.default)(this, "
|
|
21
|
-
(0, _defineProperty2.default)(this, "
|
|
22
|
-
this.
|
|
22
|
+
(0, _defineProperty2.default)(this, "_getDataLoader", undefined);
|
|
23
|
+
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
24
|
+
this.entity = params.entity;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
async getOne(item) {
|
|
@@ -42,13 +44,13 @@ class CategoryDataLoader {
|
|
|
42
44
|
|
|
43
45
|
this._getDataLoader = new _dataloader.default(async items => {
|
|
44
46
|
const batched = items.map(item => {
|
|
45
|
-
return this.
|
|
46
|
-
PK:
|
|
47
|
-
SK:
|
|
47
|
+
return this.entity.getBatch({
|
|
48
|
+
PK: (0, _keys.createPartitionKey)(item),
|
|
49
|
+
SK: (0, _keys.createSortKey)(item)
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
52
|
const records = await (0, _batchRead.batchReadAll)({
|
|
51
|
-
table: this.
|
|
53
|
+
table: this.entity.table,
|
|
52
54
|
items: batched
|
|
53
55
|
});
|
|
54
56
|
const results = records.reduce((collection, result) => {
|
|
@@ -57,7 +59,7 @@ class CategoryDataLoader {
|
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
const key = cacheKeyFn(result);
|
|
60
|
-
collection[key] = (0, _cleanup.cleanupItem)(this.
|
|
62
|
+
collection[key] = (0, _cleanup.cleanupItem)(this.entity, result);
|
|
61
63
|
return collection;
|
|
62
64
|
}, {});
|
|
63
65
|
return items.map(item => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CategoryDataLoader","constructor","params","undefined","entity","getOne","item","getDataLoader","load","getAll","items","loadMany","clear","clearAll","_getDataLoader","cacheKeyFn","key","tenant","locale","slug","DataLoader","batched","map","getBatch","PK","createPartitionKey","SK","createSortKey","records","batchReadAll","table","results","reduce","collection","result","cleanupItem"],"sources":["dataLoader.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { Category } from \"@webiny/api-page-builder/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { createPartitionKey, createSortKey } from \"./keys\";\n\ninterface Params {\n entity: Entity<any>;\n}\n\ntype DataLoaderGetItem = Pick<Category, \"slug\" | \"tenant\" | \"locale\">;\n\nexport class CategoryDataLoader {\n private _getDataLoader: DataLoader<any, any> | undefined = undefined;\n\n private readonly entity: Entity<any>;\n\n constructor(params: Params) {\n this.entity = params.entity;\n }\n\n public async getOne(item: DataLoaderGetItem): Promise<Category> {\n return await this.getDataLoader().load(item);\n }\n\n public async getAll(items: DataLoaderGetItem[]): Promise<Category[]> {\n return await this.getDataLoader().loadMany(items);\n }\n\n public clear(): void {\n this.getDataLoader().clearAll();\n }\n\n private getDataLoader(): DataLoader<any, any> {\n if (!this._getDataLoader) {\n const cacheKeyFn = (key: DataLoaderGetItem) => {\n return `T#${key.tenant}#L#${key.locale}#${key.slug}`;\n };\n this._getDataLoader = new DataLoader(\n async items => {\n const batched = items.map(item => {\n return this.entity.getBatch({\n PK: createPartitionKey(item),\n SK: createSortKey(item)\n });\n });\n\n const records = await batchReadAll<Category>({\n table: this.entity.table,\n items: batched\n });\n\n const results = records.reduce((collection, result) => {\n if (!result) {\n return collection;\n }\n const key = cacheKeyFn(result);\n collection[key] = cleanupItem(this.entity, result) as Category;\n return collection;\n }, {} as Record<string, Category>);\n return items.map(item => {\n const key = cacheKeyFn(item);\n return results[key] || null;\n });\n },\n {\n cacheKeyFn\n }\n );\n }\n return this._getDataLoader;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;AAQO,MAAMA,kBAAN,CAAyB;EAK5BC,WAAW,CAACC,MAAD,EAAiB;IAAA,sDAJ+BC,SAI/B;IAAA;IACxB,KAAKC,MAAL,GAAcF,MAAM,CAACE,MAArB;EACH;;EAEkB,MAANC,MAAM,CAACC,IAAD,EAA6C;IAC5D,OAAO,MAAM,KAAKC,aAAL,GAAqBC,IAArB,CAA0BF,IAA1B,CAAb;EACH;;EAEkB,MAANG,MAAM,CAACC,KAAD,EAAkD;IACjE,OAAO,MAAM,KAAKH,aAAL,GAAqBI,QAArB,CAA8BD,KAA9B,CAAb;EACH;;EAEME,KAAK,GAAS;IACjB,KAAKL,aAAL,GAAqBM,QAArB;EACH;;EAEON,aAAa,GAAyB;IAC1C,IAAI,CAAC,KAAKO,cAAV,EAA0B;MACtB,MAAMC,UAAU,GAAIC,GAAD,IAA4B;QAC3C,OAAQ,KAAIA,GAAG,CAACC,MAAO,MAAKD,GAAG,CAACE,MAAO,IAAGF,GAAG,CAACG,IAAK,EAAnD;MACH,CAFD;;MAGA,KAAKL,cAAL,GAAsB,IAAIM,mBAAJ,CAClB,MAAMV,KAAN,IAAe;QACX,MAAMW,OAAO,GAAGX,KAAK,CAACY,GAAN,CAAUhB,IAAI,IAAI;UAC9B,OAAO,KAAKF,MAAL,CAAYmB,QAAZ,CAAqB;YACxBC,EAAE,EAAE,IAAAC,wBAAA,EAAmBnB,IAAnB,CADoB;YAExBoB,EAAE,EAAE,IAAAC,mBAAA,EAAcrB,IAAd;UAFoB,CAArB,CAAP;QAIH,CALe,CAAhB;QAOA,MAAMsB,OAAO,GAAG,MAAM,IAAAC,uBAAA,EAAuB;UACzCC,KAAK,EAAE,KAAK1B,MAAL,CAAY0B,KADsB;UAEzCpB,KAAK,EAAEW;QAFkC,CAAvB,CAAtB;QAKA,MAAMU,OAAO,GAAGH,OAAO,CAACI,MAAR,CAAe,CAACC,UAAD,EAAaC,MAAb,KAAwB;UACnD,IAAI,CAACA,MAAL,EAAa;YACT,OAAOD,UAAP;UACH;;UACD,MAAMjB,GAAG,GAAGD,UAAU,CAACmB,MAAD,CAAtB;UACAD,UAAU,CAACjB,GAAD,CAAV,GAAkB,IAAAmB,oBAAA,EAAY,KAAK/B,MAAjB,EAAyB8B,MAAzB,CAAlB;UACA,OAAOD,UAAP;QACH,CAPe,EAOb,EAPa,CAAhB;QAQA,OAAOvB,KAAK,CAACY,GAAN,CAAUhB,IAAI,IAAI;UACrB,MAAMU,GAAG,GAAGD,UAAU,CAACT,IAAD,CAAtB;UACA,OAAOyB,OAAO,CAACf,GAAD,CAAP,IAAgB,IAAvB;QACH,CAHM,CAAP;MAIH,CA1BiB,EA2BlB;QACID;MADJ,CA3BkB,CAAtB;IA+BH;;IACD,OAAO,KAAKD,cAAZ;EACH;;AA3D2B"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { CategoryDynamoDbElasticFieldPlugin } from "../../plugins/definitions/CategoryDynamoDbElasticFieldPlugin";
|
|
2
|
-
declare const
|
|
3
|
-
export default _default;
|
|
2
|
+
export declare const createCategoryDynamoDbFields: () => CategoryDynamoDbElasticFieldPlugin[];
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createCategoryDynamoDbFields = void 0;
|
|
7
7
|
|
|
8
8
|
var _CategoryDynamoDbElasticFieldPlugin = require("../../plugins/definitions/CategoryDynamoDbElasticFieldPlugin");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const createCategoryDynamoDbFields = () => {
|
|
11
11
|
return [new _CategoryDynamoDbElasticFieldPlugin.CategoryDynamoDbElasticFieldPlugin({
|
|
12
12
|
field: "id"
|
|
13
13
|
}), new _CategoryDynamoDbElasticFieldPlugin.CategoryDynamoDbElasticFieldPlugin({
|
|
@@ -25,4 +25,4 @@ var _default = () => {
|
|
|
25
25
|
})];
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
exports.
|
|
28
|
+
exports.createCategoryDynamoDbFields = createCategoryDynamoDbFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createCategoryDynamoDbFields","CategoryDynamoDbElasticFieldPlugin","field","type","path"],"sources":["fields.ts"],"sourcesContent":["import { CategoryDynamoDbElasticFieldPlugin } from \"~/plugins/definitions/CategoryDynamoDbElasticFieldPlugin\";\n\nexport const createCategoryDynamoDbFields = (): CategoryDynamoDbElasticFieldPlugin[] => {\n return [\n new CategoryDynamoDbElasticFieldPlugin({\n field: \"id\"\n }),\n new CategoryDynamoDbElasticFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new CategoryDynamoDbElasticFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n }),\n new CategoryDynamoDbElasticFieldPlugin({\n field: \"publishedOn\",\n type: \"date\"\n }),\n new CategoryDynamoDbElasticFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n })\n ];\n};\n"],"mappings":";;;;;;;AAAA;;AAEO,MAAMA,4BAA4B,GAAG,MAA4C;EACpF,OAAO,CACH,IAAIC,sEAAJ,CAAuC;IACnCC,KAAK,EAAE;EAD4B,CAAvC,CADG,EAIH,IAAID,sEAAJ,CAAuC;IACnCC,KAAK,EAAE,WAD4B;IAEnCC,IAAI,EAAE;EAF6B,CAAvC,CAJG,EAQH,IAAIF,sEAAJ,CAAuC;IACnCC,KAAK,EAAE,SAD4B;IAEnCC,IAAI,EAAE;EAF6B,CAAvC,CARG,EAYH,IAAIF,sEAAJ,CAAuC;IACnCC,KAAK,EAAE,aAD4B;IAEnCC,IAAI,EAAE;EAF6B,CAAvC,CAZG,EAgBH,IAAIF,sEAAJ,CAAuC;IACnCC,KAAK,EAAE,WAD4B;IAEnCE,IAAI,EAAE;EAF6B,CAAvC,CAhBG,CAAP;AAqBH,CAtBM"}
|