@fuzdev/fuz_app 0.13.0 → 0.14.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.
@@ -37,6 +37,22 @@ export interface ActionContext {
37
37
  pending_effects: Array<Promise<void>>;
38
38
  /** Logger instance. */
39
39
  log: Logger;
40
+ /**
41
+ * Send a request-scoped JSON-RPC notification to the originator.
42
+ *
43
+ * On streaming transports (WebSocket) this routes to the originating
44
+ * connection only. On the HTTP RPC transport this is a no-op with a
45
+ * DEV-mode warn — non-streaming transports have no channel for mid-
46
+ * request notifications. The `streams` field on an `ActionSpec` names
47
+ * the notification method this handler is expected to emit.
48
+ */
49
+ notify: (method: string, params: unknown) => void;
50
+ /**
51
+ * AbortSignal that fires when the originating request is cancelled
52
+ * (client disconnect on HTTP, socket close on WebSocket). Streaming
53
+ * handlers should check this for early termination.
54
+ */
55
+ signal: AbortSignal;
40
56
  }
41
57
  /**
42
58
  * Handler function for an RPC action.
@@ -1 +1 @@
1
- {"version":3,"file":"action_rpc.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAoB,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAgC,KAAK,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE9F,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AAEpC,OAAO,EAGN,KAAK,gBAAgB,EAGrB,MAAM,oBAAoB,CAAC;AAO5B;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC7B,+DAA+D;IAC/D,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;IAC5B,iDAAiD;IACjD,UAAU,EAAE,gBAAgB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-139,6 +139,12 @@ export const create_rpc_endpoint = (options) => {
139
139
  }
140
140
  // step 5: dispatch — transaction for mutations, pool for reads
141
141
  const use_transaction = action.spec.side_effects;
142
+ const notify = (notify_method, _notify_params) => {
143
+ if (DEV) {
144
+ log.warn(`ctx.notify('${notify_method}') called on non-streaming transport; notification dropped (method=${method_name})`);
145
+ }
146
+ };
147
+ const signal = c.req.raw.signal;
142
148
  const execute = async (db) => {
143
149
  const action_context = {
144
150
  auth: request_context,
@@ -147,6 +153,8 @@ export const create_rpc_endpoint = (options) => {
147
153
  background_db: route.background_db,
148
154
  pending_effects: route.pending_effects,
149
155
  log,
156
+ notify,
157
+ signal,
150
158
  };
151
159
  const output = await action.handler(parse_result.data, action_context);
152
160
  // DEV-only output validation
@@ -51,6 +51,14 @@ export declare const ActionSpec: z.ZodObject<{
51
51
  output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
52
52
  async: z.ZodBoolean;
53
53
  description: z.ZodString;
54
+ /**
55
+ * Names the notification method this action emits as request-scoped
56
+ * progress. Forward-compatible handshake — transport-agnostic, does not
57
+ * imply a specific delivery mechanism. Registry-time validation (e.g.,
58
+ * ensuring the named method is a `remote_notification` spec) is a
59
+ * consumer-side concern.
60
+ */
61
+ streams: z.ZodOptional<z.ZodString>;
54
62
  }, z.core.$strict>;
55
63
  export type ActionSpec = z.infer<typeof ActionSpec>;
56
64
  export declare const RequestResponseActionSpec: z.ZodObject<{
@@ -64,6 +72,7 @@ export declare const RequestResponseActionSpec: z.ZodObject<{
64
72
  input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
65
73
  output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
66
74
  description: z.ZodString;
75
+ streams: z.ZodOptional<z.ZodString>;
67
76
  kind: z.ZodDefault<z.ZodLiteral<"request_response">>;
68
77
  auth: z.ZodUnion<readonly [z.ZodLiteral<"public">, z.ZodLiteral<"authenticated">, z.ZodLiteral<"keeper">, z.ZodObject<{
69
78
  role: z.ZodString;
@@ -80,6 +89,7 @@ export declare const RemoteNotificationActionSpec: z.ZodObject<{
80
89
  }>;
81
90
  input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
82
91
  description: z.ZodString;
92
+ streams: z.ZodOptional<z.ZodString>;
83
93
  kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
84
94
  auth: z.ZodDefault<z.ZodNull>;
85
95
  side_effects: z.ZodDefault<z.ZodLiteral<true>>;
@@ -103,6 +113,7 @@ export declare const LocalCallActionSpec: z.ZodObject<{
103
113
  output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
104
114
  async: z.ZodBoolean;
105
115
  description: z.ZodString;
116
+ streams: z.ZodOptional<z.ZodString>;
106
117
  kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
107
118
  auth: z.ZodDefault<z.ZodNull>;
108
119
  }, z.core.$strict>;
@@ -118,6 +129,7 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
118
129
  input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
119
130
  output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
120
131
  description: z.ZodString;
132
+ streams: z.ZodOptional<z.ZodString>;
121
133
  kind: z.ZodDefault<z.ZodLiteral<"request_response">>;
122
134
  auth: z.ZodUnion<readonly [z.ZodLiteral<"public">, z.ZodLiteral<"authenticated">, z.ZodLiteral<"keeper">, z.ZodObject<{
123
135
  role: z.ZodString;
@@ -132,6 +144,7 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
132
144
  }>;
133
145
  input: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
134
146
  description: z.ZodString;
147
+ streams: z.ZodOptional<z.ZodString>;
135
148
  kind: z.ZodDefault<z.ZodLiteral<"remote_notification">>;
136
149
  auth: z.ZodDefault<z.ZodNull>;
137
150
  side_effects: z.ZodDefault<z.ZodLiteral<true>>;
@@ -149,6 +162,7 @@ export declare const ActionSpecUnion: z.ZodUnion<readonly [z.ZodObject<{
149
162
  output: z.ZodCustom<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
150
163
  async: z.ZodBoolean;
151
164
  description: z.ZodString;
165
+ streams: z.ZodOptional<z.ZodString>;
152
166
  kind: z.ZodDefault<z.ZodLiteral<"local_call">>;
153
167
  auth: z.ZodDefault<z.ZodNull>;
154
168
  }, z.core.$strict>]>;
@@ -1 +1 @@
1
- {"version":3,"file":"action_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,eAAO,MAAM,UAAU;;;;EAAoE,CAAC;AAC5F,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEpD,eAAO,MAAM,eAAe;;;;EAA0C,CAAC;AACvE,MAAM,MAA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C,OAAO,mBAAmB,CAAC,CAAC;AAEtE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAI1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,eAKoB,CAAC;AAE9E,eAAO,MAAM,gBAAgB;;;;;;;;;;EAU3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -32,6 +32,14 @@ export const ActionSpec = z.strictObject({
32
32
  output: z.custom((v) => v instanceof z.ZodType),
33
33
  async: z.boolean(),
34
34
  description: z.string(),
35
+ /**
36
+ * Names the notification method this action emits as request-scoped
37
+ * progress. Forward-compatible handshake — transport-agnostic, does not
38
+ * imply a specific delivery mechanism. Registry-time validation (e.g.,
39
+ * ensuring the named method is a `remote_notification` spec) is a
40
+ * consumer-side concern.
41
+ */
42
+ streams: z.string().optional(),
35
43
  });
36
44
  export const RequestResponseActionSpec = ActionSpec.extend({
37
45
  kind: z.literal('request_response').default('request_response'),
@@ -1 +1 @@
1
- {"version":3,"file":"admin_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_routes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAA8C,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGpG,OAAO,EAAoC,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAcxF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAShD,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,CAAC,EACtD,UAAU,iBAAiB,KACzB,KAAK,CAAC,SAAS,CAkPjB,CAAC"}
1
+ {"version":3,"file":"admin_routes.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/admin_routes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAA8C,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAGpG,OAAO,EAAoC,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAcxF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAShD,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,gBAAgB,CAAC,EACtD,UAAU,iBAAiB,KACzB,KAAK,CAAC,SAAS,CAoPjB,CAAC"}
@@ -171,7 +171,9 @@ export const create_admin_account_route_specs = (deps, options) => {
171
171
  input: z.null(),
172
172
  output: z.strictObject({ ok: z.literal(true), revoked: z.literal(true) }),
173
173
  errors: {
174
- 403: z.looseObject({ error: z.literal(ERROR_ROLE_NOT_WEB_GRANTABLE) }),
174
+ 403: z.looseObject({
175
+ error: z.enum([ERROR_INSUFFICIENT_PERMISSIONS, ERROR_ROLE_NOT_WEB_GRANTABLE]),
176
+ }),
175
177
  404: z.looseObject({
176
178
  error: z.enum([ERROR_ACCOUNT_NOT_FOUND, ERROR_PERMIT_NOT_FOUND]),
177
179
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuzdev/fuz_app",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "fullstack app library",
5
5
  "glyph": "🗝",
6
6
  "logo": "logo.svg",