@voltro/protocol 0.85.0 → 0.86.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/CHANGELOG.md +666 -0
- package/README.md +14 -0
- package/THIRD-PARTY-NOTICES.md +5 -33
- package/dist/approval.js +64 -0
- package/dist/approvalDescriptors.js +26 -0
- package/dist/auth.js +369 -0
- package/dist/boundedRing.js +27 -0
- package/dist/businessRule.js +11 -0
- package/dist/connection.js +73 -0
- package/dist/devActivity.js +4 -0
- package/dist/errorValue.js +21 -0
- package/dist/event.js +104 -0
- package/dist/idempotency.js +66 -0
- package/dist/identity.js +5 -9
- package/dist/index.d.ts +225 -21
- package/dist/index.js +42 -1700
- package/dist/inspect.js +14 -240
- package/dist/inspectBackfill.js +52 -0
- package/dist/inspectCommandRejection.js +21 -0
- package/dist/inspectProjection.js +133 -0
- package/dist/inspectStorageProjection.js +86 -0
- package/dist/inspectValueIdentity.js +4 -0
- package/dist/inspectWorkflowExecution.js +34 -0
- package/dist/inspectWorkflowQueuedStart.js +31 -0
- package/dist/jsonSchema.js +54 -0
- package/dist/outbox.js +10 -0
- package/dist/pairing.js +75 -0
- package/dist/plugin.js +61 -0
- package/dist/pluginNaming.js +32 -0
- package/dist/procedure.js +262 -0
- package/dist/publicApi.js +344 -0
- package/dist/reactivityChannel.js +34 -0
- package/dist/rest.d.ts +33 -0
- package/dist/rest.js +213 -470
- package/dist/restFormat.js +163 -0
- package/dist/rowEquality.js +31 -0
- package/dist/rowPatch.js +182 -0
- package/dist/schemaShape.js +67 -0
- package/dist/scopes.js +240 -0
- package/dist/serverErrorBus.js +15 -0
- package/dist/serviceCall.js +14 -0
- package/dist/session.js +13 -15
- package/dist/{sessionHeader-DriTZhmv.js → sessionHeader.js} +1 -1
- package/dist/storageAccess.js +14 -0
- package/dist/storeErrors.js +66 -0
- package/dist/storeScreenshots.js +90 -0
- package/dist/strictInput.js +27 -0
- package/dist/subscriptionEvent.js +37 -0
- package/dist/tenantSelection.js +40 -0
- package/dist/time.js +7 -0
- package/dist/undo.js +38 -0
- package/dist/validation.js +39 -0
- package/dist/webSocketGateway.js +10 -0
- package/dist/workflow.js +297 -0
- package/dist/workflowAccess.js +61 -0
- package/dist/workflowRestart.js +45 -0
- package/dist/workflowRetry.js +44 -0
- package/dist/workflowStartOutcome.js +30 -0
- package/package.json +3 -3
- package/dist/restFormat-BlgTLxm1.js +0 -298
- package/dist/scopes-ClywBij8.js +0 -548
package/dist/outbox.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/outbox.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (typeof e != "object" || !e) throw Error(`Outbox handler ${t}: definition must be an object`);
|
|
4
|
+
let n = e;
|
|
5
|
+
if (typeof n.effect != "string" || n.effect.trim() === "") throw Error(`Outbox handler ${t}: effect must be a non-empty string`);
|
|
6
|
+
if (typeof n.handler != "function") throw Error(`Outbox handler ${t}: handler must be a function`);
|
|
7
|
+
if (n.maxAttempts !== void 0 && (typeof n.maxAttempts != "number" || !Number.isSafeInteger(n.maxAttempts) || n.maxAttempts < 1)) throw Error(`Outbox handler ${t}: maxAttempts must be a positive safe integer`);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as validateOutboxHandlerDefinition };
|
package/dist/pairing.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/pairing.ts
|
|
2
|
+
var e = "voltro-dev", t = "pair", n = "voltro:pairing", r = (e) => {
|
|
3
|
+
try {
|
|
4
|
+
let t = new URL(e);
|
|
5
|
+
return t.protocol === "http:" || t.protocol === "https:";
|
|
6
|
+
} catch {
|
|
7
|
+
return !1;
|
|
8
|
+
}
|
|
9
|
+
}, i = (e) => {
|
|
10
|
+
try {
|
|
11
|
+
let t = new URL(e).hostname;
|
|
12
|
+
return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "[::1]";
|
|
13
|
+
} catch {
|
|
14
|
+
return !1;
|
|
15
|
+
}
|
|
16
|
+
}, a = (n) => {
|
|
17
|
+
if (!r(n.api)) throw Error(`pairingLink: api must be an http(s) url, got ${JSON.stringify(n.api)}`);
|
|
18
|
+
if (i(n.api)) throw Error("pairingLink: api must be the LAN address — a device cannot reach localhost on this machine");
|
|
19
|
+
if (!/^[A-Za-z0-9_-]+$/.test(n.name)) throw Error(`pairingLink: name must be a plain identifier, got ${JSON.stringify(n.name)}`);
|
|
20
|
+
let a = new URLSearchParams({
|
|
21
|
+
api: n.api,
|
|
22
|
+
name: n.name
|
|
23
|
+
});
|
|
24
|
+
return n.token !== void 0 && n.token.length > 0 && a.set("token", n.token), `${e}://${t}?${a.toString()}`;
|
|
25
|
+
}, o = (e) => {
|
|
26
|
+
let t;
|
|
27
|
+
try {
|
|
28
|
+
t = new URL(e);
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (t.protocol !== "voltro-dev:" || (t.host || t.pathname.replace(/^\/+/, "")) !== "pair") return null;
|
|
33
|
+
let n = t.searchParams.get("api") ?? "", a = t.searchParams.get("name") ?? "", o = t.searchParams.get("token");
|
|
34
|
+
return !r(n) || i(n) || !/^[A-Za-z0-9_-]+$/.test(a) ? null : {
|
|
35
|
+
api: n,
|
|
36
|
+
name: a,
|
|
37
|
+
...o !== null && o.length > 0 ? { token: o } : {}
|
|
38
|
+
};
|
|
39
|
+
}, s = (e) => "getItem" in e ? {
|
|
40
|
+
get: async (t) => e.getItem(t),
|
|
41
|
+
set: async (t, n) => {
|
|
42
|
+
await e.setItem(t, n);
|
|
43
|
+
},
|
|
44
|
+
remove: e.removeItem ? async (t) => {
|
|
45
|
+
await e.removeItem(t);
|
|
46
|
+
} : null
|
|
47
|
+
} : {
|
|
48
|
+
get: async (t) => e.get(t),
|
|
49
|
+
set: async (t, n) => {
|
|
50
|
+
await e.set(t, n);
|
|
51
|
+
},
|
|
52
|
+
remove: e.remove ? async (t) => {
|
|
53
|
+
await e.remove(t);
|
|
54
|
+
} : null
|
|
55
|
+
}, c = async (e, t) => {
|
|
56
|
+
await s(e).set(n, JSON.stringify(t));
|
|
57
|
+
}, l = async (e) => {
|
|
58
|
+
let t = await s(e).get(n);
|
|
59
|
+
if (t === null || t === "") return null;
|
|
60
|
+
try {
|
|
61
|
+
let e = JSON.parse(t);
|
|
62
|
+
return typeof e.api != "string" || typeof e.name != "string" || !r(e.api) ? null : {
|
|
63
|
+
api: e.api,
|
|
64
|
+
name: e.name,
|
|
65
|
+
...typeof e.token == "string" && e.token.length > 0 ? { token: e.token } : {}
|
|
66
|
+
};
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}, u = async (e) => {
|
|
71
|
+
let t = s(e);
|
|
72
|
+
t.remove ? await t.remove(n) : await t.set(n, "");
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { t as PAIRING_HOST, e as PAIRING_SCHEME, n as PAIRING_STORAGE_KEY, c as applyPairing, u as clearPairing, a as pairingLink, o as parsePairingLink, l as readPairing };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Context as e, Layer as t } from "effect";
|
|
2
|
+
//#region src/plugin.ts
|
|
3
|
+
var n = (e) => e, r = (e) => e, i = (e) => {
|
|
4
|
+
let t = e.alias?.trim(), n = e.instance?.trim(), r = t !== void 0 && t !== "" ? t : e.base;
|
|
5
|
+
return n !== void 0 && n !== "" ? `${r}#${n}` : r;
|
|
6
|
+
}, a = (e) => {
|
|
7
|
+
if (e.length !== 0) return (t, n) => e.reduceRight((e, t) => t(e, n), t);
|
|
8
|
+
}, o = (n, r) => {
|
|
9
|
+
let i = e.Service(n);
|
|
10
|
+
return {
|
|
11
|
+
Tag: i,
|
|
12
|
+
Live: t.succeed(i, r)
|
|
13
|
+
};
|
|
14
|
+
}, s = (e, t, n) => {
|
|
15
|
+
if (!t) return { ok: !0 };
|
|
16
|
+
let r = n === void 0 ? null : c(n);
|
|
17
|
+
if (!r) return {
|
|
18
|
+
ok: !0,
|
|
19
|
+
unverified: `plugin "${e}" requires framework ${t}, but the running framework version is ${n === void 0 ? "unknown" : `unreadable ("${n}")`} — not checked.`
|
|
20
|
+
};
|
|
21
|
+
let i = t.trim();
|
|
22
|
+
if (i === "*" || i === "") return { ok: !0 };
|
|
23
|
+
let a = i.split(/\s+/);
|
|
24
|
+
for (let i of a) if (!u(i, r)) return {
|
|
25
|
+
ok: !1,
|
|
26
|
+
reason: `plugin "${e}" requires framework ${t}, running ${n}`
|
|
27
|
+
};
|
|
28
|
+
return { ok: !0 };
|
|
29
|
+
}, c = (e) => {
|
|
30
|
+
let t = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?$/.exec(e.trim());
|
|
31
|
+
return t ? {
|
|
32
|
+
major: Number(t[1]),
|
|
33
|
+
minor: Number(t[2]),
|
|
34
|
+
patch: Number(t[3]),
|
|
35
|
+
pre: t[4] ?? ""
|
|
36
|
+
} : null;
|
|
37
|
+
}, l = (e, t) => e.major === t.major ? e.minor === t.minor ? e.patch === t.patch ? e.pre && !t.pre ? -1 : !e.pre && t.pre ? 1 : e.pre && t.pre ? e.pre < t.pre ? -1 : +(e.pre > t.pre) : 0 : e.patch - t.patch : e.minor - t.minor : e.major - t.major, u = (e, t) => {
|
|
38
|
+
if (e === "*") return !0;
|
|
39
|
+
if (e.startsWith("^")) {
|
|
40
|
+
let n = c(e.slice(1));
|
|
41
|
+
return !n || t.major !== n.major ? !1 : l(t, n) >= 0;
|
|
42
|
+
}
|
|
43
|
+
if (e.startsWith("~")) {
|
|
44
|
+
let n = c(e.slice(1));
|
|
45
|
+
return !n || t.major !== n.major || t.minor !== n.minor ? !1 : l(t, n) >= 0;
|
|
46
|
+
}
|
|
47
|
+
let n = /^(>=|<=|>|<)(.+)$/.exec(e);
|
|
48
|
+
if (n) {
|
|
49
|
+
let e = n[1], r = c(n[2]);
|
|
50
|
+
if (!r) return !1;
|
|
51
|
+
let i = l(t, r);
|
|
52
|
+
if (e === ">=") return i >= 0;
|
|
53
|
+
if (e === "<=") return i <= 0;
|
|
54
|
+
if (e === ">") return i > 0;
|
|
55
|
+
if (e === "<") return i < 0;
|
|
56
|
+
}
|
|
57
|
+
let r = c(e);
|
|
58
|
+
return r ? l(t, r) === 0 : !1;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { s as checkFrameworkCompat, a as composeRpcInterceptors, n as definePlugin, r as definePluginRoute, o as definePluginService, i as pluginInstanceName };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/pluginNaming.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
|
|
4
|
+
return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/-([a-zA-Z0-9])/g, (e, t) => t.toUpperCase());
|
|
5
|
+
}, t = (e) => {
|
|
6
|
+
let t = e.startsWith("@") ? e.replace(/^@[^/]+\//, "") : e;
|
|
7
|
+
return (t.startsWith("plugin-") ? t.slice(7) : t).replace(/#/g, "--").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
8
|
+
}, n = Symbol.for("@voltro/protocol/pluginAliases"), r = () => {
|
|
9
|
+
let e = globalThis, t = e[n];
|
|
10
|
+
if (t instanceof Map) return t;
|
|
11
|
+
let r = /* @__PURE__ */ new Map();
|
|
12
|
+
return e[n] = r, r;
|
|
13
|
+
}, i = (e) => {
|
|
14
|
+
let t = r();
|
|
15
|
+
for (let [n, r] of Object.entries(e)) {
|
|
16
|
+
if (r === "") continue;
|
|
17
|
+
let e = t.get(n);
|
|
18
|
+
e === void 0 ? t.set(n, /* @__PURE__ */ new Set([r])) : e.add(r);
|
|
19
|
+
}
|
|
20
|
+
}, a = () => {
|
|
21
|
+
r().clear();
|
|
22
|
+
}, o = (t, n) => {
|
|
23
|
+
let i = r().get(t);
|
|
24
|
+
if (i === void 0 || i.size === 0) return `${e(t)}.${n}`;
|
|
25
|
+
if (i.size === 1) for (let e of i) return `${e}.${n}`;
|
|
26
|
+
let a, o = 0;
|
|
27
|
+
for (let e of i) e.includes("#") || (a = e, o++);
|
|
28
|
+
if (o === 1) return `${a}.${n}`;
|
|
29
|
+
throw Error(`[voltro] ${t} is installed more than once (${[...i].sort().join(", ")}) and no single install is the primary one, so a plugin hook cannot tell which of them it addresses. Call the route by its full tag instead — e.g. useSubscription(api, '${[...i].sort()[0]}.${n}').`);
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { e as pluginAlias, t as pluginSlug, o as pluginTag, i as registerPluginAliases, a as resetPluginAliases };
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { subscriptionEvent as e } from "./subscriptionEvent.js";
|
|
2
|
+
import { RequestedTenantRefused as t } from "./tenantSelection.js";
|
|
3
|
+
import { Unauthenticated as n } from "./auth.js";
|
|
4
|
+
import { NoSuchResource as r, ScopeError as i, declaresResourceGuard as a, isOpenAccess as o, openAccessSpec as s, serviceAccessSpec as c } from "./scopes.js";
|
|
5
|
+
import { strictInput as l } from "./strictInput.js";
|
|
6
|
+
import { BusinessRuleViolation as u } from "./businessRule.js";
|
|
7
|
+
import { MutationConnectionRequired as d, MutationInFlight as f } from "./idempotency.js";
|
|
8
|
+
import { ValidationError as p, ValidationErrors as m } from "./validation.js";
|
|
9
|
+
import { ApprovalErrors as h } from "./approval.js";
|
|
10
|
+
import { normalizeSource as g } from "./reactivityChannel.js";
|
|
11
|
+
import { Schema as _ } from "effect";
|
|
12
|
+
import { Rpc as v } from "effect/rpc";
|
|
13
|
+
import { VersionConflict as y } from "@voltro/database/wire";
|
|
14
|
+
//#region src/procedure.ts
|
|
15
|
+
var b = (e) => e.internal !== !0, x = (e) => e.service === void 0 ? "client" : "service", S = (e) => b(e) && e.service === void 0, C = (e) => b(e) && e.service !== void 0, w = /^[a-z][a-z0-9-]{0,55}$/i, T = (e) => {
|
|
16
|
+
if (D(e), E(e), e.idempotencyScope !== void 0 && e.idempotencyScope !== "subject" && e.idempotencyScope !== "connection") throw Error(`${e.name}: idempotencyScope must be 'subject' or 'connection'`);
|
|
17
|
+
let t = e.serialize;
|
|
18
|
+
if (t !== void 0) {
|
|
19
|
+
if (typeof t.key != "function") throw Error(`${e.name}: serialize.key must be a function of the input`);
|
|
20
|
+
if (t.maxPending !== void 0 && (!Number.isSafeInteger(t.maxPending) || t.maxPending < 1)) throw Error(`${e.name}: serialize.maxPending must be a positive integer`);
|
|
21
|
+
}
|
|
22
|
+
if (e.idempotencyScope === "connection" && (e.internal === !0 || e.publicApi !== void 0 || e.exposeAsTool !== void 0)) throw Error(`${e.name}: connection-scoped mutations require the native WebSocket RPC surface; internal, publicApi and exposeAsTool cannot establish its connection state`);
|
|
23
|
+
if (Array.isArray(e.guards) && e.guards.length === 0) throw Error(`${e.name}: \`guards: []\` is empty, so it enforces nothing — but it reads\n at the call site as if this procedure were protected. Omit the field for an
|
|
24
|
+
unguarded procedure, or list the scopes required to call it.`);
|
|
25
|
+
let n = typeof e.source == "string" ? [e.source] : Array.isArray(e.source) ? e.source : void 0;
|
|
26
|
+
if (n !== void 0 && (n.length === 0 || n.some((e) => String(e).trim() === ""))) throw Error(`${e.name}: \`source\` is empty, so this query declares reactivity and\n subscribes to nothing — it serves one snapshot and never updates again,
|
|
27
|
+
which is indistinguishable from "nothing changed". Name the table(s) it
|
|
28
|
+
reads, or omit \`source\` for a non-reactive query.`);
|
|
29
|
+
if (e.internal !== !0) return e;
|
|
30
|
+
if (e.openAccess !== void 0) throw Error(`${e.name}: \`internal: true\` cannot be combined with \`openAccess\`.\n \`internal\` takes the procedure OFF the wire, and \`openAccess\` declares who may
|
|
31
|
+
call it there — together they describe a decision about a surface that does not
|
|
32
|
+
exist. Drop \`openAccess\` (an internal procedure needs no wire decision), or drop
|
|
33
|
+
\`internal: true\` if the procedure really is meant to be callable.`);
|
|
34
|
+
if (e.overridesPlugin === !0) throw Error(`${e.name}: \`internal: true\` cannot be combined with \`overridesPlugin\`.\n The override REMOVES the plugin route, and an internal procedure is not
|
|
35
|
+
wire-reachable — so the plugin's route would vanish with nothing callable
|
|
36
|
+
in its place, and callers would get a 404 for something that used to work.`);
|
|
37
|
+
let r = [e.publicApi === void 0 ? void 0 : "publicApi", e.exposeAsTool === void 0 ? void 0 : "exposeAsTool"].filter((e) => e !== void 0);
|
|
38
|
+
if (r.length === 0) return e;
|
|
39
|
+
throw Error(`${e.name}: \`internal: true\` cannot be combined with ${r.map((e) => `\`${e}\``).join(" or ")}. \`internal\` takes the procedure OFF the wire; those put it back ON a different one (${r.includes("publicApi") ? "a REST route" : "an agent tool"}), and that surface is projected without consulting the flag — so the procedure would be unreachable from your client and reachable from the internet. Drop \`internal: true\` if the wider surface is intended, or remove the ${r.join(" / ")} annotation if it is not.`);
|
|
40
|
+
}, E = (e) => {
|
|
41
|
+
let t = e.service;
|
|
42
|
+
if (t === void 0) return;
|
|
43
|
+
let n = t.callers;
|
|
44
|
+
if (!Array.isArray(n) || n.length === 0) throw Error(`${e.name}: \`service.callers\` is empty, so NO app may call this procedure —\n and no browser either. Name the calling app(s), e.g. \`service: { callers: ['worker'] }\`,
|
|
45
|
+
or drop \`service:\` if the procedure is meant for this app's own clients.`);
|
|
46
|
+
let r = n.filter((e) => typeof e != "string" || !w.test(e));
|
|
47
|
+
if (r.length > 0) throw Error(`${e.name}: \`service.callers\` holds ${r.map((e) => JSON.stringify(e)).join(", ")} — a caller is an\n app name (letters, digits, dashes; starting with a letter; at most 56 characters), the same name this app
|
|
48
|
+
lists in \`serviceCallers\` and the caller's credential resolves to.`);
|
|
49
|
+
if (new Set(n).size !== n.length) throw Error(`${e.name}: \`service.callers\` lists the same app twice`);
|
|
50
|
+
let i = [
|
|
51
|
+
e.internal === !0 ? "`internal: true` (it removes the wire surface a service calls over)" : void 0,
|
|
52
|
+
e.publicApi === void 0 ? void 0 : "`publicApi` (a REST route is for callers that are not the listed apps)",
|
|
53
|
+
e.exposeAsTool === void 0 ? void 0 : "`exposeAsTool` (an agent tool is not one of the listed apps)",
|
|
54
|
+
e.requiresApproval === void 0 ? void 0 : "`requiresApproval` (a second HUMAN cannot approve a machine call)",
|
|
55
|
+
e.overridesPlugin === !0 ? "`overridesPlugin` (a plugin route is a client surface; replacing it with a service-only one breaks its clients)" : void 0,
|
|
56
|
+
e.idempotencyScope === "connection" ? "`idempotencyScope: 'connection'` (a service call dedups per service, across reconnects)" : void 0
|
|
57
|
+
].filter((e) => e !== void 0);
|
|
58
|
+
if (i.length !== 0) throw Error(`${e.name}: \`service:\` cannot be combined with ${i.join("; ")}.\n A service procedure is callable only by the listed apps of this project, over the
|
|
59
|
+
socket, with their service credential. Drop the other field, or drop \`service:\`.`);
|
|
60
|
+
}, D = (e) => {
|
|
61
|
+
let t = e.requiresApproval;
|
|
62
|
+
if (t !== void 0) {
|
|
63
|
+
if (!Array.isArray(t.approvers) || t.approvers.length === 0) throw Error(`${e.name}: \`requiresApproval.approvers\` is empty, so NOBODY can approve this\n procedure and every call would park forever. Name the scope(s) an approver must hold
|
|
64
|
+
— e.g. \`approvers: [{ scope: 'invoices:approve' }]\`.`);
|
|
65
|
+
if (e.openAccess !== void 0) throw Error(`${e.name}: \`requiresApproval\` cannot be combined with \`openAccess\`.\n The self-approval refusal compares subject ids, and an unauthenticated caller has
|
|
66
|
+
none — so on an open procedure every anonymous caller would count as a DIFFERENT
|
|
67
|
+
human from every other, and the second-pair-of-eyes control would enforce nothing.
|
|
68
|
+
Give the procedure a \`guards:\` decision, or drop \`requiresApproval\`.`);
|
|
69
|
+
}
|
|
70
|
+
}, O = (e) => e.action !== void 0 && e.resourceType !== void 0, k = (e) => e.authenticated === !0, A = (e) => e.openAccess !== void 0 || e.guards !== void 0 && e.guards.length > 0, j = (e, t, n, r) => {
|
|
71
|
+
if (r !== void 0) {
|
|
72
|
+
if (n !== void 0 || t !== void 0 && t.length > 0) throw Error(`${e}: \`service:\` is an access decision of its own — only the listed apps may\n call this procedure — so it cannot sit beside \`guards:\` or \`openAccess:\`. A service
|
|
73
|
+
holds no scopes, and no user may call a service procedure. Keep exactly one.`);
|
|
74
|
+
return Array.isArray(r.callers) ? [c(r.callers)] : void 0;
|
|
75
|
+
}
|
|
76
|
+
if (n === void 0) return t;
|
|
77
|
+
if (n.trim() === "") throw Error(`${e}: \`openAccess\` needs a REASON, not an empty string. It is the sentence a\n reviewer reads to decide whether this procedure should really be callable
|
|
78
|
+
without an authorization check — e.g. \`openAccess: 'public pricing, no caller data'\`.`);
|
|
79
|
+
if (t !== void 0 && t.length > 0) throw Error(`${e}: \`openAccess\` and \`guards\` are two different access decisions, so\n declaring both says the procedure is protected AND open. Keep the guards if a
|
|
80
|
+
caller must hold a scope; drop them if anyone may call it.`);
|
|
81
|
+
return [s(n.trim())];
|
|
82
|
+
}, M = (e) => T({
|
|
83
|
+
kind: "query",
|
|
84
|
+
name: e.name,
|
|
85
|
+
input: e.input,
|
|
86
|
+
output: e.output,
|
|
87
|
+
error: e.error ?? _.Never,
|
|
88
|
+
source: g(e.source),
|
|
89
|
+
cache: e.cache,
|
|
90
|
+
guards: j(e.name, e.guards, e.openAccess, e.service),
|
|
91
|
+
openAccess: e.openAccess,
|
|
92
|
+
service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
|
|
93
|
+
publicApi: e.publicApi,
|
|
94
|
+
exposeAsTool: e.exposeAsTool,
|
|
95
|
+
internal: e.internal,
|
|
96
|
+
overridesPlugin: e.overridesPlugin
|
|
97
|
+
}), N = (e) => T({
|
|
98
|
+
kind: "mutation",
|
|
99
|
+
name: e.name,
|
|
100
|
+
input: e.input,
|
|
101
|
+
output: e.output,
|
|
102
|
+
error: e.error ?? _.Never,
|
|
103
|
+
...e.idempotencyScope === void 0 ? {} : { idempotencyScope: e.idempotencyScope },
|
|
104
|
+
...e.serialize === void 0 ? {} : { serialize: e.serialize },
|
|
105
|
+
target: e.target,
|
|
106
|
+
guards: j(e.name, e.guards, e.openAccess, e.service),
|
|
107
|
+
openAccess: e.openAccess,
|
|
108
|
+
service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
|
|
109
|
+
publicApi: e.publicApi,
|
|
110
|
+
exposeAsTool: e.exposeAsTool,
|
|
111
|
+
requiresApproval: e.requiresApproval,
|
|
112
|
+
internal: e.internal,
|
|
113
|
+
overridesPlugin: e.overridesPlugin
|
|
114
|
+
}), P = (e) => T({
|
|
115
|
+
kind: "action",
|
|
116
|
+
name: e.name,
|
|
117
|
+
input: e.input,
|
|
118
|
+
output: e.output,
|
|
119
|
+
error: e.error ?? _.Never,
|
|
120
|
+
guards: j(e.name, e.guards, e.openAccess, e.service),
|
|
121
|
+
openAccess: e.openAccess,
|
|
122
|
+
service: e.service === void 0 ? void 0 : { callers: Array.isArray(e.service.callers) ? [...e.service.callers] : e.service.callers },
|
|
123
|
+
source: e.source,
|
|
124
|
+
target: e.target,
|
|
125
|
+
publicApi: e.publicApi,
|
|
126
|
+
exposeAsTool: e.exposeAsTool,
|
|
127
|
+
requiresApproval: e.requiresApproval,
|
|
128
|
+
internal: e.internal,
|
|
129
|
+
overridesPlugin: e.overridesPlugin
|
|
130
|
+
}), F = (e) => T({
|
|
131
|
+
kind: "stream",
|
|
132
|
+
name: e.name,
|
|
133
|
+
input: e.input,
|
|
134
|
+
element: e.element,
|
|
135
|
+
error: e.error ?? _.Never,
|
|
136
|
+
internal: e.internal,
|
|
137
|
+
overridesPlugin: e.overridesPlugin,
|
|
138
|
+
guards: j(e.name, e.guards, e.openAccess),
|
|
139
|
+
openAccess: e.openAccess
|
|
140
|
+
}), I = (e, t) => t && t.length > 0 ? _.Union([e, ...t]) : e, L = (e) => e !== void 0 && e.some((e) => !o(e)), R = (e) => _.Union([
|
|
141
|
+
e,
|
|
142
|
+
i,
|
|
143
|
+
n,
|
|
144
|
+
t
|
|
145
|
+
]), z = (e) => _.Union([e, u]), B = (e) => _.Union([
|
|
146
|
+
e,
|
|
147
|
+
p,
|
|
148
|
+
m
|
|
149
|
+
]), V = (e, t) => t === void 0 ? e : _.Union([e, h]), H = (e, t) => a(t) ? _.Union([e, r]) : e, U = (e, t, n) => I(W(e, t), n), W = (e, t) => {
|
|
150
|
+
let n = H(R(e.error), e.guards);
|
|
151
|
+
if (t === "stream" || t === "query") return n;
|
|
152
|
+
let r = t === "mutation" ? _.Union([
|
|
153
|
+
z(n),
|
|
154
|
+
f,
|
|
155
|
+
y
|
|
156
|
+
]) : n;
|
|
157
|
+
return V(B(t === "mutation" && e.idempotencyScope === "connection" ? _.Union([r, d]) : r), e.requiresApproval);
|
|
158
|
+
}, G = {
|
|
159
|
+
query: [
|
|
160
|
+
i,
|
|
161
|
+
n,
|
|
162
|
+
t
|
|
163
|
+
],
|
|
164
|
+
stream: [
|
|
165
|
+
i,
|
|
166
|
+
n,
|
|
167
|
+
t
|
|
168
|
+
],
|
|
169
|
+
action: [
|
|
170
|
+
i,
|
|
171
|
+
n,
|
|
172
|
+
t,
|
|
173
|
+
p,
|
|
174
|
+
m
|
|
175
|
+
],
|
|
176
|
+
mutation: [
|
|
177
|
+
i,
|
|
178
|
+
n,
|
|
179
|
+
t,
|
|
180
|
+
u,
|
|
181
|
+
f,
|
|
182
|
+
y,
|
|
183
|
+
p,
|
|
184
|
+
m
|
|
185
|
+
]
|
|
186
|
+
}, K = (e, t) => I(H(R(e.errorSchema), e.guards), t), q = (e, t) => ({
|
|
187
|
+
...e,
|
|
188
|
+
name: t
|
|
189
|
+
}), J = (t, n) => v.make(t.name, {
|
|
190
|
+
payload: l(t.input, t.name, L(t.guards)),
|
|
191
|
+
success: e(t.output),
|
|
192
|
+
error: U(t, "query", n),
|
|
193
|
+
stream: !0
|
|
194
|
+
}), Y = (e, t) => v.make(e.name, {
|
|
195
|
+
payload: l(e.input, e.name, L(e.guards)),
|
|
196
|
+
success: e.output,
|
|
197
|
+
error: U(e, "mutation", t)
|
|
198
|
+
}), X = (e, t) => v.make(e.name, {
|
|
199
|
+
payload: l(e.input, e.name, L(e.guards)),
|
|
200
|
+
success: e.output,
|
|
201
|
+
error: U(e, "action", t)
|
|
202
|
+
}), Z = (e, t) => v.make(e.name, {
|
|
203
|
+
payload: l(e.input, e.name, L(e.guards)),
|
|
204
|
+
success: e.element,
|
|
205
|
+
error: U(e, "stream", t),
|
|
206
|
+
stream: !0
|
|
207
|
+
}), Q = (e) => {
|
|
208
|
+
switch (e.kind) {
|
|
209
|
+
case "query": return J(e);
|
|
210
|
+
case "mutation": return Y(e);
|
|
211
|
+
case "action": return X(e);
|
|
212
|
+
case "stream": return Z(e);
|
|
213
|
+
}
|
|
214
|
+
}, $ = (e) => {
|
|
215
|
+
let t = e.input, n = t === void 0 ? {} : { input: t }, r = e.output, i = r === void 0 ? {} : { output: r };
|
|
216
|
+
if (e.kind === "query") return {
|
|
217
|
+
kind: "query",
|
|
218
|
+
source: e.source,
|
|
219
|
+
...n,
|
|
220
|
+
...i
|
|
221
|
+
};
|
|
222
|
+
if (e.kind === "action") return {
|
|
223
|
+
kind: "action",
|
|
224
|
+
...n,
|
|
225
|
+
...i
|
|
226
|
+
};
|
|
227
|
+
if (e.kind === "stream") return {
|
|
228
|
+
kind: "stream",
|
|
229
|
+
...n,
|
|
230
|
+
...i
|
|
231
|
+
};
|
|
232
|
+
let a = e.target, o = e.idempotencyScope === void 0 ? {} : { idempotencyScope: e.idempotencyScope }, s = e.serialize === void 0 ? {} : { serialize: e.serialize };
|
|
233
|
+
if (a === void 0) return {
|
|
234
|
+
kind: "mutation",
|
|
235
|
+
...n,
|
|
236
|
+
...i,
|
|
237
|
+
...o,
|
|
238
|
+
...s
|
|
239
|
+
};
|
|
240
|
+
let c = Array.isArray(a) ? a : [a];
|
|
241
|
+
return {
|
|
242
|
+
kind: "mutation",
|
|
243
|
+
...n,
|
|
244
|
+
...i,
|
|
245
|
+
...o,
|
|
246
|
+
...s,
|
|
247
|
+
targets: c.map((e) => ({
|
|
248
|
+
table: e.table,
|
|
249
|
+
op: e.op,
|
|
250
|
+
..."order" in e && e.order !== void 0 ? { order: e.order } : {},
|
|
251
|
+
..."shape" in e && e.shape !== void 0 ? { shape: e.shape } : {},
|
|
252
|
+
..."identify" in e && e.identify !== void 0 ? { identify: e.identify } : {},
|
|
253
|
+
..."path" in e && e.path !== void 0 ? { path: e.path } : {},
|
|
254
|
+
..."by" in e && e.by !== void 0 ? { by: e.by } : {},
|
|
255
|
+
..."match" in e && e.match !== void 0 ? { match: e.match } : {},
|
|
256
|
+
..."shapeItem" in e && e.shapeItem !== void 0 ? { shapeItem: e.shapeItem } : {},
|
|
257
|
+
..."relations" in e && e.relations !== void 0 ? { relations: e.relations } : {}
|
|
258
|
+
}))
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
//#endregion
|
|
262
|
+
export { G as FRAMEWORK_WIRE_ERRORS, w as SERVICE_NAME_PATTERN, X as actionToRpc, P as defineAction, N as defineMutation, M as defineQuery, F as defineStream, A as hasAccessDecision, L as hasEnforcedGuard, k as isAuthenticatedGuard, S as isClientReachable, O as isPolicyGuard, C as isServiceReachable, b as isWireReachable, Y as mutationToRpc, $ as normalizeDescriptor, J as queryToRpc, Z as streamToRpc, Q as toRpc, x as wireAudienceOf, U as wireErrorUnion, q as withRpcTag, K as workflowWireErrorUnion };
|