rastack 0.0.48 → 0.0.50
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/CHANGELOG.md +4 -0
- package/components/auto-form/AutoForm.tsx +13 -0
- package/components/auto-form/use-auto-form.ts +28 -0
- package/components/types.ts +8 -0
- package/dist/admin.js +13 -13
- package/dist/compile/analyze.d.ts +26 -0
- package/dist/compile/analyze.js +70 -3
- package/dist/compile/entities.d.ts +19 -0
- package/dist/compile/entities.js +87 -13
- package/dist/compile/index.d.ts +23 -4
- package/dist/compile/index.js +86 -7
- package/dist/compile/model.d.ts +38 -0
- package/dist/compile/openapi.d.ts +9 -0
- package/dist/compile/openapi.js +14 -0
- package/dist/define/index.d.ts +107 -13
- package/dist/define/index.js +1 -1
- package/dist/import/tabular.d.ts +8 -2
- package/dist/import/tabular.js +1 -1
- package/dist/rastack-admin.d.ts +14 -7
- package/dist/rastack-admin.js +85 -40
- package/dist/rastack-import.js +4 -1
- package/dist/validate/adapters.js +2 -0
- package/dist/validate/index.d.ts +1 -0
- package/dist/validate/index.js +1 -0
- package/dist/validate/machine.d.ts +23 -2
- package/dist/validate/machine.js +35 -2
- package/dist/validate/transitions.d.ts +86 -0
- package/dist/validate/transitions.js +199 -0
- package/dist/wasm/rastack_wasm.js +1 -1
- package/dist/wasm/rastack_wasm_bg.wasm +0 -0
- package/hooks/data.ts +209 -0
- package/hooks/entity.ts +222 -0
- package/hooks/form/entity-form.ts +354 -0
- package/hooks/form/form.ts +8 -1
- package/hooks/form/index.ts +7 -1
- package/hooks/index.ts +4 -0
- package/hooks/manifest.ts +41 -0
- package/hooks/registry.ts +39 -0
- package/package.json +1 -1
- package/provider/provider.tsx +8 -1
- package/provider/types.ts +7 -2
- package/src/compile/analyze.ts +83 -4
- package/src/compile/entities.ts +111 -11
- package/src/compile/index.ts +108 -11
- package/src/compile/model.ts +40 -0
- package/src/compile/openapi.ts +13 -1
- package/src/define/index.ts +148 -20
- package/src/import/tabular.ts +9 -2
- package/src/rastack-admin.ts +105 -46
- package/src/rastack-import.ts +4 -1
- package/src/validate/adapters.ts +1 -0
- package/src/validate/index.ts +1 -0
- package/src/validate/machine.ts +55 -3
- package/src/validate/transitions.ts +232 -0
- package/test/components.spec.ts +22 -0
- package/test/transitions.spec.ts +372 -0
- package/test/typed-hooks.spec.ts +407 -0
- package/wasm/rastack_wasm.js +1 -1
- package/wasm/rastack_wasm_bg.wasm +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.50](https://github.com/theserverkid/reactapistack/compare/v0.0.49...v0.0.50) (2026-07-15)
|
|
6
|
+
|
|
7
|
+
### [0.0.49](https://github.com/theserverkid/reactapistack/compare/v0.0.48...v0.0.49) (2026-07-14)
|
|
8
|
+
|
|
5
9
|
### [0.0.48](https://github.com/theserverkid/reactapistack/compare/v0.0.47...v0.0.48) (2026-07-13)
|
|
6
10
|
|
|
7
11
|
### [0.0.47](https://github.com/theserverkid/reactapistack/compare/v0.0.46...v0.0.47) (2026-07-13)
|
|
@@ -229,6 +229,19 @@ export function AutoForm(props: AutoFormProps): React.JSX.Element {
|
|
|
229
229
|
justifyContent: "flex-end",
|
|
230
230
|
}}
|
|
231
231
|
>
|
|
232
|
+
{/* State-machine actions: one button per transition available from
|
|
233
|
+
the record's current state (feature-detected off the form). */}
|
|
234
|
+
{model.transitions.map((t) => (
|
|
235
|
+
<Button
|
|
236
|
+
key={t.name}
|
|
237
|
+
type="button"
|
|
238
|
+
variant="outline"
|
|
239
|
+
disabled={model.isSubmitting}
|
|
240
|
+
onClick={() => t.fire()}
|
|
241
|
+
>
|
|
242
|
+
{t.label}
|
|
243
|
+
</Button>
|
|
244
|
+
))}
|
|
232
245
|
{onCancel ? (
|
|
233
246
|
<Button
|
|
234
247
|
type="button"
|
|
@@ -37,6 +37,15 @@ export interface AutoFormFieldModel {
|
|
|
37
37
|
) => React.ReactNode;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** One state-machine action the form can fire from the record's current state. */
|
|
41
|
+
export interface AutoFormTransitionModel {
|
|
42
|
+
name: string;
|
|
43
|
+
label: React.ReactNode;
|
|
44
|
+
/** The state the record enters when the action fires. */
|
|
45
|
+
to: string;
|
|
46
|
+
fire: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
export interface AutoFormModel {
|
|
41
50
|
fields: AutoFormFieldModel[];
|
|
42
51
|
submit: () => void;
|
|
@@ -45,6 +54,11 @@ export interface AutoFormModel {
|
|
|
45
54
|
/** `true` when the form is valid and not mid-submit. */
|
|
46
55
|
canSubmit: boolean;
|
|
47
56
|
errors: Record<string, unknown>;
|
|
57
|
+
/**
|
|
58
|
+
* State-machine actions — feature-detected from `useForm(Entity)` results
|
|
59
|
+
* whose resource declares `transitions`. Empty on forms without one.
|
|
60
|
+
*/
|
|
61
|
+
transitions: AutoFormTransitionModel[];
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
/** Pure model assembly — see {@link useAutoForm}. Testable with a mock form. */
|
|
@@ -70,6 +84,19 @@ export function buildAutoFormModel(
|
|
|
70
84
|
};
|
|
71
85
|
});
|
|
72
86
|
|
|
87
|
+
// Feature-detect the state machine: `useForm(Entity)` exposes the declared
|
|
88
|
+
// transitions available from the record's current state; anything else
|
|
89
|
+
// (legacy hooks, hand-rolled forms) simply renders no actions.
|
|
90
|
+
const transitions: AutoFormTransitionModel[] =
|
|
91
|
+
Array.isArray(form.transitions) && typeof form.transition === "function"
|
|
92
|
+
? form.transitions.map((t) => ({
|
|
93
|
+
name: t.name,
|
|
94
|
+
label: t.label ?? humanizeKey(t.name),
|
|
95
|
+
to: t.to,
|
|
96
|
+
fire: () => form.transition!(t.name),
|
|
97
|
+
}))
|
|
98
|
+
: [];
|
|
99
|
+
|
|
73
100
|
return {
|
|
74
101
|
fields,
|
|
75
102
|
submit: () => form.onSubmit(),
|
|
@@ -77,6 +104,7 @@ export function buildAutoFormModel(
|
|
|
77
104
|
isSubmitting: form.isSubmitting,
|
|
78
105
|
canSubmit: !form.isSubmitDisabled && !form.isSubmitting,
|
|
79
106
|
errors: (form.errors as Record<string, unknown>) ?? {},
|
|
107
|
+
transitions,
|
|
80
108
|
};
|
|
81
109
|
}
|
|
82
110
|
|
package/components/types.ts
CHANGED
|
@@ -95,4 +95,12 @@ export interface AutoFormLike {
|
|
|
95
95
|
isSubmitting: boolean;
|
|
96
96
|
/** Formik's error bag, keyed by field name. */
|
|
97
97
|
errors?: Record<string, unknown> | unknown;
|
|
98
|
+
/**
|
|
99
|
+
* State-machine actions, feature-detected like everything else: when
|
|
100
|
+
* `useForm(Entity)` exposes the resource's declared transitions, the
|
|
101
|
+
* auto-form renders one action button per available edge.
|
|
102
|
+
*/
|
|
103
|
+
transitions?: Array<{ name: string; label?: string; to: string }>;
|
|
104
|
+
/** Fire a declared transition (stage the edge's patch and save). */
|
|
105
|
+
transition?(name: string): void;
|
|
98
106
|
}
|