@webiny/migrations 0.0.0-unstable.2aaa1916d9

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 (93) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +1 -0
  3. package/ddb-es.d.ts +2 -0
  4. package/ddb-es.js +17 -0
  5. package/ddb-es.js.map +1 -0
  6. package/ddb.d.ts +2 -0
  7. package/ddb.js +17 -0
  8. package/ddb.js.map +1 -0
  9. package/migrations/5.43.0/001/constants.d.ts +2 -0
  10. package/migrations/5.43.0/001/constants.js +10 -0
  11. package/migrations/5.43.0/001/constants.js.map +1 -0
  12. package/migrations/5.43.0/001/ddb/index.d.ts +13 -0
  13. package/migrations/5.43.0/001/ddb/index.js +215 -0
  14. package/migrations/5.43.0/001/ddb/index.js.map +1 -0
  15. package/migrations/5.43.0/001/ddb-es/index.d.ts +16 -0
  16. package/migrations/5.43.0/001/ddb-es/index.js +257 -0
  17. package/migrations/5.43.0/001/ddb-es/index.js.map +1 -0
  18. package/migrations/5.43.0/001/entities/createEntryEntity.d.ts +91 -0
  19. package/migrations/5.43.0/001/entities/createEntryEntity.js +188 -0
  20. package/migrations/5.43.0/001/entities/createEntryEntity.js.map +1 -0
  21. package/migrations/5.43.0/001/types.d.ts +47 -0
  22. package/migrations/5.43.0/001/types.js +7 -0
  23. package/migrations/5.43.0/001/types.js.map +1 -0
  24. package/package.json +36 -0
  25. package/utils/createEntity.d.ts +90 -0
  26. package/utils/createEntity.js +67 -0
  27. package/utils/createEntity.js.map +1 -0
  28. package/utils/createLocaleEntity.d.ts +42 -0
  29. package/utils/createLocaleEntity.js +32 -0
  30. package/utils/createLocaleEntity.js.map +1 -0
  31. package/utils/createTenantEntity.d.ts +48 -0
  32. package/utils/createTenantEntity.js +13 -0
  33. package/utils/createTenantEntity.js.map +1 -0
  34. package/utils/dynamoDb.d.ts +4 -0
  35. package/utils/dynamoDb.js +62 -0
  36. package/utils/dynamoDb.js.map +1 -0
  37. package/utils/elasticsearch/disableEsIndexing.d.ts +9 -0
  38. package/utils/elasticsearch/disableEsIndexing.js +33 -0
  39. package/utils/elasticsearch/disableEsIndexing.js.map +1 -0
  40. package/utils/elasticsearch/esCreateIndex.d.ts +9 -0
  41. package/utils/elasticsearch/esCreateIndex.js +62 -0
  42. package/utils/elasticsearch/esCreateIndex.js.map +1 -0
  43. package/utils/elasticsearch/esFindOne.d.ts +8 -0
  44. package/utils/elasticsearch/esFindOne.js +27 -0
  45. package/utils/elasticsearch/esFindOne.js.map +1 -0
  46. package/utils/elasticsearch/esGetIndexExist.d.ts +9 -0
  47. package/utils/elasticsearch/esGetIndexExist.js +37 -0
  48. package/utils/elasticsearch/esGetIndexExist.js.map +1 -0
  49. package/utils/elasticsearch/esGetIndexName.d.ts +7 -0
  50. package/utils/elasticsearch/esGetIndexName.js +41 -0
  51. package/utils/elasticsearch/esGetIndexName.js.map +1 -0
  52. package/utils/elasticsearch/esGetIndexSettings.d.ts +7 -0
  53. package/utils/elasticsearch/esGetIndexSettings.js +32 -0
  54. package/utils/elasticsearch/esGetIndexSettings.js.map +1 -0
  55. package/utils/elasticsearch/esListIndexes.d.ts +6 -0
  56. package/utils/elasticsearch/esListIndexes.js +23 -0
  57. package/utils/elasticsearch/esListIndexes.js.map +1 -0
  58. package/utils/elasticsearch/esPutIndexSettings.d.ts +7 -0
  59. package/utils/elasticsearch/esPutIndexSettings.js +30 -0
  60. package/utils/elasticsearch/esPutIndexSettings.js.map +1 -0
  61. package/utils/elasticsearch/esQueryAll.d.ts +8 -0
  62. package/utils/elasticsearch/esQueryAll.js +26 -0
  63. package/utils/elasticsearch/esQueryAll.js.map +1 -0
  64. package/utils/elasticsearch/esQueryAllWithCallback.d.ts +10 -0
  65. package/utils/elasticsearch/esQueryAllWithCallback.js +45 -0
  66. package/utils/elasticsearch/esQueryAllWithCallback.js.map +1 -0
  67. package/utils/elasticsearch/fetchOriginalEsSettings.d.ts +12 -0
  68. package/utils/elasticsearch/fetchOriginalEsSettings.js +35 -0
  69. package/utils/elasticsearch/fetchOriginalEsSettings.js.map +1 -0
  70. package/utils/elasticsearch/index.d.ts +12 -0
  71. package/utils/elasticsearch/index.js +139 -0
  72. package/utils/elasticsearch/index.js.map +1 -0
  73. package/utils/elasticsearch/plugins/base.d.ts +3 -0
  74. package/utils/elasticsearch/plugins/base.js +12 -0
  75. package/utils/elasticsearch/plugins/base.js.map +1 -0
  76. package/utils/elasticsearch/plugins/index.d.ts +6 -0
  77. package/utils/elasticsearch/plugins/index.js +14 -0
  78. package/utils/elasticsearch/plugins/index.js.map +1 -0
  79. package/utils/elasticsearch/plugins/japanese.d.ts +4 -0
  80. package/utils/elasticsearch/plugins/japanese.js +13 -0
  81. package/utils/elasticsearch/plugins/japanese.js.map +1 -0
  82. package/utils/elasticsearch/restoreOriginalEsSettings.d.ts +14 -0
  83. package/utils/elasticsearch/restoreOriginalEsSettings.js +52 -0
  84. package/utils/elasticsearch/restoreOriginalEsSettings.js.map +1 -0
  85. package/utils/forEachTenantLocale.d.ts +22 -0
  86. package/utils/forEachTenantLocale.js +55 -0
  87. package/utils/forEachTenantLocale.js.map +1 -0
  88. package/utils/getCompressedData.d.ts +4 -0
  89. package/utils/getCompressedData.js +19 -0
  90. package/utils/getCompressedData.js.map +1 -0
  91. package/utils/index.d.ts +7 -0
  92. package/utils/index.js +84 -0
  93. package/utils/index.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","esQueryAll","elasticsearchClient","body","index","search","response","executeWithRetry","hits","map","item","_source","exports"],"sources":["esQueryAll.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { ElasticsearchSearchResponse, SearchBody } from \"@webiny/api-elasticsearch/types\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\nexport interface EsQueryAllParams {\n elasticsearchClient: Client;\n index: string;\n body: SearchBody;\n}\n\nexport const esQueryAll = async <TItem>({ elasticsearchClient, body, index }: EsQueryAllParams) => {\n const search = async (): Promise<ElasticsearchSearchResponse<TItem>> => {\n return elasticsearchClient.search({\n index,\n body\n });\n };\n\n const response = await executeWithRetry(search);\n\n return response.body.hits.hits.map(item => {\n return item._source;\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAQO,MAAMC,UAAU,GAAG,MAAAA,CAAc;EAAEC,mBAAmB;EAAEC,IAAI;EAAEC;AAAwB,CAAC,KAAK;EAC/F,MAAMC,MAAM,GAAG,MAAAA,CAAA,KAAyD;IACpE,OAAOH,mBAAmB,CAACG,MAAM,CAAC;MAC9BD,KAAK;MACLD;IACJ,CAAC,CAAC;EACN,CAAC;EAED,MAAMG,QAAQ,GAAG,MAAM,IAAAC,uBAAgB,EAACF,MAAM,CAAC;EAE/C,OAAOC,QAAQ,CAACH,IAAI,CAACK,IAAI,CAACA,IAAI,CAACC,GAAG,CAACC,IAAI,IAAI;IACvC,OAAOA,IAAI,CAACC,OAAO;EACvB,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAX,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { Client } from "@elastic/elasticsearch";
2
+ import type { SearchBody } from "@webiny/api-elasticsearch/types";
3
+ export interface EsQueryAllWithCallbackParams<TItem> {
4
+ elasticsearchClient: Client;
5
+ index: string;
6
+ body: SearchBody;
7
+ callback: (items: TItem[], cursor: string[]) => Promise<void>;
8
+ onError?: (error: Error) => Promise<void> | void;
9
+ }
10
+ export declare const esQueryAllWithCallback: <TItem>({ elasticsearchClient, body, index, callback, onError }: EsQueryAllWithCallbackParams<TItem>) => Promise<void>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.esQueryAllWithCallback = void 0;
7
+ var _utils = require("@webiny/utils");
8
+ const esQueryAllWithCallback = async ({
9
+ elasticsearchClient,
10
+ body,
11
+ index,
12
+ callback,
13
+ onError
14
+ }) => {
15
+ let cursor = body.search_after;
16
+ while (true) {
17
+ const bodyWithCursor = {
18
+ ...body,
19
+ search_after: cursor
20
+ };
21
+ const search = async () => {
22
+ return elasticsearchClient.search({
23
+ index,
24
+ body: bodyWithCursor
25
+ });
26
+ };
27
+ try {
28
+ const response = await (0, _utils.executeWithRetry)(search);
29
+ const hits = response.body.hits;
30
+ if (hits.hits.length <= 0) {
31
+ break;
32
+ }
33
+ cursor = hits.hits[hits.hits.length - 1].sort;
34
+ await callback(hits.hits.map(item => item._source), cursor);
35
+ } catch (ex) {
36
+ if (!onError) {
37
+ throw ex;
38
+ }
39
+ await onError(ex);
40
+ }
41
+ }
42
+ };
43
+ exports.esQueryAllWithCallback = esQueryAllWithCallback;
44
+
45
+ //# sourceMappingURL=esQueryAllWithCallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","esQueryAllWithCallback","elasticsearchClient","body","index","callback","onError","cursor","search_after","bodyWithCursor","search","response","executeWithRetry","hits","length","sort","map","item","_source","ex","exports"],"sources":["esQueryAllWithCallback.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type {\n ElasticsearchSearchResponse,\n PrimitiveValue,\n SearchBody\n} from \"@webiny/api-elasticsearch/types\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\nexport interface EsQueryAllWithCallbackParams<TItem> {\n elasticsearchClient: Client;\n index: string;\n body: SearchBody;\n callback: (items: TItem[], cursor: string[]) => Promise<void>;\n onError?: (error: Error) => Promise<void> | void;\n}\n\nexport const esQueryAllWithCallback = async <TItem>({\n elasticsearchClient,\n body,\n index,\n callback,\n onError\n}: EsQueryAllWithCallbackParams<TItem>) => {\n let cursor: PrimitiveValue[] | undefined = body.search_after;\n while (true) {\n const bodyWithCursor = { ...body, search_after: cursor };\n\n const search = async (): Promise<ElasticsearchSearchResponse<TItem>> => {\n return elasticsearchClient.search({\n index,\n body: bodyWithCursor\n });\n };\n\n try {\n const response = await executeWithRetry(search);\n\n const hits = response.body.hits;\n if (hits.hits.length <= 0) {\n break;\n }\n\n cursor = hits.hits[hits.hits.length - 1].sort as unknown as string[];\n await callback(\n hits.hits.map(item => item._source),\n cursor as string[]\n );\n } catch (ex) {\n if (!onError) {\n throw ex;\n }\n await onError(ex);\n }\n }\n};\n"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AAUO,MAAMC,sBAAsB,GAAG,MAAAA,CAAc;EAChDC,mBAAmB;EACnBC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AACiC,CAAC,KAAK;EACvC,IAAIC,MAAoC,GAAGJ,IAAI,CAACK,YAAY;EAC5D,OAAO,IAAI,EAAE;IACT,MAAMC,cAAc,GAAG;MAAE,GAAGN,IAAI;MAAEK,YAAY,EAAED;IAAO,CAAC;IAExD,MAAMG,MAAM,GAAG,MAAAA,CAAA,KAAyD;MACpE,OAAOR,mBAAmB,CAACQ,MAAM,CAAC;QAC9BN,KAAK;QACLD,IAAI,EAAEM;MACV,CAAC,CAAC;IACN,CAAC;IAED,IAAI;MACA,MAAME,QAAQ,GAAG,MAAM,IAAAC,uBAAgB,EAACF,MAAM,CAAC;MAE/C,MAAMG,IAAI,GAAGF,QAAQ,CAACR,IAAI,CAACU,IAAI;MAC/B,IAAIA,IAAI,CAACA,IAAI,CAACC,MAAM,IAAI,CAAC,EAAE;QACvB;MACJ;MAEAP,MAAM,GAAGM,IAAI,CAACA,IAAI,CAACA,IAAI,CAACA,IAAI,CAACC,MAAM,GAAG,CAAC,CAAC,CAACC,IAA2B;MACpE,MAAMV,QAAQ,CACVQ,IAAI,CAACA,IAAI,CAACG,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,OAAO,CAAC,EACnCX,MACJ,CAAC;IACL,CAAC,CAAC,OAAOY,EAAE,EAAE;MACT,IAAI,CAACb,OAAO,EAAE;QACV,MAAMa,EAAE;MACZ;MACA,MAAMb,OAAO,CAACa,EAAE,CAAC;IACrB;EACJ;AACJ,CAAC;AAACC,OAAA,CAAAnB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import type { Logger } from "@webiny/data-migration";
2
+ import type { Client } from "@elastic/elasticsearch";
3
+ interface FetchOriginalElasticsearchSettingsParams {
4
+ elasticsearchClient: Client;
5
+ index: string;
6
+ logger: Logger;
7
+ }
8
+ interface IndexSettings {
9
+ refresh_interval: `${number}s`;
10
+ }
11
+ export declare const fetchOriginalElasticsearchSettings: (params: FetchOriginalElasticsearchSettingsParams) => Promise<IndexSettings | null>;
12
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchOriginalElasticsearchSettings = void 0;
7
+ var _ = require("./..");
8
+ const fetchOriginalElasticsearchSettings = async params => {
9
+ const {
10
+ index,
11
+ logger
12
+ } = params;
13
+ try {
14
+ const settings = await (0, _.esGetIndexSettings)({
15
+ elasticsearchClient: params.elasticsearchClient,
16
+ index,
17
+ fields: ["refresh_interval"]
18
+ });
19
+ return {
20
+ refresh_interval: settings.refresh_interval || "1s"
21
+ };
22
+ } catch (ex) {
23
+ logger.error(`Failed to fetch original Elasticsearch settings for index "${index}".`);
24
+ logger.error({
25
+ ...ex,
26
+ message: ex.message,
27
+ code: ex.code,
28
+ data: ex.data
29
+ });
30
+ }
31
+ return null;
32
+ };
33
+ exports.fetchOriginalElasticsearchSettings = fetchOriginalElasticsearchSettings;
34
+
35
+ //# sourceMappingURL=fetchOriginalEsSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_","require","fetchOriginalElasticsearchSettings","params","index","logger","settings","esGetIndexSettings","elasticsearchClient","fields","refresh_interval","ex","error","message","code","data","exports"],"sources":["fetchOriginalEsSettings.ts"],"sourcesContent":["import { esGetIndexSettings } from \"~/utils\";\nimport type { Logger } from \"@webiny/data-migration\";\nimport type { Client } from \"@elastic/elasticsearch\";\n\ninterface FetchOriginalElasticsearchSettingsParams {\n elasticsearchClient: Client;\n index: string;\n logger: Logger;\n}\n\ninterface IndexSettings {\n refresh_interval: `${number}s`;\n}\n\nexport const fetchOriginalElasticsearchSettings = async (\n params: FetchOriginalElasticsearchSettingsParams\n): Promise<IndexSettings | null> => {\n const { index, logger } = params;\n try {\n const settings = await esGetIndexSettings({\n elasticsearchClient: params.elasticsearchClient,\n index,\n fields: [\"refresh_interval\"]\n });\n return {\n refresh_interval: settings.refresh_interval || \"1s\"\n };\n } catch (ex) {\n logger.error(`Failed to fetch original Elasticsearch settings for index \"${index}\".`);\n logger.error({\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n });\n }\n\n return null;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,OAAA;AAcO,MAAMC,kCAAkC,GAAG,MAC9CC,MAAgD,IAChB;EAChC,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAChC,IAAI;IACA,MAAMG,QAAQ,GAAG,MAAM,IAAAC,oBAAkB,EAAC;MACtCC,mBAAmB,EAAEL,MAAM,CAACK,mBAAmB;MAC/CJ,KAAK;MACLK,MAAM,EAAE,CAAC,kBAAkB;IAC/B,CAAC,CAAC;IACF,OAAO;MACHC,gBAAgB,EAAEJ,QAAQ,CAACI,gBAAgB,IAAI;IACnD,CAAC;EACL,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTN,MAAM,CAACO,KAAK,CAAC,8DAA8DR,KAAK,IAAI,CAAC;IACrFC,MAAM,CAACO,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;EAEA,OAAO,IAAI;AACf,CAAC;AAACC,OAAA,CAAAd,kCAAA,GAAAA,kCAAA","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ export * from "./esCreateIndex";
2
+ export * from "./esFindOne";
3
+ export * from "./esGetIndexExist";
4
+ export * from "./esGetIndexName";
5
+ export * from "./esGetIndexSettings";
6
+ export * from "./esPutIndexSettings";
7
+ export * from "./esQueryAllWithCallback";
8
+ export * from "./esQueryAll";
9
+ export * from "./esListIndexes";
10
+ export * from "./disableEsIndexing";
11
+ export * from "./fetchOriginalEsSettings";
12
+ export * from "./restoreOriginalEsSettings";
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _esCreateIndex = require("./esCreateIndex");
7
+ Object.keys(_esCreateIndex).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _esCreateIndex[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _esCreateIndex[key];
14
+ }
15
+ });
16
+ });
17
+ var _esFindOne = require("./esFindOne");
18
+ Object.keys(_esFindOne).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _esFindOne[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _esFindOne[key];
25
+ }
26
+ });
27
+ });
28
+ var _esGetIndexExist = require("./esGetIndexExist");
29
+ Object.keys(_esGetIndexExist).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _esGetIndexExist[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _esGetIndexExist[key];
36
+ }
37
+ });
38
+ });
39
+ var _esGetIndexName = require("./esGetIndexName");
40
+ Object.keys(_esGetIndexName).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _esGetIndexName[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _esGetIndexName[key];
47
+ }
48
+ });
49
+ });
50
+ var _esGetIndexSettings = require("./esGetIndexSettings");
51
+ Object.keys(_esGetIndexSettings).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _esGetIndexSettings[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _esGetIndexSettings[key];
58
+ }
59
+ });
60
+ });
61
+ var _esPutIndexSettings = require("./esPutIndexSettings");
62
+ Object.keys(_esPutIndexSettings).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _esPutIndexSettings[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _esPutIndexSettings[key];
69
+ }
70
+ });
71
+ });
72
+ var _esQueryAllWithCallback = require("./esQueryAllWithCallback");
73
+ Object.keys(_esQueryAllWithCallback).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _esQueryAllWithCallback[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _esQueryAllWithCallback[key];
80
+ }
81
+ });
82
+ });
83
+ var _esQueryAll = require("./esQueryAll");
84
+ Object.keys(_esQueryAll).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _esQueryAll[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _esQueryAll[key];
91
+ }
92
+ });
93
+ });
94
+ var _esListIndexes = require("./esListIndexes");
95
+ Object.keys(_esListIndexes).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _esListIndexes[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _esListIndexes[key];
102
+ }
103
+ });
104
+ });
105
+ var _disableEsIndexing = require("./disableEsIndexing");
106
+ Object.keys(_disableEsIndexing).forEach(function (key) {
107
+ if (key === "default" || key === "__esModule") return;
108
+ if (key in exports && exports[key] === _disableEsIndexing[key]) return;
109
+ Object.defineProperty(exports, key, {
110
+ enumerable: true,
111
+ get: function () {
112
+ return _disableEsIndexing[key];
113
+ }
114
+ });
115
+ });
116
+ var _fetchOriginalEsSettings = require("./fetchOriginalEsSettings");
117
+ Object.keys(_fetchOriginalEsSettings).forEach(function (key) {
118
+ if (key === "default" || key === "__esModule") return;
119
+ if (key in exports && exports[key] === _fetchOriginalEsSettings[key]) return;
120
+ Object.defineProperty(exports, key, {
121
+ enumerable: true,
122
+ get: function () {
123
+ return _fetchOriginalEsSettings[key];
124
+ }
125
+ });
126
+ });
127
+ var _restoreOriginalEsSettings = require("./restoreOriginalEsSettings");
128
+ Object.keys(_restoreOriginalEsSettings).forEach(function (key) {
129
+ if (key === "default" || key === "__esModule") return;
130
+ if (key in exports && exports[key] === _restoreOriginalEsSettings[key]) return;
131
+ Object.defineProperty(exports, key, {
132
+ enumerable: true,
133
+ get: function () {
134
+ return _restoreOriginalEsSettings[key];
135
+ }
136
+ });
137
+ });
138
+
139
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_esCreateIndex","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_esFindOne","_esGetIndexExist","_esGetIndexName","_esGetIndexSettings","_esPutIndexSettings","_esQueryAllWithCallback","_esQueryAll","_esListIndexes","_disableEsIndexing","_fetchOriginalEsSettings","_restoreOriginalEsSettings"],"sources":["index.ts"],"sourcesContent":["export * from \"./esCreateIndex\";\nexport * from \"./esFindOne\";\nexport * from \"./esGetIndexExist\";\nexport * from \"./esGetIndexName\";\nexport * from \"./esGetIndexSettings\";\nexport * from \"./esPutIndexSettings\";\nexport * from \"./esQueryAllWithCallback\";\nexport * from \"./esQueryAll\";\nexport * from \"./esListIndexes\";\nexport * from \"./disableEsIndexing\";\nexport * from \"./fetchOriginalEsSettings\";\nexport * from \"./restoreOriginalEsSettings\";\n"],"mappings":";;;;;AAAA,IAAAA,c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EAAAf,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAc,wBAAA,CAAAd,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAU,wBAAA,CAAAd,GAAA;IAAA;EAAA;AAAA;AACA,IAAAe,0BAAA,GAAAnB,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAiB,0BAAA,EAAAhB,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAe,0BAAA,CAAAf,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAW,0BAAA,CAAAf,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export declare const base: {
2
+ body: import("@webiny/api-elasticsearch/types").ElasticsearchIndexRequestBody;
3
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.base = void 0;
7
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
+ const base = exports.base = {
9
+ body: (0, _apiElasticsearch.getBaseConfiguration)()
10
+ };
11
+
12
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiElasticsearch","require","base","exports","body","getBaseConfiguration"],"sources":["base.ts"],"sourcesContent":["import { getBaseConfiguration } from \"@webiny/api-elasticsearch\";\n\nexport const base = {\n body: getBaseConfiguration()\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG;EAChBE,IAAI,EAAE,IAAAC,sCAAoB,EAAC;AAC/B,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { ElasticsearchIndexRequestBody } from "@webiny/api-elasticsearch/types";
2
+ export interface ElasticsearchIndexPlugins {
3
+ body: ElasticsearchIndexRequestBody;
4
+ locales?: string[];
5
+ }
6
+ export declare const elasticsearchIndexPlugins: () => ElasticsearchIndexPlugins[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elasticsearchIndexPlugins = void 0;
7
+ var _base = require("./base");
8
+ var _japanese = require("./japanese");
9
+ const elasticsearchIndexPlugins = () => {
10
+ return [_base.base, _japanese.japanese];
11
+ };
12
+ exports.elasticsearchIndexPlugins = elasticsearchIndexPlugins;
13
+
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_base","require","_japanese","elasticsearchIndexPlugins","base","japanese","exports"],"sources":["index.ts"],"sourcesContent":["import type { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\n\nimport { base } from \"./base\";\nimport { japanese } from \"./japanese\";\n\nexport interface ElasticsearchIndexPlugins {\n body: ElasticsearchIndexRequestBody;\n locales?: string[];\n}\n\nexport const elasticsearchIndexPlugins = (): ElasticsearchIndexPlugins[] => {\n return [base, japanese];\n};\n"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAOO,MAAME,yBAAyB,GAAGA,CAAA,KAAmC;EACxE,OAAO,CAACC,UAAI,EAAEC,kBAAQ,CAAC;AAC3B,CAAC;AAACC,OAAA,CAAAH,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const japanese: {
2
+ body: import("@webiny/api-elasticsearch/types").ElasticsearchIndexRequestBody;
3
+ locales: string[];
4
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.japanese = void 0;
7
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
+ const japanese = exports.japanese = {
9
+ body: (0, _apiElasticsearch.getJapaneseConfiguration)(),
10
+ locales: ["ja", "ja-jp"]
11
+ };
12
+
13
+ //# sourceMappingURL=japanese.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_apiElasticsearch","require","japanese","exports","body","getJapaneseConfiguration","locales"],"sources":["japanese.ts"],"sourcesContent":["import { getJapaneseConfiguration } from \"@webiny/api-elasticsearch\";\n\nexport const japanese = {\n body: getJapaneseConfiguration(),\n locales: [\"ja\", \"ja-jp\"]\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACpBE,IAAI,EAAE,IAAAC,0CAAwB,EAAC,CAAC;EAChCC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO;AAC3B,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import type { Logger } from "@webiny/data-migration";
2
+ import type { Client } from "@elastic/elasticsearch";
3
+ interface IndexSettings {
4
+ refresh_interval: `${number}s` | "-1";
5
+ }
6
+ interface RestoreOriginalElasticsearchSettingsParams {
7
+ indexSettings: {
8
+ [index: string]: IndexSettings | null;
9
+ };
10
+ logger: Logger;
11
+ elasticsearchClient: Client;
12
+ }
13
+ export declare const restoreOriginalElasticsearchSettings: (params: RestoreOriginalElasticsearchSettingsParams) => Promise<void>;
14
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.restoreOriginalElasticsearchSettings = void 0;
7
+ var _ = require("./..");
8
+ const restoreOriginalElasticsearchSettings = async params => {
9
+ const {
10
+ indexSettings,
11
+ logger
12
+ } = params;
13
+ const indexes = indexSettings;
14
+ if (!indexes || typeof indexes !== "object") {
15
+ return;
16
+ }
17
+ for (const index in indexes) {
18
+ const settings = indexes[index];
19
+ if (!settings || typeof settings !== "object") {
20
+ continue;
21
+ }
22
+
23
+ // We must ensure that the refresh interval is not set to a negative value. Why?
24
+ // We've had a case where a migration run has been manually stopped, and the index settings
25
+ // were never restored. Once a second run was started and this restore function
26
+ // was called, the refresh interval was set to `-1s`, which effectively disabled indexing.
27
+ let refreshInterval = settings.refresh_interval || `1s`;
28
+ if (refreshInterval === "-1") {
29
+ refreshInterval = "1s";
30
+ }
31
+ try {
32
+ await (0, _.esPutIndexSettings)({
33
+ elasticsearchClient: params.elasticsearchClient,
34
+ index,
35
+ settings: {
36
+ refresh_interval: refreshInterval
37
+ }
38
+ });
39
+ } catch (ex) {
40
+ logger.error(`Failed to restore original settings for index "${index}". Please do it manually.`);
41
+ logger.error({
42
+ ...ex,
43
+ message: ex.message,
44
+ code: ex.code,
45
+ data: ex.data
46
+ });
47
+ }
48
+ }
49
+ };
50
+ exports.restoreOriginalElasticsearchSettings = restoreOriginalElasticsearchSettings;
51
+
52
+ //# sourceMappingURL=restoreOriginalEsSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_","require","restoreOriginalElasticsearchSettings","params","indexSettings","logger","indexes","index","settings","refreshInterval","refresh_interval","esPutIndexSettings","elasticsearchClient","ex","error","message","code","data","exports"],"sources":["restoreOriginalEsSettings.ts"],"sourcesContent":["import { esPutIndexSettings } from \"~/utils\";\nimport type { Logger } from \"@webiny/data-migration\";\nimport type { Client } from \"@elastic/elasticsearch\";\n\ninterface IndexSettings {\n refresh_interval: `${number}s` | \"-1\";\n}\n\ninterface RestoreOriginalElasticsearchSettingsParams {\n indexSettings: {\n [index: string]: IndexSettings | null;\n };\n logger: Logger;\n elasticsearchClient: Client;\n}\n\nexport const restoreOriginalElasticsearchSettings = async (\n params: RestoreOriginalElasticsearchSettingsParams\n): Promise<void> => {\n const { indexSettings, logger } = params;\n\n const indexes = indexSettings;\n if (!indexes || typeof indexes !== \"object\") {\n return;\n }\n\n for (const index in indexes) {\n const settings = indexes[index];\n if (!settings || typeof settings !== \"object\") {\n continue;\n }\n\n // We must ensure that the refresh interval is not set to a negative value. Why?\n // We've had a case where a migration run has been manually stopped, and the index settings\n // were never restored. Once a second run was started and this restore function\n // was called, the refresh interval was set to `-1s`, which effectively disabled indexing.\n let refreshInterval = settings.refresh_interval || `1s`;\n if (refreshInterval === \"-1\") {\n refreshInterval = \"1s\";\n }\n\n try {\n await esPutIndexSettings({\n elasticsearchClient: params.elasticsearchClient,\n index,\n settings: {\n refresh_interval: refreshInterval\n }\n });\n } catch (ex) {\n logger.error(\n `Failed to restore original settings for index \"${index}\". Please do it manually.`\n );\n logger.error({\n ...ex,\n message: ex.message,\n code: ex.code,\n data: ex.data\n });\n }\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,OAAA;AAgBO,MAAMC,oCAAoC,GAAG,MAChDC,MAAkD,IAClC;EAChB,MAAM;IAAEC,aAAa;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAExC,MAAMG,OAAO,GAAGF,aAAa;EAC7B,IAAI,CAACE,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IACzC;EACJ;EAEA,KAAK,MAAMC,KAAK,IAAID,OAAO,EAAE;IACzB,MAAME,QAAQ,GAAGF,OAAO,CAACC,KAAK,CAAC;IAC/B,IAAI,CAACC,QAAQ,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;MAC3C;IACJ;;IAEA;IACA;IACA;IACA;IACA,IAAIC,eAAe,GAAGD,QAAQ,CAACE,gBAAgB,IAAI,IAAI;IACvD,IAAID,eAAe,KAAK,IAAI,EAAE;MAC1BA,eAAe,GAAG,IAAI;IAC1B;IAEA,IAAI;MACA,MAAM,IAAAE,oBAAkB,EAAC;QACrBC,mBAAmB,EAAET,MAAM,CAACS,mBAAmB;QAC/CL,KAAK;QACLC,QAAQ,EAAE;UACNE,gBAAgB,EAAED;QACtB;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOI,EAAE,EAAE;MACTR,MAAM,CAACS,KAAK,CACR,kDAAkDP,KAAK,2BAC3D,CAAC;MACDF,MAAM,CAACS,KAAK,CAAC;QACT,GAAGD,EAAE;QACLE,OAAO,EAAEF,EAAE,CAACE,OAAO;QACnBC,IAAI,EAAEH,EAAE,CAACG,IAAI;QACbC,IAAI,EAAEJ,EAAE,CAACI;MACb,CAAC,CAAC;IACN;EACJ;AACJ,CAAC;AAACC,OAAA,CAAAhB,oCAAA,GAAAA,oCAAA","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { Logger } from "@webiny/logger";
3
+ export interface Tenant {
4
+ data: {
5
+ id: string;
6
+ name: string;
7
+ };
8
+ }
9
+ export interface I18NLocale {
10
+ code: string;
11
+ }
12
+ type ForEachTenantLocaleCallback = (params: {
13
+ tenantId: string;
14
+ localeCode: string;
15
+ }) => boolean | Promise<boolean>;
16
+ interface ForEachTenantLocaleParams {
17
+ table: Table<string, string, string>;
18
+ logger: Logger;
19
+ callback: ForEachTenantLocaleCallback;
20
+ }
21
+ export declare const forEachTenantLocale: ({ table, logger, callback }: ForEachTenantLocaleParams) => Promise<void>;
22
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.forEachTenantLocale = void 0;
7
+ var _ = require("./");
8
+ const forEachTenantLocale = async ({
9
+ table,
10
+ logger,
11
+ callback
12
+ }) => {
13
+ const tenantEntity = (0, _.createTenantEntity)(table);
14
+ const tenants = await (0, _.queryAll)({
15
+ entity: tenantEntity,
16
+ partitionKey: "TENANTS",
17
+ options: {
18
+ index: "GSI1",
19
+ gte: " "
20
+ }
21
+ });
22
+ if (tenants.length === 0) {
23
+ logger.info(`No tenants found in the system.`);
24
+ return;
25
+ }
26
+ const localeEntity = (0, _.createLocaleEntity)(table);
27
+ for (const tenant of tenants) {
28
+ const locales = await (0, _.queryAll)({
29
+ entity: localeEntity,
30
+ partitionKey: `T#${tenant.data.id}#I18N#L`,
31
+ options: {
32
+ gte: " "
33
+ }
34
+ });
35
+ if (locales.length === 0) {
36
+ logger.info(`No locales found in tenant "${tenant.data.id}".`);
37
+ continue;
38
+ }
39
+ for (const locale of locales) {
40
+ const result = await callback({
41
+ tenantId: tenant.data.id,
42
+ localeCode: locale.code
43
+ });
44
+ // For now, we only check if the return value is `false`. If so, we stop
45
+ // iterating over the locales and tenants completely. If needed, we could
46
+ // add more control over the iteration process.
47
+ if (result === false) {
48
+ return;
49
+ }
50
+ }
51
+ }
52
+ };
53
+ exports.forEachTenantLocale = forEachTenantLocale;
54
+
55
+ //# sourceMappingURL=forEachTenantLocale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_","require","forEachTenantLocale","table","logger","callback","tenantEntity","createTenantEntity","tenants","queryAll","entity","partitionKey","options","index","gte","length","info","localeEntity","createLocaleEntity","tenant","locales","data","id","locale","result","tenantId","localeCode","code","exports"],"sources":["forEachTenantLocale.ts"],"sourcesContent":["import { createLocaleEntity, createTenantEntity, queryAll } from \"~/utils\";\nimport type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Logger } from \"@webiny/logger\";\n\nexport interface Tenant {\n data: {\n id: string;\n name: string;\n };\n}\n\nexport interface I18NLocale {\n code: string;\n}\n\ntype ForEachTenantLocaleCallback = (params: {\n tenantId: string;\n localeCode: string;\n}) => boolean | Promise<boolean>;\n\ninterface ForEachTenantLocaleParams {\n table: Table<string, string, string>;\n logger: Logger;\n callback: ForEachTenantLocaleCallback;\n}\n\nexport const forEachTenantLocale = async ({\n table,\n logger,\n callback\n}: ForEachTenantLocaleParams) => {\n const tenantEntity = createTenantEntity(table);\n const tenants = await queryAll<Tenant>({\n entity: tenantEntity,\n partitionKey: \"TENANTS\",\n options: {\n index: \"GSI1\",\n gte: \" \"\n }\n });\n\n if (tenants.length === 0) {\n logger.info(`No tenants found in the system.`);\n return;\n }\n\n const localeEntity = createLocaleEntity(table);\n\n for (const tenant of tenants) {\n const locales = await queryAll<I18NLocale>({\n entity: localeEntity,\n partitionKey: `T#${tenant.data.id}#I18N#L`,\n options: {\n gte: \" \"\n }\n });\n\n if (locales.length === 0) {\n logger.info(`No locales found in tenant \"${tenant.data.id}\".`);\n continue;\n }\n\n for (const locale of locales) {\n const result = await callback({ tenantId: tenant.data.id, localeCode: locale.code });\n // For now, we only check if the return value is `false`. If so, we stop\n // iterating over the locales and tenants completely. If needed, we could\n // add more control over the iteration process.\n if (result === false) {\n return;\n }\n }\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,CAAA,GAAAC,OAAA;AA0BO,MAAMC,mBAAmB,GAAG,MAAAA,CAAO;EACtCC,KAAK;EACLC,MAAM;EACNC;AACuB,CAAC,KAAK;EAC7B,MAAMC,YAAY,GAAG,IAAAC,oBAAkB,EAACJ,KAAK,CAAC;EAC9C,MAAMK,OAAO,GAAG,MAAM,IAAAC,UAAQ,EAAS;IACnCC,MAAM,EAAEJ,YAAY;IACpBK,YAAY,EAAE,SAAS;IACvBC,OAAO,EAAE;MACLC,KAAK,EAAE,MAAM;MACbC,GAAG,EAAE;IACT;EACJ,CAAC,CAAC;EAEF,IAAIN,OAAO,CAACO,MAAM,KAAK,CAAC,EAAE;IACtBX,MAAM,CAACY,IAAI,CAAC,iCAAiC,CAAC;IAC9C;EACJ;EAEA,MAAMC,YAAY,GAAG,IAAAC,oBAAkB,EAACf,KAAK,CAAC;EAE9C,KAAK,MAAMgB,MAAM,IAAIX,OAAO,EAAE;IAC1B,MAAMY,OAAO,GAAG,MAAM,IAAAX,UAAQ,EAAa;MACvCC,MAAM,EAAEO,YAAY;MACpBN,YAAY,EAAE,KAAKQ,MAAM,CAACE,IAAI,CAACC,EAAE,SAAS;MAC1CV,OAAO,EAAE;QACLE,GAAG,EAAE;MACT;IACJ,CAAC,CAAC;IAEF,IAAIM,OAAO,CAACL,MAAM,KAAK,CAAC,EAAE;MACtBX,MAAM,CAACY,IAAI,CAAC,+BAA+BG,MAAM,CAACE,IAAI,CAACC,EAAE,IAAI,CAAC;MAC9D;IACJ;IAEA,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;MAC1B,MAAMI,MAAM,GAAG,MAAMnB,QAAQ,CAAC;QAAEoB,QAAQ,EAAEN,MAAM,CAACE,IAAI,CAACC,EAAE;QAAEI,UAAU,EAAEH,MAAM,CAACI;MAAK,CAAC,CAAC;MACpF;MACA;MACA;MACA,IAAIH,MAAM,KAAK,KAAK,EAAE;QAClB;MACJ;IACJ;EACJ;AACJ,CAAC;AAACI,OAAA,CAAA1B,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const getCompressedData: (data: any) => Promise<{
2
+ compression: string;
3
+ value: string;
4
+ }>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCompressedData = void 0;
7
+ var _gzip = require("@webiny/utils/compression/gzip");
8
+ const GZIP = "gzip";
9
+ const TO_STORAGE_ENCODING = "base64";
10
+ const getCompressedData = async data => {
11
+ const value = await (0, _gzip.compress)(JSON.stringify(data));
12
+ return {
13
+ compression: GZIP,
14
+ value: value.toString(TO_STORAGE_ENCODING)
15
+ };
16
+ };
17
+ exports.getCompressedData = getCompressedData;
18
+
19
+ //# sourceMappingURL=getCompressedData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_gzip","require","GZIP","TO_STORAGE_ENCODING","getCompressedData","data","value","gzip","JSON","stringify","compression","toString","exports"],"sources":["getCompressedData.ts"],"sourcesContent":["import { compress as gzip } from \"@webiny/utils/compression/gzip\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\n\nexport const getCompressedData = async (data: any) => {\n const value = await gzip(JSON.stringify(data));\n\n return {\n compression: GZIP,\n value: value.toString(TO_STORAGE_ENCODING)\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,mBAAmB,GAAG,QAAQ;AAE7B,MAAMC,iBAAiB,GAAG,MAAOC,IAAS,IAAK;EAClD,MAAMC,KAAK,GAAG,MAAM,IAAAC,cAAI,EAACC,IAAI,CAACC,SAAS,CAACJ,IAAI,CAAC,CAAC;EAE9C,OAAO;IACHK,WAAW,EAAER,IAAI;IACjBI,KAAK,EAAEA,KAAK,CAACK,QAAQ,CAACR,mBAAmB;EAC7C,CAAC;AACL,CAAC;AAACS,OAAA,CAAAR,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export * from "./dynamoDb";
2
+ export * from "./elasticsearch";
3
+ export * from "./forEachTenantLocale";
4
+ export * from "./createEntity";
5
+ export * from "./createLocaleEntity";
6
+ export * from "./createTenantEntity";
7
+ export * from "./getCompressedData";