@fuzdev/fuz_app 0.161.0 → 0.162.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/dist/auth/CLAUDE.md +16 -8
- package/dist/auth/account_action_specs.d.ts +173 -35
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +10 -7
- package/dist/auth/account_route_schema.d.ts +293 -46
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +5 -4
- package/dist/auth/account_schema.d.ts +489 -103
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +67 -47
- package/dist/auth/admin_action_specs.d.ts +1753 -240
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +29 -25
- package/dist/auth/audit_emitter.d.ts +8 -3
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +32 -9
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +4 -3
- package/dist/auth/audit_log_schema.d.ts +786 -259
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +188 -201
- package/dist/auth/audit_log_schema_fuz.d.ts +17 -3
- package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -1
- package/dist/auth/audit_log_schema_fuz.js +17 -4
- package/dist/auth/credential_type_schema.d.ts +1 -1
- package/dist/auth/invite_schema.d.ts +98 -26
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +21 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +27 -0
- package/dist/auth/role_grant_offer_action_specs.d.ts +72 -72
- package/dist/auth/role_grant_offer_notifications.d.ts +60 -60
- package/dist/auth/role_grant_offer_schema.d.ts +6 -6
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +8 -8
- package/dist/dev/setup.d.ts +14 -7
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +11 -6
- package/dist/primitive_schemas.d.ts +1 -4
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +1 -5
- package/dist/primitive_schemas_fuz.d.ts +36 -2
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +34 -3
- package/dist/testing/CLAUDE.md +7 -3
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +6 -2
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +12 -13
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +4 -2
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +4 -3
- package/dist/testing/db_entities.d.ts +3 -1
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +4 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +3 -2
- package/dist/zod.d.ts +2 -1
- package/dist/zod.d.ts.map +1 -1
- package/dist/zod.js +6 -2
- package/package.json +1 -1
|
@@ -4,19 +4,33 @@
|
|
|
4
4
|
* schemas written in fuz_schema.
|
|
5
5
|
*
|
|
6
6
|
* `AuditEventTypeName` is built from the constants the Zod one is, the
|
|
7
|
-
* grammar and the two messages
|
|
8
|
-
* `auth/name_schema.ts`, so the two can't drift apart.
|
|
7
|
+
* grammar and the two messages this module exports and the bound of
|
|
8
|
+
* `auth/name_schema.ts`, so the two can't drift apart. The constants live
|
|
9
|
+
* here, not beside the Zod schema, because `audit_log_schema.ts` builds its
|
|
10
|
+
* wire rows from these twins. They give every input
|
|
9
11
|
* the same verdict and output, and write the same JSON Schema (`maxLength`
|
|
10
12
|
* and `pattern`); a string both too long and off the grammar gets the one
|
|
11
13
|
* length issue from this twin, as its `pipe` stops at the first failing step,
|
|
12
14
|
* where the Zod one adds the grammar issue after it.
|
|
13
15
|
*
|
|
14
|
-
* The
|
|
16
|
+
* The twins are `@nodocs` while the Zod schemas of the same names stay, as
|
|
15
17
|
* the docs build refuses two exports of one name.
|
|
16
18
|
*
|
|
17
19
|
* @module
|
|
18
20
|
*/
|
|
19
21
|
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
22
|
+
/**
|
|
23
|
+
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
24
|
+
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
25
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
26
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
27
|
+
* length cap `AuditEventTypeName` takes.
|
|
28
|
+
*/
|
|
29
|
+
export declare const AUDIT_EVENT_TYPE_NAME_REGEX: RegExp;
|
|
30
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
31
|
+
export declare const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = "must be at most 64 characters";
|
|
32
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
33
|
+
export declare const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = "must start with a letter; only letters, digits, _ . / - allowed";
|
|
20
34
|
/**
|
|
21
35
|
* Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
22
36
|
* `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit_log_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema_fuz.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"audit_log_schema_fuz.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/audit_log_schema_fuz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAgC,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAKxF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,QAA+B,CAAC;AAExE,sEAAsE;AACtE,eAAO,MAAM,oCAAoC,kCAAkD,CAAC;AAEpG,iFAAiF;AACjF,eAAO,MAAM,qCAAqC,oEACgB,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0MAG9B,CAAC;AACF,cAAc;AACd,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,wIAAiC,CAAC;AAC3D,cAAc;AACd,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
* schemas written in fuz_schema.
|
|
5
5
|
*
|
|
6
6
|
* `AuditEventTypeName` is built from the constants the Zod one is, the
|
|
7
|
-
* grammar and the two messages
|
|
8
|
-
* `auth/name_schema.ts`, so the two can't drift apart.
|
|
7
|
+
* grammar and the two messages this module exports and the bound of
|
|
8
|
+
* `auth/name_schema.ts`, so the two can't drift apart. The constants live
|
|
9
|
+
* here, not beside the Zod schema, because `audit_log_schema.ts` builds its
|
|
10
|
+
* wire rows from these twins. They give every input
|
|
9
11
|
* the same verdict and output, and write the same JSON Schema (`maxLength`
|
|
10
12
|
* and `pattern`); a string both too long and off the grammar gets the one
|
|
11
13
|
* length issue from this twin, as its `pipe` stops at the first failing step,
|
|
12
14
|
* where the Zod one adds the grammar issue after it.
|
|
13
15
|
*
|
|
14
|
-
* The
|
|
16
|
+
* The twins are `@nodocs` while the Zod schemas of the same names stay, as
|
|
15
17
|
* the docs build refuses two exports of one name.
|
|
16
18
|
*
|
|
17
19
|
* @module
|
|
@@ -19,7 +21,18 @@
|
|
|
19
21
|
import { message, one_of, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
|
|
20
22
|
import { bounded_string } from '../primitive_schemas_fuz.js';
|
|
21
23
|
import { NAME_LENGTH_MAX } from './name_schema.js';
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Letter start, then letters, digits, `_`, `.`, `/`, `-`. Accepts snake_case,
|
|
26
|
+
* dotted, and namespaced consumer conventions; rejects empty strings, leading
|
|
27
|
+
* separators, whitespace, and control characters. The audit event type's own
|
|
28
|
+
* grammar, wider than the shared name grammar (`auth/name_schema.ts`), whose
|
|
29
|
+
* length cap `AuditEventTypeName` takes.
|
|
30
|
+
*/
|
|
31
|
+
export const AUDIT_EVENT_TYPE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_./-]*$/;
|
|
32
|
+
/** The message of an audit event-type name past `NAME_LENGTH_MAX`. */
|
|
33
|
+
export const AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE = `must be at most ${NAME_LENGTH_MAX} characters`;
|
|
34
|
+
/** The message of an audit event-type name off `AUDIT_EVENT_TYPE_NAME_REGEX`. */
|
|
35
|
+
export const AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE = 'must start with a letter; only letters, digits, _ . / - allowed';
|
|
23
36
|
/**
|
|
24
37
|
* Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
|
|
25
38
|
* `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
|
|
@@ -43,9 +43,9 @@ export declare const CREDENTIAL_TYPE_DAEMON_TOKEN = "daemon_token";
|
|
|
43
43
|
export declare const BUILTIN_CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
|
|
44
44
|
/** Zod enum for builtin credential types only. */
|
|
45
45
|
export declare const BuiltinCredentialType: z.ZodEnum<{
|
|
46
|
-
daemon_token: "daemon_token";
|
|
47
46
|
session: "session";
|
|
48
47
|
api_token: "api_token";
|
|
48
|
+
daemon_token: "daemon_token";
|
|
49
49
|
}>;
|
|
50
50
|
export type BuiltinCredentialType = z.infer<typeof BuiltinCredentialType>;
|
|
51
51
|
/**
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import { Uuid, Username
|
|
9
|
+
import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
|
|
10
|
+
import { Email, Uuid, type Username } from '../primitive_schemas_fuz.js';
|
|
11
11
|
/** Invite row from the database. */
|
|
12
12
|
export interface Invite {
|
|
13
13
|
id: Uuid;
|
|
@@ -18,30 +18,102 @@ export interface Invite {
|
|
|
18
18
|
created_at: string;
|
|
19
19
|
created_by: Uuid | null;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
created_at:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
created_by:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Client-safe invite data, a `@fuzdev/fuz_schema` schema. Its `username` is
|
|
23
|
+
* `UsernameCanonical`, the lowercase every creation path stores.
|
|
24
|
+
*/
|
|
25
|
+
export declare const InviteJson: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
26
|
+
email: string | null;
|
|
27
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
|
|
28
|
+
created_at: string;
|
|
29
|
+
username: string | null;
|
|
30
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
31
|
+
claimed_at: string | null;
|
|
32
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
33
|
+
}, {
|
|
34
|
+
email: string | null;
|
|
35
|
+
id: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
username: string | null;
|
|
38
|
+
claimed_by: string | null;
|
|
39
|
+
claimed_at: string | null;
|
|
40
|
+
created_by: string | null;
|
|
41
|
+
}, "object", {
|
|
42
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
43
|
+
readonly '~types'?: {
|
|
44
|
+
readonly input: string;
|
|
45
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
46
|
+
} | undefined;
|
|
47
|
+
};
|
|
48
|
+
email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
49
|
+
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>>;
|
|
50
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
51
|
+
readonly '~types'?: {
|
|
52
|
+
readonly input: string;
|
|
53
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
54
|
+
} | undefined;
|
|
55
|
+
}>>;
|
|
56
|
+
claimed_at: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
57
|
+
created_at: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
58
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
59
|
+
readonly '~types'?: {
|
|
60
|
+
readonly input: string;
|
|
61
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
62
|
+
} | undefined;
|
|
63
|
+
}>>;
|
|
64
|
+
}>;
|
|
65
|
+
export type InviteJson = Infer<typeof InviteJson>;
|
|
66
|
+
/**
|
|
67
|
+
* Invite data with resolved creator/claimer usernames, a `@fuzdev/fuz_schema`
|
|
68
|
+
* schema. The resolved names are plain strings.
|
|
69
|
+
*/
|
|
70
|
+
export declare const InviteWithUsernamesJson: import("@fuzdev/fuz_schema/schema.ts").Schema<{
|
|
71
|
+
email: string | null;
|
|
72
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">;
|
|
73
|
+
created_at: string;
|
|
74
|
+
username: string | null;
|
|
75
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
76
|
+
claimed_at: string | null;
|
|
77
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null;
|
|
78
|
+
created_by_username: string | null;
|
|
79
|
+
claimed_by_username: string | null;
|
|
80
|
+
}, {
|
|
81
|
+
email: string | null;
|
|
82
|
+
id: string;
|
|
83
|
+
created_at: string;
|
|
84
|
+
username: string | null;
|
|
85
|
+
claimed_by: string | null;
|
|
86
|
+
claimed_at: string | null;
|
|
87
|
+
created_by: string | null;
|
|
88
|
+
created_by_username: string | null;
|
|
89
|
+
claimed_by_username: string | null;
|
|
90
|
+
}, "object", {
|
|
91
|
+
created_by_username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
92
|
+
claimed_by_username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>;
|
|
93
|
+
id: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
94
|
+
readonly '~types'?: {
|
|
95
|
+
readonly input: string;
|
|
96
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
97
|
+
} | undefined;
|
|
98
|
+
};
|
|
99
|
+
email: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
100
|
+
username: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>>;
|
|
101
|
+
claimed_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
102
|
+
readonly '~types'?: {
|
|
103
|
+
readonly input: string;
|
|
104
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
105
|
+
} | undefined;
|
|
106
|
+
}>>;
|
|
107
|
+
claimed_at: import("@fuzdev/fuz_schema/schema.ts").Schema<string | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>>>;
|
|
108
|
+
created_at: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>>;
|
|
109
|
+
created_by: import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid"> | null, string | null, "nullable", import("@fuzdev/fuz_schema/schema.ts").SchemaWrapperDef<import("@fuzdev/fuz_schema/schema.ts").Schema<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, "pipe", readonly (import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"string"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"number"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"bigint"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"boolean"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"check"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"uuid"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"unknown"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"record"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"array"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"union"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"literal"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"nullable"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"optional"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"transform"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"pipe"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"lazy"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"regex"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"one_of"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"with_default_fn"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"loose_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"strip_object"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"object_with_rest"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"variant"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_length"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"min_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"max_value"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"safe_integer"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"iso_datetime"> | import("@fuzdev/fuz_schema/schema.ts").SchemaOfKind<"to_lower_case">)[]> & {
|
|
110
|
+
readonly '~types'?: {
|
|
111
|
+
readonly input: string;
|
|
112
|
+
readonly first: import("@fuzdev/fuz_schema/schema.ts").Schema<string, string, "string", undefined>;
|
|
113
|
+
} | undefined;
|
|
114
|
+
}>>;
|
|
115
|
+
}>;
|
|
116
|
+
export type InviteWithUsernamesJson = Infer<typeof InviteWithUsernamesJson>;
|
|
45
117
|
/** Input for creating an invite. */
|
|
46
118
|
export interface CreateInviteInput {
|
|
47
119
|
email?: Email | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invite_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"invite_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/invite_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA4B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAEpF,OAAO,EACN,KAAK,EAGL,IAAI,EACJ,KAAK,QAAQ,EACb,MAAM,6BAA6B,CAAC;AAErC,oCAAoC;AACpC,MAAM,WAAW,MAAM;IACtB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE5E,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB"}
|
|
@@ -6,20 +6,27 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
/**
|
|
12
|
-
|
|
9
|
+
import { nullable, object, string } from '@fuzdev/fuz_schema/schema.ts';
|
|
10
|
+
import { Email, Timestamp, UsernameCanonical, Uuid } from '../primitive_schemas_fuz.js';
|
|
11
|
+
/**
|
|
12
|
+
* Client-safe invite data, a `@fuzdev/fuz_schema` schema. Its `username` is
|
|
13
|
+
* `UsernameCanonical`, the lowercase every creation path stores.
|
|
14
|
+
*/
|
|
15
|
+
export const InviteJson = object({
|
|
13
16
|
id: Uuid,
|
|
14
|
-
email:
|
|
15
|
-
username:
|
|
16
|
-
claimed_by:
|
|
17
|
-
claimed_at:
|
|
18
|
-
created_at:
|
|
19
|
-
created_by:
|
|
17
|
+
email: nullable(Email),
|
|
18
|
+
username: nullable(UsernameCanonical),
|
|
19
|
+
claimed_by: nullable(Uuid),
|
|
20
|
+
claimed_at: nullable(Timestamp),
|
|
21
|
+
created_at: Timestamp,
|
|
22
|
+
created_by: nullable(Uuid)
|
|
20
23
|
});
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Invite data with resolved creator/claimer usernames, a `@fuzdev/fuz_schema`
|
|
26
|
+
* schema. The resolved names are plain strings.
|
|
27
|
+
*/
|
|
28
|
+
export const InviteWithUsernamesJson = object({
|
|
29
|
+
...InviteJson.def,
|
|
30
|
+
created_by_username: nullable(string),
|
|
31
|
+
claimed_by_username: nullable(string)
|
|
25
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAkQ1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
|
package/dist/auth/migrations.js
CHANGED
|
@@ -257,6 +257,33 @@ const AUTH_MIGRATIONS = [
|
|
|
257
257
|
AND superseded_at IS NULL
|
|
258
258
|
AND expire_audited_at IS NULL`);
|
|
259
259
|
}
|
|
260
|
+
},
|
|
261
|
+
// Every `account.username` lowercase, as `Username` canonicalizes every
|
|
262
|
+
// name production creates, so the wire's username (`UsernameCanonical`)
|
|
263
|
+
// is the stored one and the case-insensitive unique index reads the same
|
|
264
|
+
// value as the column.
|
|
265
|
+
//
|
|
266
|
+
// `ADD CONSTRAINT … CHECK` validates the rows already there: a database
|
|
267
|
+
// holding a username with an uppercase letter (one written outside the
|
|
268
|
+
// creation paths, by hand or by a harness) fails the migration on
|
|
269
|
+
// `check_violation`, and the chain's transaction rolls back. Lowercase
|
|
270
|
+
// those rows (`UPDATE account SET username = lower(username)`, which the
|
|
271
|
+
// unique index on `LOWER(username)` keeps from colliding) and migrate
|
|
272
|
+
// again. Idempotent without PL/pgSQL, as `role_grant_scope_kind_paired`:
|
|
273
|
+
// probe `information_schema.table_constraints`, then add only if absent.
|
|
274
|
+
{
|
|
275
|
+
name: 'account_username_lowercase',
|
|
276
|
+
up: async (db) => {
|
|
277
|
+
const existing = await db.query(`SELECT 1 FROM information_schema.table_constraints
|
|
278
|
+
WHERE table_schema = 'public'
|
|
279
|
+
AND table_name = 'account'
|
|
280
|
+
AND constraint_name = 'account_username_lowercase'`);
|
|
281
|
+
if (existing.length === 0) {
|
|
282
|
+
await db.query(`ALTER TABLE account
|
|
283
|
+
ADD CONSTRAINT account_username_lowercase
|
|
284
|
+
CHECK (username = lower(username))`);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
260
287
|
}
|
|
261
288
|
];
|
|
262
289
|
/**
|