@webiny/migrations 5.43.0-beta.0 → 5.43.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/ddb-es.d.ts +2 -2
  2. package/ddb-es.js +2 -2
  3. package/ddb-es.js.map +1 -1
  4. package/ddb.d.ts +2 -2
  5. package/ddb.js +2 -2
  6. package/ddb.js.map +1 -1
  7. package/migrations/5.43.0/001/constants.d.ts +2 -0
  8. package/migrations/5.43.0/001/constants.js +10 -0
  9. package/migrations/5.43.0/001/constants.js.map +1 -0
  10. package/migrations/{5.41.0/001 → 5.43.0/001/ddb}/index.d.ts +6 -4
  11. package/migrations/5.43.0/001/ddb/index.js +215 -0
  12. package/migrations/5.43.0/001/ddb/index.js.map +1 -0
  13. package/migrations/5.43.0/001/ddb-es/index.d.ts +16 -0
  14. package/migrations/5.43.0/001/ddb-es/index.js +257 -0
  15. package/migrations/5.43.0/001/ddb-es/index.js.map +1 -0
  16. package/migrations/5.43.0/001/entities/createEntryEntity.d.ts +89 -0
  17. package/migrations/5.43.0/001/entities/createEntryEntity.js +188 -0
  18. package/migrations/5.43.0/001/entities/createEntryEntity.js.map +1 -0
  19. package/migrations/5.43.0/001/types.d.ts +47 -0
  20. package/migrations/5.43.0/001/types.js +7 -0
  21. package/migrations/5.43.0/001/types.js.map +1 -0
  22. package/package.json +17 -17
  23. package/utils/getCompressedData.d.ts +4 -0
  24. package/utils/getCompressedData.js +19 -0
  25. package/utils/getCompressedData.js.map +1 -0
  26. package/utils/index.d.ts +1 -0
  27. package/utils/index.js +11 -0
  28. package/utils/index.js.map +1 -1
  29. package/migrations/5.41.0/001/createTenantEntity.d.ts +0 -42
  30. package/migrations/5.41.0/001/createTenantEntity.js +0 -46
  31. package/migrations/5.41.0/001/createTenantEntity.js.map +0 -1
  32. package/migrations/5.41.0/001/createUserEntity.d.ts +0 -48
  33. package/migrations/5.41.0/001/createUserEntity.js +0 -54
  34. package/migrations/5.41.0/001/createUserEntity.js.map +0 -1
  35. package/migrations/5.41.0/001/index.js +0 -92
  36. package/migrations/5.41.0/001/index.js.map +0 -1
@@ -1,48 +0,0 @@
1
- import { Table } from "@webiny/db-dynamodb/toolbox";
2
- export declare const createUserEntity: (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,54 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createUserEntity = void 0;
7
- var _utils = require("../../../utils");
8
- const attributes = {
9
- id: {
10
- type: "string"
11
- },
12
- tenant: {
13
- type: "string"
14
- },
15
- email: {
16
- type: "string"
17
- },
18
- firstName: {
19
- type: "string"
20
- },
21
- lastName: {
22
- type: "string"
23
- },
24
- avatar: {
25
- type: "map"
26
- },
27
- createdBy: {
28
- type: "map"
29
- },
30
- createdOn: {
31
- type: "string"
32
- },
33
- group: {
34
- type: "string"
35
- },
36
- team: {
37
- type: "string"
38
- },
39
- groups: {
40
- type: "map"
41
- },
42
- teams: {
43
- type: "map"
44
- },
45
- webinyVersion: {
46
- type: "string"
47
- }
48
- };
49
- const createUserEntity = table => {
50
- return (0, _utils.createStandardEntity)(table, "AdminUsers.User", attributes);
51
- };
52
- exports.createUserEntity = createUserEntity;
53
-
54
- //# sourceMappingURL=createUserEntity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_utils","require","attributes","id","type","tenant","email","firstName","lastName","avatar","createdBy","createdOn","group","team","groups","teams","webinyVersion","createUserEntity","table","createStandardEntity","exports"],"sources":["createUserEntity.ts"],"sourcesContent":["import { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { createLegacyEntity, createStandardEntity } from \"~/utils\";\n\nconst attributes: Parameters<typeof createLegacyEntity>[2] = {\n id: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n email: {\n type: \"string\"\n },\n firstName: {\n type: \"string\"\n },\n lastName: {\n type: \"string\"\n },\n avatar: {\n type: \"map\"\n },\n createdBy: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n group: {\n type: \"string\"\n },\n team: {\n type: \"string\"\n },\n groups: {\n type: \"map\"\n },\n teams: {\n type: \"map\"\n },\n webinyVersion: {\n type: \"string\"\n }\n};\n\nexport const createUserEntity = (table: Table<string, string, string>) => {\n return createStandardEntity(table, \"AdminUsers.User\", attributes);\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,UAAoD,GAAG;EACzDC,EAAE,EAAE;IACAC,IAAI,EAAE;EACV,CAAC;EACDC,MAAM,EAAE;IACJD,IAAI,EAAE;EACV,CAAC;EACDE,KAAK,EAAE;IACHF,IAAI,EAAE;EACV,CAAC;EACDG,SAAS,EAAE;IACPH,IAAI,EAAE;EACV,CAAC;EACDI,QAAQ,EAAE;IACNJ,IAAI,EAAE;EACV,CAAC;EACDK,MAAM,EAAE;IACJL,IAAI,EAAE;EACV,CAAC;EACDM,SAAS,EAAE;IACPN,IAAI,EAAE;EACV,CAAC;EACDO,SAAS,EAAE;IACPP,IAAI,EAAE;EACV,CAAC;EACDQ,KAAK,EAAE;IACHR,IAAI,EAAE;EACV,CAAC;EACDS,IAAI,EAAE;IACFT,IAAI,EAAE;EACV,CAAC;EACDU,MAAM,EAAE;IACJV,IAAI,EAAE;EACV,CAAC;EACDW,KAAK,EAAE;IACHX,IAAI,EAAE;EACV,CAAC;EACDY,aAAa,EAAE;IACXZ,IAAI,EAAE;EACV;AACJ,CAAC;AAEM,MAAMa,gBAAgB,GAAIC,KAAoC,IAAK;EACtE,OAAO,IAAAC,2BAAoB,EAACD,KAAK,EAAE,iBAAiB,EAAEhB,UAAU,CAAC;AACrE,CAAC;AAACkB,OAAA,CAAAH,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,92 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.AdminUsers_5_41_0_001 = void 0;
7
- var _dataMigration = require("@webiny/data-migration");
8
- var _utils = require("../../../utils");
9
- var _createTenantEntity = require("./createTenantEntity");
10
- var _createUserEntity = require("./createUserEntity");
11
- var _ioc = require("@webiny/ioc");
12
- var _utils2 = require("@webiny/utils");
13
- var _dbDynamodb = require("@webiny/db-dynamodb");
14
- class AdminUsers_5_41_0_001 {
15
- constructor(table) {
16
- this.newUserEntity = (0, _createUserEntity.createUserEntity)(table);
17
- this.tenantEntity = (0, _createTenantEntity.createTenantEntity)(table);
18
- }
19
- getId() {
20
- return "5.41.0-001";
21
- }
22
- getDescription() {
23
- return "Introduce 'groups' and 'teams` properties (old 'group' and 'team' are no longer in use)";
24
- }
25
- async shouldExecute({
26
- logger
27
- }) {
28
- const user = await (0, _utils.queryOne)({
29
- entity: this.newUserEntity,
30
- partitionKey: `T#root#ADMIN_USERS`,
31
- options: {
32
- index: "GSI1",
33
- gt: " "
34
- }
35
- });
36
- if (!user) {
37
- logger.info(`No users were found; skipping migration.`);
38
- return false;
39
- }
40
- if (Array.isArray(user.data.groups)) {
41
- logger.info(`User records seems to be in order; skipping migration.`);
42
- return false;
43
- }
44
- return true;
45
- }
46
- async execute({
47
- logger
48
- }) {
49
- const tenants = await (0, _utils.queryAll)({
50
- entity: this.tenantEntity,
51
- partitionKey: "TENANTS",
52
- options: {
53
- index: "GSI1",
54
- gt: " "
55
- }
56
- });
57
- for (const tenant of tenants) {
58
- const users = await (0, _utils.queryAll)({
59
- entity: this.newUserEntity,
60
- partitionKey: `T#${tenant.data.id}#ADMIN_USERS`,
61
- options: {
62
- index: "GSI1",
63
- gt: " "
64
- }
65
- });
66
- if (users.length === 0) {
67
- logger.info(`No users found on tenant "${tenant.data.id}".`);
68
- continue;
69
- }
70
- const newUsersEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
71
- entity: this.newUserEntity,
72
- put: users.filter(user => !Array.isArray(user.data.groups)).map(user => {
73
- return {
74
- ...user,
75
- data: {
76
- ...user.data,
77
- groups: [user.data.group].filter(Boolean),
78
- teams: [user.data.team].filter(Boolean)
79
- }
80
- };
81
- })
82
- });
83
- await (0, _utils2.executeWithRetry)(async () => {
84
- return await newUsersEntityBatch.execute();
85
- });
86
- }
87
- }
88
- }
89
- exports.AdminUsers_5_41_0_001 = AdminUsers_5_41_0_001;
90
- (0, _ioc.makeInjectable)(AdminUsers_5_41_0_001, [(0, _ioc.inject)(_dataMigration.PrimaryDynamoTableSymbol)]);
91
-
92
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_dataMigration","require","_utils","_createTenantEntity","_createUserEntity","_ioc","_utils2","_dbDynamodb","AdminUsers_5_41_0_001","constructor","table","newUserEntity","createUserEntity","tenantEntity","createTenantEntity","getId","getDescription","shouldExecute","logger","user","queryOne","entity","partitionKey","options","index","gt","info","Array","isArray","data","groups","execute","tenants","queryAll","tenant","users","id","length","newUsersEntityBatch","createEntityWriteBatch","put","filter","map","group","Boolean","teams","team","executeWithRetry","exports","makeInjectable","inject","PrimaryDynamoTableSymbol"],"sources":["index.ts"],"sourcesContent":["import { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { DataMigrationContext, PrimaryDynamoTableSymbol } from \"@webiny/data-migration\";\nimport { queryAll, queryOne } from \"~/utils\";\nimport { createTenantEntity } from \"./createTenantEntity\";\nimport { createUserEntity } from \"./createUserEntity\";\nimport { inject, makeInjectable } from \"@webiny/ioc\";\nimport { executeWithRetry } from \"@webiny/utils\";\nimport { createEntityWriteBatch } from \"@webiny/db-dynamodb\";\n\nexport class AdminUsers_5_41_0_001 {\n private readonly newUserEntity: ReturnType<typeof createUserEntity>;\n private readonly tenantEntity: ReturnType<typeof createTenantEntity>;\n\n constructor(table: Table<string, string, string>) {\n this.newUserEntity = createUserEntity(table);\n this.tenantEntity = createTenantEntity(table);\n }\n\n getId() {\n return \"5.41.0-001\";\n }\n\n getDescription() {\n return \"Introduce 'groups' and 'teams` properties (old 'group' and 'team' are no longer in use)\";\n }\n\n async shouldExecute({ logger }: DataMigrationContext): Promise<boolean> {\n const user = await queryOne<{ data: any }>({\n entity: this.newUserEntity,\n partitionKey: `T#root#ADMIN_USERS`,\n options: {\n index: \"GSI1\",\n gt: \" \"\n }\n });\n\n if (!user) {\n logger.info(`No users were found; skipping migration.`);\n return false;\n }\n\n if (Array.isArray(user.data.groups)) {\n logger.info(`User records seems to be in order; skipping migration.`);\n return false;\n }\n\n return true;\n }\n\n async execute({ logger }: DataMigrationContext): Promise<void> {\n const tenants = await queryAll<{ data: { id: string; name: string } }>({\n entity: this.tenantEntity,\n partitionKey: \"TENANTS\",\n options: {\n index: \"GSI1\",\n gt: \" \"\n }\n });\n\n for (const tenant of tenants) {\n const users = await queryAll<{ id: string; email: string; data?: any }>({\n entity: this.newUserEntity,\n partitionKey: `T#${tenant.data.id}#ADMIN_USERS`,\n options: {\n index: \"GSI1\",\n gt: \" \"\n }\n });\n\n if (users.length === 0) {\n logger.info(`No users found on tenant \"${tenant.data.id}\".`);\n continue;\n }\n\n const newUsersEntityBatch = createEntityWriteBatch({\n entity: this.newUserEntity,\n put: users\n .filter(user => !Array.isArray(user.data.groups))\n .map(user => {\n return {\n ...user,\n data: {\n ...user.data,\n groups: [user.data.group].filter(Boolean),\n teams: [user.data.team].filter(Boolean)\n }\n };\n })\n });\n\n await executeWithRetry(async () => {\n return await newUsersEntityBatch.execute();\n });\n }\n }\n}\n\nmakeInjectable(AdminUsers_5_41_0_001, [inject(PrimaryDynamoTableSymbol)]);\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAEO,MAAMO,qBAAqB,CAAC;EAI/BC,WAAWA,CAACC,KAAoC,EAAE;IAC9C,IAAI,CAACC,aAAa,GAAG,IAAAC,kCAAgB,EAACF,KAAK,CAAC;IAC5C,IAAI,CAACG,YAAY,GAAG,IAAAC,sCAAkB,EAACJ,KAAK,CAAC;EACjD;EAEAK,KAAKA,CAAA,EAAG;IACJ,OAAO,YAAY;EACvB;EAEAC,cAAcA,CAAA,EAAG;IACb,OAAO,yFAAyF;EACpG;EAEA,MAAMC,aAAaA,CAAC;IAAEC;EAA6B,CAAC,EAAoB;IACpE,MAAMC,IAAI,GAAG,MAAM,IAAAC,eAAQ,EAAgB;MACvCC,MAAM,EAAE,IAAI,CAACV,aAAa;MAC1BW,YAAY,EAAE,oBAAoB;MAClCC,OAAO,EAAE;QACLC,KAAK,EAAE,MAAM;QACbC,EAAE,EAAE;MACR;IACJ,CAAC,CAAC;IAEF,IAAI,CAACN,IAAI,EAAE;MACPD,MAAM,CAACQ,IAAI,CAAC,0CAA0C,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