process-graph 1.3.0 → 2.0.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/README.md +21 -19
- package/dist/bin.js +2 -2
- package/dist/cli.d.ts +56 -76
- package/dist/cli.js +4 -3
- package/dist/{data-file-BVMxkTug.js → data-file-B8__c10l.js} +1 -1
- package/dist/dist-B0mKgR5B.js +4 -0
- package/dist/{dist-BI01yxFA.js → dist-BnymJpfk.js} +258 -473
- package/dist/graphql-CGWZ6USe.d.ts +17 -0
- package/dist/index-7nV7hCmv.d.ts +118 -0
- package/dist/{index-BC4tmAuQ.d.ts → index-B2p3mEJ3.d.ts} +2 -2
- package/dist/{index-9Au8pAmP.d.ts → index-C-ZNF81j.d.ts} +5 -24
- package/dist/{index-hri2a13-.d.ts → index-CiaCmQDP.d.ts} +2 -1
- package/dist/{graphql-BE7xm5dB.d.ts → index-CotF9Lhh.d.ts} +4 -45
- package/dist/index-DAevZqW-.d.ts +71 -0
- package/dist/{index-Dvz_I_uQ.d.ts → index-DYl6lZLe.d.ts} +29 -1
- package/dist/{index-D06bcdfw.d.ts → index-DluJZTbT.d.ts} +23 -2
- package/dist/{index-CR8xUK3S.d.ts → index-KhygugOP.d.ts} +6 -44
- package/dist/{index-D4CnOhNf.d.ts → index-wQnLXJmD.d.ts} +1 -1
- package/dist/index.d.ts +25 -4
- package/dist/index.js +4 -3
- package/dist/layout.d.ts +1 -1
- package/dist/project-CP_ye6KI.js +27 -0
- package/dist/react-flow.d.ts +5 -5
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -24
- package/dist/{router-Dk91O_9p.js → router-DzVcQ28U.js} +2 -2
- package/dist/{schema-BPT8fmfa.js → schema-CL95Lyni.js} +24 -13
- package/dist/schema-DMXa8gAZ.js +117 -0
- package/dist/source/github/node.d.ts +1 -1
- package/dist/source/github.d.ts +4 -3
- package/dist/source/github.js +39 -2
- package/dist/{source-D51N7K3A.js → source-DM4fLS5P.js} +2 -161
- package/dist/store/node.d.ts +1 -1
- package/dist/store/node.js +1 -1
- package/dist/store/wasm/worker.js +2 -2
- package/dist/store/wasm.d.ts +1 -1
- package/dist/{store-DKzvLGgl.js → store-CgweIG8J.js} +3 -12
- package/dist/store.d.ts +2 -2
- package/dist/store.js +3 -3
- package/dist/sync-CkaJO3OQ.js +213 -0
- package/dist/sync.d.ts +26 -0
- package/dist/sync.js +16 -0
- package/dist/ui.d.ts +4 -4
- package/dist/{version-Dagrkvwt.js → version-_UOnL566.js} +1 -1
- package/dist/view-DcktInd7.js +392 -0
- package/package.json +21 -15
- package/dist/dist-81kTKnMq.js +0 -3
- package/dist/parse-C1Q1zsGt.js +0 -41
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
|
-
import {
|
|
2
|
+
import { c as elementKinds, d as notations, f as overlayStatuses, i as overlaySchema, l as fragmentOperators, m as pseudoRoles, n as modelSchema, o as validateOverlay, p as participantKinds, t as boundActivitySchema, u as messageModes } from "./schema-CL95Lyni.js";
|
|
3
3
|
import { t as validate } from "./validate-DF3mQZww.js";
|
|
4
4
|
import { r as loopTransitions, s as emptyFactRecord } from "./control-DiygoEhm.js";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -11,21 +11,12 @@ import { index, integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlit
|
|
|
11
11
|
* The model's own record schemas, taken from `modelSchema` rather than restated, so what the store accepts is exactly a model or a slice of one and can never drift from it.
|
|
12
12
|
*/
|
|
13
13
|
const modelShape = modelSchema.unwrap().shape;
|
|
14
|
-
/** The model's `activity` element: the first variant of its element union. A type test pins the order, so reordering the union is a compile error. */
|
|
15
|
-
const [activityElementSchema] = modelShape.elements.unwrap().element.options;
|
|
16
14
|
/** The name a store files a model under. Any non-empty string; the store gives it no structure. */
|
|
17
15
|
const modelIdSchema = z.string().min(1);
|
|
18
16
|
/**
|
|
19
17
|
* A position in the store's history. Every change to any model takes the next revision from one store-wide sequence, so revisions only grow, a model's revision is the revision of its last change, and a model deleted and saved again never reuses an earlier one.
|
|
20
18
|
*/
|
|
21
19
|
const revisionSchema = z.int().positive();
|
|
22
|
-
/**
|
|
23
|
-
* An activity bound to the external record it stands for. `source` is required here, where the model leaves it optional: a bound item's identity is its source record, and the source-qualified identifier is its element id.
|
|
24
|
-
*/
|
|
25
|
-
const boundActivitySchema = activityElementSchema.unwrap().extend({ source: z.string().min(1) }).refine((activity) => activity.id === activity.source, {
|
|
26
|
-
message: "a bound activity's id must equal its source",
|
|
27
|
-
path: ["id"]
|
|
28
|
-
}).readonly();
|
|
29
20
|
/** The relation kinds a store keeps beside a model, the same kinds a source reports. */
|
|
30
21
|
const relationKinds = [
|
|
31
22
|
"child-of",
|
|
@@ -41,7 +32,7 @@ const relationSchema = z.strictObject({
|
|
|
41
32
|
to: z.string().min(1)
|
|
42
33
|
}).readonly();
|
|
43
34
|
/**
|
|
44
|
-
* Items read from a source, to be merged into a stored model by identifier. Each participant, activity and transition replaces the one with the same id or is appended after the existing ones; the overlay's entries replace the run state of the elements they name; each relation not already stored is appended. Everything else in the model is left as it is.
|
|
35
|
+
* Items read from a source, to be merged into a stored model by identifier. Activities are graph-schema's `boundActivitySchema`, the same schema a source's sync page uses, so a page's items pass unchanged. Each participant, activity and transition replaces the one with the same id or is appended after the existing ones; the overlay's entries replace the run state of the elements they name; each relation not already stored is appended. Everything else in the model is left as it is.
|
|
45
36
|
*/
|
|
46
37
|
const boundItemsSchema = z.strictObject({
|
|
47
38
|
participants: z.array(modelShape.participants.unwrap().element).readonly(),
|
|
@@ -1499,4 +1490,4 @@ const createSqliteGraphStore = (options) => {
|
|
|
1499
1490
|
};
|
|
1500
1491
|
};
|
|
1501
1492
|
//#endregion
|
|
1502
|
-
export {
|
|
1493
|
+
export { modelSummarySchema as A, changeKinds as C, factRecordSchema as D, factNameSchema as E, storeChangeSchema as F, storedFactsSchema as I, storedModelSchema as L, relationKinds as M, relationSchema as N, issueSchema as O, revisionSchema as P, boundItemsSchema as S, factClearingSchema as T, mergeBoundItems as _, ancestorsOf as a, defaultSubscriptionCapacity as b, mergeRelations as c, factIssues as d, factsWithin as f, emptyModel as g, checkStored as h, serialised as i, reachSchema as j, modelIdSchema as k, relationIssues as l, withoutFacts as m, tables_exports as n, childrenOf as o, mergeFacts as p, migrate as r, descendantsOf as s, createSqliteGraphStore as t, relationsWithin as u, overlayWithin as v, factChangeSchema as w, GraphStoreError as x, ChangeFeed as y };
|
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as modelIdSchema, A as defaultSubscriptionCapacity, B as Relation, C as ElementRequest, D as ChangeFeedOptions, E as ChangeFeed, F as FactChange, G as StoredModel, H as Revision, I as FactClearing, J as factChangeSchema, K as boundItemsSchema, L as ModelId, M as GraphStoreFailure, N as BoundItems, O as ChangeSubscription, P as ChangeKind, Q as issueSchema, R as ModelSummary, S as overlayWithin, T as ModelRequest, U as StoreChange, V as RelationKind, W as StoredFacts, X as factNameSchema, Y as factClearingSchema, Z as factRecordSchema, _ as mergeFacts, a as blockedChainOf, at as storeChangeSchema, b as emptyModel, c as structureOf, ct as GraphStoreClient, d as descendantsOf, et as modelSummarySchema, f as mergeRelations, g as factsWithin, h as factIssues, i as Structure, it as revisionSchema, j as GraphStoreError, k as SubscribeOptions, l as ancestorsOf, lt as graphStoreContract, m as relationsWithin, n as GraphStoreRouter, nt as relationKinds, o as impactOf, ot as storedFactsSchema, p as relationIssues, q as changeKinds, r as createGraphStoreRouter, rt as relationSchema, s as readyOf, st as storedModelSchema, t as createFakeGraphStore, tt as reachSchema, u as childrenOf, v as withoutFacts, w as GraphStore, x as mergeBoundItems, y as checkStored, z as Reach } from "./index-KhygugOP.js";
|
|
2
2
|
import { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
|
|
3
3
|
import { MigrationMeta } from "drizzle-orm/migrator";
|
|
4
4
|
//#region ../../adapters/graph/store-sqlite/dist/database.d.ts
|
|
@@ -1437,4 +1437,4 @@ declare const namedFacts: import("drizzle-orm/sqlite-core").SQLiteTableWithColum
|
|
|
1437
1437
|
dialect: "sqlite";
|
|
1438
1438
|
}>;
|
|
1439
1439
|
//#endregion
|
|
1440
|
-
export { type
|
|
1440
|
+
export { type BoundItems, ChangeFeed, type ChangeFeedOptions, type ChangeKind, type ChangeSubscription, type ElementRequest, type Exclusive, type FactChange, type FactClearing, type GraphStore, type GraphStoreClient, GraphStoreError, type GraphStoreFailure, type GraphStoreRouter, type ModelId, type ModelRequest, type ModelSummary, type Reach, type Relation, type RelationKind, type Revision, type SqliteDatabase, type SqliteGraphStoreOptions, type StoreChange, type StoredFacts, type StoredModel, type Structure, type SubscribeOptions, ancestorsOf, blockedChainOf, boundItemsSchema, changeKinds, checkStored, childrenOf, createFakeGraphStore, createGraphStoreRouter, defaultSubscriptionCapacity, descendantsOf, emptyModel, factChangeSchema, factClearingSchema, factIssues, factNameSchema, factRecordSchema, factsWithin, graphStoreContract, impactOf, issueSchema, mergeBoundItems, mergeFacts, mergeRelations, modelIdSchema, modelSummarySchema, overlayWithin, reachSchema, readyOf, relationIssues, relationKinds, relationSchema, relationsWithin, revisionSchema, storeChangeSchema, storedFactsSchema, storedModelSchema, structureOf, tables_d_exports as tables, withoutFacts };
|
package/dist/store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as loopTransitions, s as emptyFactRecord } from "./control-DiygoEhm.js";
|
|
2
|
-
import { A as
|
|
3
|
-
import { n as graphStoreContract, t as createGraphStoreRouter } from "./router-
|
|
2
|
+
import { A as modelSummarySchema, C as changeKinds, D as factRecordSchema, E as factNameSchema, F as storeChangeSchema, I as storedFactsSchema, L as storedModelSchema, M as relationKinds, N as relationSchema, O as issueSchema, P as revisionSchema, S as boundItemsSchema, T as factClearingSchema, _ as mergeBoundItems, a as ancestorsOf, b as defaultSubscriptionCapacity, c as mergeRelations, d as factIssues, f as factsWithin, g as emptyModel, h as checkStored, i as serialised, j as reachSchema, k as modelIdSchema, l as relationIssues, m as withoutFacts, n as tables_exports, o as childrenOf, p as mergeFacts, r as migrate, s as descendantsOf, t as createSqliteGraphStore, u as relationsWithin, v as overlayWithin, w as factChangeSchema, x as GraphStoreError, y as ChangeFeed } from "./store-CgweIG8J.js";
|
|
3
|
+
import { n as graphStoreContract, t as createGraphStoreRouter } from "./router-DzVcQ28U.js";
|
|
4
4
|
//#region ../../core/graph/store-contract/dist/structure.js
|
|
5
5
|
/**
|
|
6
6
|
* Whether an element is a pure control element: a `decision` or a pseudo-state. Control elements have no work of their own, so the structural queries pass through them and never report them.
|
|
@@ -269,4 +269,4 @@ const createFakeGraphStore = () => {
|
|
|
269
269
|
};
|
|
270
270
|
};
|
|
271
271
|
//#endregion
|
|
272
|
-
export { ChangeFeed, GraphStoreError, ancestorsOf, blockedChainOf,
|
|
272
|
+
export { ChangeFeed, GraphStoreError, ancestorsOf, blockedChainOf, boundItemsSchema, changeKinds, checkStored, childrenOf, createFakeGraphStore, createGraphStoreRouter, createSqliteGraphStore, defaultSubscriptionCapacity, descendantsOf, emptyModel, factChangeSchema, factClearingSchema, factIssues, factNameSchema, factRecordSchema, factsWithin, graphStoreContract, impactOf, issueSchema, mergeBoundItems, mergeFacts, mergeRelations, migrate, modelIdSchema, modelSummarySchema, overlayWithin, reachSchema, readyOf, relationIssues, relationKinds, relationSchema, relationsWithin, revisionSchema, serialised, storeChangeSchema, storedFactsSchema, storedModelSchema, structureOf, tables_exports as tables, withoutFacts };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ORPCError } from "@orpc/client";
|
|
2
|
+
//#region ../../core/graph/sync/dist/scopes.js
|
|
3
|
+
/** The separator between a scope's source prefix and the rest, as in `github:owner/repo`. */
|
|
4
|
+
const sourceSeparator = ":";
|
|
5
|
+
/** Thrown for a scope that names no source: it has no prefix before a colon. */
|
|
6
|
+
var InvalidScopeError = class extends Error {
|
|
7
|
+
/** The scope as it was given. */
|
|
8
|
+
scope;
|
|
9
|
+
/**
|
|
10
|
+
* @param scope - The scope that names no source.
|
|
11
|
+
*/
|
|
12
|
+
constructor(scope) {
|
|
13
|
+
super(`"${scope}" is not a scope: write <source>:<scope>, such as github:owner/repo`);
|
|
14
|
+
this.name = "InvalidScopeError";
|
|
15
|
+
this.scope = scope;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Groups source-qualified scopes by their source prefix, keeping each prefix where it first appears and each source's scopes in the order given. A sync reads the groups in this order, one source after another.
|
|
20
|
+
* @param scopes - Source-qualified scopes, such as `github:owner` or `github:owner/repo`.
|
|
21
|
+
* @returns One group per source prefix.
|
|
22
|
+
* @throws InvalidScopeError for a scope with nothing before its first colon, or no colon at all.
|
|
23
|
+
*/
|
|
24
|
+
const scopesBySource = (scopes) => {
|
|
25
|
+
const groups = /* @__PURE__ */ new Map();
|
|
26
|
+
for (const scope of scopes) {
|
|
27
|
+
const separator = scope.indexOf(sourceSeparator);
|
|
28
|
+
if (separator <= 0) throw new InvalidScopeError(scope);
|
|
29
|
+
const prefix = scope.slice(0, separator);
|
|
30
|
+
groups.set(prefix, [...groups.get(prefix) ?? [], scope]);
|
|
31
|
+
}
|
|
32
|
+
return [...groups].map(([prefix, grouped]) => ({
|
|
33
|
+
prefix,
|
|
34
|
+
scopes: grouped
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region ../../core/graph/sync/dist/sync.js
|
|
39
|
+
/** Thrown when a scope names a source no reader serves. */
|
|
40
|
+
var UnknownSourceError = class extends Error {
|
|
41
|
+
/** The source prefix no reader serves. */
|
|
42
|
+
prefix;
|
|
43
|
+
/**
|
|
44
|
+
* @param prefix - The source prefix no reader serves.
|
|
45
|
+
*/
|
|
46
|
+
constructor(prefix) {
|
|
47
|
+
super(`No source reads "${prefix}" scopes.`);
|
|
48
|
+
this.name = "UnknownSourceError";
|
|
49
|
+
this.prefix = prefix;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Thrown by `syncScopes` when a source fails while it is being read: opening its stream or reading a page. Its message is the source's, its cause is what the source threw, and where to carry on is data in `resume` and `remaining`. A failure of the store, or of the request itself (an unknown source, a malformed scope), is thrown as it is.
|
|
54
|
+
*/
|
|
55
|
+
var InterruptedSyncError = class extends Error {
|
|
56
|
+
resume;
|
|
57
|
+
remaining;
|
|
58
|
+
saved;
|
|
59
|
+
/**
|
|
60
|
+
* @param interruption - Where the sync carries on.
|
|
61
|
+
* @param cause - What the source threw.
|
|
62
|
+
*/
|
|
63
|
+
constructor(interruption, cause) {
|
|
64
|
+
super(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
65
|
+
this.name = "InterruptedSyncError";
|
|
66
|
+
this.resume = interruption.resume;
|
|
67
|
+
this.remaining = interruption.remaining;
|
|
68
|
+
this.saved = interruption.saved;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/** The oRPC client options carrying a signal, leaving the key out when there is none, since the options type does not accept an explicit `undefined`. */
|
|
72
|
+
const callOptions = (signal) => signal === void 0 ? {} : { signal };
|
|
73
|
+
/** The identifiers of the elements and participants a model in the store already has, or none when the store has no such model. */
|
|
74
|
+
const storedIdentifiers = async (store, modelId, signal) => {
|
|
75
|
+
try {
|
|
76
|
+
const stored = await store.v1.models.load({ modelId }, callOptions(signal));
|
|
77
|
+
return /* @__PURE__ */ new Set([...stored.model.elements.map((element) => element.id), ...stored.model.participants.map((participant) => participant.id)]);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (error instanceof ORPCError && error.code === "NOT_FOUND") return /* @__PURE__ */ new Set();
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const relationKey = (relation) => JSON.stringify([
|
|
84
|
+
relation.kind,
|
|
85
|
+
relation.from,
|
|
86
|
+
relation.to
|
|
87
|
+
]);
|
|
88
|
+
/** Splits what is waiting to be written into what can be written now, whose ends are all known, and what must wait for a later page. */
|
|
89
|
+
const settle = (pending, endsOf, known, last) => {
|
|
90
|
+
const ready = pending.filter((item) => last || endsOf(item).every((id) => known.has(id)));
|
|
91
|
+
return {
|
|
92
|
+
ready,
|
|
93
|
+
held: pending.filter((item) => !ready.includes(item))
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Reads the scopes from their sources page by page and merges each page into the stored model as soon as it is read: participants, bound activities, transitions, relations and run state. Progress is kept as it is made, so a sync that is cancelled, rate limited or interrupted leaves everything it read in the store, and a checkpoint to carry on from.
|
|
98
|
+
*
|
|
99
|
+
* A store rejects a write that leaves a transition or a relation naming an element or participant the model lacks, and a source may report a dependency or a sub-issue whose other end a later page brings. A transition or relation is therefore held back until the model has both of its ends, and written with the page that completes it. One whose end never arrives is written with the last page, where the store's rejection says which reference is missing.
|
|
100
|
+
* @param request - The store, sources, model, scopes, an optional filter and checkpoint, the signal and a progress listener.
|
|
101
|
+
* @returns The final progress, with no checkpoint.
|
|
102
|
+
* @throws InvalidScopeError for a scope that names no source; UnknownSourceError for a scope whose source no reader serves; an Error for a checkpoint naming a source none of the scopes use, and for a sync of no scopes; InterruptedSyncError, after the pages before it are written, when a source fails while it is read, an abort included; and whatever the store throws.
|
|
103
|
+
*/
|
|
104
|
+
const syncScopes = async (request) => {
|
|
105
|
+
const { store, sources, modelId, scopes, filter, resume, signal } = request;
|
|
106
|
+
const groups = scopesBySource(scopes).map((group) => {
|
|
107
|
+
const client = sources(group.prefix);
|
|
108
|
+
if (client === void 0) throw new UnknownSourceError(group.prefix);
|
|
109
|
+
return {
|
|
110
|
+
...group,
|
|
111
|
+
client
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
if (groups.length === 0) throw new Error("A sync needs at least one scope.");
|
|
115
|
+
const startGroup = resume === void 0 ? 0 : groups.findIndex((group) => group.prefix === resume.source);
|
|
116
|
+
if (startGroup === -1) throw new Error("The checkpoint names a source that none of the scopes use; start the sync again.");
|
|
117
|
+
const known = new Set(await storedIdentifiers(store, modelId, signal));
|
|
118
|
+
const written = {
|
|
119
|
+
participants: /* @__PURE__ */ new Set(),
|
|
120
|
+
activities: /* @__PURE__ */ new Set(),
|
|
121
|
+
transitions: /* @__PURE__ */ new Set(),
|
|
122
|
+
relations: /* @__PURE__ */ new Set()
|
|
123
|
+
};
|
|
124
|
+
const gaps = [];
|
|
125
|
+
let heldTransitions = [];
|
|
126
|
+
let heldRelations = [];
|
|
127
|
+
let pages = 0;
|
|
128
|
+
let latest;
|
|
129
|
+
const checkpointAt = (source, after) => ({
|
|
130
|
+
modelId,
|
|
131
|
+
scopes,
|
|
132
|
+
...filter === void 0 ? {} : { filter },
|
|
133
|
+
source,
|
|
134
|
+
...after === void 0 ? {} : { after }
|
|
135
|
+
});
|
|
136
|
+
const write = async (page, checkpoint) => {
|
|
137
|
+
for (const record of [...page.participants, ...page.activities]) known.add(record.id);
|
|
138
|
+
const last = checkpoint === void 0;
|
|
139
|
+
const transitions = settle([...heldTransitions, ...page.transitions], (transition) => [transition.source, transition.target], known, last);
|
|
140
|
+
const relations = settle([...heldRelations, ...page.relations], (relation) => [relation.from, relation.to], known, last);
|
|
141
|
+
heldTransitions = transitions.held;
|
|
142
|
+
heldRelations = relations.held;
|
|
143
|
+
const { revision } = await store.v1.items.upsert({
|
|
144
|
+
modelId,
|
|
145
|
+
items: {
|
|
146
|
+
participants: page.participants,
|
|
147
|
+
activities: page.activities,
|
|
148
|
+
transitions: transitions.ready,
|
|
149
|
+
relations: relations.ready,
|
|
150
|
+
overlay: page.overlay
|
|
151
|
+
}
|
|
152
|
+
}, callOptions(signal));
|
|
153
|
+
pages += 1;
|
|
154
|
+
for (const participant of page.participants) written.participants.add(participant.id);
|
|
155
|
+
for (const activity of page.activities) written.activities.add(activity.id);
|
|
156
|
+
for (const transition of transitions.ready) written.transitions.add(transition.id);
|
|
157
|
+
for (const relation of relations.ready) written.relations.add(relationKey(relation));
|
|
158
|
+
gaps.push(...page.gaps);
|
|
159
|
+
latest = {
|
|
160
|
+
pages,
|
|
161
|
+
revision,
|
|
162
|
+
participants: written.participants.size,
|
|
163
|
+
activities: written.activities.size,
|
|
164
|
+
transitions: written.transitions.size,
|
|
165
|
+
relations: written.relations.size,
|
|
166
|
+
gaps: [...gaps],
|
|
167
|
+
checkpoint
|
|
168
|
+
};
|
|
169
|
+
request.onProgress?.(latest);
|
|
170
|
+
};
|
|
171
|
+
/** Reads the sources in order, each only after the one before has finished, since a source's failure must stop the ones after it. */
|
|
172
|
+
const readFrom = async (index) => {
|
|
173
|
+
const group = groups[index];
|
|
174
|
+
if (group === void 0) return;
|
|
175
|
+
let after = index === startGroup ? resume?.after : void 0;
|
|
176
|
+
const following = groups[index + 1];
|
|
177
|
+
const interrupted = (cause) => new InterruptedSyncError({
|
|
178
|
+
resume: checkpointAt(group.prefix, after),
|
|
179
|
+
remaining: groups.slice(index + 1).flatMap((next) => next.scopes),
|
|
180
|
+
saved: pages > 0
|
|
181
|
+
}, cause);
|
|
182
|
+
const iterator = (await group.client.v1.sync.stream({
|
|
183
|
+
scope: group.scopes,
|
|
184
|
+
...after === void 0 ? {} : { after },
|
|
185
|
+
...filter === void 0 ? {} : { filter }
|
|
186
|
+
}, callOptions(signal)).catch((cause) => {
|
|
187
|
+
throw interrupted(cause);
|
|
188
|
+
}))[Symbol.asyncIterator]();
|
|
189
|
+
/** Writes each page the source yields, in order, each only after the one before is written. */
|
|
190
|
+
const drain = async () => {
|
|
191
|
+
const next = await iterator.next().catch((cause) => {
|
|
192
|
+
throw interrupted(cause);
|
|
193
|
+
});
|
|
194
|
+
if (next.done === true) return;
|
|
195
|
+
const page = next.value;
|
|
196
|
+
await write(page, page.next !== void 0 ? checkpointAt(group.prefix, page.next) : following === void 0 ? void 0 : checkpointAt(following.prefix, void 0));
|
|
197
|
+
after = page.next;
|
|
198
|
+
await drain();
|
|
199
|
+
};
|
|
200
|
+
try {
|
|
201
|
+
await drain();
|
|
202
|
+
} catch (error) {
|
|
203
|
+
await iterator.return();
|
|
204
|
+
throw error;
|
|
205
|
+
}
|
|
206
|
+
await readFrom(index + 1);
|
|
207
|
+
};
|
|
208
|
+
await readFrom(startGroup);
|
|
209
|
+
if (latest === void 0) throw new Error("unreachable: every source answers a sync with at least one page");
|
|
210
|
+
return latest;
|
|
211
|
+
};
|
|
212
|
+
//#endregion
|
|
213
|
+
export { scopesBySource as a, InvalidScopeError as i, UnknownSourceError as n, syncScopes as r, InterruptedSyncError as t };
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as SyncRequest, c as syncScopes, i as SyncProgress, l as SyncCheckpoint, n as SourceLookup, o as SyncStore, r as SyncInterruption, s as UnknownSourceError, t as InterruptedSyncError, u as syncCheckpointSchema } from "./index-7nV7hCmv.js";
|
|
2
|
+
//#region ../../core/graph/sync/dist/scopes.d.ts
|
|
3
|
+
/** The scopes of one source, in the order they were given. */
|
|
4
|
+
interface SourceScopes {
|
|
5
|
+
/** The source's identifier prefix, such as `github`. */
|
|
6
|
+
readonly prefix: string;
|
|
7
|
+
readonly scopes: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/** Thrown for a scope that names no source: it has no prefix before a colon. */
|
|
10
|
+
export declare class InvalidScopeError extends Error {
|
|
11
|
+
/** The scope as it was given. */
|
|
12
|
+
readonly scope: string;
|
|
13
|
+
/**
|
|
14
|
+
* @param scope - The scope that names no source.
|
|
15
|
+
*/
|
|
16
|
+
constructor(scope: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Groups source-qualified scopes by their source prefix, keeping each prefix where it first appears and each source's scopes in the order given. A sync reads the groups in this order, one source after another.
|
|
20
|
+
* @param scopes - Source-qualified scopes, such as `github:owner` or `github:owner/repo`.
|
|
21
|
+
* @returns One group per source prefix.
|
|
22
|
+
* @throws InvalidScopeError for a scope with nothing before its first colon, or no colon at all.
|
|
23
|
+
*/
|
|
24
|
+
export declare const scopesBySource: (scopes: readonly string[]) => readonly SourceScopes[];
|
|
25
|
+
//#endregion
|
|
26
|
+
export { InterruptedSyncError, type SourceLookup, type SourceScopes, type SyncCheckpoint, type SyncInterruption, type SyncProgress, type SyncRequest, type SyncStore, UnknownSourceError, syncCheckpointSchema, syncScopes };
|
package/dist/sync.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { h as syncFilterSchema } from "./schema-DMXa8gAZ.js";
|
|
2
|
+
import { a as scopesBySource, i as InvalidScopeError, n as UnknownSourceError, r as syncScopes, t as InterruptedSyncError } from "./sync-CkaJO3OQ.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region ../../core/graph/sync/dist/checkpoint.js
|
|
5
|
+
/**
|
|
6
|
+
* Where a sync stopped: the model, every scope it was asked for in order, the filter it read them with, the prefix of the source to read next, and the cursor after the last page it wrote within that source's scopes (absent to read them from the start). Everything before it is in the store, so a sync started from it reads only what is left. A source's cursor is valid only with the scopes and filter it was issued for, which is why both are kept with it.
|
|
7
|
+
*/
|
|
8
|
+
const syncCheckpointSchema = z.strictObject({
|
|
9
|
+
modelId: z.string().min(1),
|
|
10
|
+
scopes: z.array(z.string().min(1)).readonly(),
|
|
11
|
+
filter: syncFilterSchema.optional(),
|
|
12
|
+
source: z.string().min(1),
|
|
13
|
+
after: z.string().min(1).optional()
|
|
14
|
+
}).readonly();
|
|
15
|
+
//#endregion
|
|
16
|
+
export { InterruptedSyncError, InvalidScopeError, UnknownSourceError, scopesBySource, syncCheckpointSchema, syncScopes };
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as Status } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { f as LaneProps, h as TransitionItemProps, l as LegendProps, o as FilterPanelProps, r as DetailPanelProps, v as ElementCardProps } from "./index-
|
|
1
|
+
import { B as Status } from "./index-wQnLXJmD.js";
|
|
2
|
+
import { Y as IdSpace } from "./index-DYl6lZLe.js";
|
|
3
|
+
import { y as SequenceDiagram$1 } from "./index-DluJZTbT.js";
|
|
4
|
+
import { f as LaneProps, h as TransitionItemProps, l as LegendProps, o as FilterPanelProps, r as DetailPanelProps, v as ElementCardProps } from "./index-C-ZNF81j.js";
|
|
5
5
|
import { a as lightTheme, i as darkTheme, n as darkValues, o as vars, r as lightValues, t as ThemeValues } from "./theme-values-BybZ-cle.js";
|
|
6
6
|
import { ReactElement, ReactNode } from "react";
|
|
7
7
|
//#region ../../ui/graph/ui/dist/base.css.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/version.ts
|
|
2
2
|
/** The version of the installed `process-graph` package, as its manifest names it. The bundler writes it in when the package is built, so reading it touches no file. */
|
|
3
|
-
const version = "
|
|
3
|
+
const version = "2.0.0";
|
|
4
4
|
//#endregion
|
|
5
5
|
export { version as t };
|