@logto/schemas 1.2.3 → 1.3.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.3.0-1683292832-update-hooks.ts +105 -0
- package/alterations-js/1.3.0-1683292832-update-hooks.d.ts +3 -0
- package/alterations-js/1.3.0-1683292832-update-hooks.js +73 -0
- package/lib/db-entries/application.js +3 -3
- package/lib/db-entries/applications-role.js +3 -3
- package/lib/db-entries/connector.js +2 -2
- package/lib/db-entries/custom-phrase.js +2 -2
- package/lib/db-entries/hook.d.ts +11 -3
- package/lib/db-entries/hook.js +20 -4
- package/lib/db-entries/log.js +2 -2
- package/lib/db-entries/logto-config.js +1 -1
- package/lib/db-entries/oidc-model-instance.js +2 -2
- package/lib/db-entries/passcode.js +3 -3
- package/lib/db-entries/resource.js +3 -3
- package/lib/db-entries/role.js +3 -3
- package/lib/db-entries/roles-scope.js +3 -3
- package/lib/db-entries/scope.js +4 -4
- package/lib/db-entries/service-log.js +2 -2
- package/lib/db-entries/sign-in-experience.js +1 -1
- package/lib/db-entries/system.js +1 -1
- package/lib/db-entries/user.js +1 -1
- package/lib/db-entries/users-role.js +3 -3
- package/lib/db-entries/verification-status.js +2 -2
- package/lib/foundations/jsonb-types.d.ts +19 -8
- package/lib/foundations/jsonb-types.js +11 -0
- package/lib/types/connector.d.ts +2984 -8
- package/lib/types/connector.js +22 -0
- package/lib/types/dashboard.d.ts +116 -0
- package/lib/types/dashboard.js +18 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/scope.d.ts +40 -4
- package/lib/types/scope.js +4 -1
- package/lib/types/user.d.ts +129 -5
- package/lib/types/user.js +6 -0
- package/package.json +1 -1
- package/tables/hooks.sql +13 -11
package/lib/types/connector.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
+
import { ConnectorType, connectorMetadataGuard } from '@logto/connector-kit';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Connectors } from '../db-entries/index.js';
|
|
1
4
|
export { ConnectorType, ConnectorPlatform } from '@logto/connector-kit';
|
|
5
|
+
export const connectorResponseGuard = Connectors.guard
|
|
6
|
+
.pick({
|
|
7
|
+
id: true,
|
|
8
|
+
syncProfile: true,
|
|
9
|
+
config: true,
|
|
10
|
+
metadata: true,
|
|
11
|
+
connectorId: true,
|
|
12
|
+
})
|
|
13
|
+
.merge(connectorMetadataGuard)
|
|
14
|
+
.merge(z.object({
|
|
15
|
+
type: z.nativeEnum(ConnectorType),
|
|
16
|
+
isDemo: z.boolean().optional(),
|
|
17
|
+
}));
|
|
18
|
+
export const connectorFactoryResponseGuard = z
|
|
19
|
+
.object({
|
|
20
|
+
type: z.nativeEnum(ConnectorType),
|
|
21
|
+
isDemo: z.boolean().optional(),
|
|
22
|
+
})
|
|
23
|
+
.merge(connectorMetadataGuard);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export declare const getNewUsersResponseGuard: import("zod").ZodObject<{
|
|
2
|
+
today: import("zod").ZodObject<{
|
|
3
|
+
count: import("zod").ZodNumber;
|
|
4
|
+
delta: import("zod").ZodNumber;
|
|
5
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
6
|
+
count: number;
|
|
7
|
+
delta: number;
|
|
8
|
+
}, {
|
|
9
|
+
count: number;
|
|
10
|
+
delta: number;
|
|
11
|
+
}>;
|
|
12
|
+
last7Days: import("zod").ZodObject<{
|
|
13
|
+
count: import("zod").ZodNumber;
|
|
14
|
+
delta: import("zod").ZodNumber;
|
|
15
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
16
|
+
count: number;
|
|
17
|
+
delta: number;
|
|
18
|
+
}, {
|
|
19
|
+
count: number;
|
|
20
|
+
delta: number;
|
|
21
|
+
}>;
|
|
22
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
23
|
+
today: {
|
|
24
|
+
count: number;
|
|
25
|
+
delta: number;
|
|
26
|
+
};
|
|
27
|
+
last7Days: {
|
|
28
|
+
count: number;
|
|
29
|
+
delta: number;
|
|
30
|
+
};
|
|
31
|
+
}, {
|
|
32
|
+
today: {
|
|
33
|
+
count: number;
|
|
34
|
+
delta: number;
|
|
35
|
+
};
|
|
36
|
+
last7Days: {
|
|
37
|
+
count: number;
|
|
38
|
+
delta: number;
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export declare const getActiveUsersResponseGuard: import("zod").ZodObject<{
|
|
42
|
+
dauCurve: import("zod").ZodArray<import("zod").ZodObject<{
|
|
43
|
+
date: import("zod").ZodString;
|
|
44
|
+
count: import("zod").ZodNumber;
|
|
45
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
46
|
+
date: string;
|
|
47
|
+
count: number;
|
|
48
|
+
}, {
|
|
49
|
+
date: string;
|
|
50
|
+
count: number;
|
|
51
|
+
}>, "many">;
|
|
52
|
+
dau: import("zod").ZodObject<{
|
|
53
|
+
count: import("zod").ZodNumber;
|
|
54
|
+
delta: import("zod").ZodNumber;
|
|
55
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
56
|
+
count: number;
|
|
57
|
+
delta: number;
|
|
58
|
+
}, {
|
|
59
|
+
count: number;
|
|
60
|
+
delta: number;
|
|
61
|
+
}>;
|
|
62
|
+
wau: import("zod").ZodObject<{
|
|
63
|
+
count: import("zod").ZodNumber;
|
|
64
|
+
delta: import("zod").ZodNumber;
|
|
65
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
66
|
+
count: number;
|
|
67
|
+
delta: number;
|
|
68
|
+
}, {
|
|
69
|
+
count: number;
|
|
70
|
+
delta: number;
|
|
71
|
+
}>;
|
|
72
|
+
mau: import("zod").ZodObject<{
|
|
73
|
+
count: import("zod").ZodNumber;
|
|
74
|
+
delta: import("zod").ZodNumber;
|
|
75
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
76
|
+
count: number;
|
|
77
|
+
delta: number;
|
|
78
|
+
}, {
|
|
79
|
+
count: number;
|
|
80
|
+
delta: number;
|
|
81
|
+
}>;
|
|
82
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
83
|
+
dauCurve: {
|
|
84
|
+
date: string;
|
|
85
|
+
count: number;
|
|
86
|
+
}[];
|
|
87
|
+
dau: {
|
|
88
|
+
count: number;
|
|
89
|
+
delta: number;
|
|
90
|
+
};
|
|
91
|
+
wau: {
|
|
92
|
+
count: number;
|
|
93
|
+
delta: number;
|
|
94
|
+
};
|
|
95
|
+
mau: {
|
|
96
|
+
count: number;
|
|
97
|
+
delta: number;
|
|
98
|
+
};
|
|
99
|
+
}, {
|
|
100
|
+
dauCurve: {
|
|
101
|
+
date: string;
|
|
102
|
+
count: number;
|
|
103
|
+
}[];
|
|
104
|
+
dau: {
|
|
105
|
+
count: number;
|
|
106
|
+
delta: number;
|
|
107
|
+
};
|
|
108
|
+
wau: {
|
|
109
|
+
count: number;
|
|
110
|
+
delta: number;
|
|
111
|
+
};
|
|
112
|
+
mau: {
|
|
113
|
+
count: number;
|
|
114
|
+
delta: number;
|
|
115
|
+
};
|
|
116
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { number, object, array, string } from 'zod';
|
|
2
|
+
const dashboardUsersDataGuard = object({
|
|
3
|
+
count: number(),
|
|
4
|
+
delta: number(),
|
|
5
|
+
});
|
|
6
|
+
export const getNewUsersResponseGuard = object({
|
|
7
|
+
today: dashboardUsersDataGuard,
|
|
8
|
+
last7Days: dashboardUsersDataGuard,
|
|
9
|
+
});
|
|
10
|
+
export const getActiveUsersResponseGuard = object({
|
|
11
|
+
dauCurve: array(object({
|
|
12
|
+
date: string(),
|
|
13
|
+
count: number(),
|
|
14
|
+
})),
|
|
15
|
+
dau: dashboardUsersDataGuard,
|
|
16
|
+
wau: dashboardUsersDataGuard,
|
|
17
|
+
mau: dashboardUsersDataGuard,
|
|
18
|
+
});
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
package/lib/types/scope.d.ts
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type z } from 'zod';
|
|
2
|
+
export declare const scopeResponseGuard: z.ZodObject<z.extendShape<{
|
|
3
|
+
tenantId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
4
|
+
id: z.ZodType<string, z.ZodTypeDef, string>;
|
|
5
|
+
resourceId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
6
|
+
name: z.ZodType<string, z.ZodTypeDef, string>;
|
|
7
|
+
description: z.ZodType<string, z.ZodTypeDef, string>;
|
|
8
|
+
createdAt: z.ZodType<number, z.ZodTypeDef, number>;
|
|
9
|
+
}, {
|
|
10
|
+
resource: import("../index.js").Guard<import("../db-entries/resource.js").Resource>;
|
|
11
|
+
}>, "strip", z.ZodTypeAny, {
|
|
12
|
+
tenantId: string;
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
resource: {
|
|
18
|
+
tenantId: string;
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
indicator: string;
|
|
22
|
+
accessTokenTtl: number;
|
|
23
|
+
};
|
|
24
|
+
resourceId: string;
|
|
25
|
+
}, {
|
|
26
|
+
tenantId: string;
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
resource: {
|
|
32
|
+
tenantId: string;
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
indicator: string;
|
|
36
|
+
accessTokenTtl: number;
|
|
37
|
+
};
|
|
38
|
+
resourceId: string;
|
|
39
|
+
}>;
|
|
40
|
+
export type ScopeResponse = z.infer<typeof scopeResponseGuard>;
|
package/lib/types/scope.js
CHANGED
package/lib/types/user.d.ts
CHANGED
|
@@ -1,9 +1,133 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
export declare const userInfoSelectFields: readonly ["id", "username", "primaryEmail", "primaryPhone", "name", "avatar", "customData", "identities", "lastSignInAt", "createdAt", "applicationId", "isSuspended"];
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export declare const userInfoGuard: z.ZodObject<Pick<{
|
|
4
|
+
tenantId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
5
|
+
id: z.ZodType<string, z.ZodTypeDef, string>;
|
|
6
|
+
username: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
7
|
+
primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
8
|
+
primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
9
|
+
passwordEncrypted: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
10
|
+
passwordEncryptionMethod: z.ZodType<import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null, z.ZodTypeDef, import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null>;
|
|
11
|
+
name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
12
|
+
avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
13
|
+
applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
14
|
+
identities: z.ZodType<Record<string, {
|
|
15
|
+
details?: {} | undefined;
|
|
16
|
+
userId: string;
|
|
17
|
+
}>, z.ZodTypeDef, Record<string, {
|
|
18
|
+
details?: {} | undefined;
|
|
19
|
+
userId: string;
|
|
20
|
+
}>>;
|
|
21
|
+
customData: z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>;
|
|
22
|
+
isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
|
|
23
|
+
lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
|
|
24
|
+
createdAt: z.ZodType<number, z.ZodTypeDef, number>;
|
|
25
|
+
}, "tenantId" | "username" | "applicationId" | "id" | "name" | "createdAt" | "primaryEmail" | "primaryPhone" | "passwordEncrypted" | "passwordEncryptionMethod" | "avatar" | "identities" | "customData" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
|
|
26
|
+
tenantId: string;
|
|
27
|
+
username: string | null;
|
|
28
|
+
applicationId: string | null;
|
|
29
|
+
id: string;
|
|
30
|
+
name: string | null;
|
|
31
|
+
createdAt: number;
|
|
32
|
+
primaryEmail: string | null;
|
|
33
|
+
primaryPhone: string | null;
|
|
34
|
+
passwordEncrypted: string | null;
|
|
35
|
+
passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
|
|
36
|
+
avatar: string | null;
|
|
37
|
+
identities: Record<string, {
|
|
38
|
+
details?: {} | undefined;
|
|
39
|
+
userId: string;
|
|
40
|
+
}>;
|
|
41
|
+
customData: import("@withtyped/server").JsonObject;
|
|
42
|
+
isSuspended: boolean;
|
|
43
|
+
lastSignInAt: number | null;
|
|
44
|
+
}, {
|
|
45
|
+
tenantId: string;
|
|
46
|
+
username: string | null;
|
|
47
|
+
applicationId: string | null;
|
|
48
|
+
id: string;
|
|
49
|
+
name: string | null;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
primaryEmail: string | null;
|
|
52
|
+
primaryPhone: string | null;
|
|
53
|
+
passwordEncrypted: string | null;
|
|
54
|
+
passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
|
|
55
|
+
avatar: string | null;
|
|
56
|
+
identities: Record<string, {
|
|
57
|
+
details?: {} | undefined;
|
|
58
|
+
userId: string;
|
|
59
|
+
}>;
|
|
60
|
+
customData: import("@withtyped/server").JsonObject;
|
|
61
|
+
isSuspended: boolean;
|
|
62
|
+
lastSignInAt: number | null;
|
|
63
|
+
}>;
|
|
64
|
+
export type UserInfo = z.infer<typeof userInfoGuard>;
|
|
65
|
+
export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
|
|
66
|
+
tenantId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
67
|
+
id: z.ZodType<string, z.ZodTypeDef, string>;
|
|
68
|
+
username: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
69
|
+
primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
70
|
+
primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
71
|
+
passwordEncrypted: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
72
|
+
passwordEncryptionMethod: z.ZodType<import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null, z.ZodTypeDef, import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null>;
|
|
73
|
+
name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
74
|
+
avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
75
|
+
applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
76
|
+
identities: z.ZodType<Record<string, {
|
|
77
|
+
details?: {} | undefined;
|
|
78
|
+
userId: string;
|
|
79
|
+
}>, z.ZodTypeDef, Record<string, {
|
|
80
|
+
details?: {} | undefined;
|
|
81
|
+
userId: string;
|
|
82
|
+
}>>;
|
|
83
|
+
customData: z.ZodType<import("@withtyped/server").JsonObject, z.ZodTypeDef, import("@withtyped/server").JsonObject>;
|
|
84
|
+
isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
|
|
85
|
+
lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
|
|
86
|
+
createdAt: z.ZodType<number, z.ZodTypeDef, number>;
|
|
87
|
+
}, "tenantId" | "username" | "applicationId" | "id" | "name" | "createdAt" | "primaryEmail" | "primaryPhone" | "passwordEncrypted" | "passwordEncryptionMethod" | "avatar" | "identities" | "customData" | "isSuspended" | "lastSignInAt">, {
|
|
88
|
+
hasPassword: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
}>, "strip", z.ZodTypeAny, {
|
|
90
|
+
hasPassword?: boolean | undefined;
|
|
91
|
+
tenantId: string;
|
|
92
|
+
username: string | null;
|
|
93
|
+
applicationId: string | null;
|
|
94
|
+
id: string;
|
|
95
|
+
name: string | null;
|
|
96
|
+
createdAt: number;
|
|
97
|
+
primaryEmail: string | null;
|
|
98
|
+
primaryPhone: string | null;
|
|
99
|
+
passwordEncrypted: string | null;
|
|
100
|
+
passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
|
|
101
|
+
avatar: string | null;
|
|
102
|
+
identities: Record<string, {
|
|
103
|
+
details?: {} | undefined;
|
|
104
|
+
userId: string;
|
|
105
|
+
}>;
|
|
106
|
+
customData: import("@withtyped/server").JsonObject;
|
|
107
|
+
isSuspended: boolean;
|
|
108
|
+
lastSignInAt: number | null;
|
|
109
|
+
}, {
|
|
110
|
+
hasPassword?: boolean | undefined;
|
|
111
|
+
tenantId: string;
|
|
112
|
+
username: string | null;
|
|
113
|
+
applicationId: string | null;
|
|
114
|
+
id: string;
|
|
115
|
+
name: string | null;
|
|
116
|
+
createdAt: number;
|
|
117
|
+
primaryEmail: string | null;
|
|
118
|
+
primaryPhone: string | null;
|
|
119
|
+
passwordEncrypted: string | null;
|
|
120
|
+
passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
|
|
121
|
+
avatar: string | null;
|
|
122
|
+
identities: Record<string, {
|
|
123
|
+
details?: {} | undefined;
|
|
124
|
+
userId: string;
|
|
125
|
+
}>;
|
|
126
|
+
customData: import("@withtyped/server").JsonObject;
|
|
127
|
+
isSuspended: boolean;
|
|
128
|
+
lastSignInAt: number | null;
|
|
129
|
+
}>;
|
|
130
|
+
export type UserProfileResponse = z.infer<typeof userProfileResponseGuard>;
|
|
7
131
|
/** Internal read-only roles for user tenants. */
|
|
8
132
|
export declare enum InternalRole {
|
|
9
133
|
/**
|
package/lib/types/user.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Users } from '../db-entries/index.js';
|
|
1
3
|
export const userInfoSelectFields = Object.freeze([
|
|
2
4
|
'id',
|
|
3
5
|
'username',
|
|
@@ -12,6 +14,10 @@ export const userInfoSelectFields = Object.freeze([
|
|
|
12
14
|
'applicationId',
|
|
13
15
|
'isSuspended',
|
|
14
16
|
]);
|
|
17
|
+
export const userInfoGuard = Users.guard.pick(Object.fromEntries(userInfoSelectFields.map((key) => [key, true])));
|
|
18
|
+
export const userProfileResponseGuard = userInfoGuard.extend({
|
|
19
|
+
hasPassword: z.boolean().optional(),
|
|
20
|
+
});
|
|
15
21
|
/** Internal read-only roles for user tenants. */
|
|
16
22
|
export var InternalRole;
|
|
17
23
|
(function (InternalRole) {
|
package/package.json
CHANGED
package/tables/hooks.sql
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
create table hooks (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
2
|
+
tenant_id varchar(21) not null
|
|
3
|
+
references tenants (id) on update cascade on delete cascade,
|
|
4
|
+
id varchar(21) not null,
|
|
5
|
+
name varchar(256) not null default '',
|
|
6
|
+
event varchar(128) /* @use HookEvent */,
|
|
7
|
+
events jsonb /* @use HookEvents */ not null default '[]'::jsonb,
|
|
8
|
+
config jsonb /* @use HookConfig */ not null,
|
|
9
|
+
signing_key varchar(64) not null default '',
|
|
10
|
+
enabled boolean not null default true,
|
|
11
|
+
created_at timestamptz not null default(now()),
|
|
12
|
+
primary key (id)
|
|
13
|
+
);
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
create index hooks__event on hooks (tenant_id, event);
|
|
15
|
+
create index hooks__id on hooks (tenant_id, id);
|