@w6w/react 0.6.0 → 0.9.12
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/README.md +214 -44
- package/dist/mod.d.ts +4 -3
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +5 -3
- package/dist/mod.js.map +1 -1
- package/dist/src/W6WProvider.d.ts +89 -39
- package/dist/src/W6WProvider.d.ts.map +1 -1
- package/dist/src/W6WProvider.js +104 -57
- package/dist/src/W6WProvider.js.map +1 -1
- package/dist/src/adapter.d.ts +157 -2
- package/dist/src/adapter.d.ts.map +1 -1
- package/dist/src/adapter.js +97 -1
- package/dist/src/adapter.js.map +1 -1
- package/dist/src/flow-workflow.d.ts +109 -0
- package/dist/src/flow-workflow.d.ts.map +1 -0
- package/dist/src/flow-workflow.js +72 -0
- package/dist/src/flow-workflow.js.map +1 -0
- package/dist/src/hooks.d.ts +90 -11
- package/dist/src/hooks.d.ts.map +1 -1
- package/dist/src/hooks.js +181 -42
- package/dist/src/hooks.js.map +1 -1
- package/dist/src/single-flight.d.ts +33 -0
- package/dist/src/single-flight.d.ts.map +1 -0
- package/dist/src/single-flight.js +71 -0
- package/dist/src/single-flight.js.map +1 -0
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +13 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `toFlowWorkflow` / `fromFlowWorkflow` — a validating converter between the
|
|
3
|
+
* SDK's deliberately OPAQUE `WorkflowDefinition` (`Record<string, unknown>`,
|
|
4
|
+
* `node/src/workflows.ts`) and {@link FlowWorkflowShape}, a STRUCTURAL MIRROR
|
|
5
|
+
* of `@w6w/ui`'s `FlowWorkflow` (`src/flow-types.ts`) — the typed shape the
|
|
6
|
+
* visual editor reads and writes.
|
|
7
|
+
*
|
|
8
|
+
* This lane is MIT and takes no runtime dependency on `@w6w/ui` (not even a
|
|
9
|
+
* type import in the shipped build), so the mirror below is transcribed by
|
|
10
|
+
* hand. `ui-conformance.check.ts` pins it in BOTH directions at compile time:
|
|
11
|
+
* ui's `FlowWorkflow` is assignable to {@link fromFlowWorkflow}'s parameter,
|
|
12
|
+
* and {@link FlowWorkflowShape} is assignable to ui's `FlowWorkflow`.
|
|
13
|
+
*
|
|
14
|
+
* The mirror carries no index signature (ui's interfaces have none, and an
|
|
15
|
+
* index signature would break the first direction), yet unknown keys — `retry`,
|
|
16
|
+
* `onError`, `ports`, a host's `x-*` extension — are never dropped: both
|
|
17
|
+
* directions copy by spread, so a definition a newer server enriched
|
|
18
|
+
* round-trips untouched. The validation is the minimum the editor needs to not
|
|
19
|
+
* crash (see {@link toFlowWorkflow}); it does not check the contents of
|
|
20
|
+
* `steps[].uses` or any other nested field.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import type { WorkflowDefinition } from "@w6w/sdk";
|
|
25
|
+
/** Mirror of ui's `FlowStep`. Unknown keys are preserved at runtime. */
|
|
26
|
+
export interface FlowStepShape {
|
|
27
|
+
id: string;
|
|
28
|
+
uses: {
|
|
29
|
+
app: string;
|
|
30
|
+
action: string;
|
|
31
|
+
connection?: string | null;
|
|
32
|
+
};
|
|
33
|
+
ports?: {
|
|
34
|
+
in?: number | "many";
|
|
35
|
+
out?: number | "many";
|
|
36
|
+
};
|
|
37
|
+
with?: Record<string, unknown>;
|
|
38
|
+
retry?: {
|
|
39
|
+
maxAttempts: number;
|
|
40
|
+
backoff?: "fixed" | "exponential";
|
|
41
|
+
delayMs?: number;
|
|
42
|
+
};
|
|
43
|
+
onError?: "fail" | "continue" | "continue-record";
|
|
44
|
+
notes?: string;
|
|
45
|
+
fanOut?: "sequential" | "parallel";
|
|
46
|
+
position?: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Mirror of ui's `FlowEdge`. */
|
|
52
|
+
export interface FlowEdgeShape {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
when?: "success" | "error";
|
|
56
|
+
}
|
|
57
|
+
/** Mirror of ui's `FlowWorkflow`. */
|
|
58
|
+
export interface FlowWorkflowShape {
|
|
59
|
+
manifestVersion: string;
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
displayName?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
variables?: Array<{
|
|
65
|
+
key: string;
|
|
66
|
+
type?: string;
|
|
67
|
+
required?: boolean;
|
|
68
|
+
default?: unknown;
|
|
69
|
+
}>;
|
|
70
|
+
steps: FlowStepShape[];
|
|
71
|
+
edges?: FlowEdgeShape[];
|
|
72
|
+
settings?: {
|
|
73
|
+
autoSave?: boolean;
|
|
74
|
+
savePosition?: boolean;
|
|
75
|
+
viewport?: {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
zoom: number;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** One violation found by {@link toFlowWorkflow}. */
|
|
83
|
+
export interface WorkflowShapeIssue {
|
|
84
|
+
/** Dotted/indexed location in the definition, e.g. `steps[2].id`. */
|
|
85
|
+
path: string;
|
|
86
|
+
message: string;
|
|
87
|
+
}
|
|
88
|
+
/** Thrown by {@link toFlowWorkflow}; `issues` lists EVERY violation, not just the first. */
|
|
89
|
+
export declare class WorkflowShapeError extends Error {
|
|
90
|
+
readonly issues: WorkflowShapeIssue[];
|
|
91
|
+
constructor(issues: WorkflowShapeIssue[]);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Validate an opaque `WorkflowDefinition` and return it as a
|
|
95
|
+
* {@link FlowWorkflowShape}. Requires string `manifestVersion`/`id`/`name`; a
|
|
96
|
+
* `steps` array of objects each with a string `id`; and, when present,
|
|
97
|
+
* `edges` an array, `settings` an object, `variables` an array. Anything else
|
|
98
|
+
* throws a {@link WorkflowShapeError} listing every violation. The result is a
|
|
99
|
+
* copy (top level and each step) that keeps every unknown key.
|
|
100
|
+
*/
|
|
101
|
+
export declare function toFlowWorkflow(def: WorkflowDefinition): FlowWorkflowShape;
|
|
102
|
+
/**
|
|
103
|
+
* The inverse of {@link toFlowWorkflow}: a {@link FlowWorkflowShape} (the
|
|
104
|
+
* editor's output) back to the opaque `WorkflowDefinition` the SDK sends.
|
|
105
|
+
* Spread-copies the top level and each step, so unknown keys survive and no
|
|
106
|
+
* caller cast is needed.
|
|
107
|
+
*/
|
|
108
|
+
export declare function fromFlowWorkflow(flow: FlowWorkflowShape): WorkflowDefinition;
|
|
109
|
+
//# sourceMappingURL=flow-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-workflow.d.ts","sourceRoot":"","sources":["../../src/flow-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAClE,KAAK,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;QAClC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,iBAAiB,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,QAAQ,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC;gBAE1B,MAAM,EAAE,kBAAkB,EAAE;CASzC;AAMD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,CAoCzE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB,CAE5E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Thrown by {@link toFlowWorkflow}; `issues` lists EVERY violation, not just the first. */
|
|
2
|
+
export class WorkflowShapeError extends Error {
|
|
3
|
+
issues;
|
|
4
|
+
constructor(issues) {
|
|
5
|
+
super(`Workflow definition is not a valid flow workflow: ${issues
|
|
6
|
+
.map((i) => `${i.path}: ${i.message}`)
|
|
7
|
+
.join("; ")}`);
|
|
8
|
+
this.name = "WorkflowShapeError";
|
|
9
|
+
this.issues = issues;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function isObject(v) {
|
|
13
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validate an opaque `WorkflowDefinition` and return it as a
|
|
17
|
+
* {@link FlowWorkflowShape}. Requires string `manifestVersion`/`id`/`name`; a
|
|
18
|
+
* `steps` array of objects each with a string `id`; and, when present,
|
|
19
|
+
* `edges` an array, `settings` an object, `variables` an array. Anything else
|
|
20
|
+
* throws a {@link WorkflowShapeError} listing every violation. The result is a
|
|
21
|
+
* copy (top level and each step) that keeps every unknown key.
|
|
22
|
+
*/
|
|
23
|
+
export function toFlowWorkflow(def) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
const input = def;
|
|
26
|
+
if (!isObject(input)) {
|
|
27
|
+
throw new WorkflowShapeError([{ path: "", message: "must be an object" }]);
|
|
28
|
+
}
|
|
29
|
+
for (const key of ["manifestVersion", "id", "name"]) {
|
|
30
|
+
if (typeof input[key] !== "string")
|
|
31
|
+
issues.push({ path: key, message: "must be a string" });
|
|
32
|
+
}
|
|
33
|
+
const steps = input.steps;
|
|
34
|
+
if (!Array.isArray(steps)) {
|
|
35
|
+
issues.push({ path: "steps", message: "must be an array" });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
steps.forEach((step, i) => {
|
|
39
|
+
if (!isObject(step)) {
|
|
40
|
+
issues.push({ path: `steps[${i}]`, message: "must be an object" });
|
|
41
|
+
}
|
|
42
|
+
else if (typeof step.id !== "string") {
|
|
43
|
+
issues.push({ path: `steps[${i}].id`, message: "must be a string" });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (input.edges !== undefined && !Array.isArray(input.edges)) {
|
|
48
|
+
issues.push({ path: "edges", message: "must be an array" });
|
|
49
|
+
}
|
|
50
|
+
if (input.settings !== undefined && !isObject(input.settings)) {
|
|
51
|
+
issues.push({ path: "settings", message: "must be an object" });
|
|
52
|
+
}
|
|
53
|
+
if (input.variables !== undefined && !Array.isArray(input.variables)) {
|
|
54
|
+
issues.push({ path: "variables", message: "must be an array" });
|
|
55
|
+
}
|
|
56
|
+
if (issues.length > 0)
|
|
57
|
+
throw new WorkflowShapeError(issues);
|
|
58
|
+
return {
|
|
59
|
+
...input,
|
|
60
|
+
steps: steps.map((s) => ({ ...s })),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The inverse of {@link toFlowWorkflow}: a {@link FlowWorkflowShape} (the
|
|
65
|
+
* editor's output) back to the opaque `WorkflowDefinition` the SDK sends.
|
|
66
|
+
* Spread-copies the top level and each step, so unknown keys survive and no
|
|
67
|
+
* caller cast is needed.
|
|
68
|
+
*/
|
|
69
|
+
export function fromFlowWorkflow(flow) {
|
|
70
|
+
return { ...flow, steps: flow.steps.map((s) => ({ ...s })) };
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=flow-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE5D,OAAO;QACL,GAAG,KAAK;QACR,KAAK,EAAG,KAAmC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;KACnC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAuB;IACtD,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/src/hooks.d.ts
CHANGED
|
@@ -1,21 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The hook set — one small primitive underneath (`useAsync`
|
|
3
|
-
* mutation primitive), every
|
|
4
|
-
* `
|
|
5
|
-
* anywhere (`package.json` carries none — see README).
|
|
2
|
+
* The hook set — one small primitive underneath (`useAsync` for reads, a
|
|
3
|
+
* private mutation primitive for writes), every hook a thin wrapper over the
|
|
4
|
+
* provider's `W6WClient`. No react-query or any other data-fetching
|
|
5
|
+
* dependency anywhere (`package.json` carries none — see README).
|
|
6
6
|
*
|
|
7
7
|
* Built only over the PUBLIC, non-`console` surface (`me`, `documents`,
|
|
8
|
-
* `vars`, `connections`, `workflows`, `run`) — `console.*` is
|
|
9
|
-
* and unstable (see README), so no hook here reaches for it.
|
|
8
|
+
* `vars`, `connections`, `workflows`, `functions`, `run`) — `console.*` is
|
|
9
|
+
* studio-internal and unstable (see README), so no hook here reaches for it.
|
|
10
|
+
* The workflow and Function definition lifecycles moved onto that public
|
|
11
|
+
* surface at contract `0.5.0`, which is why hooks for them live here now
|
|
12
|
+
* rather than being unreachable without `console.*`.
|
|
10
13
|
*
|
|
11
|
-
* Cancellation
|
|
12
|
-
* (
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* Cancellation and sharing: every read method a hook here calls takes an
|
|
15
|
+
* optional `signal` (`@w6w/sdk`'s `CallOptions`, threaded to the injected
|
|
16
|
+
* `fetch`'s own `RequestInit.signal`, `node/src/http.ts`). Reads are
|
|
17
|
+
* single-flighted per client (`single-flight.ts`): hooks asking for the same
|
|
18
|
+
* thing (same hook, same arguments) while a request is in flight share ONE
|
|
19
|
+
* request and one `AbortController`, and nothing is kept once it settles. The
|
|
20
|
+
* controller is refcounted — it aborts only when the LAST subscriber has gone
|
|
21
|
+
* (unmount, `identityKey`/client switch, `ready: false`) and stayed gone past
|
|
22
|
+
* a microtask, so React StrictMode's synchronous cleanup -> remount (or a
|
|
23
|
+
* second consumer) re-attaches to the flight instead of aborting and
|
|
24
|
+
* re-firing it. A stale request's resolution or rejection can never commit
|
|
25
|
+
* into a hook that has moved on, and a genuinely abandoned request is told to
|
|
26
|
+
* stop rather than merely ignored.
|
|
27
|
+
*
|
|
28
|
+
* Every read hook also gates on `ready` (`<W6WProvider ready={...}>`,
|
|
29
|
+
* default `true`): while `false`, `useAsync` never calls the fetcher at all
|
|
30
|
+
* and reports `loading: true`.
|
|
15
31
|
*
|
|
16
32
|
* @module
|
|
17
33
|
*/
|
|
18
|
-
import type { ConnectionSummary, Doc, DocumentCreateInput, DocumentOptions, DocumentPatch, Me, RunEnvelope, RunInput, Var, VarCreateInput, VarPatch, WorkflowListOptions, WorkflowRunOptions, WorkflowRunResult, WorkflowSummary } from "@w6w/sdk";
|
|
34
|
+
import type { ConnectionSummary, Doc, DocumentCreateInput, DocumentOptions, DocumentPatch, FunctionDefinition, FunctionDetail, FunctionSummary, Me, RunEnvelope, RunInput, Var, VarCreateInput, VarPatch, WorkflowDefinition, WorkflowDetail, WorkflowListOptions, WorkflowRunOptions, WorkflowRunResult, WorkflowSaveResult, WorkflowSummary, WorkflowWriteOptions } from "@w6w/sdk";
|
|
19
35
|
/** What every read hook returns. */
|
|
20
36
|
export interface ReadResult<T> {
|
|
21
37
|
/** The last successfully fetched value, or `undefined` before the first resolves. */
|
|
@@ -46,6 +62,19 @@ export declare function useVars(): ReadResult<Var[]>;
|
|
|
46
62
|
export declare function useVar(id: string): ReadResult<Var>;
|
|
47
63
|
export declare function useConnections(): ReadResult<ConnectionSummary[]>;
|
|
48
64
|
export declare function useWorkflows(options?: WorkflowListOptions): ReadResult<WorkflowSummary[]>;
|
|
65
|
+
/**
|
|
66
|
+
* One workflow's stored definition, plus the two things that are not in it.
|
|
67
|
+
*
|
|
68
|
+
* `data.updatedAt` is the optimistic-concurrency token: hand it to
|
|
69
|
+
* {@linkcode useUpdateWorkflow}'s `ifUnmodifiedSince` and a save that would
|
|
70
|
+
* clobber someone else's edit is refused instead of winning silently. That is
|
|
71
|
+
* the whole reason this is a read hook and not just a fetch — the token has to
|
|
72
|
+
* survive from the read to the write, and a component that re-reads on every
|
|
73
|
+
* render would keep handing itself a fresh one.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useWorkflow(id: string): ReadResult<WorkflowDetail>;
|
|
76
|
+
export declare function useFunctions(): ReadResult<FunctionSummary[]>;
|
|
77
|
+
export declare function useFunction(id: string): ReadResult<FunctionDetail>;
|
|
49
78
|
export declare function useCreateDocument(): MutationResult<[DocumentCreateInput, DocumentOptions?], Doc>;
|
|
50
79
|
export declare function useUpdateDocument(): MutationResult<[
|
|
51
80
|
string,
|
|
@@ -67,4 +96,54 @@ export declare function useDeleteVar(): MutationResult<[string], void>;
|
|
|
67
96
|
*/
|
|
68
97
|
export declare function useRunWorkflow(): MutationResult<[string, WorkflowRunOptions?], WorkflowRunResult>;
|
|
69
98
|
export declare function useRun(): MutationResult<[RunInput], RunEnvelope>;
|
|
99
|
+
/**
|
|
100
|
+
* ── The definition lifecycle ──
|
|
101
|
+
*
|
|
102
|
+
* Ten hooks over the same ten SDK methods, and three properties they inherit
|
|
103
|
+
* from it rather than invent:
|
|
104
|
+
*
|
|
105
|
+
* 1. **`create` mints the id.** The server requires one in the body and never
|
|
106
|
+
* generates it, so `create({name, steps})` works and the `wf_…`/`fn_…` id
|
|
107
|
+
* comes back in the result.
|
|
108
|
+
* 2. **`update` is a full replacement, not a patch.** This is the one place
|
|
109
|
+
* these differ from `useUpdateDocument`/`useUpdateVar`, whose second
|
|
110
|
+
* argument is a `Patch` of the fields to change. Here it is the whole
|
|
111
|
+
* definition: read with {@linkcode useWorkflow} / {@linkcode useFunction},
|
|
112
|
+
* spread, change, send. A component that passed only the changed fields
|
|
113
|
+
* would delete the rest.
|
|
114
|
+
* 3. **Deleting a workflow is two calls**, `archive` then `delete`. No hook
|
|
115
|
+
* here chains them — a UI that offers "delete" should offer the archive
|
|
116
|
+
* step too, because that is the step a user can still change their mind
|
|
117
|
+
* after.
|
|
118
|
+
*
|
|
119
|
+
* None of them refetch a list on success, matching every other mutation hook
|
|
120
|
+
* in this file: this lane carries no cache to invalidate (no react-query, by
|
|
121
|
+
* design — see README), so a component pairs the mutation with the read hook's
|
|
122
|
+
* own `refetch`.
|
|
123
|
+
*/
|
|
124
|
+
export declare function useCreateWorkflow(): MutationResult<[
|
|
125
|
+
WorkflowDefinition,
|
|
126
|
+
WorkflowWriteOptions?
|
|
127
|
+
], WorkflowSaveResult>;
|
|
128
|
+
export declare function useUpdateWorkflow(): MutationResult<[
|
|
129
|
+
string,
|
|
130
|
+
WorkflowDefinition,
|
|
131
|
+
WorkflowWriteOptions?
|
|
132
|
+
], WorkflowSaveResult>;
|
|
133
|
+
export declare function useArchiveWorkflow(): MutationResult<[string], WorkflowDefinition>;
|
|
134
|
+
export declare function useDeleteWorkflow(): MutationResult<[string], void>;
|
|
135
|
+
export declare function useCreateFunction(): MutationResult<[
|
|
136
|
+
FunctionDefinition
|
|
137
|
+
], {
|
|
138
|
+
id: string;
|
|
139
|
+
key: string;
|
|
140
|
+
}>;
|
|
141
|
+
export declare function useUpdateFunction(): MutationResult<[
|
|
142
|
+
string,
|
|
143
|
+
FunctionDefinition
|
|
144
|
+
], {
|
|
145
|
+
id: string;
|
|
146
|
+
key: string;
|
|
147
|
+
}>;
|
|
148
|
+
export declare function useDeleteFunction(): MutationResult<[string], void>;
|
|
70
149
|
//# sourceMappingURL=hooks.d.ts.map
|
package/dist/src/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EACV,iBAAiB,EACjB,GAAG,EACH,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,EAAE,EACF,WAAW,EACX,QAAQ,EACR,GAAG,EACH,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAKlB,oCAAoC;AACpC,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,qFAAqF;IACrF,IAAI,EAAE,CAAC,GAAG,SAAS,CAAC;IACpB,8DAA8D;IAC9D,KAAK,EAAE,OAAO,CAAC;IACf,gFAAgF;IAChF,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAc,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC;IACvD,+FAA+F;IAC/F,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO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gB,iBAAiB,IAAI,cAAc,CACjD;IAAC,MAAM;IAAE,kBAAkB;CAAC,EAC5B;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAC5B,CAKA;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAGlE"}
|
package/dist/src/hooks.js
CHANGED
|
@@ -1,39 +1,100 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { useW6WClient } from "./W6WProvider.js";
|
|
2
|
+
import { useW6WClient, useW6WProviderContext } from "./W6WProvider.js";
|
|
3
|
+
import { subscribe } from "./single-flight.js";
|
|
3
4
|
/**
|
|
4
|
-
* Shared plumbing behind every read hook: fetch
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Shared plumbing behind every read hook: fetch on mount, on every
|
|
6
|
+
* `fetcher`/`client`/`ready` change, and on an imperative `refetch()`; drop
|
|
7
|
+
* any result that is no longer current.
|
|
8
|
+
*
|
|
9
|
+
* `fetcher` must be a `useCallback`-stabilized function taking the call's
|
|
10
|
+
* `AbortSignal` — each hook below owns that decision by listing exactly the
|
|
11
|
+
* values its own fetch depends on (including `client`), so this primitive's
|
|
12
|
+
* own dependency array stays exhaustive and needs no lint override. `client`
|
|
13
|
+
* is passed SEPARATELY (not inferred from `fetcher`'s identity) because it is
|
|
14
|
+
* the one thing that decides whether a reset is a "client change" (blank the
|
|
15
|
+
* stale data before refetching — R-7) or an ordinary same-client refetch
|
|
16
|
+
* (keep today's behaviour: loading flips true, previous data stays visible
|
|
17
|
+
* until the new result lands).
|
|
18
|
+
*
|
|
19
|
+
* Sequencing: a monotonic per-call generation number, bumped on every real
|
|
20
|
+
* fetch. Only the call whose generation is still the LATEST when it settles
|
|
21
|
+
* is allowed to commit — a superseded call (a newer one started, whether by
|
|
22
|
+
* `client` changing or by `refetch()`) can never write `state`, on resolution
|
|
23
|
+
* OR rejection. The previous call's `AbortController` is also aborted before
|
|
24
|
+
* the new one starts, and on unmount, so a genuinely abandoned request is
|
|
25
|
+
* told to stop rather than merely ignored.
|
|
26
|
+
*
|
|
27
|
+
* `ready === false` short-circuits before any of that: the fetcher is never
|
|
28
|
+
* called, any in-flight call is aborted, and state reports
|
|
29
|
+
* `{data: undefined, error: undefined, loading: true}`.
|
|
30
|
+
*
|
|
31
|
+
* A rejection named `ConfigError` (`@w6w/sdk`'s `requireToken` — no token yet,
|
|
32
|
+
* P-6) is reported as `loading: true`, not `error` — the same floor as
|
|
33
|
+
* `ready: false`, since from a caller's point of view "no credential yet" and
|
|
34
|
+
* "not ready yet" are the same state.
|
|
35
|
+
*
|
|
36
|
+
* `key` identifies the read for sharing: `JSON.stringify([method, ...args])`
|
|
37
|
+
* over the SDK method and EVERY argument `fetcher` closes over. `refetch()`
|
|
38
|
+
* starts a fresh flight (replacing the key's slot) and never aborts a flight
|
|
39
|
+
* another subscriber still holds.
|
|
10
40
|
*/
|
|
11
|
-
function useAsync(fetcher) {
|
|
41
|
+
function useAsync(key, fetcher, client, ready) {
|
|
12
42
|
const [state, setState] = useState({
|
|
13
43
|
data: undefined,
|
|
14
44
|
error: undefined,
|
|
15
45
|
loading: true,
|
|
16
46
|
});
|
|
17
47
|
const mountedRef = useRef(true);
|
|
48
|
+
const generationRef = useRef(0);
|
|
49
|
+
const subRef = useRef(null);
|
|
50
|
+
const clientRef = useRef(client);
|
|
18
51
|
useEffect(() => {
|
|
19
52
|
mountedRef.current = true;
|
|
20
53
|
return () => {
|
|
21
54
|
mountedRef.current = false;
|
|
55
|
+
subRef.current?.detach();
|
|
56
|
+
subRef.current = null;
|
|
22
57
|
};
|
|
23
58
|
}, []);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
59
|
+
const run = useCallback((fresh = false) => {
|
|
60
|
+
const clientChanged = clientRef.current !== client;
|
|
61
|
+
clientRef.current = client;
|
|
62
|
+
// Abort whatever this hook had in flight — superseded by this call,
|
|
63
|
+
// whether it is a real fetch or a `ready: false` short-circuit.
|
|
64
|
+
subRef.current?.detach();
|
|
65
|
+
subRef.current = null;
|
|
66
|
+
if (!ready) {
|
|
67
|
+
// Bump the generation too, not just abort the controller — a rejection
|
|
68
|
+
// from the just-aborted call must never land after this point and flip
|
|
69
|
+
// `loading` back to `false` out from under the `ready: false` floor.
|
|
70
|
+
++generationRef.current;
|
|
71
|
+
setState({ data: undefined, error: undefined, loading: true });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const generation = ++generationRef.current;
|
|
75
|
+
const sub = subscribe(client, key, fetcher, fresh);
|
|
76
|
+
subRef.current = sub;
|
|
77
|
+
setState((s) => clientChanged
|
|
78
|
+
? { data: undefined, error: undefined, loading: true }
|
|
79
|
+
: { ...s, loading: true });
|
|
80
|
+
sub.promise.then((data) => {
|
|
81
|
+
if (!mountedRef.current || generation !== generationRef.current)
|
|
82
|
+
return;
|
|
83
|
+
setState({ data, error: undefined, loading: false });
|
|
29
84
|
}, (error) => {
|
|
30
|
-
if (mountedRef.current)
|
|
31
|
-
|
|
85
|
+
if (!mountedRef.current || generation !== generationRef.current)
|
|
86
|
+
return;
|
|
87
|
+
if (error instanceof Error && error.name === "ConfigError") {
|
|
88
|
+
setState({ data: undefined, error: undefined, loading: true });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
setState({ data: undefined, error, loading: false });
|
|
32
92
|
});
|
|
33
|
-
}, [fetcher]);
|
|
93
|
+
}, [key, fetcher, client, ready]);
|
|
34
94
|
useEffect(() => {
|
|
35
|
-
|
|
36
|
-
}, [
|
|
95
|
+
run();
|
|
96
|
+
}, [run]);
|
|
97
|
+
const refetch = useCallback(() => run(true), [run]);
|
|
37
98
|
return { data: state.data, error: state.error, loading: state.loading, refetch };
|
|
38
99
|
}
|
|
39
100
|
/**
|
|
@@ -66,48 +127,73 @@ function useMutationResource(mutator) {
|
|
|
66
127
|
}
|
|
67
128
|
// ── reads ────────────────────────────────────────────────────────────────
|
|
68
129
|
export function useMe() {
|
|
69
|
-
const client =
|
|
70
|
-
const fetcher = useCallback(() => client.me(), [client]);
|
|
71
|
-
return useAsync(fetcher);
|
|
130
|
+
const { client, ready } = useW6WProviderContext();
|
|
131
|
+
const fetcher = useCallback((signal) => client.me({ signal }), [client]);
|
|
132
|
+
return useAsync(JSON.stringify(["me"]), fetcher, client, ready);
|
|
72
133
|
}
|
|
73
134
|
export function useDocuments(options) {
|
|
74
|
-
const client =
|
|
135
|
+
const { client, ready } = useW6WProviderContext();
|
|
75
136
|
const project = options?.project;
|
|
76
|
-
const fetcher = useCallback(() => client.documents.list(
|
|
77
|
-
return useAsync(fetcher);
|
|
137
|
+
const fetcher = useCallback((signal) => client.documents.list({ project, signal }), [client, project]);
|
|
138
|
+
return useAsync(JSON.stringify(["documents.list", project ?? null]), fetcher, client, ready);
|
|
78
139
|
}
|
|
79
140
|
export function useDocument(id, options) {
|
|
80
|
-
const client =
|
|
141
|
+
const { client, ready } = useW6WProviderContext();
|
|
81
142
|
const project = options?.project;
|
|
82
|
-
const fetcher = useCallback(() => client.documents.get(id,
|
|
83
|
-
return useAsync(fetcher);
|
|
143
|
+
const fetcher = useCallback((signal) => client.documents.get(id, { project, signal }), [client, id, project]);
|
|
144
|
+
return useAsync(JSON.stringify(["documents.get", id, project ?? null]), fetcher, client, ready);
|
|
84
145
|
}
|
|
85
146
|
export function useDocumentByKey(key, options) {
|
|
86
|
-
const client =
|
|
147
|
+
const { client, ready } = useW6WProviderContext();
|
|
87
148
|
const project = options?.project;
|
|
88
|
-
const fetcher = useCallback(() => client.documents.getByKey(key,
|
|
89
|
-
return useAsync(fetcher);
|
|
149
|
+
const fetcher = useCallback((signal) => client.documents.getByKey(key, { project, signal }), [client, key, project]);
|
|
150
|
+
return useAsync(JSON.stringify(["documents.getByKey", key, project ?? null]), fetcher, client, ready);
|
|
90
151
|
}
|
|
91
152
|
export function useVars() {
|
|
92
|
-
const client =
|
|
93
|
-
const fetcher = useCallback(() => client.vars.list(), [client]);
|
|
94
|
-
return useAsync(fetcher);
|
|
153
|
+
const { client, ready } = useW6WProviderContext();
|
|
154
|
+
const fetcher = useCallback((signal) => client.vars.list({ signal }), [client]);
|
|
155
|
+
return useAsync(JSON.stringify(["vars.list"]), fetcher, client, ready);
|
|
95
156
|
}
|
|
96
157
|
export function useVar(id) {
|
|
97
|
-
const client =
|
|
98
|
-
const fetcher = useCallback(() => client.vars.get(id), [client, id]);
|
|
99
|
-
return useAsync(fetcher);
|
|
158
|
+
const { client, ready } = useW6WProviderContext();
|
|
159
|
+
const fetcher = useCallback((signal) => client.vars.get(id, { signal }), [client, id]);
|
|
160
|
+
return useAsync(JSON.stringify(["vars.get", id]), fetcher, client, ready);
|
|
100
161
|
}
|
|
101
162
|
export function useConnections() {
|
|
102
|
-
const client =
|
|
103
|
-
const fetcher = useCallback(() => client.connections.list(), [client]);
|
|
104
|
-
return useAsync(fetcher);
|
|
163
|
+
const { client, ready } = useW6WProviderContext();
|
|
164
|
+
const fetcher = useCallback((signal) => client.connections.list({ signal }), [client]);
|
|
165
|
+
return useAsync(JSON.stringify(["connections.list"]), fetcher, client, ready);
|
|
105
166
|
}
|
|
106
167
|
export function useWorkflows(options) {
|
|
107
|
-
const client =
|
|
168
|
+
const { client, ready } = useW6WProviderContext();
|
|
108
169
|
const project = options?.project;
|
|
109
|
-
const fetcher = useCallback(() => client.workflows.list(
|
|
110
|
-
return useAsync(fetcher);
|
|
170
|
+
const fetcher = useCallback((signal) => client.workflows.list({ project, signal }), [client, project]);
|
|
171
|
+
return useAsync(JSON.stringify(["workflows.list", project ?? null]), fetcher, client, ready);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* One workflow's stored definition, plus the two things that are not in it.
|
|
175
|
+
*
|
|
176
|
+
* `data.updatedAt` is the optimistic-concurrency token: hand it to
|
|
177
|
+
* {@linkcode useUpdateWorkflow}'s `ifUnmodifiedSince` and a save that would
|
|
178
|
+
* clobber someone else's edit is refused instead of winning silently. That is
|
|
179
|
+
* the whole reason this is a read hook and not just a fetch — the token has to
|
|
180
|
+
* survive from the read to the write, and a component that re-reads on every
|
|
181
|
+
* render would keep handing itself a fresh one.
|
|
182
|
+
*/
|
|
183
|
+
export function useWorkflow(id) {
|
|
184
|
+
const { client, ready } = useW6WProviderContext();
|
|
185
|
+
const fetcher = useCallback((signal) => client.workflows.get(id, { signal }), [client, id]);
|
|
186
|
+
return useAsync(JSON.stringify(["workflows.get", id]), fetcher, client, ready);
|
|
187
|
+
}
|
|
188
|
+
export function useFunctions() {
|
|
189
|
+
const { client, ready } = useW6WProviderContext();
|
|
190
|
+
const fetcher = useCallback((signal) => client.functions.list({ signal }), [client]);
|
|
191
|
+
return useAsync(JSON.stringify(["functions.list"]), fetcher, client, ready);
|
|
192
|
+
}
|
|
193
|
+
export function useFunction(id) {
|
|
194
|
+
const { client, ready } = useW6WProviderContext();
|
|
195
|
+
const fetcher = useCallback((signal) => client.functions.get(id, { signal }), [client, id]);
|
|
196
|
+
return useAsync(JSON.stringify(["functions.get", id]), fetcher, client, ready);
|
|
111
197
|
}
|
|
112
198
|
// ── mutations ────────────────────────────────────────────────────────────
|
|
113
199
|
export function useCreateDocument() {
|
|
@@ -151,4 +237,57 @@ export function useRun() {
|
|
|
151
237
|
const client = useW6WClient();
|
|
152
238
|
return useMutationResource((input) => client.run(input));
|
|
153
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* ── The definition lifecycle ──
|
|
242
|
+
*
|
|
243
|
+
* Ten hooks over the same ten SDK methods, and three properties they inherit
|
|
244
|
+
* from it rather than invent:
|
|
245
|
+
*
|
|
246
|
+
* 1. **`create` mints the id.** The server requires one in the body and never
|
|
247
|
+
* generates it, so `create({name, steps})` works and the `wf_…`/`fn_…` id
|
|
248
|
+
* comes back in the result.
|
|
249
|
+
* 2. **`update` is a full replacement, not a patch.** This is the one place
|
|
250
|
+
* these differ from `useUpdateDocument`/`useUpdateVar`, whose second
|
|
251
|
+
* argument is a `Patch` of the fields to change. Here it is the whole
|
|
252
|
+
* definition: read with {@linkcode useWorkflow} / {@linkcode useFunction},
|
|
253
|
+
* spread, change, send. A component that passed only the changed fields
|
|
254
|
+
* would delete the rest.
|
|
255
|
+
* 3. **Deleting a workflow is two calls**, `archive` then `delete`. No hook
|
|
256
|
+
* here chains them — a UI that offers "delete" should offer the archive
|
|
257
|
+
* step too, because that is the step a user can still change their mind
|
|
258
|
+
* after.
|
|
259
|
+
*
|
|
260
|
+
* None of them refetch a list on success, matching every other mutation hook
|
|
261
|
+
* in this file: this lane carries no cache to invalidate (no react-query, by
|
|
262
|
+
* design — see README), so a component pairs the mutation with the read hook's
|
|
263
|
+
* own `refetch`.
|
|
264
|
+
*/
|
|
265
|
+
export function useCreateWorkflow() {
|
|
266
|
+
const client = useW6WClient();
|
|
267
|
+
return useMutationResource((definition, options) => client.workflows.create(definition, options));
|
|
268
|
+
}
|
|
269
|
+
export function useUpdateWorkflow() {
|
|
270
|
+
const client = useW6WClient();
|
|
271
|
+
return useMutationResource((id, definition, options) => client.workflows.update(id, definition, options));
|
|
272
|
+
}
|
|
273
|
+
export function useArchiveWorkflow() {
|
|
274
|
+
const client = useW6WClient();
|
|
275
|
+
return useMutationResource((id) => client.workflows.archive(id));
|
|
276
|
+
}
|
|
277
|
+
export function useDeleteWorkflow() {
|
|
278
|
+
const client = useW6WClient();
|
|
279
|
+
return useMutationResource((id) => client.workflows.delete(id));
|
|
280
|
+
}
|
|
281
|
+
export function useCreateFunction() {
|
|
282
|
+
const client = useW6WClient();
|
|
283
|
+
return useMutationResource((definition) => client.functions.create(definition));
|
|
284
|
+
}
|
|
285
|
+
export function useUpdateFunction() {
|
|
286
|
+
const client = useW6WClient();
|
|
287
|
+
return useMutationResource((id, definition) => client.functions.update(id, definition));
|
|
288
|
+
}
|
|
289
|
+
export function useDeleteFunction() {
|
|
290
|
+
const client = useW6WClient();
|
|
291
|
+
return useMutationResource((id) => client.functions.delete(id));
|
|
292
|
+
}
|
|
154
293
|
//# sourceMappingURL=hooks.js.map
|
package/dist/src/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/hooks.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAmB,CAAC;AAgCjD;;;;;;;GAOG;AACH,SAAS,QAAQ,CAAI,OAAyB;IAC5C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB;QAChD,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;QAC1B,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,OAAO,GAAG,KAAK,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/B,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3C,OAAO,EAAE,CAAC,IAAI,CACZ,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,UAAU,CAAC,OAAO;gBAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/E,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;YACjB,IAAI,UA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