@fuzdev/fuz_app 0.160.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.
Files changed (98) hide show
  1. package/dist/auth/CLAUDE.md +31 -21
  2. package/dist/auth/account_action_specs.d.ts +173 -35
  3. package/dist/auth/account_action_specs.d.ts.map +1 -1
  4. package/dist/auth/account_action_specs.js +10 -7
  5. package/dist/auth/account_route_schema.d.ts +293 -46
  6. package/dist/auth/account_route_schema.d.ts.map +1 -1
  7. package/dist/auth/account_route_schema.js +5 -4
  8. package/dist/auth/account_schema.d.ts +489 -103
  9. package/dist/auth/account_schema.d.ts.map +1 -1
  10. package/dist/auth/account_schema.js +67 -47
  11. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  12. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  13. package/dist/auth/admin_action_specs.d.ts +2748 -505
  14. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  15. package/dist/auth/admin_action_specs.js +175 -187
  16. package/dist/auth/app_settings_schema.d.ts +46 -23
  17. package/dist/auth/app_settings_schema.d.ts.map +1 -1
  18. package/dist/auth/app_settings_schema.js +12 -15
  19. package/dist/auth/audit_emitter.d.ts +8 -3
  20. package/dist/auth/audit_emitter.d.ts.map +1 -1
  21. package/dist/auth/audit_emitter.js +32 -9
  22. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  23. package/dist/auth/audit_log_queries.js +4 -3
  24. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  25. package/dist/auth/audit_log_schema.d.ts +791 -253
  26. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  27. package/dist/auth/audit_log_schema.js +198 -198
  28. package/dist/auth/audit_log_schema_fuz.d.ts +53 -0
  29. package/dist/auth/audit_log_schema_fuz.d.ts.map +1 -0
  30. package/dist/auth/audit_log_schema_fuz.js +50 -0
  31. package/dist/auth/credential_type_schema.d.ts +5 -8
  32. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  33. package/dist/auth/credential_type_schema.js +6 -10
  34. package/dist/auth/grant_path_schema.d.ts +4 -7
  35. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  36. package/dist/auth/grant_path_schema.js +6 -10
  37. package/dist/auth/invite_schema.d.ts +98 -26
  38. package/dist/auth/invite_schema.d.ts.map +1 -1
  39. package/dist/auth/invite_schema.js +21 -14
  40. package/dist/auth/migrations.d.ts.map +1 -1
  41. package/dist/auth/migrations.js +27 -0
  42. package/dist/auth/name_schema.d.ts +63 -0
  43. package/dist/auth/name_schema.d.ts.map +1 -0
  44. package/dist/auth/name_schema.js +65 -0
  45. package/dist/auth/request_context.d.ts.map +1 -1
  46. package/dist/auth/request_context.js +2 -1
  47. package/dist/auth/role_grant_offer_action_specs.d.ts +192 -192
  48. package/dist/auth/role_grant_offer_action_specs.js +2 -2
  49. package/dist/auth/role_grant_offer_notifications.d.ts +126 -126
  50. package/dist/auth/role_grant_offer_schema.d.ts +12 -12
  51. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
  52. package/dist/auth/role_grant_offer_schema.js +8 -8
  53. package/dist/auth/role_schema.d.ts +14 -25
  54. package/dist/auth/role_schema.d.ts.map +1 -1
  55. package/dist/auth/role_schema.js +15 -29
  56. package/dist/auth/role_schema_fuz.d.ts +4 -3
  57. package/dist/auth/role_schema_fuz.d.ts.map +1 -1
  58. package/dist/auth/role_schema_fuz.js +7 -5
  59. package/dist/auth/scope_kind_schema.d.ts +13 -26
  60. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  61. package/dist/auth/scope_kind_schema.js +15 -31
  62. package/dist/auth/scope_kind_schema_fuz.d.ts +4 -3
  63. package/dist/auth/scope_kind_schema_fuz.d.ts.map +1 -1
  64. package/dist/auth/scope_kind_schema_fuz.js +7 -5
  65. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  66. package/dist/auth/token_scope.d.ts +7 -13
  67. package/dist/auth/token_scope.d.ts.map +1 -1
  68. package/dist/auth/token_scope.js +9 -14
  69. package/dist/dev/setup.d.ts +14 -7
  70. package/dist/dev/setup.d.ts.map +1 -1
  71. package/dist/dev/setup.js +11 -6
  72. package/dist/primitive_schemas.d.ts +47 -4
  73. package/dist/primitive_schemas.d.ts.map +1 -1
  74. package/dist/primitive_schemas.js +40 -19
  75. package/dist/primitive_schemas_fuz.d.ts +70 -8
  76. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  77. package/dist/primitive_schemas_fuz.js +62 -7
  78. package/dist/testing/CLAUDE.md +11 -6
  79. package/dist/testing/app_server.d.ts +3 -1
  80. package/dist/testing/app_server.d.ts.map +1 -1
  81. package/dist/testing/app_server.js +6 -2
  82. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  83. package/dist/testing/audit_drift_guard.js +12 -13
  84. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  85. package/dist/testing/cross_backend/identity_parity.js +24 -13
  86. package/dist/testing/cross_backend/role_grant_role_grammar.d.ts.map +1 -1
  87. package/dist/testing/cross_backend/role_grant_role_grammar.js +8 -15
  88. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/session_cap.js +4 -3
  90. package/dist/testing/db_entities.d.ts +3 -1
  91. package/dist/testing/db_entities.d.ts.map +1 -1
  92. package/dist/testing/db_entities.js +4 -2
  93. package/dist/testing/integration.d.ts.map +1 -1
  94. package/dist/testing/integration.js +3 -2
  95. package/dist/zod.d.ts +2 -1
  96. package/dist/zod.d.ts.map +1 -1
  97. package/dist/zod.js +6 -2
  98. package/package.json +1 -1
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twins of the Zod `AuditEventTypeName` and
3
+ * `AuditOutcome` (`auth/audit_log_schema.ts`), under the same names, for
4
+ * schemas written in fuz_schema.
5
+ *
6
+ * `AuditEventTypeName` is built from the constants the Zod one is, the
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
11
+ * the same verdict and output, and write the same JSON Schema (`maxLength`
12
+ * and `pattern`); a string both too long and off the grammar gets the one
13
+ * length issue from this twin, as its `pipe` stops at the first failing step,
14
+ * where the Zod one adds the grammar issue after it.
15
+ *
16
+ * The twins are `@nodocs` while the Zod schemas of the same names stay, as
17
+ * the docs build refuses two exports of one name.
18
+ *
19
+ * @module
20
+ */
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";
34
+ /**
35
+ * Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
36
+ * `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
37
+ * `AuditEventTypeName`. A string it refuses gets the Zod one's message; a
38
+ * value that is no string, fuz_schema's.
39
+ *
40
+ * @nodocs
41
+ */
42
+ export declare const AuditEventTypeName: 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>>>;
43
+ /** @nodocs */
44
+ export type AuditEventTypeName = Infer<typeof AuditEventTypeName>;
45
+ /**
46
+ * Audit event outcome, the twin of the Zod `AuditOutcome`.
47
+ *
48
+ * @nodocs
49
+ */
50
+ export declare const AuditOutcome: import("@fuzdev/fuz_schema/schema.ts").Schema<"success" | "failure", "success" | "failure", "one_of", readonly ["success", "failure"]>;
51
+ /** @nodocs */
52
+ export type AuditOutcome = Infer<typeof AuditOutcome>;
53
+ //# sourceMappingURL=audit_log_schema_fuz.d.ts.map
@@ -0,0 +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;;;;;;;;;;;;;;;;;;;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"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The `@fuzdev/fuz_schema` twins of the Zod `AuditEventTypeName` and
3
+ * `AuditOutcome` (`auth/audit_log_schema.ts`), under the same names, for
4
+ * schemas written in fuz_schema.
5
+ *
6
+ * `AuditEventTypeName` is built from the constants the Zod one is, the
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
11
+ * the same verdict and output, and write the same JSON Schema (`maxLength`
12
+ * and `pattern`); a string both too long and off the grammar gets the one
13
+ * length issue from this twin, as its `pipe` stops at the first failing step,
14
+ * where the Zod one adds the grammar issue after it.
15
+ *
16
+ * The twins are `@nodocs` while the Zod schemas of the same names stay, as
17
+ * the docs build refuses two exports of one name.
18
+ *
19
+ * @module
20
+ */
21
+ import { message, one_of, pipe, regex } from '@fuzdev/fuz_schema/schema.ts';
22
+ import { bounded_string } from '../primitive_schemas_fuz.js';
23
+ import { NAME_LENGTH_MAX } from './name_schema.js';
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';
36
+ /**
37
+ * Valid audit event-type name: `AUDIT_EVENT_TYPE_NAME_REGEX`, at most
38
+ * `NAME_LENGTH_MAX` UTF-16 code units, the twin of the Zod
39
+ * `AuditEventTypeName`. A string it refuses gets the Zod one's message; a
40
+ * value that is no string, fuz_schema's.
41
+ *
42
+ * @nodocs
43
+ */
44
+ export const AuditEventTypeName = pipe(bounded_string({ max: NAME_LENGTH_MAX, max_message: AUDIT_EVENT_TYPE_NAME_LENGTH_MESSAGE }), message(regex(AUDIT_EVENT_TYPE_NAME_REGEX), AUDIT_EVENT_TYPE_NAME_PATTERN_MESSAGE));
45
+ /**
46
+ * Audit event outcome, the twin of the Zod `AuditOutcome`.
47
+ *
48
+ * @nodocs
49
+ */
50
+ export const AuditOutcome = one_of(['success', 'failure']);
@@ -22,13 +22,10 @@
22
22
  */
23
23
  import { z } from 'zod';
24
24
  /**
25
- * Runs of lowercase letters (a-z) joined by single underscores, the grammar
26
- * of `RoleName`, `ScopeKindName` and `GrantPathName` too. Rejects empty
27
- * strings, leading, trailing or consecutive underscores, uppercase, and
28
- * digits.
25
+ * Zod schema for valid credential-type name strings: the shared name grammar
26
+ * (`auth/name_schema.ts`), runs of lowercase letters joined by single
27
+ * underscores, at most `NAME_LENGTH_MAX` characters.
29
28
  */
30
- export declare const CREDENTIAL_TYPE_NAME_REGEX: RegExp;
31
- /** Zod schema for valid credential-type name strings. */
32
29
  export declare const CredentialTypeName: z.ZodString;
33
30
  export type CredentialTypeName = z.infer<typeof CredentialTypeName>;
34
31
  /** Cookie-based session credential. */
@@ -46,9 +43,9 @@ export declare const CREDENTIAL_TYPE_DAEMON_TOKEN = "daemon_token";
46
43
  export declare const BUILTIN_CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
47
44
  /** Zod enum for builtin credential types only. */
48
45
  export declare const BuiltinCredentialType: z.ZodEnum<{
49
- daemon_token: "daemon_token";
50
46
  session: "session";
51
47
  api_token: "api_token";
48
+ daemon_token: "daemon_token";
52
49
  }>;
53
50
  export type BuiltinCredentialType = z.infer<typeof BuiltinCredentialType>;
54
51
  /**
@@ -99,7 +96,7 @@ export interface CredentialTypeSchemaResult {
99
96
  * @param consumer_types - optional consumer-declared credential-type set with optional metadata
100
97
  * @returns `{CredentialType, credential_types}` — Zod schema and metadata map
101
98
  *
102
- * @throws Error if any `consumer_types` key fails the `CredentialTypeName` regex, collides with a builtin name, or appears more than once
99
+ * @throws Error if any `consumer_types` key fails `CredentialTypeName` (its grammar or its length cap), collides with a builtin name, or appears more than once
103
100
  *
104
101
  * @example
105
102
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAyB,CAAC;AAEjE,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,aAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
1
+ {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAwC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
@@ -21,17 +21,13 @@
21
21
  * @module
22
22
  */
23
23
  import { z } from 'zod';
24
+ import { create_name_schema } from './name_schema.js';
24
25
  /**
25
- * Runs of lowercase letters (a-z) joined by single underscores, the grammar
26
- * of `RoleName`, `ScopeKindName` and `GrantPathName` too. Rejects empty
27
- * strings, leading, trailing or consecutive underscores, uppercase, and
28
- * digits.
26
+ * Zod schema for valid credential-type name strings: the shared name grammar
27
+ * (`auth/name_schema.ts`), runs of lowercase letters joined by single
28
+ * underscores, at most `NAME_LENGTH_MAX` characters.
29
29
  */
30
- export const CREDENTIAL_TYPE_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
31
- /** Zod schema for valid credential-type name strings. */
32
- export const CredentialTypeName = z
33
- .string()
34
- .regex(CREDENTIAL_TYPE_NAME_REGEX, 'Credential-type names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
30
+ export const CredentialTypeName = create_name_schema('Credential-type');
35
31
  // Builtin credential types — provided by fuz_app, always available.
36
32
  /** Cookie-based session credential. */
37
33
  export const CREDENTIAL_TYPE_SESSION = 'session';
@@ -89,7 +85,7 @@ export const builtin_credential_type_meta = new Map([
89
85
  * @param consumer_types - optional consumer-declared credential-type set with optional metadata
90
86
  * @returns `{CredentialType, credential_types}` — Zod schema and metadata map
91
87
  *
92
- * @throws Error if any `consumer_types` key fails the `CredentialTypeName` regex, collides with a builtin name, or appears more than once
88
+ * @throws Error if any `consumer_types` key fails `CredentialTypeName` (its grammar or its length cap), collides with a builtin name, or appears more than once
93
89
  *
94
90
  * @example
95
91
  * ```ts
@@ -26,13 +26,10 @@
26
26
  */
27
27
  import { z } from 'zod';
28
28
  /**
29
- * Runs of lowercase letters (a-z) joined by single underscores, the grammar
30
- * of `RoleName`, `ScopeKindName` and `CredentialTypeName` too. Rejects empty
31
- * strings, leading, trailing or consecutive underscores, uppercase, and
32
- * digits.
29
+ * Zod schema for valid grant-path name strings: the shared name grammar
30
+ * (`auth/name_schema.ts`), runs of lowercase letters joined by single
31
+ * underscores, at most `NAME_LENGTH_MAX` characters.
33
32
  */
34
- export declare const GRANT_PATH_NAME_REGEX: RegExp;
35
- /** Zod schema for valid grant-path name strings. */
36
33
  export declare const GrantPathName: z.ZodString;
37
34
  export type GrantPathName = z.infer<typeof GrantPathName>;
38
35
  /** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
@@ -100,7 +97,7 @@ export interface GrantPathSchemaResult {
100
97
  * @param consumer_paths - optional consumer-declared grant-path set with optional metadata
101
98
  * @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
102
99
  *
103
- * @throws Error if any `consumer_paths` key fails the `GrantPathName` regex, collides with a builtin name, or appears more than once
100
+ * @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
104
101
  *
105
102
  * @example
106
103
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAyB,CAAC;AAE5D,oDAAoD;AACpD,eAAO,MAAM,aAAa,aAKxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,wBAAwB,GACpC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,qBA2BF,CAAC"}
1
+ {"version":3,"file":"grant_path_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/grant_path_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;GAIG;AACH,eAAO,MAAM,aAAa,aAAmC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAI1D,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,2DAKtB,CAAC;AAEX,6CAA6C;AAC7C,eAAO,MAAM,gBAAgB;;;;;EAA8B,CAAC;AAC5D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAuBrE,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,wBAAwB,GACpC,iBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAM,KAChD,qBA2BF,CAAC"}
@@ -25,17 +25,13 @@
25
25
  * @module
26
26
  */
27
27
  import { z } from 'zod';
28
+ import { create_name_schema } from './name_schema.js';
28
29
  /**
29
- * Runs of lowercase letters (a-z) joined by single underscores, the grammar
30
- * of `RoleName`, `ScopeKindName` and `CredentialTypeName` too. Rejects empty
31
- * strings, leading, trailing or consecutive underscores, uppercase, and
32
- * digits.
30
+ * Zod schema for valid grant-path name strings: the shared name grammar
31
+ * (`auth/name_schema.ts`), runs of lowercase letters joined by single
32
+ * underscores, at most `NAME_LENGTH_MAX` characters.
33
33
  */
34
- export const GRANT_PATH_NAME_REGEX = /^[a-z]+(?:_[a-z]+)*$/;
35
- /** Zod schema for valid grant-path name strings. */
36
- export const GrantPathName = z
37
- .string()
38
- .regex(GRANT_PATH_NAME_REGEX, 'Grant-path names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores');
34
+ export const GrantPathName = create_name_schema('Grant-path');
39
35
  // Builtin grant paths — provided by fuz_app, always available.
40
36
  /** Admin-mediated grant — `role_grant_offer_create` plus admin-direct flows. */
41
37
  export const GRANT_PATH_ADMIN = 'admin';
@@ -98,7 +94,7 @@ export const builtin_grant_path_meta = new Map([
98
94
  * @param consumer_paths - optional consumer-declared grant-path set with optional metadata
99
95
  * @returns `{GrantPath, grant_paths}` — Zod schema and metadata map
100
96
  *
101
- * @throws Error if any `consumer_paths` key fails the `GrantPathName` regex, collides with a builtin name, or appears more than once
97
+ * @throws Error if any `consumer_paths` key fails `GrantPathName` (its grammar or its length cap), collides with a builtin name, or appears more than once
102
98
  *
103
99
  * @example
104
100
  * ```ts
@@ -6,8 +6,8 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import { z } from 'zod';
10
- import { Uuid, Username, Email } from '../primitive_schemas.js';
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
- /** Zod schema for client-safe invite data. */
22
- export declare const InviteJson: z.ZodObject<{
23
- id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
24
- email: z.ZodNullable<z.ZodString>;
25
- username: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
26
- claimed_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
27
- claimed_at: z.ZodNullable<z.ZodString>;
28
- created_at: z.ZodString;
29
- created_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
30
- }, z.core.$strict>;
31
- export type InviteJson = z.infer<typeof InviteJson>;
32
- /** Zod schema for invite data with resolved creator/claimer usernames. */
33
- export declare const InviteWithUsernamesJson: z.ZodObject<{
34
- id: z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>;
35
- email: z.ZodNullable<z.ZodString>;
36
- username: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
37
- claimed_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
38
- claimed_at: z.ZodNullable<z.ZodString>;
39
- created_at: z.ZodString;
40
- created_by: z.ZodNullable<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.js").Branded<string, "Uuid">, string>>>;
41
- created_by_username: z.ZodNullable<z.ZodString>;
42
- claimed_by_username: z.ZodNullable<z.ZodString>;
43
- }, z.core.$strict>;
44
- export type InviteWithUsernamesJson = z.infer<typeof InviteWithUsernamesJson>;
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,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhE,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,8CAA8C;AAC9C,eAAO,MAAM,UAAU;;;;;;;;kBAQrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,uBAAuB;;;;;;;;;;kBAGlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,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"}
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 { z } from 'zod';
10
- import { Uuid, Username, Email } from '../primitive_schemas.js';
11
- /** Zod schema for client-safe invite data. */
12
- export const InviteJson = z.strictObject({
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: Email.nullable(),
15
- username: Username.nullable(),
16
- claimed_by: Uuid.nullable(),
17
- claimed_at: z.string().nullable(),
18
- created_at: z.string(),
19
- created_by: Uuid.nullable()
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
- /** Zod schema for invite data with resolved creator/claimer usernames. */
22
- export const InviteWithUsernamesJson = InviteJson.extend({
23
- created_by_username: z.string().nullable(),
24
- claimed_by_username: z.string().nullable()
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;AAqO1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,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"}
@@ -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
  /**
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The name grammar the auth vocabularies share: runs of lowercase letters
3
+ * joined by single underscores, at most `NAME_LENGTH_MAX` characters.
4
+ *
5
+ * Role names (`RoleName`), scope kinds (`ScopeKindName`), grant paths
6
+ * (`GrantPathName`), credential types (`CredentialTypeName`) and a token's
7
+ * `surface:` name (`is_route_scope_capability`) all hold it, and the audit
8
+ * event type (`AuditEventTypeName`) takes its length cap over a grammar of its
9
+ * own. Each domain keeps its own label in its messages, so the rule is shared
10
+ * and the wording is not: `create_name_schema('Role')` says
11
+ * `Role names must …`. The Rust spine's `is_valid_name` and `NAME_LENGTH_MAX`
12
+ * are its twin.
13
+ *
14
+ * @module
15
+ */
16
+ import type { z } from 'zod';
17
+ /**
18
+ * The longest name the grammar admits, in UTF-16 code units (what
19
+ * `String.length` measures; for a name on `NAME_REGEX` they are its
20
+ * characters). A name is caller-chosen text until it passes the grammar, and
21
+ * some are copied into a row or an audit row where they enter, so the grammar
22
+ * bounds the length too. Same value as the Rust spine's `NAME_LENGTH_MAX`.
23
+ */
24
+ export declare const NAME_LENGTH_MAX = 64;
25
+ /**
26
+ * The grammar of a name: runs of lowercase letters (a-z) joined by single
27
+ * underscores. Rejects empty strings, leading, trailing or consecutive
28
+ * underscores, uppercase, digits, and the partial unique indexes' `'GLOBAL'`
29
+ * token.
30
+ */
31
+ export declare const NAME_REGEX: RegExp;
32
+ /**
33
+ * Whether `name` is on the grammar and within `NAME_LENGTH_MAX`.
34
+ *
35
+ * @param name - the name to check
36
+ * @returns `true` when `name` matches `NAME_REGEX` and is at most `NAME_LENGTH_MAX` long
37
+ */
38
+ export declare const is_valid_name: (name: string) => boolean;
39
+ /**
40
+ * The message of a name longer than `NAME_LENGTH_MAX`.
41
+ *
42
+ * @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
43
+ * @returns `<label> names must be at most 64 characters`
44
+ */
45
+ export declare const format_name_length_message: (label: string) => string;
46
+ /**
47
+ * The message of a name off `NAME_REGEX`.
48
+ *
49
+ * @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
50
+ * @returns `<label> names must be lowercase letters and underscores (a-z_), no leading, trailing or consecutive underscores`
51
+ */
52
+ export declare const format_name_pattern_message: (label: string) => string;
53
+ /**
54
+ * A Zod schema for a name of one domain: `bounded_string` at
55
+ * `NAME_LENGTH_MAX`, then `NAME_REGEX`, each with the domain's message. A
56
+ * string both too long and off the grammar gets both issues, the length one
57
+ * first.
58
+ *
59
+ * @param label - the domain's label, capitalized, e.g. `'Role'` or `'Scope-kind'`
60
+ * @returns the name schema
61
+ */
62
+ export declare const create_name_schema: (label: string) => z.ZodString;
63
+ //# sourceMappingURL=name_schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/name_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAyB,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OACW,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,KAAG,MACI,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GAAI,OAAO,MAAM,KAAG,MACuD,CAAC;AAEpH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,CAAC,CAAC,SAII,CAAC"}