@fuzdev/fuz_app 0.98.0 → 0.98.1
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.
|
@@ -125,9 +125,25 @@ export declare const generate_phase_handlers: (spec: ActionSpecUnion, executor:
|
|
|
125
125
|
}) => string;
|
|
126
126
|
/** "DO NOT EDIT" banner naming the gen producer. */
|
|
127
127
|
export declare const create_banner: (origin_path: string) => string;
|
|
128
|
+
/**
|
|
129
|
+
* Derive the exported spec identifier for a method. Method names that aren't
|
|
130
|
+
* legal JS identifiers — e.g. the `/` in the `peer/ping` protocol action — have
|
|
131
|
+
* each run of illegal characters collapsed to a single `_`, so `peer/ping`
|
|
132
|
+
* resolves to `peer_ping_action_spec` (the export in `actions/peer_ping.ts`).
|
|
133
|
+
* Already-valid names pass through unchanged.
|
|
134
|
+
*/
|
|
128
135
|
export declare const to_action_spec_identifier: (method: string) => string;
|
|
129
136
|
export declare const to_action_spec_input_identifier: (method: string) => string;
|
|
130
137
|
export declare const to_action_spec_output_identifier: (method: string) => string;
|
|
138
|
+
/**
|
|
139
|
+
* Render a method name as an object/interface property key — bare when it's a
|
|
140
|
+
* valid JS identifier, single-quoted otherwise. Method names like `peer/ping`
|
|
141
|
+
* aren't legal as bare keys, so quoting keeps the emitted `ActionSpecs` /
|
|
142
|
+
* `ActionInputs` / `FrontendActionsApi` members valid TypeScript. Pairs with
|
|
143
|
+
* the bracketed indexed-access form (`ActionInputs['peer/ping']`) used for
|
|
144
|
+
* value/type lookups, which already accepts the raw method string.
|
|
145
|
+
*/
|
|
146
|
+
export declare const to_action_property_key: (method: string) => string;
|
|
131
147
|
/**
|
|
132
148
|
* Generates one method line of the typed `FrontendActionsApi` interface for a
|
|
133
149
|
* single spec. Encapsulates the input/options/return-type signature shape so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action_codegen.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/action_codegen.ts"],"names":[],"mapp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KAAK,MAAM,CAAC;IACjD,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,KACC,MA2CF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,oCAAoC,GAChD,SAAS,aAAa,EACtB,UAAU;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,KACC,MAqBF,CAAC;AAMF;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,aAAa,CAAC,UAAU,CAAC,EAClC,SAAS,aAAa,KACpB;IACF,YAAY,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CAiC1C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B,KAAG,MAYH,CAAC"}
|
|
@@ -296,14 +296,30 @@ export const generate_phase_handlers = (spec, executor, imports, options) => {
|
|
|
296
296
|
) => ${return_type}`;
|
|
297
297
|
})
|
|
298
298
|
.join(';\n\t\t');
|
|
299
|
-
return `${method}?: {\n\t\t${phase_handlers};\n\t}`;
|
|
299
|
+
return `${to_action_property_key(method)}?: {\n\t\t${phase_handlers};\n\t}`;
|
|
300
300
|
};
|
|
301
301
|
/** "DO NOT EDIT" banner naming the gen producer. */
|
|
302
302
|
export const create_banner = (origin_path) => `generated by ${origin_path} - DO NOT EDIT OR RISK LOST DATA`;
|
|
303
303
|
// TODO rethink these, see also zzz `codegen.ts`
|
|
304
|
-
|
|
304
|
+
/**
|
|
305
|
+
* Derive the exported spec identifier for a method. Method names that aren't
|
|
306
|
+
* legal JS identifiers — e.g. the `/` in the `peer/ping` protocol action — have
|
|
307
|
+
* each run of illegal characters collapsed to a single `_`, so `peer/ping`
|
|
308
|
+
* resolves to `peer_ping_action_spec` (the export in `actions/peer_ping.ts`).
|
|
309
|
+
* Already-valid names pass through unchanged.
|
|
310
|
+
*/
|
|
311
|
+
export const to_action_spec_identifier = (method) => `${method.replace(/[^A-Za-z0-9_$]+/g, '_')}_action_spec`;
|
|
305
312
|
export const to_action_spec_input_identifier = (method) => `${to_action_spec_identifier(method)}.input`;
|
|
306
313
|
export const to_action_spec_output_identifier = (method) => `${to_action_spec_identifier(method)}.output`;
|
|
314
|
+
/**
|
|
315
|
+
* Render a method name as an object/interface property key — bare when it's a
|
|
316
|
+
* valid JS identifier, single-quoted otherwise. Method names like `peer/ping`
|
|
317
|
+
* aren't legal as bare keys, so quoting keeps the emitted `ActionSpecs` /
|
|
318
|
+
* `ActionInputs` / `FrontendActionsApi` members valid TypeScript. Pairs with
|
|
319
|
+
* the bracketed indexed-access form (`ActionInputs['peer/ping']`) used for
|
|
320
|
+
* value/type lookups, which already accepts the raw method string.
|
|
321
|
+
*/
|
|
322
|
+
export const to_action_property_key = (method) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(method) ? method : `'${method}'`;
|
|
307
323
|
/**
|
|
308
324
|
* Generates one method line of the typed `FrontendActionsApi` interface for a
|
|
309
325
|
* single spec. Encapsulates the input/options/return-type signature shape so
|
|
@@ -379,7 +395,7 @@ export const generate_actions_api_method_signature = (spec, imports, options) =>
|
|
|
379
395
|
imports.add_type('@fuzdev/fuz_util/result.ts', 'Result');
|
|
380
396
|
imports.add_type('@fuzdev/fuz_app/http/jsonrpc.ts', 'JsonrpcErrorObject');
|
|
381
397
|
}
|
|
382
|
-
return `${spec.method}: (${input_param}${options_param}) => ${return_type};`;
|
|
398
|
+
return `${to_action_property_key(spec.method)}: (${input_param}${options_param}) => ${return_type};`;
|
|
383
399
|
};
|
|
384
400
|
// --------------------------------------------------------------------------
|
|
385
401
|
// High-level codegen helpers — compose the lower-level primitives above into
|
|
@@ -456,7 +472,7 @@ export const resolve_spec_qualifier = (imports, options) => {
|
|
|
456
472
|
return options.qualify_spec;
|
|
457
473
|
const specs_module = options?.specs_module ?? DEFAULT_SPECS_MODULE;
|
|
458
474
|
imports.add(specs_module, '* as specs');
|
|
459
|
-
return (s) => `specs.${s.method}
|
|
475
|
+
return (s) => `specs.${to_action_spec_identifier(s.method)}`;
|
|
460
476
|
};
|
|
461
477
|
/**
|
|
462
478
|
* Emit one or more `z.enum([...])` declarations for action method names —
|
|
@@ -592,8 +608,12 @@ export interface ActionSpecs {}
|
|
|
592
608
|
export const action_specs: Array<ActionSpecUnion> = Object.values(ActionSpecs);`;
|
|
593
609
|
}
|
|
594
610
|
const qualify = resolve_spec_qualifier(imports, options);
|
|
595
|
-
const value_lines = filtered
|
|
596
|
-
|
|
611
|
+
const value_lines = filtered
|
|
612
|
+
.map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)},`)
|
|
613
|
+
.join('\n');
|
|
614
|
+
const type_lines = filtered
|
|
615
|
+
.map((s) => `\t${to_action_property_key(s.method)}: typeof ${qualify(s)};`)
|
|
616
|
+
.join('\n');
|
|
597
617
|
return `/**
|
|
598
618
|
* Action specifications indexed by method name.
|
|
599
619
|
* These represent the complete action spec definitions.
|
|
@@ -643,13 +663,17 @@ export interface ActionOutputs {}`;
|
|
|
643
663
|
}
|
|
644
664
|
imports.add('zod', 'z');
|
|
645
665
|
const qualify = resolve_spec_qualifier(imports, options);
|
|
646
|
-
const inputs_value = filtered
|
|
666
|
+
const inputs_value = filtered
|
|
667
|
+
.map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.input,`)
|
|
668
|
+
.join('\n');
|
|
647
669
|
const inputs_type = filtered
|
|
648
|
-
.map((s) => `\t${s.method}: z.infer<typeof ${qualify(s)}.input>;`)
|
|
670
|
+
.map((s) => `\t${to_action_property_key(s.method)}: z.infer<typeof ${qualify(s)}.input>;`)
|
|
671
|
+
.join('\n');
|
|
672
|
+
const outputs_value = filtered
|
|
673
|
+
.map((s) => `\t${to_action_property_key(s.method)}: ${qualify(s)}.output,`)
|
|
649
674
|
.join('\n');
|
|
650
|
-
const outputs_value = filtered.map((s) => `\t${s.method}: ${qualify(s)}.output,`).join('\n');
|
|
651
675
|
const outputs_type = filtered
|
|
652
|
-
.map((s) => `\t${s.method}: z.infer<typeof ${qualify(s)}.output>;`)
|
|
676
|
+
.map((s) => `\t${to_action_property_key(s.method)}: z.infer<typeof ${qualify(s)}.output>;`)
|
|
653
677
|
.join('\n');
|
|
654
678
|
return `/**
|
|
655
679
|
* Action parameter schemas indexed by method name.
|
|
@@ -722,7 +746,7 @@ export interface ActionEventDatas {}`;
|
|
|
722
746
|
const type_args = spec.kind === 'remote_notification'
|
|
723
747
|
? `<'${spec.method}', ActionInputs['${spec.method}']>`
|
|
724
748
|
: `<'${spec.method}', ActionInputs['${spec.method}'], ActionOutputs['${spec.method}']>`;
|
|
725
|
-
return `\t${spec.method}: ${data_type}${type_args};`;
|
|
749
|
+
return `\t${to_action_property_key(spec.method)}: ${data_type}${type_args};`;
|
|
726
750
|
});
|
|
727
751
|
return `/**
|
|
728
752
|
* Action event data types indexed by method name.
|
|
@@ -873,7 +897,7 @@ export const broadcast_action_specs: ReadonlyArray<ActionSpecUnion> = [];`;
|
|
|
873
897
|
const qualify = resolve_spec_qualifier(imports, options);
|
|
874
898
|
const interface_body = '\n' +
|
|
875
899
|
broadcast
|
|
876
|
-
.map((s) => `\t${s.method}: (input: ActionInputs['${s.method}']) => Promise<void>;`)
|
|
900
|
+
.map((s) => `\t${to_action_property_key(s.method)}: (input: ActionInputs['${s.method}']) => Promise<void>;`)
|
|
877
901
|
.join('\n') +
|
|
878
902
|
'\n';
|
|
879
903
|
const array_body = '\n' + broadcast.map((s) => `\t${qualify(s)},`).join('\n') + '\n';
|
|
@@ -979,7 +1003,7 @@ export const create_namespace_qualifier = (sources, imports) => {
|
|
|
979
1003
|
if (!ns) {
|
|
980
1004
|
throw new Error(`unknown action method passed to qualify_spec: ${spec.method} — not in any registered source`);
|
|
981
1005
|
}
|
|
982
|
-
return `${ns}.${spec.method}
|
|
1006
|
+
return `${ns}.${to_action_spec_identifier(spec.method)}`;
|
|
983
1007
|
};
|
|
984
1008
|
return { qualify_spec, all_specs };
|
|
985
1009
|
};
|