@smartcrab/contracts-management 0.1.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/LICENSE +202 -0
- package/dist/api-keys.d.ts +251 -0
- package/dist/api-keys.js +78 -0
- package/dist/audit-events.d.ts +94 -0
- package/dist/audit-events.js +45 -0
- package/dist/billing.d.ts +30 -0
- package/dist/billing.js +30 -0
- package/dist/clients.d.ts +328 -0
- package/dist/clients.js +141 -0
- package/dist/common.d.ts +95 -0
- package/dist/common.js +99 -0
- package/dist/connections.d.ts +201 -0
- package/dist/connections.js +107 -0
- package/dist/domains.d.ts +167 -0
- package/dist/domains.js +74 -0
- package/dist/environments.d.ts +194 -0
- package/dist/environments.js +101 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +27 -0
- package/dist/primitives.d.ts +49 -0
- package/dist/primitives.js +56 -0
- package/dist/projects.d.ts +78 -0
- package/dist/projects.js +49 -0
- package/dist/rbac.d.ts +222 -0
- package/dist/rbac.js +226 -0
- package/dist/usage.d.ts +72 -0
- package/dist/usage.js +52 -0
- package/dist/user-jobs.d.ts +253 -0
- package/dist/user-jobs.js +95 -0
- package/dist/user-subresources.d.ts +161 -0
- package/dist/user-subresources.js +85 -0
- package/dist/users.d.ts +193 -0
- package/dist/users.js +112 -0
- package/dist/webhooks.d.ts +306 -0
- package/dist/webhooks.js +134 -0
- package/dist/workspaces.d.ts +172 -0
- package/dist/workspaces.js +77 -0
- package/package.json +42 -0
- package/src/api-keys.test.ts +86 -0
- package/src/api-keys.ts +97 -0
- package/src/audit-events.test.ts +44 -0
- package/src/audit-events.ts +57 -0
- package/src/billing.test.ts +57 -0
- package/src/billing.ts +46 -0
- package/src/clients.test.ts +169 -0
- package/src/clients.ts +182 -0
- package/src/common.test.ts +102 -0
- package/src/common.ts +127 -0
- package/src/connections.test.ts +65 -0
- package/src/connections.ts +134 -0
- package/src/domains.test.ts +48 -0
- package/src/domains.ts +104 -0
- package/src/environments.test.ts +67 -0
- package/src/environments.ts +133 -0
- package/src/index.ts +27 -0
- package/src/primitives.ts +100 -0
- package/src/projects.test.ts +49 -0
- package/src/projects.ts +72 -0
- package/src/rbac.test.ts +148 -0
- package/src/rbac.ts +250 -0
- package/src/secret-fields.test.ts +84 -0
- package/src/usage.test.ts +57 -0
- package/src/usage.ts +66 -0
- package/src/user-jobs.test.ts +86 -0
- package/src/user-jobs.ts +120 -0
- package/src/user-subresources.test.ts +115 -0
- package/src/user-subresources.ts +128 -0
- package/src/users.test.ts +91 -0
- package/src/users.ts +149 -0
- package/src/webhooks.test.ts +187 -0
- package/src/webhooks.ts +182 -0
- package/src/workspaces.test.ts +127 -0
- package/src/workspaces.ts +106 -0
package/dist/users.d.ts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* `users` (design.md §12.1) projected with `user_emails` (§12.2)'s decrypted
|
|
4
|
+
* display value. Excluded: `auth_partition_id` (assignment's forbidden-field
|
|
5
|
+
* list — internal Auth D1 co-location routing, §12), `security_version`
|
|
6
|
+
* (internal invalidation counter, excluded by the same rationale
|
|
7
|
+
* `@smartcrab/contracts-public`'s `/v1/me` uses), `primary_email_id`
|
|
8
|
+
* (internal FK, superseded here by the resolved `email` field itself), and
|
|
9
|
+
* `deleted_at` (status `pending_deletion` already reports this, matching
|
|
10
|
+
* `@smartcrab/contracts-public`'s `meUserSchema`).
|
|
11
|
+
*
|
|
12
|
+
* `email` is the plaintext address: `user_emails.email_ciphertext` (the
|
|
13
|
+
* forbidden column) is decrypted server-side before this projection is
|
|
14
|
+
* built, exactly as `/v1/me` does for the same underlying table.
|
|
15
|
+
* `metadata` (from `metadata_json`) IS exposed here — unlike `/v1/me`, this
|
|
16
|
+
* is the admin-facing Management API, and arbitrary app-defined user
|
|
17
|
+
* metadata is a normal, non-secret admin/dashboard field (design.md does not
|
|
18
|
+
* name it a secret column).
|
|
19
|
+
*/
|
|
20
|
+
export declare const USER_STATUSES: readonly ["active", "blocked", "pending_deletion"];
|
|
21
|
+
export declare const userStatusSchema: z.ZodEnum<{
|
|
22
|
+
active: "active";
|
|
23
|
+
blocked: "blocked";
|
|
24
|
+
pending_deletion: "pending_deletion";
|
|
25
|
+
}>;
|
|
26
|
+
export type UserStatus = (typeof USER_STATUSES)[number];
|
|
27
|
+
export declare const userSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
environment_id: z.ZodString;
|
|
30
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
31
|
+
email_verified: z.ZodBoolean;
|
|
32
|
+
name: z.ZodNullable<z.ZodString>;
|
|
33
|
+
avatar_url: z.ZodNullable<z.ZodURL>;
|
|
34
|
+
locale: z.ZodNullable<z.ZodString>;
|
|
35
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
36
|
+
status: z.ZodEnum<{
|
|
37
|
+
active: "active";
|
|
38
|
+
blocked: "blocked";
|
|
39
|
+
pending_deletion: "pending_deletion";
|
|
40
|
+
}>;
|
|
41
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
42
|
+
created_at: z.ZodISODateTime;
|
|
43
|
+
updated_at: z.ZodISODateTime;
|
|
44
|
+
last_login_at: z.ZodNullable<z.ZodISODateTime>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export type User = z.infer<typeof userSchema>;
|
|
47
|
+
export declare const userListQuerySchema: z.ZodObject<{
|
|
48
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
49
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
50
|
+
environment_id: z.ZodString;
|
|
51
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
active: "active";
|
|
53
|
+
blocked: "blocked";
|
|
54
|
+
pending_deletion: "pending_deletion";
|
|
55
|
+
}>>;
|
|
56
|
+
search: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
export type UserListQuery = z.infer<typeof userListQuerySchema>;
|
|
59
|
+
export declare const userListResponseSchema: z.ZodObject<{
|
|
60
|
+
items: z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
environment_id: z.ZodString;
|
|
63
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
64
|
+
email_verified: z.ZodBoolean;
|
|
65
|
+
name: z.ZodNullable<z.ZodString>;
|
|
66
|
+
avatar_url: z.ZodNullable<z.ZodURL>;
|
|
67
|
+
locale: z.ZodNullable<z.ZodString>;
|
|
68
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
69
|
+
status: z.ZodEnum<{
|
|
70
|
+
active: "active";
|
|
71
|
+
blocked: "blocked";
|
|
72
|
+
pending_deletion: "pending_deletion";
|
|
73
|
+
}>;
|
|
74
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
75
|
+
created_at: z.ZodISODateTime;
|
|
76
|
+
updated_at: z.ZodISODateTime;
|
|
77
|
+
last_login_at: z.ZodNullable<z.ZodISODateTime>;
|
|
78
|
+
}, z.core.$strict>>;
|
|
79
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
export type UserListResponse = z.infer<typeof userListResponseSchema>;
|
|
82
|
+
export declare const userCreateRequestSchema: z.ZodObject<{
|
|
83
|
+
environment_id: z.ZodString;
|
|
84
|
+
email: z.ZodEmail;
|
|
85
|
+
email_verified: z.ZodDefault<z.ZodBoolean>;
|
|
86
|
+
name: z.ZodOptional<z.ZodString>;
|
|
87
|
+
avatar_url: z.ZodOptional<z.ZodURL>;
|
|
88
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
89
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
90
|
+
metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
export type UserCreateRequest = z.infer<typeof userCreateRequestSchema>;
|
|
93
|
+
export declare const userCreateResponseSchema: z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
environment_id: z.ZodString;
|
|
96
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
97
|
+
email_verified: z.ZodBoolean;
|
|
98
|
+
name: z.ZodNullable<z.ZodString>;
|
|
99
|
+
avatar_url: z.ZodNullable<z.ZodURL>;
|
|
100
|
+
locale: z.ZodNullable<z.ZodString>;
|
|
101
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
102
|
+
status: z.ZodEnum<{
|
|
103
|
+
active: "active";
|
|
104
|
+
blocked: "blocked";
|
|
105
|
+
pending_deletion: "pending_deletion";
|
|
106
|
+
}>;
|
|
107
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
108
|
+
created_at: z.ZodISODateTime;
|
|
109
|
+
updated_at: z.ZodISODateTime;
|
|
110
|
+
last_login_at: z.ZodNullable<z.ZodISODateTime>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export type UserCreateResponse = z.infer<typeof userCreateResponseSchema>;
|
|
113
|
+
/** Environment context required by every individual-user route. */
|
|
114
|
+
export declare const userEnvironmentQuerySchema: z.ZodObject<{
|
|
115
|
+
environment_id: z.ZodString;
|
|
116
|
+
}, z.core.$strict>;
|
|
117
|
+
export type UserEnvironmentQuery = z.infer<typeof userEnvironmentQuerySchema>;
|
|
118
|
+
export declare const userGetResponseSchema: z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
environment_id: z.ZodString;
|
|
121
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
122
|
+
email_verified: z.ZodBoolean;
|
|
123
|
+
name: z.ZodNullable<z.ZodString>;
|
|
124
|
+
avatar_url: z.ZodNullable<z.ZodURL>;
|
|
125
|
+
locale: z.ZodNullable<z.ZodString>;
|
|
126
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
127
|
+
status: z.ZodEnum<{
|
|
128
|
+
active: "active";
|
|
129
|
+
blocked: "blocked";
|
|
130
|
+
pending_deletion: "pending_deletion";
|
|
131
|
+
}>;
|
|
132
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
133
|
+
created_at: z.ZodISODateTime;
|
|
134
|
+
updated_at: z.ZodISODateTime;
|
|
135
|
+
last_login_at: z.ZodNullable<z.ZodISODateTime>;
|
|
136
|
+
}, z.core.$strict>;
|
|
137
|
+
export type UserGetResponse = z.infer<typeof userGetResponseSchema>;
|
|
138
|
+
/**
|
|
139
|
+
* `email` is deliberately excluded, same as `@smartcrab/contracts-public`'s
|
|
140
|
+
* `meUpdateRequestSchema`: changing it is a dual-verification recovery flow
|
|
141
|
+
* (design.md §25), not a generic field patch — for admin-initiated changes,
|
|
142
|
+
* design.md §25 additionally requires Owner/Admin, a reason, and an audit
|
|
143
|
+
* record, which this generic `PATCH` does not carry.
|
|
144
|
+
*/
|
|
145
|
+
export declare const userUpdateRequestSchema: z.ZodObject<{
|
|
146
|
+
name: z.ZodOptional<z.ZodString>;
|
|
147
|
+
avatar_url: z.ZodOptional<z.ZodURL>;
|
|
148
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
149
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
150
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
export type UserUpdateRequest = z.infer<typeof userUpdateRequestSchema>;
|
|
153
|
+
export declare const userUpdateResponseSchema: z.ZodObject<{
|
|
154
|
+
id: z.ZodString;
|
|
155
|
+
environment_id: z.ZodString;
|
|
156
|
+
email: z.ZodNullable<z.ZodEmail>;
|
|
157
|
+
email_verified: z.ZodBoolean;
|
|
158
|
+
name: z.ZodNullable<z.ZodString>;
|
|
159
|
+
avatar_url: z.ZodNullable<z.ZodURL>;
|
|
160
|
+
locale: z.ZodNullable<z.ZodString>;
|
|
161
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
162
|
+
status: z.ZodEnum<{
|
|
163
|
+
active: "active";
|
|
164
|
+
blocked: "blocked";
|
|
165
|
+
pending_deletion: "pending_deletion";
|
|
166
|
+
}>;
|
|
167
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
168
|
+
created_at: z.ZodISODateTime;
|
|
169
|
+
updated_at: z.ZodISODateTime;
|
|
170
|
+
last_login_at: z.ZodNullable<z.ZodISODateTime>;
|
|
171
|
+
}, z.core.$strict>;
|
|
172
|
+
export type UserUpdateResponse = z.infer<typeof userUpdateResponseSchema>;
|
|
173
|
+
export declare const userDeleteResponseSchema: z.ZodObject<{
|
|
174
|
+
id: z.ZodString;
|
|
175
|
+
status: z.ZodLiteral<"pending_deletion">;
|
|
176
|
+
}, z.core.$strict>;
|
|
177
|
+
export type UserDeleteResponse = z.infer<typeof userDeleteResponseSchema>;
|
|
178
|
+
export declare const userBlockRequestSchema: z.ZodObject<{
|
|
179
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
180
|
+
}, z.core.$strict>;
|
|
181
|
+
export type UserBlockRequest = z.infer<typeof userBlockRequestSchema>;
|
|
182
|
+
export declare const userBlockResponseSchema: z.ZodObject<{
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
status: z.ZodLiteral<"blocked">;
|
|
185
|
+
}, z.core.$strict>;
|
|
186
|
+
export type UserBlockResponse = z.infer<typeof userBlockResponseSchema>;
|
|
187
|
+
export declare const userUnblockRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
188
|
+
export type UserUnblockRequest = z.infer<typeof userUnblockRequestSchema>;
|
|
189
|
+
export declare const userUnblockResponseSchema: z.ZodObject<{
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
status: z.ZodLiteral<"active">;
|
|
192
|
+
}, z.core.$strict>;
|
|
193
|
+
export type UserUnblockResponse = z.infer<typeof userUnblockResponseSchema>;
|
package/dist/users.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { cursorPageSchema, paginationQuerySchema } from "./common.js";
|
|
3
|
+
import { environmentIdSchema, userIdSchema } from "./primitives.js";
|
|
4
|
+
/**
|
|
5
|
+
* `users` (design.md §12.1) projected with `user_emails` (§12.2)'s decrypted
|
|
6
|
+
* display value. Excluded: `auth_partition_id` (assignment's forbidden-field
|
|
7
|
+
* list — internal Auth D1 co-location routing, §12), `security_version`
|
|
8
|
+
* (internal invalidation counter, excluded by the same rationale
|
|
9
|
+
* `@smartcrab/contracts-public`'s `/v1/me` uses), `primary_email_id`
|
|
10
|
+
* (internal FK, superseded here by the resolved `email` field itself), and
|
|
11
|
+
* `deleted_at` (status `pending_deletion` already reports this, matching
|
|
12
|
+
* `@smartcrab/contracts-public`'s `meUserSchema`).
|
|
13
|
+
*
|
|
14
|
+
* `email` is the plaintext address: `user_emails.email_ciphertext` (the
|
|
15
|
+
* forbidden column) is decrypted server-side before this projection is
|
|
16
|
+
* built, exactly as `/v1/me` does for the same underlying table.
|
|
17
|
+
* `metadata` (from `metadata_json`) IS exposed here — unlike `/v1/me`, this
|
|
18
|
+
* is the admin-facing Management API, and arbitrary app-defined user
|
|
19
|
+
* metadata is a normal, non-secret admin/dashboard field (design.md does not
|
|
20
|
+
* name it a secret column).
|
|
21
|
+
*/
|
|
22
|
+
export const USER_STATUSES = ["active", "blocked", "pending_deletion"];
|
|
23
|
+
export const userStatusSchema = z.enum(USER_STATUSES);
|
|
24
|
+
const userMetadataSchema = z.record(z.string(), z.unknown());
|
|
25
|
+
export const userSchema = z.strictObject({
|
|
26
|
+
id: userIdSchema,
|
|
27
|
+
environment_id: environmentIdSchema,
|
|
28
|
+
email: z.email().nullable(),
|
|
29
|
+
email_verified: z.boolean(),
|
|
30
|
+
name: z.string().nullable(),
|
|
31
|
+
avatar_url: z.url().nullable(),
|
|
32
|
+
locale: z.string().nullable(),
|
|
33
|
+
timezone: z.string().nullable(),
|
|
34
|
+
status: userStatusSchema,
|
|
35
|
+
metadata: userMetadataSchema,
|
|
36
|
+
created_at: z.iso.datetime(),
|
|
37
|
+
updated_at: z.iso.datetime(),
|
|
38
|
+
last_login_at: z.iso.datetime().nullable(),
|
|
39
|
+
});
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// GET /users
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
export const userListQuerySchema = paginationQuerySchema.extend({
|
|
44
|
+
environment_id: environmentIdSchema,
|
|
45
|
+
status: userStatusSchema.optional(),
|
|
46
|
+
/** Free-text search over name/email (matched server-side against the decrypted/normalized values). */
|
|
47
|
+
search: z.string().min(1).max(200).optional(),
|
|
48
|
+
});
|
|
49
|
+
export const userListResponseSchema = cursorPageSchema(userSchema);
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// POST /users
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
export const userCreateRequestSchema = z.strictObject({
|
|
54
|
+
environment_id: environmentIdSchema,
|
|
55
|
+
email: z.email(),
|
|
56
|
+
/** Admin-created users may be marked pre-verified (e.g. bulk import from a trusted source). */
|
|
57
|
+
email_verified: z.boolean().default(false),
|
|
58
|
+
name: z.string().min(1).max(200).optional(),
|
|
59
|
+
avatar_url: z.url().optional(),
|
|
60
|
+
locale: z.string().min(1).max(35).optional(),
|
|
61
|
+
timezone: z.string().min(1).max(64).optional(),
|
|
62
|
+
metadata: userMetadataSchema.default({}),
|
|
63
|
+
});
|
|
64
|
+
export const userCreateResponseSchema = userSchema;
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// GET /users/:userId
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/** Environment context required by every individual-user route. */
|
|
69
|
+
export const userEnvironmentQuerySchema = z.strictObject({
|
|
70
|
+
environment_id: environmentIdSchema,
|
|
71
|
+
});
|
|
72
|
+
export const userGetResponseSchema = userSchema;
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// PATCH /users/:userId
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
/**
|
|
77
|
+
* `email` is deliberately excluded, same as `@smartcrab/contracts-public`'s
|
|
78
|
+
* `meUpdateRequestSchema`: changing it is a dual-verification recovery flow
|
|
79
|
+
* (design.md §25), not a generic field patch — for admin-initiated changes,
|
|
80
|
+
* design.md §25 additionally requires Owner/Admin, a reason, and an audit
|
|
81
|
+
* record, which this generic `PATCH` does not carry.
|
|
82
|
+
*/
|
|
83
|
+
export const userUpdateRequestSchema = z.strictObject({
|
|
84
|
+
name: z.string().min(1).max(200).optional(),
|
|
85
|
+
avatar_url: z.url().optional(),
|
|
86
|
+
locale: z.string().min(1).max(35).optional(),
|
|
87
|
+
timezone: z.string().min(1).max(64).optional(),
|
|
88
|
+
metadata: userMetadataSchema.optional(),
|
|
89
|
+
});
|
|
90
|
+
export const userUpdateResponseSchema = userSchema;
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// DELETE /users/:userId (design.md §33.1: logical delete first)
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
export const userDeleteResponseSchema = z.strictObject({
|
|
95
|
+
id: userIdSchema,
|
|
96
|
+
status: z.literal("pending_deletion"),
|
|
97
|
+
});
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// POST /users/:userId/block, /users/:userId/unblock
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
export const userBlockRequestSchema = z.strictObject({
|
|
102
|
+
reason: z.string().min(1).max(1000).optional(),
|
|
103
|
+
});
|
|
104
|
+
export const userBlockResponseSchema = z.strictObject({
|
|
105
|
+
id: userIdSchema,
|
|
106
|
+
status: z.literal("blocked"),
|
|
107
|
+
});
|
|
108
|
+
export const userUnblockRequestSchema = z.strictObject({});
|
|
109
|
+
export const userUnblockResponseSchema = z.strictObject({
|
|
110
|
+
id: userIdSchema,
|
|
111
|
+
status: z.literal("active"),
|
|
112
|
+
});
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* `webhook_endpoints` (design.md §11.13) and the Customer Webhook event
|
|
4
|
+
* catalog (design.md §29.4's "イベント例" list, treated as the canonical
|
|
5
|
+
* enum since no other source enumerates event types). `secret_ciphertext`/
|
|
6
|
+
* `secret_iv` are excluded per the assignment's forbidden-field list; like
|
|
7
|
+
* `management_api_keys` (§11.12) and client secrets, the plaintext webhook
|
|
8
|
+
* signing secret is shown exactly once, on create/rotate.
|
|
9
|
+
*/
|
|
10
|
+
export declare const WEBHOOK_EVENT_TYPES: readonly ["user.created", "user.updated", "user.deleted", "user.blocked", "identity.linked", "identity.unlinked", "passkey.created", "passkey.deleted", "session.created", "session.revoked", "login.succeeded", "login.failed", "email.delivery.bounced", "mau.threshold_reached"];
|
|
11
|
+
export declare const webhookEventTypeSchema: z.ZodEnum<{
|
|
12
|
+
"user.created": "user.created";
|
|
13
|
+
"user.updated": "user.updated";
|
|
14
|
+
"user.deleted": "user.deleted";
|
|
15
|
+
"user.blocked": "user.blocked";
|
|
16
|
+
"identity.linked": "identity.linked";
|
|
17
|
+
"identity.unlinked": "identity.unlinked";
|
|
18
|
+
"passkey.created": "passkey.created";
|
|
19
|
+
"passkey.deleted": "passkey.deleted";
|
|
20
|
+
"session.created": "session.created";
|
|
21
|
+
"session.revoked": "session.revoked";
|
|
22
|
+
"login.succeeded": "login.succeeded";
|
|
23
|
+
"login.failed": "login.failed";
|
|
24
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
25
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
26
|
+
}>;
|
|
27
|
+
export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
|
|
28
|
+
export declare const WEBHOOK_STATUSES: readonly ["active", "disabled"];
|
|
29
|
+
export declare const webhookStatusSchema: z.ZodEnum<{
|
|
30
|
+
active: "active";
|
|
31
|
+
disabled: "disabled";
|
|
32
|
+
}>;
|
|
33
|
+
export type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];
|
|
34
|
+
export declare const webhookSchema: z.ZodObject<{
|
|
35
|
+
id: z.ZodString;
|
|
36
|
+
environment_id: z.ZodString;
|
|
37
|
+
url: z.ZodURL;
|
|
38
|
+
event_types: z.ZodArray<z.ZodEnum<{
|
|
39
|
+
"user.created": "user.created";
|
|
40
|
+
"user.updated": "user.updated";
|
|
41
|
+
"user.deleted": "user.deleted";
|
|
42
|
+
"user.blocked": "user.blocked";
|
|
43
|
+
"identity.linked": "identity.linked";
|
|
44
|
+
"identity.unlinked": "identity.unlinked";
|
|
45
|
+
"passkey.created": "passkey.created";
|
|
46
|
+
"passkey.deleted": "passkey.deleted";
|
|
47
|
+
"session.created": "session.created";
|
|
48
|
+
"session.revoked": "session.revoked";
|
|
49
|
+
"login.succeeded": "login.succeeded";
|
|
50
|
+
"login.failed": "login.failed";
|
|
51
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
52
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
53
|
+
}>>;
|
|
54
|
+
status: z.ZodEnum<{
|
|
55
|
+
active: "active";
|
|
56
|
+
disabled: "disabled";
|
|
57
|
+
}>;
|
|
58
|
+
created_at: z.ZodISODateTime;
|
|
59
|
+
updated_at: z.ZodISODateTime;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
export type Webhook = z.infer<typeof webhookSchema>;
|
|
62
|
+
export declare const webhookListQuerySchema: z.ZodObject<{
|
|
63
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
64
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
65
|
+
environment_id: z.ZodString;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type WebhookListQuery = z.infer<typeof webhookListQuerySchema>;
|
|
68
|
+
export declare const webhookListResponseSchema: z.ZodObject<{
|
|
69
|
+
items: z.ZodArray<z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
environment_id: z.ZodString;
|
|
72
|
+
url: z.ZodURL;
|
|
73
|
+
event_types: z.ZodArray<z.ZodEnum<{
|
|
74
|
+
"user.created": "user.created";
|
|
75
|
+
"user.updated": "user.updated";
|
|
76
|
+
"user.deleted": "user.deleted";
|
|
77
|
+
"user.blocked": "user.blocked";
|
|
78
|
+
"identity.linked": "identity.linked";
|
|
79
|
+
"identity.unlinked": "identity.unlinked";
|
|
80
|
+
"passkey.created": "passkey.created";
|
|
81
|
+
"passkey.deleted": "passkey.deleted";
|
|
82
|
+
"session.created": "session.created";
|
|
83
|
+
"session.revoked": "session.revoked";
|
|
84
|
+
"login.succeeded": "login.succeeded";
|
|
85
|
+
"login.failed": "login.failed";
|
|
86
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
87
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
88
|
+
}>>;
|
|
89
|
+
status: z.ZodEnum<{
|
|
90
|
+
active: "active";
|
|
91
|
+
disabled: "disabled";
|
|
92
|
+
}>;
|
|
93
|
+
created_at: z.ZodISODateTime;
|
|
94
|
+
updated_at: z.ZodISODateTime;
|
|
95
|
+
}, z.core.$strict>>;
|
|
96
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
export type WebhookListResponse = z.infer<typeof webhookListResponseSchema>;
|
|
99
|
+
export declare const webhookCreateRequestSchema: z.ZodObject<{
|
|
100
|
+
environment_id: z.ZodString;
|
|
101
|
+
url: z.ZodURL;
|
|
102
|
+
event_types: z.ZodArray<z.ZodEnum<{
|
|
103
|
+
"user.created": "user.created";
|
|
104
|
+
"user.updated": "user.updated";
|
|
105
|
+
"user.deleted": "user.deleted";
|
|
106
|
+
"user.blocked": "user.blocked";
|
|
107
|
+
"identity.linked": "identity.linked";
|
|
108
|
+
"identity.unlinked": "identity.unlinked";
|
|
109
|
+
"passkey.created": "passkey.created";
|
|
110
|
+
"passkey.deleted": "passkey.deleted";
|
|
111
|
+
"session.created": "session.created";
|
|
112
|
+
"session.revoked": "session.revoked";
|
|
113
|
+
"login.succeeded": "login.succeeded";
|
|
114
|
+
"login.failed": "login.failed";
|
|
115
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
116
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
117
|
+
}>>;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
export type WebhookCreateRequest = z.infer<typeof webhookCreateRequestSchema>;
|
|
120
|
+
/** One-time plaintext signing secret (design.md §11.12's display-once rule, applied here too; §29.4 HMAC). */
|
|
121
|
+
export declare const webhookCreateResponseSchema: z.ZodObject<{
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
environment_id: z.ZodString;
|
|
124
|
+
url: z.ZodURL;
|
|
125
|
+
event_types: z.ZodArray<z.ZodEnum<{
|
|
126
|
+
"user.created": "user.created";
|
|
127
|
+
"user.updated": "user.updated";
|
|
128
|
+
"user.deleted": "user.deleted";
|
|
129
|
+
"user.blocked": "user.blocked";
|
|
130
|
+
"identity.linked": "identity.linked";
|
|
131
|
+
"identity.unlinked": "identity.unlinked";
|
|
132
|
+
"passkey.created": "passkey.created";
|
|
133
|
+
"passkey.deleted": "passkey.deleted";
|
|
134
|
+
"session.created": "session.created";
|
|
135
|
+
"session.revoked": "session.revoked";
|
|
136
|
+
"login.succeeded": "login.succeeded";
|
|
137
|
+
"login.failed": "login.failed";
|
|
138
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
139
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
140
|
+
}>>;
|
|
141
|
+
status: z.ZodEnum<{
|
|
142
|
+
active: "active";
|
|
143
|
+
disabled: "disabled";
|
|
144
|
+
}>;
|
|
145
|
+
created_at: z.ZodISODateTime;
|
|
146
|
+
updated_at: z.ZodISODateTime;
|
|
147
|
+
secret: z.ZodString;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
export type WebhookCreateResponse = z.infer<typeof webhookCreateResponseSchema>;
|
|
150
|
+
export declare const webhookUpdateRequestSchema: z.ZodObject<{
|
|
151
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
152
|
+
event_types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
153
|
+
"user.created": "user.created";
|
|
154
|
+
"user.updated": "user.updated";
|
|
155
|
+
"user.deleted": "user.deleted";
|
|
156
|
+
"user.blocked": "user.blocked";
|
|
157
|
+
"identity.linked": "identity.linked";
|
|
158
|
+
"identity.unlinked": "identity.unlinked";
|
|
159
|
+
"passkey.created": "passkey.created";
|
|
160
|
+
"passkey.deleted": "passkey.deleted";
|
|
161
|
+
"session.created": "session.created";
|
|
162
|
+
"session.revoked": "session.revoked";
|
|
163
|
+
"login.succeeded": "login.succeeded";
|
|
164
|
+
"login.failed": "login.failed";
|
|
165
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
166
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
167
|
+
}>>>;
|
|
168
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
169
|
+
active: "active";
|
|
170
|
+
disabled: "disabled";
|
|
171
|
+
}>>;
|
|
172
|
+
}, z.core.$strict>;
|
|
173
|
+
export type WebhookUpdateRequest = z.infer<typeof webhookUpdateRequestSchema>;
|
|
174
|
+
export declare const webhookUpdateResponseSchema: z.ZodObject<{
|
|
175
|
+
id: z.ZodString;
|
|
176
|
+
environment_id: z.ZodString;
|
|
177
|
+
url: z.ZodURL;
|
|
178
|
+
event_types: z.ZodArray<z.ZodEnum<{
|
|
179
|
+
"user.created": "user.created";
|
|
180
|
+
"user.updated": "user.updated";
|
|
181
|
+
"user.deleted": "user.deleted";
|
|
182
|
+
"user.blocked": "user.blocked";
|
|
183
|
+
"identity.linked": "identity.linked";
|
|
184
|
+
"identity.unlinked": "identity.unlinked";
|
|
185
|
+
"passkey.created": "passkey.created";
|
|
186
|
+
"passkey.deleted": "passkey.deleted";
|
|
187
|
+
"session.created": "session.created";
|
|
188
|
+
"session.revoked": "session.revoked";
|
|
189
|
+
"login.succeeded": "login.succeeded";
|
|
190
|
+
"login.failed": "login.failed";
|
|
191
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
192
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
193
|
+
}>>;
|
|
194
|
+
status: z.ZodEnum<{
|
|
195
|
+
active: "active";
|
|
196
|
+
disabled: "disabled";
|
|
197
|
+
}>;
|
|
198
|
+
created_at: z.ZodISODateTime;
|
|
199
|
+
updated_at: z.ZodISODateTime;
|
|
200
|
+
}, z.core.$strict>;
|
|
201
|
+
export type WebhookUpdateResponse = z.infer<typeof webhookUpdateResponseSchema>;
|
|
202
|
+
export declare const webhookDeleteResponseSchema: z.ZodObject<{
|
|
203
|
+
id: z.ZodString;
|
|
204
|
+
deleted: z.ZodLiteral<true>;
|
|
205
|
+
}, z.core.$strict>;
|
|
206
|
+
export type WebhookDeleteResponse = z.infer<typeof webhookDeleteResponseSchema>;
|
|
207
|
+
export declare const webhookRotateSecretRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
208
|
+
export type WebhookRotateSecretRequest = z.infer<typeof webhookRotateSecretRequestSchema>;
|
|
209
|
+
export declare const webhookRotateSecretResponseSchema: z.ZodObject<{
|
|
210
|
+
id: z.ZodString;
|
|
211
|
+
secret: z.ZodString;
|
|
212
|
+
rotated_at: z.ZodISODateTime;
|
|
213
|
+
}, z.core.$strict>;
|
|
214
|
+
export type WebhookRotateSecretResponse = z.infer<typeof webhookRotateSecretResponseSchema>;
|
|
215
|
+
export declare const webhookTestRequestSchema: z.ZodObject<{
|
|
216
|
+
event_type: z.ZodOptional<z.ZodEnum<{
|
|
217
|
+
"user.created": "user.created";
|
|
218
|
+
"user.updated": "user.updated";
|
|
219
|
+
"user.deleted": "user.deleted";
|
|
220
|
+
"user.blocked": "user.blocked";
|
|
221
|
+
"identity.linked": "identity.linked";
|
|
222
|
+
"identity.unlinked": "identity.unlinked";
|
|
223
|
+
"passkey.created": "passkey.created";
|
|
224
|
+
"passkey.deleted": "passkey.deleted";
|
|
225
|
+
"session.created": "session.created";
|
|
226
|
+
"session.revoked": "session.revoked";
|
|
227
|
+
"login.succeeded": "login.succeeded";
|
|
228
|
+
"login.failed": "login.failed";
|
|
229
|
+
"email.delivery.bounced": "email.delivery.bounced";
|
|
230
|
+
"mau.threshold_reached": "mau.threshold_reached";
|
|
231
|
+
}>>;
|
|
232
|
+
}, z.core.$strict>;
|
|
233
|
+
export type WebhookTestRequest = z.infer<typeof webhookTestRequestSchema>;
|
|
234
|
+
/** design.md §29.4: "2xxだけ成功". `delivered` reports whether the endpoint returned 2xx. */
|
|
235
|
+
export declare const webhookTestResponseSchema: z.ZodObject<{
|
|
236
|
+
delivered: z.ZodBoolean;
|
|
237
|
+
response_status: z.ZodNullable<z.ZodNumber>;
|
|
238
|
+
response_time_ms: z.ZodNullable<z.ZodNumber>;
|
|
239
|
+
requested_at: z.ZodISODateTime;
|
|
240
|
+
}, z.core.$strict>;
|
|
241
|
+
export type WebhookTestResponse = z.infer<typeof webhookTestResponseSchema>;
|
|
242
|
+
/**
|
|
243
|
+
* `webhook_delivery_history` (design.md §29.4, §10.10): one row per delivery
|
|
244
|
+
* attempt. Deliberately excludes any request/response body, header, or
|
|
245
|
+
* signature — only status/attempt/response code/duration are ever recorded
|
|
246
|
+
* or exposed here, matching `@smartcrab/database-control`'s
|
|
247
|
+
* `WebhookDeliveryHistoryRecord`.
|
|
248
|
+
*/
|
|
249
|
+
export declare const WEBHOOK_DELIVERY_STATUSES: readonly ["pending", "delivered", "failed", "exhausted"];
|
|
250
|
+
export declare const webhookDeliveryStatusSchema: z.ZodEnum<{
|
|
251
|
+
failed: "failed";
|
|
252
|
+
pending: "pending";
|
|
253
|
+
delivered: "delivered";
|
|
254
|
+
exhausted: "exhausted";
|
|
255
|
+
}>;
|
|
256
|
+
export type WebhookDeliveryStatus = (typeof WEBHOOK_DELIVERY_STATUSES)[number];
|
|
257
|
+
export declare const webhookDeliverySchema: z.ZodObject<{
|
|
258
|
+
id: z.ZodString;
|
|
259
|
+
webhook_id: z.ZodString;
|
|
260
|
+
event_id: z.ZodString;
|
|
261
|
+
event_type: z.ZodString;
|
|
262
|
+
attempt: z.ZodNumber;
|
|
263
|
+
status: z.ZodEnum<{
|
|
264
|
+
failed: "failed";
|
|
265
|
+
pending: "pending";
|
|
266
|
+
delivered: "delivered";
|
|
267
|
+
exhausted: "exhausted";
|
|
268
|
+
}>;
|
|
269
|
+
response_status_code: z.ZodNullable<z.ZodNumber>;
|
|
270
|
+
duration_ms: z.ZodNumber;
|
|
271
|
+
occurred_at: z.ZodISODateTime;
|
|
272
|
+
}, z.core.$strict>;
|
|
273
|
+
export type WebhookDelivery = z.infer<typeof webhookDeliverySchema>;
|
|
274
|
+
export declare const webhookDeliveryListQuerySchema: z.ZodObject<{
|
|
275
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
276
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
277
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
278
|
+
failed: "failed";
|
|
279
|
+
pending: "pending";
|
|
280
|
+
delivered: "delivered";
|
|
281
|
+
exhausted: "exhausted";
|
|
282
|
+
}>>;
|
|
283
|
+
occurred_after: z.ZodOptional<z.ZodISODateTime>;
|
|
284
|
+
occurred_before: z.ZodOptional<z.ZodISODateTime>;
|
|
285
|
+
}, z.core.$strip>;
|
|
286
|
+
export type WebhookDeliveryListQuery = z.infer<typeof webhookDeliveryListQuerySchema>;
|
|
287
|
+
export declare const webhookDeliveryListResponseSchema: z.ZodObject<{
|
|
288
|
+
items: z.ZodArray<z.ZodObject<{
|
|
289
|
+
id: z.ZodString;
|
|
290
|
+
webhook_id: z.ZodString;
|
|
291
|
+
event_id: z.ZodString;
|
|
292
|
+
event_type: z.ZodString;
|
|
293
|
+
attempt: z.ZodNumber;
|
|
294
|
+
status: z.ZodEnum<{
|
|
295
|
+
failed: "failed";
|
|
296
|
+
pending: "pending";
|
|
297
|
+
delivered: "delivered";
|
|
298
|
+
exhausted: "exhausted";
|
|
299
|
+
}>;
|
|
300
|
+
response_status_code: z.ZodNullable<z.ZodNumber>;
|
|
301
|
+
duration_ms: z.ZodNumber;
|
|
302
|
+
occurred_at: z.ZodISODateTime;
|
|
303
|
+
}, z.core.$strict>>;
|
|
304
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
305
|
+
}, z.core.$strict>;
|
|
306
|
+
export type WebhookDeliveryListResponse = z.infer<typeof webhookDeliveryListResponseSchema>;
|