@webiny/api-page-builder-so-ddb-es 0.0.0-mt-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/definitions/categoryEntity.d.ts +6 -0
- package/definitions/categoryEntity.js +68 -0
- package/definitions/menuEntity.d.ts +6 -0
- package/definitions/menuEntity.js +68 -0
- package/definitions/pageElasticsearchEntity.d.ts +6 -0
- package/definitions/pageElasticsearchEntity.js +47 -0
- package/definitions/pageElementEntity.d.ts +6 -0
- package/definitions/pageElementEntity.js +74 -0
- package/definitions/pageEntity.d.ts +6 -0
- package/definitions/pageEntity.js +113 -0
- package/definitions/settingsEntity.d.ts +6 -0
- package/definitions/settingsEntity.js +77 -0
- package/definitions/systemEntity.d.ts +6 -0
- package/definitions/systemEntity.js +44 -0
- package/definitions/table.d.ts +6 -0
- package/definitions/table.js +30 -0
- package/definitions/tableElasticsearch.d.ts +5 -0
- package/definitions/tableElasticsearch.js +37 -0
- package/index.d.ts +8 -0
- package/index.js +26 -0
- package/operations/category/CategoryDataLoader.d.ts +20 -0
- package/operations/category/CategoryDataLoader.js +77 -0
- package/operations/category/CategoryStorageOperations.d.ts +29 -0
- package/operations/category/CategoryStorageOperations.js +243 -0
- package/operations/category/fields.d.ts +3 -0
- package/operations/category/fields.js +28 -0
- package/operations/category/index.d.ts +5 -0
- package/operations/category/index.js +28 -0
- package/operations/configurations.d.ts +36 -0
- package/operations/configurations.js +71 -0
- package/operations/menu/MenuStorageOperations.d.ts +23 -0
- package/operations/menu/MenuStorageOperations.js +235 -0
- package/operations/menu/fields.d.ts +3 -0
- package/operations/menu/fields.js +25 -0
- package/operations/menu/index.d.ts +5 -0
- package/operations/menu/index.js +28 -0
- package/operations/pageElement/PageElementStorageOperations.d.ts +23 -0
- package/operations/pageElement/PageElementStorageOperations.js +234 -0
- package/operations/pageElement/fields.d.ts +3 -0
- package/operations/pageElement/fields.js +19 -0
- package/operations/pageElement/index.d.ts +7 -0
- package/operations/pageElement/index.js +28 -0
- package/operations/pages/PageStorageOperations.d.ts +79 -0
- package/operations/pages/PageStorageOperations.js +1117 -0
- package/operations/pages/elasticsearchQueryBody.d.ts +18 -0
- package/operations/pages/elasticsearchQueryBody.js +271 -0
- package/operations/pages/fields.d.ts +3 -0
- package/operations/pages/fields.js +42 -0
- package/operations/pages/helpers.d.ts +42 -0
- package/operations/pages/helpers.js +89 -0
- package/operations/pages/index.d.ts +5 -0
- package/operations/pages/index.js +33 -0
- package/operations/settings/SettingsStorageOperations.d.ts +35 -0
- package/operations/settings/SettingsStorageOperations.js +191 -0
- package/operations/settings/index.d.ts +7 -0
- package/operations/settings/index.js +23 -0
- package/operations/system/InstallationDdbEsPlugin.d.ts +2 -0
- package/operations/system/InstallationDdbEsPlugin.js +73 -0
- package/operations/system/SystemStorageOperations.d.ts +16 -0
- package/operations/system/SystemStorageOperations.js +114 -0
- package/operations/system/index.d.ts +5 -0
- package/operations/system/index.js +29 -0
- package/package.json +65 -0
- package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.d.ts +4 -0
- package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js +17 -0
- package/plugins/definitions/IndexPageDataPlugin.d.ts +18 -0
- package/plugins/definitions/IndexPageDataPlugin.js +32 -0
- package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.d.ts +4 -0
- package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js +17 -0
- package/plugins/definitions/PageElasticsearchBodyModifierPlugin.d.ts +4 -0
- package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js +17 -0
- package/plugins/definitions/PageElasticsearchFieldPlugin.d.ts +5 -0
- package/plugins/definitions/PageElasticsearchFieldPlugin.js +22 -0
- package/plugins/definitions/PageElasticsearchQueryModifierPlugin.d.ts +4 -0
- package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js +17 -0
- package/plugins/definitions/PageElasticsearchSortModifierPlugin.d.ts +4 -0
- package/plugins/definitions/PageElasticsearchSortModifierPlugin.js +17 -0
- package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.d.ts +4 -0
- package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js +17 -0
- package/plugins/definitions/SearchLatestPagesPlugin.d.ts +4 -0
- package/plugins/definitions/SearchLatestPagesPlugin.js +17 -0
- package/plugins/definitions/SearchPagesPlugin.d.ts +24 -0
- package/plugins/definitions/SearchPagesPlugin.js +39 -0
- package/plugins/definitions/SearchPublishedPagesPlugin.d.ts +4 -0
- package/plugins/definitions/SearchPublishedPagesPlugin.js +17 -0
- package/upgrades/index.d.ts +2 -0
- package/upgrades/index.js +14 -0
- package/upgrades/v5.15.0/category.d.ts +2 -0
- package/upgrades/v5.15.0/category.js +75 -0
- package/upgrades/v5.15.0/index.d.ts +4 -0
- package/upgrades/v5.15.0/index.js +52 -0
- package/upgrades/v5.15.0/menu.d.ts +2 -0
- package/upgrades/v5.15.0/menu.js +75 -0
- package/upgrades/v5.15.0/pageElement.d.ts +2 -0
- package/upgrades/v5.15.0/pageElement.js +75 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SettingsStorageOperationsDdbEs = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
var _settingsEntity = require("../../definitions/settingsEntity");
|
|
17
|
+
|
|
18
|
+
var _table = require("../../definitions/table");
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
|
|
24
|
+
const extractFromStorage = settings => {
|
|
25
|
+
return _objectSpread(_objectSpread({}, settings), {}, {
|
|
26
|
+
tenant: !settings.tenant ? false : settings.tenant,
|
|
27
|
+
locale: !settings.locale ? false : settings.locale
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const prepareForStorage = settings => {
|
|
32
|
+
return _objectSpread(_objectSpread({}, settings), {}, {
|
|
33
|
+
tenant: !settings.tenant ? null : settings.tenant,
|
|
34
|
+
locale: !settings.locale ? null : settings.locale
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
class SettingsStorageOperationsDdbEs {
|
|
39
|
+
constructor({
|
|
40
|
+
context
|
|
41
|
+
}) {
|
|
42
|
+
(0, _defineProperty2.default)(this, "context", void 0);
|
|
43
|
+
(0, _defineProperty2.default)(this, "table", void 0);
|
|
44
|
+
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
45
|
+
this.context = context;
|
|
46
|
+
this.table = (0, _table.defineTable)({
|
|
47
|
+
context
|
|
48
|
+
});
|
|
49
|
+
this.entity = (0, _settingsEntity.defineSettingsEntity)({
|
|
50
|
+
context,
|
|
51
|
+
table: this.table
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* We can simply return the partition key for this storage operations.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
createCacheKey(options) {
|
|
60
|
+
return this.createPartitionKey(options);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async get(params) {
|
|
64
|
+
const {
|
|
65
|
+
where
|
|
66
|
+
} = params;
|
|
67
|
+
const keys = {
|
|
68
|
+
PK: this.createPartitionKey(where),
|
|
69
|
+
SK: this.createSortKey(where)
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const result = await this.entity.get(keys);
|
|
74
|
+
|
|
75
|
+
if (!result || !result.Item) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const settings = (0, _cleanup.cleanupItem)(this.entity, result.Item);
|
|
80
|
+
return extractFromStorage(settings);
|
|
81
|
+
} catch (ex) {
|
|
82
|
+
throw new _error.default(ex.message || "Could not load settings record.", ex.code || "SETTINGS_GET_ERROR", {
|
|
83
|
+
keys
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async create(params) {
|
|
89
|
+
const {
|
|
90
|
+
settings
|
|
91
|
+
} = params;
|
|
92
|
+
const keys = {
|
|
93
|
+
PK: this.createPartitionKey(settings),
|
|
94
|
+
SK: this.createSortKey(settings)
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
try {
|
|
98
|
+
await this.entity.put(_objectSpread(_objectSpread({}, prepareForStorage(settings)), {}, {
|
|
99
|
+
TYPE: this.createType()
|
|
100
|
+
}, keys));
|
|
101
|
+
return settings;
|
|
102
|
+
} catch (ex) {
|
|
103
|
+
throw new _error.default(ex.message || "Could not create settings record.", ex.code || "SETTINGS_CREATE_ERROR", {
|
|
104
|
+
settings,
|
|
105
|
+
keys
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async update(params) {
|
|
111
|
+
const {
|
|
112
|
+
original,
|
|
113
|
+
settings
|
|
114
|
+
} = params;
|
|
115
|
+
const keys = {
|
|
116
|
+
PK: this.createPartitionKey(settings),
|
|
117
|
+
SK: this.createSortKey(settings)
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
await this.entity.put(_objectSpread(_objectSpread({}, prepareForStorage(settings)), {}, {
|
|
122
|
+
TYPE: this.createType()
|
|
123
|
+
}, keys));
|
|
124
|
+
return settings;
|
|
125
|
+
} catch (ex) {
|
|
126
|
+
throw new _error.default(ex.message || "Could not update settings record.", ex.code || "SETTINGS_UPDATE_ERROR", {
|
|
127
|
+
original,
|
|
128
|
+
settings,
|
|
129
|
+
keys
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Because it is a possibility that tenant and locale are set as false (for the global settings) we must take
|
|
135
|
+
* it in consideration and create the partition key for the global settings.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
createPartitionKey(options) {
|
|
140
|
+
let {
|
|
141
|
+
tenant,
|
|
142
|
+
locale
|
|
143
|
+
} = options;
|
|
144
|
+
const parts = [];
|
|
145
|
+
|
|
146
|
+
if (tenant !== false) {
|
|
147
|
+
if (!tenant) {
|
|
148
|
+
tenant = this.context.tenancy.getCurrentTenant().id;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
parts.push(`T#${tenant}`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (locale !== false) {
|
|
155
|
+
if (!locale) {
|
|
156
|
+
locale = this.context.i18nContent.getLocale().code;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
parts.push(`L#${locale}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
parts.push("PB#SETTINGS");
|
|
163
|
+
return parts.join("#");
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* We expect any object that has type property in it.
|
|
167
|
+
* This way we can either receive a settings object or where conditions
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
createSortKey({
|
|
172
|
+
type
|
|
173
|
+
}) {
|
|
174
|
+
switch (type) {
|
|
175
|
+
case "default":
|
|
176
|
+
return type;
|
|
177
|
+
|
|
178
|
+
default:
|
|
179
|
+
throw new _error.default("Unsupported type for the sort key.", "UNSUPPORTED_TYPE", {
|
|
180
|
+
type
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
createType() {
|
|
186
|
+
return "pb.settings";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
exports.SettingsStorageOperationsDdbEs = SettingsStorageOperationsDdbEs;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SettingsStorageOperationsProviderPlugin } from "@webiny/api-page-builder/plugins/SettingsStorageOperationsProviderPlugin";
|
|
2
|
+
import { SettingsStorageOperations } from "@webiny/api-page-builder/types";
|
|
3
|
+
export declare class SettingsStorageOperationsDdbEsProviderPlugin extends SettingsStorageOperationsProviderPlugin {
|
|
4
|
+
provide({ context }: {
|
|
5
|
+
context: any;
|
|
6
|
+
}): Promise<SettingsStorageOperations>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SettingsStorageOperationsDdbEsProviderPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
var _SettingsStorageOperationsProviderPlugin = require("@webiny/api-page-builder/plugins/SettingsStorageOperationsProviderPlugin");
|
|
9
|
+
|
|
10
|
+
var _SettingsStorageOperations = require("./SettingsStorageOperations");
|
|
11
|
+
|
|
12
|
+
class SettingsStorageOperationsDdbEsProviderPlugin extends _SettingsStorageOperationsProviderPlugin.SettingsStorageOperationsProviderPlugin {
|
|
13
|
+
async provide({
|
|
14
|
+
context
|
|
15
|
+
}) {
|
|
16
|
+
return new _SettingsStorageOperations.SettingsStorageOperationsDdbEs({
|
|
17
|
+
context
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.SettingsStorageOperationsDdbEsProviderPlugin = SettingsStorageOperationsDdbEsProviderPlugin;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.installation = void 0;
|
|
9
|
+
|
|
10
|
+
var _InstallationPlugin = require("@webiny/api-page-builder/plugins/InstallationPlugin");
|
|
11
|
+
|
|
12
|
+
var _configurations = _interopRequireDefault(require("../configurations"));
|
|
13
|
+
|
|
14
|
+
const installation = () => {
|
|
15
|
+
return new _InstallationPlugin.InstallationPlugin({
|
|
16
|
+
beforeInstall: async params => {
|
|
17
|
+
const {
|
|
18
|
+
context
|
|
19
|
+
} = params;
|
|
20
|
+
const {
|
|
21
|
+
elasticsearch
|
|
22
|
+
} = context;
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
index
|
|
26
|
+
} = _configurations.default.es(context);
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
body: exists
|
|
30
|
+
} = await elasticsearch.indices.exists({
|
|
31
|
+
index
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (exists) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await elasticsearch.indices.create({
|
|
39
|
+
index,
|
|
40
|
+
body: {
|
|
41
|
+
// need this part for sorting to work on text fields
|
|
42
|
+
settings: {
|
|
43
|
+
analysis: {
|
|
44
|
+
analyzer: {
|
|
45
|
+
lowercase_analyzer: {
|
|
46
|
+
type: "custom",
|
|
47
|
+
filter: ["lowercase", "trim"],
|
|
48
|
+
tokenizer: "keyword"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
mappings: {
|
|
54
|
+
properties: {
|
|
55
|
+
property: {
|
|
56
|
+
type: "text",
|
|
57
|
+
fields: {
|
|
58
|
+
keyword: {
|
|
59
|
+
type: "keyword",
|
|
60
|
+
ignore_above: 256
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
analyzer: "lowercase_analyzer"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.installation = installation;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PbContext, System, SystemStorageOperations, SystemStorageOperationsCreateParams, SystemStorageOperationsUpdateParams } from "@webiny/api-page-builder/types";
|
|
2
|
+
import { Entity, Table } from "dynamodb-toolbox";
|
|
3
|
+
export interface Params {
|
|
4
|
+
context: PbContext;
|
|
5
|
+
}
|
|
6
|
+
export declare class SystemStorageOperationsDdbEs implements SystemStorageOperations {
|
|
7
|
+
protected readonly context: PbContext;
|
|
8
|
+
readonly table: Table;
|
|
9
|
+
readonly entity: Entity<any>;
|
|
10
|
+
constructor({ context }: Params);
|
|
11
|
+
get(): Promise<System>;
|
|
12
|
+
create(params: SystemStorageOperationsCreateParams): Promise<System>;
|
|
13
|
+
update(params: SystemStorageOperationsUpdateParams): Promise<System>;
|
|
14
|
+
protected createPartitionKey(): string;
|
|
15
|
+
protected createSortKey(): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.SystemStorageOperationsDdbEs = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
var _systemEntity = require("../../definitions/systemEntity");
|
|
17
|
+
|
|
18
|
+
var _table = require("../../definitions/table");
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
|
|
24
|
+
class SystemStorageOperationsDdbEs {
|
|
25
|
+
constructor({
|
|
26
|
+
context
|
|
27
|
+
}) {
|
|
28
|
+
(0, _defineProperty2.default)(this, "context", void 0);
|
|
29
|
+
(0, _defineProperty2.default)(this, "table", void 0);
|
|
30
|
+
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
31
|
+
this.context = context;
|
|
32
|
+
this.table = (0, _table.defineTable)({
|
|
33
|
+
context
|
|
34
|
+
});
|
|
35
|
+
this.entity = (0, _systemEntity.defineSystemEntity)({
|
|
36
|
+
context,
|
|
37
|
+
table: this.table
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async get() {
|
|
42
|
+
const keys = {
|
|
43
|
+
PK: this.createPartitionKey(),
|
|
44
|
+
SK: this.createSortKey()
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const result = await this.entity.get(keys);
|
|
49
|
+
|
|
50
|
+
if (!result || !result.Item) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (0, _cleanup.cleanupItem)(this.entity, result.Item);
|
|
55
|
+
} catch (ex) {
|
|
56
|
+
throw new _error.default(ex.message || "Could not load system record.", ex.code || "SYSTEM_GET_ERROR", {
|
|
57
|
+
keys
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async create(params) {
|
|
63
|
+
const {
|
|
64
|
+
system
|
|
65
|
+
} = params;
|
|
66
|
+
const keys = {
|
|
67
|
+
PK: this.createPartitionKey(),
|
|
68
|
+
SK: this.createSortKey()
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
await this.entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
73
|
+
return system;
|
|
74
|
+
} catch (ex) {
|
|
75
|
+
throw new _error.default(ex.message || "Could not create system record.", ex.code || "SYSTEM_CREATE_ERROR", {
|
|
76
|
+
system,
|
|
77
|
+
keys
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async update(params) {
|
|
83
|
+
const {
|
|
84
|
+
original,
|
|
85
|
+
system
|
|
86
|
+
} = params;
|
|
87
|
+
const keys = {
|
|
88
|
+
PK: this.createPartitionKey(),
|
|
89
|
+
SK: this.createSortKey()
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
await this.entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
94
|
+
return system;
|
|
95
|
+
} catch (ex) {
|
|
96
|
+
throw new _error.default(ex.message || "Could not update system record.", ex.code || "SYSTEM_UPDATE_ERROR", {
|
|
97
|
+
original,
|
|
98
|
+
system,
|
|
99
|
+
keys
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
createPartitionKey() {
|
|
105
|
+
return `T#${this.context.tenancy.getCurrentTenant().id}#SYSTEM`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
createSortKey() {
|
|
109
|
+
return "PB";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
exports.SystemStorageOperationsDdbEs = SystemStorageOperationsDdbEs;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Params, SystemStorageOperationsProviderPlugin } from "@webiny/api-page-builder/plugins/SystemStorageOperationsProviderPlugin";
|
|
2
|
+
import { SystemStorageOperations } from "@webiny/api-page-builder/types";
|
|
3
|
+
export declare class SystemStorageOperationsDdbEsProviderPlugin extends SystemStorageOperationsProviderPlugin {
|
|
4
|
+
provide({ context }: Params): Promise<SystemStorageOperations>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SystemStorageOperationsDdbEsProviderPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
var _SystemStorageOperationsProviderPlugin = require("@webiny/api-page-builder/plugins/SystemStorageOperationsProviderPlugin");
|
|
9
|
+
|
|
10
|
+
var _SystemStorageOperations = require("./SystemStorageOperations");
|
|
11
|
+
|
|
12
|
+
var _InstallationDdbEsPlugin = require("./InstallationDdbEsPlugin");
|
|
13
|
+
|
|
14
|
+
class SystemStorageOperationsDdbEsProviderPlugin extends _SystemStorageOperationsProviderPlugin.SystemStorageOperationsProviderPlugin {
|
|
15
|
+
async provide({
|
|
16
|
+
context
|
|
17
|
+
}) {
|
|
18
|
+
/**
|
|
19
|
+
* We need the installation plugin to insert the page builder elasticsearch index on before install.
|
|
20
|
+
*/
|
|
21
|
+
context.plugins.register([(0, _InstallationDdbEsPlugin.installation)()]);
|
|
22
|
+
return new _SystemStorageOperations.SystemStorageOperationsDdbEs({
|
|
23
|
+
context
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.SystemStorageOperationsDdbEsProviderPlugin = SystemStorageOperationsDdbEsProviderPlugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-page-builder-so-ddb-es",
|
|
3
|
+
"version": "0.0.0-mt-1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"@webiny/api-page-builder",
|
|
7
|
+
"storage-operations",
|
|
8
|
+
"dynamodb",
|
|
9
|
+
"pb:ddb-es"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
14
|
+
"directory": "packages/api-page-builder-so-ddb-es"
|
|
15
|
+
},
|
|
16
|
+
"author": "Webiny Ltd",
|
|
17
|
+
"description": "The DynamoDB + Elasticsearch storage operations Webiny Page Builder API.",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/runtime": "7.15.4",
|
|
21
|
+
"@webiny/api-elasticsearch": "0.0.0-mt-1",
|
|
22
|
+
"@webiny/api-page-builder": "0.0.0-mt-1",
|
|
23
|
+
"@webiny/api-upgrade": "0.0.0-mt-1",
|
|
24
|
+
"@webiny/db-dynamodb": "0.0.0-mt-1",
|
|
25
|
+
"@webiny/error": "0.0.0-mt-1",
|
|
26
|
+
"@webiny/handler-db": "0.0.0-mt-1",
|
|
27
|
+
"@webiny/plugins": "0.0.0-mt-1",
|
|
28
|
+
"dataloader": "2.0.0",
|
|
29
|
+
"dynamodb-toolbox": "0.3.4",
|
|
30
|
+
"elastic-ts": "0.7.0",
|
|
31
|
+
"lodash": "4.17.21"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/cli": "^7.5.5",
|
|
35
|
+
"@babel/core": "^7.5.5",
|
|
36
|
+
"@babel/preset-env": "^7.5.5",
|
|
37
|
+
"@babel/preset-typescript": "^7.8.3",
|
|
38
|
+
"@elastic/elasticsearch": "7.12.0",
|
|
39
|
+
"@elastic/elasticsearch-mock": "0.3.0",
|
|
40
|
+
"@shelf/jest-elasticsearch": "^1.0.0",
|
|
41
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-mt-1",
|
|
42
|
+
"@webiny/api-security": "^0.0.0-mt-1",
|
|
43
|
+
"@webiny/api-tenancy": "^0.0.0-mt-1",
|
|
44
|
+
"@webiny/cli": "^0.0.0-mt-1",
|
|
45
|
+
"@webiny/handler": "^0.0.0-mt-1",
|
|
46
|
+
"@webiny/handler-aws": "^0.0.0-mt-1",
|
|
47
|
+
"@webiny/handler-graphql": "^0.0.0-mt-1",
|
|
48
|
+
"@webiny/project-utils": "^0.0.0-mt-1",
|
|
49
|
+
"jest": "^26.6.3",
|
|
50
|
+
"jest-dynalite": "^3.2.0",
|
|
51
|
+
"jest-environment-node": "^27.0.6",
|
|
52
|
+
"rimraf": "^3.0.2",
|
|
53
|
+
"ttypescript": "^1.5.12",
|
|
54
|
+
"typescript": "^4.1.3"
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public",
|
|
58
|
+
"directory": "dist"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "yarn webiny run build",
|
|
62
|
+
"watch": "yarn webiny run watch"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "37736d8456a6ecb342a6c3645060bd9a3f2d4bb0"
|
|
65
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CategoryDynamoDbElasticFieldPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _FieldPlugin = require("@webiny/db-dynamodb/plugins/definitions/FieldPlugin");
|
|
13
|
+
|
|
14
|
+
class CategoryDynamoDbElasticFieldPlugin extends _FieldPlugin.FieldPlugin {}
|
|
15
|
+
|
|
16
|
+
exports.CategoryDynamoDbElasticFieldPlugin = CategoryDynamoDbElasticFieldPlugin;
|
|
17
|
+
(0, _defineProperty2.default)(CategoryDynamoDbElasticFieldPlugin, "type", "pageBuilder.dynamodb.es.field.category");
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { PbContext } from "@webiny/api-page-builder/graphql/types";
|
|
3
|
+
import { Page } from "@webiny/api-page-builder/types";
|
|
4
|
+
interface ApplyPageDataParams<TPage> {
|
|
5
|
+
data: Record<string, any>;
|
|
6
|
+
page: TPage;
|
|
7
|
+
context: PbContext;
|
|
8
|
+
}
|
|
9
|
+
interface ApplyPageDataCallable<TPage> {
|
|
10
|
+
(params: ApplyPageDataParams<TPage>): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class IndexPageDataPlugin<TPage extends Page = Page> extends Plugin {
|
|
13
|
+
static readonly type = "pb.elasticsearch.index-page-data";
|
|
14
|
+
private readonly callable;
|
|
15
|
+
constructor(callable: ApplyPageDataCallable<TPage>);
|
|
16
|
+
apply(params: ApplyPageDataParams<TPage>): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.IndexPageDataPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _plugins = require("@webiny/plugins");
|
|
13
|
+
|
|
14
|
+
class IndexPageDataPlugin extends _plugins.Plugin {
|
|
15
|
+
constructor(callable) {
|
|
16
|
+
super();
|
|
17
|
+
(0, _defineProperty2.default)(this, "callable", void 0);
|
|
18
|
+
this.callable = callable;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply(params) {
|
|
22
|
+
if (typeof this.callable !== "function") {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
this.callable(params);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.IndexPageDataPlugin = IndexPageDataPlugin;
|
|
32
|
+
(0, _defineProperty2.default)(IndexPageDataPlugin, "type", "pb.elasticsearch.index-page-data");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.MenuDynamoDbElasticFieldPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _FieldPlugin = require("@webiny/db-dynamodb/plugins/definitions/FieldPlugin");
|
|
13
|
+
|
|
14
|
+
class MenuDynamoDbElasticFieldPlugin extends _FieldPlugin.FieldPlugin {}
|
|
15
|
+
|
|
16
|
+
exports.MenuDynamoDbElasticFieldPlugin = MenuDynamoDbElasticFieldPlugin;
|
|
17
|
+
(0, _defineProperty2.default)(MenuDynamoDbElasticFieldPlugin, "type", "pageBuilder.dynamodb.es.field.menu");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.PageElasticsearchBodyModifierPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _ElasticsearchBodyModifierPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchBodyModifierPlugin");
|
|
13
|
+
|
|
14
|
+
class PageElasticsearchBodyModifierPlugin extends _ElasticsearchBodyModifierPlugin.ElasticsearchBodyModifierPlugin {}
|
|
15
|
+
|
|
16
|
+
exports.PageElasticsearchBodyModifierPlugin = PageElasticsearchBodyModifierPlugin;
|
|
17
|
+
(0, _defineProperty2.default)(PageElasticsearchBodyModifierPlugin, "type", "pageBuilder.elasticsearch.modifier.body.page");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ElasticsearchFieldPlugin, Params } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin";
|
|
2
|
+
export declare class PageElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
|
|
3
|
+
static readonly type: string;
|
|
4
|
+
constructor(params: Params);
|
|
5
|
+
}
|