@logto/schemas 1.2.3 → 1.5.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 (78) hide show
  1. package/alterations/1.3.0-1683292832-update-hooks.ts +105 -0
  2. package/alterations/1.5.0-1684382842-add-name-tag-created-at-for-tenants-table.ts +22 -0
  3. package/alterations/1.5.0-1684739802-create-hook-id-index-for-logs.ts +18 -0
  4. package/alterations/1.5.0-1684822341-init-domains.ts +66 -0
  5. package/alterations/1.5.0-1684837981-add-manage-tenant-self-scope-to-user-role.ts +56 -0
  6. package/alterations/1.5.0-1685285719-support-default-resource.ts +23 -0
  7. package/alterations-js/1.3.0-1683292832-update-hooks.d.ts +3 -0
  8. package/alterations-js/1.3.0-1683292832-update-hooks.js +73 -0
  9. package/alterations-js/1.5.0-1684382842-add-name-tag-created-at-for-tenants-table.d.ts +3 -0
  10. package/alterations-js/1.5.0-1684382842-add-name-tag-created-at-for-tenants-table.js +19 -0
  11. package/alterations-js/1.5.0-1684739802-create-hook-id-index-for-logs.d.ts +3 -0
  12. package/alterations-js/1.5.0-1684739802-create-hook-id-index-for-logs.js +14 -0
  13. package/alterations-js/1.5.0-1684822341-init-domains.d.ts +3 -0
  14. package/alterations-js/1.5.0-1684822341-init-domains.js +57 -0
  15. package/alterations-js/1.5.0-1684837981-add-manage-tenant-self-scope-to-user-role.d.ts +3 -0
  16. package/alterations-js/1.5.0-1684837981-add-manage-tenant-self-scope-to-user-role.js +50 -0
  17. package/alterations-js/1.5.0-1685285719-support-default-resource.d.ts +3 -0
  18. package/alterations-js/1.5.0-1685285719-support-default-resource.js +19 -0
  19. package/lib/db-entries/application.js +6 -6
  20. package/lib/db-entries/applications-role.js +6 -6
  21. package/lib/db-entries/connector.js +4 -4
  22. package/lib/db-entries/custom-phrase.js +4 -4
  23. package/lib/db-entries/domain.d.ts +24 -0
  24. package/lib/db-entries/domain.js +53 -0
  25. package/lib/db-entries/hook.d.ts +11 -3
  26. package/lib/db-entries/hook.js +21 -5
  27. package/lib/db-entries/index.d.ts +1 -0
  28. package/lib/db-entries/index.js +1 -0
  29. package/lib/db-entries/log.js +4 -4
  30. package/lib/db-entries/logto-config.js +2 -2
  31. package/lib/db-entries/oidc-model-instance.js +4 -4
  32. package/lib/db-entries/passcode.js +6 -6
  33. package/lib/db-entries/resource.d.ts +2 -0
  34. package/lib/db-entries/resource.js +10 -6
  35. package/lib/db-entries/role.js +6 -6
  36. package/lib/db-entries/roles-scope.js +6 -6
  37. package/lib/db-entries/scope.js +8 -8
  38. package/lib/db-entries/service-log.js +4 -4
  39. package/lib/db-entries/sign-in-experience.js +2 -2
  40. package/lib/db-entries/system.js +2 -2
  41. package/lib/db-entries/user.js +2 -2
  42. package/lib/db-entries/users-role.js +6 -6
  43. package/lib/db-entries/verification-status.js +4 -4
  44. package/lib/foundations/jsonb-types.d.ts +160 -11
  45. package/lib/foundations/jsonb-types.js +52 -2
  46. package/lib/models/tenants.d.ts +4 -1
  47. package/lib/models/tenants.js +4 -0
  48. package/lib/seeds/application.js +1 -1
  49. package/lib/seeds/cloud-api.d.ts +4 -0
  50. package/lib/seeds/cloud-api.js +8 -1
  51. package/lib/seeds/management-api.d.ts +3 -3
  52. package/lib/seeds/management-api.js +38 -30
  53. package/lib/types/connector.d.ts +2984 -8
  54. package/lib/types/connector.js +22 -0
  55. package/lib/types/dashboard.d.ts +116 -0
  56. package/lib/types/dashboard.js +18 -0
  57. package/lib/types/domain.d.ts +90 -0
  58. package/lib/types/domain.js +22 -0
  59. package/lib/types/hook.d.ts +82 -2
  60. package/lib/types/hook.js +9 -1
  61. package/lib/types/index.d.ts +2 -0
  62. package/lib/types/index.js +2 -0
  63. package/lib/types/interactions.d.ts +6 -6
  64. package/lib/types/log/hook.d.ts +1 -1
  65. package/lib/types/log/hook.js +1 -1
  66. package/lib/types/scope.d.ts +42 -4
  67. package/lib/types/scope.js +4 -1
  68. package/lib/types/system.d.ts +26 -3
  69. package/lib/types/system.js +15 -0
  70. package/lib/types/tenant.d.ts +34 -1
  71. package/lib/types/tenant.js +19 -1
  72. package/lib/types/user.d.ts +129 -5
  73. package/lib/types/user.js +6 -0
  74. package/package.json +2 -2
  75. package/tables/domains.sql +17 -0
  76. package/tables/hooks.sql +13 -11
  77. package/tables/logs.sql +3 -0
  78. package/tables/resources.sql +5 -0
@@ -0,0 +1,105 @@
1
+ import { generateStandardId } from '@logto/shared';
2
+ import { sql } from 'slonik';
3
+
4
+ import type { AlterationScript } from '../lib/types/alteration.js';
5
+
6
+ enum HookEvent {
7
+ PostRegister = 'PostRegister',
8
+ PostSignIn = 'PostSignIn',
9
+ PostResetPassword = 'PostResetPassword',
10
+ }
11
+
12
+ type HookConfig = {
13
+ url: string;
14
+ headers?: Record<string, string>;
15
+ retries?: number;
16
+ };
17
+
18
+ type Hook = {
19
+ tenantId: string;
20
+ id: string;
21
+ name: string;
22
+ event: HookEvent | null;
23
+ events: HookEvent[];
24
+ config: HookConfig;
25
+ signingKey: string;
26
+ enabled: boolean;
27
+ createdAt: number;
28
+ };
29
+
30
+ const alteration: AlterationScript = {
31
+ up: async (pool) => {
32
+ await pool.query(sql`
33
+ alter table hooks
34
+ add column name varchar(256) not null default '',
35
+ add column events jsonb not null default '[]'::jsonb,
36
+ add column signing_key varchar(64) not null default '',
37
+ add column enabled boolean not null default true,
38
+ alter column event drop not null;
39
+ drop index hooks__event;
40
+ `);
41
+ },
42
+ down: async (pool) => {
43
+ await pool.query(sql`
44
+ delete from hooks where enabled = false;
45
+ `);
46
+
47
+ const { rows: hooks } = await pool.query<Hook>(sql`
48
+ select * from hooks;
49
+ `);
50
+
51
+ /* eslint-disable no-await-in-loop */
52
+ for (const { id, tenantId, events, config } of hooks) {
53
+ const { retries, ...rest } = config;
54
+
55
+ const updatedConfig = {
56
+ ...rest,
57
+ retries: retries ?? 3,
58
+ };
59
+
60
+ if (events.length === 0) {
61
+ await pool.query(sql`
62
+ update hooks
63
+ set config = ${JSON.stringify(updatedConfig)}
64
+ where id = ${id} and tenant_id = ${tenantId};
65
+ `);
66
+
67
+ continue;
68
+ }
69
+
70
+ for (const [index, event] of events.entries()) {
71
+ if (index === 0) {
72
+ await pool.query(sql`
73
+ update hooks
74
+ set event = ${event},
75
+ config = ${JSON.stringify(updatedConfig)}
76
+ where id = ${id} and tenant_id = ${tenantId};
77
+ `);
78
+
79
+ continue;
80
+ }
81
+
82
+ // Create new hook when there are multiple events
83
+ const hookId = generateStandardId();
84
+
85
+ await pool.query(sql`
86
+ insert into hooks (id, tenant_id, event, config)
87
+ values (${hookId}, ${tenantId}, ${event}, ${JSON.stringify(updatedConfig)});
88
+ `);
89
+ }
90
+ }
91
+ /* eslint-enable no-await-in-loop */
92
+
93
+ await pool.query(sql`
94
+ alter table hooks
95
+ alter column event set not null,
96
+ drop column name,
97
+ drop column events,
98
+ drop column signing_key,
99
+ drop column enabled;
100
+ create index hooks__event on hooks (tenant_id, event);
101
+ `);
102
+ },
103
+ };
104
+
105
+ export default alteration;
@@ -0,0 +1,22 @@
1
+ import { sql } from 'slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ const alteration: AlterationScript = {
6
+ up: async (pool) => {
7
+ // Add new tenant columns for name, tag, and created_at.
8
+ await pool.query(sql`
9
+ alter table tenants add column name varchar(128) not null default 'My Project';
10
+ alter table tenants add column tag varchar(64) not null default 'development';
11
+ alter table tenants add column created_at timestamptz not null default(now());
12
+ `);
13
+ },
14
+ down: async (pool) => {
15
+ await pool.query(sql`
16
+ alter table tenants drop column name;
17
+ alter table tenants drop column tag;
18
+ alter table tenants drop column created_at;
19
+ `);
20
+ },
21
+ };
22
+ export default alteration;
@@ -0,0 +1,18 @@
1
+ import { sql } from 'slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ const alteration: AlterationScript = {
6
+ up: async (pool) => {
7
+ await pool.query(sql`
8
+ create index logs__hook_id on logs (tenant_id, (payload->>'hookId'));
9
+ `);
10
+ },
11
+ down: async (pool) => {
12
+ await pool.query(sql`
13
+ drop index logs__hook_id;
14
+ `);
15
+ },
16
+ };
17
+
18
+ export default alteration;
@@ -0,0 +1,66 @@
1
+ import type { CommonQueryMethods } from 'slonik';
2
+ import { sql } from 'slonik';
3
+
4
+ import type { AlterationScript } from '../lib/types/alteration.js';
5
+
6
+ const getId = (value: string) => sql.identifier([value]);
7
+
8
+ const getDatabaseName = async (pool: CommonQueryMethods) => {
9
+ const { currentDatabase } = await pool.one<{ currentDatabase: string }>(sql`
10
+ select current_database();
11
+ `);
12
+
13
+ return currentDatabase.replaceAll('-', '_');
14
+ };
15
+
16
+ const alteration: AlterationScript = {
17
+ up: async (pool) => {
18
+ const database = await getDatabaseName(pool);
19
+ const baseRoleId = getId(`logto_tenant_${database}`);
20
+
21
+ await pool.query(sql`
22
+ create table domains (
23
+ tenant_id varchar(21) not null
24
+ references tenants (id) on update cascade on delete cascade,
25
+ id varchar(21) not null,
26
+ domain varchar(256) not null,
27
+ status varchar(32) not null default('PendingVerification'),
28
+ error_message varchar(1024),
29
+ dns_records jsonb /* @use DomainDnsRecords */ not null default '[]'::jsonb,
30
+ cloudflare_data jsonb /* @use CloudflareData */,
31
+ updated_at timestamptz not null default(now()),
32
+ created_at timestamptz not null default(now()),
33
+ primary key (id),
34
+ constraint domains__domain
35
+ unique (domain)
36
+ );
37
+
38
+ create index domains__id on domains (tenant_id, id);
39
+
40
+ create trigger set_tenant_id before insert on domains
41
+ for each row execute procedure set_tenant_id();
42
+
43
+ alter table domains enable row level security;
44
+
45
+ create policy domains_tenant_id on domains
46
+ as restrictive
47
+ using (tenant_id = (select id from tenants where db_user = current_user));
48
+ create policy domains_modification on domains
49
+ using (true);
50
+
51
+ grant select, insert, update, delete on domains to ${baseRoleId};
52
+ `);
53
+ },
54
+ down: async (pool) => {
55
+ await pool.query(sql`
56
+ drop policy domains_tenant_id on domains;
57
+ drop policy domains_modification on domains;
58
+
59
+ alter table domains disable row level security;
60
+
61
+ drop table domains;
62
+ `);
63
+ },
64
+ };
65
+
66
+ export default alteration;
@@ -0,0 +1,56 @@
1
+ import { generateStandardId } from '@logto/shared/universal';
2
+ import { sql } from 'slonik';
3
+
4
+ import type { AlterationScript } from '../lib/types/alteration.js';
5
+
6
+ const adminTenantId = 'admin';
7
+
8
+ const alteration: AlterationScript = {
9
+ up: async (pool) => {
10
+ // Get `resourceId` of the admin tenant's resource whose indicator is `https://cloud.logto.io/api`.
11
+ const { id: resourceId } = await pool.one<{ id: string }>(sql`
12
+ select id from resources
13
+ where tenant_id = ${adminTenantId}
14
+ and indicator = 'https://cloud.logto.io/api'
15
+ `);
16
+
17
+ // Get `roleId` of the admin tenant's role whose name is `user`.
18
+ const { id: roleId } = await pool.one<{ id: string }>(sql`
19
+ select id from roles
20
+ where tenant_id = ${adminTenantId}
21
+ and name = 'user';
22
+ `);
23
+
24
+ // Insert `manage:tenant:self` scope.
25
+ const scopeId = generateStandardId();
26
+ await pool.query(sql`
27
+ insert into scopes (tenant_id, id, name, description, resource_id)
28
+ values (
29
+ ${adminTenantId},
30
+ ${scopeId},
31
+ 'manage:tenant:self',
32
+ 'Allow managing tenant itself, including update and delete.',
33
+ ${resourceId}
34
+ );
35
+ `);
36
+ // Assign `manage:tenant:self` scope to `user` role.
37
+ await pool.query(sql`
38
+ insert into roles_scopes (tenant_id, id, role_id, scope_id)
39
+ values (
40
+ ${adminTenantId},
41
+ ${generateStandardId()},
42
+ ${roleId},
43
+ ${scopeId}
44
+ );
45
+ `);
46
+ },
47
+ down: async (pool) => {
48
+ // Delete `manage:tenant:self` scope.
49
+ // No need to delete `roles_scopes` because it will be cascade deleted.
50
+ await pool.query(sql`
51
+ delete from scopes
52
+ where tenant_id = ${adminTenantId} and name = 'manage:tenant:self';
53
+ `);
54
+ },
55
+ };
56
+ export default alteration;
@@ -0,0 +1,23 @@
1
+ import { sql } from 'slonik';
2
+
3
+ import type { AlterationScript } from '../lib/types/alteration.js';
4
+
5
+ const alteration: AlterationScript = {
6
+ up: async (pool) => {
7
+ await pool.query(sql`
8
+ alter table resources
9
+ add column is_default boolean not null default (false);
10
+ create unique index resources__is_default_true
11
+ on resources (tenant_id)
12
+ where is_default = true;
13
+ `);
14
+ },
15
+ down: async (pool) => {
16
+ await pool.query(sql`
17
+ alter table resources
18
+ drop is_default;
19
+ `);
20
+ },
21
+ };
22
+
23
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,73 @@
1
+ import { generateStandardId } from '@logto/shared';
2
+ import { sql } from 'slonik';
3
+ var HookEvent;
4
+ (function (HookEvent) {
5
+ HookEvent["PostRegister"] = "PostRegister";
6
+ HookEvent["PostSignIn"] = "PostSignIn";
7
+ HookEvent["PostResetPassword"] = "PostResetPassword";
8
+ })(HookEvent || (HookEvent = {}));
9
+ const alteration = {
10
+ up: async (pool) => {
11
+ await pool.query(sql `
12
+ alter table hooks
13
+ add column name varchar(256) not null default '',
14
+ add column events jsonb not null default '[]'::jsonb,
15
+ add column signing_key varchar(64) not null default '',
16
+ add column enabled boolean not null default true,
17
+ alter column event drop not null;
18
+ drop index hooks__event;
19
+ `);
20
+ },
21
+ down: async (pool) => {
22
+ await pool.query(sql `
23
+ delete from hooks where enabled = false;
24
+ `);
25
+ const { rows: hooks } = await pool.query(sql `
26
+ select * from hooks;
27
+ `);
28
+ /* eslint-disable no-await-in-loop */
29
+ for (const { id, tenantId, events, config } of hooks) {
30
+ const { retries, ...rest } = config;
31
+ const updatedConfig = {
32
+ ...rest,
33
+ retries: retries ?? 3,
34
+ };
35
+ if (events.length === 0) {
36
+ await pool.query(sql `
37
+ update hooks
38
+ set config = ${JSON.stringify(updatedConfig)}
39
+ where id = ${id} and tenant_id = ${tenantId};
40
+ `);
41
+ continue;
42
+ }
43
+ for (const [index, event] of events.entries()) {
44
+ if (index === 0) {
45
+ await pool.query(sql `
46
+ update hooks
47
+ set event = ${event},
48
+ config = ${JSON.stringify(updatedConfig)}
49
+ where id = ${id} and tenant_id = ${tenantId};
50
+ `);
51
+ continue;
52
+ }
53
+ // Create new hook when there are multiple events
54
+ const hookId = generateStandardId();
55
+ await pool.query(sql `
56
+ insert into hooks (id, tenant_id, event, config)
57
+ values (${hookId}, ${tenantId}, ${event}, ${JSON.stringify(updatedConfig)});
58
+ `);
59
+ }
60
+ }
61
+ /* eslint-enable no-await-in-loop */
62
+ await pool.query(sql `
63
+ alter table hooks
64
+ alter column event set not null,
65
+ drop column name,
66
+ drop column events,
67
+ drop column signing_key,
68
+ drop column enabled;
69
+ create index hooks__event on hooks (tenant_id, event);
70
+ `);
71
+ },
72
+ };
73
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,19 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ // Add new tenant columns for name, tag, and created_at.
5
+ await pool.query(sql `
6
+ alter table tenants add column name varchar(128) not null default 'My Project';
7
+ alter table tenants add column tag varchar(64) not null default 'development';
8
+ alter table tenants add column created_at timestamptz not null default(now());
9
+ `);
10
+ },
11
+ down: async (pool) => {
12
+ await pool.query(sql `
13
+ alter table tenants drop column name;
14
+ alter table tenants drop column tag;
15
+ alter table tenants drop column created_at;
16
+ `);
17
+ },
18
+ };
19
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,14 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ create index logs__hook_id on logs (tenant_id, (payload->>'hookId'));
6
+ `);
7
+ },
8
+ down: async (pool) => {
9
+ await pool.query(sql `
10
+ drop index logs__hook_id;
11
+ `);
12
+ },
13
+ };
14
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,57 @@
1
+ import { sql } from 'slonik';
2
+ const getId = (value) => sql.identifier([value]);
3
+ const getDatabaseName = async (pool) => {
4
+ const { currentDatabase } = await pool.one(sql `
5
+ select current_database();
6
+ `);
7
+ return currentDatabase.replaceAll('-', '_');
8
+ };
9
+ const alteration = {
10
+ up: async (pool) => {
11
+ const database = await getDatabaseName(pool);
12
+ const baseRoleId = getId(`logto_tenant_${database}`);
13
+ await pool.query(sql `
14
+ create table domains (
15
+ tenant_id varchar(21) not null
16
+ references tenants (id) on update cascade on delete cascade,
17
+ id varchar(21) not null,
18
+ domain varchar(256) not null,
19
+ status varchar(32) not null default('PendingVerification'),
20
+ error_message varchar(1024),
21
+ dns_records jsonb /* @use DomainDnsRecords */ not null default '[]'::jsonb,
22
+ cloudflare_data jsonb /* @use CloudflareData */,
23
+ updated_at timestamptz not null default(now()),
24
+ created_at timestamptz not null default(now()),
25
+ primary key (id),
26
+ constraint domains__domain
27
+ unique (domain)
28
+ );
29
+
30
+ create index domains__id on domains (tenant_id, id);
31
+
32
+ create trigger set_tenant_id before insert on domains
33
+ for each row execute procedure set_tenant_id();
34
+
35
+ alter table domains enable row level security;
36
+
37
+ create policy domains_tenant_id on domains
38
+ as restrictive
39
+ using (tenant_id = (select id from tenants where db_user = current_user));
40
+ create policy domains_modification on domains
41
+ using (true);
42
+
43
+ grant select, insert, update, delete on domains to ${baseRoleId};
44
+ `);
45
+ },
46
+ down: async (pool) => {
47
+ await pool.query(sql `
48
+ drop policy domains_tenant_id on domains;
49
+ drop policy domains_modification on domains;
50
+
51
+ alter table domains disable row level security;
52
+
53
+ drop table domains;
54
+ `);
55
+ },
56
+ };
57
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,50 @@
1
+ import { generateStandardId } from '@logto/shared/universal';
2
+ import { sql } from 'slonik';
3
+ const adminTenantId = 'admin';
4
+ const alteration = {
5
+ up: async (pool) => {
6
+ // Get `resourceId` of the admin tenant's resource whose indicator is `https://cloud.logto.io/api`.
7
+ const { id: resourceId } = await pool.one(sql `
8
+ select id from resources
9
+ where tenant_id = ${adminTenantId}
10
+ and indicator = 'https://cloud.logto.io/api'
11
+ `);
12
+ // Get `roleId` of the admin tenant's role whose name is `user`.
13
+ const { id: roleId } = await pool.one(sql `
14
+ select id from roles
15
+ where tenant_id = ${adminTenantId}
16
+ and name = 'user';
17
+ `);
18
+ // Insert `manage:tenant:self` scope.
19
+ const scopeId = generateStandardId();
20
+ await pool.query(sql `
21
+ insert into scopes (tenant_id, id, name, description, resource_id)
22
+ values (
23
+ ${adminTenantId},
24
+ ${scopeId},
25
+ 'manage:tenant:self',
26
+ 'Allow managing tenant itself, including update and delete.',
27
+ ${resourceId}
28
+ );
29
+ `);
30
+ // Assign `manage:tenant:self` scope to `user` role.
31
+ await pool.query(sql `
32
+ insert into roles_scopes (tenant_id, id, role_id, scope_id)
33
+ values (
34
+ ${adminTenantId},
35
+ ${generateStandardId()},
36
+ ${roleId},
37
+ ${scopeId}
38
+ );
39
+ `);
40
+ },
41
+ down: async (pool) => {
42
+ // Delete `manage:tenant:self` scope.
43
+ // No need to delete `roles_scopes` because it will be cascade deleted.
44
+ await pool.query(sql `
45
+ delete from scopes
46
+ where tenant_id = ${adminTenantId} and name = 'manage:tenant:self';
47
+ `);
48
+ },
49
+ };
50
+ export default alteration;
@@ -0,0 +1,3 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ declare const alteration: AlterationScript;
3
+ export default alteration;
@@ -0,0 +1,19 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ alter table resources
6
+ add column is_default boolean not null default (false);
7
+ create unique index resources__is_default_true
8
+ on resources (tenant_id)
9
+ where is_default = true;
10
+ `);
11
+ },
12
+ down: async (pool) => {
13
+ await pool.query(sql `
14
+ alter table resources
15
+ drop is_default;
16
+ `);
17
+ },
18
+ };
19
+ export default alteration;
@@ -4,9 +4,9 @@ import { oidcClientMetadataGuard, customClientMetadataGuard } from './../foundat
4
4
  import { ApplicationType } from './custom-types.js';
5
5
  const createGuard = z.object({
6
6
  tenantId: z.string().max(21).optional(),
7
- id: z.string().max(21),
8
- name: z.string().max(256),
9
- secret: z.string().max(64),
7
+ id: z.string().min(1).max(21),
8
+ name: z.string().min(1).max(256),
9
+ secret: z.string().min(1).max(64),
10
10
  description: z.string().nullable().optional(),
11
11
  type: z.nativeEnum(ApplicationType),
12
12
  oidcClientMetadata: oidcClientMetadataGuard,
@@ -15,9 +15,9 @@ const createGuard = z.object({
15
15
  });
16
16
  const guard = z.object({
17
17
  tenantId: z.string().max(21),
18
- id: z.string().max(21),
19
- name: z.string().max(256),
20
- secret: z.string().max(64),
18
+ id: z.string().min(1).max(21),
19
+ name: z.string().min(1).max(256),
20
+ secret: z.string().min(1).max(64),
21
21
  description: z.string().nullable(),
22
22
  type: z.nativeEnum(ApplicationType),
23
23
  oidcClientMetadata: oidcClientMetadataGuard,
@@ -2,15 +2,15 @@
2
2
  import { z } from 'zod';
3
3
  const createGuard = z.object({
4
4
  tenantId: z.string().max(21).optional(),
5
- id: z.string().max(21),
6
- applicationId: z.string().max(21),
7
- roleId: z.string().max(21),
5
+ id: z.string().min(1).max(21),
6
+ applicationId: z.string().min(1).max(21),
7
+ roleId: z.string().min(1).max(21),
8
8
  });
9
9
  const guard = z.object({
10
10
  tenantId: z.string().max(21),
11
- id: z.string().max(21),
12
- applicationId: z.string().max(21),
13
- roleId: z.string().max(21),
11
+ id: z.string().min(1).max(21),
12
+ applicationId: z.string().min(1).max(21),
13
+ roleId: z.string().min(1).max(21),
14
14
  });
15
15
  export const ApplicationsRoles = Object.freeze({
16
16
  table: 'applications_roles',
@@ -3,18 +3,18 @@ import { z } from 'zod';
3
3
  import { jsonObjectGuard, configurableConnectorMetadataGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  tenantId: z.string().max(21).optional(),
6
- id: z.string().max(128),
6
+ id: z.string().min(1).max(128),
7
7
  syncProfile: z.boolean().optional(),
8
- connectorId: z.string().max(128),
8
+ connectorId: z.string().min(1).max(128),
9
9
  config: jsonObjectGuard.optional(),
10
10
  metadata: configurableConnectorMetadataGuard.optional(),
11
11
  createdAt: z.number().optional(),
12
12
  });
13
13
  const guard = z.object({
14
14
  tenantId: z.string().max(21),
15
- id: z.string().max(128),
15
+ id: z.string().min(1).max(128),
16
16
  syncProfile: z.boolean(),
17
- connectorId: z.string().max(128),
17
+ connectorId: z.string().min(1).max(128),
18
18
  config: jsonObjectGuard,
19
19
  metadata: configurableConnectorMetadataGuard,
20
20
  createdAt: z.number(),
@@ -3,14 +3,14 @@ import { z } from 'zod';
3
3
  import { translationGuard } from './../foundations/index.js';
4
4
  const createGuard = z.object({
5
5
  tenantId: z.string().max(21).optional(),
6
- id: z.string().max(21),
7
- languageTag: z.string().max(16),
6
+ id: z.string().min(1).max(21),
7
+ languageTag: z.string().min(1).max(16),
8
8
  translation: translationGuard,
9
9
  });
10
10
  const guard = z.object({
11
11
  tenantId: z.string().max(21),
12
- id: z.string().max(21),
13
- languageTag: z.string().max(16),
12
+ id: z.string().min(1).max(21),
13
+ languageTag: z.string().min(1).max(16),
14
14
  translation: translationGuard,
15
15
  });
16
16
  export const CustomPhrases = Object.freeze({