@pgxsinkit/client 0.6.2 → 0.6.4
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/circuits/group-sync.d.ts.map +1 -1
- package/dist/circuits/sync-engine.d.ts.map +1 -1
- package/dist/event-lane.d.ts.map +1 -1
- package/dist/export-data.d.ts.map +1 -1
- package/dist/export-dump.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -10
- package/dist/index.js.map +19 -19
- package/dist/local-tables.d.ts.map +1 -1
- package/dist/opfs-effects.d.ts.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/sync/subscription-state.d.ts.map +1 -1
- package/dist/worker/attach-sync-client.d.ts.map +1 -1
- package/dist/worker/define-sync-worker.d.ts +1 -1
- package/dist/worker/define-sync-worker.d.ts.map +1 -1
- package/dist/worker/engine-router.d.ts.map +1 -1
- package/package.json +7 -9
- package/skills/core/SKILL.md +1 -6
- package/skills/operating/SKILL.md +1 -1
- package/src/circuits/group-sync.ts +6 -6
- package/src/circuits/shape-group.ts +1 -1
- package/src/circuits/stream-source.ts +2 -2
- package/src/circuits/sync-engine.ts +4 -4
- package/src/event-lane.ts +4 -4
- package/src/export-data.ts +5 -1
- package/src/export-dump.ts +1 -1
- package/src/index.ts +16 -10
- package/src/local-tables.ts +4 -4
- package/src/mutation.ts +2 -2
- package/src/opfs-effects.ts +1 -1
- package/src/schema.ts +2 -2
- package/src/sync/subscription-state.ts +1 -1
- package/src/worker/attach-sync-client.ts +13 -12
- package/src/worker/define-sync-worker.ts +9 -5
- package/src/worker/election-coordinator.ts +1 -1
- package/src/worker/engine-router.ts +3 -3
- package/oxlint-plugin.js +0 -143
|
@@ -33,13 +33,13 @@ import { setSyncDebugSink, syncDebug } from "../debug";
|
|
|
33
33
|
import { describeErrorChain } from "../error-chain";
|
|
34
34
|
import type { EventLaneOptions } from "../event-lane";
|
|
35
35
|
import {
|
|
36
|
-
type PgwasmClient,
|
|
37
36
|
createPgwasmClient,
|
|
38
|
-
type CreateSyncClientOptions,
|
|
39
37
|
createSyncClient,
|
|
38
|
+
type CreateSyncClientOptions,
|
|
40
39
|
type DataExportOptions,
|
|
41
40
|
type DiagnosticExportOptions,
|
|
42
41
|
type MutationBatchItem,
|
|
42
|
+
type PgwasmClient,
|
|
43
43
|
type RawQueryOptions,
|
|
44
44
|
type RawStatement,
|
|
45
45
|
type StoreExportOptions,
|
|
@@ -57,9 +57,9 @@ import {
|
|
|
57
57
|
assertSameExecutionLimit,
|
|
58
58
|
type EngineControlMessage,
|
|
59
59
|
type EngineIdentity,
|
|
60
|
+
type ExecutionLimitConfig,
|
|
60
61
|
ExecutionLimitMismatchError,
|
|
61
62
|
executionLimitMismatchToWire,
|
|
62
|
-
type ExecutionLimitConfig,
|
|
63
63
|
ProvisionStalledError,
|
|
64
64
|
provisionStalledToWire,
|
|
65
65
|
readControlEnvelope,
|
|
@@ -78,8 +78,8 @@ import {
|
|
|
78
78
|
type BootMilestone,
|
|
79
79
|
type BridgeCodec,
|
|
80
80
|
type BridgeEnvelope,
|
|
81
|
-
type BridgeEvent,
|
|
82
81
|
type BridgeErrorWire,
|
|
82
|
+
type BridgeEvent,
|
|
83
83
|
type BridgePort,
|
|
84
84
|
type BridgeTransferable,
|
|
85
85
|
type ExportArtefactWire,
|
|
@@ -574,7 +574,11 @@ export function defineSyncWorker<const TRegistry extends SyncTableRegistry>(
|
|
|
574
574
|
broadcastEvent({ kind: "status", status });
|
|
575
575
|
// Derive a per-group `groupReady` event for each group that newly reached ready, so a tab gets both the
|
|
576
576
|
// status snapshot (`status.groups`) and a discrete edge to await (ADR-0032 decision 6/7).
|
|
577
|
-
|
|
577
|
+
const groups = status.groups ?? {};
|
|
578
|
+
for (const groupKey of seenReadyGroups) {
|
|
579
|
+
if (groups[groupKey] !== true) seenReadyGroups.delete(groupKey);
|
|
580
|
+
}
|
|
581
|
+
for (const [groupKey, ready] of Object.entries(groups)) {
|
|
578
582
|
if (ready && !seenReadyGroups.has(groupKey)) {
|
|
579
583
|
seenReadyGroups.add(groupKey);
|
|
580
584
|
broadcastEvent({ kind: "groupReady", groupKey });
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
import { storeIdentityComponent } from "../store-path";
|
|
34
34
|
import {
|
|
35
|
-
engineIdentityEquals,
|
|
36
35
|
type EngineControlMessage,
|
|
37
36
|
type EngineIdentity,
|
|
37
|
+
engineIdentityEquals,
|
|
38
38
|
readControlEnvelope as readEnvelope,
|
|
39
39
|
wrapControlEnvelope as envelope,
|
|
40
40
|
} from "./engine-control";
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
// `ch`/`v` and is ignored by the bridge router. Step 7's attach client speaks this SAME envelope.
|
|
35
35
|
|
|
36
36
|
import {
|
|
37
|
+
type EngineControlMessage,
|
|
38
|
+
type EngineIdentity,
|
|
37
39
|
engineIdentityEquals,
|
|
40
|
+
type ExecutionLimitConfig,
|
|
38
41
|
mintEngineIdentity,
|
|
39
42
|
readControlEnvelope,
|
|
40
43
|
shouldApplyControlMessage,
|
|
41
|
-
type EngineControlMessage,
|
|
42
|
-
type EngineIdentity,
|
|
43
|
-
type ExecutionLimitConfig,
|
|
44
44
|
wrapControlEnvelope as envelope,
|
|
45
45
|
} from "./engine-control";
|
|
46
46
|
|
package/oxlint-plugin.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// Custom oxlint plugin for pgxsinkit's guarded-query surface (ADR-0021).
|
|
2
|
-
//
|
|
3
|
-
// The type split makes `use` structurally absent on the pure `client.query` / `queryRow` path (they take
|
|
4
|
-
// the builder callback directly). This rule catches the two provenance facts the type system cannot see:
|
|
5
|
-
// A) a raw `sql` fragment smuggled into the pure path — the compiled-SQL scan can miss a lazy relation
|
|
6
|
-
// named as a bare/unquoted identifier there, silently losing the guard; and
|
|
7
|
-
// B) a `use` on the raw path (`queryRaw` / `useLiveQueryRaw`) whose builder is actually pure Drizzle — the
|
|
8
|
-
// scan already detects every relation, so the `use` is redundant (autofixed away).
|
|
9
|
-
//
|
|
10
|
-
// Shipped with @pgxsinkit/client via the `./oxlint` subpath export, so consumers can enable it in their
|
|
11
|
-
// own oxlint config: `"jsPlugins": ["@pgxsinkit/client/oxlint"]` + `"pgxsinkit/guarded-query-purity": "error"`.
|
|
12
|
-
// Plain JS (not TS, and outside src/) on purpose: it is a tooling artifact loaded by oxlint at lint time,
|
|
13
|
-
// not part of the library's typed surface, so it is neither built nor typechecked nor self-linted.
|
|
14
|
-
//
|
|
15
|
-
// NOTE: this plugin has NO version logic — it runs under whatever oxlint loads it (1.72, 1.73, …), not
|
|
16
|
-
// only the version it was written against. But oxlint's jsPlugins feature is alpha and NOT semver-covered:
|
|
17
|
-
// the plugin API it relies on (create/context/report, ESTree node `.range`, `fixer.removeRange`) can
|
|
18
|
-
// change on a *minor* oxlint bump without that being flagged as breaking. That is why oxlint is pinned to
|
|
19
|
-
// an EXACT version in package.json (no `^`) — so upgrades are deliberate. On every oxlint bump, re-run
|
|
20
|
-
// lint and confirm this rule still loads and fires; adjust it here if the alpha API drifted.
|
|
21
|
-
|
|
22
|
-
const PURE_METHODS = new Set(["query", "queryRow"]);
|
|
23
|
-
const RAW_METHODS = new Set(["queryRaw", "queryRawRow", "useLiveQueryRaw", "useLiveQueryRawRow"]);
|
|
24
|
-
|
|
25
|
-
/** Depth-first visit of every descendant AST node. */
|
|
26
|
-
function walk(node, visit) {
|
|
27
|
-
if (!node || typeof node !== "object") return;
|
|
28
|
-
if (typeof node.type === "string") visit(node);
|
|
29
|
-
for (const key in node) {
|
|
30
|
-
if (key === "parent") continue;
|
|
31
|
-
const child = node[key];
|
|
32
|
-
if (Array.isArray(child)) {
|
|
33
|
-
for (const item of child) walk(item, visit);
|
|
34
|
-
} else if (child && typeof child === "object") {
|
|
35
|
-
walk(child, visit);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** True if this build function embeds a raw SQL fragment: a ``sql`…` `` tagged template or `sql.raw(...)`. */
|
|
41
|
-
function usesRawSql(fn) {
|
|
42
|
-
let found = false;
|
|
43
|
-
walk(fn.body, (n) => {
|
|
44
|
-
if (found) return;
|
|
45
|
-
if (n.type === "TaggedTemplateExpression") {
|
|
46
|
-
const tag = n.tag;
|
|
47
|
-
if (tag && tag.type === "Identifier" && tag.name === "sql") found = true;
|
|
48
|
-
else if (tag && tag.type === "MemberExpression" && tag.property && tag.property.name === "sql") found = true;
|
|
49
|
-
} else if (n.type === "CallExpression") {
|
|
50
|
-
const c = n.callee;
|
|
51
|
-
if (
|
|
52
|
-
c &&
|
|
53
|
-
c.type === "MemberExpression" &&
|
|
54
|
-
c.object &&
|
|
55
|
-
c.object.name === "sql" &&
|
|
56
|
-
c.property &&
|
|
57
|
-
c.property.name === "raw"
|
|
58
|
-
) {
|
|
59
|
-
found = true;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return found;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function isFunction(node) {
|
|
67
|
-
return !!node && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const guardedQueryPurity = {
|
|
71
|
-
meta: {
|
|
72
|
-
type: "problem",
|
|
73
|
-
fixable: "code",
|
|
74
|
-
docs: { description: "Guard the pure/raw split of the pgxsinkit client query surface (ADR-0021)." },
|
|
75
|
-
},
|
|
76
|
-
create(context) {
|
|
77
|
-
const sourceCode = context.sourceCode ?? context.getSourceCode();
|
|
78
|
-
return {
|
|
79
|
-
CallExpression(node) {
|
|
80
|
-
const callee = node.callee;
|
|
81
|
-
const method =
|
|
82
|
-
callee && callee.type === "MemberExpression"
|
|
83
|
-
? callee.property && callee.property.name
|
|
84
|
-
: callee && callee.type === "Identifier"
|
|
85
|
-
? callee.name
|
|
86
|
-
: undefined;
|
|
87
|
-
if (!method || (!PURE_METHODS.has(method) && !RAW_METHODS.has(method))) return;
|
|
88
|
-
|
|
89
|
-
const arg0 = node.arguments && node.arguments[0];
|
|
90
|
-
let buildFn;
|
|
91
|
-
let useProp;
|
|
92
|
-
if (isFunction(arg0)) {
|
|
93
|
-
buildFn = arg0; // pure callback form: query(fn) / queryRow(fn)
|
|
94
|
-
} else if (arg0 && arg0.type === "ObjectExpression") {
|
|
95
|
-
for (const p of arg0.properties) {
|
|
96
|
-
if (p.type !== "Property" || !p.key) continue;
|
|
97
|
-
if (p.key.name === "build") buildFn = p.value;
|
|
98
|
-
else if (p.key.name === "use") useProp = p;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (!isFunction(buildFn)) return;
|
|
102
|
-
|
|
103
|
-
const raw = usesRawSql(buildFn);
|
|
104
|
-
|
|
105
|
-
// A) raw sql on the PURE path — the scan can miss a bare identifier → a real safety hole.
|
|
106
|
-
if (PURE_METHODS.has(method) && raw) {
|
|
107
|
-
const rawEquivalent = method === "queryRow" ? "queryRawRow" : "queryRaw";
|
|
108
|
-
context.report({
|
|
109
|
-
node: buildFn,
|
|
110
|
-
message:
|
|
111
|
-
`${method}() is the pure-Drizzle path but its build() embeds a raw \`sql\` fragment, which the ` +
|
|
112
|
-
`lazy-relation scan can miss (a bare identifier). Use client.${rawEquivalent}({ use, build }) and ` +
|
|
113
|
-
`declare the lazy relations in \`use\` (ADR-0021).`,
|
|
114
|
-
});
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// B) `use` on the raw path with a pure build — redundant. Autofix: drop the `use` property.
|
|
119
|
-
if (RAW_METHODS.has(method) && useProp && !raw) {
|
|
120
|
-
context.report({
|
|
121
|
-
node: useProp,
|
|
122
|
-
message:
|
|
123
|
-
"`use` is redundant here: build() is pure Drizzle, so the compiled-SQL scan detects every " +
|
|
124
|
-
"relation it reads. Drop `use` and prefer the pure query method (ADR-0021).",
|
|
125
|
-
fix(fixer) {
|
|
126
|
-
const text = sourceCode.getText();
|
|
127
|
-
const start = useProp.range[0];
|
|
128
|
-
let end = useProp.range[1];
|
|
129
|
-
while (end < text.length && /\s/.test(text[end])) end++;
|
|
130
|
-
if (text[end] === ",") end++;
|
|
131
|
-
return fixer.removeRange([start, end]);
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export default {
|
|
141
|
-
meta: { name: "pgxsinkit" },
|
|
142
|
-
rules: { "guarded-query-purity": guardedQueryPurity },
|
|
143
|
-
};
|