@webiny/api-headless-cms-ddb 5.39.0-beta.0 → 5.39.0-beta.2
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/definitions/entry.d.ts +2 -2
- package/definitions/entry.js +61 -14
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +2 -2
- package/definitions/group.js +6 -7
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +2 -2
- package/definitions/model.js +6 -7
- package/definitions/model.js.map +1 -1
- package/definitions/system.d.ts +2 -2
- package/definitions/system.js +6 -7
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +4 -4
- package/definitions/table.js +5 -3
- package/definitions/table.js.map +1 -1
- package/dynamoDb/path/locationFolderId.js +1 -1
- package/dynamoDb/path/locationFolderId.js.map +1 -1
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.js +4 -8
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +0 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +0 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +0 -3
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -1
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +1 -1
- package/operations/entry/dataLoaders.js +12 -13
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.js +9 -8
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/filter.js +9 -8
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/getValue.js +3 -2
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/systemFields.js +25 -31
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/index.d.ts +1 -1
- package/operations/entry/index.js +198 -63
- package/operations/entry/index.js.map +1 -1
- package/operations/group/index.d.ts +1 -1
- package/operations/group/index.js +30 -20
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +1 -1
- package/operations/model/index.js +23 -12
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.d.ts +1 -1
- package/operations/system/index.js +16 -6
- package/operations/system/index.js.map +1 -1
- package/package.json +11 -12
- package/plugins/CmsEntryFieldFilterPathPlugin.js +6 -3
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.js +2 -6
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.js +1 -4
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.js +1 -4
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
- package/types.d.ts +7 -8
- package/types.js.map +1 -1
package/definitions/entry.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb
|
|
1
|
+
import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
2
|
import { Attributes } from "../types";
|
|
3
3
|
interface Params {
|
|
4
|
-
table: Table
|
|
4
|
+
table: Table<string, string, string>;
|
|
5
5
|
entityName: string;
|
|
6
6
|
attributes: Attributes;
|
|
7
7
|
}
|
package/definitions/entry.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createEntryEntity = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createEntryEntity = params => {
|
|
11
9
|
const {
|
|
12
10
|
table,
|
|
13
11
|
entityName,
|
|
14
12
|
attributes
|
|
15
13
|
} = params;
|
|
16
|
-
return new
|
|
14
|
+
return new _toolbox.Entity({
|
|
17
15
|
name: entityName,
|
|
18
16
|
table,
|
|
19
|
-
attributes:
|
|
17
|
+
attributes: {
|
|
20
18
|
PK: {
|
|
21
19
|
type: "string",
|
|
22
20
|
partitionKey: true
|
|
@@ -49,30 +47,78 @@ const createEntryEntity = params => {
|
|
|
49
47
|
id: {
|
|
50
48
|
type: "string"
|
|
51
49
|
},
|
|
52
|
-
|
|
50
|
+
modelId: {
|
|
51
|
+
type: "string"
|
|
52
|
+
},
|
|
53
|
+
locale: {
|
|
54
|
+
type: "string"
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Revision-level meta fields. 👇
|
|
58
|
+
*/
|
|
59
|
+
revisionCreatedOn: {
|
|
60
|
+
type: "string"
|
|
61
|
+
},
|
|
62
|
+
revisionModifiedOn: {
|
|
63
|
+
type: "string"
|
|
64
|
+
},
|
|
65
|
+
revisionSavedOn: {
|
|
66
|
+
type: "string"
|
|
67
|
+
},
|
|
68
|
+
revisionFirstPublishedOn: {
|
|
69
|
+
type: "string"
|
|
70
|
+
},
|
|
71
|
+
revisionLastPublishedOn: {
|
|
72
|
+
type: "string"
|
|
73
|
+
},
|
|
74
|
+
revisionCreatedBy: {
|
|
53
75
|
type: "map"
|
|
54
76
|
},
|
|
55
|
-
|
|
77
|
+
revisionModifiedBy: {
|
|
56
78
|
type: "map"
|
|
57
79
|
},
|
|
58
|
-
|
|
80
|
+
revisionSavedBy: {
|
|
81
|
+
type: "map"
|
|
82
|
+
},
|
|
83
|
+
revisionFirstPublishedBy: {
|
|
59
84
|
type: "map"
|
|
60
85
|
},
|
|
86
|
+
revisionLastPublishedBy: {
|
|
87
|
+
type: "map"
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Entry-level meta fields. 👇
|
|
91
|
+
*/
|
|
61
92
|
createdOn: {
|
|
62
93
|
type: "string"
|
|
63
94
|
},
|
|
64
|
-
|
|
95
|
+
modifiedOn: {
|
|
65
96
|
type: "string"
|
|
66
97
|
},
|
|
67
|
-
|
|
98
|
+
savedOn: {
|
|
68
99
|
type: "string"
|
|
69
100
|
},
|
|
70
|
-
|
|
101
|
+
firstPublishedOn: {
|
|
71
102
|
type: "string"
|
|
72
103
|
},
|
|
73
|
-
|
|
104
|
+
lastPublishedOn: {
|
|
74
105
|
type: "string"
|
|
75
106
|
},
|
|
107
|
+
createdBy: {
|
|
108
|
+
type: "map"
|
|
109
|
+
},
|
|
110
|
+
modifiedBy: {
|
|
111
|
+
type: "map"
|
|
112
|
+
},
|
|
113
|
+
savedBy: {
|
|
114
|
+
type: "map"
|
|
115
|
+
},
|
|
116
|
+
firstPublishedBy: {
|
|
117
|
+
type: "map"
|
|
118
|
+
},
|
|
119
|
+
lastPublishedBy: {
|
|
120
|
+
type: "map"
|
|
121
|
+
},
|
|
76
122
|
version: {
|
|
77
123
|
type: "number"
|
|
78
124
|
},
|
|
@@ -90,8 +136,9 @@ const createEntryEntity = params => {
|
|
|
90
136
|
},
|
|
91
137
|
meta: {
|
|
92
138
|
type: "map"
|
|
93
|
-
}
|
|
94
|
-
|
|
139
|
+
},
|
|
140
|
+
...(attributes || {})
|
|
141
|
+
}
|
|
95
142
|
});
|
|
96
143
|
};
|
|
97
144
|
exports.createEntryEntity = createEntryEntity;
|
package/definitions/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createEntryEntity","params","table","entityName","attributes","Entity","name","PK","type","partitionKey","SK","sortKey","GSI1_PK","GSI1_SK","TYPE","__type","webinyVersion","tenant","entryId","id","modelId","locale","revisionCreatedOn","revisionModifiedOn","revisionSavedOn","revisionFirstPublishedOn","revisionLastPublishedOn","revisionCreatedBy","revisionModifiedBy","revisionSavedBy","revisionFirstPublishedBy","revisionLastPublishedBy","createdOn","modifiedOn","savedOn","firstPublishedOn","lastPublishedOn","createdBy","modifiedBy","savedBy","firstPublishedBy","lastPublishedBy","version","locked","status","location","values","meta","exports"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createEntryEntity = (params: Params): Entity<any> => {\n const { table, entityName, attributes } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n __type: {\n type: \"string\"\n },\n webinyVersion: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n entryId: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n\n /**\n * Revision-level meta fields. 👇\n */\n revisionCreatedOn: { type: \"string\" },\n revisionModifiedOn: { type: \"string\" },\n revisionSavedOn: { type: \"string\" },\n revisionFirstPublishedOn: { type: \"string\" },\n revisionLastPublishedOn: { type: \"string\" },\n revisionCreatedBy: { type: \"map\" },\n revisionModifiedBy: { type: \"map\" },\n revisionSavedBy: { type: \"map\" },\n revisionFirstPublishedBy: { type: \"map\" },\n revisionLastPublishedBy: { type: \"map\" },\n\n /**\n * Entry-level meta fields. 👇\n */\n createdOn: { type: \"string\" },\n modifiedOn: { type: \"string\" },\n savedOn: { type: \"string\" },\n firstPublishedOn: { type: \"string\" },\n lastPublishedOn: { type: \"string\" },\n createdBy: { type: \"map\" },\n modifiedBy: { type: \"map\" },\n savedBy: { type: \"map\" },\n firstPublishedBy: { type: \"map\" },\n lastPublishedBy: { type: \"map\" },\n\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n location: {\n type: \"map\"\n },\n values: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,iBAAiB,GAAIC,MAAc,IAAkB;EAC9D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEH,UAAU;IAChBD,KAAK;IACLE,UAAU,EAAE;MACRG,EAAE,EAAE;QACAC,IAAI,EAAE,QAAQ;QACdC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAF,IAAI,EAAE,QAAQ;QACdG,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLJ,IAAI,EAAE;MACV,CAAC;MACDK,OAAO,EAAE;QACLL,IAAI,EAAE;MACV,CAAC;MACDM,IAAI,EAAE;QACFN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV,CAAC;MACDQ,aAAa,EAAE;QACXR,IAAI,EAAE;MACV,CAAC;MACDS,MAAM,EAAE;QACJT,IAAI,EAAE;MACV,CAAC;MACDU,OAAO,EAAE;QACLV,IAAI,EAAE;MACV,CAAC;MACDW,EAAE,EAAE;QACAX,IAAI,EAAE;MACV,CAAC;MACDY,OAAO,EAAE;QACLZ,IAAI,EAAE;MACV,CAAC;MACDa,MAAM,EAAE;QACJb,IAAI,EAAE;MACV,CAAC;MAED;AACZ;AACA;MACYc,iBAAiB,EAAE;QAAEd,IAAI,EAAE;MAAS,CAAC;MACrCe,kBAAkB,EAAE;QAAEf,IAAI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QACJtC,IAAI,EAAE;MACV,CAAC;MACDuC,IAAI,EAAE;QACFvC,IAAI,EAAE;MACV,CAAC;MACD,IAAIJ,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC4C,OAAA,CAAAhD,iBAAA,GAAAA,iBAAA"}
|
package/definitions/group.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb
|
|
1
|
+
import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
2
|
import { Attributes } from "../types";
|
|
3
3
|
interface Params {
|
|
4
|
-
table: Table
|
|
4
|
+
table: Table<string, string, string>;
|
|
5
5
|
entityName: string;
|
|
6
6
|
attributes: Attributes;
|
|
7
7
|
}
|
package/definitions/group.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createGroupEntity = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createGroupEntity = params => {
|
|
11
9
|
const {
|
|
12
10
|
table,
|
|
13
11
|
attributes,
|
|
14
12
|
entityName
|
|
15
13
|
} = params;
|
|
16
|
-
return new
|
|
14
|
+
return new _toolbox.Entity({
|
|
17
15
|
name: entityName,
|
|
18
16
|
table,
|
|
19
|
-
attributes:
|
|
17
|
+
attributes: {
|
|
20
18
|
PK: {
|
|
21
19
|
partitionKey: true
|
|
22
20
|
},
|
|
@@ -58,8 +56,9 @@ const createGroupEntity = params => {
|
|
|
58
56
|
},
|
|
59
57
|
tenant: {
|
|
60
58
|
type: "string"
|
|
61
|
-
}
|
|
62
|
-
|
|
59
|
+
},
|
|
60
|
+
...(attributes || {})
|
|
61
|
+
}
|
|
63
62
|
});
|
|
64
63
|
};
|
|
65
64
|
exports.createGroupEntity = createGroupEntity;
|
package/definitions/group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createGroupEntity","params","table","attributes","entityName","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","webinyVersion","id","slug","locale","description","icon","createdBy","createdOn","savedOn","tenant","exports"],"sources":["group.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\nexport const createGroupEntity = (params: Params): Entity<any> => {\n const { table, attributes, entityName } = 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 webinyVersion: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n name: {\n type: \"string\"\n },\n slug: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n description: {\n type: \"string\"\n },\n icon: {\n type: \"string\"\n },\n\n createdBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,iBAAiB,GAAIC,MAAc,IAAkB;EAC9D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEF,UAAU;IAChBF,KAAK;IACLC,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE;MACV,CAAC;MACDC,aAAa,EAAE;QACXD,IAAI,EAAE;MACV,CAAC;MACDE,EAAE,EAAE;QACAF,IAAI,EAAE;MACV,CAAC;MACDN,IAAI,EAAE;QACFM,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACDK,WAAW,EAAE;QACTL,IAAI,EAAE;MACV,CAAC;MACDM,IAAI,EAAE;QACFN,IAAI,EAAE;MACV,CAAC;MAEDO,SAAS,EAAE;QACPP,IAAI,EAAE;MACV,CAAC;MACDQ,SAAS,EAAE;QACPR,IAAI,EAAE;MACV,CAAC;MACDS,OAAO,EAAE;QACLT,IAAI,EAAE;MACV,CAAC;MACDU,MAAM,EAAE;QACJV,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACoB,OAAA,CAAAvB,iBAAA,GAAAA,iBAAA"}
|
package/definitions/model.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb
|
|
1
|
+
import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
2
|
import { Attributes } from "../types";
|
|
3
3
|
interface Params {
|
|
4
|
-
table: Table
|
|
4
|
+
table: Table<string, string, string>;
|
|
5
5
|
entityName: string;
|
|
6
6
|
attributes: Attributes;
|
|
7
7
|
}
|
package/definitions/model.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createModelEntity = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createModelEntity = params => {
|
|
11
9
|
const {
|
|
12
10
|
table,
|
|
13
11
|
attributes,
|
|
14
12
|
entityName
|
|
15
13
|
} = params;
|
|
16
|
-
return new
|
|
14
|
+
return new _toolbox.Entity({
|
|
17
15
|
name: entityName,
|
|
18
16
|
table,
|
|
19
|
-
attributes:
|
|
17
|
+
attributes: {
|
|
20
18
|
PK: {
|
|
21
19
|
partitionKey: true
|
|
22
20
|
},
|
|
@@ -102,8 +100,9 @@ const createModelEntity = params => {
|
|
|
102
100
|
tenant: {
|
|
103
101
|
type: "string",
|
|
104
102
|
required: true
|
|
105
|
-
}
|
|
106
|
-
|
|
103
|
+
},
|
|
104
|
+
...(attributes || {})
|
|
105
|
+
}
|
|
107
106
|
});
|
|
108
107
|
};
|
|
109
108
|
exports.createModelEntity = createModelEntity;
|
package/definitions/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createModelEntity","params","table","attributes","entityName","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","required","webinyVersion","modelId","singularApiName","pluralApiName","locale","group","icon","description","createdOn","savedOn","createdBy","fields","layout","tags","default","lockedFields","titleFieldId","descriptionFieldId","imageFieldId","tenant","exports"],"sources":["model.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createModelEntity = (params: Params): Entity<any> => {\n const { table, attributes, entityName } = 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 required: true\n },\n webinyVersion: {\n type: \"string\",\n required: true\n },\n name: {\n type: \"string\",\n required: true\n },\n modelId: {\n type: \"string\",\n required: true\n },\n singularApiName: {\n type: \"string\",\n required: true\n },\n pluralApiName: {\n type: \"string\",\n required: true\n },\n locale: {\n type: \"string\",\n required: true\n },\n group: {\n type: \"map\",\n required: true\n },\n icon: {\n type: \"string\"\n },\n description: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\",\n required: true\n },\n savedOn: {\n type: \"string\",\n required: true\n },\n createdBy: {\n type: \"map\",\n required: true\n },\n fields: {\n type: \"list\",\n required: true\n },\n layout: {\n type: \"list\",\n required: true\n },\n tags: {\n type: \"list\",\n required: false,\n default: []\n },\n lockedFields: {\n type: \"list\",\n required: true\n },\n titleFieldId: {\n type: \"string\"\n },\n descriptionFieldId: {\n type: \"string\"\n },\n imageFieldId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\",\n required: true\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,iBAAiB,GAAIC,MAAc,IAAkB;EAC9D,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEF,UAAU;IAChBF,KAAK;IACLC,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFC,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDC,aAAa,EAAE;QACXF,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDP,IAAI,EAAE;QACFM,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDE,OAAO,EAAE;QACLH,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDG,eAAe,EAAE;QACbJ,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,C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7 +1,7 @@
|
|
|
1
|
-
import { Entity, Table } from "dynamodb
|
|
1
|
+
import { Entity, Table } from "@webiny/db-dynamodb/toolbox";
|
|
2
2
|
import { Attributes } from "../types";
|
|
3
3
|
interface Params {
|
|
4
|
-
table: Table
|
|
4
|
+
table: Table<string, string, string>;
|
|
5
5
|
entityName: string;
|
|
6
6
|
attributes: Attributes;
|
|
7
7
|
}
|
package/definitions/system.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createSystemEntity = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
10
8
|
const createSystemEntity = params => {
|
|
11
9
|
const {
|
|
12
10
|
entityName,
|
|
13
11
|
attributes,
|
|
14
12
|
table
|
|
15
13
|
} = params;
|
|
16
|
-
return new
|
|
14
|
+
return new _toolbox.Entity({
|
|
17
15
|
name: entityName,
|
|
18
16
|
table,
|
|
19
|
-
attributes:
|
|
17
|
+
attributes: {
|
|
20
18
|
PK: {
|
|
21
19
|
partitionKey: true
|
|
22
20
|
},
|
|
@@ -34,8 +32,9 @@ const createSystemEntity = params => {
|
|
|
34
32
|
},
|
|
35
33
|
readAPIKey: {
|
|
36
34
|
type: "string"
|
|
37
|
-
}
|
|
38
|
-
|
|
35
|
+
},
|
|
36
|
+
...(attributes || {})
|
|
37
|
+
}
|
|
39
38
|
});
|
|
40
39
|
};
|
|
41
40
|
exports.createSystemEntity = createSystemEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey","exports"],"sources":["system.ts"],"sourcesContent":["import { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = 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 version: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n readAPIKey: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,UAAU,EAAE;QACRH,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA"}
|
package/definitions/table.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { TableModifier } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
import { Table } from "dynamodb
|
|
2
|
+
import { DynamoDBClient } from "@webiny/aws-sdk/client-dynamodb";
|
|
3
|
+
import { Table } from "@webiny/db-dynamodb/toolbox";
|
|
4
4
|
interface Params {
|
|
5
5
|
table?: TableModifier;
|
|
6
|
-
documentClient:
|
|
6
|
+
documentClient: DynamoDBClient;
|
|
7
7
|
}
|
|
8
|
-
export declare const createTable: ({ table, documentClient }: Params) => Table
|
|
8
|
+
export declare const createTable: ({ table, documentClient }: Params) => Table<string, string, string>;
|
|
9
9
|
export {};
|
package/definitions/table.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createTable = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _toolbox = require("@webiny/db-dynamodb/toolbox");
|
|
8
8
|
const createTable = ({
|
|
9
9
|
table,
|
|
10
10
|
documentClient
|
|
@@ -19,10 +19,12 @@ const createTable = ({
|
|
|
19
19
|
partitionKey: "GSI1_PK",
|
|
20
20
|
sortKey: "GSI1_SK"
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
},
|
|
23
|
+
autoExecute: true,
|
|
24
|
+
autoParse: true
|
|
23
25
|
};
|
|
24
26
|
const config = typeof table === "function" ? table(tableConfig) : tableConfig;
|
|
25
|
-
return new
|
|
27
|
+
return new _toolbox.Table(config);
|
|
26
28
|
};
|
|
27
29
|
exports.createTable = createTable;
|
|
28
30
|
|
package/definitions/table.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_toolbox","require","createTable","table","documentClient","tableConfig","name","process","env","DB_TABLE_HEADLESS_CMS","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","config","Table","exports"],"sources":["table.ts"],"sourcesContent":["import { TableModifier } from \"~/types\";\nimport { DynamoDBClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface Params {\n table?: TableModifier;\n documentClient: DynamoDBClient;\n}\nexport const createTable = ({ table, documentClient }: Params): Table<string, string, string> => {\n const tableConfig: TableConstructor<string, string, string> = {\n name: process.env.DB_TABLE_HEADLESS_CMS || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n },\n autoExecute: true,\n autoParse: true\n };\n\n const config = typeof table === \"function\" ? table(tableConfig) : tableConfig;\n\n return new Table(config);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAOO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAuB,CAAC,KAAoC;EAC7F,MAAMC,WAAqD,GAAG;IAC1DC,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,qBAAqB,IAAKF,OAAO,CAACC,GAAG,CAACE,QAAmB;IAC3EC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAET,cAAc;IAC9BU,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;IACJ,CAAC;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC;EAED,MAAMC,MAAM,GAAG,OAAOf,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACE,WAAW,CAAC,GAAGA,WAAW;EAE7E,OAAO,IAAIc,cAAK,CAACD,MAAM,CAAC;AAC5B,CAAC;AAACE,OAAA,CAAAlB,WAAA,GAAAA,WAAA"}
|
|
@@ -31,7 +31,7 @@ const createLocationFolderIdPathPlugin = () => {
|
|
|
31
31
|
canUse: (field, parents) => {
|
|
32
32
|
if (field.fieldId !== "folderId") {
|
|
33
33
|
return false;
|
|
34
|
-
} else if (!
|
|
34
|
+
} else if (!parents?.length) {
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
return parents[0] === "wbyAco_location";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPathPlugin","createPath","field","path","settings","WebinyError","createLocationFolderIdPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType","canUse","parents","fieldId","length","exports"],"sources":["locationFolderId.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createLocationFolderIdPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"text\",\n path: createPath,\n canUse: (field, parents) => {\n if (field.fieldId !== \"folderId\") {\n return false;\n } else if (!parents?.length) {\n return false;\n }\n return parents[0] === \"wbyAco_location\";\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAOA,MAAME,UAA8B,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EAClD,MAAM;IAAEC;EAAK,CAAC,GAAGD,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;EACrC,IAAI,CAACD,IAAI,EAAE;IACP,MAAM,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,gCAAgC,GAAGA,CAAA,KAAqC;EACjF,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,MAAM;IACjBL,IAAI,EAAEF,UAAU;IAChBQ,MAAM,EAAEA,CAACP,KAAK,EAAEQ,OAAO,KAAK;MACxB,IAAIR,KAAK,CAACS,OAAO,KAAK,UAAU,EAAE;QAC9B,OAAO,KAAK;MAChB,CAAC,MAAM,IAAI,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPathPlugin","createPath","field","path","settings","WebinyError","createLocationFolderIdPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType","canUse","parents","fieldId","length","exports"],"sources":["locationFolderId.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createLocationFolderIdPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"text\",\n path: createPath,\n canUse: (field, parents) => {\n if (field.fieldId !== \"folderId\") {\n return false;\n } else if (!parents?.length) {\n return false;\n }\n return parents[0] === \"wbyAco_location\";\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAOA,MAAME,UAA8B,GAAGA,CAAC;EAAEC;AAAM,CAAC,KAAK;EAClD,MAAM;IAAEC;EAAK,CAAC,GAAGD,KAAK,CAACE,QAAQ,IAAI,CAAC,CAAC;EACrC,IAAI,CAACD,IAAI,EAAE;IACP,MAAM,IAAIE,cAAW,CAAC,8BAA8B,EAAE,sBAAsB,EAAE;MAC1EH;IACJ,CAAC,CAAC;EACN;EACA,OAAOC,IAAI;AACf,CAAC;AAEM,MAAMG,gCAAgC,GAAGA,CAAA,KAAqC;EACjF,OAAO,IAAIC,4DAA6B,CAAC;IACrCC,SAAS,EAAE,MAAM;IACjBL,IAAI,EAAEF,UAAU;IAChBQ,MAAM,EAAEA,CAACP,KAAK,EAAEQ,OAAO,KAAK;MACxB,IAAIR,KAAK,CAACS,OAAO,KAAK,UAAU,EAAE;QAC9B,OAAO,KAAK;MAChB,CAAC,MAAM,IAAI,CAACD,OAAO,EAAEE,MAAM,EAAE;QACzB,OAAO,KAAK;MAChB;MACA,OAAOF,OAAO,CAAC,CAAC,CAAC,KAAK,iBAAiB;IAC3C;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAAP,gCAAA,GAAAA,gCAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","excludeTypes","convertFromStorage","field","value","multipleValues","result","v","push","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","filter","map","exports"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (\n field: Pick<CmsModelField, \"multipleValues\">,\n value: string | string[]\n) => {\n try {\n if (field.multipleValues) {\n const result: Date[] = [];\n for (const v of value) {\n if (!v) {\n continue;\n }\n try {\n result.push(new Date(v));\n } catch {}\n }\n return result;\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any):
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_apiHeadlessCms","excludeTypes","convertFromStorage","field","value","multipleValues","result","v","push","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","filter","map","exports"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (\n field: Pick<CmsModelField, \"multipleValues\">,\n value: string | string[]\n) => {\n try {\n if (field.multipleValues) {\n const result: Date[] = [];\n for (const v of value) {\n if (!v) {\n continue;\n }\n try {\n result.push(new Date(v));\n } catch {}\n }\n return result;\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any): string => {\n if (value instanceof Date || (value as Record<string, any>).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n return convertValueToStorage(field, value);\n }\n });\n};\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAJA;AACA;AACA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,CAACmB,QAAQ,IAAI,CAAC,CAAC;MACrC,IAAI,CAAClB,KAAK,IAAI,CAACiB,IAAI,IAAIpB,YAAY,CAACsB,QAAQ,CAACF,IAAI,CAAC,EAAE;QAChD,OAAOjB,KAAK;MAChB;MACA,OAAOF,kBAAkB,CAACC,KAAK,EAAEC,KAAK,CAAC;IAC3C,CAAC;IACDoB,SAAS,EAAE,MAAAA,CAAO;MAAEpB,KAAK;MAAED;IAAM,CAAC,KAAK;MACnC,MAAM;QAAEkB;MAAK,CAAC,GAAGlB,KAAK,CAACmB,QAAQ,IAAI,CAAC,CAAC;MACrC,IAAI,CAAClB,KAAK,IAAI,CAACiB,IAAI,IAAIpB,YAAY,CAACsB,QAAQ,CAACF,IAAI,CAAC,EAAE;QAChD,OAAOjB,KAAK;MAChB;MACA,IAAID,KAAK,CAACE,cAAc,EAAE;QACtB,MAAMA,cAAc,GAAGD,KAA6C;QACpE,OAAO,CAACC,cAAc,IAAI,EAAE,EACvBoB,MAAM,CAAClB,CAAC,IAAI,CAAC,CAACA,CAAC,CAAC,CAChBmB,GAAG,CAACnB,CAAC,IAAI;UACN,OAAOK,qBAAqB,CAACT,KAAK,EAAEI,CAAC,CAAC;QAC1C,CAAC,CAAC;MACV;MACA,OAAOK,qBAAqB,CAACT,KAAK,EAAEC,KAAK,CAAC;IAC9C;EACJ,CAAC,CAAC;AACN,CAAC;AAACuB,OAAA,CAAAV,gCAAA,GAAAA,gCAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip","exports"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_gzip","_apiHeadlessCms","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","WebinyError","storageId","fieldId","compression","JSON","stringify","buf","ungzip","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue","gzip","exports"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n return new StorageTransformPlugin<string | string[], StorageValue>({\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n};\n"],"mappings":";;;;;;;AAIA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AANA;AACA;AACA;;AAMA,MAAMG,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AACpC,MAAMC,qBAAqB,GAAG,MAAM;AAEpC,MAAMC,eAAe,GAAIC,KAAsB,IAAa;EACxD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOC,MAAM,CAACC,IAAI,CAACF,KAAK,EAAEH,mBAAmB,CAAC;EAClD;EACA,OAAOG,KAAK;AAChB,CAAC;AAQM,MAAMG,oCAAoC,GAAGA,CAAA,KAAM;EACtD,OAAO,IAAIC,sCAAsB,CAAkC;IAC/DC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEP,KAAK,EAAEQ;IAAa,CAA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,CAAC;IACDC,SAAS,EAAE,MAAAA,CAAO;MAAE3B,KAAK,EAAE4B;IAAa,CAAC,KAAK;MAC1C;AACZ;AACA;MACY,IAAIA,YAAY,IAAIA,YAAY,CAACC,cAAc,CAAC,aAAa,CAAC,KAAK,IAAI,EAAE;QACrE,OAAOD,YAAY;MACvB;MACA,MAAMjB,OAAO,GAAGD,KAAK,CAACC,OAAO,CAACiB,YAAY,CAAC;MAC3C,MAAM5B,KAAK,GAAGW,OAAO,GAAGK,IAAI,CAACC,SAAS,CAACW,YAAY,CAAC,GAAGA,YAAY;MACnE,MAAME,eAAe,GAAG,MAAM,IAAAC,cAAI,EAAC/B,KAAK,CAAC;MAEzC,MAAMoB,MAAoB,GAAG;QACzBL,WAAW,EAAEnB,IAAI;QACjBI,KAAK,EAAE8B,eAAe,CAACT,QAAQ,CAACxB,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACc,OAAO,EAAE;QACV,OAAOS,MAAM;MACjB;MACAA,MAAM,CAACT,OAAO,GAAGA,OAAO;MACxB,OAAOS,MAAM;IACjB;EACJ,CAAC,CAAC;AACN,CAAC;AAACY,OAAA,CAAA7B,oCAAA,GAAAA,oCAAA"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.DataLoaderCache = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
7
|
class DataLoaderCache {
|
|
11
|
-
|
|
12
|
-
(0, _defineProperty2.default)(this, "cache", {});
|
|
13
|
-
}
|
|
8
|
+
cache = {};
|
|
14
9
|
getDataLoader(params) {
|
|
15
10
|
const key = this.createKey(params);
|
|
16
11
|
return this.cache[key] || null;
|
|
@@ -26,9 +21,10 @@ class DataLoaderCache {
|
|
|
26
21
|
}
|
|
27
22
|
return;
|
|
28
23
|
}
|
|
29
|
-
const key = this.createKey(
|
|
24
|
+
const key = this.createKey({
|
|
25
|
+
...params,
|
|
30
26
|
name: ""
|
|
31
|
-
})
|
|
27
|
+
});
|
|
32
28
|
for (const current in this.cache) {
|
|
33
29
|
if (current.startsWith(key) === false) {
|
|
34
30
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DataLoaderCache","
|
|
1
|
+
{"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAQ,GAAEA,MAAM,CAACS,MAAO,IAAGT,MAAM,CAACU,MAAO,IAAGV,MAAM,CAACO,IAAK,EAAC;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA"}
|
|
@@ -33,9 +33,6 @@ const createGetLatestRevisionByEntryId = params => {
|
|
|
33
33
|
SK: latestKey
|
|
34
34
|
});
|
|
35
35
|
return collection;
|
|
36
|
-
/**
|
|
37
|
-
* We cast as any because there is no return type defined.
|
|
38
|
-
*/
|
|
39
36
|
}, {});
|
|
40
37
|
const records = await (0, _batchRead.batchReadAll)({
|
|
41
38
|
table: entity.table,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dataloader","_interopRequireDefault","require","_batchRead","_cleanup","_createBatchScheduleFn","_keys","_utils","createGetLatestRevisionByEntryId","params","entity","locale","tenant","latestKey","createLatestSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, any>>((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n
|
|
1
|
+
{"version":3,"names":["_dataloader","_interopRequireDefault","require","_batchRead","_cleanup","_createBatchScheduleFn","_keys","_utils","createGetLatestRevisionByEntryId","params","entity","locale","tenant","latestKey","createLatestSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, any>>((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n }, {});\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEO,MAAMM,gCAAgC,GAAIC,MAAwB,IAAK;EAC1E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,MAAMI,SAAS,GAAG,IAAAC,yBAAmB,EAAC,CAAC;EAEvC,OAAO,IAAIC,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CAAsB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChE,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCV,MAAM;QACND,MAAM;QACNS;MACJ,CAAC,CAAC;MACF,IAAID,UAAU,CAACE,YAAY,CAAC,EAAE;QAC1B,OAAOF,UAAU;MACrB;MACAA,UAAU,CAACE,YAAY,CAAC,GAAGX,MAAM,CAACa,QAAQ,CAAC;QACvCC,EAAE,EAAEH,YAAY;QAChBI,EAAE,EAAEZ;MACR,CAAC,CAAC;MACF,OAAOM,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,MAAMO,OAAO,GAAG,MAAM,IAAAC,uBAAY,EAAkB;MAChDC,KAAK,EAAElB,MAAM,CAACkB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACd,OAAO;IAChC,CAAC,CAAC;IACF,MAAMY,KAAK,GAAG,IAAAG,qBAAY,EAACtB,MAAM,EAAEgB,OAAO,CAAC;IAE3C,OAAOV,GAAG,CAACiB,GAAG,CAACb,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEc;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACf,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACO,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOH,OAAO,KAAKG,IAAI,CAACH,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACII,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAhC,gCAAA,GAAAA,gCAAA"}
|
|
@@ -33,9 +33,6 @@ const createGetPublishedRevisionByEntryId = params => {
|
|
|
33
33
|
SK: publishedKey
|
|
34
34
|
});
|
|
35
35
|
return collection;
|
|
36
|
-
/**
|
|
37
|
-
* We cast as any because there is no return type defined.
|
|
38
|
-
*/
|
|
39
36
|
}, {});
|
|
40
37
|
const records = await (0, _batchRead.batchReadAll)({
|
|
41
38
|
table: entity.table,
|