@dudousxd/nestjs-catalog-react 0.21.0 → 0.23.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/context.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { CallableWorkflowRef, CatalogAuditEvent, CatalogConnection, Catalog
2
2
  import { type ReactNode } from 'react';
3
3
  import type { EmbeddedChartPayload, EmbeddedDashboardPayload } from './embed/payload';
4
4
  import { type PeopleQuery } from './routes';
5
- import type { CatalogWorkflow, WorkflowDurability, WorkflowInput, WorkflowRun } from './workflow/model';
5
+ import type { CatalogWorkflow, CatalogWorkflowRelease, WorkflowDurability, WorkflowInput, WorkflowRun } from './workflow/model';
6
6
  /**
7
7
  * How these screens talk to the server.
8
8
  *
@@ -251,6 +251,31 @@ export interface WorkflowRunOptions {
251
251
  * acknowledgement and gave no reason, which is refused.
252
252
  */
253
253
  expectShrink?: string;
254
+ /**
255
+ * Run a particular released version rather than the one this graph is set to.
256
+ *
257
+ * Absent — the ordinary case — runs whatever the graph is set to run: its live
258
+ * version if it has one, its latest save otherwise. Present is how a newly
259
+ * released version gets tried **without becoming what the cron executes**,
260
+ * which is the half of this feature that makes the other half safe: if the
261
+ * only way to run a new version were to deploy it, nobody would release
262
+ * anything they had not already decided to ship.
263
+ *
264
+ * Naming a version here does not move the live pointer. Deploying is
265
+ * `setWorkflowLiveVersion`, and the two are deliberately different calls.
266
+ */
267
+ version?: number;
268
+ }
269
+ export interface WorkflowReleaseInput {
270
+ /**
271
+ * Whatever the releaser wants to say about this version.
272
+ *
273
+ * Optional, and usually empty. It is stored on the release rather than derived
274
+ * from anything, because the one question a rollback has to answer six months
275
+ * later — "what was wrong with v8?" — has no other place to be written down:
276
+ * the graph diff says what changed and never says why.
277
+ */
278
+ notes?: string;
254
279
  }
255
280
  export interface WorkflowScheduleInput {
256
281
  /** Cron-ish, interpreted by whatever schedules it. Empty means manual only. */
@@ -796,6 +821,37 @@ export interface CatalogClient {
796
821
  * watching schedules while parsing nothing.
797
822
  */
798
823
  scheduleWorkflow(id: string, input: WorkflowScheduleInput): Promise<ScheduledWorkflow>;
824
+ /**
825
+ * Every released version of this graph, newest first.
826
+ *
827
+ * What a version picker is built on, and what a rollback is chosen from: the
828
+ * entry above the live one is what you came back from. Each carries the graph
829
+ * as it was, so a screen can draw an old version rather than only name it.
830
+ */
831
+ listWorkflowReleases(id: string): Promise<CatalogWorkflowRelease[]>;
832
+ /**
833
+ * Freeze this graph as it currently stands. **Deploys nothing.**
834
+ *
835
+ * Answers with the release, and with the *existing* one if this version was
836
+ * already released — the graph has not changed, so a second release would
837
+ * record an event that did not happen. A screen may therefore treat this as
838
+ * idempotent and does not need to disable its own button to be correct.
839
+ */
840
+ releaseWorkflow(id: string, input?: WorkflowReleaseInput): Promise<CatalogWorkflowRelease>;
841
+ /**
842
+ * Choose which released version this graph runs. **This is the deploy.**
843
+ *
844
+ * The same call is going live, rolling back and un-pinning: a smaller number
845
+ * is the rollback, and `null` takes the graph back to running its latest save.
846
+ * There is no separate rollback call because there is no separate mechanism —
847
+ * the older graph is still stored, so repointing is the whole of it.
848
+ *
849
+ * A screen that offers this should show both numbers. `liveWorkflowVersion`
850
+ * from `@dudousxd/nestjs-catalog/client` is the shared answer to "which one
851
+ * runs now", so a console does not reimplement the rule and end up disagreeing
852
+ * with the scheduler about what is deployed.
853
+ */
854
+ setWorkflowLiveVersion(id: string, version: number | null): Promise<CatalogWorkflow>;
799
855
  /**
800
856
  * What the system behind one source node looks like right now. Writes nothing.
801
857
  *
package/dist/context.js CHANGED
@@ -112,7 +112,28 @@ export function CatalogProvider({ transport, pipelineBasePath = DEFAULT_PIPELINE
112
112
  ...(options && 'expectShrink' in options && options.expectShrink !== undefined
113
113
  ? { expectShrink: options.expectShrink }
114
114
  : {}),
115
+ ...(options?.version === undefined ? {} : { version: options.version }),
115
116
  }),
117
+ listWorkflowReleases: (id) => transport.get(pipeline.workflowReleases(id)),
118
+ releaseWorkflow: (id, input) => transport.post(pipeline.workflowReleases(id), {
119
+ // Conditionally, for the reason `runWorkflow` spreads its two: the
120
+ // server distinguishes a body with no `notes` from one carrying an
121
+ // empty string, and a transport that serialised `undefined` would
122
+ // flatten the two.
123
+ ...(input?.notes === undefined ? {} : { notes: input.notes }),
124
+ }),
125
+ setWorkflowLiveVersion: (id, version) => {
126
+ if (!transport.put) {
127
+ throw new Error('This transport cannot PUT, so it cannot set a live version. Implement `put` on the ' +
128
+ 'transport you passed to CatalogProvider — going live sets a pointer to a value ' +
129
+ 'rather than appending anything, which is why the route is a PUT and not a POST.');
130
+ }
131
+ // `version` is sent even when it is null, and that is the contract
132
+ // rather than an oversight: the server refuses a body with no `version`
133
+ // key, because reading an omitted field as "un-pin" would deploy the
134
+ // most dangerous of the three operations by default.
135
+ return transport.put(pipeline.workflowLive(id), { version });
136
+ },
116
137
  scheduleWorkflow: (id, input) => {
117
138
  if (!transport.put) {
118
139
  throw new Error('This transport cannot PUT, so it cannot set a schedule. Implement `put` on the ' +
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ export { WORKFLOW_NAME } from './workflow/name';
29
29
  export { checkShapes, type ShapeKnowledge, type SourceColumn, type SourceShape, type TargetProperty, type TargetShape, } from './workflow/shape';
30
30
  export { canConnect, type ConnectionVerdict, edgeId, hasBlockingProblem, problemsByNode, type ValidateOptions, validateWorkflow, type WorkflowDraft, type WorkflowProblem, type WorkflowProblemCode, type WorkflowProblemLevel, wouldCycle, } from './workflow/validate';
31
31
  export { attachTransformIds, buildWorkflowTemplate, type EnrichOptions, enrichWithLookup, fanOutTypes, type FanOutOptions, type FanOutTarget, FILE_DROP_KINDS, type FileDropOptions, joinSources, type JoinOptions, loadFileDrop, type PeriodicFullReloadOptions, periodicFullReload, planIsRunnable, planToWorkflowInput, refuseUnusableColumnNames, RELOAD_CADENCE_IDS, RELOAD_CADENCES, type ReloadCadence, replicateTable, type ReplicateTableOptions, SOURCE_KINDS, type TemplateDeclaration, type TemplateExpectation, type TemplateOutcome, type TemplatePlan, type TemplateRefusal, type TemplateRefusalCode, type TemplateRequest, type TemplateSchedule, type TemplateTransformRequest, withinMsFor, WORKFLOW_TEMPLATE_IDS, WORKFLOW_TEMPLATES, type WorkflowTemplateId, type WorkflowTemplateMeta, } from './workflow/templates';
32
- export { type CatalogClient, type CatalogIdentity, type CatalogRevision, type CatalogPeoplePage, type CatalogPersonRole, type CatalogPersonSummary, type CatalogPrincipalSummary, CatalogProvider, type CatalogProviderProps, type CatalogTransport, type ConnectionInput, type ConnectionUse, catalogQueryKeys, type DeleteReconciliation, type LoadExpectation, type LoadExpectationInput, type ResolvedLoadExpectation, type RowCountBound, type StoredLoadExpectation, type PersonInput, type PersonUpsertResult, type PipelineCapabilities, type CallableWorkflowList, type ScheduledWorkflow, type TransformInput, type ListedReusableNode, type ReusableNodeInput, type ReusableNodeUsage, type SavedNodeAsReusable, type WorkflowRunOptions, type WorkflowScheduleInput, useCatalogClient, } from './context';
32
+ export { type CatalogClient, type CatalogIdentity, type CatalogRevision, type CatalogPeoplePage, type CatalogPersonRole, type CatalogPersonSummary, type CatalogPrincipalSummary, CatalogProvider, type CatalogProviderProps, type CatalogTransport, type ConnectionInput, type ConnectionUse, catalogQueryKeys, type DeleteReconciliation, type LoadExpectation, type LoadExpectationInput, type ResolvedLoadExpectation, type RowCountBound, type StoredLoadExpectation, type PersonInput, type PersonUpsertResult, type PipelineCapabilities, type CallableWorkflowList, type ScheduledWorkflow, type TransformInput, type ListedReusableNode, type ReusableNodeInput, type ReusableNodeUsage, type SavedNodeAsReusable, type WorkflowReleaseInput, type WorkflowRunOptions, type WorkflowScheduleInput, useCatalogClient, } from './context';
33
33
  export { type AccessRoutes, accessRoutes, DEFAULT_ACCESS_BASE_PATH, DEFAULT_PIPELINE_BASE_PATH, DEFAULT_PUBLISH_BASE_PATH, embedRoutes, type PeopleQuery, type PipelineRoutes, pipelineRoutes, } from './routes';
34
34
  export { ConfirmDialog } from './ui/dialog';
35
35
  export { FieldGroup, TextAreaField, TextField } from './ui/field';
package/dist/routes.d.ts CHANGED
@@ -241,6 +241,36 @@ export interface PipelineRoutes {
241
241
  * silently revert.
242
242
  */
243
243
  workflowSchedule(id: string): string;
244
+ /**
245
+ * Frozen versions of this graph. GET lists them newest first, POST mints one.
246
+ *
247
+ * A sub-resource of the graph rather than a top-level listing, because a
248
+ * release has no identity away from the workflow it is a release of — the same
249
+ * reasoning `transformRevisions` follows one object over.
250
+ *
251
+ * **Pressing POST deploys nothing.** It writes an immutable copy of the graph
252
+ * as it currently stands and answers with it; what runs is unchanged until
253
+ * somebody presses {@link PipelineRoutes.workflowLive}. The two are separate
254
+ * routes because they are separate decisions, and a screen that offered them
255
+ * as one button would rebuild the coupling this pair exists to break.
256
+ */
257
+ workflowReleases(id: string): string;
258
+ /**
259
+ * Which released version this graph actually runs. **This is the deploy.**
260
+ *
261
+ * `PUT` a `{ version }` to go live, and the same `PUT` with a smaller number
262
+ * is the rollback — there is no separate rollback route because there is no
263
+ * separate mechanism, the older graph is still stored. `{ version: null }`
264
+ * takes the graph back to running whatever its latest save holds, which is
265
+ * where every graph starts and is the one call here that makes editing mean
266
+ * deploying again.
267
+ *
268
+ * A screen built on this needs both numbers to say anything useful: the live
269
+ * version and the head. `liveWorkflowVersion` from `@dudousxd/nestjs-catalog/client`
270
+ * is the shared answer to "which one runs", so a console does not compute it
271
+ * with its own `??` and end up disagreeing with the scheduler.
272
+ */
273
+ workflowLive(id: string): string;
244
274
  /**
245
275
  * What the system behind one source node looks like right now. Writes nothing.
246
276
  *
package/dist/routes.js CHANGED
@@ -154,6 +154,8 @@ export function pipelineRoutes(basePath = DEFAULT_PIPELINE_BASE_PATH) {
154
154
  unpublishWorkflow: (id) => `${base}/workflows/${encodeURIComponent(id)}/unpublish`,
155
155
  runWorkflow: (id) => `${base}/workflows/${encodeURIComponent(id)}/run`,
156
156
  workflowSchedule: (id) => `${base}/workflows/${encodeURIComponent(id)}/schedule`,
157
+ workflowReleases: (id) => `${base}/workflows/${encodeURIComponent(id)}/releases`,
158
+ workflowLive: (id) => `${base}/workflows/${encodeURIComponent(id)}/live`,
157
159
  discoverSourceSchema: (id, nodeId) => `${base}/workflows/${encodeURIComponent(id)}/nodes/${encodeURIComponent(nodeId)}/discover`,
158
160
  saveNodeAsReusable: (id, nodeId) => `${base}/workflows/${encodeURIComponent(id)}/nodes/${encodeURIComponent(nodeId)}/save-as-reusable`,
159
161
  loadExpectations: () => expectations.expectations(),
@@ -0,0 +1,161 @@
1
+ import { type WorkflowBranchLabel, type WorkflowEdge, type WorkflowNode, type WorkflowNodeKind } from './model';
2
+ /**
3
+ * What right-clicking something on this canvas offers, worked out from the graph.
4
+ *
5
+ * ## The problem this is really solving
6
+ *
7
+ * "Create the next node and wire it in one action" already existed. It lives in
8
+ * a pill on a node's hover toolbar, roughly 46×20 pixels on a 1600-pixel canvas,
9
+ * and the person who asked for this feature never found it. When told it was
10
+ * there they answered: *"Apertei na borda e só deu wire ué"* — they pressed the
11
+ * handle, got the click-to-connect gesture, and reasonably concluded that was
12
+ * the feature. **Two different affordances were both called "wire", and the one
13
+ * carrying the menu was the less visible of the two.**
14
+ *
15
+ * So a context menu here is not a convenience on top of a discovered feature. It
16
+ * is the discoverable home for a capability that already shipped and was being
17
+ * missed, and everything else follows from that: the same list is what the hover
18
+ * pill opens (renamed, because the collision of names was half the bug), so
19
+ * there is one set of node actions in this package and no way for two menus to
20
+ * drift apart.
21
+ *
22
+ * ## The two rules everything here obeys
23
+ *
24
+ * **Never offer something the graph would refuse.** Every option that makes an
25
+ * edge is filtered through `canConnect` — the same function the drag, the click
26
+ * gesture and the inspector's picker are all refused by — by building a
27
+ * throwaway node and asking. Nothing here restates a rule about what may follow
28
+ * what. And where a list comes out empty, the menu *says why* instead of showing
29
+ * a blank space: "nothing here" and "nothing is possible" look identical and
30
+ * mean completely different things, and for a sink the answer is permanent.
31
+ *
32
+ * **Destructive items are separated.** `separated` puts a rule and a gap above a
33
+ * section, and delete is always the last section on the menu, on its own, in the
34
+ * destructive tone. It is still true that a variable-length "Already wired"
35
+ * group above it moves it between openings; what is avoided is the worse case —
36
+ * an ordinary item and a destructive one trading places at the same coordinates.
37
+ *
38
+ * ## Why this is a model and not JSX
39
+ *
40
+ * Two surfaces render it, and a third could. Keeping it as data means the
41
+ * question a reviewer actually cares about — *does a sink get offered anything
42
+ * downstream, ever?* — is a plain assertion over an array rather than a DOM
43
+ * query against a portalled popup that jsdom cannot lay out.
44
+ */
45
+ /** What was right-clicked. The four things this canvas can distinguish. */
46
+ export type CanvasMenuTarget = {
47
+ kind: 'node';
48
+ nodeId: string;
49
+ } | {
50
+ kind: 'edge';
51
+ edge: WorkflowEdge;
52
+ }
53
+ /** Empty canvas, with the point in GRAPH coordinates — where a node would land. */
54
+ | {
55
+ kind: 'pane';
56
+ at: {
57
+ x: number;
58
+ y: number;
59
+ };
60
+ }
61
+ /** Several nodes at once. Only ever reached with two or more. */
62
+ | {
63
+ kind: 'selection';
64
+ nodeIds: string[];
65
+ };
66
+ /**
67
+ * The mark beside an item.
68
+ *
69
+ * A name rather than an element, so this module stays data and the icon set
70
+ * stays an implementation detail of whichever surface draws it.
71
+ */
72
+ export type CanvasMenuIcon = 'open' | 'code' | 'arrow' | 'plus' | 'insert' | 'branch' | 'unplug' | 'trash' | 'tidy' | 'fit';
73
+ export interface CanvasMenuItem {
74
+ key: string;
75
+ label: string;
76
+ /** The right-hand column: what this does, in two or three words. */
77
+ hint?: string;
78
+ icon: CanvasMenuIcon;
79
+ /** Set on anything that removes something. Colours it, and nothing else. */
80
+ destructive?: boolean;
81
+ /**
82
+ * A sentence under the label, for the one case where the cost is not obvious
83
+ * from it. Used for exactly two things today — the wires a node takes with it,
84
+ * and what removing a node from a PUBLISHED graph does — because a warning on
85
+ * every item is a warning nobody reads.
86
+ */
87
+ detail?: string;
88
+ run(): void;
89
+ }
90
+ export interface CanvasMenuSection {
91
+ key: string;
92
+ title?: string;
93
+ /**
94
+ * Rendered instead of an empty list.
95
+ *
96
+ * The whole reason a section can be empty and still present: a sink offered no
97
+ * downstream targets has to say "a sink commits its rows, nothing runs after
98
+ * one" rather than show a gap that reads like a loading state.
99
+ */
100
+ note?: string;
101
+ /** A rule and a gap above it. Every destructive section sets this. */
102
+ separated?: boolean;
103
+ items: CanvasMenuItem[];
104
+ }
105
+ /**
106
+ * Everything the menu can ask the canvas to do.
107
+ *
108
+ * Handed in rather than dispatched through a union the canvas then switches on,
109
+ * because every one of these already exists on the canvas as a named callback
110
+ * with its own announcement and its own `markStarted` bookkeeping. A second
111
+ * dispatch layer would be a place for one of them to be forgotten.
112
+ */
113
+ export interface CanvasMenuActions {
114
+ inspect(nodeId: string): void;
115
+ editCode(nodeId: string): void;
116
+ connect(from: string, to: string): void;
117
+ connectToNew(from: string, kind: WorkflowNodeKind): void;
118
+ insertBetween(edge: WorkflowEdge, kind: WorkflowNodeKind): void;
119
+ setBranch(edge: WorkflowEdge, branch: WorkflowBranchLabel): void;
120
+ disconnect(edge: WorkflowEdge): void;
121
+ removeNodes(ids: string[]): void;
122
+ addAt(kind: WorkflowNodeKind, at: {
123
+ x: number;
124
+ y: number;
125
+ }): void;
126
+ tidy(): void;
127
+ fitAll(): void;
128
+ fitNodes(ids: string[]): void;
129
+ }
130
+ export interface CanvasMenuContext {
131
+ nodes: WorkflowNode[];
132
+ edges: WorkflowEdge[];
133
+ /** Every kind that can exist, in the order the palette offers them. */
134
+ kinds: readonly WorkflowNodeKind[];
135
+ canEdit: boolean;
136
+ /**
137
+ * Whether the STORED graph is published.
138
+ *
139
+ * Changes one sentence and no behaviour. A published graph has to stay
140
+ * runnable — the server refuses a save that would leave one unable to run, in
141
+ * those words — so removing a node from one is an edit that will be turned
142
+ * away at the moment it is saved rather than at the moment it is made. Saying
143
+ * so on the item is the difference between finding that out now and finding it
144
+ * out after twenty minutes of further editing.
145
+ */
146
+ published: boolean;
147
+ actions: CanvasMenuActions;
148
+ }
149
+ export declare function buildCanvasMenu(target: CanvasMenuTarget, context: CanvasMenuContext): CanvasMenuSection[];
150
+ /**
151
+ * What removing this node costs, in one sentence, or nothing at all.
152
+ *
153
+ * Two facts, and only when they apply. The wires, because a node removal that
154
+ * quietly unwires two OTHER nodes and says nothing is how somebody finds out
155
+ * half an hour later that their graph no longer reaches its sink. And the
156
+ * published case, because the server enforces a rule this canvas cannot: a
157
+ * published graph has to stay runnable, so the edit is accepted here and refused
158
+ * at the save — the one place a warning in advance is worth more than a
159
+ * confirmation dialog.
160
+ */
161
+ export declare function deleteCost(wires: number, published: boolean): string | undefined;