@dudousxd/nestjs-catalog 0.16.0 → 0.18.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/LICENSE +21 -0
- package/dist/catalog.events.d.ts +26 -1
- package/dist/catalog.events.js +8 -0
- package/dist/catalog.pipeline.d.ts +448 -5
- package/dist/catalog.pipeline.js +409 -11
- package/dist/catalog.workspace.d.ts +24 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +24 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -3
- package/package.json +6 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Davide Carvalho
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/catalog.events.d.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const CATALOG_LIB = "catalog";
|
|
16
16
|
/** Every event name this package emits. Exported so a watcher can claim them. */
|
|
17
|
-
export declare const CATALOG_EVENTS: readonly ["schema.changed", "snapshot.written", "snapshot.committed", "snapshot.dropped", "type.curated", "overlay.reset", "connector.run.started", "connector.run.finished", "transform.changed", "workflow.changed", "query.shared", "dashboard.shared"];
|
|
17
|
+
export declare const CATALOG_EVENTS: readonly ["schema.changed", "snapshot.written", "snapshot.committed", "snapshot.dropped", "type.curated", "overlay.reset", "connector.run.started", "connector.run.finished", "transform.changed", "reusable-node.changed", "workflow.changed", "query.shared", "dashboard.shared"];
|
|
18
18
|
export type CatalogEvent = (typeof CATALOG_EVENTS)[number];
|
|
19
19
|
/**
|
|
20
20
|
* Where each event sits in the life of one load.
|
|
@@ -286,6 +286,31 @@ export interface CatalogEventPayloads {
|
|
|
286
286
|
version: number;
|
|
287
287
|
changedBy: string;
|
|
288
288
|
};
|
|
289
|
+
/**
|
|
290
|
+
* Someone changed a node body that several graphs share.
|
|
291
|
+
*
|
|
292
|
+
* The third authoring event, and the one that answers a question the other two
|
|
293
|
+
* cannot. `transform.changed` and `workflow.changed` both name something
|
|
294
|
+
* inside the graph that changed behaviour; this names a change **outside**
|
|
295
|
+
* every graph it affects. A load that started reading a different query last
|
|
296
|
+
* Tuesday, whose own graph has not been touched in a month, has its whole
|
|
297
|
+
* explanation here and nowhere else — which is precisely the silence that
|
|
298
|
+
* makes shared nodes dangerous and precisely what this event is for.
|
|
299
|
+
*
|
|
300
|
+
* It carries no list of the graphs downstream, deliberately. That list is a
|
|
301
|
+
* query (`GET reusable-nodes/:id/workflows`) and it is answered as of *now*,
|
|
302
|
+
* whereas an event is a record of one moment; freezing a list into the trail
|
|
303
|
+
* would produce a fact that is wrong by the following week and looks
|
|
304
|
+
* authoritative.
|
|
305
|
+
*/
|
|
306
|
+
'reusable-node.changed': {
|
|
307
|
+
reusableNodeId: string;
|
|
308
|
+
name: string;
|
|
309
|
+
/** `source` or `sink` — see `REUSABLE_NODE_KINDS`. */
|
|
310
|
+
kind: string;
|
|
311
|
+
version: number;
|
|
312
|
+
changedBy: string;
|
|
313
|
+
};
|
|
289
314
|
/**
|
|
290
315
|
* Someone changed the wiring rather than the code.
|
|
291
316
|
*
|
package/dist/catalog.events.js
CHANGED
|
@@ -32,6 +32,7 @@ exports.CATALOG_EVENTS = [
|
|
|
32
32
|
'connector.run.started',
|
|
33
33
|
'connector.run.finished',
|
|
34
34
|
'transform.changed',
|
|
35
|
+
'reusable-node.changed',
|
|
35
36
|
'workflow.changed',
|
|
36
37
|
'query.shared',
|
|
37
38
|
'dashboard.shared',
|
|
@@ -63,6 +64,13 @@ exports.CATALOG_EVENT_PHASE = {
|
|
|
63
64
|
// one an earlier rank than the other would assert a causal order between two
|
|
64
65
|
// edits that have none.
|
|
65
66
|
'workflow.changed': 1,
|
|
67
|
+
// And the same rank again, for the same argument one step further out.
|
|
68
|
+
// Editing a reusable node is an authoring act that precedes the run being
|
|
69
|
+
// investigated, exactly as editing a transform or rewiring a graph is — and
|
|
70
|
+
// it is the one of the three that can change a load nobody edited, so a trace
|
|
71
|
+
// that could not place it beside the others would be missing the entry that
|
|
72
|
+
// explains the surprise.
|
|
73
|
+
'reusable-node.changed': 1,
|
|
66
74
|
// Curation carries no snapshot id, so it never lands inside a trace and this
|
|
67
75
|
// rank is never consulted. It is written out rather than left to the fallback
|
|
68
76
|
// because the type demands every event have one, and a `Record` that has to
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* schedules, retries and checkpoints, and writing a second one would mean two
|
|
8
8
|
* systems each believing they decide when a load runs.
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
10
|
+
import { type CatalogRevision } from './catalog.workspace';
|
|
11
11
|
/**
|
|
12
12
|
* Where a connector pulls from.
|
|
13
13
|
*
|
|
@@ -903,7 +903,7 @@ export declare function workflowRowY(row: number): number;
|
|
|
903
903
|
* vocabularies would let them disagree. Credentials stay out of the catalog
|
|
904
904
|
* here exactly as they do everywhere else.
|
|
905
905
|
*/
|
|
906
|
-
export interface WorkflowSourceNode extends WorkflowNodeBase {
|
|
906
|
+
export interface WorkflowSourceNode extends WorkflowNodeBase, ReusableNodeRef {
|
|
907
907
|
kind: 'source';
|
|
908
908
|
/** Named `sourceKind` rather than `kind`, which the union already uses. */
|
|
909
909
|
sourceKind: ConnectorKind;
|
|
@@ -925,6 +925,56 @@ export interface WorkflowTransformNode extends WorkflowNodeBase {
|
|
|
925
925
|
* logic used at three points in a graph is versioned once and fixed once.
|
|
926
926
|
*/
|
|
927
927
|
transformId: string;
|
|
928
|
+
/**
|
|
929
|
+
* Which version of that code to run. Absent follows the latest.
|
|
930
|
+
*
|
|
931
|
+
* ## The claim this field exists to make true
|
|
932
|
+
*
|
|
933
|
+
* The line above says a shared transform is "versioned once and fixed once",
|
|
934
|
+
* and until this field there was nothing here to fix it *to*. A transform node
|
|
935
|
+
* named a `transformId` and nothing else, `runTransform` resolved it with
|
|
936
|
+
* `getTransform`, and `getTransform` answers with whatever is in the row
|
|
937
|
+
* today. So editing a transform changed every graph that referenced it, at
|
|
938
|
+
* once, with nothing in anybody else's diff and nothing in their run history
|
|
939
|
+
* to explain the change — the graph's fingerprint does not move (see
|
|
940
|
+
* `workflowGraphHash`, which excludes the transform's version on purpose and
|
|
941
|
+
* still does) so there is not even a new graph version to look at.
|
|
942
|
+
*
|
|
943
|
+
* That was survivable only because almost nothing was shared. It stops being
|
|
944
|
+
* survivable the moment reusable nodes make sharing the point, which is why
|
|
945
|
+
* this landed with them rather than after them.
|
|
946
|
+
*
|
|
947
|
+
* The precedent is {@link WorkflowCallNode.callVersion}, whose docblock makes
|
|
948
|
+
* the same argument about somebody else's workflow: the version is authored,
|
|
949
|
+
* and a run that would have used a different one is refused rather than
|
|
950
|
+
* quietly run. This is that rule pointed at code stored in the same database.
|
|
951
|
+
*
|
|
952
|
+
* ## Why absent is allowed to mean "latest" rather than being backfilled
|
|
953
|
+
*
|
|
954
|
+
* Because that is what every graph already in a deployment means, exactly, and
|
|
955
|
+
* a backfill would be a behaviour change dressed as a migration. Pinning the
|
|
956
|
+
* live version at upgrade time freezes graphs whose authors have been relying
|
|
957
|
+
* on edits reaching them; pinning nothing but *refusing* an unpinned node
|
|
958
|
+
* stops every scheduled load on the deployment. Both are an upgrade that
|
|
959
|
+
* changes what runs, and neither is a decision this package gets to make for
|
|
960
|
+
* somebody. So absent keeps meaning precisely what it has always meant, and
|
|
961
|
+
* the repair is that following is now a **stated** position with a pinned
|
|
962
|
+
* alternative beside it, rather than the only position and an unstated one.
|
|
963
|
+
*
|
|
964
|
+
* What does change is that it is no longer silent: `describeTransformPin`
|
|
965
|
+
* turns either state into a sentence a screen can render, so "this follows
|
|
966
|
+
* whatever that code becomes" is something the author is told rather than
|
|
967
|
+
* something they find out.
|
|
968
|
+
*
|
|
969
|
+
* ## What a pin costs
|
|
970
|
+
*
|
|
971
|
+
* A pinned version is resolved out of `catalog_revision`, which is bounded per
|
|
972
|
+
* subject (`CATALOG_REVISION_LIMIT`). A pin to a version that has been evicted
|
|
973
|
+
* cannot be honoured, and the run fails saying so rather than falling back to
|
|
974
|
+
* the latest — a pin nobody could check is not a pin, which is the sentence
|
|
975
|
+
* `WorkflowRunSteps.checkCall` already stands on.
|
|
976
|
+
*/
|
|
977
|
+
transformVersion?: number;
|
|
928
978
|
}
|
|
929
979
|
/**
|
|
930
980
|
* Writes into an object type and commits.
|
|
@@ -937,9 +987,17 @@ export interface WorkflowTransformNode extends WorkflowNodeBase {
|
|
|
937
987
|
* convenience that two workflows already provide. Branching inside the graph
|
|
938
988
|
* stays fully supported; every path simply has to arrive here.
|
|
939
989
|
*/
|
|
940
|
-
export interface WorkflowSinkNode extends WorkflowNodeBase {
|
|
990
|
+
export interface WorkflowSinkNode extends WorkflowNodeBase, ReusableNodeRef {
|
|
941
991
|
kind: 'sink';
|
|
942
|
-
/**
|
|
992
|
+
/**
|
|
993
|
+
* Which object type the rows become.
|
|
994
|
+
*
|
|
995
|
+
* Stays on the node even when the node is an instance of a reusable one, and
|
|
996
|
+
* that is the one field a reusable body may **not** move under a graph. See
|
|
997
|
+
* {@link ReusableNodeRef} — the write grants a graph was checked against are
|
|
998
|
+
* checked against this string, so a reusable sink that could repoint it would
|
|
999
|
+
* be a way to write a type the author was never granted.
|
|
1000
|
+
*/
|
|
943
1001
|
targetType: string;
|
|
944
1002
|
/**
|
|
945
1003
|
* Whether the commit replaces the dataset or merges into it. Exactly the
|
|
@@ -1586,6 +1644,281 @@ export interface WorkflowFilterNode extends WorkflowNodeBase {
|
|
|
1586
1644
|
* a `transformId` and nothing catches it.
|
|
1587
1645
|
*/
|
|
1588
1646
|
export type WorkflowNode = WorkflowSourceNode | WorkflowTransformNode | WorkflowSinkNode | WorkflowCallNode | WorkflowIfNode | WorkflowFilterNode;
|
|
1647
|
+
/**
|
|
1648
|
+
* The node kinds that can be saved once and used in several graphs.
|
|
1649
|
+
*
|
|
1650
|
+
* Source and sink, and the reason is that those two are the only kinds whose
|
|
1651
|
+
* *composition* is worth a name. A connection is already a shared object, and it
|
|
1652
|
+
* answers "which database" — but nobody reaches for "the warehouse" when they
|
|
1653
|
+
* draw a graph, they reach for "the nightly MVR pull from the warehouse", which
|
|
1654
|
+
* is the connection **plus** the query, plus whether it reads everything or only
|
|
1655
|
+
* what changed, plus what the thing is called. That composition had nowhere to
|
|
1656
|
+
* live, so it was retyped per graph and the fourteenth copy was the one with the
|
|
1657
|
+
* typo in the `WHERE` clause.
|
|
1658
|
+
*
|
|
1659
|
+
* A transform is deliberately **not** here, and that is not an omission: a
|
|
1660
|
+
* transform is already a stored object referenced by id
|
|
1661
|
+
* ({@link WorkflowTransformNode.transformId}), so a reusable transform node
|
|
1662
|
+
* would be a second way to say the same thing. What it was missing is a version
|
|
1663
|
+
* pin, which is {@link WorkflowTransformNode.transformVersion}, not this.
|
|
1664
|
+
*
|
|
1665
|
+
* `call`, `if` and `filter` are not here either, and the record below is where
|
|
1666
|
+
* each of them says so — see {@link NODE_KIND_IS_REUSABLE}.
|
|
1667
|
+
*/
|
|
1668
|
+
export declare const REUSABLE_NODE_KINDS: readonly ["source", "sink"];
|
|
1669
|
+
export type ReusableNodeKind = (typeof REUSABLE_NODE_KINDS)[number];
|
|
1670
|
+
/** Same reason as {@link isConnectorKind}: one list, no second copy to drift. */
|
|
1671
|
+
export declare function isReusableNodeKind(value: unknown): value is ReusableNodeKind;
|
|
1672
|
+
/**
|
|
1673
|
+
* Whether each node kind may be saved as a reusable node.
|
|
1674
|
+
*
|
|
1675
|
+
* A record over every kind rather than a shorter list of the two that can,
|
|
1676
|
+
* because this codebase keeps being bitten by hand-maintained lists going quiet
|
|
1677
|
+
* — most recently the add-node row that shipped the `filter` node with no way to
|
|
1678
|
+
* create it. A kind added to {@link WORKFLOW_NODE_KINDS} without an entry here
|
|
1679
|
+
* is a type error in this file naming the decision it has not made.
|
|
1680
|
+
*
|
|
1681
|
+
* The second `satisfies` is the other half of the same guard, in the other
|
|
1682
|
+
* direction: anything named in {@link REUSABLE_NODE_KINDS} has to be `true`
|
|
1683
|
+
* here, so the list and this table cannot come apart. Adding `'filter'` to that
|
|
1684
|
+
* list without a `ReusableFilterBody` therefore fails to compile twice — once
|
|
1685
|
+
* here, and once at every narrowing over {@link ReusableNodeBody}.
|
|
1686
|
+
*
|
|
1687
|
+
* Why each `false`:
|
|
1688
|
+
*
|
|
1689
|
+
* - `transform` — already a reference to a stored object. See
|
|
1690
|
+
* {@link REUSABLE_NODE_KINDS}.
|
|
1691
|
+
* - `call` — already a reference to somebody else's registered workflow, pinned
|
|
1692
|
+
* by name and version. There is nothing left to name.
|
|
1693
|
+
* - `if` and `filter` — a predicate is *about* the rows in front of it. A gate
|
|
1694
|
+
* saved under a name and dropped into another graph tests a column that graph
|
|
1695
|
+
* may not have, and a filter is worse: {@link WorkflowFilterNode.narrows} is
|
|
1696
|
+
* an acknowledgement about *this* graph's sinks, so a shared one would carry
|
|
1697
|
+
* somebody else's acknowledgement into a graph they never saw.
|
|
1698
|
+
*/
|
|
1699
|
+
export declare const NODE_KIND_IS_REUSABLE: {
|
|
1700
|
+
readonly source: true;
|
|
1701
|
+
readonly transform: false;
|
|
1702
|
+
readonly sink: true;
|
|
1703
|
+
readonly call: false;
|
|
1704
|
+
readonly if: false;
|
|
1705
|
+
readonly filter: false;
|
|
1706
|
+
};
|
|
1707
|
+
/** Whether this kind can be saved as a reusable node. Reads {@link NODE_KIND_IS_REUSABLE}. */
|
|
1708
|
+
export declare function nodeKindIsReusable(kind: WorkflowNodeKind): boolean;
|
|
1709
|
+
/**
|
|
1710
|
+
* What a node carries when it is an instance of a reusable one.
|
|
1711
|
+
*
|
|
1712
|
+
* ## By reference, and that is the whole feature
|
|
1713
|
+
*
|
|
1714
|
+
* The cheap version of "save this node" copies its fields into the next graph
|
|
1715
|
+
* and forgets where they came from. It is cheaper in every way except the one
|
|
1716
|
+
* that was asked for: "quantos workflows tão usando quais nós" is unanswerable
|
|
1717
|
+
* about a copy, because after the copy there is nothing left that says the two
|
|
1718
|
+
* nodes are the same node. So the id stays on the node, `GET
|
|
1719
|
+
* reusable-nodes/:id/workflows` counts by it, and the count is exact rather than
|
|
1720
|
+
* a guess at which configurations look alike.
|
|
1721
|
+
*
|
|
1722
|
+
* ## The fields stay on the node as well, and are not the authority
|
|
1723
|
+
*
|
|
1724
|
+
* A source node that names a reusable node still carries its own `sourceKind`,
|
|
1725
|
+
* `config` and the rest. That is a **cache**, not a copy — the identical
|
|
1726
|
+
* arrangement `toGraph` already documents for a source that names a connector:
|
|
1727
|
+
* the fields are kept so that `validateWorkflow` stays pure and the canvas can
|
|
1728
|
+
* draw the node without a round trip, and execution re-reads the stored object,
|
|
1729
|
+
* so an edit takes effect on the next run.
|
|
1730
|
+
*
|
|
1731
|
+
* ## Which is exactly why {@link version} exists
|
|
1732
|
+
*
|
|
1733
|
+
* "An edit takes effect on the next run" is the useful behaviour and the
|
|
1734
|
+
* dangerous one, and which of the two it is depends on whether the person
|
|
1735
|
+
* editing knows who else is downstream. So the reference states its position:
|
|
1736
|
+
*
|
|
1737
|
+
* - **absent** — follows the latest. What a connector reference has always
|
|
1738
|
+
* meant, and the right default for "the warehouse pull" that four graphs
|
|
1739
|
+
* share and all four want fixed at once.
|
|
1740
|
+
* - **present** — pinned. The reusable node may move on and this graph does not,
|
|
1741
|
+
* until somebody edits *this* graph, which is a new version of it with a diff
|
|
1742
|
+
* to read.
|
|
1743
|
+
*
|
|
1744
|
+
* Both are in the graph fingerprint, so changing position is an edit; neither is
|
|
1745
|
+
* silent, which was the whole complaint. This is the same rule
|
|
1746
|
+
* {@link WorkflowTransformNode.transformVersion} states for transforms, and it
|
|
1747
|
+
* is stated twice on purpose rather than shared: they are two different stored
|
|
1748
|
+
* objects and a reader arriving at either should not have to find the other.
|
|
1749
|
+
*/
|
|
1750
|
+
export interface ReusableNodeRef {
|
|
1751
|
+
/**
|
|
1752
|
+
* The reusable node this is an instance of, or absent for a node configured
|
|
1753
|
+
* in place. Both remain first-class, indefinitely: a one-off source is not a
|
|
1754
|
+
* failure to reuse something.
|
|
1755
|
+
*/
|
|
1756
|
+
useId?: string;
|
|
1757
|
+
/** The pinned version of that reusable node. Absent follows the latest. */
|
|
1758
|
+
useVersion?: number;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* The part of a source node that is worth saving under a name.
|
|
1762
|
+
*
|
|
1763
|
+
* Everything a source needs to read, and nothing that belongs to the graph it
|
|
1764
|
+
* sits in. Absent here, on purpose: `id`, which has to be unique within one
|
|
1765
|
+
* graph and is also a durable step name, and `position`, which is where somebody
|
|
1766
|
+
* dragged the box on one canvas.
|
|
1767
|
+
*
|
|
1768
|
+
* `name` is absent too, and that is the less obvious one. A reusable node has a
|
|
1769
|
+
* name — it is how "flip db sink" is a thing anybody can ask for — but it lives
|
|
1770
|
+
* on {@link CatalogReusableNode} rather than in the body, because a graph is
|
|
1771
|
+
* allowed to call its instance something else. Folding the name in would rename
|
|
1772
|
+
* every node in every graph the moment somebody tidied up the library's naming,
|
|
1773
|
+
* and a node's name is documented as cosmetic precisely so that it is nobody
|
|
1774
|
+
* else's business.
|
|
1775
|
+
*/
|
|
1776
|
+
export interface ReusableSourceBody {
|
|
1777
|
+
kind: 'source';
|
|
1778
|
+
sourceKind: ConnectorKind;
|
|
1779
|
+
connectionId?: string;
|
|
1780
|
+
config: Record<string, unknown>;
|
|
1781
|
+
secretEnvVar?: string;
|
|
1782
|
+
mode?: 'full' | 'incremental';
|
|
1783
|
+
}
|
|
1784
|
+
/**
|
|
1785
|
+
* The part of a sink node that is worth saving under a name.
|
|
1786
|
+
*
|
|
1787
|
+
* `targetType` is in here, so "the Mvr full reload" is a thing that can be named
|
|
1788
|
+
* — and it is also the field {@link applyReusableNode} refuses to move under a
|
|
1789
|
+
* graph that already committed to a different one. Both are true at once and
|
|
1790
|
+
* they are not in tension: a graph adopting this body *takes* the type at the
|
|
1791
|
+
* moment it is saved, and is grant-checked for it then. What may not happen is
|
|
1792
|
+
* the type changing afterwards, under a graph whose author is not looking, into
|
|
1793
|
+
* one they were never granted.
|
|
1794
|
+
*/
|
|
1795
|
+
export interface ReusableSinkBody {
|
|
1796
|
+
kind: 'sink';
|
|
1797
|
+
targetType: string;
|
|
1798
|
+
mode?: 'full' | 'incremental';
|
|
1799
|
+
}
|
|
1800
|
+
export type ReusableNodeBody = ReusableSourceBody | ReusableSinkBody;
|
|
1801
|
+
/**
|
|
1802
|
+
* {@link unreachableNodeKind}, for reusable bodies, and for the identical
|
|
1803
|
+
* reason: every branch over {@link ReusableNodeBody} ends here, so a body added
|
|
1804
|
+
* to the union without a rule for folding it onto a node is a type error naming
|
|
1805
|
+
* the file rather than a graph that saves and then runs a node nobody
|
|
1806
|
+
* configured. It throws as well, because these arrive as JSON out of a column.
|
|
1807
|
+
*/
|
|
1808
|
+
export declare function unreachableReusableNodeKind(body: never, where: string): never;
|
|
1809
|
+
/**
|
|
1810
|
+
* A node body saved once, under a name, and used from several graphs.
|
|
1811
|
+
*
|
|
1812
|
+
* Versioned exactly as a {@link CatalogTransform} is, and archived in the same
|
|
1813
|
+
* `catalog_revision` table under its own subject — one table, one retention
|
|
1814
|
+
* rule, which is the argument `RevisionRow` already makes for holding transforms
|
|
1815
|
+
* and saved queries together. That is what makes
|
|
1816
|
+
* {@link ReusableNodeRef.version} resolvable rather than merely a number: a
|
|
1817
|
+
* graph pinned to v2 can still be handed v2's body after v3 exists.
|
|
1818
|
+
*
|
|
1819
|
+
* There is no library screen and there is deliberately not going to be one. A
|
|
1820
|
+
* reusable node is offered where a node is added and its usage count is shown on
|
|
1821
|
+
* the node itself, because the number changes a decision exactly at the moment
|
|
1822
|
+
* somebody is about to change something four other graphs depend on — which is
|
|
1823
|
+
* not a moment they spend on a listing page.
|
|
1824
|
+
*/
|
|
1825
|
+
export interface CatalogReusableNode {
|
|
1826
|
+
id: string;
|
|
1827
|
+
/**
|
|
1828
|
+
* What people ask for it by — "flip db sink". Unique across reusable nodes,
|
|
1829
|
+
* enforced in the store, because two of them called the same thing is a
|
|
1830
|
+
* picker that cannot be used.
|
|
1831
|
+
*/
|
|
1832
|
+
name: string;
|
|
1833
|
+
description?: string;
|
|
1834
|
+
/** Which node kind this stands for. Redundant with `body.kind` and indexed. */
|
|
1835
|
+
kind: ReusableNodeKind;
|
|
1836
|
+
body: ReusableNodeBody;
|
|
1837
|
+
/**
|
|
1838
|
+
* Counts saves that changed the **body**, exactly as a transform's counts
|
|
1839
|
+
* saves that changed the code: renaming a reusable node is not a new version
|
|
1840
|
+
* of it, and inflating the number would make a pin to it meaningless.
|
|
1841
|
+
*/
|
|
1842
|
+
version: number;
|
|
1843
|
+
createdBy: string;
|
|
1844
|
+
createdAt: string;
|
|
1845
|
+
updatedAt: string;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* How many graphs use a reusable node, and which.
|
|
1849
|
+
*
|
|
1850
|
+
* Shaped after `GET connections/:id/workflows`, which answers the same question
|
|
1851
|
+
* for a connection, because an operator asking either is about to do the same
|
|
1852
|
+
* thing: change something and want to know who is downstream. A count on its own
|
|
1853
|
+
* would be a number to be alarmed by; the list is what makes it actionable.
|
|
1854
|
+
*/
|
|
1855
|
+
export interface CatalogReusableNodeUse {
|
|
1856
|
+
workflowId: string;
|
|
1857
|
+
workflowName: string;
|
|
1858
|
+
status: WorkflowStatus;
|
|
1859
|
+
/** The node within that graph, and the position its reference states. */
|
|
1860
|
+
nodeId: string;
|
|
1861
|
+
nodeName: string;
|
|
1862
|
+
/** The pinned version, or absent for a reference that follows the latest. */
|
|
1863
|
+
pinnedVersion?: number;
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Fold a reusable body onto the node that references it.
|
|
1867
|
+
*
|
|
1868
|
+
* The one implementation, called by the store when a graph is saved and by the
|
|
1869
|
+
* runner when one is executed, so the node a canvas draws and the node that runs
|
|
1870
|
+
* cannot describe different reads. Pure, and it takes the body rather than
|
|
1871
|
+
* fetching one, for the reason `validateWorkflow` is pure: this file is imported
|
|
1872
|
+
* by the browser entry point.
|
|
1873
|
+
*
|
|
1874
|
+
* ## What it refuses
|
|
1875
|
+
*
|
|
1876
|
+
* A sink body whose `targetType` differs from the one already on the node. That
|
|
1877
|
+
* is not a tidiness check — it is the same shape as `WorkflowRunSteps.checkCall`
|
|
1878
|
+
* and it is load-bearing for the same reason. A graph's sinks are checked
|
|
1879
|
+
* against the author's write grants (`assertMayWriteTypes`) using the type on
|
|
1880
|
+
* the node, at save time. If a reusable body could repoint that afterwards, then
|
|
1881
|
+
* editing a shared sink would write into a type that nobody with access to this
|
|
1882
|
+
* graph was ever granted — and it would do it on a schedule, with the graph's
|
|
1883
|
+
* own diff showing nothing. So the disagreement fails, naming both types, and
|
|
1884
|
+
* the repair is that the referencing graph is re-saved and re-checked.
|
|
1885
|
+
*
|
|
1886
|
+
* A mismatched *kind* is refused for the plainer reason that there is nothing
|
|
1887
|
+
* sensible to do with it: a sink body on a source node is a reference somebody
|
|
1888
|
+
* repointed at the wrong object, and folding half of it in would produce a node
|
|
1889
|
+
* that is neither.
|
|
1890
|
+
*/
|
|
1891
|
+
export declare function applyReusableNode(node: WorkflowNode, body: ReusableNodeBody): WorkflowNode;
|
|
1892
|
+
/** Whether a stored value is a reusable body this build can execute. */
|
|
1893
|
+
export declare function isReusableNodeBody(value: unknown): value is ReusableNodeBody;
|
|
1894
|
+
/**
|
|
1895
|
+
* The body a node is currently carrying, ready to be saved under a name.
|
|
1896
|
+
*
|
|
1897
|
+
* The other direction of {@link applyReusableNode}, and the reason
|
|
1898
|
+
* save-as-reusable cannot silently deep-copy: this is what gets stored, the node
|
|
1899
|
+
* keeps a `useId` pointing at it, and nothing anywhere duplicates a graph.
|
|
1900
|
+
*
|
|
1901
|
+
* Answers `undefined` for a kind that cannot be reusable rather than throwing,
|
|
1902
|
+
* because the caller is a route answering a person who pressed a button on a
|
|
1903
|
+
* node — {@link nodeKindIsReusable} is what a screen asks before offering it,
|
|
1904
|
+
* and the route repeats the question rather than trusting the screen asked.
|
|
1905
|
+
*/
|
|
1906
|
+
export declare function reusableNodeBodyOf(node: WorkflowNode): ReusableNodeBody | undefined;
|
|
1907
|
+
/**
|
|
1908
|
+
* What a node's version discipline is, as a sentence a screen can render.
|
|
1909
|
+
*
|
|
1910
|
+
* Here rather than in the console for the reason `describeDurability`'s siblings
|
|
1911
|
+
* are: a screen that worked out its own wording would eventually describe
|
|
1912
|
+
* "follows the latest" as though it were a pin, which is the misunderstanding
|
|
1913
|
+
* this whole field exists to remove. One sentence, one place, and the console
|
|
1914
|
+
* renders it.
|
|
1915
|
+
*/
|
|
1916
|
+
export interface VersionPinCopy {
|
|
1917
|
+
pinned: boolean;
|
|
1918
|
+
label: string;
|
|
1919
|
+
detail: string;
|
|
1920
|
+
}
|
|
1921
|
+
export declare function describeVersionPin(version: number | undefined, subject: string): VersionPinCopy;
|
|
1589
1922
|
/**
|
|
1590
1923
|
* Which side of an {@link WorkflowIfNode} a wire leaves by.
|
|
1591
1924
|
*
|
|
@@ -2088,7 +2421,7 @@ export interface CallableWorkflowBlock {
|
|
|
2088
2421
|
}
|
|
2089
2422
|
export declare function callableWorkflowBlock(ref: CallableWorkflowRef): CallableWorkflowBlock | undefined;
|
|
2090
2423
|
/** Every way a graph can be refused. Exported so a canvas can key off the code. */
|
|
2091
|
-
export declare const WORKFLOW_ISSUE_CODES: readonly ["empty", "invalid-node-id", "duplicate-node-id", "edge-endpoint-missing", "self-edge", "duplicate-edge", "cycle", "no-source", "source-has-input", "no-sink", "duplicate-sink-type", "sink-has-output", "unreachable", "dead-end", "transform-not-named", "call-not-named", "if-not-named", "if-threshold-invalid", "if-needs-one-input", "branch-not-labelled", "branch-on-plain-edge", "filter-predicate-invalid", "filter-narrows-unacknowledged", "filter-narrows-nothing"];
|
|
2424
|
+
export declare const WORKFLOW_ISSUE_CODES: readonly ["empty", "invalid-node-id", "duplicate-node-id", "edge-endpoint-missing", "self-edge", "duplicate-edge", "cycle", "no-source", "source-has-input", "no-sink", "duplicate-sink-type", "sink-has-output", "unreachable", "dead-end", "transform-not-named", "call-not-named", "if-not-named", "if-threshold-invalid", "if-needs-one-input", "branch-not-labelled", "branch-on-plain-edge", "filter-predicate-invalid", "filter-narrows-unacknowledged", "filter-narrows-nothing", "version-pin-invalid"];
|
|
2092
2425
|
export type WorkflowIssueCode = (typeof WORKFLOW_ISSUE_CODES)[number];
|
|
2093
2426
|
export interface WorkflowValidationIssue {
|
|
2094
2427
|
code: WorkflowIssueCode;
|
|
@@ -2441,6 +2774,34 @@ export declare function supportsWorkflows(store: CatalogPipelineStore): store is
|
|
|
2441
2774
|
* flag is a claim and a method is the thing itself.
|
|
2442
2775
|
*/
|
|
2443
2776
|
export declare function supportsTransformRevisions(store: CatalogPipelineStore): store is CatalogPipelineStore & Required<Pick<CatalogPipelineStore, 'listTransformRevisions'>>;
|
|
2777
|
+
/**
|
|
2778
|
+
* Whether this store can produce one particular version of a transform's code.
|
|
2779
|
+
*
|
|
2780
|
+
* Separate from {@link supportsTransformRevisions}, and not implied by it: one
|
|
2781
|
+
* answers "can a screen show the history", the other "can a run honour a pin".
|
|
2782
|
+
* A store could reasonably have the first and not the second, and folding them
|
|
2783
|
+
* together would let a graph be saved with a pin this deployment cannot resolve
|
|
2784
|
+
* — discovered mid-load rather than at the moment the pin was set.
|
|
2785
|
+
*/
|
|
2786
|
+
export declare function supportsTransformPins(store: CatalogPipelineStore): store is CatalogPipelineStore & Required<Pick<CatalogPipelineStore, 'getTransformAt'>>;
|
|
2787
|
+
/**
|
|
2788
|
+
* The four reads and two writes a reusable node needs, as one derived type.
|
|
2789
|
+
*
|
|
2790
|
+
* `Required<Pick<...>>` rather than a second interface, which is the lesson
|
|
2791
|
+
* {@link CatalogLoadExpectationStore} records: these are optional members OF the
|
|
2792
|
+
* pipeline store, so writing them out again here would be a copy that can drift.
|
|
2793
|
+
*/
|
|
2794
|
+
export type CatalogReusableNodeStore = Required<Pick<CatalogPipelineStore, 'listReusableNodes' | 'getReusableNode' | 'getReusableNodeAt' | 'saveReusableNode' | 'deleteReusableNode' | 'reusableNodeUses'>>;
|
|
2795
|
+
/**
|
|
2796
|
+
* Whether this store can hold reusable nodes.
|
|
2797
|
+
*
|
|
2798
|
+
* All six, and never a subset. A store with `getReusableNode` but no
|
|
2799
|
+
* `reusableNodeUses` could serve a picker and could not answer the question the
|
|
2800
|
+
* feature exists for — and the shape of that failure is a console offering to
|
|
2801
|
+
* share a node while being unable to say who already depends on it, which is
|
|
2802
|
+
* worse than not offering at all.
|
|
2803
|
+
*/
|
|
2804
|
+
export declare function supportsReusableNodes(store: CatalogPipelineStore): store is CatalogPipelineStore & CatalogReusableNodeStore;
|
|
2444
2805
|
export declare function supportsWorkflowStages(store: CatalogPipelineStore): store is CatalogPipelineStore & CatalogStageStore;
|
|
2445
2806
|
/**
|
|
2446
2807
|
* A store that really does hold operator-set expectations, all four members
|
|
@@ -2526,6 +2887,88 @@ export interface CatalogPipelineStore extends Partial<CatalogWorkflowStore>, Par
|
|
|
2526
2887
|
* that bound costs.
|
|
2527
2888
|
*/
|
|
2528
2889
|
listTransformRevisions?(id: string): Promise<CatalogRevision[]>;
|
|
2890
|
+
/**
|
|
2891
|
+
* The code at one particular version, which is what a pin resolves through.
|
|
2892
|
+
*
|
|
2893
|
+
* Separate from {@link listTransformRevisions} rather than left to a caller
|
|
2894
|
+
* filtering that list, and the difference is the whole point: this is on the
|
|
2895
|
+
* hot path of every pinned transform node of every run, and reading up to
|
|
2896
|
+
* {@link CATALOG_REVISION_LIMIT} whole code bodies to keep one of them is a
|
|
2897
|
+
* cost paid per node per run. It is also a different answer — the list falls
|
|
2898
|
+
* back to a synthesised head for a subject that predates the revision table,
|
|
2899
|
+
* and this must not, because "the only version we can produce is the current
|
|
2900
|
+
* one" is exactly the case a pin needs to be told about rather than handed.
|
|
2901
|
+
*
|
|
2902
|
+
* `undefined` means the version cannot be produced: it predates the archive,
|
|
2903
|
+
* or it has fallen off the far end of the per-subject cap. The runner turns
|
|
2904
|
+
* that into a failed node rather than a fall-back to the latest, which is the
|
|
2905
|
+
* same stand `WorkflowRunSteps.checkCall` takes — a pin nobody could check is
|
|
2906
|
+
* not a pin.
|
|
2907
|
+
*
|
|
2908
|
+
* **Optional**, mixed in exactly as its neighbour above is and for the same
|
|
2909
|
+
* reason. {@link supportsTransformPins} is how a caller asks; a store without
|
|
2910
|
+
* it can still run graphs, and a graph with a pinned node is refused there
|
|
2911
|
+
* with a sentence rather than by a method that is missing at run time.
|
|
2912
|
+
*/
|
|
2913
|
+
getTransformAt?(id: string, version: number): Promise<CatalogTransform | undefined>;
|
|
2914
|
+
/**
|
|
2915
|
+
* Node bodies saved under a name and used from several graphs.
|
|
2916
|
+
*
|
|
2917
|
+
* **Optional**, mixed in for the reason every optional member here is: a store
|
|
2918
|
+
* written against the previous shape of this interface still satisfies it, and
|
|
2919
|
+
* a purely additive feature must not turn that into a compile error — or,
|
|
2920
|
+
* worse, into a run-time discovery, since the `supports*` probes narrow
|
|
2921
|
+
* structurally. {@link supportsReusableNodes} is how a caller asks.
|
|
2922
|
+
*
|
|
2923
|
+
* A deployment whose store implements none of these behaves exactly as it does
|
|
2924
|
+
* today: every node is configured in place, which is what they all are.
|
|
2925
|
+
*/
|
|
2926
|
+
listReusableNodes?(): Promise<CatalogReusableNode[]>;
|
|
2927
|
+
getReusableNode?(id: string): Promise<CatalogReusableNode | undefined>;
|
|
2928
|
+
/**
|
|
2929
|
+
* The body at one particular version, for a reference that pinned one.
|
|
2930
|
+
*
|
|
2931
|
+
* The sibling of {@link getTransformAt}, with the same contract and the same
|
|
2932
|
+
* `undefined`: a version the archive can no longer produce is reported as
|
|
2933
|
+
* absent and never substituted with the latest.
|
|
2934
|
+
*/
|
|
2935
|
+
getReusableNodeAt?(id: string, version: number): Promise<CatalogReusableNode | undefined>;
|
|
2936
|
+
/**
|
|
2937
|
+
* Bumps {@link CatalogReusableNode.version} when the **body** changed, and
|
|
2938
|
+
* archives it, exactly as {@link saveTransform} does for code.
|
|
2939
|
+
*
|
|
2940
|
+
* Editing a reusable node that other graphs pin therefore creates a new
|
|
2941
|
+
* version rather than refusing. Refusing was the other candidate and it is the
|
|
2942
|
+
* wrong one: this is the only editor there is, so a refusal would strand
|
|
2943
|
+
* whoever owns the node the moment anybody else pinned it, and would make
|
|
2944
|
+
* pinning a way to take something hostage. Creating a version costs the pinned
|
|
2945
|
+
* graphs nothing — they resolve through the archive and keep running the body
|
|
2946
|
+
* they named — and what the editor gets instead of a refusal is the count of
|
|
2947
|
+
* who is downstream, at the moment they are about to press save.
|
|
2948
|
+
*/
|
|
2949
|
+
saveReusableNode?(input: Pick<CatalogReusableNode, 'name' | 'body'> & {
|
|
2950
|
+
id?: string;
|
|
2951
|
+
description?: string;
|
|
2952
|
+
}, createdBy: string): Promise<CatalogReusableNode>;
|
|
2953
|
+
/**
|
|
2954
|
+
* Refuses while any graph still references it.
|
|
2955
|
+
*
|
|
2956
|
+
* The same refusal {@link deleteConnection} makes and for the same reason:
|
|
2957
|
+
* deleting one out from under its graphs turns every one of them into a load
|
|
2958
|
+
* that fails at run time, discovered on a schedule rather than at the moment
|
|
2959
|
+
* somebody decided.
|
|
2960
|
+
*/
|
|
2961
|
+
deleteReusableNode?(id: string): Promise<boolean>;
|
|
2962
|
+
/**
|
|
2963
|
+
* Which graphs use a reusable node, and at which node within each.
|
|
2964
|
+
*
|
|
2965
|
+
* On the store rather than derived in a controller from `listWorkflows`,
|
|
2966
|
+
* unlike `connections/:id/workflows` which does exactly that. The difference
|
|
2967
|
+
* is that this number is rendered *beside every entry of a picker*, so
|
|
2968
|
+
* deriving it would mean parsing every graph in the deployment once per
|
|
2969
|
+
* reusable node offered. A store can answer it from the rows it holds.
|
|
2970
|
+
*/
|
|
2971
|
+
reusableNodeUses?(id: string): Promise<CatalogReusableNodeUse[]>;
|
|
2529
2972
|
/**
|
|
2530
2973
|
* Per-type load expectations as an operator set them.
|
|
2531
2974
|
*
|