@logto/schemas 1.12.0 → 1.13.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 (130) hide show
  1. package/alterations/1.13.0-1702274830-add-new-third-party-column-to-applications-table.ts +20 -0
  2. package/alterations/1.13.0-1702372401-add-application-permissions-tables.ts +93 -0
  3. package/alterations/1.13.0-1702544178-sync-tenant-orgs.ts +296 -0
  4. package/alterations/1.13.0-1702871078-protected-application-type.ts +24 -0
  5. package/alterations/1.13.0-1702877515-protected-app-configs.ts +18 -0
  6. package/alterations/1.13.0-1702978120-application-sign-in-experience-table.ts +61 -0
  7. package/alterations/1.13.0-1703229996-daily-token-usage.ts +62 -0
  8. package/alterations/1.13.0-1703230000-update-tenant-roles.ts +94 -0
  9. package/alterations/1.13.0-1704692973-remove-legacy-resources.ts +147 -0
  10. package/alterations/1.13.0-1704934999-add-magic-links-table.ts +37 -0
  11. package/alterations/1.13.0-1704935001-add-organization-invitation-tables.ts +78 -0
  12. package/alterations/1.13.0-1705288654-add-application-user-consent-organizations-table.ts +62 -0
  13. package/alterations/1.13.0-1705991158-update-invitation-indices.ts +32 -0
  14. package/alterations/1.13.0-1706449174-update-organization-invitation-column.ts +24 -0
  15. package/alterations/1.13.0-1706510290-protected-app-host-index.ts +21 -0
  16. package/alterations/1.13.0-1706512952-restore-get-started-page.ts +17 -0
  17. package/alterations/1.13.0-1706528755-remove-magic-links.ts +46 -0
  18. package/alterations/1.13.0-1706585206-protected-app-custom-domain-unique.ts +21 -0
  19. package/alterations/utils/1704934999-tables.ts +49 -0
  20. package/alterations/utils/README.md +9 -0
  21. package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.d.ts +3 -0
  22. package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.js +16 -0
  23. package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.d.ts +3 -0
  24. package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.js +79 -0
  25. package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.d.ts +18 -0
  26. package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.js +225 -0
  27. package/alterations-js/1.13.0-1702871078-protected-application-type.d.ts +3 -0
  28. package/alterations-js/1.13.0-1702871078-protected-application-type.js +20 -0
  29. package/alterations-js/1.13.0-1702877515-protected-app-configs.d.ts +3 -0
  30. package/alterations-js/1.13.0-1702877515-protected-app-configs.js +14 -0
  31. package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.d.ts +3 -0
  32. package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.js +51 -0
  33. package/alterations-js/1.13.0-1703229996-daily-token-usage.d.ts +3 -0
  34. package/alterations-js/1.13.0-1703229996-daily-token-usage.js +51 -0
  35. package/alterations-js/1.13.0-1703230000-update-tenant-roles.d.ts +11 -0
  36. package/alterations-js/1.13.0-1703230000-update-tenant-roles.js +87 -0
  37. package/alterations-js/1.13.0-1704692973-remove-legacy-resources.d.ts +3 -0
  38. package/alterations-js/1.13.0-1704692973-remove-legacy-resources.js +124 -0
  39. package/alterations-js/1.13.0-1704934999-add-magic-links-table.d.ts +3 -0
  40. package/alterations-js/1.13.0-1704934999-add-magic-links-table.js +32 -0
  41. package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.d.ts +3 -0
  42. package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.js +72 -0
  43. package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.d.ts +3 -0
  44. package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.js +52 -0
  45. package/alterations-js/1.13.0-1705991158-update-invitation-indices.d.ts +7 -0
  46. package/alterations-js/1.13.0-1705991158-update-invitation-indices.js +27 -0
  47. package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.d.ts +3 -0
  48. package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.js +20 -0
  49. package/alterations-js/1.13.0-1706510290-protected-app-host-index.d.ts +3 -0
  50. package/alterations-js/1.13.0-1706510290-protected-app-host-index.js +17 -0
  51. package/alterations-js/1.13.0-1706512952-restore-get-started-page.d.ts +3 -0
  52. package/alterations-js/1.13.0-1706512952-restore-get-started-page.js +13 -0
  53. package/alterations-js/1.13.0-1706528755-remove-magic-links.d.ts +3 -0
  54. package/alterations-js/1.13.0-1706528755-remove-magic-links.js +41 -0
  55. package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.d.ts +3 -0
  56. package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.js +17 -0
  57. package/alterations-js/utils/1704934999-tables.d.ts +11 -0
  58. package/alterations-js/utils/1704934999-tables.js +43 -0
  59. package/lib/db-entries/application-sign-in-experience.d.ts +26 -0
  60. package/lib/db-entries/application-sign-in-experience.js +42 -0
  61. package/lib/db-entries/application-user-consent-organization-scope.d.ts +24 -0
  62. package/lib/db-entries/application-user-consent-organization-scope.js +29 -0
  63. package/lib/db-entries/application-user-consent-organization.d.ts +22 -0
  64. package/lib/db-entries/application-user-consent-organization.js +33 -0
  65. package/lib/db-entries/application-user-consent-resource-scope.d.ts +24 -0
  66. package/lib/db-entries/application-user-consent-resource-scope.js +29 -0
  67. package/lib/db-entries/application-user-consent-user-scope.d.ts +24 -0
  68. package/lib/db-entries/application-user-consent-user-scope.js +29 -0
  69. package/lib/db-entries/application.d.ts +6 -2
  70. package/lib/db-entries/application.js +9 -1
  71. package/lib/db-entries/custom-types.d.ts +8 -1
  72. package/lib/db-entries/custom-types.js +8 -0
  73. package/lib/db-entries/daily-token-usage.d.ts +20 -0
  74. package/lib/db-entries/daily-token-usage.js +33 -0
  75. package/lib/db-entries/index.d.ts +8 -0
  76. package/lib/db-entries/index.js +8 -0
  77. package/lib/db-entries/organization-invitation-role-relation.d.ts +24 -0
  78. package/lib/db-entries/organization-invitation-role-relation.js +29 -0
  79. package/lib/db-entries/organization-invitation.d.ts +53 -0
  80. package/lib/db-entries/organization-invitation.js +58 -0
  81. package/lib/foundations/jsonb-types/applications.d.ts +380 -0
  82. package/lib/foundations/jsonb-types/applications.js +29 -0
  83. package/lib/foundations/jsonb-types/custom-domain.d.ts +37 -89
  84. package/lib/foundations/jsonb-types/custom-domain.js +4 -9
  85. package/lib/foundations/jsonb-types/index.d.ts +1 -0
  86. package/lib/foundations/jsonb-types/index.js +1 -0
  87. package/lib/models/tenants.d.ts +1 -1
  88. package/lib/seeds/application.d.ts +1 -1
  89. package/lib/seeds/application.js +3 -1
  90. package/lib/seeds/cloud-api.d.ts +0 -2
  91. package/lib/seeds/cloud-api.js +0 -3
  92. package/lib/seeds/management-api.d.ts +77 -6
  93. package/lib/seeds/management-api.js +14 -10
  94. package/lib/types/application.d.ts +576 -1
  95. package/lib/types/application.js +42 -1
  96. package/lib/types/connector.js +1 -1
  97. package/lib/types/consent.d.ts +568 -0
  98. package/lib/types/consent.js +47 -0
  99. package/lib/types/domain.d.ts +21 -65
  100. package/lib/types/index.d.ts +3 -0
  101. package/lib/types/index.js +3 -0
  102. package/lib/types/interactions.d.ts +6 -6
  103. package/lib/types/logto-config.d.ts +32 -6
  104. package/lib/types/logto-config.js +12 -2
  105. package/lib/types/mapi-proxy.d.ts +30 -0
  106. package/lib/types/mapi-proxy.js +49 -0
  107. package/lib/types/organization.d.ts +10 -1
  108. package/lib/types/organization.js +4 -1
  109. package/lib/types/sso-connector.d.ts +9 -9
  110. package/lib/types/sso-connector.js +1 -1
  111. package/lib/types/system.d.ts +28 -1
  112. package/lib/types/system.js +17 -0
  113. package/lib/types/tenant-organization.d.ts +107 -0
  114. package/lib/types/tenant-organization.js +145 -0
  115. package/lib/types/tenant.d.ts +0 -1
  116. package/lib/types/tenant.js +2 -4
  117. package/lib/types/user-assets.d.ts +5 -5
  118. package/lib/types/user-assets.js +1 -0
  119. package/lib/types/user.d.ts +14 -15
  120. package/lib/types/user.js +0 -1
  121. package/package.json +14 -14
  122. package/tables/application_sign_in_experiences.sql +15 -0
  123. package/tables/application_user_consent_organization_scopes.sql +14 -0
  124. package/tables/application_user_consent_organizations.sql +16 -0
  125. package/tables/application_user_consent_resource_scopes.sql +14 -0
  126. package/tables/application_user_consent_user_scopes.sql +13 -0
  127. package/tables/applications.sql +16 -1
  128. package/tables/daily_token_usage.sql +11 -0
  129. package/tables/organization_invitation_role_relations.sql +14 -0
  130. package/tables/organization_invitations.sql +36 -0
@@ -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,72 @@
1
+ import { sql } from 'slonik';
2
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
3
+ const alteration = {
4
+ up: async (pool) => {
5
+ await pool.query(sql `
6
+ create type organization_invitation_status as enum ('Pending', 'Accepted', 'Expired', 'Revoked');
7
+
8
+ create table organization_invitations (
9
+ tenant_id varchar(21) not null
10
+ references tenants (id) on update cascade on delete cascade,
11
+ /** The unique identifier of the invitation. */
12
+ id varchar(21) not null,
13
+ /** The user ID who sent the invitation. */
14
+ inviter_id varchar(21) not null,
15
+ /** The email address or other identifier of the invitee. */
16
+ invitee varchar(256) not null,
17
+ /** The user ID of who accepted the invitation. */
18
+ accepted_user_id varchar(21)
19
+ references users (id) on update cascade on delete cascade,
20
+ /** The ID of the organization to which the invitee is invited. */
21
+ organization_id varchar(21) not null,
22
+ /** The status of the invitation. */
23
+ status organization_invitation_status not null,
24
+ /** The ID of the magic link that can be used to accept the invitation. */
25
+ magic_link_id varchar(21)
26
+ references magic_links (id) on update cascade on delete cascade,
27
+ /** The time when the invitation was created. */
28
+ created_at timestamptz not null default (now()),
29
+ /** The time when the invitation status was last updated. */
30
+ updated_at timestamptz not null default (now()),
31
+ /** The time when the invitation expires. */
32
+ expires_at timestamptz not null,
33
+ primary key (id),
34
+ foreign key (tenant_id, inviter_id, organization_id)
35
+ references organization_user_relations (tenant_id, user_id, organization_id)
36
+ on update cascade on delete cascade
37
+ );
38
+
39
+ -- Ensure there is only one pending invitation for a given invitee and organization.
40
+ create unique index organization_invitations__invitee_organization_id
41
+ on organization_invitations (tenant_id, invitee, organization_id)
42
+ where status = 'Pending';
43
+ `);
44
+ await applyTableRls(pool, 'organization_invitations');
45
+ await pool.query(sql `
46
+ create table organization_invitation_role_relations (
47
+ tenant_id varchar(21) not null
48
+ references tenants (id) on update cascade on delete cascade,
49
+ /** The ID of the invitation. */
50
+ invitation_id varchar(21) not null
51
+ references organization_invitations (id) on update cascade on delete cascade,
52
+ /** The ID of the organization role. */
53
+ organization_role_id varchar(21) not null
54
+ references organization_roles (id) on update cascade on delete cascade,
55
+ primary key (tenant_id, invitation_id, organization_role_id)
56
+ );
57
+ `);
58
+ await applyTableRls(pool, 'organization_invitation_role_relations');
59
+ },
60
+ down: async (pool) => {
61
+ await dropTableRls(pool, 'organization_invitation_role_relations');
62
+ await pool.query(sql `
63
+ drop table organization_invitation_role_relations;
64
+ `);
65
+ await dropTableRls(pool, 'organization_invitations');
66
+ await pool.query(sql `
67
+ drop table organization_invitations;
68
+ drop type organization_invitation_status;
69
+ `);
70
+ },
71
+ };
72
+ 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,52 @@
1
+ import { sql } from 'slonik';
2
+ const getDatabaseName = async (pool) => {
3
+ const { currentDatabase } = await pool.one(sql `
4
+ select current_database();
5
+ `);
6
+ return currentDatabase.replaceAll('-', '_');
7
+ };
8
+ const enableRls = async (pool, database, table) => {
9
+ const baseRoleId = sql.identifier([`logto_tenant_${database}`]);
10
+ await pool.query(sql `
11
+ create trigger set_tenant_id before insert on ${sql.identifier([table])}
12
+ for each row execute procedure set_tenant_id();
13
+
14
+ alter table ${sql.identifier([table])} enable row level security;
15
+
16
+ create policy ${sql.identifier([`${table}_tenant_id`])} on ${sql.identifier([table])}
17
+ as restrictive
18
+ using (tenant_id = (select id from tenants where db_user = current_user));
19
+
20
+ create policy ${sql.identifier([`${table}_modification`])} on ${sql.identifier([table])}
21
+ using (true);
22
+
23
+ grant select, insert, update, delete on ${sql.identifier([table])} to ${baseRoleId};
24
+ `);
25
+ };
26
+ const alteration = {
27
+ up: async (pool) => {
28
+ const database = await getDatabaseName(pool);
29
+ await pool.query(sql `
30
+ create table application_user_consent_organizations (
31
+ tenant_id varchar(21) not null
32
+ references tenants (id) on update cascade on delete cascade,
33
+ application_id varchar(21) not null
34
+ references applications (id) on update cascade on delete cascade,
35
+ organization_id varchar(21) not null,
36
+ user_id varchar(21) not null,
37
+ primary key (tenant_id, application_id, organization_id, user_id),
38
+ /** User's consent to an application should be synchronized with the user's membership in the organization. */
39
+ foreign key (tenant_id, organization_id, user_id)
40
+ references organization_user_relations (tenant_id, organization_id, user_id)
41
+ on update cascade on delete cascade
42
+ )
43
+ `);
44
+ await enableRls(pool, database, 'application_user_consent_organizations');
45
+ },
46
+ down: async (pool) => {
47
+ await pool.query(sql `
48
+ drop table application_user_consent_organizations;
49
+ `);
50
+ },
51
+ };
52
+ export default alteration;
@@ -0,0 +1,7 @@
1
+ import type { AlterationScript } from '../lib/types/alteration.js';
2
+ /**
3
+ * @fileoverview Separates the index (tenant_id, inviter_id, organization_id) to two indices. Also
4
+ * makes the inviter_id nullable.
5
+ */
6
+ declare const alteration: AlterationScript;
7
+ export default alteration;
@@ -0,0 +1,27 @@
1
+ import { sql } from 'slonik';
2
+ /**
3
+ * @fileoverview Separates the index (tenant_id, inviter_id, organization_id) to two indices. Also
4
+ * makes the inviter_id nullable.
5
+ */
6
+ const alteration = {
7
+ up: async (pool) => {
8
+ await pool.query(sql `
9
+ alter table organization_invitations
10
+ drop constraint organization_invitations_tenant_id_inviter_id_organization_fkey,
11
+ add foreign key (inviter_id) references users (id) on update cascade on delete cascade,
12
+ add foreign key (organization_id) references organizations (id) on update cascade on delete cascade,
13
+ alter column inviter_id drop not null;
14
+ `);
15
+ },
16
+ down: async (pool) => {
17
+ await pool.query(sql `
18
+ alter table organization_invitations
19
+ drop constraint organization_invitations_inviter_id_fkey,
20
+ drop constraint organization_invitations_organization_id_fkey,
21
+ add foreign key (tenant_id, inviter_id, organization_id) references organization_user_relations
22
+ (tenant_id, user_id, organization_id) on update cascade on delete cascade,
23
+ alter column inviter_id set not null;
24
+ `);
25
+ },
26
+ };
27
+ 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,20 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ alter table organization_invitation_role_relations
6
+ rename column invitation_id to organization_invitation_id;
7
+ alter table organization_invitation_role_relations
8
+ rename constraint organization_invitation_role_relations_invitation_id_fkey to organization_invitation_role_re_organization_invitation_id_fkey;
9
+ `);
10
+ },
11
+ down: async (pool) => {
12
+ await pool.query(sql `
13
+ alter table organization_invitation_role_relations
14
+ rename column organization_invitation_id to invitation_id;
15
+ alter table organization_invitation_role_relations
16
+ rename constraint organization_invitation_role_re_organization_invitation_id_fkey to organization_invitation_role_relations_invitation_id_fkey;
17
+ `);
18
+ },
19
+ };
20
+ 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,17 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ create unique index applications__protected_app_metadata_host
6
+ on applications (
7
+ (protected_app_metadata->>'host')
8
+ );
9
+ `);
10
+ },
11
+ down: async (pool) => {
12
+ await pool.query(sql `
13
+ drop index applications__protected_app_metadata_host;
14
+ `);
15
+ },
16
+ };
17
+ 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,13 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ update users
6
+ set custom_data = custom_data #- '{adminConsolePreferences, getStartedHidden}';
7
+ `);
8
+ },
9
+ down: async () => {
10
+ // Do nothing as the data change is not reversible
11
+ },
12
+ };
13
+ 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,41 @@
1
+ import { sql } from 'slonik';
2
+ import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
3
+ const alteration = {
4
+ up: async (pool) => {
5
+ await pool.query(sql `
6
+ alter table organization_invitations
7
+ drop column magic_link_id;
8
+ `);
9
+ await dropTableRls(pool, 'magic_links');
10
+ await pool.query(sql `
11
+ drop table magic_links;
12
+ `);
13
+ },
14
+ down: async (pool) => {
15
+ await pool.query(sql `
16
+ create table magic_links (
17
+ tenant_id varchar(21) not null
18
+ references tenants (id) on update cascade on delete cascade,
19
+ /** The unique identifier of the link. */
20
+ id varchar(21) not null,
21
+ /** The token that can be used to verify the link. */
22
+ token varchar(32) not null,
23
+ /** The time when the link was created. */
24
+ created_at timestamptz not null default (now()),
25
+ /** The time when the link was consumed. */
26
+ consumed_at timestamptz,
27
+ primary key (id)
28
+ );
29
+
30
+ create index magic_links__token
31
+ on magic_links (tenant_id, token);
32
+ `);
33
+ await applyTableRls(pool, 'magic_links');
34
+ await pool.query(sql `
35
+ alter table organization_invitations
36
+ add column magic_link_id varchar(21)
37
+ references magic_links (id) on update cascade on delete cascade;
38
+ `);
39
+ },
40
+ };
41
+ 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,17 @@
1
+ import { sql } from 'slonik';
2
+ const alteration = {
3
+ up: async (pool) => {
4
+ await pool.query(sql `
5
+ create unique index applications__protected_app_metadata_custom_domain
6
+ on applications (
7
+ (protected_app_metadata->'customDomains'->0->>'domain')
8
+ );
9
+ `);
10
+ },
11
+ down: async (pool) => {
12
+ await pool.query(sql `
13
+ drop index applications__protected_app_metadata_custom_domain;
14
+ `);
15
+ },
16
+ };
17
+ export default alteration;
@@ -0,0 +1,11 @@
1
+ import { type CommonQueryMethods } from 'slonik';
2
+ /**
3
+ * A function to call after the table is created. It will apply the necessary row-level security
4
+ * policies and triggers to the table.
5
+ */
6
+ export declare const applyTableRls: (pool: CommonQueryMethods, tableName: string) => Promise<void>;
7
+ /**
8
+ * A function to call before the table is dropped. It will remove the row-level security policies
9
+ * and triggers from the table.
10
+ */
11
+ export declare const dropTableRls: (pool: CommonQueryMethods, tableName: string) => Promise<void>;
@@ -0,0 +1,43 @@
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
+ /**
10
+ * A function to call after the table is created. It will apply the necessary row-level security
11
+ * policies and triggers to the table.
12
+ */
13
+ export const applyTableRls = async (pool, tableName) => {
14
+ const database = await getDatabaseName(pool);
15
+ const baseRoleId = getId(`logto_tenant_${database}`);
16
+ const table = getId(tableName);
17
+ await pool.query(sql `
18
+ create trigger set_tenant_id before insert on ${table}
19
+ for each row execute procedure set_tenant_id();
20
+
21
+ alter table ${table} enable row level security;
22
+
23
+ create policy ${getId(`${tableName}_tenant_id`)} on ${table}
24
+ as restrictive
25
+ using (tenant_id = (select id from tenants where db_user = current_user));
26
+
27
+ create policy ${getId(`${tableName}_modification`)} on ${table}
28
+ using (true);
29
+
30
+ grant select, insert, update, delete on ${table} to ${baseRoleId};
31
+ `);
32
+ };
33
+ /**
34
+ * A function to call before the table is dropped. It will remove the row-level security policies
35
+ * and triggers from the table.
36
+ */
37
+ export const dropTableRls = async (pool, tableName) => {
38
+ await pool.query(sql `
39
+ drop policy ${getId(`${tableName}_modification`)} on ${getId(tableName)};
40
+ drop policy ${getId(`${tableName}_tenant_id`)} on ${getId(tableName)};
41
+ drop trigger set_tenant_id on ${getId(tableName)};
42
+ `);
43
+ };
@@ -0,0 +1,26 @@
1
+ import { Branding, GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * Application level sign-in experience configuration.
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link ApplicationSignInExperience} for the original type.
7
+ */
8
+ export type CreateApplicationSignInExperience = {
9
+ tenantId?: string;
10
+ applicationId: string;
11
+ branding?: Branding;
12
+ termsOfUseUrl?: string | null;
13
+ privacyPolicyUrl?: string | null;
14
+ displayName?: string | null;
15
+ };
16
+ /** Application level sign-in experience configuration. */
17
+ export type ApplicationSignInExperience = {
18
+ tenantId: string;
19
+ applicationId: string;
20
+ branding: Branding;
21
+ termsOfUseUrl: string | null;
22
+ privacyPolicyUrl: string | null;
23
+ displayName: string | null;
24
+ };
25
+ export type ApplicationSignInExperienceKeys = 'tenantId' | 'applicationId' | 'branding' | 'termsOfUseUrl' | 'privacyPolicyUrl' | 'displayName';
26
+ export declare const ApplicationSignInExperiences: GeneratedSchema<ApplicationSignInExperienceKeys, CreateApplicationSignInExperience, ApplicationSignInExperience, 'application_sign_in_experiences', 'application_sign_in_experience'>;
@@ -0,0 +1,42 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ import { brandingGuard } from './../foundations/index.js';
4
+ const createGuard = z.object({
5
+ tenantId: z.string().max(21).optional(),
6
+ applicationId: z.string().min(1).max(21),
7
+ branding: brandingGuard.optional(),
8
+ termsOfUseUrl: z.string().max(2048).nullable().optional(),
9
+ privacyPolicyUrl: z.string().max(2048).nullable().optional(),
10
+ displayName: z.string().max(256).nullable().optional(),
11
+ });
12
+ const guard = z.object({
13
+ tenantId: z.string().max(21),
14
+ applicationId: z.string().min(1).max(21),
15
+ branding: brandingGuard,
16
+ termsOfUseUrl: z.string().max(2048).nullable(),
17
+ privacyPolicyUrl: z.string().max(2048).nullable(),
18
+ displayName: z.string().max(256).nullable(),
19
+ });
20
+ export const ApplicationSignInExperiences = Object.freeze({
21
+ table: 'application_sign_in_experiences',
22
+ tableSingular: 'application_sign_in_experience',
23
+ fields: {
24
+ tenantId: 'tenant_id',
25
+ applicationId: 'application_id',
26
+ branding: 'branding',
27
+ termsOfUseUrl: 'terms_of_use_url',
28
+ privacyPolicyUrl: 'privacy_policy_url',
29
+ displayName: 'display_name',
30
+ },
31
+ fieldKeys: [
32
+ 'tenantId',
33
+ 'applicationId',
34
+ 'branding',
35
+ 'termsOfUseUrl',
36
+ 'privacyPolicyUrl',
37
+ 'displayName',
38
+ ],
39
+ createGuard,
40
+ guard,
41
+ updateGuard: guard.partial(),
42
+ });
@@ -0,0 +1,24 @@
1
+ import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * The organization scopes (permissions) assigned to an application.
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link ApplicationUserConsentOrganizationScope} for the original type.
7
+ */
8
+ export type CreateApplicationUserConsentOrganizationScope = {
9
+ tenantId?: string;
10
+ /** The globally unique identifier of the application. */
11
+ applicationId: string;
12
+ /** The globally unique identifier of the organization scope. */
13
+ organizationScopeId: string;
14
+ };
15
+ /** The organization scopes (permissions) assigned to an application. */
16
+ export type ApplicationUserConsentOrganizationScope = {
17
+ tenantId: string;
18
+ /** The globally unique identifier of the application. */
19
+ applicationId: string;
20
+ /** The globally unique identifier of the organization scope. */
21
+ organizationScopeId: string;
22
+ };
23
+ export type ApplicationUserConsentOrganizationScopeKeys = 'tenantId' | 'applicationId' | 'organizationScopeId';
24
+ export declare const ApplicationUserConsentOrganizationScopes: GeneratedSchema<ApplicationUserConsentOrganizationScopeKeys, CreateApplicationUserConsentOrganizationScope, ApplicationUserConsentOrganizationScope, 'application_user_consent_organization_scopes', 'application_user_consent_organization_scope'>;
@@ -0,0 +1,29 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ const createGuard = z.object({
4
+ tenantId: z.string().max(21).optional(),
5
+ applicationId: z.string().min(1).max(21),
6
+ organizationScopeId: z.string().min(1).max(21),
7
+ });
8
+ const guard = z.object({
9
+ tenantId: z.string().max(21),
10
+ applicationId: z.string().min(1).max(21),
11
+ organizationScopeId: z.string().min(1).max(21),
12
+ });
13
+ export const ApplicationUserConsentOrganizationScopes = Object.freeze({
14
+ table: 'application_user_consent_organization_scopes',
15
+ tableSingular: 'application_user_consent_organization_scope',
16
+ fields: {
17
+ tenantId: 'tenant_id',
18
+ applicationId: 'application_id',
19
+ organizationScopeId: 'organization_scope_id',
20
+ },
21
+ fieldKeys: [
22
+ 'tenantId',
23
+ 'applicationId',
24
+ 'organizationScopeId',
25
+ ],
26
+ createGuard,
27
+ guard,
28
+ updateGuard: guard.partial(),
29
+ });
@@ -0,0 +1,22 @@
1
+ import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * The relations between applications, users and organizations. A relation means that a user has consented to an application to access data in an organization.
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link ApplicationUserConsentOrganization} for the original type.
7
+ */
8
+ export type CreateApplicationUserConsentOrganization = {
9
+ tenantId?: string;
10
+ applicationId: string;
11
+ organizationId: string;
12
+ userId: string;
13
+ };
14
+ /** The relations between applications, users and organizations. A relation means that a user has consented to an application to access data in an organization. */
15
+ export type ApplicationUserConsentOrganization = {
16
+ tenantId: string;
17
+ applicationId: string;
18
+ organizationId: string;
19
+ userId: string;
20
+ };
21
+ export type ApplicationUserConsentOrganizationKeys = 'tenantId' | 'applicationId' | 'organizationId' | 'userId';
22
+ export declare const ApplicationUserConsentOrganizations: GeneratedSchema<ApplicationUserConsentOrganizationKeys, CreateApplicationUserConsentOrganization, ApplicationUserConsentOrganization, 'application_user_consent_organizations', 'application_user_consent_organization'>;
@@ -0,0 +1,33 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ const createGuard = z.object({
4
+ tenantId: z.string().max(21).optional(),
5
+ applicationId: z.string().min(1).max(21),
6
+ organizationId: z.string().min(1).max(21),
7
+ userId: z.string().min(1).max(21),
8
+ });
9
+ const guard = z.object({
10
+ tenantId: z.string().max(21),
11
+ applicationId: z.string().min(1).max(21),
12
+ organizationId: z.string().min(1).max(21),
13
+ userId: z.string().min(1).max(21),
14
+ });
15
+ export const ApplicationUserConsentOrganizations = Object.freeze({
16
+ table: 'application_user_consent_organizations',
17
+ tableSingular: 'application_user_consent_organization',
18
+ fields: {
19
+ tenantId: 'tenant_id',
20
+ applicationId: 'application_id',
21
+ organizationId: 'organization_id',
22
+ userId: 'user_id',
23
+ },
24
+ fieldKeys: [
25
+ 'tenantId',
26
+ 'applicationId',
27
+ 'organizationId',
28
+ 'userId',
29
+ ],
30
+ createGuard,
31
+ guard,
32
+ updateGuard: guard.partial(),
33
+ });
@@ -0,0 +1,24 @@
1
+ import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * The resource scopes (permissions) assigned to an application's consent request.
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link ApplicationUserConsentResourceScope} for the original type.
7
+ */
8
+ export type CreateApplicationUserConsentResourceScope = {
9
+ tenantId?: string;
10
+ /** The globally unique identifier of the application. */
11
+ applicationId: string;
12
+ /** The globally unique identifier of the resource scope. */
13
+ scopeId: string;
14
+ };
15
+ /** The resource scopes (permissions) assigned to an application's consent request. */
16
+ export type ApplicationUserConsentResourceScope = {
17
+ tenantId: string;
18
+ /** The globally unique identifier of the application. */
19
+ applicationId: string;
20
+ /** The globally unique identifier of the resource scope. */
21
+ scopeId: string;
22
+ };
23
+ export type ApplicationUserConsentResourceScopeKeys = 'tenantId' | 'applicationId' | 'scopeId';
24
+ export declare const ApplicationUserConsentResourceScopes: GeneratedSchema<ApplicationUserConsentResourceScopeKeys, CreateApplicationUserConsentResourceScope, ApplicationUserConsentResourceScope, 'application_user_consent_resource_scopes', 'application_user_consent_resource_scope'>;
@@ -0,0 +1,29 @@
1
+ // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
+ import { z } from 'zod';
3
+ const createGuard = z.object({
4
+ tenantId: z.string().max(21).optional(),
5
+ applicationId: z.string().min(1).max(21),
6
+ scopeId: z.string().min(1).max(21),
7
+ });
8
+ const guard = z.object({
9
+ tenantId: z.string().max(21),
10
+ applicationId: z.string().min(1).max(21),
11
+ scopeId: z.string().min(1).max(21),
12
+ });
13
+ export const ApplicationUserConsentResourceScopes = Object.freeze({
14
+ table: 'application_user_consent_resource_scopes',
15
+ tableSingular: 'application_user_consent_resource_scope',
16
+ fields: {
17
+ tenantId: 'tenant_id',
18
+ applicationId: 'application_id',
19
+ scopeId: 'scope_id',
20
+ },
21
+ fieldKeys: [
22
+ 'tenantId',
23
+ 'applicationId',
24
+ 'scopeId',
25
+ ],
26
+ createGuard,
27
+ guard,
28
+ updateGuard: guard.partial(),
29
+ });
@@ -0,0 +1,24 @@
1
+ import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ * The user scopes (permissions) assigned to an application
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link ApplicationUserConsentUserScope} for the original type.
7
+ */
8
+ export type CreateApplicationUserConsentUserScope = {
9
+ tenantId?: string;
10
+ /** The globally unique identifier of the application. */
11
+ applicationId: string;
12
+ /** The unique UserScope enum value @see (@logto/core-kit/open-id.js) for more details */
13
+ userScope: string;
14
+ };
15
+ /** The user scopes (permissions) assigned to an application */
16
+ export type ApplicationUserConsentUserScope = {
17
+ tenantId: string;
18
+ /** The globally unique identifier of the application. */
19
+ applicationId: string;
20
+ /** The unique UserScope enum value @see (@logto/core-kit/open-id.js) for more details */
21
+ userScope: string;
22
+ };
23
+ export type ApplicationUserConsentUserScopeKeys = 'tenantId' | 'applicationId' | 'userScope';
24
+ export declare const ApplicationUserConsentUserScopes: GeneratedSchema<ApplicationUserConsentUserScopeKeys, CreateApplicationUserConsentUserScope, ApplicationUserConsentUserScope, 'application_user_consent_user_scopes', 'application_user_consent_user_scope'>;