@webiny/api-headless-cms-ddb 5.37.8 → 5.38.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +0 -10
- package/index.js.map +1 -1
- package/package.json +10 -10
- package/types.d.ts +1 -2
- package/types.js +0 -1
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -55
- package/definitions/settings.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -113
- package/operations/settings/index.js.map +0 -1
package/index.js
CHANGED
|
@@ -12,14 +12,12 @@ var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filte
|
|
|
12
12
|
var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
|
|
13
13
|
var _types = require("./types");
|
|
14
14
|
var _table = require("./definitions/table");
|
|
15
|
-
var _settings = require("./definitions/settings");
|
|
16
15
|
var _system = require("./definitions/system");
|
|
17
16
|
var _group = require("./definitions/group");
|
|
18
17
|
var _model = require("./definitions/model");
|
|
19
18
|
var _entry = require("./definitions/entry");
|
|
20
19
|
var _plugins = require("@webiny/plugins");
|
|
21
20
|
var _system2 = require("./operations/system");
|
|
22
|
-
var _settings2 = require("./operations/settings");
|
|
23
21
|
var _group2 = require("./operations/group");
|
|
24
22
|
var _model2 = require("./operations/model");
|
|
25
23
|
var _entry2 = require("./operations/entry");
|
|
@@ -50,11 +48,6 @@ const createStorageOperations = params => {
|
|
|
50
48
|
documentClient
|
|
51
49
|
});
|
|
52
50
|
const entities = {
|
|
53
|
-
settings: (0, _settings.createSettingsEntity)({
|
|
54
|
-
entityName: _types.ENTITIES.SETTINGS,
|
|
55
|
-
table: tableInstance,
|
|
56
|
-
attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
|
|
57
|
-
}),
|
|
58
51
|
system: (0, _system.createSystemEntity)({
|
|
59
52
|
entityName: _types.ENTITIES.SYSTEM,
|
|
60
53
|
table: tableInstance,
|
|
@@ -118,9 +111,6 @@ const createStorageOperations = params => {
|
|
|
118
111
|
system: (0, _system2.createSystemStorageOperations)({
|
|
119
112
|
entity: entities.system
|
|
120
113
|
}),
|
|
121
|
-
settings: (0, _settings2.createSettingsStorageOperations)({
|
|
122
|
-
entity: entities.settings
|
|
123
|
-
}),
|
|
124
114
|
groups: (0, _group2.createGroupsStorageOperations)({
|
|
125
115
|
entity: entities.groups,
|
|
126
116
|
plugins
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_filters","_interopRequireDefault","require","_dynamoDb","_types","_table","
|
|
1
|
+
{"version":3,"names":["_filters","_interopRequireDefault","require","_dynamoDb","_types","_table","_system","_group","_model","_entry","_plugins","_system2","_group2","_model2","_entry2","_plugins2","_plugins3","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_ValueFilterPlugin","_apiHeadlessCms","createStorageOperations","params","attributes","table","documentClient","plugins","userPlugins","tableInstance","createTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","createFilterCreatePlugins","createEntriesStorageOperations","entity","name","beforeInit","context","types","CmsEntryFieldFilterPathPlugin","type","CmsFieldFilterValueTransformPlugin","CmsEntryFieldFilterPlugin","CmsEntryFieldSortingPlugin","ValueFilterPlugin","StorageOperationsCmsModelPlugin","mergeByType","register","dataLoaders","clearAll","getEntities","getTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { createModelsStorageOperations } from \"~/operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin,\n CmsFieldFilterValueTransformPlugin\n} from \"~/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { attributes, table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n\n const entities = {\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins(),\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async context => {\n const types: string[] = [\n \"cms-model-field-to-graphql\",\n CmsEntryFieldFilterPathPlugin.type,\n CmsFieldFilterValueTransformPlugin.type,\n CmsEntryFieldFilterPlugin.type,\n CmsEntryFieldSortingPlugin.type,\n ValueFilterPlugin.type,\n StorageOperationsCmsModelPlugin.type\n ];\n /**\n * Collect all required plugins from parent context.\n */\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAEA,IAAAa,SAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AASAe,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAA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qC,QAAQ,EAAEA,CAAA,KAAMvC,aAAa;IAC7BG,MAAM,EAAE,IAAAqC,sCAA6B,EAAC;MAClClB,MAAM,EAAEpB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAAiC,qCAA6B,EAAC;MAClCnB,MAAM,EAAEpB,QAAQ,CAACM,MAAM;MACvBV;IACJ,CAAC,CAAC;IACFa,MAAM,EAAE,IAAA+B,qCAA6B,EAAC;MAClCpB,MAAM,EAAEpB,QAAQ,CAACS;IACrB,CAAC,CAAC;IACFG;EACJ,CAAC;AACL,CAAC;AAAC3B,OAAA,CAAAM,uBAAA,GAAAA,uBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.38.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "7.22.6",
|
|
26
|
-
"@webiny/api-headless-cms": "5.
|
|
27
|
-
"@webiny/db-dynamodb": "5.
|
|
28
|
-
"@webiny/error": "5.
|
|
29
|
-
"@webiny/handler-db": "5.
|
|
30
|
-
"@webiny/utils": "5.
|
|
26
|
+
"@webiny/api-headless-cms": "5.38.0-beta.1",
|
|
27
|
+
"@webiny/db-dynamodb": "5.38.0-beta.1",
|
|
28
|
+
"@webiny/error": "5.38.0-beta.1",
|
|
29
|
+
"@webiny/handler-db": "5.38.0-beta.1",
|
|
30
|
+
"@webiny/utils": "5.38.0-beta.1",
|
|
31
31
|
"aws-sdk": "2.1310.0",
|
|
32
32
|
"dataloader": "2.2.1",
|
|
33
33
|
"dot-prop": "6.0.1",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"@babel/core": "7.22.8",
|
|
41
41
|
"@babel/preset-env": "7.22.7",
|
|
42
42
|
"@types/jsonpack": "1.1.2",
|
|
43
|
-
"@webiny/cli": "5.
|
|
44
|
-
"@webiny/plugins": "5.
|
|
45
|
-
"@webiny/project-utils": "5.
|
|
43
|
+
"@webiny/cli": "5.38.0-beta.1",
|
|
44
|
+
"@webiny/plugins": "5.38.0-beta.1",
|
|
45
|
+
"@webiny/project-utils": "5.38.0-beta.1",
|
|
46
46
|
"jest": "29.5.0",
|
|
47
47
|
"jest-dynalite": "3.6.1",
|
|
48
48
|
"ttypescript": "1.5.15",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"build": "yarn webiny run build",
|
|
57
57
|
"watch": "yarn webiny run watch"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6daf38d3ed0c029a8fea005c2b6246e5b325a09c"
|
|
60
60
|
}
|
package/types.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig
|
|
|
29
29
|
export declare type Attributes = Record<string, AttributeDefinition>;
|
|
30
30
|
export declare enum ENTITIES {
|
|
31
31
|
SYSTEM = "CmsSystem",
|
|
32
|
-
SETTINGS = "CmsSettings",
|
|
33
32
|
GROUPS = "CmsGroups",
|
|
34
33
|
MODELS = "CmsModels",
|
|
35
34
|
ENTRIES = "CmsEntries"
|
|
@@ -45,7 +44,7 @@ export interface StorageOperationsFactoryParams {
|
|
|
45
44
|
}
|
|
46
45
|
export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
|
|
47
46
|
getTable: () => Table;
|
|
48
|
-
getEntities: () => Record<"system" | "
|
|
47
|
+
getEntities: () => Record<"system" | "groups" | "models" | "entries", Entity<any>>;
|
|
49
48
|
}
|
|
50
49
|
export interface StorageOperationsFactory {
|
|
51
50
|
(params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
|
package/types.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ENTITIES = void 0;
|
|
7
7
|
let ENTITIES = /*#__PURE__*/function (ENTITIES) {
|
|
8
8
|
ENTITIES["SYSTEM"] = "CmsSystem";
|
|
9
|
-
ENTITIES["SETTINGS"] = "CmsSettings";
|
|
10
9
|
ENTITIES["GROUPS"] = "CmsGroups";
|
|
11
10
|
ENTITIES["MODELS"] = "CmsModels";
|
|
12
11
|
ENTITIES["ENTRIES"] = "CmsEntries";
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n
|
|
1
|
+
{"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport {\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport { DynamoDBTypes, TableConstructor } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { Entity, Table } from \"dynamodb-toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor): TableConstructor;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DocumentClient;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table;\n getEntities: () => Record<\"system\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: DataLoadersHandlerInterface;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\">;\n}\nexport interface DataLoadersHandlerInterface {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":";;;;;;IA2CYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA;AAAAC,OAAA,CAAAD,QAAA,GAAAA,QAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb-toolbox";
|
|
2
|
-
import { Attributes } from "../types";
|
|
3
|
-
interface Params {
|
|
4
|
-
table: Table;
|
|
5
|
-
entityName: string;
|
|
6
|
-
attributes: Attributes;
|
|
7
|
-
}
|
|
8
|
-
export declare const createSettingsEntity: (params: Params) => Entity<any>;
|
|
9
|
-
export {};
|
package/definitions/settings.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createSettingsEntity = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
10
|
-
const createSettingsEntity = params => {
|
|
11
|
-
const {
|
|
12
|
-
entityName,
|
|
13
|
-
table,
|
|
14
|
-
attributes
|
|
15
|
-
} = params;
|
|
16
|
-
return new _dynamodbToolbox.Entity({
|
|
17
|
-
name: entityName,
|
|
18
|
-
table,
|
|
19
|
-
attributes: (0, _objectSpread2.default)({
|
|
20
|
-
PK: {
|
|
21
|
-
partitionKey: true
|
|
22
|
-
},
|
|
23
|
-
SK: {
|
|
24
|
-
sortKey: true
|
|
25
|
-
},
|
|
26
|
-
TYPE: {
|
|
27
|
-
type: "string"
|
|
28
|
-
},
|
|
29
|
-
key: {
|
|
30
|
-
type: "string"
|
|
31
|
-
},
|
|
32
|
-
uploadMinFileSize: {
|
|
33
|
-
type: "number"
|
|
34
|
-
},
|
|
35
|
-
uploadMaxFileSize: {
|
|
36
|
-
type: "number"
|
|
37
|
-
},
|
|
38
|
-
srcPrefix: {
|
|
39
|
-
type: "string"
|
|
40
|
-
},
|
|
41
|
-
contentModelLastChange: {
|
|
42
|
-
type: "string"
|
|
43
|
-
},
|
|
44
|
-
tenant: {
|
|
45
|
-
type: "string"
|
|
46
|
-
},
|
|
47
|
-
locale: {
|
|
48
|
-
type: "string"
|
|
49
|
-
}
|
|
50
|
-
}, attributes || {})
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
exports.createSettingsEntity = createSettingsEntity;
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=settings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_dynamodbToolbox","require","createSettingsEntity","params","entityName","table","attributes","Entity","name","_objectSpread2","default","PK","partitionKey","SK","sortKey","TYPE","type","key","uploadMinFileSize","uploadMaxFileSize","srcPrefix","contentModelLastChange","tenant","locale","exports"],"sources":["settings.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSettingsEntity = (params: Params): Entity<any> => {\n const { entityName, table, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\"\n },\n key: {\n type: \"string\"\n },\n uploadMinFileSize: {\n type: \"number\"\n },\n uploadMaxFileSize: {\n type: \"number\"\n },\n srcPrefix: {\n type: \"string\"\n },\n contentModelLastChange: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AASO,MAAMC,oBAAoB,GAAIC,MAAc,IAAkB;EACjE,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBC,KAAK;IACLC,UAAU,MAAAG,cAAA,CAAAC,OAAA;MACNC,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,GAAG,EAAE;QACDD,IAAI,EAAE;MACV,CAAC;MACDE,iBAAiB,EAAE;QACfF,IAAI,EAAE;MACV,CAAC;MACDG,iBAAiB,EAAE;QACfH,IAAI,EAAE;MACV,CAAC;MACDI,SAAS,EAAE;QACPJ,IAAI,EAAE;MACV,CAAC;MACDK,sBAAsB,EAAE;QACpBL,IAAI,EAAE;MACV,CAAC;MACDM,MAAM,EAAE;QACJN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV;IAAC,GACGV,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAACkB,OAAA,CAAAtB,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
interface CreateSettingsStorageOperationsParams {
|
|
4
|
-
entity: Entity<any>;
|
|
5
|
-
}
|
|
6
|
-
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
|
|
7
|
-
export {};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createSettingsStorageOperations = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
12
|
-
const convertToDbData = settings => {
|
|
13
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
14
|
-
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
const convertFromDbData = settings => {
|
|
18
|
-
if (!settings) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
let contentModelLastChange;
|
|
22
|
-
try {
|
|
23
|
-
contentModelLastChange = new Date(settings.contentModelLastChange);
|
|
24
|
-
} catch {
|
|
25
|
-
contentModelLastChange = new Date();
|
|
26
|
-
}
|
|
27
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
28
|
-
contentModelLastChange
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const createPartitionKey = ({
|
|
32
|
-
tenant,
|
|
33
|
-
locale
|
|
34
|
-
}) => {
|
|
35
|
-
return `T#${tenant}#L#${locale}#CMS#SETTINGS`;
|
|
36
|
-
};
|
|
37
|
-
const createSortKey = () => {
|
|
38
|
-
return "settings";
|
|
39
|
-
};
|
|
40
|
-
const createKeys = params => {
|
|
41
|
-
return {
|
|
42
|
-
PK: createPartitionKey(params),
|
|
43
|
-
SK: createSortKey()
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const createSettingsStorageOperations = params => {
|
|
47
|
-
const {
|
|
48
|
-
entity
|
|
49
|
-
} = params;
|
|
50
|
-
const create = async params => {
|
|
51
|
-
const {
|
|
52
|
-
settings
|
|
53
|
-
} = params;
|
|
54
|
-
const keys = createKeys(settings);
|
|
55
|
-
const dbSettings = convertToDbData(settings);
|
|
56
|
-
try {
|
|
57
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
58
|
-
return settings;
|
|
59
|
-
} catch (ex) {
|
|
60
|
-
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
61
|
-
error: ex,
|
|
62
|
-
settings,
|
|
63
|
-
dbSettings,
|
|
64
|
-
keys
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const update = async params => {
|
|
69
|
-
const {
|
|
70
|
-
settings
|
|
71
|
-
} = params;
|
|
72
|
-
const keys = createKeys(settings);
|
|
73
|
-
const dbSettings = convertToDbData(settings);
|
|
74
|
-
try {
|
|
75
|
-
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
76
|
-
return settings;
|
|
77
|
-
} catch (ex) {
|
|
78
|
-
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
79
|
-
error: ex,
|
|
80
|
-
settings,
|
|
81
|
-
dbSettings,
|
|
82
|
-
keys
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const get = async params => {
|
|
87
|
-
const keys = createKeys(params);
|
|
88
|
-
try {
|
|
89
|
-
const record = await (0, _get.get)({
|
|
90
|
-
entity,
|
|
91
|
-
keys
|
|
92
|
-
});
|
|
93
|
-
if (!record) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const settings = (0, _cleanup.cleanupItem)(entity, record);
|
|
97
|
-
return convertFromDbData(settings);
|
|
98
|
-
} catch (ex) {
|
|
99
|
-
throw new _error.default(ex.message || "Could not get settings.", ex.code || "GET_SETTINGS_ERROR", {
|
|
100
|
-
error: ex,
|
|
101
|
-
keys
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
return {
|
|
106
|
-
create,
|
|
107
|
-
get,
|
|
108
|
-
update
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
exports.createSettingsStorageOperations = createSettingsStorageOperations;
|
|
112
|
-
|
|
113
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_get","require","_error","_interopRequireDefault","_cleanup","convertToDbData","settings","_objectSpread2","default","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem","exports"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;AAQA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,MAAMI,eAAe,GAAIC,QAAqB,IAAoB;EAC9D,WAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOF,QAAQ;IACXG,sBAAsB,EAAEH,QAAQ,CAACG,sBAAsB,CAACC,WAAW,CAAC;EAAC;AAE7E,CAAC;AAED,MAAMC,iBAAiB,GAAIL,QAAwB,IAAyB;EACxE,IAAI,CAACA,QAAQ,EAAE;IACX,OAAO,IAAI;EACf;EACA,IAAIG,sBAAsB;EAC1B,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAI,CAACN,QAAQ,CAACG,sBAAsB,CAAC;EACtE,CAAC,CAAC,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAI,CAAC,CAAC;EACvC;EACA,WAAAL,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MACOF,QAAQ;IACXG;EAAsB;AAE9B,CAAC;AAOD,MAAMI,kBAAkB,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAA2B,CAAC,KAAa;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAAc;AACjD,CAAC;AAED,MAAMC,aAAa,GAAGA,CAAA,KAAc;EAChC,OAAO,UAAU;AACrB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa,CAAC;EACtB,CAAC;AACL,CAAC;AAMM,MAAMK,+BAA+B,GACxCH,MAA6C,IACd;EAC/B,MAAM;IAAEI;EAAO,CAAC,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