@fuzdev/fuz_app 0.135.0 → 0.137.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/actions/CLAUDE.md +2 -2
- package/dist/actions/action_spec.d.ts +0 -48
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/CLAUDE.md +8 -2
- package/dist/auth/account_action_specs.d.ts +7 -0
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +12 -3
- package/dist/auth/account_schema.d.ts +1 -6
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +1 -0
- package/dist/auth/actor_search_action_specs.d.ts +1 -1
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +3 -6
- package/dist/auth/audit_emitter.d.ts +4 -0
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +18 -2
- package/dist/auth/cell_action_specs.d.ts +11 -1
- package/dist/auth/cell_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_action_specs.js +18 -5
- package/dist/auth/cell_item_action_specs.d.ts.map +1 -1
- package/dist/auth/cell_item_action_specs.js +2 -4
- package/dist/auth/password.d.ts +2 -2
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +10 -12
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +9 -9
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +2 -1
- package/dist/auth/role_grant_offer_schema.d.ts +1 -1
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_schema.js +4 -7
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +5 -4
- package/dist/auth/scope_kind_schema.d.ts +10 -0
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +15 -3
- package/dist/cli/args.d.ts +21 -15
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +40 -16
- package/dist/cli/daemon.d.ts +0 -5
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/help.d.ts +45 -6
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +81 -4
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/http/CLAUDE.md +1 -1
- package/dist/http/auth_shape.d.ts +0 -27
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/body_limit.d.ts +27 -14
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +29 -16
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +5 -3
- package/dist/primitive_schemas.d.ts +38 -4
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +77 -13
- package/dist/server/x_accel.d.ts +0 -1
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/testing/CLAUDE.md +36 -19
- package/dist/testing/audit_drift_guard.d.ts +18 -5
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +24 -8
- package/dist/testing/cross_backend/action_manifest.d.ts +0 -14
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.d.ts +18 -5
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +233 -34
- package/dist/testing/cross_backend/body_size_smuggling.d.ts +0 -12
- package/dist/testing/cross_backend/body_size_smuggling.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size_smuggling.js +92 -147
- package/dist/testing/cross_backend/capabilities.d.ts +3 -24
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +1 -4
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +31 -2
- package/dist/testing/cross_backend/conformance_case.d.ts +3 -3
- package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_header_robustness.js +18 -54
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +2 -8
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +2 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +5 -9
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +5 -0
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -14
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +65 -0
- package/dist/testing/schema_introspect.d.ts +24 -4
- package/dist/testing/schema_introspect.d.ts.map +1 -1
- package/dist/testing/schema_introspect.js +27 -4
- package/dist/testing/transports/raw_http.d.ts +78 -0
- package/dist/testing/transports/raw_http.d.ts.map +1 -0
- package/dist/testing/transports/raw_http.js +141 -0
- package/package.json +7 -5
- package/dist/env/resolve.d.ts +0 -163
- package/dist/env/resolve.d.ts.map +0 -1
- package/dist/env/resolve.js +0 -267
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { z } from 'zod';
|
|
24
24
|
import { Uuid } from '@fuzdev/fuz_util/id.ts';
|
|
25
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
25
26
|
import { ERROR_INSUFFICIENT_PERMISSIONS, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
|
|
26
27
|
import { RoleName } from './role_schema.js';
|
|
28
|
+
import { SCOPE_KIND_LENGTH_MAX } from './scope_kind_schema.js';
|
|
27
29
|
import { ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX, RoleGrantOfferJson } from './role_grant_offer_schema.js';
|
|
28
30
|
import { ROLE_GRANT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
|
|
29
31
|
import { ActingActor } from '../http/auth_shape.js';
|
|
@@ -63,8 +65,10 @@ export const is_grant_scope_paired = (input) => (input.scope_kind == null) === (
|
|
|
63
65
|
/** The message a half-scoped grant input fails with — the grant inputs' refine, and the UI's pre-RPC guard. */
|
|
64
66
|
export const GRANT_SCOPE_PAIRED_MESSAGE = "'scope_kind' and 'scope_id' must be given together (both for a scoped grant, neither for a global one)";
|
|
65
67
|
/** The `scope_kind` field both grant inputs share, paired with `scope_id`. */
|
|
66
|
-
const GrantScopeKind =
|
|
67
|
-
|
|
68
|
+
const GrantScopeKind = bounded_string({ max: SCOPE_KIND_LENGTH_MAX })
|
|
69
|
+
.nullish()
|
|
70
|
+
.meta({
|
|
71
|
+
description: `Machine-readable kind tag for \`scope_id\` — paired-null with \`scope_id\` (both null for global, both non-null for scoped). Required iff \`scope_id\` is set. At most ${SCOPE_KIND_LENGTH_MAX} characters.`
|
|
68
72
|
});
|
|
69
73
|
// -- Input/output schemas ---------------------------------------------------
|
|
70
74
|
/**
|
|
@@ -89,9 +93,7 @@ export const RoleGrantOfferCreateInput = z
|
|
|
89
93
|
scope_id: Uuid.nullish().meta({
|
|
90
94
|
description: 'Scope id for resource-scoped grants (e.g. classroom id). `null` for global.'
|
|
91
95
|
}),
|
|
92
|
-
message:
|
|
93
|
-
.string()
|
|
94
|
-
.max(ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX)
|
|
96
|
+
message: bounded_string({ max: ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX })
|
|
95
97
|
.nullish()
|
|
96
98
|
.meta({ description: 'Optional free-form note from the grantor.' }),
|
|
97
99
|
acting: ActingActor
|
|
@@ -105,9 +107,7 @@ export const RoleGrantOfferAcceptInput = z.strictObject({
|
|
|
105
107
|
/** Input for `role_grant_offer_decline`. */
|
|
106
108
|
export const RoleGrantOfferDeclineInput = z.strictObject({
|
|
107
109
|
offer_id: Uuid.meta({ description: 'The offer to decline.' }),
|
|
108
|
-
reason:
|
|
109
|
-
.string()
|
|
110
|
-
.max(ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX)
|
|
110
|
+
reason: bounded_string({ max: ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX })
|
|
111
111
|
.nullish()
|
|
112
112
|
.meta({ description: 'Optional free-form reason given on decline.' }),
|
|
113
113
|
acting: ActingActor
|
|
@@ -136,7 +136,7 @@ export const RoleGrantOfferListInput = z
|
|
|
136
136
|
export const RoleGrantRevokeInput = z.strictObject({
|
|
137
137
|
actor_id: Uuid.meta({ description: 'Actor whose role_grant to revoke.' }),
|
|
138
138
|
role_grant_id: Uuid.meta({ description: 'The role_grant to revoke.' }),
|
|
139
|
-
reason:
|
|
139
|
+
reason: bounded_string({ max: ROLE_GRANT_REVOKED_REASON_LENGTH_MAX }).nullish().meta({
|
|
140
140
|
description: 'Optional free-form reason; stamped on `role_grant.revoked_reason` and surfaced on the revokee WS notification.'
|
|
141
141
|
}),
|
|
142
142
|
acting: ActingActor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_notifications.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAsB,KAAK,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"role_grant_offer_notifications.d.ts","sourceRo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AAC;AAEpF,eAAO,MAAM,6CAA6C,GACzD,QAAQ,6BAA6B,KACnC,mBACiF,CAAC;AAErF,eAAO,MAAM,oCAAoC,GAChD,QAAQ,qBAAqB,KAC3B,mBACwE,CAAC"}
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
import { z } from 'zod';
|
|
33
33
|
import { Uuid as UuidSchema } from '@fuzdev/fuz_util/id.ts';
|
|
34
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
34
35
|
import { create_action_event_spec } from '../actions/action_bridge.js';
|
|
35
36
|
import { create_jsonrpc_notification } from '../http/jsonrpc_helpers.js';
|
|
36
37
|
import { RoleName } from './role_schema.js';
|
|
@@ -89,7 +90,7 @@ export const RoleGrantRevokeParams = z.strictObject({
|
|
|
89
90
|
role_grant_id: UuidSchema,
|
|
90
91
|
role: RoleName,
|
|
91
92
|
scope_id: UuidSchema.nullable(),
|
|
92
|
-
reason:
|
|
93
|
+
reason: bounded_string({ max: ROLE_GRANT_REVOKED_REASON_LENGTH_MAX }).nullable()
|
|
93
94
|
});
|
|
94
95
|
// -- Action specs -----------------------------------------------------------
|
|
95
96
|
export const role_grant_offer_received_notification_spec = {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { Uuid } from '@fuzdev/fuz_util/id.ts';
|
|
16
|
-
/** Maximum length of the optional message attached to an offer. */
|
|
16
|
+
/** Maximum length of the optional message attached to an offer, and of a decline reason, in UTF-16 code units. */
|
|
17
17
|
export declare const ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX = 500;
|
|
18
18
|
/** Default TTL for a newly created offer — 30 days. Matches GitHub org-invite expiry. */
|
|
19
19
|
export declare const ROLE_GRANT_OFFER_DEFAULT_TTL_MS: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"role_grant_offer_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAK9C,kHAAkH;AAClH,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,yFAAyF;AACzF,eAAO,MAAM,+BAA+B,QAA2B,CAAC;AAExE,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,IAAI,CAAC;IACT,aAAa,EAAE,IAAI,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;IACpB;;;;;;;;;;;OAWG;IACH,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,uBAAuB,EAAE,IAAI,GAAG,IAAI,CAAC;IACrC;;;;;;;OAOG;IACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACtD,eAAe,EAAE,IAAI,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACzC,aAAa,EAAE,IAAI,CAAC;IACpB,aAAa,EAAE,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,IAAI,CAAC;CACjB;AAED,wDAAwD;AACxD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;kBAgD4D,CAAC;AAC5F,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,gEAAgE;AAChE,eAAO,MAAM,wBAAwB,GAAI,OAAO,cAAc,KAAG,kBAiB/D,CAAC"}
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
15
|
import { Uuid } from '@fuzdev/fuz_util/id.ts';
|
|
16
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
16
17
|
import { RoleName } from './role_schema.js';
|
|
17
|
-
/** Maximum length of the optional message attached to an offer. */
|
|
18
|
+
/** Maximum length of the optional message attached to an offer, and of a decline reason, in UTF-16 code units. */
|
|
18
19
|
export const ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX = 500;
|
|
19
20
|
/** Default TTL for a newly created offer — 30 days. Matches GitHub org-invite expiry. */
|
|
20
21
|
export const ROLE_GRANT_OFFER_DEFAULT_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
|
@@ -34,9 +35,7 @@ export const RoleGrantOfferJson = z
|
|
|
34
35
|
scope_id: Uuid.nullable().meta({
|
|
35
36
|
description: 'Scope the offered role_grant applies to (e.g. a classroom id). `null` for global role_grants.'
|
|
36
37
|
}),
|
|
37
|
-
message:
|
|
38
|
-
.string()
|
|
39
|
-
.max(ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX)
|
|
38
|
+
message: bounded_string({ max: ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX })
|
|
40
39
|
.nullable()
|
|
41
40
|
.meta({ description: 'Optional free-form note from the grantor.' }),
|
|
42
41
|
created_at: z.string().meta({ description: 'ISO timestamp when the offer was created.' }),
|
|
@@ -51,9 +50,7 @@ export const RoleGrantOfferJson = z
|
|
|
51
50
|
.string()
|
|
52
51
|
.nullable()
|
|
53
52
|
.meta({ description: 'ISO timestamp when the offer was declined.' }),
|
|
54
|
-
decline_reason:
|
|
55
|
-
.string()
|
|
56
|
-
.max(ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX)
|
|
53
|
+
decline_reason: bounded_string({ max: ROLE_GRANT_OFFER_MESSAGE_LENGTH_MAX })
|
|
57
54
|
.nullable()
|
|
58
55
|
.meta({ description: 'Optional reason given on decline.' }),
|
|
59
56
|
retracted_at: z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEN,KAAK,0BAA0B,EAC/B,MAAM,6BAA6B,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AAuG;IACvG,gBAAgB,CAAC,EAAE,0BAA0B,CAAC;IAC9C,+FAA+F;IAC/F,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,oFAAoF;IACpF,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAChC,0GAA0G;IAC1G,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,yEAAyE;IACzE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC1C;AAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,kBAAkB,GAC9B,gBAAgB,aAAa,CAAC,QAAQ,CAAC,EACvC,UAAS,uBAA4B,KACnC,gBA2CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC/B,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,MAAM,MAAM,EACZ,YAAY,MAAM,KAChB,OAGF,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,GACtC,YAAY,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,EACzC,YAAY,MAAM,KAChB,KAAK,CAAC,MAAM,CAMd,CAAC"}
|
package/dist/auth/role_schema.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
23
|
import { z } from 'zod';
|
|
24
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
24
25
|
import { CREDENTIAL_TYPE_DAEMON_TOKEN } from './credential_type_schema.js';
|
|
25
26
|
import { GRANT_PATH_ADMIN, GRANT_PATH_BOOTSTRAP } from './grant_path_schema.js';
|
|
26
27
|
/**
|
|
@@ -34,10 +35,10 @@ export const ROLE_NAME_LENGTH_MAX = 64;
|
|
|
34
35
|
* Valid role name: lowercase letters and underscores, no leading/trailing
|
|
35
36
|
* underscore, at most `ROLE_NAME_LENGTH_MAX` characters.
|
|
36
37
|
*/
|
|
37
|
-
export const RoleName =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
export const RoleName = bounded_string({
|
|
39
|
+
max: ROLE_NAME_LENGTH_MAX,
|
|
40
|
+
max_message: `Role names must be at most ${ROLE_NAME_LENGTH_MAX} characters`
|
|
41
|
+
}).regex(/^[a-z][a-z_]*[a-z]$|^[a-z]$/, 'Role names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
|
|
41
42
|
// Builtin roles — provided by fuz_app, always available.
|
|
42
43
|
/** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
|
|
43
44
|
export const ROLE_KEEPER = 'keeper';
|
|
@@ -37,6 +37,16 @@ import { z } from 'zod';
|
|
|
37
37
|
* `'GLOBAL'` token.
|
|
38
38
|
*/
|
|
39
39
|
export declare const SCOPE_KIND_NAME_REGEX: RegExp;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum length of a `scope_kind`, in UTF-16 code units (what
|
|
42
|
+
* `String.length` measures; enforced by `bounded_string`). Bounds the tag where it enters
|
|
43
|
+
* — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
|
|
44
|
+
* into the row and its audit metadata — and a registered name, so no
|
|
45
|
+
* registry declares a kind the grant inputs would refuse. Same value as
|
|
46
|
+
* `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
|
|
47
|
+
* spine's `SCOPE_KIND_LENGTH_MAX`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const SCOPE_KIND_LENGTH_MAX = 64;
|
|
40
50
|
/** Zod schema for valid scope-kind name strings. */
|
|
41
51
|
export declare const ScopeKindName: z.ZodString;
|
|
42
52
|
export type ScopeKindName = z.infer<typeof ScopeKindName>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"scope_kind_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/scope_kind_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,QAAgC,CAAC;AAEnE;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,oDAAoD;AACpD,eAAO,MAAM,aAAa,aAMzB,CAAC;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACrC;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,gBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,qBAwBF,CAAC"}
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* @module
|
|
31
31
|
*/
|
|
32
32
|
import { z } from 'zod';
|
|
33
|
+
import { bounded_string } from '../primitive_schemas.js';
|
|
33
34
|
/**
|
|
34
35
|
* Letter (lowercase a-z) start and end (or single letter), with letters
|
|
35
36
|
* and underscores in between. Mirrors `RoleName`. Rejects empty strings,
|
|
@@ -37,10 +38,21 @@ import { z } from 'zod';
|
|
|
37
38
|
* `'GLOBAL'` token.
|
|
38
39
|
*/
|
|
39
40
|
export const SCOPE_KIND_NAME_REGEX = /^[a-z][a-z_]*[a-z]$|^[a-z]$/;
|
|
41
|
+
/**
|
|
42
|
+
* Maximum length of a `scope_kind`, in UTF-16 code units (what
|
|
43
|
+
* `String.length` measures; enforced by `bounded_string`). Bounds the tag where it enters
|
|
44
|
+
* — the grant inputs (`role_grant_offer_create`, `role_grant_assign`) copy it
|
|
45
|
+
* into the row and its audit metadata — and a registered name, so no
|
|
46
|
+
* registry declares a kind the grant inputs would refuse. Same value as
|
|
47
|
+
* `ROLE_NAME_LENGTH_MAX`, whose grammar the name mirrors, and as the Rust
|
|
48
|
+
* spine's `SCOPE_KIND_LENGTH_MAX`.
|
|
49
|
+
*/
|
|
50
|
+
export const SCOPE_KIND_LENGTH_MAX = 64;
|
|
40
51
|
/** Zod schema for valid scope-kind name strings. */
|
|
41
|
-
export const ScopeKindName =
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
export const ScopeKindName = bounded_string({
|
|
53
|
+
max: SCOPE_KIND_LENGTH_MAX,
|
|
54
|
+
max_message: `Scope-kind names must be at most ${SCOPE_KIND_LENGTH_MAX} characters`
|
|
55
|
+
}).regex(SCOPE_KIND_NAME_REGEX, 'Scope-kind names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
|
|
44
56
|
/**
|
|
45
57
|
* Create a scope-kind schema from a consumer-declared registry.
|
|
46
58
|
*
|
package/dist/cli/args.d.ts
CHANGED
|
@@ -3,45 +3,51 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides `parse_command_args` for schema-validated command parsing and
|
|
5
5
|
* `create_extract_global_flags` as a factory for project-specific global flag extraction.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Both take `@fuzdev/fuz_schema` object schemas, the schemas `args_parse` from
|
|
8
|
+
* `@fuzdev/fuz_util/args.ts` reads, with aliases given by `meta(entry, {aliases})`.
|
|
7
9
|
*
|
|
8
10
|
* @module
|
|
9
11
|
*/
|
|
10
12
|
import { type ParsedArgs } from '@fuzdev/fuz_util/args.ts';
|
|
11
|
-
import {
|
|
13
|
+
import { type Schema } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
14
|
/**
|
|
13
15
|
* Discriminated union result for CLI argument parsing.
|
|
14
16
|
*/
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export type ParseCommandArgsResult<T> = {
|
|
18
|
+
ok: true;
|
|
19
|
+
value: T;
|
|
18
20
|
} | {
|
|
19
|
-
|
|
21
|
+
ok: false;
|
|
20
22
|
error: string;
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
|
-
* Parse command-specific args against a
|
|
25
|
+
* Parse command-specific args against a fuz_schema object schema.
|
|
24
26
|
*
|
|
25
27
|
* Validates `remaining` args (after global flag extraction) with alias expansion
|
|
26
|
-
* and returns a typed result or
|
|
28
|
+
* and returns a typed result or an error string, each issue formatted by
|
|
29
|
+
* `format_issue` on a line of its own.
|
|
27
30
|
*
|
|
28
31
|
* @param remaining - remaining args after global flag extraction
|
|
29
|
-
* @param schema -
|
|
30
|
-
* @returns parse result with typed
|
|
32
|
+
* @param schema - fuz_schema object schema for the command
|
|
33
|
+
* @returns parse result with the typed value or an error message
|
|
31
34
|
*/
|
|
32
|
-
export declare const parse_command_args: <T extends Record<string, unknown>>(remaining: ParsedArgs, schema:
|
|
35
|
+
export declare const parse_command_args: <T extends Record<string, unknown>>(remaining: ParsedArgs, schema: Schema<T, any>) => ParseCommandArgsResult<T>;
|
|
33
36
|
/**
|
|
34
37
|
* Create a project-specific global flag extractor.
|
|
35
38
|
*
|
|
36
39
|
* Returns a function that separates global flags from command-specific args.
|
|
37
|
-
* The schema defines which flags are global (with aliases via
|
|
38
|
-
* and the fallback provides defaults
|
|
40
|
+
* The schema defines which flags are global (with aliases via `meta(entry, {aliases})`,
|
|
41
|
+
* read on any wrapper layer of the entry), and the fallback provides defaults
|
|
42
|
+
* when parsing fails. Every entry is global, both of a `no-` pair like `color`
|
|
43
|
+
* and `no-color` included, so `--no-color`, which `argv_parse` reads as
|
|
44
|
+
* `color: false`, never lands in `remaining`.
|
|
39
45
|
*
|
|
40
|
-
* @param schema -
|
|
46
|
+
* @param schema - fuz_schema object schema for global flags
|
|
41
47
|
* @param fallback - default values when parsing fails
|
|
42
48
|
* @returns extractor function `(unparsed) => {flags, remaining}`
|
|
43
49
|
*/
|
|
44
|
-
export declare const create_extract_global_flags: <T extends Record<string, unknown>>(schema:
|
|
50
|
+
export declare const create_extract_global_flags: <T extends Record<string, unknown>>(schema: Schema<T, any>, fallback: T) => ((unparsed: ParsedArgs) => {
|
|
45
51
|
flags: T;
|
|
46
52
|
remaining: ParsedArgs;
|
|
47
53
|
});
|
package/dist/cli/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAyB,KAAK,UAAU,EAAiB,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGzE;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9F;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnE,WAAW,UAAU,EACrB,QAAQ,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,KACpB,sBAAsB,CAAC,CAAC,CAM1B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5E,QAAQ,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACtB,UAAU,CAAC,KACT,CAAC,CAAC,QAAQ,EAAE,UAAU,KAAK;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CA4ChE,CAAC"}
|
package/dist/cli/args.js
CHANGED
|
@@ -3,46 +3,59 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides `parse_command_args` for schema-validated command parsing and
|
|
5
5
|
* `create_extract_global_flags` as a factory for project-specific global flag extraction.
|
|
6
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* Both take `@fuzdev/fuz_schema` object schemas, the schemas `args_parse` from
|
|
8
|
+
* `@fuzdev/fuz_util/args.ts` reads, with aliases given by `meta(entry, {aliases})`.
|
|
7
9
|
*
|
|
8
10
|
* @module
|
|
9
11
|
*/
|
|
10
12
|
import { args_parse } from '@fuzdev/fuz_util/args.ts';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { format_issue } from '@fuzdev/fuz_schema/schema.ts';
|
|
14
|
+
import { get_schema_entries, get_schema_meta } from '@fuzdev/fuz_schema/introspect.ts';
|
|
13
15
|
/**
|
|
14
|
-
* Parse command-specific args against a
|
|
16
|
+
* Parse command-specific args against a fuz_schema object schema.
|
|
15
17
|
*
|
|
16
18
|
* Validates `remaining` args (after global flag extraction) with alias expansion
|
|
17
|
-
* and returns a typed result or
|
|
19
|
+
* and returns a typed result or an error string, each issue formatted by
|
|
20
|
+
* `format_issue` on a line of its own.
|
|
18
21
|
*
|
|
19
22
|
* @param remaining - remaining args after global flag extraction
|
|
20
|
-
* @param schema -
|
|
21
|
-
* @returns parse result with typed
|
|
23
|
+
* @param schema - fuz_schema object schema for the command
|
|
24
|
+
* @returns parse result with the typed value or an error message
|
|
22
25
|
*/
|
|
23
26
|
export const parse_command_args = (remaining, schema) => {
|
|
24
27
|
const parsed = args_parse(remaining, schema);
|
|
25
|
-
if (!parsed.
|
|
26
|
-
return {
|
|
28
|
+
if (!parsed.ok) {
|
|
29
|
+
return { ok: false, error: parsed.issues.map(format_issue).join('\n') };
|
|
27
30
|
}
|
|
28
|
-
return {
|
|
31
|
+
return { ok: true, value: parsed.value };
|
|
29
32
|
};
|
|
30
33
|
/**
|
|
31
34
|
* Create a project-specific global flag extractor.
|
|
32
35
|
*
|
|
33
36
|
* Returns a function that separates global flags from command-specific args.
|
|
34
|
-
* The schema defines which flags are global (with aliases via
|
|
35
|
-
* and the fallback provides defaults
|
|
37
|
+
* The schema defines which flags are global (with aliases via `meta(entry, {aliases})`,
|
|
38
|
+
* read on any wrapper layer of the entry), and the fallback provides defaults
|
|
39
|
+
* when parsing fails. Every entry is global, both of a `no-` pair like `color`
|
|
40
|
+
* and `no-color` included, so `--no-color`, which `argv_parse` reads as
|
|
41
|
+
* `color: false`, never lands in `remaining`.
|
|
36
42
|
*
|
|
37
|
-
* @param schema -
|
|
43
|
+
* @param schema - fuz_schema object schema for global flags
|
|
38
44
|
* @param fallback - default values when parsing fails
|
|
39
45
|
* @returns extractor function `(unparsed) => {flags, remaining}`
|
|
40
46
|
*/
|
|
41
47
|
export const create_extract_global_flags = (schema, fallback) => {
|
|
42
48
|
return (unparsed) => {
|
|
43
49
|
// get all global flag names and aliases from schema
|
|
44
|
-
const
|
|
45
|
-
const
|
|
50
|
+
const global_props = to_global_props(schema);
|
|
51
|
+
const global_names = new Set();
|
|
52
|
+
for (const prop of global_props) {
|
|
53
|
+
if (prop.name === '_')
|
|
54
|
+
continue;
|
|
55
|
+
global_names.add(prop.name);
|
|
56
|
+
for (const alias of prop.aliases)
|
|
57
|
+
global_names.add(alias);
|
|
58
|
+
}
|
|
46
59
|
// extract global flag values, handling aliases
|
|
47
60
|
const flags_input = {};
|
|
48
61
|
for (const prop of global_props) {
|
|
@@ -61,7 +74,7 @@ export const create_extract_global_flags = (schema, fallback) => {
|
|
|
61
74
|
}
|
|
62
75
|
// parse global flags
|
|
63
76
|
const global_parsed = args_parse(flags_input, schema);
|
|
64
|
-
const flags = global_parsed.
|
|
77
|
+
const flags = global_parsed.ok ? global_parsed.value : fallback;
|
|
65
78
|
// build remaining args without global flags
|
|
66
79
|
const remaining = { _: [...unparsed._] };
|
|
67
80
|
for (const [key, value] of Object.entries(unparsed)) {
|
|
@@ -74,3 +87,14 @@ export const create_extract_global_flags = (schema, fallback) => {
|
|
|
74
87
|
return { flags, remaining };
|
|
75
88
|
};
|
|
76
89
|
};
|
|
90
|
+
// each entry of an object schema with its aliases, a `no-` pair as two entries
|
|
91
|
+
const to_global_props = (schema) => {
|
|
92
|
+
const entries = get_schema_entries(schema);
|
|
93
|
+
if (!entries)
|
|
94
|
+
return [];
|
|
95
|
+
const props = [];
|
|
96
|
+
for (const name in entries) {
|
|
97
|
+
props.push({ name, aliases: get_schema_meta(entries[name], 'aliases') ?? [] });
|
|
98
|
+
}
|
|
99
|
+
return props;
|
|
100
|
+
};
|
package/dist/cli/daemon.d.ts
CHANGED
|
@@ -13,15 +13,10 @@ import { type CommandDeps, type EnvDeps, type FetchDeps, type FsReadDeps, type F
|
|
|
13
13
|
* Daemon info schema for `~/.{name}/run/daemon.json`.
|
|
14
14
|
*/
|
|
15
15
|
export declare const DaemonInfo: z.ZodObject<{
|
|
16
|
-
/** Schema version. */
|
|
17
16
|
version: z.ZodNumber;
|
|
18
|
-
/** Server process ID. */
|
|
19
17
|
pid: z.ZodNumber;
|
|
20
|
-
/** Port the server is listening on. */
|
|
21
18
|
port: z.ZodNumber;
|
|
22
|
-
/** ISO timestamp when server started. */
|
|
23
19
|
started: z.ZodString;
|
|
24
|
-
/** Package version of the application. */
|
|
25
20
|
app_version: z.ZodString;
|
|
26
21
|
}, z.core.$strict>;
|
|
27
22
|
export type DaemonInfo = z.infer<typeof DaemonInfo>;
|
package/dist/cli/daemon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/daemon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"daemon.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/daemon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;kBAWrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EACjC,MAAM,MAAM,KACV,MAAM,GAAG,IAGX,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,iBAAiB,GAAG,QAAQ,CAAC,EAC7F,MAAM,MAAM,EACZ,MAAM,UAAU,KACd,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAAG,OAAO,EACzF,MAAM,MAAM,KACV,OAAO,CAAC,UAAU,GAAG,IAAI,CAwB3B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAU,SAAS,WAAW,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,OAAO,CAG1F,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,MAAM,MAAM,EACZ,aAAkB,EAClB,mBAAiB,KACf,OAAO,CAAC,OAAO,CAYjB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GACvB,SAAS,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAChC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAAC,GAC3C,YAAY,GACZ,WAAW,GACX,OAAO,EACR,MAAM,MAAM,KACV,OAAO,CAAC,gBAAgB,CA2C1B,CAAC"}
|
package/dist/cli/help.d.ts
CHANGED
|
@@ -5,15 +5,20 @@
|
|
|
5
5
|
* once with `create_help` and get back `generate_main_help`,
|
|
6
6
|
* `generate_command_help`, and `get_help_text`.
|
|
7
7
|
*
|
|
8
|
+
* Schemas are `@fuzdev/fuz_schema` object schemas, the ones `parse_command_args`
|
|
9
|
+
* and `create_extract_global_flags` take, read with fuz_schema's `introspect.ts`:
|
|
10
|
+
* each entry's `description` and `aliases` metadata, its default, and its type
|
|
11
|
+
* as `format_schema_type` renders it.
|
|
12
|
+
*
|
|
8
13
|
* @module
|
|
9
14
|
*/
|
|
10
|
-
import type {
|
|
11
|
-
import { type ZodSchemaProperty } from '@fuzdev/fuz_util/zod.ts';
|
|
15
|
+
import type { AnySchema } from '@fuzdev/fuz_schema/schema.ts';
|
|
12
16
|
/**
|
|
13
17
|
* Command metadata for help generation.
|
|
14
18
|
*/
|
|
15
19
|
export interface CommandMeta<TCategory extends string = string> {
|
|
16
|
-
schema
|
|
20
|
+
/** fuz_schema object schema for the command's args. */
|
|
21
|
+
schema?: AnySchema;
|
|
17
22
|
summary: string;
|
|
18
23
|
usage: string;
|
|
19
24
|
category: TCategory;
|
|
@@ -41,8 +46,8 @@ export interface HelpOptions<TCategory extends string = string> {
|
|
|
41
46
|
categories: Array<HelpCategory<TCategory>>;
|
|
42
47
|
/** Example commands for main help. */
|
|
43
48
|
examples: Array<string>;
|
|
44
|
-
/**
|
|
45
|
-
global_args_schema:
|
|
49
|
+
/** fuz_schema object schema for global arguments (shown in all help output). */
|
|
50
|
+
global_args_schema: AnySchema;
|
|
46
51
|
/** Whether to use ANSI colors in output. Defaults to `true`. */
|
|
47
52
|
use_colors?: boolean;
|
|
48
53
|
}
|
|
@@ -57,6 +62,40 @@ export interface HelpGenerator {
|
|
|
57
62
|
/** Get help text for a command or main help. */
|
|
58
63
|
get_help_text: (command?: string, subcommand?: string) => string;
|
|
59
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* One arg as help output shows it, read from an entry of an object schema.
|
|
67
|
+
*/
|
|
68
|
+
export interface HelpArgProperty {
|
|
69
|
+
/** The entry's key, `_` for positionals. */
|
|
70
|
+
name: string;
|
|
71
|
+
/** The type the entry accepts, as `format_schema_type` renders it. */
|
|
72
|
+
type: string;
|
|
73
|
+
/** The `description` metadata, or `''`. */
|
|
74
|
+
description: string;
|
|
75
|
+
/** The default, made by calling a `with_default_fn`'s function, or `undefined`. */
|
|
76
|
+
default: unknown;
|
|
77
|
+
/** The `aliases` metadata, or `[]`. */
|
|
78
|
+
aliases: Array<string>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Read the args of an object schema for help output, in order.
|
|
82
|
+
*
|
|
83
|
+
* An entry whose `no-` negation is also an entry is left out, so a pair like
|
|
84
|
+
* `color` and `no-color` is shown once, as `--no-color`.
|
|
85
|
+
*
|
|
86
|
+
* @param schema - fuz_schema object schema
|
|
87
|
+
* @returns the args, none when `schema` is not an object schema
|
|
88
|
+
*/
|
|
89
|
+
export declare const to_help_arg_properties: (schema: AnySchema) => Array<HelpArgProperty>;
|
|
90
|
+
/**
|
|
91
|
+
* Format a default value for display, `''` for none.
|
|
92
|
+
*
|
|
93
|
+
* Strings and arrays are written as JSON, as the type column writes a string literal.
|
|
94
|
+
*
|
|
95
|
+
* @param value - the default
|
|
96
|
+
* @returns display text
|
|
97
|
+
*/
|
|
98
|
+
export declare const format_arg_default: (value: unknown) => string;
|
|
60
99
|
/**
|
|
61
100
|
* Get maximum length from array.
|
|
62
101
|
*
|
|
@@ -74,7 +113,7 @@ export declare const to_max_length: <T>(items: Array<T>, to_string: (item: T) =>
|
|
|
74
113
|
* @param prop - schema property
|
|
75
114
|
* @returns formatted name string
|
|
76
115
|
*/
|
|
77
|
-
export declare const format_arg_name: (prop:
|
|
116
|
+
export declare const format_arg_name: (prop: HelpArgProperty) => string;
|
|
78
117
|
/**
|
|
79
118
|
* Create a help generator configured for an application.
|
|
80
119
|
*
|
package/dist/cli/help.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/help.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/cli/help.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,SAA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