@webiny/migrations 5.41.0-beta.0 → 5.41.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.
|
@@ -56,14 +56,14 @@ class AdminUsers_5_41_0_001 {
|
|
|
56
56
|
for (const tenant of tenants) {
|
|
57
57
|
const users = await (0, _utils.queryAll)({
|
|
58
58
|
entity: this.newUserEntity,
|
|
59
|
-
partitionKey: `T#${tenant.id}#ADMIN_USERS`,
|
|
59
|
+
partitionKey: `T#${tenant.data.id}#ADMIN_USERS`,
|
|
60
60
|
options: {
|
|
61
61
|
index: "GSI1",
|
|
62
62
|
gt: " "
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
if (users.length === 0) {
|
|
66
|
-
logger.info(`No users found on tenant "${tenant.id}".`);
|
|
66
|
+
logger.info(`No users found on tenant "${tenant.data.id}".`);
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
69
|
const newUsers = users.filter(user => !Array.isArray(user.data.groups)).map(user => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dataMigration","require","_utils","_createTenantEntity","_createUserEntity","_ioc","_utils2","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","newUsers","filter","map","putBatch","group","Boolean","teams","team","executeWithRetry","batchWriteAll","items","exports","makeInjectable","inject","PrimaryDynamoTableSymbol"],"sources":["index.ts"],"sourcesContent":["import { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { DataMigrationContext, PrimaryDynamoTableSymbol } from \"@webiny/data-migration\";\nimport { queryOne, queryAll, batchWriteAll } from \"~/utils\";\nimport { createTenantEntity } from \"./createTenantEntity\";\nimport { createUserEntity } from \"./createUserEntity\";\nimport { makeInjectable, inject } from \"@webiny/ioc\";\nimport { executeWithRetry } from \"@webiny/utils\";\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<{ 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.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.id}\".`);\n continue;\n }\n\n const newUsers = users\n .filter(user => !Array.isArray(user.data.groups))\n .map(user => {\n return this.newUserEntity.putBatch({\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 await executeWithRetry(() =>\n batchWriteAll({ table: this.newUserEntity.table, items: newUsers })\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;AAEO,MAAMM,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,EAAG,oBAAmB;MAClCC,OAAO,EAAE;QACLC,KAAK,EAAE,MAAM;QACbC,EAAE,EAAE;MACR;IACJ,CAAC,CAAC;IAEF,IAAI,CAACN,IAAI,EAAE;MACPD,MAAM,CAACQ,IAAI,CAAE,0CAAyC,CAAC;MACvD,OAAO,KAAK;IAChB;IAEA,IAAIC,KAAK,CAACC,OAAO,CAACT,IAAI,CAACU,IAAI,CAACC,MAAM,CAAC,EAAE;MACjCZ,MAAM,CAACQ,IAAI,CAAE,wDAAuD,CAAC;MACrE,OAAO,KAAK;IAChB;IAEA,OAAO,IAAI;EACf;EAEA,MAAMK,OAAOA,CAAC;IAAEb;EAA6B,CAAC,EAAiB;IAC3D,MAAMc,OAAO,GAAG,MAAM,IAAAC,eAAQ,
|
|
1
|
+
{"version":3,"names":["_dataMigration","require","_utils","_createTenantEntity","_createUserEntity","_ioc","_utils2","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","newUsers","filter","map","putBatch","group","Boolean","teams","team","executeWithRetry","batchWriteAll","items","exports","makeInjectable","inject","PrimaryDynamoTableSymbol"],"sources":["index.ts"],"sourcesContent":["import { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { DataMigrationContext, PrimaryDynamoTableSymbol } from \"@webiny/data-migration\";\nimport { queryOne, queryAll, batchWriteAll } from \"~/utils\";\nimport { createTenantEntity } from \"./createTenantEntity\";\nimport { createUserEntity } from \"./createUserEntity\";\nimport { makeInjectable, inject } from \"@webiny/ioc\";\nimport { executeWithRetry } from \"@webiny/utils\";\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 newUsers = users\n .filter(user => !Array.isArray(user.data.groups))\n .map(user => {\n return this.newUserEntity.putBatch({\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 await executeWithRetry(() =>\n batchWriteAll({ table: this.newUserEntity.table, items: newUsers })\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;AAEO,MAAMM,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,EAAG,oBAAmB;MAClCC,OAAO,EAAE;QACLC,KAAK,EAAE,MAAM;QACbC,EAAE,EAAE;MACR;IACJ,CAAC,CAAC;IAEF,IAAI,CAACN,IAAI,EAAE;MACPD,MAAM,CAAC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AACX,IAAI,CAACU,IAAI,CAACa,KAAK,CAAC,CAACH,MAAM,CAACI,OAAO,CAAC;YACzCC,KAAK,EAAE,CAACzB,IAAI,CAACU,IAAI,CAACgB,IAAI,CAAC,CAACN,MAAM,CAACI,OAAO;UAC1C;QACJ,CAAC,CAAC;MACN,CAAC,CAAC;MAEN,MAAM,IAAAG,wBAAgB,EAAC,MACnB,IAAAC,oBAAa,EAAC;QAAErC,KAAK,EAAE,IAAI,CAACC,aAAa,CAACD,KAAK;QAAEsC,KAAK,EAAEV;MAAS,CAAC,CACtE,CAAC;IACL;EACJ;AACJ;AAACW,OAAA,CAAAzC,qBAAA,GAAAA,qBAAA;AAED,IAAA0C,mBAAc,EAAC1C,qBAAqB,EAAE,CAAC,IAAA2C,WAAM,EAACC,uCAAwB,CAAC,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/migrations",
|
|
3
|
-
"version": "5.41.0-beta.
|
|
3
|
+
"version": "5.41.0-beta.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "yarn webiny run build",
|
|
6
6
|
"watch": "yarn webiny run watch"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@elastic/elasticsearch": "7.12.0",
|
|
10
|
-
"@webiny/api-elasticsearch": "5.41.0-beta.
|
|
11
|
-
"@webiny/aws-sdk": "5.41.0-beta.
|
|
12
|
-
"@webiny/cli-plugin-deploy-pulumi": "5.41.0-beta.
|
|
13
|
-
"@webiny/data-migration": "5.41.0-beta.
|
|
14
|
-
"@webiny/db-dynamodb": "5.41.0-beta.
|
|
15
|
-
"@webiny/error": "5.41.0-beta.
|
|
16
|
-
"@webiny/ioc": "5.41.0-beta.
|
|
17
|
-
"@webiny/logger": "5.41.0-beta.
|
|
18
|
-
"@webiny/utils": "5.41.0-beta.
|
|
10
|
+
"@webiny/api-elasticsearch": "5.41.0-beta.2",
|
|
11
|
+
"@webiny/aws-sdk": "5.41.0-beta.2",
|
|
12
|
+
"@webiny/cli-plugin-deploy-pulumi": "5.41.0-beta.2",
|
|
13
|
+
"@webiny/data-migration": "5.41.0-beta.2",
|
|
14
|
+
"@webiny/db-dynamodb": "5.41.0-beta.2",
|
|
15
|
+
"@webiny/error": "5.41.0-beta.2",
|
|
16
|
+
"@webiny/ioc": "5.41.0-beta.2",
|
|
17
|
+
"@webiny/logger": "5.41.0-beta.2",
|
|
18
|
+
"@webiny/utils": "5.41.0-beta.2",
|
|
19
19
|
"execa": "5.1.1",
|
|
20
20
|
"fast-glob": "3.2.12",
|
|
21
21
|
"jsonpack": "1.1.5",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/execa": "2.0.0",
|
|
33
|
-
"@webiny/api-headless-cms": "5.41.0-beta.
|
|
34
|
-
"@webiny/api-headless-cms-ddb-es": "5.41.0-beta.
|
|
35
|
-
"@webiny/cli": "5.41.0-beta.
|
|
36
|
-
"@webiny/handler-aws": "5.41.0-beta.
|
|
37
|
-
"@webiny/plugins": "5.41.0-beta.
|
|
38
|
-
"@webiny/project-utils": "5.41.0-beta.
|
|
33
|
+
"@webiny/api-headless-cms": "5.41.0-beta.2",
|
|
34
|
+
"@webiny/api-headless-cms-ddb-es": "5.41.0-beta.2",
|
|
35
|
+
"@webiny/cli": "5.41.0-beta.2",
|
|
36
|
+
"@webiny/handler-aws": "5.41.0-beta.2",
|
|
37
|
+
"@webiny/plugins": "5.41.0-beta.2",
|
|
38
|
+
"@webiny/project-utils": "5.41.0-beta.2",
|
|
39
39
|
"elastic-ts": "0.8.0",
|
|
40
40
|
"jest-dynalite": "3.6.1",
|
|
41
41
|
"ttypescript": "1.5.15",
|
|
42
42
|
"typescript": "4.9.5"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "391a78231f6c46fddf9f6a5bfd2ee95f1cb18eb9"
|
|
45
45
|
}
|