@webiny/migrations 6.0.0-alpha.5 → 6.0.0-rc.0

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.
Files changed (85) hide show
  1. package/LICENSE +2 -7
  2. package/README.md +11 -1
  3. package/ddb-es.d.ts +1 -2
  4. package/ddb-es.js +2 -10
  5. package/ddb-es.js.map +1 -1
  6. package/ddb.d.ts +1 -2
  7. package/ddb.js +2 -10
  8. package/ddb.js.map +1 -1
  9. package/package.json +19 -22
  10. package/utils/createEntity.d.ts +3 -90
  11. package/utils/createEntity.js +3 -37
  12. package/utils/createEntity.js.map +1 -1
  13. package/utils/createTenantEntity.d.ts +2 -48
  14. package/utils/createTenantEntity.js +3 -10
  15. package/utils/createTenantEntity.js.map +1 -1
  16. package/utils/dynamoDb.d.ts +2 -2
  17. package/utils/dynamoDb.js +2 -60
  18. package/utils/dynamoDb.js.map +1 -1
  19. package/utils/elasticsearch/disableEsIndexing.js +3 -10
  20. package/utils/elasticsearch/disableEsIndexing.js.map +1 -1
  21. package/utils/elasticsearch/esCreateIndex.d.ts +0 -1
  22. package/utils/elasticsearch/esCreateIndex.js +8 -24
  23. package/utils/elasticsearch/esCreateIndex.js.map +1 -1
  24. package/utils/elasticsearch/esFindOne.d.ts +1 -1
  25. package/utils/elasticsearch/esFindOne.js +1 -8
  26. package/utils/elasticsearch/esFindOne.js.map +1 -1
  27. package/utils/elasticsearch/esGetIndexExist.d.ts +0 -1
  28. package/utils/elasticsearch/esGetIndexExist.js +4 -13
  29. package/utils/elasticsearch/esGetIndexExist.js.map +1 -1
  30. package/utils/elasticsearch/esGetIndexName.d.ts +0 -1
  31. package/utils/elasticsearch/esGetIndexName.js +8 -24
  32. package/utils/elasticsearch/esGetIndexName.js.map +1 -1
  33. package/utils/elasticsearch/esGetIndexSettings.js +5 -13
  34. package/utils/elasticsearch/esGetIndexSettings.js.map +1 -1
  35. package/utils/elasticsearch/esListIndexes.js +1 -8
  36. package/utils/elasticsearch/esListIndexes.js.map +1 -1
  37. package/utils/elasticsearch/esPutIndexSettings.js +3 -11
  38. package/utils/elasticsearch/esPutIndexSettings.js.map +1 -1
  39. package/utils/elasticsearch/esQueryAll.d.ts +1 -1
  40. package/utils/elasticsearch/esQueryAll.js +3 -10
  41. package/utils/elasticsearch/esQueryAll.js.map +1 -1
  42. package/utils/elasticsearch/esQueryAllWithCallback.d.ts +1 -1
  43. package/utils/elasticsearch/esQueryAllWithCallback.js +3 -10
  44. package/utils/elasticsearch/esQueryAllWithCallback.js.map +1 -1
  45. package/utils/elasticsearch/fetchOriginalEsSettings.js +3 -10
  46. package/utils/elasticsearch/fetchOriginalEsSettings.js.map +1 -1
  47. package/utils/elasticsearch/index.d.ts +12 -12
  48. package/utils/elasticsearch/index.js +12 -137
  49. package/utils/elasticsearch/index.js.map +1 -1
  50. package/utils/elasticsearch/plugins/base.js +3 -9
  51. package/utils/elasticsearch/plugins/base.js.map +1 -1
  52. package/utils/elasticsearch/plugins/index.d.ts +1 -1
  53. package/utils/elasticsearch/plugins/index.js +3 -11
  54. package/utils/elasticsearch/plugins/index.js.map +1 -1
  55. package/utils/elasticsearch/restoreOriginalEsSettings.js +3 -10
  56. package/utils/elasticsearch/restoreOriginalEsSettings.js.map +1 -1
  57. package/utils/getCompressedData.js +3 -10
  58. package/utils/getCompressedData.js.map +1 -1
  59. package/utils/index.d.ts +5 -7
  60. package/utils/index.js +5 -82
  61. package/utils/index.js.map +1 -1
  62. package/migrations/5.43.0/001/constants.d.ts +0 -2
  63. package/migrations/5.43.0/001/constants.js +0 -10
  64. package/migrations/5.43.0/001/constants.js.map +0 -1
  65. package/migrations/5.43.0/001/ddb/index.d.ts +0 -13
  66. package/migrations/5.43.0/001/ddb/index.js +0 -215
  67. package/migrations/5.43.0/001/ddb/index.js.map +0 -1
  68. package/migrations/5.43.0/001/ddb-es/index.d.ts +0 -16
  69. package/migrations/5.43.0/001/ddb-es/index.js +0 -257
  70. package/migrations/5.43.0/001/ddb-es/index.js.map +0 -1
  71. package/migrations/5.43.0/001/entities/createEntryEntity.d.ts +0 -91
  72. package/migrations/5.43.0/001/entities/createEntryEntity.js +0 -188
  73. package/migrations/5.43.0/001/entities/createEntryEntity.js.map +0 -1
  74. package/migrations/5.43.0/001/types.d.ts +0 -47
  75. package/migrations/5.43.0/001/types.js +0 -7
  76. package/migrations/5.43.0/001/types.js.map +0 -1
  77. package/utils/createLocaleEntity.d.ts +0 -42
  78. package/utils/createLocaleEntity.js +0 -32
  79. package/utils/createLocaleEntity.js.map +0 -1
  80. package/utils/elasticsearch/plugins/japanese.d.ts +0 -4
  81. package/utils/elasticsearch/plugins/japanese.js +0 -13
  82. package/utils/elasticsearch/plugins/japanese.js.map +0 -1
  83. package/utils/forEachTenantLocale.d.ts +0 -22
  84. package/utils/forEachTenantLocale.js +0 -55
  85. package/utils/forEachTenantLocale.js.map +0 -1
package/LICENSE CHANGED
@@ -1,11 +1,6 @@
1
- Copyright (c) Webiny Inc.
1
+ MIT License
2
2
 
3
- Portions of this software are licensed as follows:
4
-
5
- * All content that resides under the "enterprise/" directories of this repository, is licensed under the license defined in their respective "enterprise/LICENSE" file.
6
- * All content that resides under the "packages/" sub-directories of this repository, is licensed under the license defined in their respective "packages/*/LICENSE" file.
7
- * All third party components incorporated into the Webiny Software are licensed under the original license provided by the owner of the applicable component.
8
- * Content outside of the above mentioned directories or restrictions above is available under the "MIT" license as defined below.
3
+ Copyright (c) Webiny
9
4
 
10
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
11
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1 +1,11 @@
1
- # Webiny Data Migrations
1
+ # @webiny/migrations
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/ddb-es.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { Flp_5_43_0_001 } from "./migrations/5.43.0/001/ddb-es";
2
- export declare const migrations: () => (typeof Flp_5_43_0_001)[];
1
+ export declare const migrations: () => never[];
package/ddb-es.js CHANGED
@@ -1,17 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.migrations = void 0;
7
- var _ddbEs = require("./migrations/5.43.0/001/ddb-es");
8
1
  // We only list current version migrations here. No need to have them all
9
2
  // listed, as we only need the latest version migrations to be executed.
10
3
  // This also helps with keeping the bundle size down / faster boot times.
11
4
 
12
- const migrations = () => {
13
- return [_ddbEs.Flp_5_43_0_001];
5
+ export const migrations = () => {
6
+ return [];
14
7
  };
15
- exports.migrations = migrations;
16
8
 
17
9
  //# sourceMappingURL=ddb-es.js.map
package/ddb-es.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_ddbEs","require","migrations","Flp_5_43_0_001","exports"],"sources":["ddb-es.ts"],"sourcesContent":["// We only list current version migrations here. No need to have them all\n// listed, as we only need the latest version migrations to be executed.\n// This also helps with keeping the bundle size down / faster boot times.\nimport { Flp_5_43_0_001 } from \"~/migrations/5.43.0/001/ddb-es/\";\n\nexport const migrations = () => {\n return [Flp_5_43_0_001];\n};\n"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,CAACC,qBAAc,CAAC;AAC3B,CAAC;AAACC,OAAA,CAAAF,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["migrations"],"sources":["ddb-es.ts"],"sourcesContent":["// We only list current version migrations here. No need to have them all\n// listed, as we only need the latest version migrations to be executed.\n// This also helps with keeping the bundle size down / faster boot times.\n\nexport const migrations = () => {\n return [];\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,EAAE;AACb,CAAC","ignoreList":[]}
package/ddb.d.ts CHANGED
@@ -1,2 +1 @@
1
- import { Flp_5_43_0_001 } from "./migrations/5.43.0/001/ddb";
2
- export declare const migrations: () => (typeof Flp_5_43_0_001)[];
1
+ export declare const migrations: () => never[];
package/ddb.js CHANGED
@@ -1,17 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.migrations = void 0;
7
- var _ddb = require("./migrations/5.43.0/001/ddb");
8
1
  // We only list current version migrations here. No need to have them all
9
2
  // listed, as we only need the latest version migrations to be executed.
10
3
  // This also helps with keeping the bundle size down / faster boot times.
11
4
 
12
- const migrations = () => {
13
- return [_ddb.Flp_5_43_0_001];
5
+ export const migrations = () => {
6
+ return [];
14
7
  };
15
- exports.migrations = migrations;
16
8
 
17
9
  //# sourceMappingURL=ddb.js.map
package/ddb.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_ddb","require","migrations","Flp_5_43_0_001","exports"],"sources":["ddb.ts"],"sourcesContent":["// We only list current version migrations here. No need to have them all\n// listed, as we only need the latest version migrations to be executed.\n// This also helps with keeping the bundle size down / faster boot times.\nimport { Flp_5_43_0_001 } from \"~/migrations/5.43.0/001/ddb\";\n\nexport const migrations = () => {\n return [Flp_5_43_0_001];\n};\n"],"mappings":";;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGO,MAAMC,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,CAACC,mBAAc,CAAC;AAC3B,CAAC;AAACC,OAAA,CAAAF,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["migrations"],"sources":["ddb.ts"],"sourcesContent":["// We only list current version migrations here. No need to have them all\n// listed, as we only need the latest version migrations to be executed.\n// This also helps with keeping the bundle size down / faster boot times.\n\nexport const migrations = () => {\n return [];\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAU,GAAGA,CAAA,KAAM;EAC5B,OAAO,EAAE;AACb,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,36 +1,33 @@
1
1
  {
2
2
  "name": "@webiny/migrations",
3
- "version": "6.0.0-alpha.5",
4
- "scripts": {
5
- "build": "node ../cli/bin.js run build",
6
- "watch": "node ../cli/bin.js run watch"
7
- },
3
+ "version": "6.0.0-rc.0",
4
+ "type": "module",
8
5
  "dependencies": {
9
6
  "@elastic/elasticsearch": "7.12.0",
10
- "@webiny/api-elasticsearch": "6.0.0-alpha.5",
11
- "@webiny/aws-sdk": "6.0.0-alpha.5",
12
- "@webiny/data-migration": "6.0.0-alpha.5",
13
- "@webiny/db-dynamodb": "6.0.0-alpha.5",
14
- "@webiny/error": "6.0.0-alpha.5",
15
- "@webiny/ioc": "6.0.0-alpha.5",
16
- "@webiny/logger": "6.0.0-alpha.5",
17
- "@webiny/tasks": "6.0.0-alpha.5",
18
- "@webiny/utils": "6.0.0-alpha.5",
19
- "lodash": "4.17.21"
7
+ "@webiny/api-elasticsearch": "6.0.0-rc.0",
8
+ "@webiny/aws-sdk": "6.0.0-rc.0",
9
+ "@webiny/data-migration": "6.0.0-rc.0",
10
+ "@webiny/db-dynamodb": "6.0.0-rc.0",
11
+ "@webiny/error": "6.0.0-rc.0",
12
+ "@webiny/ioc": "6.0.0-rc.0",
13
+ "@webiny/utils": "6.0.0-rc.0",
14
+ "lodash": "4.17.23"
20
15
  },
21
16
  "publishConfig": {
22
17
  "access": "public",
23
18
  "directory": "dist"
24
19
  },
25
20
  "devDependencies": {
26
- "@webiny/api-headless-cms": "6.0.0-alpha.5",
27
- "@webiny/api-headless-cms-ddb-es": "6.0.0-alpha.5",
28
- "@webiny/handler-aws": "6.0.0-alpha.5",
29
- "@webiny/plugins": "6.0.0-alpha.5",
30
- "@webiny/project-utils": "6.0.0-alpha.5",
21
+ "@webiny/api-headless-cms": "6.0.0-rc.0",
22
+ "@webiny/api-headless-cms-ddb-es": "6.0.0-rc.0",
23
+ "@webiny/build-tools": "6.0.0-rc.0",
24
+ "@webiny/handler-aws": "6.0.0-rc.0",
25
+ "@webiny/plugins": "6.0.0-rc.0",
26
+ "@webiny/project-utils": "6.0.0-rc.0",
31
27
  "elastic-ts": "0.12.0",
32
28
  "jest-dynalite": "3.6.1",
33
- "typescript": "5.3.3"
29
+ "typescript": "5.9.3",
30
+ "vitest": "4.0.18"
34
31
  },
35
- "gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
32
+ "gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
36
33
  }
@@ -1,90 +1,3 @@
1
- import type { AttributeDefinitions, Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Entity } from "@webiny/db-dynamodb/toolbox";
3
- export declare const createLegacyEntity: (table: Table<string, string, string>, entityName: string, attributes: AttributeDefinitions) => Entity<string, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, Table<string, string, string>, true, true, boolean, string, string, string, boolean, {
4
- PK: {
5
- partitionKey: true;
6
- };
7
- SK: {
8
- sortKey: true;
9
- };
10
- GSI1_PK: {
11
- type: "string";
12
- };
13
- GSI1_SK: {
14
- type: "string";
15
- };
16
- TYPE: {
17
- type: "string";
18
- };
19
- }, {
20
- PK: {
21
- partitionKey: true;
22
- };
23
- SK: {
24
- sortKey: true;
25
- };
26
- GSI1_PK: {
27
- type: "string";
28
- };
29
- GSI1_SK: {
30
- type: "string";
31
- };
32
- TYPE: {
33
- type: "string";
34
- };
35
- }, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
36
- [x: string]: any;
37
- [x: number]: any;
38
- [x: symbol]: any;
39
- }, {
40
- [x: string]: any;
41
- [x: number]: any;
42
- [x: symbol]: any;
43
- }>;
44
- export declare const createStandardEntity: (table: Table<string, string, string>, entityName: string, attributes?: AttributeDefinitions) => Entity<string, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, Table<string, string, string>, true, true, boolean, string, string, string, boolean, {
45
- PK: {
46
- partitionKey: true;
47
- };
48
- SK: {
49
- sortKey: true;
50
- };
51
- GSI1_PK: {
52
- type: "string";
53
- };
54
- GSI1_SK: {
55
- type: "string";
56
- };
57
- TYPE: {
58
- type: "string";
59
- };
60
- data: {
61
- type: "map";
62
- };
63
- }, {
64
- PK: {
65
- partitionKey: true;
66
- };
67
- SK: {
68
- sortKey: true;
69
- };
70
- GSI1_PK: {
71
- type: "string";
72
- };
73
- GSI1_SK: {
74
- type: "string";
75
- };
76
- TYPE: {
77
- type: "string";
78
- };
79
- data: {
80
- type: "map";
81
- };
82
- }, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
83
- [x: string]: any;
84
- [x: number]: any;
85
- [x: symbol]: any;
86
- }, {
87
- [x: string]: any;
88
- [x: number]: any;
89
- [x: symbol]: any;
90
- }>;
1
+ import type { AttributeDefinitions, Table } from "@webiny/db-dynamodb/toolbox.js";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox.js";
3
+ export declare const createStandardEntity: (table: Table<string, string, string>, entityName: string, attributes?: AttributeDefinitions) => Entity;
@@ -1,39 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createStandardEntity = exports.createLegacyEntity = void 0;
7
- var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
- const createLegacyEntity = (table, entityName, attributes) => {
9
- return new _toolbox.Entity({
10
- table,
11
- name: entityName,
12
- attributes: {
13
- PK: {
14
- partitionKey: true
15
- },
16
- SK: {
17
- sortKey: true
18
- },
19
- GSI1_PK: {
20
- type: "string"
21
- },
22
- GSI1_SK: {
23
- type: "string"
24
- },
25
- TYPE: {
26
- type: "string"
27
- },
28
- ...(attributes || {})
29
- },
30
- autoExecute: true,
31
- autoParse: true
32
- });
33
- };
34
- exports.createLegacyEntity = createLegacyEntity;
35
- const createStandardEntity = (table, entityName, attributes = {}) => {
36
- return new _toolbox.Entity({
1
+ import { Entity } from "@webiny/db-dynamodb/toolbox.js";
2
+ export const createStandardEntity = (table, entityName, attributes = {}) => {
3
+ return new Entity({
37
4
  table,
38
5
  name: entityName,
39
6
  attributes: {
@@ -62,6 +29,5 @@ const createStandardEntity = (table, entityName, attributes = {}) => {
62
29
  autoParse: true
63
30
  });
64
31
  };
65
- exports.createStandardEntity = createStandardEntity;
66
32
 
67
33
  //# sourceMappingURL=createEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_toolbox","require","createLegacyEntity","table","entityName","attributes","Entity","name","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","autoExecute","autoParse","exports","createStandardEntity","data"],"sources":["createEntity.ts"],"sourcesContent":["import type { AttributeDefinitions, Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\n\nexport const createLegacyEntity = (\n table: Table<string, string, string>,\n entityName: string,\n attributes: AttributeDefinitions\n) => {\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n ...(attributes || {})\n },\n autoExecute: true,\n autoParse: true\n });\n};\n\nexport const createStandardEntity = (\n table: Table<string, string, string>,\n entityName: string,\n attributes: AttributeDefinitions = {}\n) => {\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n // When moving attributes to `data` envelope, we need to keep the old attributes in place for 1 version.\n ...attributes\n },\n autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAGA,CAC9BC,KAAoC,EACpCC,UAAkB,EAClBC,UAAgC,KAC/B;EACD,OAAO,IAAIC,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACD,IAAIR,UAAU,IAAI,CAAC,CAAC;IACxB,CAAC;IACDW,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA;AAEK,MAAMiB,oBAAoB,GAAGA,CAChChB,KAAoC,EACpCC,UAAkB,EAClBC,UAAgC,GAAG,CAAC,CAAC,KACpC;EACD,OAAO,IAAIC,eAAM,CAAC;IACdH,KAAK;IACLI,IAAI,EAAEH,UAAU;IAChBC,UAAU,EAAE;MACRG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDO,IAAI,EAAE;QACFP,IAAI,EAAE;MACV,CAAC;MACD;MACA,GAAGR;IACP,CAAC;IACDW,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["Entity","createStandardEntity","table","entityName","attributes","name","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","data","autoExecute","autoParse"],"sources":["createEntity.ts"],"sourcesContent":["import type { AttributeDefinitions, Table } from \"@webiny/db-dynamodb/toolbox.js\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox.js\";\n\nexport const createStandardEntity = (\n table: Table<string, string, string>,\n entityName: string,\n attributes: AttributeDefinitions = {}\n): Entity => {\n return new Entity({\n table,\n name: entityName,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n // When moving attributes to `data` envelope, we need to keep the old attributes in place for 1 version.\n ...attributes\n },\n autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,gCAAgC;AAEvD,OAAO,MAAMC,oBAAoB,GAAGA,CAChCC,KAAoC,EACpCC,UAAkB,EAClBC,UAAgC,GAAG,CAAC,CAAC,KAC5B;EACT,OAAO,IAAIJ,MAAM,CAAC;IACdE,KAAK;IACLG,IAAI,EAAEF,UAAU;IAChBC,UAAU,EAAE;MACRE,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,IAAI,EAAE;QACFH,IAAI,EAAE;MACV,CAAC;MACD;MACA,GAAGP;IACP,CAAC;IACDW,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,48 +1,2 @@
1
- import type { Table } from "@webiny/db-dynamodb/toolbox";
2
- export declare const createTenantEntity: (table: Table<string, string, string>) => import("dynamodb-toolbox/dist/cjs/classes/Entity/Entity").default<string, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, Table<string, string, string>, true, true, boolean, string, string, string, boolean, {
3
- PK: {
4
- partitionKey: true;
5
- };
6
- SK: {
7
- sortKey: true;
8
- };
9
- GSI1_PK: {
10
- type: "string";
11
- };
12
- GSI1_SK: {
13
- type: "string";
14
- };
15
- TYPE: {
16
- type: "string";
17
- };
18
- data: {
19
- type: "map";
20
- };
21
- }, {
22
- PK: {
23
- partitionKey: true;
24
- };
25
- SK: {
26
- sortKey: true;
27
- };
28
- GSI1_PK: {
29
- type: "string";
30
- };
31
- GSI1_SK: {
32
- type: "string";
33
- };
34
- TYPE: {
35
- type: "string";
36
- };
37
- data: {
38
- type: "map";
39
- };
40
- }, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
41
- [x: string]: any;
42
- [x: number]: any;
43
- [x: symbol]: any;
44
- }, {
45
- [x: string]: any;
46
- [x: number]: any;
47
- [x: symbol]: any;
48
- }>;
1
+ import type { Table, Entity } from "@webiny/db-dynamodb/toolbox.js";
2
+ export declare const createTenantEntity: (table: Table<string, string, string>) => Entity;
@@ -1,13 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createTenantEntity = void 0;
7
- var _ = require("./");
8
- const createTenantEntity = table => {
9
- return (0, _.createStandardEntity)(table, "TenancyTenant");
1
+ import { createStandardEntity } from "./index.js";
2
+ export const createTenantEntity = table => {
3
+ return createStandardEntity(table, "TenancyTenant");
10
4
  };
11
- exports.createTenantEntity = createTenantEntity;
12
5
 
13
6
  //# sourceMappingURL=createTenantEntity.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_","require","createTenantEntity","table","createStandardEntity","exports"],"sources":["createTenantEntity.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { createStandardEntity } from \"~/utils\";\n\nexport const createTenantEntity = (table: Table<string, string, string>) => {\n return createStandardEntity(table, \"TenancyTenant\");\n};\n"],"mappings":";;;;;;AACA,IAAAA,CAAA,GAAAC,OAAA;AAEO,MAAMC,kBAAkB,GAAIC,KAAoC,IAAK;EACxE,OAAO,IAAAC,sBAAoB,EAACD,KAAK,EAAE,eAAe,CAAC;AACvD,CAAC;AAACE,OAAA,CAAAH,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createStandardEntity","createTenantEntity","table"],"sources":["createTenantEntity.ts"],"sourcesContent":["import type { Table, Entity } from \"@webiny/db-dynamodb/toolbox.js\";\nimport { createStandardEntity } from \"~/utils/index.js\";\n\nexport const createTenantEntity = (table: Table<string, string, string>): Entity => {\n return createStandardEntity(table, \"TenancyTenant\");\n};\n"],"mappings":"AACA,SAASA,oBAAoB;AAE7B,OAAO,MAAMC,kBAAkB,GAAIC,KAAoC,IAAa;EAChF,OAAOF,oBAAoB,CAACE,KAAK,EAAE,eAAe,CAAC;AACvD,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { BatchReadItem, BatchReadParams, BatchWriteItem, BatchWriteParams, GetRecordParams, ScanParams, ScanResponse } from "@webiny/db-dynamodb/utils";
2
- import { batchReadAll, batchWriteAll, get, count, queryAll, queryAllWithCallback as ddbQueryAllWithCallback, queryOne, scan, scanWithCallback as ddbScanWithCallback } from "@webiny/db-dynamodb/utils";
1
+ import type { BatchReadItem, BatchReadParams, BatchWriteItem, BatchWriteParams, GetRecordParams, ScanParams, ScanResponse } from "@webiny/db-dynamodb/utils/index.js";
2
+ import { batchReadAll, batchWriteAll, get, count, queryAll, queryAllWithCallback as ddbQueryAllWithCallback, queryOne, scan, scanWithCallback as ddbScanWithCallback } from "@webiny/db-dynamodb/utils/index.js";
3
3
  export { count, get, queryAll, ddbQueryAllWithCallback, queryOne, batchReadAll, batchWriteAll, scan, ddbScanWithCallback };
4
4
  export type { GetRecordParams, BatchWriteItem, BatchWriteParams, BatchReadItem, BatchReadParams, ScanParams, ScanResponse };
package/utils/dynamoDb.js CHANGED
@@ -1,62 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "batchReadAll", {
7
- enumerable: true,
8
- get: function () {
9
- return _utils.batchReadAll;
10
- }
11
- });
12
- Object.defineProperty(exports, "batchWriteAll", {
13
- enumerable: true,
14
- get: function () {
15
- return _utils.batchWriteAll;
16
- }
17
- });
18
- Object.defineProperty(exports, "count", {
19
- enumerable: true,
20
- get: function () {
21
- return _utils.count;
22
- }
23
- });
24
- Object.defineProperty(exports, "ddbQueryAllWithCallback", {
25
- enumerable: true,
26
- get: function () {
27
- return _utils.queryAllWithCallback;
28
- }
29
- });
30
- Object.defineProperty(exports, "ddbScanWithCallback", {
31
- enumerable: true,
32
- get: function () {
33
- return _utils.scanWithCallback;
34
- }
35
- });
36
- Object.defineProperty(exports, "get", {
37
- enumerable: true,
38
- get: function () {
39
- return _utils.get;
40
- }
41
- });
42
- Object.defineProperty(exports, "queryAll", {
43
- enumerable: true,
44
- get: function () {
45
- return _utils.queryAll;
46
- }
47
- });
48
- Object.defineProperty(exports, "queryOne", {
49
- enumerable: true,
50
- get: function () {
51
- return _utils.queryOne;
52
- }
53
- });
54
- Object.defineProperty(exports, "scan", {
55
- enumerable: true,
56
- get: function () {
57
- return _utils.scan;
58
- }
59
- });
60
- var _utils = require("@webiny/db-dynamodb/utils");
1
+ import { batchReadAll, batchWriteAll, get, count, queryAll, queryAllWithCallback as ddbQueryAllWithCallback, queryOne, scan, scanWithCallback as ddbScanWithCallback } from "@webiny/db-dynamodb/utils/index.js";
2
+ export { count, get, queryAll, ddbQueryAllWithCallback, queryOne, batchReadAll, batchWriteAll, scan, ddbScanWithCallback };
61
3
 
62
4
  //# sourceMappingURL=dynamoDb.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require"],"sources":["dynamoDb.ts"],"sourcesContent":["import type {\n BatchReadItem,\n BatchReadParams,\n BatchWriteItem,\n BatchWriteParams,\n GetRecordParams,\n ScanParams,\n ScanResponse\n} from \"@webiny/db-dynamodb/utils\";\nimport {\n batchReadAll,\n batchWriteAll,\n get,\n count,\n queryAll,\n queryAllWithCallback as ddbQueryAllWithCallback,\n queryOne,\n scan,\n scanWithCallback as ddbScanWithCallback\n} from \"@webiny/db-dynamodb/utils\";\n\nexport {\n count,\n get,\n queryAll,\n ddbQueryAllWithCallback,\n queryOne,\n batchReadAll,\n batchWriteAll,\n scan,\n ddbScanWithCallback\n};\nexport type {\n GetRecordParams,\n BatchWriteItem,\n BatchWriteParams,\n BatchReadItem,\n BatchReadParams,\n ScanParams,\n ScanResponse\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["batchReadAll","batchWriteAll","get","count","queryAll","queryAllWithCallback","ddbQueryAllWithCallback","queryOne","scan","scanWithCallback","ddbScanWithCallback"],"sources":["dynamoDb.ts"],"sourcesContent":["import type {\n BatchReadItem,\n BatchReadParams,\n BatchWriteItem,\n BatchWriteParams,\n GetRecordParams,\n ScanParams,\n ScanResponse\n} from \"@webiny/db-dynamodb/utils/index.js\";\nimport {\n batchReadAll,\n batchWriteAll,\n get,\n count,\n queryAll,\n queryAllWithCallback as ddbQueryAllWithCallback,\n queryOne,\n scan,\n scanWithCallback as ddbScanWithCallback\n} from \"@webiny/db-dynamodb/utils/index.js\";\n\nexport {\n count,\n get,\n queryAll,\n ddbQueryAllWithCallback,\n queryOne,\n batchReadAll,\n batchWriteAll,\n scan,\n ddbScanWithCallback\n};\nexport type {\n GetRecordParams,\n BatchWriteItem,\n BatchWriteParams,\n BatchReadItem,\n BatchReadParams,\n ScanParams,\n ScanResponse\n};\n"],"mappings":"AASA,SACIA,YAAY,EACZC,aAAa,EACbC,GAAG,EACHC,KAAK,EACLC,QAAQ,EACRC,oBAAoB,IAAIC,uBAAuB,EAC/CC,QAAQ,EACRC,IAAI,EACJC,gBAAgB,IAAIC,mBAAmB,QACpC,oCAAoC;AAE3C,SACIP,KAAK,EACLD,GAAG,EACHE,QAAQ,EACRE,uBAAuB,EACvBC,QAAQ,EACRP,YAAY,EACZC,aAAa,EACbO,IAAI,EACJE,mBAAmB","ignoreList":[]}
@@ -1,17 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.disableElasticsearchIndexing = void 0;
7
- var _ = require("./..");
8
- const disableElasticsearchIndexing = async params => {
1
+ import { esPutIndexSettings } from "../index.js";
2
+ export const disableElasticsearchIndexing = async params => {
9
3
  const {
10
4
  index,
11
5
  logger
12
6
  } = params;
13
7
  try {
14
- await (0, _.esPutIndexSettings)({
8
+ await esPutIndexSettings({
15
9
  elasticsearchClient: params.elasticsearchClient,
16
10
  index,
17
11
  settings: {
@@ -28,6 +22,5 @@ const disableElasticsearchIndexing = async params => {
28
22
  });
29
23
  }
30
24
  };
31
- exports.disableElasticsearchIndexing = disableElasticsearchIndexing;
32
25
 
33
26
  //# sourceMappingURL=disableEsIndexing.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_","require","disableElasticsearchIndexing","params","index","logger","esPutIndexSettings","elasticsearchClient","settings","refresh_interval","ex","error","message","code","data","exports"],"sources":["disableEsIndexing.ts"],"sourcesContent":["import { esPutIndexSettings } from \"~/utils\";\nimport type { Logger } from \"@webiny/data-migration\";\nimport type { Client } from \"@elastic/elasticsearch\";\n\ninterface DisableElasticsearchIndexingParams {\n index: string;\n logger: Logger;\n elasticsearchClient: Client;\n}\n\nexport const disableElasticsearchIndexing = async (\n params: DisableElasticsearchIndexingParams\n): Promise<void> => {\n const { index, logger } = params;\n\n try {\n await esPutIndexSettings({\n elasticsearchClient: params.elasticsearchClient,\n index,\n settings: {\n refresh_interval: -1\n }\n });\n } catch (ex) {\n logger.error(`Failed to disable indexing for index \"${index}\".`);\n logger.error({\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n });\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,OAAA;AAUO,MAAMC,4BAA4B,GAAG,MACxCC,MAA0C,IAC1B;EAChB,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEhC,IAAI;IACA,MAAM,IAAAG,oBAAkB,EAAC;MACrBC,mBAAmB,EAAEJ,MAAM,CAACI,mBAAmB;MAC/CH,KAAK;MACLI,QAAQ,EAAE;QACNC,gBAAgB,EAAE,CAAC;MACvB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTL,MAAM,CAACM,KAAK,CAAC,yCAAyCP,KAAK,IAAI,CAAC;IAChEC,MAAM,CAACM,KAAK,CAAC;MACT,GAAGD,EAAE;MACLE,OAAO,EAAEF,EAAE,CAACE,OAAO;MACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;MACbC,IAAI,EAAEJ,EAAE,CAACI;IACb,CAAC,CAAC;EACN;AACJ,CAAC;AAACC,OAAA,CAAAb,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["esPutIndexSettings","disableElasticsearchIndexing","params","index","logger","elasticsearchClient","settings","refresh_interval","ex","error","message","code","data"],"sources":["disableEsIndexing.ts"],"sourcesContent":["import { esPutIndexSettings } from \"~/utils/index.js\";\nimport type { Logger } from \"@webiny/data-migration\";\nimport type { Client } from \"@elastic/elasticsearch\";\n\ninterface DisableElasticsearchIndexingParams {\n index: string;\n logger: Logger;\n elasticsearchClient: Client;\n}\n\nexport const disableElasticsearchIndexing = async (\n params: DisableElasticsearchIndexingParams\n): Promise<void> => {\n const { index, logger } = params;\n\n try {\n await esPutIndexSettings({\n elasticsearchClient: params.elasticsearchClient,\n index,\n settings: {\n refresh_interval: -1\n }\n });\n } catch (ex) {\n logger.error(`Failed to disable indexing for index \"${index}\".`);\n logger.error({\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n });\n }\n};\n"],"mappings":"AAAA,SAASA,kBAAkB;AAU3B,OAAO,MAAMC,4BAA4B,GAAG,MACxCC,MAA0C,IAC1B;EAChB,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEhC,IAAI;IACA,MAAMF,kBAAkB,CAAC;MACrBK,mBAAmB,EAAEH,MAAM,CAACG,mBAAmB;MAC/CF,KAAK;MACLG,QAAQ,EAAE;QACNC,gBAAgB,EAAE,CAAC;MACvB;IACJ,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTJ,MAAM,CAACK,KAAK,CAAC,yCAAyCN,KAAK,IAAI,CAAC;IAChEC,MAAM,CAACK,KAAK,CAAC;MACT,GAAGD,EAAE;MACLE,OAAO,EAAEF,EAAE,CAACE,OAAO;MACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;MACbC,IAAI,EAAEJ,EAAE,CAACI;IACb,CAAC,CAAC;EACN;AACJ,CAAC","ignoreList":[]}
@@ -2,7 +2,6 @@ import type { Client } from "@elastic/elasticsearch";
2
2
  export interface EsCreateIndexParams {
3
3
  elasticsearchClient: Client;
4
4
  tenant: string;
5
- locale: string;
6
5
  type: string;
7
6
  isHeadlessCmsModel: boolean;
8
7
  }
@@ -1,40 +1,26 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.esCreateIndex = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _ = require("./..");
10
- var _plugins = require("./plugins");
11
- const esCreateIndex = async params => {
1
+ import WebinyError from "@webiny/error";
2
+ import { esGetIndexName, esGetIndexExist } from "../index.js";
3
+ import { elasticsearchIndexPlugins } from "./plugins/index.js";
4
+ export const esCreateIndex = async params => {
12
5
  const {
13
6
  elasticsearchClient,
14
7
  tenant,
15
- locale,
16
8
  type,
17
9
  isHeadlessCmsModel
18
10
  } = params;
19
- const indexName = (0, _.esGetIndexName)({
11
+ const indexName = esGetIndexName({
20
12
  tenant,
21
- locale,
22
13
  type,
23
14
  isHeadlessCmsModel
24
15
  });
25
16
  try {
26
- const exist = await (0, _.esGetIndexExist)(params);
17
+ const exist = await esGetIndexExist(params);
27
18
  if (exist) {
28
19
  return indexName;
29
20
  }
30
21
 
31
22
  // Get registered plugins
32
- const plugin = (0, _plugins.elasticsearchIndexPlugins)().filter(plugin => {
33
- if (!plugin.locales) {
34
- return true;
35
- }
36
- return plugin.locales.includes(locale.toLowerCase());
37
- }).pop();
23
+ const plugin = elasticsearchIndexPlugins().pop();
38
24
  await elasticsearchClient.indices.create({
39
25
  index: indexName,
40
26
  ...(plugin && {
@@ -49,14 +35,12 @@ const esCreateIndex = async params => {
49
35
  if (ex.message === "resource_already_exists_exception") {
50
36
  return indexName;
51
37
  }
52
- throw new _error.default(ex.message || "Could not create Elasticsearch index.", ex.code || "CREATE_ELASTICSEARCH_INDEX_ERROR", {
38
+ throw new WebinyError(ex.message || "Could not create Elasticsearch index.", ex.code || "CREATE_OPENSEARCH_INDEX_ERROR", {
53
39
  error: ex,
54
- locale,
55
40
  tenant,
56
41
  type
57
42
  });
58
43
  }
59
44
  };
60
- exports.esCreateIndex = esCreateIndex;
61
45
 
62
46
  //# sourceMappingURL=esCreateIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_","_plugins","esCreateIndex","params","elasticsearchClient","tenant","locale","type","isHeadlessCmsModel","indexName","esGetIndexName","exist","esGetIndexExist","plugin","elasticsearchIndexPlugins","filter","locales","includes","toLowerCase","pop","indices","create","index","body","ex","message","WebinyError","code","error","exports"],"sources":["esCreateIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { esGetIndexName, esGetIndexExist } from \"~/utils\";\nimport { elasticsearchIndexPlugins } from \"~/utils/elasticsearch/plugins\";\n\nexport interface EsCreateIndexParams {\n elasticsearchClient: Client;\n tenant: string;\n locale: string;\n type: string;\n isHeadlessCmsModel: boolean;\n}\n\nexport const esCreateIndex = async (params: EsCreateIndexParams): Promise<string> => {\n const { elasticsearchClient, tenant, locale, type, isHeadlessCmsModel } = params;\n\n const indexName = esGetIndexName({ tenant, locale, type, isHeadlessCmsModel });\n\n try {\n const exist = await esGetIndexExist(params);\n\n if (exist) {\n return indexName;\n }\n\n // Get registered plugins\n const plugin = elasticsearchIndexPlugins()\n .filter(plugin => {\n if (!plugin.locales) {\n return true;\n }\n\n return plugin.locales.includes(locale.toLowerCase());\n })\n .pop();\n\n await elasticsearchClient.indices.create({\n index: indexName,\n ...(plugin && { body: plugin.body })\n });\n return indexName;\n } catch (ex) {\n // Despite the fact the above `esGetIndexExist` check told us the index does not exist,\n // we've seen cases where the `resource_already_exists_exception` would still be thrown\n // upon index creation. That's why we're doing an additional check of the error message.\n if (ex.message === \"resource_already_exists_exception\") {\n return indexName;\n }\n\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index.\",\n ex.code || \"CREATE_ELASTICSEARCH_INDEX_ERROR\",\n {\n error: ex,\n locale,\n tenant,\n type\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,CAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAUO,MAAMG,aAAa,GAAG,MAAOC,MAA2B,IAAsB;EACjF,MAAM;IAAEC,mBAAmB;IAAEC,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAmB,CAAC,GAAGL,MAAM;EAEhF,MAAMM,SAAS,GAAG,IAAAC,gBAAc,EAAC;IAAEL,MAAM;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAmB,CAAC,CAAC;EAE9E,IAAI;IACA,MAAMG,KAAK,GAAG,MAAM,IAAAC,iBAAe,EAACT,MAAM,CAAC;IAE3C,IAAIQ,KAAK,EAAE;MACP,OAAOF,SAAS;IACpB;;IAEA;IACA,MAAMI,MAAM,GAAG,IAAAC,kCAAyB,EAAC,CAAC,CACrCC,MAAM,CAACF,MAAM,IAAI;MACd,IAAI,CAACA,MAAM,CAACG,OAAO,EAAE;QACjB,OAAO,IAAI;MACf;MAEA,OAAOH,MAAM,CAACG,OAAO,CAACC,QAAQ,CAACX,MAAM,CAACY,WAAW,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CACDC,GAAG,CAAC,CAAC;IAEV,MAAMf,mBAAmB,CAACgB,OAAO,CAACC,MAAM,CAAC;MACrCC,KAAK,EAAEb,SAAS;MAChB,IAAII,MAAM,IAAI;QAAEU,IAAI,EAAEV,MAAM,CAACU;MAAK,CAAC;IACvC,CAAC,CAAC;IACF,OAAOd,SAAS;EACpB,CAAC,CAAC,OAAOe,EAAE,EAAE;IACT;IACA;IACA;IACA,IAAIA,EAAE,CAACC,OAAO,KAAK,mCAAmC,EAAE;MACpD,OAAOhB,SAAS;IACpB;IAEA,MAAM,IAAIiB,cAAW,CACjBF,EAAE,CAACC,OAAO,IAAI,uCAAuC,EACrDD,EAAE,CAACG,IAAI,IAAI,kCAAkC,EAC7C;MACIC,KAAK,EAAEJ,EAAE;MACTlB,MAAM;MACND,MAAM;MACNE;IACJ,CACJ,CAAC;EACL;AACJ,CAAC;AAACsB,OAAA,CAAA3B,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","esGetIndexName","esGetIndexExist","elasticsearchIndexPlugins","esCreateIndex","params","elasticsearchClient","tenant","type","isHeadlessCmsModel","indexName","exist","plugin","pop","indices","create","index","body","ex","message","code","error"],"sources":["esCreateIndex.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { esGetIndexName, esGetIndexExist } from \"~/utils/index.js\";\nimport { elasticsearchIndexPlugins } from \"~/utils/elasticsearch/plugins/index.js\";\n\nexport interface EsCreateIndexParams {\n elasticsearchClient: Client;\n tenant: string;\n type: string;\n isHeadlessCmsModel: boolean;\n}\n\nexport const esCreateIndex = async (params: EsCreateIndexParams): Promise<string> => {\n const { elasticsearchClient, tenant, type, isHeadlessCmsModel } = params;\n\n const indexName = esGetIndexName({ tenant, type, isHeadlessCmsModel });\n\n try {\n const exist = await esGetIndexExist(params);\n\n if (exist) {\n return indexName;\n }\n\n // Get registered plugins\n const plugin = elasticsearchIndexPlugins().pop();\n\n await elasticsearchClient.indices.create({\n index: indexName,\n ...(plugin && { body: plugin.body })\n });\n return indexName;\n } catch (ex) {\n // Despite the fact the above `esGetIndexExist` check told us the index does not exist,\n // we've seen cases where the `resource_already_exists_exception` would still be thrown\n // upon index creation. That's why we're doing an additional check of the error message.\n if (ex.message === \"resource_already_exists_exception\") {\n return indexName;\n }\n\n throw new WebinyError(\n ex.message || \"Could not create Elasticsearch index.\",\n ex.code || \"CREATE_OPENSEARCH_INDEX_ERROR\",\n {\n error: ex,\n tenant,\n type\n }\n );\n }\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,cAAc,EAAEC,eAAe;AACxC,SAASC,yBAAyB;AASlC,OAAO,MAAMC,aAAa,GAAG,MAAOC,MAA2B,IAAsB;EACjF,MAAM;IAAEC,mBAAmB;IAAEC,MAAM;IAAEC,IAAI;IAAEC;EAAmB,CAAC,GAAGJ,MAAM;EAExE,MAAMK,SAAS,GAAGT,cAAc,CAAC;IAAEM,MAAM;IAAEC,IAAI;IAAEC;EAAmB,CAAC,CAAC;EAEtE,IAAI;IACA,MAAME,KAAK,GAAG,MAAMT,eAAe,CAACG,MAAM,CAAC;IAE3C,IAAIM,KAAK,EAAE;MACP,OAAOD,SAAS;IACpB;;IAEA;IACA,MAAME,MAAM,GAAGT,yBAAyB,CAAC,CAAC,CAACU,GAAG,CAAC,CAAC;IAEhD,MAAMP,mBAAmB,CAACQ,OAAO,CAACC,MAAM,CAAC;MACrCC,KAAK,EAAEN,SAAS;MAChB,IAAIE,MAAM,IAAI;QAAEK,IAAI,EAAEL,MAAM,CAACK;MAAK,CAAC;IACvC,CAAC,CAAC;IACF,OAAOP,SAAS;EACpB,CAAC,CAAC,OAAOQ,EAAE,EAAE;IACT;IACA;IACA;IACA,IAAIA,EAAE,CAACC,OAAO,KAAK,mCAAmC,EAAE;MACpD,OAAOT,SAAS;IACpB;IAEA,MAAM,IAAIV,WAAW,CACjBkB,EAAE,CAACC,OAAO,IAAI,uCAAuC,EACrDD,EAAE,CAACE,IAAI,IAAI,+BAA+B,EAC1C;MACIC,KAAK,EAAEH,EAAE;MACTX,MAAM;MACNC;IACJ,CACJ,CAAC;EACL;AACJ,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { Client } from "@elastic/elasticsearch";
2
- import type { SearchBody } from "@webiny/api-elasticsearch/types";
2
+ import type { SearchBody } from "@webiny/api-elasticsearch/types.js";
3
3
  export interface EsFindOneParams {
4
4
  elasticsearchClient: Client;
5
5
  index: string;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.esFindOne = void 0;
7
- const esFindOne = async ({
1
+ export const esFindOne = async ({
8
2
  elasticsearchClient,
9
3
  body,
10
4
  index
@@ -22,6 +16,5 @@ const esFindOne = async ({
22
16
  }
23
17
  return hits.hits[0]._source;
24
18
  };
25
- exports.esFindOne = esFindOne;
26
19
 
27
20
  //# sourceMappingURL=esFindOne.js.map