@webiny/api-headless-cms-ddb-es 0.0.0-unstable.d65ec29d44 → 0.0.0-unstable.da99e0b846
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.d.ts +1 -1
- package/configurations.js.map +1 -1
- package/definitions/entry.js +3 -0
- package/definitions/entry.js.map +1 -1
- package/definitions/model.js +17 -0
- package/definitions/model.js.map +1 -1
- package/dynamoDb/storage/date.js +3 -1
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +3 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +3 -1
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +2 -8
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/index.js +7 -10
- package/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/index.js +47 -17
- package/operations/entry/index.js.map +1 -1
- package/operations/model/index.js +1 -1
- package/operations/model/index.js.map +1 -1
- package/package.json +21 -14
package/configurations.d.ts
CHANGED
package/configurations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["configurations","es","model","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface ElasticsearchConfig {\n index: string;\n}\n\ninterface CmsElasticsearchParams {\n model: CmsModel
|
|
1
|
+
{"version":3,"names":["configurations","es","model","tenant","locale","WebinyError","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","index","modelId","join","toLowerCase","prefix","ELASTIC_SEARCH_INDEX_PREFIX"],"sources":["configurations.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface ElasticsearchConfig {\n index: string;\n}\n\ninterface CmsElasticsearchParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\ninterface Configurations {\n es: (params: CmsElasticsearchParams) => ElasticsearchConfig;\n}\n\nexport const configurations: Configurations = {\n es({ model }) {\n const { tenant, locale } = model;\n\n if (!tenant) {\n throw new WebinyError(\n `Missing \"tenant\" parameter when trying to create Elasticsearch index name.`,\n \"TENANT_ERROR\"\n );\n } else if (!locale) {\n throw new WebinyError(\n `Missing \"locale\" parameter when trying to create Elasticsearch index name.`,\n \"LOCALE_ERROR\"\n );\n }\n\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n const index = [sharedIndex ? \"root\" : tenant, \"headless-cms\", locale, model.modelId]\n .join(\"-\")\n .toLowerCase();\n\n const prefix = process.env.ELASTIC_SEARCH_INDEX_PREFIX || \"\";\n if (!prefix) {\n return {\n index\n };\n }\n return {\n index: prefix + index\n };\n }\n};\n"],"mappings":";;;;;;;AACA;AAcO,MAAMA,cAA8B,GAAG;EAC1CC,EAAE,CAAC;IAAEC;EAAM,CAAC,EAAE;IACV,MAAM;MAAEC,MAAM;MAAEC;IAAO,CAAC,GAAGF,KAAK;IAEhC,IAAI,CAACC,MAAM,EAAE;MACT,MAAM,IAAIE,cAAW,CAChB,4EAA2E,EAC5E,cAAc,CACjB;IACL,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;MAChB,MAAM,IAAIC,cAAW,CAChB,4EAA2E,EAC5E,cAAc,CACjB;IACL;IAEA,MAAMC,WAAW,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B,KAAK,MAAM;IACvE,MAAMC,KAAK,GAAG,CAACJ,WAAW,GAAG,MAAM,GAAGH,MAAM,EAAE,cAAc,EAAEC,MAAM,EAAEF,KAAK,CAACS,OAAO,CAAC,CAC/EC,IAAI,CAAC,GAAG,CAAC,CACTC,WAAW,EAAE;IAElB,MAAMC,MAAM,GAAGP,OAAO,CAACC,GAAG,CAACO,2BAA2B,IAAI,EAAE;IAC5D,IAAI,CAACD,MAAM,EAAE;MACT,OAAO;QACHJ;MACJ,CAAC;IACL;IACA,OAAO;MACHA,KAAK,EAAEI,MAAM,GAAGJ;IACpB,CAAC;EACL;AACJ,CAAC;AAAC"}
|
package/definitions/entry.js
CHANGED
package/definitions/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createEntryEntity","params","table","entityName","attributes","Entity","name","PK","type","partitionKey","SK","sortKey","TYPE","__type","webinyVersion","tenant","entryId","id","createdBy","ownedBy","createdOn","savedOn","modelId","locale","publishedOn","version","locked","status","values","meta"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateEntryEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): 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 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 createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n publishedOn: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n values: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,iBAAiB,GAAIC,MAA+B,IAAkB;EAC/E,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEH,UAAU;IAChBD,KAAK;IACLE,UAAU;MACNG,EAAE,EAAE;QACAC,IAAI,EAAE,QAAQ;QACdC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAF,IAAI,EAAE,QAAQ;QACdG,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFJ,IAAI,EAAE;MACV,CAAC;MACDK,MAAM,EAAE;QACJL,IAAI,EAAE;MACV,CAAC;MACDM,aAAa,EAAE;QACXN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,EAAE,EAAE;QACAT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE;MACV,CAAC;MACDW,OAAO,EAAE;QACLX,IAAI,EAAE;MACV,CAAC;MACDY,
|
|
1
|
+
{"version":3,"names":["createEntryEntity","params","table","entityName","attributes","Entity","name","PK","type","partitionKey","SK","sortKey","TYPE","__type","webinyVersion","tenant","entryId","id","createdBy","ownedBy","modifiedBy","createdOn","savedOn","modelId","locale","publishedOn","version","locked","status","values","meta"],"sources":["entry.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateEntryEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\nexport const createEntryEntity = (params: CreateEntryEntityParams): 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 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 createdBy: {\n type: \"map\"\n },\n ownedBy: {\n type: \"map\"\n },\n modifiedBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n savedOn: {\n type: \"string\"\n },\n modelId: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n publishedOn: {\n type: \"string\"\n },\n version: {\n type: \"number\"\n },\n locked: {\n type: \"boolean\"\n },\n status: {\n type: \"string\"\n },\n values: {\n type: \"map\"\n },\n meta: {\n type: \"map\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,MAAMA,iBAAiB,GAAIC,MAA+B,IAAkB;EAC/E,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEH,UAAU;IAChBD,KAAK;IACLE,UAAU;MACNG,EAAE,EAAE;QACAC,IAAI,EAAE,QAAQ;QACdC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAF,IAAI,EAAE,QAAQ;QACdG,OAAO,EAAE;MACb,CAAC;MACDC,IAAI,EAAE;QACFJ,IAAI,EAAE;MACV,CAAC;MACDK,MAAM,EAAE;QACJL,IAAI,EAAE;MACV,CAAC;MACDM,aAAa,EAAE;QACXN,IAAI,EAAE;MACV,CAAC;MACDO,MAAM,EAAE;QACJP,IAAI,EAAE;MACV,CAAC;MACDQ,OAAO,EAAE;QACLR,IAAI,EAAE;MACV,CAAC;MACDS,EAAE,EAAE;QACAT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE;MACV,CAAC;MACDW,OAAO,EAAE;QACLX,IAAI,EAAE;MACV,CAAC;MACDY,UAAU,EAAE;QACRZ,IAAI,EAAE;MACV,CAAC;MACDa,SAAS,EAAE;QACPb,IAAI,EAAE;MACV,CAAC;MACDc,OAAO,EAAE;QACLd,IAAI,EAAE;MACV,CAAC;MACDe,OAAO,EAAE;QACLf,IAAI,EAAE;MACV,CAAC;MACDgB,MAAM,EAAE;QACJhB,IAAI,EAAE;MACV,CAAC;MACDiB,WAAW,EAAE;QACTjB,IAAI,EAAE;MACV,CAAC;MACDkB,OAAO,EAAE;QACLlB,IAAI,EAAE;MACV,CAAC;MACDmB,MAAM,EAAE;QACJnB,IAAI,EAAE;MACV,CAAC;MACDoB,MAAM,EAAE;QACJpB,IAAI,EAAE;MACV,CAAC;MACDqB,MAAM,EAAE;QACJrB,IAAI,EAAE;MACV,CAAC;MACDsB,IAAI,EAAE;QACFtB,IAAI,EAAE;MACV;IAAC,GACGJ,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/definitions/model.js
CHANGED
|
@@ -39,6 +39,14 @@ const createModelEntity = params => {
|
|
|
39
39
|
type: "string",
|
|
40
40
|
required: true
|
|
41
41
|
},
|
|
42
|
+
singularApiName: {
|
|
43
|
+
type: "string",
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
pluralApiName: {
|
|
47
|
+
type: "string",
|
|
48
|
+
required: true
|
|
49
|
+
},
|
|
42
50
|
locale: {
|
|
43
51
|
type: "string",
|
|
44
52
|
required: true
|
|
@@ -47,6 +55,9 @@ const createModelEntity = params => {
|
|
|
47
55
|
type: "map",
|
|
48
56
|
required: true
|
|
49
57
|
},
|
|
58
|
+
icon: {
|
|
59
|
+
type: "string"
|
|
60
|
+
},
|
|
50
61
|
description: {
|
|
51
62
|
type: "string"
|
|
52
63
|
},
|
|
@@ -82,6 +93,12 @@ const createModelEntity = params => {
|
|
|
82
93
|
titleFieldId: {
|
|
83
94
|
type: "string"
|
|
84
95
|
},
|
|
96
|
+
descriptionFieldId: {
|
|
97
|
+
type: "string"
|
|
98
|
+
},
|
|
99
|
+
imageFieldId: {
|
|
100
|
+
type: "string"
|
|
101
|
+
},
|
|
85
102
|
tenant: {
|
|
86
103
|
type: "string",
|
|
87
104
|
required: true
|
package/definitions/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createModelEntity","params","table","attributes","entityName","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","required","webinyVersion","modelId","locale","group","description","createdOn","savedOn","createdBy","fields","layout","tags","default","lockedFields","titleFieldId","tenant"],"sources":["model.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateModelEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createModelEntity = (params: CreateModelEntityParams): 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 locale: {\n type: \"string\",\n required: true\n },\n group: {\n type: \"map\",\n required: true\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 tenant: {\n type: \"string\",\n required: true\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;AAAA;AASO,MAAMA,iBAAiB,GAAIC,MAA+B,IAAkB;EAC/E,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEF,UAAU;IAChBF,KAAK;IACLC,UAAU;MACNI,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,
|
|
1
|
+
{"version":3,"names":["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"],"sources":["model.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateModelEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createModelEntity = (params: CreateModelEntityParams): 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;AASO,MAAMA,iBAAiB,GAAIC,MAA+B,IAAkB;EAC/E,MAAM;IAAEC,KAAK;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,uBAAM,CAAC;IACdC,IAAI,EAAEF,UAAU;IAChBF,KAAK;IACLC,UAAU;MACNI,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,CAAC;MACDI,aAAa,EAAE;QACXL,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDK,MAAM,EAAE;QACJN,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDM,KAAK,EAAE;QACHP,IAAI,EAAE,KAAK;QACXC,QAAQ,EAAE;MACd,CAAC;MACDO,IAAI,EAAE;QACFR,IAAI,EAAE;MACV,CAAC;MACDS,WAAW,EAAE;QACTT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDU,OAAO,EAAE;QACLX,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd,CAAC;MACDW,SAAS,EAAE;QACPZ,IAAI,EAAE,KAAK;QACXC,QAAQ,EAAE;MACd,CAAC;MACDY,MAAM,EAAE;QACJb,IAAI,EAAE,MAAM;QACZC,QAAQ,EAAE;MACd,CAAC;MACDa,MAAM,EAAE;QACJd,IAAI,EAAE,MAAM;QACZC,QAAQ,EAAE;MACd,CAAC;MACDc,IAAI,EAAE;QACFf,IAAI,EAAE,MAAM;QACZC,QAAQ,EAAE,KAAK;QACfe,OAAO,EAAE;MACb,CAAC;MACDC,YAAY,EAAE;QACVjB,IAAI,EAAE,MAAM;QACZC,QAAQ,EAAE;MACd,CAAC;MACDiB,YAAY,EAAE;QACVlB,IAAI,EAAE;MACV,CAAC;MACDmB,kBAAkB,EAAE;QAChBnB,IAAI,EAAE;MACV,CAAC;MACDoB,YAAY,EAAE;QACVpB,IAAI,EAAE;MACV,CAAC;MACDqB,MAAM,EAAE;QACJrB,IAAI,EAAE,QAAQ;QACdC,QAAQ,EAAE;MACd;IAAC,GACGV,UAAU,IAAI,CAAC,CAAC;EAE5B,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/dynamoDb/storage/date.js
CHANGED
|
@@ -38,7 +38,7 @@ const convertValueToStorage = (field, value) => {
|
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
const createDateStorageTransformPlugin = () => {
|
|
41
|
-
|
|
41
|
+
const plugin = new _apiHeadlessCms.StorageTransformPlugin({
|
|
42
42
|
fieldType: "datetime",
|
|
43
43
|
fromStorage: async ({
|
|
44
44
|
value,
|
|
@@ -80,5 +80,7 @@ const createDateStorageTransformPlugin = () => {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
plugin.name = `headless-cms.dynamodb.storageTransform.date`;
|
|
84
|
+
return plugin;
|
|
83
85
|
};
|
|
84
86
|
exports.createDateStorageTransformPlugin = createDateStorageTransformPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage"],"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\ntype PartialCmsModelField = Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"multipleValues\">;\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: PartialCmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\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: PartialCmsModelField, value: any): any => {\n if ((value as 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
|
|
1
|
+
{"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage","name"],"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\ntype PartialCmsModelField = Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"multipleValues\">;\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: PartialCmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\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: PartialCmsModelField, value: any): any => {\n if ((value as 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 const plugin = 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 if ((value as 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,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.date`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAGA;AACA;AAJA;AACA;AACA;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Q,CAACF,IAAI,CAAC,EAAE;QAChD,OAAOlB,KAAK;MAChB;MACA,OAAOF,kBAAkB,CAACC,KAAK,EAAEC,KAAK,CAAC;IAC3C,CAAC;IACDqB,SAAS,EAAE,OAAO;MAAErB,KAAK;MAAED;IAAM,CAAC,KAAK;MACnC,MAAM;QAAEmB;MAAK,CAAC,GAAGnB,KAAK,CAACoB,QAAQ,IAAI,CAAC,CAAC;MACrC,IAAI,CAACnB,KAAK,IAAI,CAACkB,IAAI,IAAIrB,YAAY,CAACuB,QAAQ,CAACF,IAAI,CAAC,EAAE;QAChD,OAAOlB,KAAK;MAChB;MACA,IAAID,KAAK,CAACE,cAAc,EAAE;QACtB,MAAMA,cAAc,GAAGD,KAA6C;QACpE,OAAO,CAACC,cAAc,IAAI,EAAE,EACvBC,MAAM,CAACC,CAAC,IAAI,CAAC,CAACA,CAAC,CAAC,CAChBC,GAAG,CAACD,CAAC,IAAI;UACN,OAAOK,qBAAqB,CAACT,KAAK,EAAEI,CAAC,CAAC;QAC1C,CAAC,CAAC;MACV;MACA,IAAKH,KAAK,CAASS,WAAW,EAAE;QAC5B,OAAQT,KAAK,CAAUS,WAAW,EAAE;MACxC,CAAC,MAAM,IAAI,OAAOT,KAAK,KAAK,QAAQ,EAAE;QAClC,OAAOA,KAAK;MAChB;MACA,MAAM,IAAIU,cAAW,CAAC,2CAA2C,EAAE,kBAAkB,EAAE;QACnFV,KAAK;QACLW,OAAO,EAAEZ,KAAK,CAACY,OAAO;QACtBC,SAAS,EAAEb,KAAK,CAACa;MACrB,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;EACFE,MAAM,CAACQ,IAAI,GAAI,6CAA4C;EAE3D,OAAOR,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -22,7 +22,7 @@ const convertToBuffer = value => {
|
|
|
22
22
|
return value;
|
|
23
23
|
};
|
|
24
24
|
const createLongTextStorageTransformPlugin = () => {
|
|
25
|
-
|
|
25
|
+
const plugin = new _apiHeadlessCms.StorageTransformPlugin({
|
|
26
26
|
fieldType: "long-text",
|
|
27
27
|
fromStorage: async ({
|
|
28
28
|
field,
|
|
@@ -87,5 +87,7 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
87
87
|
return result;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
+
plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;
|
|
91
|
+
return plugin;
|
|
90
92
|
};
|
|
91
93
|
exports.createLongTextStorageTransformPlugin = createLongTextStorageTransformPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["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"],"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
|
|
1
|
+
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","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","name"],"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 const plugin = 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 any;\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 plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAIA;AACA;AACA;AANA;AACA;AACA;;AAMA,MAAMA,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,GAAG,MAAM;EACtD,MAAMC,MAAM,GAAG,IAAIC,sCAAsB,CAAkC;IACvEC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,OAAO;MAAEC,KAAK;MAAER,KAAK,EAAES;IAAa,CAAC,KAAK;MACnD,MAAMC,MAAM,GAAG,OAAOD,YAAY;MAClC,IACI,CAACA,YAAY,IACbC,MAAM,KAAK,QAAQ,IACnBA,MAAM,KAAK,QAAQ,IACnBC,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC,KAAK,IAAI,EACtC;QACE,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAIC,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIG,cAAW,CAChB,gFAA+EL,KAAK,CAACM,SAAU,OAAMN,KAAK,CAACO,OAAQ,GAAE,C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AY;MACnE,MAAME,eAAe,GAAG,MAAM,IAAAC,cAAI,EAAChC,KAAK,CAAC;MAEzC,MAAMqB,MAAoB,GAAG;QACzBL,WAAW,EAAEpB,IAAI;QACjBI,KAAK,EAAE+B,eAAe,CAACT,QAAQ,CAACzB,mBAAmB;MACvD,CAAC;MACD,IAAI,CAACe,OAAO,EAAE;QACV,OAAOS,MAAM;MACjB;MACAA,MAAM,CAACT,OAAO,GAAGA,OAAO;MACxB,OAAOS,MAAM;IACjB;EACJ,CAAC,CAAC;EACFjB,MAAM,CAAC6B,IAAI,GAAG7B,MAAM,CAAC6B,IAAI,GAAI,kDAAiD;EAE9E,OAAO7B,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -32,7 +32,7 @@ const transformArray = value => {
|
|
|
32
32
|
return value;
|
|
33
33
|
};
|
|
34
34
|
const createRichTextStorageTransformPlugin = () => {
|
|
35
|
-
|
|
35
|
+
const plugin = new _apiHeadlessCms.StorageTransformPlugin({
|
|
36
36
|
fieldType: "rich-text",
|
|
37
37
|
fromStorage: async ({
|
|
38
38
|
field,
|
|
@@ -104,5 +104,7 @@ const createRichTextStorageTransformPlugin = () => {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
|
+
plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;
|
|
108
|
+
return plugin;
|
|
107
109
|
};
|
|
108
110
|
exports.createRichTextStorageTransformPlugin = createRichTextStorageTransformPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","process","env","DEBUG","console","log","message","toStorage","jsonValue","pack"],"sources":["richText.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nexport type OriginalValue = Record<string, any> | any[];\n\nexport interface StorageValue {\n compression: string;\n value: any;\n}\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value as any);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n
|
|
1
|
+
{"version":3,"names":["transformArray","value","isArray","Array","shouldBeArray","from","k","createRichTextStorageTransformPlugin","plugin","StorageTransformPlugin","fieldType","fromStorage","field","storageValue","WebinyError","storageId","compression","jsonpack","unpack","ex","process","env","DEBUG","console","log","message","toStorage","jsonValue","pack","name"],"sources":["richText.ts"],"sourcesContent":["import jsonpack from \"jsonpack\";\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nexport type OriginalValue = Record<string, any> | any[];\n\nexport interface StorageValue {\n compression: string;\n value: any;\n}\n\n/**\n * Remove when jsonpack gets PR with a fix merged\n * https://github.com/rgcl/jsonpack/pull/25/files\n * NOTE 2021-07-28: it seems PR is not going to be merged so keep this.\n */\n// TODO @ts-refactor figure better type\nconst transformArray = (value: any) => {\n if (!value) {\n return value;\n }\n let isArray = Array.isArray(value);\n const shouldBeArray = value instanceof Array === false && isArray;\n if (shouldBeArray) {\n value = Array.from(value as any);\n isArray = true;\n }\n if (typeof value === \"object\" || isArray) {\n for (const k in value) {\n value[k] = transformArray(value[k]);\n }\n }\n return value;\n};\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\".`\n );\n }\n /**\n * This is to circumvent a bug introduced with 5.8.0 storage operations.\n * Do not remove.\n */\n if (!storageValue[\"compression\"]) {\n return storageValue;\n }\n const { compression, value } = storageValue;\n if (compression !== \"jsonpack\") {\n throw new WebinyError(\n `This plugin cannot transform something not packed with \"jsonpack\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n /**\n * No point in going further if no value.\n */\n if (!value) {\n return null;\n }\n try {\n return jsonpack.unpack(value);\n } catch (ex) {\n if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while decompressing rich-text.\");\n console.log(ex.message);\n return null;\n }\n },\n toStorage: async ({ value }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n * Introduced a bug with 5.8.0 storage operations, so just return the value to correct it.\n */\n if (!!value?.compression) {\n return value as any;\n }\n value = transformArray(value);\n\n let jsonValue: string | null = null;\n try {\n jsonValue = jsonpack.pack(value);\n } catch (ex) {\n if (process.env.DEBUG !== \"true\") {\n return null;\n }\n console.log(\"Error while compressing rich-text.\");\n console.log(ex.message);\n }\n return {\n compression: \"jsonpack\",\n value: jsonValue\n };\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAIC,KAAU,IAAK;EACnC,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,IAAIC,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACD,KAAK,CAAC;EAClC,MAAMG,aAAa,GAAGH,KAAK,YAAYE,KAAK,KAAK,KAAK,IAAID,OAAO;EACjE,IAAIE,aAAa,EAAE;IACfH,KAAK,GAAGE,KAAK,CAACE,IAAI,CAACJ,KAAK,CAAQ;IAChCC,OAAO,GAAG,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ACvB,OAAO,IAAI;MACf;IACJ,CAAC;IACDC,SAAS,EAAE,OAAO;MAAEzB;IAAM,CAAC,KAAK;MAAA;MAC5B;AACZ;AACA;AACA;MACY,IAAI,CAAC,YAACA,KAAK,mCAAL,OAAOe,WAAW,GAAE;QACtB,OAAOf,KAAK;MAChB;MACAA,KAAK,GAAGD,cAAc,CAACC,KAAK,CAAC;MAE7B,IAAI0B,SAAwB,GAAG,IAAI;MACnC,IAAI;QACAA,SAAS,GAAGV,iBAAQ,CAACW,IAAI,CAAC3B,KAAK,CAAC;MACpC,CAAC,CAAC,OAAOkB,EAAE,EAAE;QACT,IAAIC,OAAO,CAACC,GAAG,CAACC,KAAK,KAAK,MAAM,EAAE;UAC9B,OAAO,IAAI;QACf;QACAC,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;QACjDD,OAAO,CAACC,GAAG,CAACL,EAAE,CAACM,OAAO,CAAC;MAC3B;MACA,OAAO;QACHT,WAAW,EAAE,UAAU;QACvBf,KAAK,EAAE0B;MACX,CAAC;IACL;EACJ,CAAC,CAAC;EACFnB,MAAM,CAACqB,IAAI,GAAI,kDAAiD;EAEhE,OAAOrB,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -19,12 +19,6 @@ var _default = () => ({
|
|
|
19
19
|
* We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.
|
|
20
20
|
*/
|
|
21
21
|
return {
|
|
22
|
-
/**
|
|
23
|
-
* // TODO @Bruno validate and test
|
|
24
|
-
* I have no idea why we encoded the raw value. We will see in testing and when upgrading our test projects.
|
|
25
|
-
* // TODO remove comments when tested and verified.
|
|
26
|
-
*/
|
|
27
|
-
// value: rawValue ? encodeURIComponent(rawValue) : "",
|
|
28
22
|
value: Array.isArray(rawValue) ? rawValue : rawValue || ""
|
|
29
23
|
};
|
|
30
24
|
},
|
|
@@ -38,9 +32,9 @@ var _default = () => ({
|
|
|
38
32
|
value
|
|
39
33
|
}) {
|
|
40
34
|
if (Array.isArray(value)) {
|
|
41
|
-
return value
|
|
35
|
+
return value;
|
|
42
36
|
}
|
|
43
|
-
return value
|
|
37
|
+
return value || "";
|
|
44
38
|
}
|
|
45
39
|
});
|
|
46
40
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["type","name","fieldType","toIndex","rawValue","value","Array","isArray","fromIndex"
|
|
1
|
+
{"version":3,"names":["type","name","fieldType","toIndex","rawValue","value","Array","isArray","fromIndex"],"sources":["longTextIndexing.ts"],"sourcesContent":["import { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\n/**\n * The long-text indexing plugin must take in consideration that users might have list of long-text fields.\n * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.\n */\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-long-text\",\n fieldType: \"long-text\",\n toIndex({ rawValue }) {\n /**\n * We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.\n */\n return {\n value: Array.isArray(rawValue) ? rawValue : rawValue || \"\"\n };\n },\n /**\n * When taking value from the index, we can return the original value.\n * At that point the `transformFromStorage` does not need to do anything.\n *\n * We need to decode to support older systems.\n */\n fromIndex({ value }) {\n if (Array.isArray(value)) {\n return value;\n }\n return value || \"\";\n }\n});\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AAHA,eAIe,OAA2C;EACtDA,IAAI,EAAE,mCAAmC;EACzCC,IAAI,EAAE,6CAA6C;EACnDC,SAAS,EAAE,WAAW;EACtBC,OAAO,CAAC;IAAEC;EAAS,CAAC,EAAE;IAClB;AACR;AACA;IACQ,OAAO;MACHC,KAAK,EAAEC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,GAAGA,QAAQ,GAAGA,QAAQ,IAAI;IAC5D,CAAC;EACL,CAAC;EACD;AACJ;AACA;AACA;AACA;AACA;EACII,SAAS,CAAC;IAAEH;EAAM,CAAC,EAAE;IACjB,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;MACtB,OAAOA,KAAK;IAChB;IACA,OAAOA,KAAK,IAAI,EAAE;EACtB;AACJ,CAAC,CAAC;AAAA"}
|
package/index.js
CHANGED
|
@@ -44,6 +44,7 @@ Object.keys(_plugins2).forEach(function (key) {
|
|
|
44
44
|
});
|
|
45
45
|
var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
|
|
46
46
|
var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
|
|
47
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
47
48
|
const createStorageOperations = params => {
|
|
48
49
|
const {
|
|
49
50
|
attributes,
|
|
@@ -94,17 +95,10 @@ const createStorageOperations = params => {
|
|
|
94
95
|
})
|
|
95
96
|
};
|
|
96
97
|
const plugins = new _plugins.PluginsContainer([
|
|
97
|
-
/**
|
|
98
|
-
* Plugins of type CmsModelFieldToGraphQLPlugin.
|
|
99
|
-
*/
|
|
100
98
|
/**
|
|
101
99
|
* DynamoDB filter plugins for the where conditions.
|
|
102
100
|
*/
|
|
103
101
|
(0, _filters.default)(),
|
|
104
|
-
/**
|
|
105
|
-
* Elasticsearch operators.
|
|
106
|
-
*/
|
|
107
|
-
(0, _apiElasticsearch.getElasticsearchOperators)(),
|
|
108
102
|
/**
|
|
109
103
|
* Field plugins for DynamoDB.
|
|
110
104
|
*/
|
|
@@ -143,10 +137,13 @@ const createStorageOperations = params => {
|
|
|
143
137
|
* We need to fetch all the plugin types in the list from the main container.
|
|
144
138
|
* This way we do not need to register plugins in the storage plugins contains.
|
|
145
139
|
*/
|
|
146
|
-
const types = [
|
|
140
|
+
const types = [
|
|
141
|
+
// Elasticsearch
|
|
142
|
+
_apiElasticsearch.CompressionPlugin.type, _apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
|
|
143
|
+
// Headless CMS
|
|
144
|
+
"cms-model-field-to-graphql", _CmsEntryFilterPlugin.CmsEntryFilterPlugin.type, _plugins2.CmsEntryElasticsearchBodyModifierPlugin.type, _plugins2.CmsEntryElasticsearchFullTextSearchPlugin.type, _plugins2.CmsEntryElasticsearchIndexPlugin.type, _plugins2.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, _plugins2.CmsEntryElasticsearchQueryModifierPlugin.type, _plugins2.CmsEntryElasticsearchSortModifierPlugin.type, _plugins2.CmsEntryElasticsearchFieldPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type];
|
|
147
145
|
for (const type of types) {
|
|
148
|
-
|
|
149
|
-
plugins.register(contextPlugins);
|
|
146
|
+
plugins.mergeByType(context.plugins, type);
|
|
150
147
|
}
|
|
151
148
|
},
|
|
152
149
|
init: async context => {
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","getElasticsearchOperators","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","name","beforeInit","context","register","types","CmsEntryFilterPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchFieldPlugin","contextPlugins","byType","init","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugin,\n getElasticsearchOperators\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchFieldPlugin\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n 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 entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * Plugins of type CmsModelFieldToGraphQLPlugin.\n */\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsEntryElasticsearchFieldPlugin.type\n ];\n for (const type of types) {\n const contextPlugins = context.plugins.byType(type);\n plugins.register(contextPlugins);\n }\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAYA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAHA;AACA;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UAAU;IACVC,KAAK;IACLC,OAAO;IACPC,cAAc;IACdC,aAAa;IACbC,OAAO,EAAEC;EACb,CAAC,GAAGP,MAAM;EAEV,MAAMQ,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BP,KAAK;IACLE;EACJ,CAAC,CAAC;EACF,MAAMM,0BAA0B,GAAG,IAAAC,4CAAwB,EAAC;IACxDT,KAAK,EAAEC,OAAO;IACdC;EACJ,CAAC,CAAC;EAEF,MAAMQ,QAAQ,GAAG;IACbC,QAAQ,EAAE,IAAAC,+BAAoB,EAAC;MAC3BC,UAAU,EAAEC,eAAQ,CAACC,QAAQ;MAC7Bf,KAAK,EAAEM,aAAa;MACpBP,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACe,eAAQ,CAACC,QAAQ,CAAC,GAAG,CAAC;IAC9D,CAAC,CAAC;IACFC,MAAM,EAAE,IAAAC,2BAAkB,EAAC;MACvBJ,UAAU,EAAEC,eAAQ,CAACI,MAAM;MAC3BlB,KAAK,EAAEM,aAAa;MACpBP,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACe,eAAQ,CAACI,MAAM,CAAC,GAAG,CAAC;IAC5D,CAAC,CAAC;IACFC,MAAM,EAAE,IAAAC,wBAAiB,EAAC;MACtBP,UAAU,EA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AG,CAACM,kBAAkB,CAACJ,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QAC1D,MAAM,IAAAI,kDAAwB,EAAC;UAC3B5D,aAAa;UACbwD;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;MAEFnB,OAAO,CAACgB,GAAG,CAACQ,iBAAiB,CAACN,SAAS,CAAC,OAAO;QAAEC;MAAM,CAAC,KAAK;QACzD,MAAM,IAAAC,kDAAwB,EAAC;UAC3BzD,aAAa;UACbwD,KAAK;UACLvD;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC;IACD6D,WAAW,EAAE,MAAMvD,QAAQ;IAC3BwD,QAAQ,EAAE,MAAM5D,aAAa;IAC7B6D,UAAU,EAAE,MAAM3D,0BAA0B;IAC5CQ,MAAM,EAAE,IAAAoD,qCAA6B,EAAC;MAClCC,MAAM,EAAE3D,QAAQ,CAACM;IACrB,CAAC,CAAC;IACFL,QAAQ,EAAE,IAAA2D,yCAA+B,EAAC;MACtCD,MAAM,EAAE3D,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFQ,MAAM,EAAE,IAAAoD,qCAA6B,EAAC;MAClCF,MAAM,EAAE3D,QAAQ,CAACS,MAAM;MACvBf;IACJ,CAAC,CAAC;IACFkB,MAAM,EAAE,IAAAkD,oCAA6B,EAAC;MAClCH,MAAM,EAAE3D,QAAQ,CAACY,MAAM;MACvBnB;IACJ,CAAC,CAAC;IACFsB,OAAO,EAAE,IAAAgD,qCAA8B,EAAC;MACpCJ,MAAM,EAAE3D,QAAQ,CAACe,OAAO;MACxBiD,QAAQ,EAAEhE,QAAQ,CAACkB,SAAS;MAC5BxB,OAAO;MACPD;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","name","beforeInit","context","register","types","CompressionPlugin","type","ElasticsearchQueryBuilderOperatorPlugin","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsEntryElasticsearchFieldPlugin","StorageOperationsCmsModelPlugin","mergeByType","init","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n CompressionPlugin,\n ElasticsearchQueryBuilderOperatorPlugin\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchFieldPlugin\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n 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 entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\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 * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n // Elasticsearch\n CompressionPlugin.type,\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsEntryElasticsearchFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAaA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAJA;AACA;AACA;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UAAU;IACVC,KAAK;IACLC,OAAO;IACPC,cAAc;IACdC,aAAa;IACbC,OAAO,EAAEC;EACb,CAAC,GAAGP,MAAM;EAEV,MAAMQ,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BP,KAAK;IACLE;EACJ,CAAC,CAAC;EACF,MAAMM,0BAA0B,GAAG,IAAAC,4CAAwB,EAAC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;MAClCF,MAAM,EAAE3D,QAAQ,CAACS,MAAM;MACvBf;IACJ,CAAC,CAAC;IACFkB,MAAM,EAAE,IAAAkD,oCAA6B,EAAC;MAClCH,MAAM,EAAE3D,QAAQ,CAACY,MAAM;MACvBnB;IACJ,CAAC,CAAC;IACFsB,OAAO,EAAE,IAAAgD,qCAA8B,EAAC;MACpCJ,MAAM,EAAE3D,QAAQ,CAACe,OAAO;MACxBiD,QAAQ,EAAEhE,QAAQ,CAACkB,SAAS;MAC5BxB,OAAO;MACPD;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -26,7 +26,7 @@ const createApplyFiltering = ({
|
|
|
26
26
|
} = params;
|
|
27
27
|
const plugin = operatorPlugins[operator];
|
|
28
28
|
if (!plugin) {
|
|
29
|
-
throw new _error.default("
|
|
29
|
+
throw new _error.default(`Elasticsearch operator "${operator}" plugin missing.`, "PLUGIN_MISSING", {
|
|
30
30
|
operator
|
|
31
31
|
});
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"
|
|
1
|
+
{"version":3,"names":["createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAKA;AAQO,MAAMA,oBAAoB,GAAG,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CAChB,2BAA0BH,QAAS,mBAAkB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CAAC,CACJ;IACL;IAEA,MAAMH,KAAK,GAAG,IAAAO,gDAAuB,EAAC;MAClCV,OAAO,EAAEH,aAAa;MACtBU,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMO,OAAO,GAAG,IAAAC,mBAAU,EAACL,KAAK,CAAC;IAEjC,MAAM;MAAEM,QAAQ;MAAEC;IAAK,CAAC,GAAGhB,eAAe,CAAC;MACvCS,KAAK;MACLJ,KAAK;MACLD,GAAG;MACHS;IACJ,CAAC,CAAC;IAEFH,MAAM,CAACO,KAAK,CAACV,KAAK,EAAE;MAChBW,IAAI,EAAET,KAAK,CAACA,KAAK,CAACU,OAAO;MACzBJ,QAAQ;MACRC,IAAI;MACJX,KAAK;MACLQ;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -21,6 +21,7 @@ var _utils = require("@webiny/utils");
|
|
|
21
21
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
22
22
|
var _body = require("./elasticsearch/body");
|
|
23
23
|
var _recordType = require("./recordType");
|
|
24
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
24
25
|
const getEntryData = input => {
|
|
25
26
|
const output = (0, _objectSpread2.default)({}, input);
|
|
26
27
|
delete output["PK"];
|
|
@@ -76,14 +77,27 @@ const createEntriesStorageOperations = params => {
|
|
|
76
77
|
elasticsearch,
|
|
77
78
|
plugins
|
|
78
79
|
} = params;
|
|
80
|
+
let storageOperationsCmsModelPlugin;
|
|
81
|
+
const getStorageOperationsCmsModelPlugin = () => {
|
|
82
|
+
if (storageOperationsCmsModelPlugin) {
|
|
83
|
+
return storageOperationsCmsModelPlugin;
|
|
84
|
+
}
|
|
85
|
+
storageOperationsCmsModelPlugin = plugins.oneByType(_apiHeadlessCms.StorageOperationsCmsModelPlugin.type);
|
|
86
|
+
return storageOperationsCmsModelPlugin;
|
|
87
|
+
};
|
|
88
|
+
const getStorageOperationsModel = model => {
|
|
89
|
+
const plugin = getStorageOperationsCmsModelPlugin();
|
|
90
|
+
return plugin.getModel(model);
|
|
91
|
+
};
|
|
79
92
|
const dataLoaders = new _dataLoaders.DataLoadersHandler({
|
|
80
93
|
entity
|
|
81
94
|
});
|
|
82
|
-
const create = async (
|
|
95
|
+
const create = async (initialModel, params) => {
|
|
83
96
|
const {
|
|
84
97
|
entry: initialEntry,
|
|
85
98
|
storageEntry: initialStorageEntry
|
|
86
99
|
} = params;
|
|
100
|
+
const model = getStorageOperationsModel(initialModel);
|
|
87
101
|
const isPublished = initialEntry.status === "published";
|
|
88
102
|
const locked = isPublished ? true : initialEntry.locked;
|
|
89
103
|
const entry = convertEntryKeysToStorage({
|
|
@@ -190,11 +204,12 @@ const createEntriesStorageOperations = params => {
|
|
|
190
204
|
}
|
|
191
205
|
return initialStorageEntry;
|
|
192
206
|
};
|
|
193
|
-
const createRevisionFrom = async (
|
|
207
|
+
const createRevisionFrom = async (initialModel, params) => {
|
|
194
208
|
const {
|
|
195
209
|
entry: initialEntry,
|
|
196
210
|
storageEntry: initialStorageEntry
|
|
197
211
|
} = params;
|
|
212
|
+
const model = getStorageOperationsModel(initialModel);
|
|
198
213
|
const entry = convertEntryKeysToStorage({
|
|
199
214
|
model,
|
|
200
215
|
entry: initialEntry
|
|
@@ -270,11 +285,12 @@ const createEntriesStorageOperations = params => {
|
|
|
270
285
|
*/
|
|
271
286
|
return initialStorageEntry;
|
|
272
287
|
};
|
|
273
|
-
const update = async (
|
|
288
|
+
const update = async (initialModel, params) => {
|
|
274
289
|
const {
|
|
275
290
|
entry: initialEntry,
|
|
276
291
|
storageEntry: initialStorageEntry
|
|
277
292
|
} = params;
|
|
293
|
+
const model = getStorageOperationsModel(initialModel);
|
|
278
294
|
const entry = convertEntryKeysToStorage({
|
|
279
295
|
model,
|
|
280
296
|
entry: initialEntry
|
|
@@ -436,10 +452,11 @@ const createEntriesStorageOperations = params => {
|
|
|
436
452
|
}
|
|
437
453
|
return initialStorageEntry;
|
|
438
454
|
};
|
|
439
|
-
const deleteEntry = async (
|
|
455
|
+
const deleteEntry = async (initialModel, params) => {
|
|
440
456
|
const {
|
|
441
457
|
entry
|
|
442
458
|
} = params;
|
|
459
|
+
const model = getStorageOperationsModel(initialModel);
|
|
443
460
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
444
461
|
id: entry.id,
|
|
445
462
|
locale: model.locale,
|
|
@@ -497,12 +514,13 @@ const createEntriesStorageOperations = params => {
|
|
|
497
514
|
});
|
|
498
515
|
}
|
|
499
516
|
};
|
|
500
|
-
const deleteRevision = async (
|
|
517
|
+
const deleteRevision = async (initialModel, params) => {
|
|
501
518
|
const {
|
|
502
519
|
entry,
|
|
503
520
|
latestEntry,
|
|
504
521
|
latestStorageEntry
|
|
505
522
|
} = params;
|
|
523
|
+
const model = getStorageOperationsModel(initialModel);
|
|
506
524
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
507
525
|
id: entry.id,
|
|
508
526
|
locale: model.locale,
|
|
@@ -602,8 +620,9 @@ const createEntriesStorageOperations = params => {
|
|
|
602
620
|
});
|
|
603
621
|
}
|
|
604
622
|
};
|
|
605
|
-
const list = async (
|
|
623
|
+
const list = async (initialModel, params) => {
|
|
606
624
|
var _response, _response$body;
|
|
625
|
+
const model = getStorageOperationsModel(initialModel);
|
|
607
626
|
const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
|
|
608
627
|
const {
|
|
609
628
|
index
|
|
@@ -683,7 +702,8 @@ const createEntriesStorageOperations = params => {
|
|
|
683
702
|
items
|
|
684
703
|
};
|
|
685
704
|
};
|
|
686
|
-
const get = async (
|
|
705
|
+
const get = async (initialModel, params) => {
|
|
706
|
+
const model = getStorageOperationsModel(initialModel);
|
|
687
707
|
const {
|
|
688
708
|
items
|
|
689
709
|
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
@@ -691,11 +711,12 @@ const createEntriesStorageOperations = params => {
|
|
|
691
711
|
}));
|
|
692
712
|
return items.shift() || null;
|
|
693
713
|
};
|
|
694
|
-
const publish = async (
|
|
714
|
+
const publish = async (initialModel, params) => {
|
|
695
715
|
const {
|
|
696
716
|
entry: initialEntry,
|
|
697
717
|
storageEntry: initialStorageEntry
|
|
698
718
|
} = params;
|
|
719
|
+
const model = getStorageOperationsModel(initialModel);
|
|
699
720
|
const entry = convertEntryKeysToStorage({
|
|
700
721
|
model,
|
|
701
722
|
entry: initialEntry
|
|
@@ -873,11 +894,12 @@ const createEntriesStorageOperations = params => {
|
|
|
873
894
|
}
|
|
874
895
|
return initialStorageEntry;
|
|
875
896
|
};
|
|
876
|
-
const unpublish = async (
|
|
897
|
+
const unpublish = async (initialModel, params) => {
|
|
877
898
|
const {
|
|
878
899
|
entry: initialEntry,
|
|
879
900
|
storageEntry: initialStorageEntry
|
|
880
901
|
} = params;
|
|
902
|
+
const model = getStorageOperationsModel(initialModel);
|
|
881
903
|
const entry = convertEntryKeysToStorage({
|
|
882
904
|
model,
|
|
883
905
|
entry: initialEntry
|
|
@@ -968,7 +990,8 @@ const createEntriesStorageOperations = params => {
|
|
|
968
990
|
}
|
|
969
991
|
return initialStorageEntry;
|
|
970
992
|
};
|
|
971
|
-
const getLatestRevisionByEntryId = async (
|
|
993
|
+
const getLatestRevisionByEntryId = async (initialModel, params) => {
|
|
994
|
+
const model = getStorageOperationsModel(initialModel);
|
|
972
995
|
const [entry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
973
996
|
model,
|
|
974
997
|
ids: [params.id]
|
|
@@ -981,7 +1004,8 @@ const createEntriesStorageOperations = params => {
|
|
|
981
1004
|
entry
|
|
982
1005
|
});
|
|
983
1006
|
};
|
|
984
|
-
const getPublishedRevisionByEntryId = async (
|
|
1007
|
+
const getPublishedRevisionByEntryId = async (initialModel, params) => {
|
|
1008
|
+
const model = getStorageOperationsModel(initialModel);
|
|
985
1009
|
const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
986
1010
|
model,
|
|
987
1011
|
ids: [params.id]
|
|
@@ -994,7 +1018,8 @@ const createEntriesStorageOperations = params => {
|
|
|
994
1018
|
entry
|
|
995
1019
|
});
|
|
996
1020
|
};
|
|
997
|
-
const getRevisionById = async (
|
|
1021
|
+
const getRevisionById = async (initialModel, params) => {
|
|
1022
|
+
const model = getStorageOperationsModel(initialModel);
|
|
998
1023
|
const [entry] = await dataLoaders.getRevisionById({
|
|
999
1024
|
model,
|
|
1000
1025
|
ids: [params.id]
|
|
@@ -1007,7 +1032,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1007
1032
|
entry
|
|
1008
1033
|
});
|
|
1009
1034
|
};
|
|
1010
|
-
const getRevisions = async (
|
|
1035
|
+
const getRevisions = async (initialModel, params) => {
|
|
1036
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1011
1037
|
const entries = await dataLoaders.getAllEntryRevisions({
|
|
1012
1038
|
model,
|
|
1013
1039
|
ids: [params.id]
|
|
@@ -1019,7 +1045,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1019
1045
|
});
|
|
1020
1046
|
});
|
|
1021
1047
|
};
|
|
1022
|
-
const getByIds = async (
|
|
1048
|
+
const getByIds = async (initialModel, params) => {
|
|
1049
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1023
1050
|
const entries = await dataLoaders.getRevisionById({
|
|
1024
1051
|
model,
|
|
1025
1052
|
ids: params.ids
|
|
@@ -1031,7 +1058,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1031
1058
|
});
|
|
1032
1059
|
});
|
|
1033
1060
|
};
|
|
1034
|
-
const getLatestByIds = async (
|
|
1061
|
+
const getLatestByIds = async (initialModel, params) => {
|
|
1062
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1035
1063
|
const entries = await dataLoaders.getLatestRevisionByEntryId({
|
|
1036
1064
|
model,
|
|
1037
1065
|
ids: params.ids
|
|
@@ -1043,7 +1071,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1043
1071
|
});
|
|
1044
1072
|
});
|
|
1045
1073
|
};
|
|
1046
|
-
const getPublishedByIds = async (
|
|
1074
|
+
const getPublishedByIds = async (initialModel, params) => {
|
|
1075
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1047
1076
|
const entries = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1048
1077
|
model,
|
|
1049
1078
|
ids: params.ids
|
|
@@ -1055,7 +1084,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1055
1084
|
});
|
|
1056
1085
|
});
|
|
1057
1086
|
};
|
|
1058
|
-
const getPreviousRevision = async (
|
|
1087
|
+
const getPreviousRevision = async (initialModel, params) => {
|
|
1088
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1059
1089
|
const {
|
|
1060
1090
|
tenant,
|
|
1061
1091
|
locale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getEntryData","input","output","getESLatestEntryData","plugins","entry","compress","latest","TYPE","createLatestRecordType","__type","getESPublishedEntryData","published","createPublishedRecordType","convertEntryKeysToStorage","params","model","values","convertValueKeyToStorage","fields","convertEntryKeysFromStorage","convertValueKeyFromStorage","createEntriesStorageOperations","entity","esEntity","elasticsearch","dataLoaders","DataLoadersHandler","create","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","esEntry","prepareEntryToIndex","lodashCloneDeep","index","esIndex","configurations","es","esLatestData","esPublishedData","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","createRecordType","push","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esItems","data","createRevisionFrom","put","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","undefined","elasticsearchLatestData","elasticsearchPublishedData","length","deleteEntry","partitionKey","queryAll","options","gte","deleteItems","map","item","deleteBatch","deleteEsItems","deleteRevision","latestEntry","list","limit","createLimit","result","indices","exists","body","hasMoreItems","totalCount","cursor","createElasticsearchBody","after","decodeCursor","response","search","hits","total","extractEntriesFromIndex","entries","_source","pop","encodeCursor","sort","value","get","shift","publish","latestEsEntry","getRecord","keys","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","savedOn","latestEsEntryDataDecompressed","decompress","PUBLISHED","publishedOn","preparedEntryData","unpublish","getRevisions","getAllEntryRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","entryId","version","queryParams","lt","zeroPad","filters","attr","eq","reverse","queryOne","cleanupItem","delete"],"sources":["index.ts"],"sourcesContent":["import lodashCloneDeep from \"lodash/cloneDeep\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsEntryStorageOperations,\n CmsEntryStorageOperationsCreateParams,\n CmsEntryStorageOperationsCreateRevisionFromParams,\n CmsEntryStorageOperationsDeleteParams,\n CmsEntryStorageOperationsDeleteRevisionParams,\n CmsEntryStorageOperationsGetByIdsParams,\n CmsEntryStorageOperationsGetLatestByIdsParams,\n CmsEntryStorageOperationsGetLatestRevisionParams,\n CmsEntryStorageOperationsGetParams,\n CmsEntryStorageOperationsGetPreviousRevisionParams,\n CmsEntryStorageOperationsGetPublishedByIdsParams,\n CmsEntryStorageOperationsGetRevisionParams,\n CmsEntryStorageOperationsGetRevisionsParams,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsPublishParams,\n CmsEntryStorageOperationsUnpublishParams,\n CmsEntryStorageOperationsUpdateParams,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex, prepareEntryToIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { queryAll, queryOne, QueryOneParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLimit,\n encodeCursor,\n compress,\n decompress,\n decodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"~/operations/entry/elasticsearch/body\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\n\nconst getEntryData = (input: CmsEntry): CmsEntry => {\n const output: any = {\n ...input\n };\n delete output[\"PK\"];\n delete output[\"SK\"];\n delete output[\"published\"];\n delete output[\"latest\"];\n\n return output;\n};\n\nconst getESLatestEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n });\n};\n\nconst getESPublishedEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n });\n};\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nconst convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, string>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({ ...entry, locked }),\n storageEntry: lodashCloneDeep({ ...storageEntry, locked })\n });\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n const esPublishedData = await getESPublishedEntryData(plugins, esEntry);\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esItems = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n const { index } = configurations.es({\n model\n });\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * Update the \"latest\" entry item in the Elasticsearch\n */\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n data: esLatestData\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUpdateParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n /**\n * Variable for the elasticsearch entry so we do not convert it more than once\n */\n let esEntry: CmsIndexEntry | undefined = undefined;\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n let elasticsearchLatestData: any = null;\n if (latestStorageEntry?.id === entry.id) {\n /**\n * First we update the regular DynamoDB table\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestSortKey()\n })\n );\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n\n elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n }\n let elasticsearchPublishedData = null;\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n if (!elasticsearchLatestData) {\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n if (!esEntry) {\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n }\n elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);\n } else {\n elasticsearchPublishedData = {\n ...elasticsearchLatestData,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n };\n delete elasticsearchPublishedData.latest;\n }\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const deleteEntry = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteParams\n ) => {\n const { entry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n };\n\n const deleteRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (latestEntry && latestStorageEntry) {\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(latestEntry),\n storageEntry: lodashCloneDeep(latestStorageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n /**\n * In the end we need to set the new latest entry\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const list = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => {\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"ELASTICSEARCH_ERROR\", {\n error: ex,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetParams\n ) => {\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsPublishParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getRecord<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest or published data.\",\n ex.code || \"PUBLISH_BATCH_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems = [];\n\n const { index } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n savedOn: entry.savedOn,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n /**\n * If we are publishing the latest revision, let's also update the latest revision's status in ES.\n */\n if (latestEsEntry && latestStorageEntry?.id === entry.id) {\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed: CmsEntry = (await decompress(\n plugins,\n latestEsEntry.data\n )) as any;\n\n esItems.push(\n esEntity.putBatch({\n index,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await getESLatestEntryData(plugins, {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n savedOn: entry.savedOn,\n publishedOn: entry.publishedOn\n })\n })\n );\n }\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);\n\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsUnpublishParams\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n const getPublishedRevisionByEntryId = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => {\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => {\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => {\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetByIdsParams\n ) => {\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => {\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => {\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision = async (\n model: StorageOperationsCmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => {\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAuBA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAGA;AACA;AAEA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAAK,CACX;EACD,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,WAAW,CAAC;EAC1B,OAAOA,MAAM,CAAC,QAAQ,CAAC;EAEvB,OAAOA,MAAM;AACjB,CAAC;AAED,MAAMC,oBAAoB,GAAG,OAAOC,OAAyB,EAAEC,KAAe,KAAK;EAC/E,OAAO,IAAAC,0BAAQ,EAACF,OAAO,8DAChBJ,YAAY,CAACK,KAAK,CAAC;IACtBE,MAAM,EAAE,IAAI;IACZC,IAA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ZC,EAAE,EAAE,IAAA1F,4BAAgB;QACxB,CAAC,EACD;UACIyF,IAAI,EAAE,SAAS;UACfH,EAAE,EAAEF;QACR,CAAC,CACJ;QACDO,OAAO,EAAE;MACb;IACJ,CAAC;IAED,IAAI;MACA,MAAMpD,MAAM,GAAG,MAAM,IAAAqD,eAAQ,EAAWP,WAAW,CAAC;MAEpD,MAAM1I,KAAK,GAAG,IAAAkJ,oBAAW,EAAChI,MAAM,EAAE0E,MAAM,CAAC;MAEzC,IAAI,CAAC5F,KAAK,EAAE;QACR,OAAO,IAAI;MACf;MACA,OAAOe,2BAA2B,CAAC;QAC/Bf,KAAK;QACLW;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAO+C,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,gDAAgD,EAC9DF,EAAE,CAACG,IAAI,IAAI,4BAA4B,8DAEhCnD,MAAM;QACToD,KAAK,EAAEJ,EAAE;QACToB,YAAY,EAAE4D,WAAW,CAAC5D,YAAY;QACtCE,OAAO,EAAE0D,WAAW,CAAC1D,OAAO;QAC5BrE;MAAK,GAEZ;IACL;EACJ,CAAC;EAED,OAAO;IACHY,MAAM;IACN0C,kBAAkB;IAClBE,MAAM;IACNgF,MAAM,EAAEtE,WAAW;IACnBU,cAAc;IACd0B,GAAG;IACHE,OAAO;IACPc,SAAS;IACTxC,IAAI;IACJpB,0BAA0B;IAC1BG,6BAA6B;IAC7BgD,eAAe;IACfU,YAAY;IACZE,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
1
|
+
{"version":3,"names":["getEntryData","input","output","getESLatestEntryData","plugins","entry","compress","latest","TYPE","createLatestRecordType","__type","getESPublishedEntryData","published","createPublishedRecordType","convertEntryKeysToStorage","params","model","values","convertValueKeyToStorage","fields","convertEntryKeysFromStorage","convertValueKeyFromStorage","createEntriesStorageOperations","entity","esEntity","elasticsearch","storageOperationsCmsModelPlugin","getStorageOperationsCmsModelPlugin","oneByType","StorageOperationsCmsModelPlugin","type","getStorageOperationsModel","plugin","getModel","dataLoaders","DataLoadersHandler","create","initialModel","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","esEntry","prepareEntryToIndex","lodashCloneDeep","index","esIndex","configurations","es","esLatestData","esPublishedData","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","createRecordType","push","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esItems","data","createRevisionFrom","put","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","undefined","elasticsearchLatestData","elasticsearchPublishedData","length","deleteEntry","partitionKey","queryAll","options","gte","deleteItems","map","item","deleteBatch","deleteEsItems","deleteRevision","latestEntry","list","limit","createLimit","result","indices","exists","body","hasMoreItems","totalCount","cursor","createElasticsearchBody","after","decodeCursor","response","search","hits","total","extractEntriesFromIndex","entries","_source","pop","encodeCursor","sort","value","get","shift","publish","latestEsEntry","getRecord","keys","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","savedOn","latestEsEntryDataDecompressed","decompress","PUBLISHED","publishedOn","preparedEntryData","unpublish","getRevisions","getAllEntryRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","entryId","version","queryParams","lt","zeroPad","filters","attr","eq","reverse","queryOne","cleanupItem","delete"],"sources":["index.ts"],"sourcesContent":["import lodashCloneDeep from \"lodash/cloneDeep\";\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsEntryStorageOperations,\n CmsModel,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex, prepareEntryToIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"~/operations/entry/keys\";\nimport { queryAll, queryOne, QueryOneParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n compress,\n createLimit,\n decodeCursor,\n decompress,\n encodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { ElasticsearchSearchResponse } from \"@webiny/api-elasticsearch/types\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"~/operations/entry/elasticsearch/body\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\n\nconst getEntryData = (input: CmsEntry): CmsEntry => {\n const output: any = {\n ...input\n };\n delete output[\"PK\"];\n delete output[\"SK\"];\n delete output[\"published\"];\n delete output[\"latest\"];\n\n return output;\n};\n\nconst getESLatestEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n });\n};\n\nconst getESPublishedEntryData = async (plugins: PluginsContainer, entry: CmsEntry) => {\n return compress(plugins, {\n ...getEntryData(entry),\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n });\n};\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nconst convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nconst convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, string>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n let storageOperationsCmsModelPlugin: StorageOperationsCmsModelPlugin | undefined;\n const getStorageOperationsCmsModelPlugin = () => {\n if (storageOperationsCmsModelPlugin) {\n return storageOperationsCmsModelPlugin;\n }\n storageOperationsCmsModelPlugin = plugins.oneByType<StorageOperationsCmsModelPlugin>(\n StorageOperationsCmsModelPlugin.type\n );\n return storageOperationsCmsModelPlugin;\n };\n\n const getStorageOperationsModel = (model: CmsModel): StorageOperationsCmsModel => {\n const plugin = getStorageOperationsCmsModelPlugin();\n return plugin.getModel(model);\n };\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create: CmsEntryStorageOperations[\"create\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = getStorageOperationsModel(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({ ...entry, locked }),\n storageEntry: lodashCloneDeep({ ...storageEntry, locked })\n });\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n const esPublishedData = await getESPublishedEntryData(plugins, esEntry);\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esItems = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom: CmsEntryStorageOperations[\"createRevisionFrom\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n const { index } = configurations.es({\n model\n });\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n /**\n * Update the \"latest\" entry item in the Elasticsearch\n */\n try {\n await esEntity.put({\n ...latestKeys,\n index,\n data: esLatestData\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update: CmsEntryStorageOperations[\"update\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n /**\n * Variable for the elasticsearch entry so we do not convert it more than once\n */\n let esEntry: CmsIndexEntry | undefined = undefined;\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n let elasticsearchLatestData: any = null;\n if (latestStorageEntry?.id === entry.id) {\n /**\n * First we update the regular DynamoDB table\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestSortKey()\n })\n );\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n\n elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n }\n let elasticsearchPublishedData = null;\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n if (!elasticsearchLatestData) {\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n if (!esEntry) {\n esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep({\n ...entry,\n locked\n }),\n storageEntry: lodashCloneDeep({\n ...storageEntry,\n locked\n })\n });\n }\n elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);\n } else {\n elasticsearchPublishedData = {\n ...elasticsearchLatestData,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n };\n delete elasticsearchPublishedData.latest;\n }\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const deleteEntry: CmsEntryStorageOperations[\"delete\"] = async (initialModel, params) => {\n const { entry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n };\n\n const deleteRevision: CmsEntryStorageOperations[\"deleteRevision\"] = async (\n initialModel,\n params\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n if (latestEntry && latestStorageEntry) {\n const esEntry = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(latestEntry),\n storageEntry: lodashCloneDeep(latestStorageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, esEntry);\n /**\n * In the end we need to set the new latest entry\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const list: CmsEntryStorageOperations[\"list\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n try {\n const result = await elasticsearch.indices.exists({\n index\n });\n if (!result?.body) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n } catch (ex) {\n throw new WebinyError(\n \"Could not determine if Elasticsearch index exists.\",\n \"ELASTICSEARCH_INDEX_CHECK_ERROR\",\n {\n error: ex,\n index\n }\n );\n }\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (ex) {\n throw new WebinyError(ex.message, ex.code || \"ELASTICSEARCH_ERROR\", {\n error: ex,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get: CmsEntryStorageOperations[\"get\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish: CmsEntryStorageOperations[\"publish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getRecord<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest or published data.\",\n ex.code || \"PUBLISH_BATCH_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems = [];\n\n const { index } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n savedOn: entry.savedOn,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n /**\n * If we are publishing the latest revision, let's also update the latest revision's status in ES.\n */\n if (latestEsEntry && latestStorageEntry?.id === entry.id) {\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed: CmsEntry = (await decompress(\n plugins,\n latestEsEntry.data\n )) as any;\n\n esItems.push(\n esEntity.putBatch({\n index,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await getESLatestEntryData(plugins, {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n savedOn: entry.savedOn,\n publishedOn: entry.publishedOn\n })\n })\n );\n }\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);\n\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish: CmsEntryStorageOperations[\"unpublish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const entry = convertEntryKeysToStorage({\n model,\n entry: initialEntry\n });\n const storageEntry = convertEntryKeysToStorage({\n model,\n entry: initialStorageEntry\n });\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n const preparedEntryData = prepareEntryToIndex({\n plugins,\n model,\n entry: lodashCloneDeep(entry),\n storageEntry: lodashCloneDeep(storageEntry)\n });\n\n const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId: CmsEntryStorageOperations[\"getLatestRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getPublishedRevisionByEntryId: CmsEntryStorageOperations[\"getPublishedRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById: CmsEntryStorageOperations[\"getRevisionById\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions: CmsEntryStorageOperations[\"getRevisions\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds: CmsEntryStorageOperations[\"getByIds\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds: CmsEntryStorageOperations[\"getLatestByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds: CmsEntryStorageOperations[\"getPublishedByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision: CmsEntryStorageOperations[\"getPreviousRevision\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n delete: deleteEntry,\n deleteRevision,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AAQA;AACA;AAIA;AACA;AACA;AAMA;AACA;AAOA;AACA;AACA;AAGA;AACA;AACA;AAEA,MAAMA,YAAY,GAAIC,KAAe,IAAe;EAChD,MAAMC,MAAW,mCACVD,KAAK,CACX;EACD,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,WAAW,CAA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;IACZE,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC;EACJ,CAAC;AACL,CAAC;AAAC"}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createModelsStorageOperations = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _configurations = require("../../configurations");
|
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
10
|
+
var _configurations = require("../../configurations");
|
|
11
11
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
12
12
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
13
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { configurations } from \"~/configurations\";\nimport WebinyError from \"@webiny/error\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;AAUA;AACA;AAEA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAQ,KAAIC,MAAO,MAAKC,MAAO,SAAQ;AAC3C,CAAC;AAKD,MAAMC,aAAa,GAAIH,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACI,OAAO;AACzB,CAAC;AAMD,MAAMC,UAAU,GAAIL,MAA2C,IAAW;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AAC"}
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { configurations } from \"~/configurations\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAWA;AAEA;AACA;AACA;AAOA,MAAMA,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAQ,KAAIC,MAAO,MAAKC,MAAO,SAAQ;AAC3C,CAAC;AAMD,MAAMC,aAAa,GAAIH,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACI,OAAO;AACzB,CAAC;AAOD,MAAMC,UAAU,GAAIL,MAA2C,IAAW;EACtE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,aAAa,CAACH,MAAM;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAG,MAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOM,MAAMC,6BAA6B,GACtCT,MAA2C,IACf;EAC5B,MAAM;IAAEU,MAAM;IAAEC;EAAc,CAAC,GAAGX,MAAM;EAExC,MAAMY,MAAM,GAAG,MAAOZ,MAA6C,IAAK;IACpE,MAAM;MAAEa;IAAM,CAAC,GAAGb,MAAM;IAExB,MAAM;MAAEc;IAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;MAChCH;IACJ,CAAC,CAAC;IAEF,MAAMI,IAA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AC,CACJ;IACL;EACJ,CAAC;EAED,MAAMmB,IAAI,GAAG,MAAOpC,MAA2C,IAAK;IAChE,MAAM;MAAEqC;IAAM,CAAC,GAAGrC,MAAM;IACxB,MAAMsC,cAA8B,GAAG;MACnC5B,MAAM;MACN6B,YAAY,EAAExC,kBAAkB,CAACsC,KAAK,CAAC;MACvCG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IACD,IAAI;MACA,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAWL,cAAc,CAAC;MAEtD,OAAO,IAAAM,qBAAY,EAAClC,MAAM,EAAEgC,KAAK,CAAC;IACtC,CAAC,CAAC,OAAOpB,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,wBAAwB,EACtCR,EAAE,CAACS,IAAI,IAAI,kBAAkB,EAC7B;QACIb,KAAK,EAAEI,EAAE;QACTiB,YAAY,EAAED,cAAc,CAACC;MACjC,CAAC,CACJ;IACL;EACJ,CAAC;EAED,OAAO;IACH3B,MAAM;IACNiB,MAAM;IACNL,MAAM,EAAEQ,WAAW;IACnBC,GAAG;IACHG;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.da99e0b846",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "7.20.13",
|
|
26
|
-
"@webiny/api": "0.0.0-unstable.
|
|
27
|
-
"@webiny/api-elasticsearch": "0.0.0-unstable.
|
|
28
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
29
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
30
|
-
"@webiny/error": "0.0.0-unstable.
|
|
31
|
-
"@webiny/handler-db": "0.0.0-unstable.
|
|
32
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
33
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
26
|
+
"@webiny/api": "0.0.0-unstable.da99e0b846",
|
|
27
|
+
"@webiny/api-elasticsearch": "0.0.0-unstable.da99e0b846",
|
|
28
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.da99e0b846",
|
|
29
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.da99e0b846",
|
|
30
|
+
"@webiny/error": "0.0.0-unstable.da99e0b846",
|
|
31
|
+
"@webiny/handler-db": "0.0.0-unstable.da99e0b846",
|
|
32
|
+
"@webiny/plugins": "0.0.0-unstable.da99e0b846",
|
|
33
|
+
"@webiny/utils": "0.0.0-unstable.da99e0b846",
|
|
34
34
|
"dataloader": "2.2.1",
|
|
35
35
|
"dynamodb-toolbox": "0.3.5",
|
|
36
36
|
"jsonpack": "1.1.5",
|
|
@@ -42,10 +42,17 @@
|
|
|
42
42
|
"@babel/preset-env": "^7.19.4",
|
|
43
43
|
"@elastic/elasticsearch": "7.12.0",
|
|
44
44
|
"@types/jsonpack": "^1.1.0",
|
|
45
|
-
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.
|
|
46
|
-
"@webiny/
|
|
47
|
-
"@webiny/
|
|
48
|
-
"@webiny/
|
|
45
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^0.0.0-unstable.da99e0b846",
|
|
46
|
+
"@webiny/api-i18n": "^0.0.0-unstable.da99e0b846",
|
|
47
|
+
"@webiny/api-i18n-ddb": "^0.0.0-unstable.da99e0b846",
|
|
48
|
+
"@webiny/api-security": "^0.0.0-unstable.da99e0b846",
|
|
49
|
+
"@webiny/api-security-so-ddb": "^0.0.0-unstable.da99e0b846",
|
|
50
|
+
"@webiny/api-tenancy": "^0.0.0-unstable.da99e0b846",
|
|
51
|
+
"@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.da99e0b846",
|
|
52
|
+
"@webiny/cli": "^0.0.0-unstable.da99e0b846",
|
|
53
|
+
"@webiny/handler": "^0.0.0-unstable.da99e0b846",
|
|
54
|
+
"@webiny/handler-aws": "^0.0.0-unstable.da99e0b846",
|
|
55
|
+
"@webiny/project-utils": "^0.0.0-unstable.da99e0b846",
|
|
49
56
|
"jest": "^28.1.0",
|
|
50
57
|
"jest-dynalite": "^3.2.0",
|
|
51
58
|
"jest-environment-node": "^27.2.4",
|
|
@@ -64,5 +71,5 @@
|
|
|
64
71
|
"build": "yarn webiny run build",
|
|
65
72
|
"watch": "yarn webiny run watch"
|
|
66
73
|
},
|
|
67
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "da99e0b8461741d3ae57fdb9d4b2fc7646c1d754"
|
|
68
75
|
}
|