@krak-stack/auth 0.2.30 → 0.2.32
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/CHANGELOG.md +17 -0
- package/README.md +79 -1
- package/dist/admin/api.group.d.ts +94 -0
- package/dist/admin/api.group.js +3 -3
- package/dist/admin/schema.d.ts +215 -0
- package/dist/admin/schema.js +39 -1
- package/dist/api.d.ts +1531 -1377
- package/dist/auth/api.group.d.ts +19 -1
- package/dist/auth/api.group.js +17 -1
- package/dist/auth/schema.d.ts +12 -0
- package/dist/auth/schema.js +12 -0
- package/dist/components/account-deletion-request.d.ts +5 -0
- package/dist/components/account-deletion-request.js +7 -0
- package/dist/components/account-deletion.d.ts +8 -0
- package/dist/components/account-deletion.js +59 -0
- package/dist/components/admin-organizations.js +13 -3
- package/dist/components/admin-users.js +18 -1
- package/dist/components/associated-projects-notice.js +1 -1
- package/dist/components/auth-client-api.d.ts +127 -0
- package/dist/components/deletion-visibility.d.ts +1 -0
- package/dist/components/deletion-visibility.js +3 -0
- package/dist/components/organization-deletion-request.d.ts +17 -0
- package/dist/components/organization-deletion-request.js +9 -0
- package/dist/components/organization-switcher.js +31 -2
- package/dist/components/user-button.d.ts +29 -1
- package/dist/components/user-button.js +39 -2
- package/dist/extra/api.group.d.ts +13 -1
- package/dist/extra/api.group.js +5 -1
- package/dist/extra/schema.d.ts +13 -0
- package/dist/extra/schema.js +13 -0
- package/dist/schema.d.ts +35 -0
- package/dist/schema.js +25 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/middleware.d.ts +10 -2
- package/dist/server/middleware.js +4 -1
- package/dist/server/webhook-layer.d.ts +6 -0
- package/dist/server/webhook-layer.js +37 -0
- package/dist/server/webhooks.d.ts +38 -0
- package/dist/server/webhooks.js +39 -0
- package/dist/service.d.ts +66 -0
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @krak-stack/auth
|
|
2
2
|
|
|
3
|
+
## 0.2.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Require published Registry `0.1.61` or later for signed webhook-ID deduplication and the shared delivery table. Remove local Registry archive dependencies.
|
|
8
|
+
- Remove empty project-notice padding beneath user and organization menu headers.
|
|
9
|
+
- b497b8f: Require onDeleteUser when calling AuthMiddleware.layer. Projects provide their SQL cleanup callback; the middleware reads signing configuration, mounts the endpoint, and uses registry WebhooksReceiver for transactional deduplication. No separate auth-webhook service is needed. The layer now requires SQL; the former bare-auth-layer argument must be passed as authLayer in the options object.
|
|
10
|
+
- Temporarily hide account and organization deletion controls and dialogs in production builds, including admin organization deletion. Development builds retain these controls. Backend deletion authorization and cleanup remain unchanged.
|
|
11
|
+
- a46fb60: Add owner-confirmed organization deletion to the organization switcher and validated `organization.deletion_requested` cleanup webhooks, routed through the required `onDeleteOrganization` callback alongside `onDeleteUser`. Account deletion lists blocking organizations without deleting them. Unshared personal organizations are cleaned up with account deletion; standalone deletion remains protected.
|
|
12
|
+
- a46fb60: Use Registry's signed webhook-id for receiver deduplication and remove requestId and version from Auth webhook data. Requires the matching Registry signature protocol update on both sender and receiver.
|
|
13
|
+
|
|
14
|
+
## 0.2.31
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Preserve shared table column filters through admin user and organization query state and HTTP requests. Validate endpoint-specific fields and filter kinds, apply parameterized predicates before pagination and counting, and retain project scope. Configure typed boolean/date and organization-type controls; hide preview-only relationship filters until full option catalogs are available. Require registry 0.1.58 or later for the shared filter and menu updates.
|
|
19
|
+
|
|
3
20
|
## 0.2.30
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -57,6 +57,84 @@ const program = Effect.gen(function* () {
|
|
|
57
57
|
|
|
58
58
|
Use `AuthMiddleware.layer()` to provide request headers and configuration in an Effect HttpApi application. See the [middleware guide](https://auth.krakstack.net/en/docs/middleware).
|
|
59
59
|
|
|
60
|
+
### Auth webhooks
|
|
61
|
+
|
|
62
|
+
`AuthMiddleware.layer({ onDeleteUser, onDeleteOrganization })` requires both cleanup callbacks; there is no opt-out or default
|
|
63
|
+
successful cleanup. The SDK automatically mounts `POST /api/webhooks/auth`.
|
|
64
|
+
Every consuming project supplies only its application-specific SQL cleanup:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { AuthMiddleware } from "@krak-stack/auth/server";
|
|
68
|
+
import { Layer } from "effect";
|
|
69
|
+
|
|
70
|
+
const authentication = AuthMiddleware.layer({
|
|
71
|
+
onDeleteUser: ({ userId }) => eraseLocalUserData(userId),
|
|
72
|
+
onDeleteOrganization: ({ organizationId }) => eraseLocalOrganizationData(organizationId),
|
|
73
|
+
// Optional: handle other Auth events. Validate event-specific data here.
|
|
74
|
+
onWebhook: (webhook) => handleOtherAuthEvent(webhook),
|
|
75
|
+
}).pipe(Layer.provide(databaseLayer));
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Set server-only `KRAKSTACK_AUTH_WEBHOOK_SECRET` (at least 32 characters) and
|
|
79
|
+
`VITE_KRAKSTACK_AUTH_PROJECT_ID`, or pass explicit `webhookSecret: Redacted<string>` and
|
|
80
|
+
`projectId` options. Missing/invalid configuration fails setup. The cleanup must
|
|
81
|
+
use the same SQL pool as the receiver; it executes in the receipt transaction.
|
|
82
|
+
Do not perform external side effects or launch unawaited work in the callback.
|
|
83
|
+
|
|
84
|
+
The middleware uses `WebhooksReceiver` from `@krak-stack/registry/webhooks`.
|
|
85
|
+
Receiver migrations create only deduplication receipts, not delivery tables or
|
|
86
|
+
workers. Signed `user.deletion_requested` envelopes have data
|
|
87
|
+
fields `projectId`, `userId`, and `scope: "account"`. Requests are
|
|
88
|
+
HMAC-authenticated, project-validated, limited to 16 KiB, and acknowledged only
|
|
89
|
+
after commit. The timestamp window is five minutes. Duplicates return 204;
|
|
90
|
+
changed content under the same signed `webhook-id` returns 409.
|
|
91
|
+
`organization.deletion_requested` routes validated data (
|
|
92
|
+
`projectId`, `organizationId`, `scope: "organization"`) to `onDeleteOrganization`.
|
|
93
|
+
Neither deletion event routes to `onWebhook`. Other
|
|
94
|
+
events retain their event-specific JSON data and route to `onWebhook`; without a
|
|
95
|
+
handler they return 400, never a successful acknowledgement. Cleanup failures
|
|
96
|
+
roll back the receipt and return 500 so delivery can retry.
|
|
97
|
+
|
|
98
|
+
Signatures cover `${webhookId}.${timestamp}.${rawBody}`. Upgrade sender and receiver
|
|
99
|
+
together: legacy signatures over only timestamp/body are rejected. Neither `requestId`
|
|
100
|
+
nor `version` is required in webhook data.
|
|
101
|
+
|
|
102
|
+
Explicitly schedule `WebhooksReceiver.cleanup()` for receipts older than 30 days;
|
|
103
|
+
handlers must remain idempotent after expiry. Central Auth uses Better Auth's
|
|
104
|
+
native delete-user flow and durably notifies connected projects after the user
|
|
105
|
+
has been removed. Configure the project's **Webhook URL** and copy its **Signing
|
|
106
|
+
secret** into the receiving server. Platform admins and organization owners must
|
|
107
|
+
transfer their roles before self-deleting. This does not guarantee that a project's
|
|
108
|
+
callback covers all personal data. Inventory invitations, logs, exports,
|
|
109
|
+
processors, and backups before claiming complete erasure. Use
|
|
110
|
+
`@krak-stack/registry` `0.1.61` or later and upgrade sender and receiver together.
|
|
111
|
+
Account and organization deletion controls are temporarily hidden in production
|
|
112
|
+
builds, including admin organization deletion. Development controls remain available;
|
|
113
|
+
this UI rollout gate does not disable server endpoints or change authorization.
|
|
114
|
+
|
|
115
|
+
**Français :** `AuthMiddleware.layer({ onDeleteUser, onDeleteOrganization })` exige les deux fonctions de nettoyage et monte la route de
|
|
116
|
+
réception automatiquement. Chaque projet doit fournir son nettoyage SQL et le
|
|
117
|
+
secret de signature côté serveur ; une configuration absente empêche le
|
|
118
|
+
démarrage. Le reçu et le nettoyage sont validés dans la même transaction.
|
|
119
|
+
Un doublon retourne 204, un conflit de contenu 409 et un échec de nettoyage 500.
|
|
120
|
+
La réception seule ne démarre aucun travailleur d’envoi. Planifier le nettoyage
|
|
121
|
+
des reçus après 30 jours et conserver un traitement idempotent. Le parcours de
|
|
122
|
+
suppression central utilise Better Auth et notifie les projets après suppression
|
|
123
|
+
de l’utilisateur. Configurez l’URL du webhook et son secret de signature dans le
|
|
124
|
+
projet. Les administrateurs de plateforme et propriétaires d’organisation doivent
|
|
125
|
+
d’abord transférer leurs rôles. `onDeleteUser` reçoit les données validées de suppression du compte ;
|
|
126
|
+
`onDeleteOrganization` reçoit celles de suppression de l’organisation.
|
|
127
|
+
Le gestionnaire facultatif `onWebhook` reçoit les
|
|
128
|
+
autres événements avec leurs données JSON ; sans gestionnaire, ils retournent 400.
|
|
129
|
+
La déduplication utilise l’en-tête `webhook-id` signé. Aucun `requestId` n’est requis dans les données.
|
|
130
|
+
La signature couvre `${webhookId}.${timestamp}.${rawBody}`. Mettre à jour les deux côtés ensemble :
|
|
131
|
+
les anciennes signatures sont refusées. Aucun champ `version` n’est requis dans les données.
|
|
132
|
+
Ce mécanisme ne garantit pas, à lui seul, la conformité ou l’effacement complet.
|
|
133
|
+
Utilisez `@krak-stack/registry` `0.1.61` ou une version ultérieure et mettez à jour les deux côtés ensemble.
|
|
134
|
+
Les commandes de suppression de compte et d’organisation, y compris dans l’administration,
|
|
135
|
+
sont temporairement masquées en production. Elles restent disponibles en développement ;
|
|
136
|
+
ce masquage ne désactive pas les points d’entrée serveur ni leurs contrôles d’autorisation.
|
|
137
|
+
|
|
60
138
|
`AuthMiddleware` also annotates request logs and spans with verified user,
|
|
61
139
|
organization, and actor IDs using its existing session lookup. Missing sessions
|
|
62
140
|
are anonymous; auth service failures are not silently treated as anonymous.
|
|
@@ -87,7 +165,7 @@ as `AuthMiddleware.layer()`. It does not grant permissions or provide `CurrentAc
|
|
|
87
165
|
|
|
88
166
|
## React Components
|
|
89
167
|
|
|
90
|
-
The component bundle uses the optional peer dependencies declared in `package.json` and Krakstack/shadcn UI primitives from `@krak-stack/registry`. Install the component peers used by your application; server-only
|
|
168
|
+
The component bundle uses the optional peer dependencies declared in `package.json` and Krakstack/shadcn UI primitives from `@krak-stack/registry`. Install the component peers used by your application. Server middleware needs `effect`, the matching registry package, and an SQL pool; React component peers are not needed for server-only use.
|
|
91
169
|
|
|
92
170
|
When components are configured, register their Tailwind source:
|
|
93
171
|
|
|
@@ -229,6 +229,53 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
|
|
|
229
229
|
readonly direction: "asc" | "desc";
|
|
230
230
|
}[]>>;
|
|
231
231
|
readonly projectId: Schema.optional<Schema.String>;
|
|
232
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
233
|
+
readonly id: string;
|
|
234
|
+
readonly kind: "number";
|
|
235
|
+
readonly min?: number | undefined;
|
|
236
|
+
readonly max?: number | undefined;
|
|
237
|
+
} | {
|
|
238
|
+
readonly id: string;
|
|
239
|
+
readonly kind: "date";
|
|
240
|
+
readonly from?: string | undefined;
|
|
241
|
+
readonly to?: string | undefined;
|
|
242
|
+
} | {
|
|
243
|
+
readonly id: string;
|
|
244
|
+
readonly kind: "text";
|
|
245
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
246
|
+
readonly value: string;
|
|
247
|
+
} | {
|
|
248
|
+
readonly id: string;
|
|
249
|
+
readonly kind: "boolean";
|
|
250
|
+
readonly value: boolean;
|
|
251
|
+
} | {
|
|
252
|
+
readonly id: string;
|
|
253
|
+
readonly kind: "values";
|
|
254
|
+
readonly values: readonly [string, ...string[]];
|
|
255
|
+
})[], readonly ({
|
|
256
|
+
readonly id: string;
|
|
257
|
+
readonly kind: "number";
|
|
258
|
+
readonly min?: number | undefined;
|
|
259
|
+
readonly max?: number | undefined;
|
|
260
|
+
} | {
|
|
261
|
+
readonly id: string;
|
|
262
|
+
readonly kind: "date";
|
|
263
|
+
readonly from?: string | undefined;
|
|
264
|
+
readonly to?: string | undefined;
|
|
265
|
+
} | {
|
|
266
|
+
readonly id: string;
|
|
267
|
+
readonly kind: "text";
|
|
268
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
269
|
+
readonly value: string;
|
|
270
|
+
} | {
|
|
271
|
+
readonly id: string;
|
|
272
|
+
readonly kind: "boolean";
|
|
273
|
+
readonly value: boolean;
|
|
274
|
+
} | {
|
|
275
|
+
readonly id: string;
|
|
276
|
+
readonly kind: "values";
|
|
277
|
+
readonly values: readonly [string, ...string[]];
|
|
278
|
+
})[]>>;
|
|
232
279
|
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
233
280
|
readonly data: Schema.$Array<Schema.Struct<{
|
|
234
281
|
readonly id: Schema.String;
|
|
@@ -270,6 +317,53 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
|
|
|
270
317
|
readonly direction: "asc" | "desc";
|
|
271
318
|
}[]>>;
|
|
272
319
|
readonly projectId: Schema.optional<Schema.String>;
|
|
320
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
321
|
+
readonly id: string;
|
|
322
|
+
readonly kind: "number";
|
|
323
|
+
readonly min?: number | undefined;
|
|
324
|
+
readonly max?: number | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
readonly id: string;
|
|
327
|
+
readonly kind: "date";
|
|
328
|
+
readonly from?: string | undefined;
|
|
329
|
+
readonly to?: string | undefined;
|
|
330
|
+
} | {
|
|
331
|
+
readonly id: string;
|
|
332
|
+
readonly kind: "text";
|
|
333
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
334
|
+
readonly value: string;
|
|
335
|
+
} | {
|
|
336
|
+
readonly id: string;
|
|
337
|
+
readonly kind: "boolean";
|
|
338
|
+
readonly value: boolean;
|
|
339
|
+
} | {
|
|
340
|
+
readonly id: string;
|
|
341
|
+
readonly kind: "values";
|
|
342
|
+
readonly values: readonly [string, ...string[]];
|
|
343
|
+
})[], readonly ({
|
|
344
|
+
readonly id: string;
|
|
345
|
+
readonly kind: "number";
|
|
346
|
+
readonly min?: number | undefined;
|
|
347
|
+
readonly max?: number | undefined;
|
|
348
|
+
} | {
|
|
349
|
+
readonly id: string;
|
|
350
|
+
readonly kind: "date";
|
|
351
|
+
readonly from?: string | undefined;
|
|
352
|
+
readonly to?: string | undefined;
|
|
353
|
+
} | {
|
|
354
|
+
readonly id: string;
|
|
355
|
+
readonly kind: "text";
|
|
356
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
357
|
+
readonly value: string;
|
|
358
|
+
} | {
|
|
359
|
+
readonly id: string;
|
|
360
|
+
readonly kind: "boolean";
|
|
361
|
+
readonly value: boolean;
|
|
362
|
+
} | {
|
|
363
|
+
readonly id: string;
|
|
364
|
+
readonly kind: "values";
|
|
365
|
+
readonly values: readonly [string, ...string[]];
|
|
366
|
+
})[]>>;
|
|
273
367
|
}>>, never, never, Schema.toCodecJson<Schema.Struct<{
|
|
274
368
|
readonly data: Schema.$Array<Schema.Struct<{
|
|
275
369
|
readonly id: Schema.String;
|
package/dist/admin/api.group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, OpenApi, } from "effect/http-api";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import { AdminCreateOrganizationPayload, AdminApiKey, AdminApiKeyIdParams,
|
|
3
|
+
import { AdminCreateOrganizationPayload, AdminApiKey, AdminApiKeyIdParams, AdminUserListQuery, AdminOrganizationListQuery, AdminOrganization, AdminOrganizationIdParams, AdminUpdateApiKeyPayload, AdminUpdateOrganizationPayload, DashboardStatsQuery, DashboardStatsResponse, PaginatedAdminOrganizations, PaginatedAdminUsers, ServerCreateDomainPayload, ServerDomain, ServerDomainIdParams, ServerDomainRecordsResponse, ServerUpdateDomainPayload, } from "./schema.js";
|
|
4
4
|
export * from "./schema.js";
|
|
5
5
|
export const AdminApiGroup = HttpApiGroup.make("admin")
|
|
6
6
|
.add(HttpApiEndpoint.get("dashboardStats", "/admin/dashboard-stats", {
|
|
@@ -100,7 +100,7 @@ export const AdminApiGroup = HttpApiGroup.make("admin")
|
|
|
100
100
|
description: "Disables rate-limit enforcement for an API key.",
|
|
101
101
|
})))
|
|
102
102
|
.add(HttpApiEndpoint.get("listUsers", "/admin/users", {
|
|
103
|
-
query:
|
|
103
|
+
query: AdminUserListQuery.fields,
|
|
104
104
|
success: PaginatedAdminUsers,
|
|
105
105
|
error: [
|
|
106
106
|
HttpApiError.Unauthorized,
|
|
@@ -113,7 +113,7 @@ export const AdminApiGroup = HttpApiGroup.make("admin")
|
|
|
113
113
|
description: "Returns paginated auth user records with optional filtering and sorting.",
|
|
114
114
|
})))
|
|
115
115
|
.add(HttpApiEndpoint.get("listOrganizations", "/admin/organizations", {
|
|
116
|
-
query:
|
|
116
|
+
query: AdminOrganizationListQuery.fields,
|
|
117
117
|
success: PaginatedAdminOrganizations,
|
|
118
118
|
error: [
|
|
119
119
|
HttpApiError.Unauthorized,
|
package/dist/admin/schema.d.ts
CHANGED
|
@@ -1,6 +1,174 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { ServerCreateDomainPayload, ServerDomain, ServerDomainIdParams, ServerDomainRecordsResponse, ServerUpdateDomainPayload } from "../server/schema.js";
|
|
3
3
|
export declare const AdminListQuery: Schema.Struct<{
|
|
4
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
5
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
6
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
7
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly direction: "asc" | "desc";
|
|
10
|
+
}[], readonly {
|
|
11
|
+
readonly id: string;
|
|
12
|
+
readonly direction: "asc" | "desc";
|
|
13
|
+
}[]>>;
|
|
14
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly kind: "number";
|
|
17
|
+
readonly min?: number | undefined;
|
|
18
|
+
readonly max?: number | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly kind: "date";
|
|
22
|
+
readonly from?: string | undefined;
|
|
23
|
+
readonly to?: string | undefined;
|
|
24
|
+
} | {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly kind: "text";
|
|
27
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
28
|
+
readonly value: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly kind: "boolean";
|
|
32
|
+
readonly value: boolean;
|
|
33
|
+
} | {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly kind: "values";
|
|
36
|
+
readonly values: readonly [string, ...string[]];
|
|
37
|
+
})[], readonly ({
|
|
38
|
+
readonly id: string;
|
|
39
|
+
readonly kind: "number";
|
|
40
|
+
readonly min?: number | undefined;
|
|
41
|
+
readonly max?: number | undefined;
|
|
42
|
+
} | {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly kind: "date";
|
|
45
|
+
readonly from?: string | undefined;
|
|
46
|
+
readonly to?: string | undefined;
|
|
47
|
+
} | {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly kind: "text";
|
|
50
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
51
|
+
readonly value: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly id: string;
|
|
54
|
+
readonly kind: "boolean";
|
|
55
|
+
readonly value: boolean;
|
|
56
|
+
} | {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly kind: "values";
|
|
59
|
+
readonly values: readonly [string, ...string[]];
|
|
60
|
+
})[]>>;
|
|
61
|
+
readonly projectId: Schema.optional<Schema.String>;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const AdminUserColumnFilter: Schema.Union<readonly [Schema.Struct<{
|
|
64
|
+
readonly id: Schema.NonEmptyString;
|
|
65
|
+
readonly kind: Schema.Literal<"text">;
|
|
66
|
+
readonly operator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
|
|
67
|
+
readonly value: Schema.NonEmptyString;
|
|
68
|
+
}>, Schema.Struct<{
|
|
69
|
+
readonly id: Schema.NonEmptyString;
|
|
70
|
+
readonly kind: Schema.Literal<"number">;
|
|
71
|
+
readonly min: Schema.optional<Schema.Finite>;
|
|
72
|
+
readonly max: Schema.optional<Schema.Finite>;
|
|
73
|
+
}>, Schema.Struct<{
|
|
74
|
+
readonly id: Schema.NonEmptyString;
|
|
75
|
+
readonly kind: Schema.Literal<"date">;
|
|
76
|
+
readonly from: Schema.optional<Schema.String>;
|
|
77
|
+
readonly to: Schema.optional<Schema.String>;
|
|
78
|
+
}>, Schema.Struct<{
|
|
79
|
+
readonly id: Schema.NonEmptyString;
|
|
80
|
+
readonly kind: Schema.Literal<"boolean">;
|
|
81
|
+
readonly value: Schema.Boolean;
|
|
82
|
+
}>, Schema.Struct<{
|
|
83
|
+
readonly id: Schema.NonEmptyString;
|
|
84
|
+
readonly kind: Schema.Literal<"values">;
|
|
85
|
+
readonly values: Schema.NonEmptyArray<Schema.String>;
|
|
86
|
+
}>]>;
|
|
87
|
+
export declare const AdminOrganizationColumnFilter: Schema.Union<readonly [Schema.Struct<{
|
|
88
|
+
readonly id: Schema.NonEmptyString;
|
|
89
|
+
readonly kind: Schema.Literal<"text">;
|
|
90
|
+
readonly operator: Schema.Literals<readonly ["contains", "equals", "startsWith", "endsWith"]>;
|
|
91
|
+
readonly value: Schema.NonEmptyString;
|
|
92
|
+
}>, Schema.Struct<{
|
|
93
|
+
readonly id: Schema.NonEmptyString;
|
|
94
|
+
readonly kind: Schema.Literal<"number">;
|
|
95
|
+
readonly min: Schema.optional<Schema.Finite>;
|
|
96
|
+
readonly max: Schema.optional<Schema.Finite>;
|
|
97
|
+
}>, Schema.Struct<{
|
|
98
|
+
readonly id: Schema.NonEmptyString;
|
|
99
|
+
readonly kind: Schema.Literal<"date">;
|
|
100
|
+
readonly from: Schema.optional<Schema.String>;
|
|
101
|
+
readonly to: Schema.optional<Schema.String>;
|
|
102
|
+
}>, Schema.Struct<{
|
|
103
|
+
readonly id: Schema.NonEmptyString;
|
|
104
|
+
readonly kind: Schema.Literal<"boolean">;
|
|
105
|
+
readonly value: Schema.Boolean;
|
|
106
|
+
}>, Schema.Struct<{
|
|
107
|
+
readonly id: Schema.NonEmptyString;
|
|
108
|
+
readonly kind: Schema.Literal<"values">;
|
|
109
|
+
readonly values: Schema.NonEmptyArray<Schema.String>;
|
|
110
|
+
}>]>;
|
|
111
|
+
export declare const AdminUserListQuery: Schema.Struct<{
|
|
112
|
+
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
113
|
+
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
114
|
+
readonly globalFilter: Schema.optional<Schema.String>;
|
|
115
|
+
readonly sort: Schema.optional<Schema.declare<readonly {
|
|
116
|
+
readonly id: string;
|
|
117
|
+
readonly direction: "asc" | "desc";
|
|
118
|
+
}[], readonly {
|
|
119
|
+
readonly id: string;
|
|
120
|
+
readonly direction: "asc" | "desc";
|
|
121
|
+
}[]>>;
|
|
122
|
+
readonly projectId: Schema.optional<Schema.String>;
|
|
123
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly kind: "number";
|
|
126
|
+
readonly min?: number | undefined;
|
|
127
|
+
readonly max?: number | undefined;
|
|
128
|
+
} | {
|
|
129
|
+
readonly id: string;
|
|
130
|
+
readonly kind: "date";
|
|
131
|
+
readonly from?: string | undefined;
|
|
132
|
+
readonly to?: string | undefined;
|
|
133
|
+
} | {
|
|
134
|
+
readonly id: string;
|
|
135
|
+
readonly kind: "text";
|
|
136
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
137
|
+
readonly value: string;
|
|
138
|
+
} | {
|
|
139
|
+
readonly id: string;
|
|
140
|
+
readonly kind: "boolean";
|
|
141
|
+
readonly value: boolean;
|
|
142
|
+
} | {
|
|
143
|
+
readonly id: string;
|
|
144
|
+
readonly kind: "values";
|
|
145
|
+
readonly values: readonly [string, ...string[]];
|
|
146
|
+
})[], readonly ({
|
|
147
|
+
readonly id: string;
|
|
148
|
+
readonly kind: "number";
|
|
149
|
+
readonly min?: number | undefined;
|
|
150
|
+
readonly max?: number | undefined;
|
|
151
|
+
} | {
|
|
152
|
+
readonly id: string;
|
|
153
|
+
readonly kind: "date";
|
|
154
|
+
readonly from?: string | undefined;
|
|
155
|
+
readonly to?: string | undefined;
|
|
156
|
+
} | {
|
|
157
|
+
readonly id: string;
|
|
158
|
+
readonly kind: "text";
|
|
159
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
160
|
+
readonly value: string;
|
|
161
|
+
} | {
|
|
162
|
+
readonly id: string;
|
|
163
|
+
readonly kind: "boolean";
|
|
164
|
+
readonly value: boolean;
|
|
165
|
+
} | {
|
|
166
|
+
readonly id: string;
|
|
167
|
+
readonly kind: "values";
|
|
168
|
+
readonly values: readonly [string, ...string[]];
|
|
169
|
+
})[]>>;
|
|
170
|
+
}>;
|
|
171
|
+
export declare const AdminOrganizationListQuery: Schema.Struct<{
|
|
4
172
|
readonly page: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
5
173
|
readonly pageSize: Schema.decodeTo<Schema.Int, Schema.optional<Schema.Union<readonly [Schema.Number, Schema.NumberFromString]>>, never, never>;
|
|
6
174
|
readonly globalFilter: Schema.optional<Schema.String>;
|
|
@@ -12,6 +180,53 @@ export declare const AdminListQuery: Schema.Struct<{
|
|
|
12
180
|
readonly direction: "asc" | "desc";
|
|
13
181
|
}[]>>;
|
|
14
182
|
readonly projectId: Schema.optional<Schema.String>;
|
|
183
|
+
readonly filters: Schema.optional<Schema.declare<readonly ({
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly kind: "number";
|
|
186
|
+
readonly min?: number | undefined;
|
|
187
|
+
readonly max?: number | undefined;
|
|
188
|
+
} | {
|
|
189
|
+
readonly id: string;
|
|
190
|
+
readonly kind: "date";
|
|
191
|
+
readonly from?: string | undefined;
|
|
192
|
+
readonly to?: string | undefined;
|
|
193
|
+
} | {
|
|
194
|
+
readonly id: string;
|
|
195
|
+
readonly kind: "text";
|
|
196
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
197
|
+
readonly value: string;
|
|
198
|
+
} | {
|
|
199
|
+
readonly id: string;
|
|
200
|
+
readonly kind: "boolean";
|
|
201
|
+
readonly value: boolean;
|
|
202
|
+
} | {
|
|
203
|
+
readonly id: string;
|
|
204
|
+
readonly kind: "values";
|
|
205
|
+
readonly values: readonly [string, ...string[]];
|
|
206
|
+
})[], readonly ({
|
|
207
|
+
readonly id: string;
|
|
208
|
+
readonly kind: "number";
|
|
209
|
+
readonly min?: number | undefined;
|
|
210
|
+
readonly max?: number | undefined;
|
|
211
|
+
} | {
|
|
212
|
+
readonly id: string;
|
|
213
|
+
readonly kind: "date";
|
|
214
|
+
readonly from?: string | undefined;
|
|
215
|
+
readonly to?: string | undefined;
|
|
216
|
+
} | {
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly kind: "text";
|
|
219
|
+
readonly operator: "contains" | "endsWith" | "equals" | "startsWith";
|
|
220
|
+
readonly value: string;
|
|
221
|
+
} | {
|
|
222
|
+
readonly id: string;
|
|
223
|
+
readonly kind: "boolean";
|
|
224
|
+
readonly value: boolean;
|
|
225
|
+
} | {
|
|
226
|
+
readonly id: string;
|
|
227
|
+
readonly kind: "values";
|
|
228
|
+
readonly values: readonly [string, ...string[]];
|
|
229
|
+
})[]>>;
|
|
15
230
|
}>;
|
|
16
231
|
export declare const AdminProjectPreview: Schema.Struct<{
|
|
17
232
|
readonly id: Schema.String;
|
package/dist/admin/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { ApiKeyPermissionGrant } from "../access.js";
|
|
3
|
-
import { PaginatedResponse, Query } from "@krak-stack/registry/query";
|
|
3
|
+
import { ColumnFilter, ColumnFilters, PaginatedResponse, Query, } from "@krak-stack/registry/query";
|
|
4
4
|
import { ServerCreateDomainPayload, ServerDomain, ServerDomainIdParams, ServerDomainRecordsResponse, ServerUpdateDomainPayload, } from "../server/schema.js";
|
|
5
5
|
export const AdminListQuery = Schema.Struct({
|
|
6
6
|
...Query.fields,
|
|
@@ -11,6 +11,44 @@ export const AdminListQuery = Schema.Struct({
|
|
|
11
11
|
description: "Paginated administrative list query optionally scoped to linked project records.",
|
|
12
12
|
examples: [{ page: 0, pageSize: 10, projectId: "project-id" }],
|
|
13
13
|
});
|
|
14
|
+
export const AdminUserColumnFilter = ColumnFilter.check(Schema.makeFilter((filter) => {
|
|
15
|
+
switch (filter.id) {
|
|
16
|
+
case "name":
|
|
17
|
+
case "email":
|
|
18
|
+
case "role":
|
|
19
|
+
return filter.kind === "text";
|
|
20
|
+
case "emailVerified":
|
|
21
|
+
case "banned":
|
|
22
|
+
return filter.kind === "boolean";
|
|
23
|
+
case "createdAt":
|
|
24
|
+
case "lastSignedIn":
|
|
25
|
+
return filter.kind === "date";
|
|
26
|
+
default:
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
})).annotate({ identifier: "AdminUserColumnFilter" });
|
|
30
|
+
export const AdminOrganizationColumnFilter = ColumnFilter.check(Schema.makeFilter((filter) => {
|
|
31
|
+
switch (filter.id) {
|
|
32
|
+
case "name":
|
|
33
|
+
case "slug":
|
|
34
|
+
return filter.kind === "text";
|
|
35
|
+
case "createdAt":
|
|
36
|
+
return filter.kind === "date";
|
|
37
|
+
case "userId":
|
|
38
|
+
return (filter.kind === "values" &&
|
|
39
|
+
filter.values.every((value) => ["personal", "standard"].includes(value)));
|
|
40
|
+
default:
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
})).annotate({ identifier: "AdminOrganizationColumnFilter" });
|
|
44
|
+
export const AdminUserListQuery = Schema.Struct({
|
|
45
|
+
...AdminListQuery.fields,
|
|
46
|
+
filters: Schema.optional(ColumnFilters.check(Schema.makeFilter((filters) => filters.every(Schema.is(AdminUserColumnFilter))))),
|
|
47
|
+
}).annotate({ identifier: "AdminUserListQuery" });
|
|
48
|
+
export const AdminOrganizationListQuery = Schema.Struct({
|
|
49
|
+
...AdminListQuery.fields,
|
|
50
|
+
filters: Schema.optional(ColumnFilters.check(Schema.makeFilter((filters) => filters.every(Schema.is(AdminOrganizationColumnFilter))))),
|
|
51
|
+
}).annotate({ identifier: "AdminOrganizationListQuery" });
|
|
14
52
|
export const AdminProjectPreview = Schema.Struct({
|
|
15
53
|
id: Schema.String,
|
|
16
54
|
name: Schema.String,
|