@logto/schemas 1.9.2 → 1.10.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.
@@ -43,14 +43,23 @@ const alteration: AlterationScript = {
43
43
  scopeId: string;
44
44
  indicator: string;
45
45
  }>(sql`
46
- select roles.id as "role_id", roles.tenant_id as "tenant_id", scopes.id as "scope_id", resources.indicator as "indicator" from roles join roles_scopes on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id join scopes on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
47
- where roles.name = ${InternalRole.Admin} and roles.type = ${
48
- RoleType.MachineToMachine
49
- } and scopes.name = ${
50
- PredefinedScope.All
51
- } and resources.indicator like ${getManagementApiResourceIndicator(
52
- '%'
53
- )} and resources.name = 'Logto Management API'
46
+ select
47
+ roles.id as "role_id",
48
+ roles.tenant_id as "tenant_id",
49
+ scopes.id as "scope_id",
50
+ resources.indicator as "indicator" from roles
51
+ join roles_scopes
52
+ on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id
53
+ join scopes
54
+ on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id
55
+ join resources
56
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
57
+ where
58
+ roles.name = ${InternalRole.Admin}
59
+ and roles.type = ${RoleType.MachineToMachine}
60
+ and scopes.name = ${PredefinedScope.All}
61
+ and resources.indicator like ${getManagementApiResourceIndicator('%')}
62
+ and resources.name = 'Logto Management API'
54
63
  `);
55
64
  // Can not directly use the result from the query unless we use subquery, separate the filter and subquery for easy understanding.
56
65
  const internalManagementApiRoles = internalManagementApiRolesCandidates.filter(
@@ -177,14 +186,24 @@ const alteration: AlterationScript = {
177
186
  scopeId: string;
178
187
  indicator: string;
179
188
  }>(sql`
180
- select roles.id as "role_id", roles.tenant_id as "tenant_id", scopes.id as "scope_id", resources.indicator as "indicator" from roles join roles_scopes on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id join scopes on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
181
- where roles.name = ${managementApiAccessRoleName} and roles.description = ${managementApiAccessRoleDescription} and roles.type = ${
182
- RoleType.MachineToMachine
183
- } and scopes.name = ${
184
- PredefinedScope.All
185
- } and resources.indicator like ${getManagementApiResourceIndicator(
186
- '%'
187
- )} and resources.name = 'Logto Management API';
189
+ select
190
+ roles.id as "role_id",
191
+ roles.tenant_id as "tenant_id",
192
+ scopes.id as "scope_id",
193
+ resources.indicator as "indicator" from roles
194
+ join roles_scopes
195
+ on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id
196
+ join scopes
197
+ on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id
198
+ join resources
199
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
200
+ where
201
+ roles.name = ${managementApiAccessRoleName}
202
+ and roles.description = ${managementApiAccessRoleDescription}
203
+ and roles.type = ${RoleType.MachineToMachine}
204
+ and scopes.name = ${PredefinedScope.All}
205
+ and resources.indicator like ${getManagementApiResourceIndicator('%')}
206
+ and resources.name = 'Logto Management API';
188
207
  `);
189
208
  // Can not directly use the result from the query unless we use subquery, separate the filter and subquery for easy understanding.
190
209
  const managementApiAccessRoles = managementApiAccessRolesCandidates.filter(
@@ -219,14 +238,23 @@ const alteration: AlterationScript = {
219
238
  roleId: string;
220
239
  tenantId: string;
221
240
  }>(sql`
222
- select roles.id as "roleId", roles.tenant_id as "tenantId" from roles join roles_scopes on roles.tenant_id = roles_scopes.tenant_id and roles.id = roles_scopes.role_id join scopes on scopes.tenant_id = roles_scopes.tenant_id and scopes.id = roles_scopes.scope_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id where roles.name = ${
223
- InternalRole.Admin
224
- } and ( roles.tenant_id, resources.indicator ) in (values ${sql.join(
225
- concernedTenantIds.map(
226
- (tenantId) => sql`( ${tenantId}, ${getManagementApiResourceIndicator(tenantId)} )`
227
- ),
228
- sql`, `
229
- )});
241
+ select
242
+ roles.id as "roleId",
243
+ roles.tenant_id as "tenantId" from roles
244
+ join roles_scopes
245
+ on roles.tenant_id = roles_scopes.tenant_id and roles.id = roles_scopes.role_id
246
+ join scopes
247
+ on scopes.tenant_id = roles_scopes.tenant_id and scopes.id = roles_scopes.scope_id
248
+ join resources
249
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
250
+ where
251
+ roles.name = ${InternalRole.Admin}
252
+ and ( roles.tenant_id, resources.indicator ) in (values ${sql.join(
253
+ concernedTenantIds.map(
254
+ (tenantId) => sql`( ${tenantId}, ${getManagementApiResourceIndicator(tenantId)} )`
255
+ ),
256
+ sql`, `
257
+ )});
230
258
  `);
231
259
  /**
232
260
  * Step 4
@@ -33,8 +33,23 @@ const alteration = {
33
33
  * Based on this setup, we can use the following query to get all internal admin roles.
34
34
  */
35
35
  const { rows: internalManagementApiRolesCandidates } = await pool.query(sql `
36
- select roles.id as "role_id", roles.tenant_id as "tenant_id", scopes.id as "scope_id", resources.indicator as "indicator" from roles join roles_scopes on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id join scopes on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
37
- where roles.name = ${InternalRole.Admin} and roles.type = ${RoleType.MachineToMachine} and scopes.name = ${PredefinedScope.All} and resources.indicator like ${getManagementApiResourceIndicator('%')} and resources.name = 'Logto Management API'
36
+ select
37
+ roles.id as "role_id",
38
+ roles.tenant_id as "tenant_id",
39
+ scopes.id as "scope_id",
40
+ resources.indicator as "indicator" from roles
41
+ join roles_scopes
42
+ on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id
43
+ join scopes
44
+ on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id
45
+ join resources
46
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
47
+ where
48
+ roles.name = ${InternalRole.Admin}
49
+ and roles.type = ${RoleType.MachineToMachine}
50
+ and scopes.name = ${PredefinedScope.All}
51
+ and resources.indicator like ${getManagementApiResourceIndicator('%')}
52
+ and resources.name = 'Logto Management API'
38
53
  `);
39
54
  // Can not directly use the result from the query unless we use subquery, separate the filter and subquery for easy understanding.
40
55
  const internalManagementApiRoles = internalManagementApiRolesCandidates.filter(({ indicator, tenantId }) => indicator === getManagementApiResourceIndicator(tenantId));
@@ -103,8 +118,24 @@ const alteration = {
103
118
  * Based on this setup, we can use the following query to get all internal admin roles.
104
119
  */
105
120
  const { rows: managementApiAccessRolesCandidates } = await pool.query(sql `
106
- select roles.id as "role_id", roles.tenant_id as "tenant_id", scopes.id as "scope_id", resources.indicator as "indicator" from roles join roles_scopes on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id join scopes on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
107
- where roles.name = ${managementApiAccessRoleName} and roles.description = ${managementApiAccessRoleDescription} and roles.type = ${RoleType.MachineToMachine} and scopes.name = ${PredefinedScope.All} and resources.indicator like ${getManagementApiResourceIndicator('%')} and resources.name = 'Logto Management API';
121
+ select
122
+ roles.id as "role_id",
123
+ roles.tenant_id as "tenant_id",
124
+ scopes.id as "scope_id",
125
+ resources.indicator as "indicator" from roles
126
+ join roles_scopes
127
+ on roles_scopes.role_id = roles.id and roles_scopes.tenant_id = roles.tenant_id
128
+ join scopes
129
+ on scopes.id = roles_scopes.scope_id and scopes.tenant_id = roles_scopes.tenant_id
130
+ join resources
131
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
132
+ where
133
+ roles.name = ${managementApiAccessRoleName}
134
+ and roles.description = ${managementApiAccessRoleDescription}
135
+ and roles.type = ${RoleType.MachineToMachine}
136
+ and scopes.name = ${PredefinedScope.All}
137
+ and resources.indicator like ${getManagementApiResourceIndicator('%')}
138
+ and resources.name = 'Logto Management API';
108
139
  `);
109
140
  // Can not directly use the result from the query unless we use subquery, separate the filter and subquery for easy understanding.
110
141
  const managementApiAccessRoles = managementApiAccessRolesCandidates.filter(({ indicator, tenantId }) => indicator === getManagementApiResourceIndicator(tenantId));
@@ -124,7 +155,18 @@ const alteration = {
124
155
  */
125
156
  const concernedTenantIds = deduplicate(managementApiAccessRoles.map(({ tenantId }) => tenantId));
126
157
  const { rows: internalAdminAccessRoles } = await pool.query(sql `
127
- select roles.id as "roleId", roles.tenant_id as "tenantId" from roles join roles_scopes on roles.tenant_id = roles_scopes.tenant_id and roles.id = roles_scopes.role_id join scopes on scopes.tenant_id = roles_scopes.tenant_id and scopes.id = roles_scopes.scope_id join resources on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id where roles.name = ${InternalRole.Admin} and ( roles.tenant_id, resources.indicator ) in (values ${sql.join(concernedTenantIds.map((tenantId) => sql `( ${tenantId}, ${getManagementApiResourceIndicator(tenantId)} )`), sql `, `)});
158
+ select
159
+ roles.id as "roleId",
160
+ roles.tenant_id as "tenantId" from roles
161
+ join roles_scopes
162
+ on roles.tenant_id = roles_scopes.tenant_id and roles.id = roles_scopes.role_id
163
+ join scopes
164
+ on scopes.tenant_id = roles_scopes.tenant_id and scopes.id = roles_scopes.scope_id
165
+ join resources
166
+ on resources.id = scopes.resource_id and resources.tenant_id = scopes.tenant_id
167
+ where
168
+ roles.name = ${InternalRole.Admin}
169
+ and ( roles.tenant_id, resources.indicator ) in (values ${sql.join(concernedTenantIds.map((tenantId) => sql `( ${tenantId}, ${getManagementApiResourceIndicator(tenantId)} )`), sql `, `)});
128
170
  `);
129
171
  /**
130
172
  * Step 4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -65,7 +65,7 @@
65
65
  "prettier": "@silverhand/eslint-config/.prettierrc",
66
66
  "dependencies": {
67
67
  "@logto/connector-kit": "^1.1.1",
68
- "@logto/core-kit": "^2.1.2",
68
+ "@logto/core-kit": "^2.2.0",
69
69
  "@logto/language-kit": "^1.0.0",
70
70
  "@logto/phrases": "^1.5.0",
71
71
  "@logto/phrases-experience": "^1.3.1",