@webiny/api-headless-cms-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 +35 -0
- package/configurations.d.ts +12 -0
- package/configurations.js +32 -0
- package/definitions/entry.d.ts +8 -0
- package/definitions/entry.js +91 -0
- package/definitions/entryElasticsearch.d.ts +8 -0
- package/definitions/entryElasticsearch.js +46 -0
- package/definitions/group.d.ts +8 -0
- package/definitions/group.js +74 -0
- package/definitions/model.d.ts +8 -0
- package/definitions/model.js +96 -0
- package/definitions/settings.d.ts +8 -0
- package/definitions/settings.js +62 -0
- package/definitions/system.d.ts +8 -0
- package/definitions/system.js +50 -0
- package/definitions/table.d.ts +8 -0
- package/definitions/table.js +24 -0
- package/definitions/tableElasticsearch.d.ts +8 -0
- package/definitions/tableElasticsearch.js +24 -0
- package/dynamoDb/index.d.ts +2 -0
- package/dynamoDb/index.js +18 -0
- package/dynamoDb/storage/date.d.ts +3 -0
- package/dynamoDb/storage/date.js +65 -0
- package/dynamoDb/storage/longText.d.ts +7 -0
- package/dynamoDb/storage/longText.js +83 -0
- package/dynamoDb/storage/richText.d.ts +8 -0
- package/dynamoDb/storage/richText.js +110 -0
- package/elasticsearch/index.d.ts +2 -0
- package/elasticsearch/index.js +16 -0
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +89 -0
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
- package/elasticsearch/indexing/index.d.ts +2 -0
- package/elasticsearch/indexing/index.js +24 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +3 -0
- package/elasticsearch/indexing/longTextIndexing.js +36 -0
- package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
- package/elasticsearch/indexing/numberIndexing.js +48 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +3 -0
- package/elasticsearch/indexing/objectIndexing.js +200 -0
- package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
- package/elasticsearch/indexing/richTextIndexing.js +34 -0
- package/elasticsearch/search/index.d.ts +3 -0
- package/elasticsearch/search/index.js +16 -0
- package/elasticsearch/search/refSearch.d.ts +3 -0
- package/elasticsearch/search/refSearch.js +24 -0
- package/elasticsearch/search/timeSearch.d.ts +3 -0
- package/elasticsearch/search/timeSearch.js +25 -0
- package/helpers/createElasticsearchQueryBody.d.ts +11 -0
- package/helpers/createElasticsearchQueryBody.js +375 -0
- package/helpers/entryIndexHelpers.d.ts +18 -0
- package/helpers/entryIndexHelpers.js +189 -0
- package/helpers/fields.d.ts +77 -0
- package/helpers/fields.js +174 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +31 -0
- package/helpers/operatorPluginsList.d.ts +7 -0
- package/helpers/operatorPluginsList.js +30 -0
- package/helpers/searchPluginsList.d.ts +6 -0
- package/helpers/searchPluginsList.js +26 -0
- package/helpers/transformValueForSearch.d.ts +9 -0
- package/helpers/transformValueForSearch.js +26 -0
- package/index.d.ts +2 -0
- package/index.js +171 -0
- package/operations/entry/dataLoaders.d.ts +47 -0
- package/operations/entry/dataLoaders.js +347 -0
- package/operations/entry/elasticsearchFields.d.ts +2 -0
- package/operations/entry/elasticsearchFields.js +32 -0
- package/operations/entry/fields.d.ts +3 -0
- package/operations/entry/fields.js +60 -0
- package/operations/entry/index.d.ts +13 -0
- package/operations/entry/index.js +1152 -0
- package/operations/entry/keys.d.ts +12 -0
- package/operations/entry/keys.js +40 -0
- package/operations/group/index.d.ts +8 -0
- package/operations/group/index.js +202 -0
- package/operations/model/index.d.ts +8 -0
- package/operations/model/index.js +205 -0
- package/operations/settings/index.d.ts +6 -0
- package/operations/settings/index.js +141 -0
- package/operations/system/createElasticsearchTemplate.d.ts +5 -0
- package/operations/system/createElasticsearchTemplate.js +62 -0
- package/operations/system/index.d.ts +6 -0
- package/operations/system/index.js +105 -0
- package/package.json +73 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
- package/types.d.ts +191 -0
- package/types.js +60 -0
- package/upgrades/index.d.ts +2 -0
- package/upgrades/index.js +16 -0
- package/upgrades/utils.d.ts +1 -0
- package/upgrades/utils.js +16 -0
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +6 -0
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +16 -0
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +2 -0
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +12 -0
- package/upgrades/v5.0.0/entryValueFixer.d.ts +4 -0
- package/upgrades/v5.0.0/entryValueFixer.js +124 -0
- package/upgrades/v5.0.0/fieldFinder.d.ts +6 -0
- package/upgrades/v5.0.0/fieldFinder.js +42 -0
- package/upgrades/v5.0.0/helpers.d.ts +4 -0
- package/upgrades/v5.0.0/helpers.js +57 -0
- package/upgrades/v5.0.0/index.d.ts +4 -0
- package/upgrades/v5.0.0/index.js +232 -0
- package/upgrades/v5.8.0/index.d.ts +4 -0
- package/upgrades/v5.8.0/index.js +426 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createSystemStorageOperations = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
14
|
+
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
+
|
|
16
|
+
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
const createPartitionKey = ({
|
|
23
|
+
tenant
|
|
24
|
+
}) => {
|
|
25
|
+
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const createSortKey = () => {
|
|
29
|
+
return "CMS";
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const createKeys = params => {
|
|
33
|
+
return {
|
|
34
|
+
PK: createPartitionKey(params),
|
|
35
|
+
SK: createSortKey()
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const createSystemStorageOperations = params => {
|
|
40
|
+
const {
|
|
41
|
+
entity
|
|
42
|
+
} = params;
|
|
43
|
+
|
|
44
|
+
const create = async ({
|
|
45
|
+
system
|
|
46
|
+
}) => {
|
|
47
|
+
const keys = createKeys(system);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
51
|
+
return system;
|
|
52
|
+
} catch (ex) {
|
|
53
|
+
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
54
|
+
error: ex,
|
|
55
|
+
system,
|
|
56
|
+
keys
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const update = async params => {
|
|
62
|
+
const {
|
|
63
|
+
system,
|
|
64
|
+
original
|
|
65
|
+
} = params;
|
|
66
|
+
const keys = createKeys(system);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
await entity.put(_objectSpread(_objectSpread({}, system), keys));
|
|
70
|
+
return system;
|
|
71
|
+
} catch (ex) {
|
|
72
|
+
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
|
+
error: ex,
|
|
74
|
+
system,
|
|
75
|
+
original,
|
|
76
|
+
keys
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const get = async params => {
|
|
82
|
+
const keys = createKeys(params);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const system = await (0, _get.get)({
|
|
86
|
+
entity,
|
|
87
|
+
keys
|
|
88
|
+
});
|
|
89
|
+
return (0, _cleanup.cleanupItem)(entity, system);
|
|
90
|
+
} catch (ex) {
|
|
91
|
+
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
92
|
+
error: ex,
|
|
93
|
+
keys
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
create,
|
|
100
|
+
update,
|
|
101
|
+
get
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
exports.createSystemStorageOperations = createSystemStorageOperations;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
+
"version": "0.0.0-mt-1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"@webiny/api-headless-cms",
|
|
7
|
+
"storage-operations",
|
|
8
|
+
"dynamodb",
|
|
9
|
+
"elasticsearch",
|
|
10
|
+
"cms:ddb-es"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/webiny/webiny-js.git",
|
|
15
|
+
"directory": "packages/api-headless-cms-ddb-es"
|
|
16
|
+
},
|
|
17
|
+
"description": "DynamoDB and Elasticsearch storage operations plugin for Headless CMS API.",
|
|
18
|
+
"contributors": [
|
|
19
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
20
|
+
"Sven Al Hamad <sven@webiny.com>",
|
|
21
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
22
|
+
],
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@babel/runtime": "7.15.4",
|
|
26
|
+
"@webiny/api-headless-cms": "0.0.0-mt-1",
|
|
27
|
+
"@webiny/api-upgrade": "0.0.0-mt-1",
|
|
28
|
+
"@webiny/db-dynamodb": "0.0.0-mt-1",
|
|
29
|
+
"@webiny/error": "0.0.0-mt-1",
|
|
30
|
+
"@webiny/handler": "0.0.0-mt-1",
|
|
31
|
+
"@webiny/handler-aws": "0.0.0-mt-1",
|
|
32
|
+
"@webiny/handler-db": "0.0.0-mt-1",
|
|
33
|
+
"@webiny/plugins": "0.0.0-mt-1",
|
|
34
|
+
"@webiny/utils": "0.0.0-mt-1",
|
|
35
|
+
"dataloader": "2.0.0",
|
|
36
|
+
"dynamodb-toolbox": "0.3.4",
|
|
37
|
+
"jsonpack": "1.1.5",
|
|
38
|
+
"lodash.chunk": "4.2.0",
|
|
39
|
+
"lodash.clonedeep": "4.5.0",
|
|
40
|
+
"lodash.omit": "4.5.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@babel/cli": "^7.5.5",
|
|
44
|
+
"@babel/core": "^7.5.5",
|
|
45
|
+
"@babel/preset-env": "^7.5.5",
|
|
46
|
+
"@babel/preset-flow": "^7.0.0",
|
|
47
|
+
"@elastic/elasticsearch": "7.12.0",
|
|
48
|
+
"@shelf/jest-elasticsearch": "^1.0.0",
|
|
49
|
+
"@types/jsonpack": "^1.1.0",
|
|
50
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-mt-1",
|
|
51
|
+
"@webiny/api-elasticsearch": "^0.0.0-mt-1",
|
|
52
|
+
"@webiny/cli": "^0.0.0-mt-1",
|
|
53
|
+
"@webiny/project-utils": "^0.0.0-mt-1",
|
|
54
|
+
"jest": "^26.6.3",
|
|
55
|
+
"jest-dynalite": "^3.2.0",
|
|
56
|
+
"jest-environment-node": "^26.6.2",
|
|
57
|
+
"mdbid": "^1.0.0",
|
|
58
|
+
"prettier": "^2.3.2",
|
|
59
|
+
"rimraf": "^3.0.2",
|
|
60
|
+
"sinon": "^9.0.2",
|
|
61
|
+
"ttypescript": "^1.5.12",
|
|
62
|
+
"typescript": "^4.1.3"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"directory": "dist"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "yarn webiny run build",
|
|
70
|
+
"watch": "yarn webiny run watch"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "37736d8456a6ecb342a6c3645060bd9a3f2d4bb0"
|
|
73
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElasticsearchBodyModifierPlugin, ModifyBodyCallable, ModifyBodyParams as BaseModifyBodyParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchBodyModifierPlugin";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface ModifyBodyParams extends BaseModifyBodyParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
}
|
|
6
|
+
export interface Config {
|
|
7
|
+
modifyBody: ModifyBodyCallable<ModifyBodyParams>;
|
|
8
|
+
/**
|
|
9
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
10
|
+
*/
|
|
11
|
+
modelId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CmsEntryElasticsearchBodyModifierPlugin extends ElasticsearchBodyModifierPlugin<ModifyBodyParams> {
|
|
14
|
+
static readonly type: string;
|
|
15
|
+
readonly modelId?: string;
|
|
16
|
+
constructor(config: Config);
|
|
17
|
+
}
|
|
@@ -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.CmsEntryElasticsearchBodyModifierPlugin = 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 CmsEntryElasticsearchBodyModifierPlugin extends _ElasticsearchBodyModifierPlugin.ElasticsearchBodyModifierPlugin {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config.modifyBody);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = config.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchBodyModifierPlugin = CmsEntryElasticsearchBodyModifierPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchBodyModifierPlugin, "type", "cms.elasticsearch.modifier.body.entry");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElasticsearchFieldPlugin, Params as BaseParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin";
|
|
2
|
+
export interface Params extends BaseParams {
|
|
3
|
+
/**
|
|
4
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
5
|
+
*/
|
|
6
|
+
modelId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class CmsEntryElasticsearchFieldPlugin extends ElasticsearchFieldPlugin {
|
|
9
|
+
static readonly type: string;
|
|
10
|
+
readonly modelId?: string;
|
|
11
|
+
constructor(params: Params);
|
|
12
|
+
}
|
|
@@ -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.CmsEntryElasticsearchFieldPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _ElasticsearchFieldPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchFieldPlugin");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchFieldPlugin extends _ElasticsearchFieldPlugin.ElasticsearchFieldPlugin {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super(params);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = params.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchFieldPlugin = CmsEntryElasticsearchFieldPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchFieldPlugin, "type", "elasticsearch.fieldDefinition.cms.entry");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElasticsearchQueryModifierPlugin, ModifyQueryCallable, ModifyQueryParams as BaseModifyQueryParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryModifierPlugin";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface ModifyQueryParams extends BaseModifyQueryParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
}
|
|
6
|
+
export interface Config {
|
|
7
|
+
modifyQuery: ModifyQueryCallable<ModifyQueryParams>;
|
|
8
|
+
/**
|
|
9
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
10
|
+
*/
|
|
11
|
+
modelId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CmsEntryElasticsearchQueryModifierPlugin extends ElasticsearchQueryModifierPlugin<ModifyQueryParams> {
|
|
14
|
+
static readonly type: string;
|
|
15
|
+
readonly modelId?: string;
|
|
16
|
+
constructor(config: Config);
|
|
17
|
+
}
|
|
@@ -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.CmsEntryElasticsearchQueryModifierPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _ElasticsearchQueryModifierPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryModifierPlugin");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchQueryModifierPlugin extends _ElasticsearchQueryModifierPlugin.ElasticsearchQueryModifierPlugin {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config.modifyQuery);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = config.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchQueryModifierPlugin = CmsEntryElasticsearchQueryModifierPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchQueryModifierPlugin, "type", "cms.elasticsearch.modifier.query.entry");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElasticsearchSortModifierPlugin, ModifySortCallable, ModifySortParams as BaseModifySortParams } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchSortModifierPlugin";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface ModifySortParams extends BaseModifySortParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
}
|
|
6
|
+
export interface Config {
|
|
7
|
+
modifySort: ModifySortCallable<ModifySortParams>;
|
|
8
|
+
/**
|
|
9
|
+
* If modelId is not passed, there is no filtering of plugins by it when plugin is applied during the runtime.
|
|
10
|
+
*/
|
|
11
|
+
modelId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CmsEntryElasticsearchSortModifierPlugin extends ElasticsearchSortModifierPlugin<ModifySortParams> {
|
|
14
|
+
static readonly type: string;
|
|
15
|
+
readonly modelId?: string;
|
|
16
|
+
constructor(config: Config);
|
|
17
|
+
}
|
|
@@ -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.CmsEntryElasticsearchSortModifierPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _ElasticsearchSortModifierPlugin = require("@webiny/api-elasticsearch/plugins/definition/ElasticsearchSortModifierPlugin");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchSortModifierPlugin extends _ElasticsearchSortModifierPlugin.ElasticsearchSortModifierPlugin {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(config.modifySort);
|
|
17
|
+
(0, _defineProperty2.default)(this, "modelId", void 0);
|
|
18
|
+
this.modelId = config.modelId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.CmsEntryElasticsearchSortModifierPlugin = CmsEntryElasticsearchSortModifierPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchSortModifierPlugin, "type", "cms.elasticsearch.modifier.sort.entry");
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
+
import { CmsEntry, CmsModel, CmsModelField, CmsModelFieldToGraphQLPlugin, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import { DynamoDBTypes, TableConstructor } from "dynamodb-toolbox/dist/classes/Table";
|
|
4
|
+
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
5
|
+
import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
|
|
6
|
+
import { Client } from "@elastic/elasticsearch";
|
|
7
|
+
import { Entity, Table } from "dynamodb-toolbox";
|
|
8
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
9
|
+
/**
|
|
10
|
+
* Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
|
|
11
|
+
*
|
|
12
|
+
* @see ElasticsearchQueryBuilderValueSearchPlugin.transform
|
|
13
|
+
*/
|
|
14
|
+
interface ElasticsearchQueryBuilderValueSearchPluginArgs {
|
|
15
|
+
field: CmsModelField;
|
|
16
|
+
value: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A plugin definition for transforming the search value for Elasticsearch.
|
|
20
|
+
*
|
|
21
|
+
* @category Plugin
|
|
22
|
+
* @category Elasticsearch
|
|
23
|
+
*/
|
|
24
|
+
export interface ElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
|
|
25
|
+
/**
|
|
26
|
+
* A plugin type.
|
|
27
|
+
*/
|
|
28
|
+
type: "cms-elastic-search-query-builder-value-search";
|
|
29
|
+
/**
|
|
30
|
+
* A field type for plugin to target.
|
|
31
|
+
*/
|
|
32
|
+
fieldType: string;
|
|
33
|
+
/**
|
|
34
|
+
* Transform value that is going to be searched for in the Elasticsearch.
|
|
35
|
+
*/
|
|
36
|
+
transform: (args: ElasticsearchQueryBuilderValueSearchPluginArgs) => any;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A definition of the entry that is being prepared for the Elasticsearch.
|
|
40
|
+
*
|
|
41
|
+
* @category Elasticsearch
|
|
42
|
+
* @category CmsEntry
|
|
43
|
+
*/
|
|
44
|
+
export interface CmsIndexEntry extends CmsEntry {
|
|
45
|
+
/**
|
|
46
|
+
* Values that are not going to be indexed.
|
|
47
|
+
*/
|
|
48
|
+
rawValues: Record<string, any>;
|
|
49
|
+
/**
|
|
50
|
+
* A first part of the ID, without the revision.
|
|
51
|
+
* For example, we can search for all the revisions of the given entry.
|
|
52
|
+
*/
|
|
53
|
+
primaryId: string;
|
|
54
|
+
/**
|
|
55
|
+
* Dev can add what ever keys they want and need. Just need to be careful not to break the entry.
|
|
56
|
+
*/
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.
|
|
61
|
+
*
|
|
62
|
+
* @category Elasticsearch
|
|
63
|
+
* @category CmsEntry
|
|
64
|
+
*/
|
|
65
|
+
interface CmsModelFieldToElasticsearchToParams {
|
|
66
|
+
plugins: PluginsContainer;
|
|
67
|
+
model: CmsModel;
|
|
68
|
+
field: CmsModelField;
|
|
69
|
+
/**
|
|
70
|
+
* Raw value on the entry - before prepare for storage.
|
|
71
|
+
*/
|
|
72
|
+
rawValue: any;
|
|
73
|
+
/**
|
|
74
|
+
* Value prepared for storage received from base api-headless-cms package.
|
|
75
|
+
*/
|
|
76
|
+
value: any;
|
|
77
|
+
getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;
|
|
78
|
+
getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Arguments for the method that is transforming content entry from Elasticsearch into the original one.
|
|
82
|
+
*
|
|
83
|
+
* @category Elasticsearch
|
|
84
|
+
* @category CmsEntry
|
|
85
|
+
*/
|
|
86
|
+
interface CmsModelFieldToElasticsearchFromParams {
|
|
87
|
+
plugins: PluginsContainer;
|
|
88
|
+
model: CmsModel;
|
|
89
|
+
field: CmsModelField;
|
|
90
|
+
value: any;
|
|
91
|
+
rawValue: any;
|
|
92
|
+
getFieldIndexPlugin(fieldType: string): CmsModelFieldToElasticsearchPlugin;
|
|
93
|
+
getFieldTypePlugin(fieldType: string): CmsModelFieldToGraphQLPlugin;
|
|
94
|
+
}
|
|
95
|
+
interface ToIndexValue {
|
|
96
|
+
/**
|
|
97
|
+
* Use this key to store value for indexing.
|
|
98
|
+
*/
|
|
99
|
+
value?: any;
|
|
100
|
+
/**
|
|
101
|
+
* Use this key to tell ES that this value should not be indexed.
|
|
102
|
+
*/
|
|
103
|
+
rawValue?: any;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A plugin defining transformation of entry for Elasticsearch.
|
|
107
|
+
*
|
|
108
|
+
* @category Plugin
|
|
109
|
+
* @category ContentModelField
|
|
110
|
+
* @category CmsEntry
|
|
111
|
+
* @category Elasticsearch
|
|
112
|
+
*/
|
|
113
|
+
export interface CmsModelFieldToElasticsearchPlugin extends Plugin {
|
|
114
|
+
/**
|
|
115
|
+
* A plugin type
|
|
116
|
+
*/
|
|
117
|
+
type: "cms-model-field-to-elastic-search";
|
|
118
|
+
/**
|
|
119
|
+
* A unique identifier of the field type (text, number, json, myField, ...).
|
|
120
|
+
*
|
|
121
|
+
* ```ts
|
|
122
|
+
* fieldType: "myField"
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
fieldType: string;
|
|
126
|
+
/**
|
|
127
|
+
* If you need to define a type when building an Elasticsearch query.
|
|
128
|
+
* Check [dateTimeIndexing](https://github.com/webiny/webiny-js/blob/3074165701b8b45e5fc6ac2444caace7d04ada66/packages/api-headless-cms/src/content/plugins/es/indexing/dateTimeIndexing.ts) plugin for usage example.
|
|
129
|
+
*
|
|
130
|
+
* ```ts
|
|
131
|
+
* unmappedType: "date"
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
unmappedType?: (field: CmsModelField) => string;
|
|
135
|
+
/**
|
|
136
|
+
* This is meant to do some transformation of the entry, preferably only to fieldType it was defined for. Nothing is stopping you to do anything you want to other fields, but try to separate field transformations.
|
|
137
|
+
* It returns `Partial<CmsContentIndexEntryType>`. Always return a top-level property of the entry since it is merged via spread operator.
|
|
138
|
+
*
|
|
139
|
+
* ```ts
|
|
140
|
+
* toIndex({ value }) {
|
|
141
|
+
* return {
|
|
142
|
+
* value: value, // This will be stored and indexed
|
|
143
|
+
* rawValue: JSON.stringify(value) // This will be stored but excluded from indexing
|
|
144
|
+
* };
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
toIndex?: (params: CmsModelFieldToElasticsearchToParams) => ToIndexValue;
|
|
149
|
+
/**
|
|
150
|
+
* This is meant to revert a transformation done in the `toIndex` method.
|
|
151
|
+
* You have access to "value" or a "rawValue", depending on what you returned from `toIndex`.
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* fromIndex({ value, rawValue }) {
|
|
155
|
+
* return JSON.parse(rawValue);
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
fromIndex?: (params: CmsModelFieldToElasticsearchFromParams) => any;
|
|
160
|
+
}
|
|
161
|
+
export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
|
|
162
|
+
export declare type Attributes = Record<string, AttributeDefinition>;
|
|
163
|
+
export declare enum ENTITIES {
|
|
164
|
+
SYSTEM = "CmsSystem",
|
|
165
|
+
SETTINGS = "CmsSettings",
|
|
166
|
+
GROUPS = "CmsGroups",
|
|
167
|
+
MODELS = "CmsModels",
|
|
168
|
+
ENTRIES = "CmsEntries",
|
|
169
|
+
ENTRIES_ES = "CmsEntriesElasticsearch"
|
|
170
|
+
}
|
|
171
|
+
export interface TableModifier {
|
|
172
|
+
(table: TableConstructor): TableConstructor;
|
|
173
|
+
}
|
|
174
|
+
export interface StorageOperationsFactoryParams {
|
|
175
|
+
documentClient: DocumentClient;
|
|
176
|
+
elasticsearch: Client;
|
|
177
|
+
table?: TableModifier;
|
|
178
|
+
esTable?: TableModifier;
|
|
179
|
+
modelFieldToGraphQLPlugins: CmsModelFieldToGraphQLPlugin[];
|
|
180
|
+
attributes?: Record<ENTITIES, Attributes>;
|
|
181
|
+
plugins?: Plugin[] | Plugin[][];
|
|
182
|
+
}
|
|
183
|
+
export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
|
|
184
|
+
getTable: () => Table;
|
|
185
|
+
getEsTable: () => Table;
|
|
186
|
+
getEntities: () => Record<"system" | "settings" | "groups" | "models" | "entries" | "entriesEs", Entity<any>>;
|
|
187
|
+
}
|
|
188
|
+
export interface StorageOperationsFactory {
|
|
189
|
+
(params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
|
|
190
|
+
}
|
|
191
|
+
export {};
|
package/types.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ENTITIES = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
|
|
10
|
+
*
|
|
11
|
+
* @see ElasticsearchQueryBuilderValueSearchPlugin.transform
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A plugin definition for transforming the search value for Elasticsearch.
|
|
16
|
+
*
|
|
17
|
+
* @category Plugin
|
|
18
|
+
* @category Elasticsearch
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A definition of the entry that is being prepared for the Elasticsearch.
|
|
23
|
+
*
|
|
24
|
+
* @category Elasticsearch
|
|
25
|
+
* @category CmsEntry
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Arguments for the method that is transforming content entry in its original form to the one we are storing to the Elasticsearch.
|
|
30
|
+
*
|
|
31
|
+
* @category Elasticsearch
|
|
32
|
+
* @category CmsEntry
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Arguments for the method that is transforming content entry from Elasticsearch into the original one.
|
|
37
|
+
*
|
|
38
|
+
* @category Elasticsearch
|
|
39
|
+
* @category CmsEntry
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A plugin defining transformation of entry for Elasticsearch.
|
|
44
|
+
*
|
|
45
|
+
* @category Plugin
|
|
46
|
+
* @category ContentModelField
|
|
47
|
+
* @category CmsEntry
|
|
48
|
+
* @category Elasticsearch
|
|
49
|
+
*/
|
|
50
|
+
let ENTITIES;
|
|
51
|
+
exports.ENTITIES = ENTITIES;
|
|
52
|
+
|
|
53
|
+
(function (ENTITIES) {
|
|
54
|
+
ENTITIES["SYSTEM"] = "CmsSystem";
|
|
55
|
+
ENTITIES["SETTINGS"] = "CmsSettings";
|
|
56
|
+
ENTITIES["GROUPS"] = "CmsGroups";
|
|
57
|
+
ENTITIES["MODELS"] = "CmsModels";
|
|
58
|
+
ENTITIES["ENTRIES"] = "CmsEntries";
|
|
59
|
+
ENTITIES["ENTRIES_ES"] = "CmsEntriesElasticsearch";
|
|
60
|
+
})(ENTITIES || (exports.ENTITIES = ENTITIES = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _index = _interopRequireDefault(require("./v5.0.0/index"));
|
|
11
|
+
|
|
12
|
+
var _index2 = _interopRequireDefault(require("./v5.8.0/index"));
|
|
13
|
+
|
|
14
|
+
var _default = () => [(0, _index.default)(), (0, _index2.default)()];
|
|
15
|
+
|
|
16
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const paginateBatch: (items: any, perPage: any, execute: any) => Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.paginateBatch = void 0;
|
|
7
|
+
|
|
8
|
+
const paginateBatch = async (items, perPage, execute) => {
|
|
9
|
+
const pages = Math.ceil(items.length / perPage);
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < pages; i++) {
|
|
12
|
+
await execute(items.slice(i * perPage, i * perPage + perPage));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.paginateBatch = paginateBatch;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.cleanDatabaseRecord = void 0;
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash.omit"));
|
|
11
|
+
|
|
12
|
+
const cleanDatabaseRecord = record => {
|
|
13
|
+
return (0, _lodash.default)(record, ["PK", "SK", "TYPE"]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.cleanDatabaseRecord = cleanDatabaseRecord;
|