@logto/schemas 1.33.0 → 1.35.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.
- package/alterations/1.34.0-1762338508-add-organization-roles-type-index.ts +19 -0
- package/alterations/1.34.0-1764164658-add-applications-roles-include-indexes.ts +38 -0
- package/alterations/1.34.0-1764236036-remove-applications-roles-include-indexes.ts +38 -0
- package/alterations/1.35.0-1764580455-remove-daily-active-users-foreign-key.ts +69 -0
- package/alterations/1.35.0-1764580589-create-aggregated-daily-active-users-table.ts +51 -0
- package/alterations/1.35.0-1764653048-update-daily-token-usage-mau-support.ts +37 -0
- package/alterations/1.35.0-1765183934-add-logs-created-at-id-index.ts +39 -0
- package/alterations/1.35.0-1765255453-update-saml-session-relay-state-to-varchar-512.ts +31 -0
- package/alterations/1.35.0-1765631949-drop-redundant-logs-id-index.ts +47 -0
- package/alterations/1.35.0-1766028646-grant-tenants-table-tag-column-read-permission.ts +39 -0
- package/alterations-js/1.34.0-1762338508-add-organization-roles-type-index.js +15 -0
- package/alterations-js/1.34.0-1764164658-add-applications-roles-include-indexes.js +30 -0
- package/alterations-js/1.34.0-1764236036-remove-applications-roles-include-indexes.js +30 -0
- package/alterations-js/1.35.0-1764580455-remove-daily-active-users-foreign-key.js +57 -0
- package/alterations-js/1.35.0-1764580589-create-aggregated-daily-active-users-table.js +40 -0
- package/alterations-js/1.35.0-1764653048-update-daily-token-usage-mau-support.js +31 -0
- package/alterations-js/1.35.0-1765183934-add-logs-created-at-id-index.js +35 -0
- package/alterations-js/1.35.0-1765255453-update-saml-session-relay-state-to-varchar-512.js +25 -0
- package/alterations-js/1.35.0-1765631949-drop-redundant-logs-id-index.js +43 -0
- package/alterations-js/1.35.0-1766028646-grant-tenants-table-tag-column-read-permission.js +31 -0
- package/lib/consts/product-event.d.ts +0 -12
- package/lib/consts/product-event.js +0 -13
- package/lib/db-entries/aggregated-daily-active-user.d.ts +22 -0
- package/lib/db-entries/aggregated-daily-active-user.js +33 -0
- package/lib/db-entries/daily-token-usage.d.ts +5 -1
- package/lib/db-entries/daily-token-usage.js +8 -0
- package/lib/db-entries/index.d.ts +1 -0
- package/lib/db-entries/index.js +1 -0
- package/lib/db-entries/saml-application-session.js +2 -2
- package/lib/foundations/jsonb-types/captcha.d.ts +16 -0
- package/lib/foundations/jsonb-types/captcha.js +7 -0
- package/lib/foundations/jsonb-types/hooks.d.ts +6 -4
- package/lib/foundations/jsonb-types/hooks.js +3 -1
- package/lib/foundations/jsonb-types/oidc-module.js +1 -1
- package/lib/seeds/application.d.ts +6 -0
- package/lib/seeds/application.js +23 -4
- package/lib/types/alteration.d.ts +11 -1
- package/lib/types/domain.d.ts +4 -2
- package/lib/types/domain.js +2 -0
- package/lib/types/hook.d.ts +7 -4
- package/lib/types/interactions.d.ts +14 -5
- package/lib/types/interactions.js +10 -4
- package/lib/types/sign-in-experience.d.ts +13 -1
- package/lib/types/sign-in-experience.js +3 -1
- package/lib/types/user.d.ts +3 -0
- package/lib/types/user.js +1 -0
- package/package.json +4 -4
- package/tables/_after_all.sql +1 -1
- package/tables/aggregated_daily_active_users.sql +16 -0
- package/tables/daily_active_users.sql +9 -4
- package/tables/daily_token_usage.sql +3 -2
- package/tables/logs.sql +3 -3
- package/tables/organization_roles.sql +3 -0
- package/tables/saml_application_sessions.sql +1 -1
|
@@ -21,10 +21,16 @@ export const interactionIdentifierGuard = z.object({
|
|
|
21
21
|
type: z.nativeEnum(SignInIdentifier),
|
|
22
22
|
value: z.string(),
|
|
23
23
|
});
|
|
24
|
-
export const verificationCodeIdentifierGuard = z.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
export const verificationCodeIdentifierGuard = z.discriminatedUnion('type', [
|
|
25
|
+
z.object({
|
|
26
|
+
type: z.literal(SignInIdentifier.Email),
|
|
27
|
+
value: z.string().regex(emailRegEx),
|
|
28
|
+
}),
|
|
29
|
+
z.object({
|
|
30
|
+
type: z.literal(SignInIdentifier.Phone),
|
|
31
|
+
value: z.string().regex(phoneRegEx),
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
28
34
|
export const socialAuthorizationUrlPayloadGuard = z.object({
|
|
29
35
|
state: z.string(),
|
|
30
36
|
redirectUri: z.string(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ConnectorMetadata, type GoogleOneTapConfig } from '@logto/connector-kit';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { type CustomProfileField, type SignInExperience } from '../db-entries/index.js';
|
|
4
|
-
import { CaptchaType } from '../foundations/jsonb-types/index.js';
|
|
4
|
+
import { CaptchaType, RecaptchaEnterpriseMode } from '../foundations/jsonb-types/index.js';
|
|
5
5
|
import { type SsoConnectorMetadata } from './sso-connector.js';
|
|
6
6
|
type ForgotPassword = {
|
|
7
7
|
phone: boolean;
|
|
@@ -32,6 +32,8 @@ export type FullSignInExperience = Omit<SignInExperience, 'forgotPasswordMethods
|
|
|
32
32
|
captchaConfig?: {
|
|
33
33
|
type: CaptchaType;
|
|
34
34
|
siteKey: string;
|
|
35
|
+
domain?: string;
|
|
36
|
+
mode?: RecaptchaEnterpriseMode;
|
|
35
37
|
};
|
|
36
38
|
customProfileFields?: Readonly<CustomProfileField[]>;
|
|
37
39
|
};
|
|
@@ -674,12 +676,18 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
674
676
|
captchaConfig: z.ZodOptional<z.ZodObject<{
|
|
675
677
|
type: z.ZodNativeEnum<typeof CaptchaType>;
|
|
676
678
|
siteKey: z.ZodString;
|
|
679
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
680
|
+
mode: z.ZodOptional<z.ZodNativeEnum<typeof RecaptchaEnterpriseMode>>;
|
|
677
681
|
}, "strip", z.ZodTypeAny, {
|
|
678
682
|
type: CaptchaType;
|
|
679
683
|
siteKey: string;
|
|
684
|
+
domain?: string | undefined;
|
|
685
|
+
mode?: RecaptchaEnterpriseMode | undefined;
|
|
680
686
|
}, {
|
|
681
687
|
type: CaptchaType;
|
|
682
688
|
siteKey: string;
|
|
689
|
+
domain?: string | undefined;
|
|
690
|
+
mode?: RecaptchaEnterpriseMode | undefined;
|
|
683
691
|
}>>;
|
|
684
692
|
customProfileFields: z.ZodArray<import("../index.js").Guard<CustomProfileField>, "many">;
|
|
685
693
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -873,6 +881,8 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
873
881
|
captchaConfig?: {
|
|
874
882
|
type: CaptchaType;
|
|
875
883
|
siteKey: string;
|
|
884
|
+
domain?: string | undefined;
|
|
885
|
+
mode?: RecaptchaEnterpriseMode | undefined;
|
|
876
886
|
} | undefined;
|
|
877
887
|
}, {
|
|
878
888
|
id: string;
|
|
@@ -1065,6 +1075,8 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
1065
1075
|
captchaConfig?: {
|
|
1066
1076
|
type: CaptchaType;
|
|
1067
1077
|
siteKey: string;
|
|
1078
|
+
domain?: string | undefined;
|
|
1079
|
+
mode?: RecaptchaEnterpriseMode | undefined;
|
|
1068
1080
|
} | undefined;
|
|
1069
1081
|
}>;
|
|
1070
1082
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { connectorMetadataGuard, googleOneTapConfigGuard, } from '@logto/connector-kit';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { CustomProfileFields, SignInExperiences, } from '../db-entries/index.js';
|
|
4
|
-
import { CaptchaType } from '../foundations/jsonb-types/index.js';
|
|
4
|
+
import { CaptchaType, RecaptchaEnterpriseMode } from '../foundations/jsonb-types/index.js';
|
|
5
5
|
import { ssoConnectorMetadataGuard } from './sso-connector.js';
|
|
6
6
|
export const fullSignInExperienceGuard = SignInExperiences.guard
|
|
7
7
|
.omit({ forgotPasswordMethods: true })
|
|
@@ -25,6 +25,8 @@ export const fullSignInExperienceGuard = SignInExperiences.guard
|
|
|
25
25
|
.object({
|
|
26
26
|
type: z.nativeEnum(CaptchaType),
|
|
27
27
|
siteKey: z.string(),
|
|
28
|
+
domain: z.string().optional(),
|
|
29
|
+
mode: z.nativeEnum(RecaptchaEnterpriseMode).optional(),
|
|
28
30
|
})
|
|
29
31
|
.optional(),
|
|
30
32
|
customProfileFields: CustomProfileFields.guard.array(),
|
package/lib/types/user.d.ts
CHANGED
|
@@ -316,6 +316,7 @@ export type UserProfileResponse = z.infer<typeof userProfileResponseGuard>;
|
|
|
316
316
|
export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
|
|
317
317
|
id: z.ZodString;
|
|
318
318
|
createdAt: z.ZodString;
|
|
319
|
+
lastUsedAt: z.ZodOptional<z.ZodString>;
|
|
319
320
|
type: z.ZodNativeEnum<typeof MfaFactor>;
|
|
320
321
|
agent: z.ZodOptional<z.ZodString>;
|
|
321
322
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -325,6 +326,7 @@ export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
|
|
|
325
326
|
id: string;
|
|
326
327
|
createdAt: string;
|
|
327
328
|
name?: string | undefined;
|
|
329
|
+
lastUsedAt?: string | undefined;
|
|
328
330
|
agent?: string | undefined;
|
|
329
331
|
remainCodes?: number | undefined;
|
|
330
332
|
}, {
|
|
@@ -332,6 +334,7 @@ export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
|
|
|
332
334
|
id: string;
|
|
333
335
|
createdAt: string;
|
|
334
336
|
name?: string | undefined;
|
|
337
|
+
lastUsedAt?: string | undefined;
|
|
335
338
|
agent?: string | undefined;
|
|
336
339
|
remainCodes?: number | undefined;
|
|
337
340
|
}>, "many">;
|
package/lib/types/user.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@withtyped/server": "^0.14.0",
|
|
67
67
|
"nanoid": "^5.0.9",
|
|
68
|
-
"@logto/
|
|
68
|
+
"@logto/connector-kit": "^4.7.0",
|
|
69
69
|
"@logto/core-kit": "^2.6.1",
|
|
70
|
-
"@logto/
|
|
71
|
-
"@logto/phrases": "^1.22.0",
|
|
70
|
+
"@logto/phrases": "^1.24.0",
|
|
72
71
|
"@logto/phrases-experience": "^1.12.0",
|
|
72
|
+
"@logto/language-kit": "^1.2.0",
|
|
73
73
|
"@logto/shared": "^3.3.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
package/tables/_after_all.sql
CHANGED
|
@@ -13,7 +13,7 @@ revoke all privileges
|
|
|
13
13
|
from logto_tenant_${database};
|
|
14
14
|
|
|
15
15
|
-- Allow limited select to perform the RLS policy query in `after_each` (using select ... from tenants ...)
|
|
16
|
-
grant select (id, db_user, is_suspended)
|
|
16
|
+
grant select (id, db_user, is_suspended, tag)
|
|
17
17
|
on table tenants
|
|
18
18
|
to logto_tenant_${database};
|
|
19
19
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** This table is used to store aggregated data of daily active users for each tenant. A daily job summarizes data from the daily active users table and inserts it into this table, or removes expired data. Therefore, we should not directly manipulate this table, except for "read" operations. */
|
|
2
|
+
create table aggregated_daily_active_users (
|
|
3
|
+
tenant_id varchar(21) not null,
|
|
4
|
+
activity_date date not null,
|
|
5
|
+
user_id varchar(21) not null,
|
|
6
|
+
activity_count integer not null,
|
|
7
|
+
primary key (tenant_id, activity_date, user_id)
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
-- Index for billing cycle range queries
|
|
11
|
+
create index aggregated_daily_active_users__tenant_date
|
|
12
|
+
on aggregated_daily_active_users (tenant_id, activity_date);
|
|
13
|
+
|
|
14
|
+
-- Index for tenant-specific user activity queries
|
|
15
|
+
create index aggregated_daily_active_users__tenant_user_date
|
|
16
|
+
on aggregated_daily_active_users (tenant_id, user_id, activity_date desc);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
create table daily_active_users (
|
|
2
2
|
id varchar(21) not null,
|
|
3
|
-
tenant_id varchar(21) not null
|
|
4
|
-
references tenants (id) on update cascade on delete cascade,
|
|
3
|
+
tenant_id varchar(21) not null,
|
|
5
4
|
user_id varchar(21) not null,
|
|
6
5
|
date timestamptz not null default (now()),
|
|
7
6
|
primary key (id),
|
|
@@ -9,8 +8,14 @@ create table daily_active_users (
|
|
|
9
8
|
unique (user_id, date)
|
|
10
9
|
);
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
-- Optimized index for aggregation queries with better write performance
|
|
12
|
+
create index daily_active_users__tenant_date_user
|
|
13
|
+
on daily_active_users (tenant_id, date, user_id);
|
|
14
|
+
|
|
15
|
+
-- BRIN index for time-series date range queries
|
|
16
|
+
-- Optimized for sequential data insertion and range scans (date >= ?)
|
|
17
|
+
create index daily_active_users__date_brin
|
|
18
|
+
on daily_active_users using brin (date);
|
|
14
19
|
|
|
15
20
|
create index daily_active_users__date
|
|
16
21
|
on daily_active_users (tenant_id, date);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
create table daily_token_usage (
|
|
2
2
|
id varchar(21) not null,
|
|
3
|
-
tenant_id varchar(21) not null
|
|
4
|
-
references tenants (id) on update cascade on delete cascade,
|
|
3
|
+
tenant_id varchar(21) not null,
|
|
5
4
|
usage bigint not null default(0),
|
|
5
|
+
user_token_usage bigint not null default(0),
|
|
6
|
+
m2m_token_usage bigint not null default(0),
|
|
6
7
|
date timestamptz not null,
|
|
7
8
|
primary key (id)
|
|
8
9
|
);
|
package/tables/logs.sql
CHANGED
|
@@ -10,9 +10,6 @@ create table logs (
|
|
|
10
10
|
primary key (id)
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
create index logs__id
|
|
14
|
-
on logs (tenant_id, id);
|
|
15
|
-
|
|
16
13
|
create index logs__key
|
|
17
14
|
on logs (tenant_id, key);
|
|
18
15
|
|
|
@@ -24,3 +21,6 @@ create index logs__application_id
|
|
|
24
21
|
|
|
25
22
|
create index logs__hook_id
|
|
26
23
|
on logs (tenant_id, (payload->>'hookId'));
|
|
24
|
+
|
|
25
|
+
create index logs__created_at_id
|
|
26
|
+
on logs (tenant_id, created_at, id);
|
|
@@ -20,6 +20,9 @@ create table organization_roles (
|
|
|
20
20
|
create index organization_roles__id
|
|
21
21
|
on organization_roles (tenant_id, id);
|
|
22
22
|
|
|
23
|
+
create index organization_roles__type
|
|
24
|
+
on organization_roles (tenant_id, type);
|
|
25
|
+
|
|
23
26
|
create function check_organization_role_type(role_id varchar(21), target_type role_type) returns boolean as
|
|
24
27
|
$$ begin
|
|
25
28
|
return (select type from organization_roles where id = role_id) = target_type;
|
|
@@ -12,7 +12,7 @@ create table saml_application_sessions (
|
|
|
12
12
|
/** The identifier of the OIDC auth request state. */
|
|
13
13
|
oidc_state varchar(32),
|
|
14
14
|
/** The relay state of the SAML auth request. */
|
|
15
|
-
relay_state varchar(
|
|
15
|
+
relay_state varchar(512),
|
|
16
16
|
/** The raw request of the SAML auth request. */
|
|
17
17
|
raw_auth_request text not null,
|
|
18
18
|
created_at timestamptz not null default(now()),
|