@party-stack/ontology-server 0.12.1 → 0.13.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 +12 -3
- package/lib/authorization.js +1 -1
- package/lib/bindingFence.d.ts +5 -0
- package/lib/bindingFence.d.ts.map +1 -1
- package/lib/bindingFence.js +24 -3
- package/lib/bindingFence.js.map +1 -1
- package/lib/composition.d.ts +1 -17
- package/lib/composition.d.ts.map +1 -1
- package/lib/definitionProjection.d.ts.map +1 -1
- package/lib/definitionProjection.js +4 -4
- package/lib/definitionProjection.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/internalAccess.js +1 -4
- package/lib/internalAccess.js.map +1 -1
- package/lib/operations.d.ts +34 -166
- package/lib/operations.d.ts.map +1 -1
- package/lib/operations.js +3 -55
- package/lib/operations.js.map +1 -1
- package/lib/replicaBootstrap.d.ts +20 -26
- package/lib/replicaBootstrap.d.ts.map +1 -1
- package/lib/replicaBootstrap.js +76 -42
- package/lib/replicaBootstrap.js.map +1 -1
- package/lib/routing.d.ts +49 -19
- package/lib/routing.d.ts.map +1 -1
- package/lib/routing.js +77 -51
- package/lib/routing.js.map +1 -1
- package/lib/rpc.d.ts +649 -764
- package/lib/rpc.d.ts.map +1 -1
- package/lib/rpc.js +112 -28
- package/lib/rpc.js.map +1 -1
- package/lib/rpcLocal.d.ts.map +1 -1
- package/lib/rpcLocal.js +5 -1
- package/lib/rpcLocal.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -91,9 +91,12 @@ export const openHandler = Effect.fn("App.openHandler")(function* (options: {
|
|
|
91
91
|
const server = yield* makeOntologyServer({
|
|
92
92
|
routes: {
|
|
93
93
|
issues: { kind: "owned", backend: owned, authenticate },
|
|
94
|
-
"forms/:formId":
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
"forms/:formId": {
|
|
95
|
+
authenticate,
|
|
96
|
+
open: Effect.fnUntraced(function* ({ formId }: Readonly<Record<string, string>>) {
|
|
97
|
+
return { kind: "proxy" as const, backend: yield* openForm(formId!), ir };
|
|
98
|
+
}),
|
|
99
|
+
},
|
|
97
100
|
},
|
|
98
101
|
idleRetentionMs: 60_000,
|
|
99
102
|
});
|
|
@@ -263,6 +266,12 @@ Use `true` for a private endpoint, or a synchronous predicate over validated con
|
|
|
263
266
|
dangerouslyAllowInternalAccess: (context) => context.role === "internal-admin",
|
|
264
267
|
```
|
|
265
268
|
|
|
269
|
+
A route that acquires its backend declares `authenticate` and
|
|
270
|
+
`dangerouslyAllowInternalAccess` beside `open`, and `open` returns only the backend and
|
|
271
|
+
binding. Each request is authenticated before the route opens. If opening fails, a caller
|
|
272
|
+
allowed internal access gets the original error and everyone else a generic message; a
|
|
273
|
+
predicate needs `authenticate` for this. Replica routes require `true`.
|
|
274
|
+
|
|
266
275
|
Authentication still runs per request. A predicate must return a boolean; session
|
|
267
276
|
and database checks belong in `authenticate`. Worker helpers enable internal access
|
|
268
277
|
for private app ports. Without an IR policy, explicit internal access grants the raw
|
package/lib/authorization.js
CHANGED
|
@@ -6,10 +6,10 @@ import { receiptPolicyProof } from "./receiptPolicy.js";
|
|
|
6
6
|
import { BackendError, classifyBackendFailure, projectBackendError, schemaValidationIssues } from "@party-stack/ontology-backend";
|
|
7
7
|
import { attachmentByteSource, collectAttachments } from "@party-stack/ontology-storage/blobs";
|
|
8
8
|
import { Cause, Effect, Exit, Schema, Scope, Stream } from "effect";
|
|
9
|
+
import { field, inArray } from "@party-stack/ontology-storage";
|
|
9
10
|
import { Table } from "@party-stack/ontology-storage/tables";
|
|
10
11
|
import { compileEffectSchemas } from "@party-stack/ontology-spec/effect";
|
|
11
12
|
import { contextPartition, resolveType } from "@party-stack/ontology-spec/utils";
|
|
12
|
-
import { field, inArray } from "@party-stack/ontology-storage";
|
|
13
13
|
import { resolveReadActionParameters } from "@party-stack/ontology-backend/actions";
|
|
14
14
|
import { CurrentActionAuthorization, CurrentExecutionContext, CurrentQueryAuthorization, actionReferenceIssues, authorizeAction, policyIndexes, policyView } from "@party-stack/ontology-backend/policy";
|
|
15
15
|
import { executeQuery, queryExecutor } from "@party-stack/ontology-backend/query";
|
package/lib/bindingFence.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { BackendError } from "@party-stack/ontology-backend";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { OntologyIR } from "@party-stack/ontology-spec";
|
|
3
4
|
import { Headers } from "effect/http/Headers";
|
|
4
5
|
//#region src/bindingFence.d.ts
|
|
5
6
|
export declare const expectedSourceHeader = "x-party-stack-expected-source";
|
|
6
7
|
export declare const expectedContextHeader = "x-party-stack-expected-context";
|
|
8
|
+
/** The contract hash of the definition the client accepted. */
|
|
9
|
+
export declare const expectedDefinitionHeader = "x-party-stack-expected-definition";
|
|
7
10
|
/** Expectations constrain the already authenticated binding; they never grant authority. */
|
|
8
11
|
export declare const expectedBindingHeaders: (binding: {
|
|
9
12
|
readonly sourceId: string;
|
|
@@ -20,6 +23,8 @@ export declare const withExpectedBinding: <R, Q extends {
|
|
|
20
23
|
readonly sourceId: string;
|
|
21
24
|
};
|
|
22
25
|
readonly context?: Record<string, unknown>;
|
|
26
|
+
/** The definition this endpoint serves. A request bound to another contract is rejected. */
|
|
27
|
+
readonly ir?: OntologyIR;
|
|
23
28
|
readonly ready?: Effect.Effect<void, BackendError, R>;
|
|
24
29
|
readonly authorize: (request: Q, headers: Headers) => Effect.Effect<void, BackendError, R>;
|
|
25
30
|
}) => (request: Q, headers: Headers) => Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindingFence.d.ts","names":[],"sources":["../src/bindingFence.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bindingFence.d.ts","names":[],"sources":["../src/bindingFence.ts"],"mappings":";;;;;qBAOa;qBACA;;qBAEA;;qBAiBA,yBAAsB;WACtB;WACA,UAAU;MACnB;;qBAMS,sBAAuB,GAAG;WAAqB;GAAmB;WAClE;aAAoB;;WACpB;aAAqB;;WACrB,UAAU;;WAEV,KAAK;WACL,QAAQ,OAAO,aAAa,cAAc;WAC1C,YAAY,SAAS,GAAG,SAAS,YAAY,OAAO,aAAa,cAAc;OAC3F,SAAA,GAAA,SAAA,YAAA,OAAA,aAAA,iWAAA"}
|
package/lib/bindingFence.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { BackendError } from "@party-stack/ontology-backend";
|
|
1
|
+
import { BackendError, classifyBackendFailure } from "@party-stack/ontology-backend";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { ontologyDefinitionContractHash } from "@party-stack/ontology-storage";
|
|
3
4
|
import { Table } from "@party-stack/ontology-storage/tables";
|
|
4
5
|
//#region src/bindingFence.ts
|
|
5
6
|
const expectedSourceHeader = "x-party-stack-expected-source";
|
|
6
7
|
const expectedContextHeader = "x-party-stack-expected-context";
|
|
8
|
+
/** The contract hash of the definition the client accepted. */
|
|
9
|
+
const expectedDefinitionHeader = "x-party-stack-expected-definition";
|
|
10
|
+
const contractHashes = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
/** Hashed once per definition: every fenced request compares against it. */
|
|
12
|
+
const contractHash = (ir) => {
|
|
13
|
+
const known = contractHashes.get(ir);
|
|
14
|
+
return known !== void 0 ? Effect.succeed(known) : ontologyDefinitionContractHash(ir).pipe(Effect.tap((hash) => Effect.sync(() => contractHashes.set(ir, hash))), Effect.mapError((cause) => classifyBackendFailure("ontology.binding", cause)));
|
|
15
|
+
};
|
|
7
16
|
const identity = Table.make({ name: "ontology-binding-identity" });
|
|
8
17
|
const contextIdentity = (context) => encodeURIComponent(identity.encode(context ?? {}));
|
|
9
18
|
/** Expectations constrain the already authenticated binding; they never grant authority. */
|
|
@@ -13,7 +22,7 @@ const expectedBindingHeaders = (binding) => ({
|
|
|
13
22
|
});
|
|
14
23
|
/** The same fence protects RPC and HTTP byte/action sidechannels before provider work. */
|
|
15
24
|
const withExpectedBinding = (options) => Effect.fnUntraced(function* (request, headers) {
|
|
16
|
-
if (request.operation !== "Describe" && (headers["x-party-stack-expected-source"] !== void 0 || headers["x-party-stack-expected-context"] !== void 0)) {
|
|
25
|
+
if (request.operation !== "Describe" && (headers["x-party-stack-expected-source"] !== void 0 || headers["x-party-stack-expected-context"] !== void 0 || headers["x-party-stack-expected-definition"] !== void 0)) {
|
|
17
26
|
yield* options.ready ?? Effect.void;
|
|
18
27
|
const expected = expectedBindingHeaders({
|
|
19
28
|
sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? "stateless",
|
|
@@ -30,10 +39,22 @@ const withExpectedBinding = (options) => Effect.fnUntraced(function* (request, h
|
|
|
30
39
|
"Accept"
|
|
31
40
|
].includes(request.operation) ? { actionOutcome: "not-committed" } : {}
|
|
32
41
|
});
|
|
42
|
+
const definition = headers[expectedDefinitionHeader];
|
|
43
|
+
if (definition !== void 0 && options.ir && definition !== (yield* contractHash(options.ir))) return yield* new BackendError({
|
|
44
|
+
operation: "ontology.binding",
|
|
45
|
+
kind: "SchemaMismatch",
|
|
46
|
+
retryable: false,
|
|
47
|
+
message: "The ontology definition changed.",
|
|
48
|
+
...[
|
|
49
|
+
"ApplyAction",
|
|
50
|
+
"Submit",
|
|
51
|
+
"Accept"
|
|
52
|
+
].includes(request.operation) ? { actionOutcome: "not-committed" } : {}
|
|
53
|
+
});
|
|
33
54
|
}
|
|
34
55
|
yield* options.authorize(request, headers);
|
|
35
56
|
});
|
|
36
57
|
//#endregion
|
|
37
|
-
export { expectedBindingHeaders, expectedContextHeader, expectedSourceHeader, withExpectedBinding };
|
|
58
|
+
export { expectedBindingHeaders, expectedContextHeader, expectedDefinitionHeader, expectedSourceHeader, withExpectedBinding };
|
|
38
59
|
|
|
39
60
|
//# sourceMappingURL=bindingFence.js.map
|
package/lib/bindingFence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindingFence.js","names":[],"sources":["../src/bindingFence.ts"],"sourcesContent":["import { BackendError } from \"@party-stack/ontology-backend\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport { Effect } from \"effect\";\nimport type { Headers } from \"effect/http/Headers\";\n\nexport const expectedSourceHeader = \"x-party-stack-expected-source\";\nexport const expectedContextHeader = \"x-party-stack-expected-context\";\nconst identity = Table.make<unknown>({ name: \"ontology-binding-identity\" });\nconst contextIdentity = (context: Record<string, unknown> | undefined) =>\n encodeURIComponent(identity.encode(context ?? {}));\n\n/** Expectations constrain the already authenticated binding; they never grant authority. */\nexport const expectedBindingHeaders = (binding: {\n readonly sourceId: string;\n readonly context?: Record<string, unknown>;\n}): Record<string, string> => ({\n [expectedSourceHeader]: encodeURIComponent(binding.sourceId),\n [expectedContextHeader]: contextIdentity(binding.context),\n});\n\n/** The same fence protects RPC and HTTP byte/action sidechannels before provider work. */\nexport const withExpectedBinding = <R, Q extends { readonly operation: string }>(options: {\n readonly source?: { readonly sourceId: string };\n readonly backend?: { readonly sourceId: string };\n readonly context?: Record<string, unknown>;\n readonly ready?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (request: Q, headers: Headers) => Effect.Effect<void, BackendError, R>;\n}) =>\n Effect.fnUntraced(function* (request: Q, headers: Headers): Effect.fn.Return<void, BackendError, R> {\n if (\n request.operation !== \"Describe\" &&\n (headers[expectedSourceHeader] !== undefined
|
|
1
|
+
{"version":3,"file":"bindingFence.js","names":[],"sources":["../src/bindingFence.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport { ontologyDefinitionContractHash } from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport { Effect } from \"effect\";\nimport type { OntologyIR } from \"@party-stack/ontology-spec\";\nimport type { Headers } from \"effect/http/Headers\";\n\nexport const expectedSourceHeader = \"x-party-stack-expected-source\";\nexport const expectedContextHeader = \"x-party-stack-expected-context\";\n/** The contract hash of the definition the client accepted. */\nexport const expectedDefinitionHeader = \"x-party-stack-expected-definition\";\nconst contractHashes = new WeakMap<OntologyIR, string>();\n/** Hashed once per definition: every fenced request compares against it. */\nconst contractHash = (ir: OntologyIR) => {\n const known = contractHashes.get(ir);\n return known !== undefined\n ? Effect.succeed(known)\n : ontologyDefinitionContractHash(ir).pipe(\n Effect.tap((hash) => Effect.sync(() => contractHashes.set(ir, hash))),\n Effect.mapError((cause) => classifyBackendFailure(\"ontology.binding\", cause))\n );\n};\nconst identity = Table.make<unknown>({ name: \"ontology-binding-identity\" });\nconst contextIdentity = (context: Record<string, unknown> | undefined) =>\n encodeURIComponent(identity.encode(context ?? {}));\n\n/** Expectations constrain the already authenticated binding; they never grant authority. */\nexport const expectedBindingHeaders = (binding: {\n readonly sourceId: string;\n readonly context?: Record<string, unknown>;\n}): Record<string, string> => ({\n [expectedSourceHeader]: encodeURIComponent(binding.sourceId),\n [expectedContextHeader]: contextIdentity(binding.context),\n});\n\n/** The same fence protects RPC and HTTP byte/action sidechannels before provider work. */\nexport const withExpectedBinding = <R, Q extends { readonly operation: string }>(options: {\n readonly source?: { readonly sourceId: string };\n readonly backend?: { readonly sourceId: string };\n readonly context?: Record<string, unknown>;\n /** The definition this endpoint serves. A request bound to another contract is rejected. */\n readonly ir?: OntologyIR;\n readonly ready?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (request: Q, headers: Headers) => Effect.Effect<void, BackendError, R>;\n}) =>\n Effect.fnUntraced(function* (request: Q, headers: Headers): Effect.fn.Return<void, BackendError, R> {\n if (\n request.operation !== \"Describe\" &&\n (headers[expectedSourceHeader] !== undefined ||\n headers[expectedContextHeader] !== undefined ||\n headers[expectedDefinitionHeader] !== undefined)\n ) {\n yield* options.ready ?? Effect.void;\n const expected = expectedBindingHeaders({\n sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? \"stateless\",\n context: options.context,\n });\n if (\n (headers[expectedSourceHeader] !== undefined &&\n headers[expectedSourceHeader] !== expected[expectedSourceHeader]) ||\n (headers[expectedContextHeader] !== undefined &&\n headers[expectedContextHeader] !== expected[expectedContextHeader])\n )\n return yield* new BackendError({\n operation: \"ontology.binding\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology source or authenticated context changed.\",\n ...([\"ApplyAction\", \"Submit\", \"Accept\"].includes(request.operation)\n ? { actionOutcome: \"not-committed\" as const }\n : {}),\n });\n // A followed replica that reopened under a new definition serves it from a new\n // endpoint; a client bound to the old contract learns it changed.\n const definition = headers[expectedDefinitionHeader];\n if (definition !== undefined && options.ir && definition !== (yield* contractHash(options.ir)))\n return yield* new BackendError({\n operation: \"ontology.binding\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology definition changed.\",\n ...([\"ApplyAction\", \"Submit\", \"Accept\"].includes(request.operation)\n ? { actionOutcome: \"not-committed\" as const }\n : {}),\n });\n }\n yield* options.authorize(request, headers);\n });\n"],"mappings":";;;;;AAOA,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;;AAErC,MAAa,2BAA2B;AACxC,MAAM,iCAAiB,IAAI,QAA4B;;AAEvD,MAAM,gBAAgB,OAAmB;CACrC,MAAM,QAAQ,eAAe,IAAI,EAAE;CACnC,OAAO,UAAU,KAAA,IACX,OAAO,QAAQ,KAAK,IACpB,+BAA+B,EAAE,CAAC,CAAC,KAC/B,OAAO,KAAK,SAAS,OAAO,WAAW,eAAe,IAAI,IAAI,IAAI,CAAC,CAAC,GACpE,OAAO,UAAU,UAAU,uBAAuB,oBAAoB,KAAK,CAAC,CAChF;AACV;AACA,MAAM,WAAW,MAAM,KAAc,EAAE,MAAM,4BAA4B,CAAC;AAC1E,MAAM,mBAAmB,YACrB,mBAAmB,SAAS,OAAO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|
|
55
55
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
56
56
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
57
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
58
57
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
59
58
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
60
59
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -70,7 +69,6 @@ export declare const prepareOntologyServer: <R>(options: Common<R> & Role) => Ef
|
|
|
70
69
|
enableRealtime?: boolean;
|
|
71
70
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
72
71
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
73
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
74
72
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
75
73
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
76
74
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -86,7 +84,6 @@ export declare const prepareOntologyServer: <R>(options: Common<R> & Role) => Ef
|
|
|
86
84
|
enableRealtime?: boolean;
|
|
87
85
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
88
86
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
89
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
90
87
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
91
88
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
92
89
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -103,7 +100,6 @@ export declare const prepareOntologyServer: <R>(options: Common<R> & Role) => Ef
|
|
|
103
100
|
enableRealtime?: boolean;
|
|
104
101
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
105
102
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
106
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
107
103
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
108
104
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
109
105
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -122,7 +118,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
122
118
|
enableRealtime?: boolean;
|
|
123
119
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
124
120
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
125
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
126
121
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
127
122
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
128
123
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -138,7 +133,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
138
133
|
enableRealtime?: boolean;
|
|
139
134
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
140
135
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
141
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
142
136
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
143
137
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
144
138
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -154,7 +148,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
154
148
|
enableRealtime?: boolean;
|
|
155
149
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
156
150
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
157
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
158
151
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
159
152
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
160
153
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -171,7 +164,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
171
164
|
enableRealtime?: boolean;
|
|
172
165
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
173
166
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
174
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
175
167
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
176
168
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
177
169
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -189,7 +181,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
189
181
|
enableRealtime?: boolean;
|
|
190
182
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
191
183
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
192
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
193
184
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
194
185
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
195
186
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -207,7 +198,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
207
198
|
enableRealtime?: boolean;
|
|
208
199
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
209
200
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
210
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
211
201
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
212
202
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
213
203
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -225,7 +215,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
225
215
|
enableRealtime?: boolean;
|
|
226
216
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
227
217
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
228
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
229
218
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
230
219
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
231
220
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -244,7 +233,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
244
233
|
enableRealtime?: boolean;
|
|
245
234
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
246
235
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
247
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
248
236
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
249
237
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
250
238
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -264,7 +252,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
264
252
|
enableRealtime?: boolean;
|
|
265
253
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
266
254
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
267
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
268
255
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
269
256
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
270
257
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -313,7 +300,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
313
300
|
enableRealtime?: boolean;
|
|
314
301
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
315
302
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
316
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
317
303
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
318
304
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
319
305
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -362,7 +348,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
362
348
|
enableRealtime?: boolean;
|
|
363
349
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
364
350
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
365
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
366
351
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
367
352
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
368
353
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -412,7 +397,6 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
412
397
|
enableRealtime?: boolean;
|
|
413
398
|
deliveryStrategy?: Schema.Schema.Type<Schema.Literals<readonly ["auto", "snapshot", "incremental"]>>;
|
|
414
399
|
delivery?: import("@party-stack/ontology-backend/delivery").DeliveryPolicy;
|
|
415
|
-
pins?: import("@party-stack/ontology-replica").ReplicaPinControls;
|
|
416
400
|
traces?: import("@party-stack/runtime/tracing").TraceStore;
|
|
417
401
|
ready?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
418
402
|
deleteLocalData?: Effect.Effect<void, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, R> | undefined;
|
|
@@ -461,7 +445,7 @@ export declare const bindOntologyServer: <R>(prepared: {
|
|
|
461
445
|
/** Ordinary provider capabilities of a replica server; speculative state remains a separate extension. */
|
|
462
446
|
export declare const replicaServerBackend: (replica: ReplicaService, backend: OntologyBackendService) => OntologyBackendService;
|
|
463
447
|
/** One role/policy composition for transports with an already authenticated binding. */
|
|
464
|
-
export declare const ontologyServerHandlers: <R = never>(options: OntologyServerBindingOptions<R>) => Layer.Layer<import("effect/rpc/Rpc").Handler<"Accept"> | import("effect/rpc/Rpc").Handler<"AckDelivery"> | import("effect/rpc/Rpc").Handler<"Acknowledge"> | import("effect/rpc/Rpc").Handler<"ApplyAction"> | import("effect/rpc/Rpc").Handler<"AttachmentMetadata"> | import("effect/rpc/Rpc").Handler<"Changes"> | import("effect/rpc/Rpc").Handler<"
|
|
448
|
+
export declare const ontologyServerHandlers: <R = never>(options: OntologyServerBindingOptions<R>) => Layer.Layer<import("effect/rpc/Rpc").Handler<"Accept"> | import("effect/rpc/Rpc").Handler<"AckDelivery"> | import("effect/rpc/Rpc").Handler<"Acknowledge"> | import("effect/rpc/Rpc").Handler<"ApplyAction"> | import("effect/rpc/Rpc").Handler<"AttachmentMetadata"> | import("effect/rpc/Rpc").Handler<"Changes"> | import("effect/rpc/Rpc").Handler<"ControlOutbox"> | import("effect/rpc/Rpc").Handler<"CreateAttachment"> | import("effect/rpc/Rpc").Handler<"Decrypt"> | import("effect/rpc/Rpc").Handler<"DeleteLocalData"> | import("effect/rpc/Rpc").Handler<"Demand"> | import("effect/rpc/Rpc").Handler<"Describe"> | import("effect/rpc/Rpc").Handler<"LoadSubset"> | import("effect/rpc/Rpc").Handler<"OpenClient"> | import("effect/rpc/Rpc").Handler<"PullChanges"> | import("effect/rpc/Rpc").Handler<"Query"> | import("effect/rpc/Rpc").Handler<"QueryFunction"> | import("effect/rpc/Rpc").Handler<"Read"> | import("effect/rpc/Rpc").Handler<"ReadAttachment"> | import("effect/rpc/Rpc").Handler<"ReleaseOwner"> | import("effect/rpc/Rpc").Handler<"ReplicaStatus"> | import("effect/rpc/Rpc").Handler<"ResolveActionParameters"> | import("effect/rpc/Rpc").Handler<"Submit"> | import("effect/rpc/Rpc").Handler<"SubscribeSelection"> | import("effect/rpc/Rpc").Handler<"SubscribeState"> | import("effect/rpc/Rpc").Handler<"Traces"> | import("effect/rpc/Rpc").Handler<"UpdateView"> | import("effect/rpc/Rpc").Handler<"ValidateAction"> | import("effect/rpc/Rpc").Handler<"WatchChanges"> | import("effect/rpc/Rpc").Handler<"WatchSubset"> | import("effect/rpc/Rpc").Handler<"WriteAttachmentChunk"> | OntologyErrorProjection, BackendError<"Conflict" | "Forbidden" | "HistoryExpired" | "Internal" | "InvalidConfiguration" | "InvalidRequest" | "InvalidResponse" | "NotFound" | "NotImplemented" | "RateLimited" | "ResultExpired" | "SchemaMismatch" | "SessionExpired" | "SessionReplaced" | "SourceMismatch" | "Unauthenticated" | "Unavailable" | "ValidationFailed" | "ViewReplaced">, Exclude<Exclude<R, never>, Scope.Scope> | Exclude<Exclude<Exclude<R, never>, Scope.Scope>, Scope.Scope>>;
|
|
465
449
|
//#endregion
|
|
466
450
|
export type { OntologyInternalAccess };
|
|
467
451
|
//# sourceMappingURL=composition.d.ts.map
|
package/lib/composition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composition.d.ts","names":["_$__attachmentTransfers_js0.AttachmentTransferPolicy","_$__rpc_js0.OntologyRpcRequest","_$__errorProjection_js0.OntologyErrorProjection"],"sources":["../src/composition.ts"],"mappings":";;;;;;;;;;YAeY,qBAAqB,cAC7B,SAAS,YACR,OAAO,OAAO,yBAAyB,cAAc,IAAI,MAAM;KAG/D,OAAO,KAAK,KACb,yBAAyB;KAGxB;WACY;WAAwB,SAAS;;WACjC;WAAwB,SAAS;;WAE/B;WACA,SAAS;WACT,OAAO;;WAGP;WACA,SAAS;WACT,SAAS;WACT;WACA;;KAEd;WAEc,SAAS;WACT,iCAAiC;;WAEnC;WAA0B;;;YAG/B,6BAA6B,aAAa,OAAO,KAAK,OAAO;;YAE7D,uBAAuB,aAAa,OAAO,KACnD,SAEO;WAAqB;;WAET;WACA;WACA,eAAe,qBAAqB;;WAGpC;WACA,iCAAiC;WACjC,cAAc,qBAAqB;;qBAM7C,wBAAuE,GAAC,SAAA,OAAA,KAAA,SAAA,OAAA
|
|
1
|
+
{"version":3,"file":"composition.d.ts","names":["_$__attachmentTransfers_js0.AttachmentTransferPolicy","_$__rpc_js0.OntologyRpcRequest","_$__errorProjection_js0.OntologyErrorProjection"],"sources":["../src/composition.ts"],"mappings":";;;;;;;;;;YAeY,qBAAqB,cAC7B,SAAS,YACR,OAAO,OAAO,yBAAyB,cAAc,IAAI,MAAM;KAG/D,OAAO,KAAK,KACb,yBAAyB;KAGxB;W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+BAAA,6CAAA,kDAAA,kDAAA,kDAAA,yDAAA,8CAAA,oDAAA,uDAAA,8CAAA,sDAAA,6CAAA,+CAAA,iDAAA,iDAAA,kDAAA,4CAAA,oDAAA,2CAAA,qDAAA,mDAAA,oDAAA,8DAAA,6CAAA,yDAAA,qDAAA,6CAAA,iDAAA,qDAAA,mDAAA,kDAAA,kCAA/BE,yBAA+B,iWAAA,QAAA,QAAA,WAAA,MAAA,SAAA,QAAA,QAAA,QAAA,WAAA,MAAA,QAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitionProjection.d.ts","names":[],"sources":["../src/definitionProjection.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"definitionProjection.d.ts","names":[],"sources":["../src/definitionProjection.ts"],"mappings":";;YAiBY,4BAA4B;YAE5B,2BAA2B,iBAAiB,qBAAqB,yBACxE,kBAAkB,cAAc,uCAEzB,iBAAiB,cAAc,wBAAwB,0CACvD;wBAigBI,0BAA0B,iBAAiB,qBAAqB,oBAAoB;EAChG,IAAI;EAEJ,UAAU;EAEV,6BAA6B,2BAA2B;EACxD;EACA,6BAA6B;;;;;;EAM7B;EACA;EACA;IACA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRelatedFromForeignKeySource, resolveLookupReference, resolveRelatedLink } from "@party-stack/ontology-spec/utils";
|
|
1
|
+
import { getActionTargetType, isRelatedFromForeignKeySource, resolveLookupReference, resolveRelatedLink } from "@party-stack/ontology-spec/utils";
|
|
2
2
|
//#region src/definitionProjection.ts
|
|
3
3
|
function hasPath(value, path) {
|
|
4
4
|
let current = value;
|
|
@@ -22,9 +22,9 @@ function getActionType(ir, actionTypeName) {
|
|
|
22
22
|
function getObjectReferenceObjectType(ir, actionType, reference) {
|
|
23
23
|
const parameter = actionType.parameters.find((candidate) => candidate.name === reference.name);
|
|
24
24
|
if (!parameter) throw new Error(`Unknown action parameter "${reference.name}".`);
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
25
|
+
const target = getActionTargetType(ir, parameter.type);
|
|
26
|
+
if (!target) throw new Error(`Action parameter "${parameter.name}" is not an object reference.`);
|
|
27
|
+
return target.objectType;
|
|
28
28
|
}
|
|
29
29
|
function getFixedActionParameterValues(fixedActionParameterValues, actionName) {
|
|
30
30
|
return fixedActionParameterValues?.[actionName];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitionProjection.js","names":["resolveType"],"sources":["../src/definitionProjection.ts"],"sourcesContent":["import {\n isRelatedFromForeignKeySource,\n resolveRelatedLink,\n resolveLookupReference,\n} from \"@party-stack/ontology-spec/utils\";\nimport type {\n ActionLogicStep,\n ActionTypeDef,\n Expression,\n OntologyDefinition,\n OntologyIR,\n PropertyAssignment,\n TypeDef,\n InputReferenceExpression,\n} from \"@party-stack/ontology-spec\";\n\nexport type FixedActionParameterValue = Expression;\n\nexport type FixedActionParameterValues<Ontology extends OntologyDefinition = OntologyDefinition> = {\n [ActionTypeName in Extract<keyof Ontology[\"actionTypes\"], string>]?: {\n [\n ParameterName in Extract<keyof Ontology[\"actionTypes\"][ActionTypeName][\"parameters\"], string>\n ]?: FixedActionParameterValue;\n };\n};\n\ntype RuntimeFixedActionParameterValues = Record<\n string,\n Record<string, FixedActionParameterValue> | undefined\n>;\n\nfunction hasPath(value: unknown, path: string[]): boolean {\n let current = value;\n for (const segment of path) {\n if (typeof current !== \"object\" || current === null || !(segment in current)) return false;\n current = (current as Record<string, unknown>)[segment];\n }\n return true;\n}\n\nfunction resolveType(ir: OntologyIR, type: TypeDef): TypeDef {\n if (type.kind !== \"ref\") return type;\n const namedType = ir.types.find((candidate) => candidate.name === type.value.name);\n if (!namedType) {\n throw new Error(`Unknown ontology type \"${type.value.name}\".`);\n }\n return resolveType(ir, namedType.type);\n}\n\nfunction getActionType(ir: OntologyIR, actionTypeName: string): ActionTypeDef {\n const actionType = ir.actionTypes.find((candidate) => candidate.name === actionTypeName);\n if (!actionType) {\n throw new Error(`Unknown action type \"${actionTypeName}\".`);\n }\n return actionType;\n}\n\nfunction getObjectReferenceObjectType(\n ir: OntologyIR,\n actionType: ActionTypeDef,\n reference: InputReferenceExpression\n): string {\n const parameter = actionType.parameters.find((candidate) => candidate.name === reference.name);\n if (!parameter) {\n throw new Error(`Unknown action parameter \"${reference.name}\".`);\n }\n const type = resolveType(ir, parameter.type);\n if (type.kind !== \"objectReference\") {\n throw new Error(`Action parameter \"${parameter.name}\" is not an object reference.`);\n }\n return type.value.objectType;\n}\n\nfunction getFixedActionParameterValues(\n fixedActionParameterValues: FixedActionParameterValues | undefined,\n actionName: string\n): Record<string, FixedActionParameterValue> | undefined {\n return (fixedActionParameterValues as RuntimeFixedActionParameterValues | undefined)?.[actionName];\n}\n\nfunction isActionParameterFixed(\n fixedActionParameterValues: FixedActionParameterValues | undefined,\n actionName: string,\n parameterName: string\n): boolean {\n return (\n getFixedActionParameterValues(fixedActionParameterValues, actionName)?.[parameterName] !== undefined\n );\n}\n\nfunction getVisibleActionParameterNames(\n actionTypeName: string,\n parameters: ReadonlyArray<{ name: string }>,\n fixedActionParameterValues?: FixedActionParameterValues\n): Set<string> {\n return new Set(\n parameters\n .filter(\n (parameter) =>\n !isActionParameterFixed(fixedActionParameterValues, actionTypeName, parameter.name)\n )\n .map((parameter) => parameter.name)\n );\n}\n\nfunction getExpressionObjectType(\n ir: OntologyIR,\n actionName: string,\n expression: Expression\n): string | undefined {\n if (expression.kind === \"lookup\") {\n return resolveLookupReference(\n ir,\n expression.value.reference,\n getActionType(ir, actionName).parameters\n )?.objectType;\n }\n if (expression.kind === \"related\") {\n const sourceObjectType = getExpressionObjectType(ir, actionName, expression.value.source);\n if (!sourceObjectType) return undefined;\n const link = resolveRelatedLink(ir, sourceObjectType, expression.value.link);\n if (!link) return undefined;\n const foreignKeyOnSource = isRelatedFromForeignKeySource(\n link,\n sourceObjectType,\n expression.value.link\n );\n if (!foreignKeyOnSource && link.cardinality === \"many\") {\n return undefined;\n }\n return foreignKeyOnSource ? link.target.objectType : link.source.objectType;\n }\n return undefined;\n}\n\nfunction projectExpression(opts: {\n expression: Expression;\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionName: string;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n projectFixedParameterValues: boolean;\n}): Expression | undefined {\n switch (opts.expression.kind) {\n case \"contextReference\": {\n const { name } = opts.expression.value;\n // Declared context is the public contract. An absent optional value\n // is still available as undefined (e.g. COALESCE's fallback).\n let type = opts.ir.context?.type;\n while (type) {\n type = resolveType(opts.ir, type);\n if (type.kind !== \"optional\") break;\n type = type.value.type;\n }\n const visible = type\n ? type.kind === \"struct\" && type.value.fields.some((field) => field.name === name)\n : hasPath(opts.context, [name]);\n return visible ? opts.expression : undefined;\n }\n case \"literal\":\n case \"uuid\":\n case \"now\":\n case \"localReference\":\n return opts.expression;\n case \"getAt\": {\n const objectType = getExpressionObjectType(\n opts.ir,\n opts.actionName,\n opts.expression.value.source\n );\n if (\n objectType &&\n !(opts.allowedObjectTypeProperties[objectType] ?? []).includes(opts.expression.value.path[0]!)\n ) {\n return undefined;\n }\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n return source\n ? {\n kind: \"getAt\",\n value: {\n source,\n path: opts.expression.value.path,\n },\n }\n : undefined;\n }\n case \"lookup\": {\n const reference = projectExpression({\n ...opts,\n expression: opts.expression.value.reference,\n });\n return reference\n ? {\n kind: \"lookup\",\n value: { reference },\n }\n : undefined;\n }\n case \"related\": {\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n return source && getExpressionObjectType(opts.ir, opts.actionName, opts.expression)\n ? {\n kind: \"related\",\n value: {\n source,\n link: opts.expression.value.link,\n },\n }\n : undefined;\n }\n case \"struct\": {\n const fields = opts.expression.value.fields.map((field) => ({\n ...field,\n value: projectExpression({\n ...opts,\n expression: field.value,\n }),\n }));\n return fields.some((field) => field.value === undefined)\n ? undefined\n : {\n kind: \"struct\",\n value: {\n fields: fields as Array<{\n name: string;\n value: Expression;\n }>,\n },\n };\n }\n case \"map\": {\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n const body = projectExpression({\n ...opts,\n expression: opts.expression.value.body,\n });\n return source && body\n ? {\n kind: \"map\",\n value: {\n source,\n binding: opts.expression.value.binding,\n body,\n },\n }\n : undefined;\n }\n case \"inputReference\": {\n const parameterName = opts.expression.value.name;\n if (opts.visibleParameters.has(parameterName)) {\n return opts.expression;\n }\n if (!opts.projectFixedParameterValues) {\n return undefined;\n }\n const fixedValue = getFixedActionParameterValues(\n opts.fixedActionParameterValues,\n opts.actionName\n )?.[parameterName];\n if (fixedValue === undefined) return undefined;\n if (fixedValue.kind === \"inputReference\" && fixedValue.value.name === parameterName) {\n return undefined;\n }\n return projectExpression({\n ...opts,\n expression: fixedValue,\n });\n }\n case \"case\": {\n const branches = opts.expression.value.branches.map((branch) => ({\n condition: projectExpression({ ...opts, expression: branch.condition }),\n result: projectExpression({ ...opts, expression: branch.result }),\n }));\n const otherwise = projectExpression({ ...opts, expression: opts.expression.value.else });\n return otherwise && branches.every((b) => b.condition && b.result)\n ? {\n kind: \"case\",\n value: {\n branches: branches as { condition: Expression; result: Expression }[],\n else: otherwise,\n },\n }\n : undefined;\n }\n case \"not\":\n case \"length\": {\n const expression = projectExpression({ ...opts, expression: opts.expression.value.expression });\n return expression ? { kind: opts.expression.kind, value: { expression } } : undefined;\n }\n case \"and\":\n case \"or\":\n case \"concat\":\n case \"coalesce\": {\n const expressions = opts.expression.value.expressions.map((expression) =>\n projectExpression({ ...opts, expression })\n );\n return expressions.every((e) => e !== undefined)\n ? { kind: opts.expression.kind, value: { expressions: expressions as Expression[] } }\n : undefined;\n }\n case \"eq\":\n case \"ne\":\n case \"lt\":\n case \"lte\":\n case \"gt\":\n case \"gte\":\n case \"in\":\n case \"contains\":\n case \"like\":\n case \"ilike\":\n case \"add\":\n case \"subtract\":\n case \"multiply\":\n case \"divide\": {\n const left = projectExpression({ ...opts, expression: opts.expression.value.left });\n const right = projectExpression({ ...opts, expression: opts.expression.value.right });\n return left && right ? { kind: opts.expression.kind, value: { left, right } } : undefined;\n }\n case \"exists\":\n return undefined;\n }\n}\n\nfunction projectAssignments(opts: {\n assignments: PropertyAssignment[];\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionName: string;\n objectTypeName: string;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n}): PropertyAssignment[] {\n const allowedProperties = opts.allowedObjectTypeProperties[opts.objectTypeName] ?? [];\n return opts.assignments.flatMap((assignment) => {\n const propertyName = assignment.property[0];\n if (!propertyName || !allowedProperties.includes(propertyName)) return [];\n const projectedValue = projectExpression({\n expression: assignment.value,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionName,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n projectFixedParameterValues: true,\n });\n return projectedValue ? [{ ...assignment, value: projectedValue }] : [];\n });\n}\n\nfunction projectLogicStep(opts: {\n step: ActionLogicStep;\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionType: ActionTypeDef;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n}): ActionLogicStep | undefined {\n switch (opts.step.kind) {\n case \"createObject\": {\n const values = projectAssignments({\n assignments: opts.step.value.values,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionType.name,\n objectTypeName: opts.step.value.objectType,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return {\n ...opts.step,\n value: {\n ...opts.step.value,\n values,\n },\n };\n }\n case \"updateObject\": {\n const objectTypeName = getObjectReferenceObjectType(\n opts.ir,\n opts.actionType,\n opts.step.value.object\n );\n const values = projectAssignments({\n assignments: opts.step.value.values,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionType.name,\n objectTypeName,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return {\n ...opts.step,\n value: {\n ...opts.step.value,\n values,\n },\n };\n }\n case \"deleteObject\":\n return opts.step;\n }\n}\n\nfunction typeReferencesObjectTypes(type: TypeDef, ir: OntologyIR, seen = new Set<string>()): Set<string> {\n if (type.kind === \"ref\") {\n if (seen.has(type.value.name)) return new Set();\n seen.add(type.value.name);\n const named = ir.types.find((candidate) => candidate.name === type.value.name);\n return named ? typeReferencesObjectTypes(named.type, ir, seen) : new Set();\n }\n switch (type.kind) {\n case \"objectReference\":\n return new Set([type.value.objectType]);\n case \"optional\":\n return typeReferencesObjectTypes(type.value.type, ir, seen);\n case \"list\":\n return typeReferencesObjectTypes(type.value.elementType, ir, seen);\n case \"map\": {\n const names = typeReferencesObjectTypes(type.value.keyType, ir, seen);\n for (const name of typeReferencesObjectTypes(type.value.valueType, ir, seen)) names.add(name);\n return names;\n }\n case \"result\": {\n const names = typeReferencesObjectTypes(type.value.okType, ir, seen);\n for (const name of typeReferencesObjectTypes(type.value.errType, ir, seen)) names.add(name);\n return names;\n }\n case \"struct\": {\n const names = new Set<string>();\n for (const field of type.value.fields) {\n for (const name of typeReferencesObjectTypes(field.type, ir, seen)) names.add(name);\n }\n return names;\n }\n case \"union\": {\n const names = new Set<string>();\n for (const variant of type.value.variants) {\n for (const name of typeReferencesObjectTypes(variant.type, ir, seen)) names.add(name);\n }\n return names;\n }\n default:\n return new Set();\n }\n}\n\nfunction collectReferencedNamedTypes(\n type: TypeDef,\n ir: OntologyIR,\n into: Set<string>,\n seen = new Set<string>()\n): void {\n if (type.kind === \"ref\") {\n if (seen.has(type.value.name)) return;\n seen.add(type.value.name);\n into.add(type.value.name);\n const named = ir.types.find((candidate) => candidate.name === type.value.name);\n if (named) collectReferencedNamedTypes(named.type, ir, into, seen);\n return;\n }\n switch (type.kind) {\n case \"optional\":\n collectReferencedNamedTypes(type.value.type, ir, into, seen);\n break;\n case \"list\":\n collectReferencedNamedTypes(type.value.elementType, ir, into, seen);\n break;\n case \"map\":\n collectReferencedNamedTypes(type.value.keyType, ir, into, seen);\n collectReferencedNamedTypes(type.value.valueType, ir, into, seen);\n break;\n case \"result\":\n collectReferencedNamedTypes(type.value.okType, ir, into, seen);\n collectReferencedNamedTypes(type.value.errType, ir, into, seen);\n break;\n case \"struct\":\n for (const field of type.value.fields) {\n collectReferencedNamedTypes(field.type, ir, into, seen);\n }\n break;\n case \"union\":\n for (const variant of type.value.variants) {\n collectReferencedNamedTypes(variant.type, ir, into, seen);\n }\n break;\n default:\n break;\n }\n}\n\nfunction actionParametersReferenceHiddenObjectType(\n actionType: ActionTypeDef,\n ir: OntologyIR,\n visibleObjectTypes: Set<string>,\n visibleParameters?: Set<string>\n): boolean {\n for (const parameter of actionType.parameters) {\n if (visibleParameters && !visibleParameters.has(parameter.name)) continue;\n for (const objectType of typeReferencesObjectTypes(parameter.type, ir)) {\n if (!visibleObjectTypes.has(objectType)) return true;\n }\n }\n return false;\n}\n\nexport function projectOntologyDefinition<Ontology extends OntologyDefinition = OntologyDefinition>(opts: {\n ir: OntologyIR;\n\n context?: Record<string, unknown>;\n\n fixedActionParameterValues?: FixedActionParameterValues<Ontology>;\n projectFixedActionParameterValuesInDefaults?: boolean;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n /**\n * Projects object/property/link/action/query visibility from the resolved\n * authorization policy. Otherwise the full schema is retained while action\n * parameters and logic are still projected.\n */\n filterSchemaByAuthorization?: boolean;\n visibleActionTypes?: readonly string[] | \"all\";\n visibleQueryFunctionTypes?: readonly string[] | \"all\";\n}): OntologyIR {\n const filterSchemaByAuthorization = opts.filterSchemaByAuthorization ?? false;\n const visibleObjectTypes = new Set(\n filterSchemaByAuthorization\n ? Object.entries(opts.allowedObjectTypeProperties)\n .filter(([, properties]) => properties.length > 0)\n .map(([objectType]) => objectType)\n : opts.ir.objectTypes.map((objectType) => objectType.name)\n );\n\n const objectTypes = filterSchemaByAuthorization\n ? opts.ir.objectTypes\n .filter((objectType) => visibleObjectTypes.has(objectType.name))\n .map((objectType) => {\n const allowed = new Set(opts.allowedObjectTypeProperties[objectType.name] ?? []);\n return {\n ...objectType,\n title: objectType.title && allowed.has(objectType.title) ? objectType.title : undefined,\n properties: objectType.properties.filter((property) => allowed.has(property.name)),\n };\n })\n : opts.ir.objectTypes;\n\n const linkTypes = filterSchemaByAuthorization\n ? opts.ir.linkTypes.filter((link) => {\n if (\n !visibleObjectTypes.has(link.source.objectType) ||\n !visibleObjectTypes.has(link.target.objectType)\n ) {\n return false;\n }\n if (!link.foreignKey) return true;\n const sourceAllowed = new Set(opts.allowedObjectTypeProperties[link.source.objectType] ?? []);\n const targetAllowed = new Set(opts.allowedObjectTypeProperties[link.target.objectType] ?? []);\n return sourceAllowed.has(link.foreignKey) || targetAllowed.has(link.foreignKey);\n })\n : opts.ir.linkTypes;\n\n const visibleActions =\n opts.visibleActionTypes === undefined || opts.visibleActionTypes === \"all\"\n ? opts.ir.actionTypes\n : opts.ir.actionTypes.filter((actionType) =>\n (opts.visibleActionTypes as readonly string[]).includes(actionType.name)\n );\n\n const actionTypes = visibleActions\n .filter(\n (actionType) =>\n !filterSchemaByAuthorization ||\n !actionParametersReferenceHiddenObjectType(\n actionType,\n opts.ir,\n visibleObjectTypes,\n getVisibleActionParameterNames(\n actionType.name,\n actionType.parameters,\n opts.fixedActionParameterValues\n )\n )\n )\n .map((actionType) => {\n const visibleParameters = getVisibleActionParameterNames(\n actionType.name,\n actionType.parameters,\n opts.fixedActionParameterValues\n );\n return {\n ...actionType,\n parameters: actionType.parameters\n .filter((parameter) => visibleParameters.has(parameter.name))\n .map((parameter) => ({\n ...parameter,\n defaultValue: parameter.defaultValue\n ? projectExpression({\n expression: parameter.defaultValue,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: actionType.name,\n visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n projectFixedParameterValues:\n opts.projectFixedActionParameterValuesInDefaults ?? false,\n })\n : undefined,\n })),\n logic: actionType.logic.flatMap((step) => {\n if (\n filterSchemaByAuthorization &&\n step.kind === \"createObject\" &&\n !visibleObjectTypes.has(step.value.objectType)\n ) {\n return [];\n }\n const projectedStep = projectLogicStep({\n step,\n\n context: opts.context,\n\n ir: opts.ir,\n actionType,\n visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return projectedStep ? [projectedStep] : [];\n }),\n };\n });\n\n const queryFunctionTypes =\n opts.visibleQueryFunctionTypes === undefined || opts.visibleQueryFunctionTypes === \"all\"\n ? opts.ir.queryFunctionTypes.filter((queryFunction) => {\n if (!filterSchemaByAuthorization) return true;\n for (const parameter of queryFunction.parameters) {\n for (const objectType of typeReferencesObjectTypes(parameter.type, opts.ir)) {\n if (!visibleObjectTypes.has(objectType)) return false;\n }\n }\n for (const objectType of typeReferencesObjectTypes(queryFunction.returnType, opts.ir)) {\n if (!visibleObjectTypes.has(objectType)) return false;\n }\n return true;\n })\n : opts.ir.queryFunctionTypes.filter((queryFunction) =>\n (opts.visibleQueryFunctionTypes as readonly string[]).includes(queryFunction.name)\n );\n\n const referencedNamedTypes = new Set<string>();\n if (opts.ir.context?.type)\n collectReferencedNamedTypes(opts.ir.context.type, opts.ir, referencedNamedTypes);\n for (const objectType of objectTypes) {\n for (const property of objectType.properties) {\n collectReferencedNamedTypes(property.type, opts.ir, referencedNamedTypes);\n }\n }\n for (const actionType of actionTypes) {\n for (const parameter of actionType.parameters) {\n collectReferencedNamedTypes(parameter.type, opts.ir, referencedNamedTypes);\n }\n if (actionType.returnType)\n collectReferencedNamedTypes(actionType.returnType, opts.ir, referencedNamedTypes);\n }\n for (const queryFunction of queryFunctionTypes) {\n for (const parameter of queryFunction.parameters) {\n collectReferencedNamedTypes(parameter.type, opts.ir, referencedNamedTypes);\n }\n collectReferencedNamedTypes(queryFunction.returnType, opts.ir, referencedNamedTypes);\n }\n\n return {\n ...opts.ir,\n types: filterSchemaByAuthorization\n ? opts.ir.types.filter((type) => referencedNamedTypes.has(type.name))\n : opts.ir.types,\n objectTypes,\n linkTypes,\n actionTypes,\n queryFunctionTypes,\n };\n}\n"],"mappings":";;AA+BA,SAAS,QAAQ,OAAgB,MAAyB;CACtD,IAAI,UAAU;CACd,KAAK,MAAM,WAAW,MAAM;EACxB,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,EAAE,WAAW,UAAU,OAAO;EACrF,UAAW,QAAoC;CACnD;CACA,OAAO;AACX;AAEA,SAASA,cAAY,IAAgB,MAAwB;CACzD,IAAI,KAAK,SAAS,OAAO,OAAO;CAChC,MAAM,YAAY,GAAG,MAAM,MAAM,cAAc,UAAU,SAAS,KAAK,MAAM,IAAI;CACjF,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,0BAA0B,KAAK,MAAM,KAAK,GAAG;CAEjE,OAAOA,cAAY,IAAI,UAAU,IAAI;AACzC;AAEA,SAAS,cAAc,IAAgB,gBAAuC;CAC1E,MAAM,aAAa,GAAG,YAAY,MAAM,cAAc,UAAU,SAAS,cAAc;CACvF,IAAI,CAAC,YACD,MAAM,IAAI,MAAM,wBAAwB,eAAe,GAAG;CAE9D,OAAO;AACX;AAEA,SAAS,6BACL,IACA,YACA,WACM;CACN,MAAM,YAAY,WAAW,WAAW,MAAM,cAAc,UAAU,SAAS,UAAU,IAAI;CAC7F,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,6BAA6B,UAAU,KAAK,GAAG;CAEnE,MAAM,OAAOA,cAAY,IAAI,UAAU,IAAI;CAC3C,IAAI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,KAAK,IAAI,oBAAoB;CACnF,KAAK,MAAM,cAAc,aACrB,KAAK,MAAM,YAAY,WAAW,YAC9B,4BAA4B,SAAS,MAAM,KAAK,IAAI,oBAAoB;CAGhF,KAAK,MAAM,cAAc,aAAa;EAClC,KAAK,MAAM,aAAa,WAAW,YAC/B,4BAA4B,UAAU,MAAM,KAAK,IAAI,oBAAoB;EAE7E,IAAI,WAAW,YACX,4BAA4B,WAAW,YAAY,KAAK,IAAI,oBAAoB;CACxF;CACA,KAAK,MAAM,iBAAiB,oBAAoB;EAC5C,KAAK,MAAM,aAAa,cAAc,YAClC,4BAA4B,UAAU,MAAM,KAAK,IAAI,oBAAoB;EAE7E,4BAA4B,cAAc,YAAY,KAAK,IAAI,oBAAoB;CACvF;CAEA,OAAO;EACH,GAAG,KAAK;EACR,OAAO,8BACD,KAAK,GAAG,MAAM,QAAQ,SAAS,qBAAqB,IAAI,KAAK,IAAI,CAAC,IAClE,KAAK,GAAG;EACd;EACA;EACA;EACA;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"definitionProjection.js","names":["resolveType"],"sources":["../src/definitionProjection.ts"],"sourcesContent":["import {\n getActionTargetType,\n isRelatedFromForeignKeySource,\n resolveRelatedLink,\n resolveLookupReference,\n} from \"@party-stack/ontology-spec/utils\";\nimport type {\n ActionLogicStep,\n ActionTypeDef,\n Expression,\n OntologyDefinition,\n OntologyIR,\n PropertyAssignment,\n TypeDef,\n InputReferenceExpression,\n} from \"@party-stack/ontology-spec\";\n\nexport type FixedActionParameterValue = Expression;\n\nexport type FixedActionParameterValues<Ontology extends OntologyDefinition = OntologyDefinition> = {\n [ActionTypeName in Extract<keyof Ontology[\"actionTypes\"], string>]?: {\n [\n ParameterName in Extract<keyof Ontology[\"actionTypes\"][ActionTypeName][\"parameters\"], string>\n ]?: FixedActionParameterValue;\n };\n};\n\ntype RuntimeFixedActionParameterValues = Record<\n string,\n Record<string, FixedActionParameterValue> | undefined\n>;\n\nfunction hasPath(value: unknown, path: string[]): boolean {\n let current = value;\n for (const segment of path) {\n if (typeof current !== \"object\" || current === null || !(segment in current)) return false;\n current = (current as Record<string, unknown>)[segment];\n }\n return true;\n}\n\nfunction resolveType(ir: OntologyIR, type: TypeDef): TypeDef {\n if (type.kind !== \"ref\") return type;\n const namedType = ir.types.find((candidate) => candidate.name === type.value.name);\n if (!namedType) {\n throw new Error(`Unknown ontology type \"${type.value.name}\".`);\n }\n return resolveType(ir, namedType.type);\n}\n\nfunction getActionType(ir: OntologyIR, actionTypeName: string): ActionTypeDef {\n const actionType = ir.actionTypes.find((candidate) => candidate.name === actionTypeName);\n if (!actionType) {\n throw new Error(`Unknown action type \"${actionTypeName}\".`);\n }\n return actionType;\n}\n\nfunction getObjectReferenceObjectType(\n ir: OntologyIR,\n actionType: ActionTypeDef,\n reference: InputReferenceExpression\n): string {\n const parameter = actionType.parameters.find((candidate) => candidate.name === reference.name);\n if (!parameter) {\n throw new Error(`Unknown action parameter \"${reference.name}\".`);\n }\n const target = getActionTargetType(ir, parameter.type);\n if (!target) {\n throw new Error(`Action parameter \"${parameter.name}\" is not an object reference.`);\n }\n return target.objectType;\n}\n\nfunction getFixedActionParameterValues(\n fixedActionParameterValues: FixedActionParameterValues | undefined,\n actionName: string\n): Record<string, FixedActionParameterValue> | undefined {\n return (fixedActionParameterValues as RuntimeFixedActionParameterValues | undefined)?.[actionName];\n}\n\nfunction isActionParameterFixed(\n fixedActionParameterValues: FixedActionParameterValues | undefined,\n actionName: string,\n parameterName: string\n): boolean {\n return (\n getFixedActionParameterValues(fixedActionParameterValues, actionName)?.[parameterName] !== undefined\n );\n}\n\nfunction getVisibleActionParameterNames(\n actionTypeName: string,\n parameters: ReadonlyArray<{ name: string }>,\n fixedActionParameterValues?: FixedActionParameterValues\n): Set<string> {\n return new Set(\n parameters\n .filter(\n (parameter) =>\n !isActionParameterFixed(fixedActionParameterValues, actionTypeName, parameter.name)\n )\n .map((parameter) => parameter.name)\n );\n}\n\nfunction getExpressionObjectType(\n ir: OntologyIR,\n actionName: string,\n expression: Expression\n): string | undefined {\n if (expression.kind === \"lookup\") {\n return resolveLookupReference(\n ir,\n expression.value.reference,\n getActionType(ir, actionName).parameters\n )?.objectType;\n }\n if (expression.kind === \"related\") {\n const sourceObjectType = getExpressionObjectType(ir, actionName, expression.value.source);\n if (!sourceObjectType) return undefined;\n const link = resolveRelatedLink(ir, sourceObjectType, expression.value.link);\n if (!link) return undefined;\n const foreignKeyOnSource = isRelatedFromForeignKeySource(\n link,\n sourceObjectType,\n expression.value.link\n );\n if (!foreignKeyOnSource && link.cardinality === \"many\") {\n return undefined;\n }\n return foreignKeyOnSource ? link.target.objectType : link.source.objectType;\n }\n return undefined;\n}\n\nfunction projectExpression(opts: {\n expression: Expression;\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionName: string;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n projectFixedParameterValues: boolean;\n}): Expression | undefined {\n switch (opts.expression.kind) {\n case \"contextReference\": {\n const { name } = opts.expression.value;\n // Declared context is the public contract. An absent optional value\n // is still available as undefined (e.g. COALESCE's fallback).\n let type = opts.ir.context?.type;\n while (type) {\n type = resolveType(opts.ir, type);\n if (type.kind !== \"optional\") break;\n type = type.value.type;\n }\n const visible = type\n ? type.kind === \"struct\" && type.value.fields.some((field) => field.name === name)\n : hasPath(opts.context, [name]);\n return visible ? opts.expression : undefined;\n }\n case \"literal\":\n case \"uuid\":\n case \"now\":\n case \"localReference\":\n return opts.expression;\n case \"getAt\": {\n const objectType = getExpressionObjectType(\n opts.ir,\n opts.actionName,\n opts.expression.value.source\n );\n if (\n objectType &&\n !(opts.allowedObjectTypeProperties[objectType] ?? []).includes(opts.expression.value.path[0]!)\n ) {\n return undefined;\n }\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n return source\n ? {\n kind: \"getAt\",\n value: {\n source,\n path: opts.expression.value.path,\n },\n }\n : undefined;\n }\n case \"lookup\": {\n const reference = projectExpression({\n ...opts,\n expression: opts.expression.value.reference,\n });\n return reference\n ? {\n kind: \"lookup\",\n value: { reference },\n }\n : undefined;\n }\n case \"related\": {\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n return source && getExpressionObjectType(opts.ir, opts.actionName, opts.expression)\n ? {\n kind: \"related\",\n value: {\n source,\n link: opts.expression.value.link,\n },\n }\n : undefined;\n }\n case \"struct\": {\n const fields = opts.expression.value.fields.map((field) => ({\n ...field,\n value: projectExpression({\n ...opts,\n expression: field.value,\n }),\n }));\n return fields.some((field) => field.value === undefined)\n ? undefined\n : {\n kind: \"struct\",\n value: {\n fields: fields as Array<{\n name: string;\n value: Expression;\n }>,\n },\n };\n }\n case \"map\": {\n const source = projectExpression({\n ...opts,\n expression: opts.expression.value.source,\n });\n const body = projectExpression({\n ...opts,\n expression: opts.expression.value.body,\n });\n return source && body\n ? {\n kind: \"map\",\n value: {\n source,\n binding: opts.expression.value.binding,\n body,\n },\n }\n : undefined;\n }\n case \"inputReference\": {\n const parameterName = opts.expression.value.name;\n if (opts.visibleParameters.has(parameterName)) {\n return opts.expression;\n }\n if (!opts.projectFixedParameterValues) {\n return undefined;\n }\n const fixedValue = getFixedActionParameterValues(\n opts.fixedActionParameterValues,\n opts.actionName\n )?.[parameterName];\n if (fixedValue === undefined) return undefined;\n if (fixedValue.kind === \"inputReference\" && fixedValue.value.name === parameterName) {\n return undefined;\n }\n return projectExpression({\n ...opts,\n expression: fixedValue,\n });\n }\n case \"case\": {\n const branches = opts.expression.value.branches.map((branch) => ({\n condition: projectExpression({ ...opts, expression: branch.condition }),\n result: projectExpression({ ...opts, expression: branch.result }),\n }));\n const otherwise = projectExpression({ ...opts, expression: opts.expression.value.else });\n return otherwise && branches.every((b) => b.condition && b.result)\n ? {\n kind: \"case\",\n value: {\n branches: branches as { condition: Expression; result: Expression }[],\n else: otherwise,\n },\n }\n : undefined;\n }\n case \"not\":\n case \"length\": {\n const expression = projectExpression({ ...opts, expression: opts.expression.value.expression });\n return expression ? { kind: opts.expression.kind, value: { expression } } : undefined;\n }\n case \"and\":\n case \"or\":\n case \"concat\":\n case \"coalesce\": {\n const expressions = opts.expression.value.expressions.map((expression) =>\n projectExpression({ ...opts, expression })\n );\n return expressions.every((e) => e !== undefined)\n ? { kind: opts.expression.kind, value: { expressions: expressions as Expression[] } }\n : undefined;\n }\n case \"eq\":\n case \"ne\":\n case \"lt\":\n case \"lte\":\n case \"gt\":\n case \"gte\":\n case \"in\":\n case \"contains\":\n case \"like\":\n case \"ilike\":\n case \"add\":\n case \"subtract\":\n case \"multiply\":\n case \"divide\": {\n const left = projectExpression({ ...opts, expression: opts.expression.value.left });\n const right = projectExpression({ ...opts, expression: opts.expression.value.right });\n return left && right ? { kind: opts.expression.kind, value: { left, right } } : undefined;\n }\n case \"exists\":\n return undefined;\n }\n}\n\nfunction projectAssignments(opts: {\n assignments: PropertyAssignment[];\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionName: string;\n objectTypeName: string;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n}): PropertyAssignment[] {\n const allowedProperties = opts.allowedObjectTypeProperties[opts.objectTypeName] ?? [];\n return opts.assignments.flatMap((assignment) => {\n const propertyName = assignment.property[0];\n if (!propertyName || !allowedProperties.includes(propertyName)) return [];\n const projectedValue = projectExpression({\n expression: assignment.value,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionName,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n projectFixedParameterValues: true,\n });\n return projectedValue ? [{ ...assignment, value: projectedValue }] : [];\n });\n}\n\nfunction projectLogicStep(opts: {\n step: ActionLogicStep;\n\n context: Record<string, unknown> | undefined;\n\n ir: OntologyIR;\n actionType: ActionTypeDef;\n visibleParameters: Set<string>;\n fixedActionParameterValues: FixedActionParameterValues | undefined;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n}): ActionLogicStep | undefined {\n switch (opts.step.kind) {\n case \"createObject\": {\n const values = projectAssignments({\n assignments: opts.step.value.values,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionType.name,\n objectTypeName: opts.step.value.objectType,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return {\n ...opts.step,\n value: {\n ...opts.step.value,\n values,\n },\n };\n }\n case \"updateObject\": {\n const objectTypeName = getObjectReferenceObjectType(\n opts.ir,\n opts.actionType,\n opts.step.value.object\n );\n const values = projectAssignments({\n assignments: opts.step.value.values,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: opts.actionType.name,\n objectTypeName,\n visibleParameters: opts.visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return {\n ...opts.step,\n value: {\n ...opts.step.value,\n values,\n },\n };\n }\n case \"deleteObject\":\n return opts.step;\n }\n}\n\nfunction typeReferencesObjectTypes(type: TypeDef, ir: OntologyIR, seen = new Set<string>()): Set<string> {\n if (type.kind === \"ref\") {\n if (seen.has(type.value.name)) return new Set();\n seen.add(type.value.name);\n const named = ir.types.find((candidate) => candidate.name === type.value.name);\n return named ? typeReferencesObjectTypes(named.type, ir, seen) : new Set();\n }\n switch (type.kind) {\n case \"objectReference\":\n return new Set([type.value.objectType]);\n case \"optional\":\n return typeReferencesObjectTypes(type.value.type, ir, seen);\n case \"list\":\n return typeReferencesObjectTypes(type.value.elementType, ir, seen);\n case \"map\": {\n const names = typeReferencesObjectTypes(type.value.keyType, ir, seen);\n for (const name of typeReferencesObjectTypes(type.value.valueType, ir, seen)) names.add(name);\n return names;\n }\n case \"result\": {\n const names = typeReferencesObjectTypes(type.value.okType, ir, seen);\n for (const name of typeReferencesObjectTypes(type.value.errType, ir, seen)) names.add(name);\n return names;\n }\n case \"struct\": {\n const names = new Set<string>();\n for (const field of type.value.fields) {\n for (const name of typeReferencesObjectTypes(field.type, ir, seen)) names.add(name);\n }\n return names;\n }\n case \"union\": {\n const names = new Set<string>();\n for (const variant of type.value.variants) {\n for (const name of typeReferencesObjectTypes(variant.type, ir, seen)) names.add(name);\n }\n return names;\n }\n default:\n return new Set();\n }\n}\n\nfunction collectReferencedNamedTypes(\n type: TypeDef,\n ir: OntologyIR,\n into: Set<string>,\n seen = new Set<string>()\n): void {\n if (type.kind === \"ref\") {\n if (seen.has(type.value.name)) return;\n seen.add(type.value.name);\n into.add(type.value.name);\n const named = ir.types.find((candidate) => candidate.name === type.value.name);\n if (named) collectReferencedNamedTypes(named.type, ir, into, seen);\n return;\n }\n switch (type.kind) {\n case \"optional\":\n collectReferencedNamedTypes(type.value.type, ir, into, seen);\n break;\n case \"list\":\n collectReferencedNamedTypes(type.value.elementType, ir, into, seen);\n break;\n case \"map\":\n collectReferencedNamedTypes(type.value.keyType, ir, into, seen);\n collectReferencedNamedTypes(type.value.valueType, ir, into, seen);\n break;\n case \"result\":\n collectReferencedNamedTypes(type.value.okType, ir, into, seen);\n collectReferencedNamedTypes(type.value.errType, ir, into, seen);\n break;\n case \"struct\":\n for (const field of type.value.fields) {\n collectReferencedNamedTypes(field.type, ir, into, seen);\n }\n break;\n case \"union\":\n for (const variant of type.value.variants) {\n collectReferencedNamedTypes(variant.type, ir, into, seen);\n }\n break;\n default:\n break;\n }\n}\n\nfunction actionParametersReferenceHiddenObjectType(\n actionType: ActionTypeDef,\n ir: OntologyIR,\n visibleObjectTypes: Set<string>,\n visibleParameters?: Set<string>\n): boolean {\n for (const parameter of actionType.parameters) {\n if (visibleParameters && !visibleParameters.has(parameter.name)) continue;\n for (const objectType of typeReferencesObjectTypes(parameter.type, ir)) {\n if (!visibleObjectTypes.has(objectType)) return true;\n }\n }\n return false;\n}\n\nexport function projectOntologyDefinition<Ontology extends OntologyDefinition = OntologyDefinition>(opts: {\n ir: OntologyIR;\n\n context?: Record<string, unknown>;\n\n fixedActionParameterValues?: FixedActionParameterValues<Ontology>;\n projectFixedActionParameterValuesInDefaults?: boolean;\n allowedObjectTypeProperties: Record<string, readonly string[]>;\n /**\n * Projects object/property/link/action/query visibility from the resolved\n * authorization policy. Otherwise the full schema is retained while action\n * parameters and logic are still projected.\n */\n filterSchemaByAuthorization?: boolean;\n visibleActionTypes?: readonly string[] | \"all\";\n visibleQueryFunctionTypes?: readonly string[] | \"all\";\n}): OntologyIR {\n const filterSchemaByAuthorization = opts.filterSchemaByAuthorization ?? false;\n const visibleObjectTypes = new Set(\n filterSchemaByAuthorization\n ? Object.entries(opts.allowedObjectTypeProperties)\n .filter(([, properties]) => properties.length > 0)\n .map(([objectType]) => objectType)\n : opts.ir.objectTypes.map((objectType) => objectType.name)\n );\n\n const objectTypes = filterSchemaByAuthorization\n ? opts.ir.objectTypes\n .filter((objectType) => visibleObjectTypes.has(objectType.name))\n .map((objectType) => {\n const allowed = new Set(opts.allowedObjectTypeProperties[objectType.name] ?? []);\n return {\n ...objectType,\n title: objectType.title && allowed.has(objectType.title) ? objectType.title : undefined,\n properties: objectType.properties.filter((property) => allowed.has(property.name)),\n };\n })\n : opts.ir.objectTypes;\n\n const linkTypes = filterSchemaByAuthorization\n ? opts.ir.linkTypes.filter((link) => {\n if (\n !visibleObjectTypes.has(link.source.objectType) ||\n !visibleObjectTypes.has(link.target.objectType)\n ) {\n return false;\n }\n if (!link.foreignKey) return true;\n const sourceAllowed = new Set(opts.allowedObjectTypeProperties[link.source.objectType] ?? []);\n const targetAllowed = new Set(opts.allowedObjectTypeProperties[link.target.objectType] ?? []);\n return sourceAllowed.has(link.foreignKey) || targetAllowed.has(link.foreignKey);\n })\n : opts.ir.linkTypes;\n\n const visibleActions =\n opts.visibleActionTypes === undefined || opts.visibleActionTypes === \"all\"\n ? opts.ir.actionTypes\n : opts.ir.actionTypes.filter((actionType) =>\n (opts.visibleActionTypes as readonly string[]).includes(actionType.name)\n );\n\n const actionTypes = visibleActions\n .filter(\n (actionType) =>\n !filterSchemaByAuthorization ||\n !actionParametersReferenceHiddenObjectType(\n actionType,\n opts.ir,\n visibleObjectTypes,\n getVisibleActionParameterNames(\n actionType.name,\n actionType.parameters,\n opts.fixedActionParameterValues\n )\n )\n )\n .map((actionType) => {\n const visibleParameters = getVisibleActionParameterNames(\n actionType.name,\n actionType.parameters,\n opts.fixedActionParameterValues\n );\n return {\n ...actionType,\n parameters: actionType.parameters\n .filter((parameter) => visibleParameters.has(parameter.name))\n .map((parameter) => ({\n ...parameter,\n defaultValue: parameter.defaultValue\n ? projectExpression({\n expression: parameter.defaultValue,\n\n context: opts.context,\n\n ir: opts.ir,\n actionName: actionType.name,\n visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n projectFixedParameterValues:\n opts.projectFixedActionParameterValuesInDefaults ?? false,\n })\n : undefined,\n })),\n logic: actionType.logic.flatMap((step) => {\n if (\n filterSchemaByAuthorization &&\n step.kind === \"createObject\" &&\n !visibleObjectTypes.has(step.value.objectType)\n ) {\n return [];\n }\n const projectedStep = projectLogicStep({\n step,\n\n context: opts.context,\n\n ir: opts.ir,\n actionType,\n visibleParameters,\n fixedActionParameterValues: opts.fixedActionParameterValues,\n allowedObjectTypeProperties: opts.allowedObjectTypeProperties,\n });\n return projectedStep ? [projectedStep] : [];\n }),\n };\n });\n\n const queryFunctionTypes =\n opts.visibleQueryFunctionTypes === undefined || opts.visibleQueryFunctionTypes === \"all\"\n ? opts.ir.queryFunctionTypes.filter((queryFunction) => {\n if (!filterSchemaByAuthorization) return true;\n for (const parameter of queryFunction.parameters) {\n for (const objectType of typeReferencesObjectTypes(parameter.type, opts.ir)) {\n if (!visibleObjectTypes.has(objectType)) return false;\n }\n }\n for (const objectType of typeReferencesObjectTypes(queryFunction.returnType, opts.ir)) {\n if (!visibleObjectTypes.has(objectType)) return false;\n }\n return true;\n })\n : opts.ir.queryFunctionTypes.filter((queryFunction) =>\n (opts.visibleQueryFunctionTypes as readonly string[]).includes(queryFunction.name)\n );\n\n const referencedNamedTypes = new Set<string>();\n if (opts.ir.context?.type)\n collectReferencedNamedTypes(opts.ir.context.type, opts.ir, referencedNamedTypes);\n for (const objectType of objectTypes) {\n for (const property of objectType.properties) {\n collectReferencedNamedTypes(property.type, opts.ir, referencedNamedTypes);\n }\n }\n for (const actionType of actionTypes) {\n for (const parameter of actionType.parameters) {\n collectReferencedNamedTypes(parameter.type, opts.ir, referencedNamedTypes);\n }\n if (actionType.returnType)\n collectReferencedNamedTypes(actionType.returnType, opts.ir, referencedNamedTypes);\n }\n for (const queryFunction of queryFunctionTypes) {\n for (const parameter of queryFunction.parameters) {\n collectReferencedNamedTypes(parameter.type, opts.ir, referencedNamedTypes);\n }\n collectReferencedNamedTypes(queryFunction.returnType, opts.ir, referencedNamedTypes);\n }\n\n return {\n ...opts.ir,\n types: filterSchemaByAuthorization\n ? opts.ir.types.filter((type) => referencedNamedTypes.has(type.name))\n : opts.ir.types,\n objectTypes,\n linkTypes,\n actionTypes,\n queryFunctionTypes,\n };\n}\n"],"mappings":";;AAgCA,SAAS,QAAQ,OAAgB,MAAyB;CACtD,IAAI,UAAU;CACd,KAAK,MAAM,WAAW,MAAM;EACxB,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,EAAE,WAAW,UAAU,OAAO;EACrF,UAAW,QAAoC;CACnD;CACA,OAAO;AACX;AAEA,SAASA,cAAY,IAAgB,MAAwB;CACzD,IAAI,KAAK,SAAS,OAAO,OAAO;CAChC,MAAM,YAAY,GAAG,MAAM,MAAM,cAAc,UAAU,SAAS,KAAK,MAAM,IAAI;CACjF,IAAI,CAAC,WACD,MAAM,IAAI,MAAM,0BAA0B,KAAK,MAAM,KAAK,GAAG;CAEjE,OAAOA,cAAY,IAAI,UAAU,IAAI;AACzC;AAEA,SAAS,cAAc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E,GACtE,IAAI,CAAC,mBAAmB,IAAI,UAAU,GAAG,OAAO;EAGxD,KAAK,MAAM,cAAc,0BAA0B,cAAc,YAAY,KAAK,EAAE,GAChF,IAAI,CAAC,mBAAmB,IAAI,UAAU,GAAG,OAAO;EAEpD,OAAO;CACX,CAAC,IACD,KAAK,GAAG,mBAAmB,QAAQ,kBAC9B,KAAK,0BAAgD,SAAS,cAAc,IAAI,CACrF;CAEV,MAAM,uCAAuB,IAAI,IAAY;CAC7C,IAAI,KAAK,GAAG,SAAS,MACjB,4BAA4B,KAAK,GAAG,QAAQ,MAAM,KAAK,IAAI,oBAAoB;CACnF,KAAK,MAAM,cAAc,aACrB,KAAK,MAAM,YAAY,WAAW,YAC9B,4BAA4B,SAAS,MAAM,KAAK,IAAI,oBAAoB;CAGhF,KAAK,MAAM,cAAc,aAAa;EAClC,KAAK,MAAM,aAAa,WAAW,YAC/B,4BAA4B,UAAU,MAAM,KAAK,IAAI,oBAAoB;EAE7E,IAAI,WAAW,YACX,4BAA4B,WAAW,YAAY,KAAK,IAAI,oBAAoB;CACxF;CACA,KAAK,MAAM,iBAAiB,oBAAoB;EAC5C,KAAK,MAAM,aAAa,cAAc,YAClC,4BAA4B,UAAU,MAAM,KAAK,IAAI,oBAAoB;EAE7E,4BAA4B,cAAc,YAAY,KAAK,IAAI,oBAAoB;CACvF;CAEA,OAAO;EACH,GAAG,KAAK;EACR,OAAO,8BACD,KAAK,GAAG,MAAM,QAAQ,SAAS,qBAAqB,IAAI,KAAK,IAAI,CAAC,IAClE,KAAK,GAAG;EACd;EACA;EACA;EACA;CACJ;AACJ"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OntologyInternalAccess } from "./internalAccess.js";
|
|
2
2
|
import { OntologyAuthenticate, OntologyBindingOptions, OntologyServerBindingOptions, ontologyServerHandlers } from "./composition.js";
|
|
3
|
-
import {
|
|
4
|
-
import { ManagedReplicaRoute, OntologyResolver, OntologyRoute,
|
|
5
|
-
export { type ManagedReplicaRoute, type OntologyAuthenticate, type OntologyBindingOptions, type OntologyInternalAccess, type OntologyResolver, type OntologyRoute, type
|
|
3
|
+
import { ReplicaUpstream } from "./replicaBootstrap.js";
|
|
4
|
+
import { ManagedReplicaRoute, OntologyResolver, OntologyRoute, OntologyRouteDeclaration, OntologyRouteFactory, OntologyRouteParams, OntologyServer, OntologyServerOptions, OntologyServerRoutes, OpenedOntologyRoute, makeOntologyServer, ontologyServerDispatch } from "./routing.js";
|
|
5
|
+
export { type ManagedReplicaRoute, type OntologyAuthenticate, type OntologyBindingOptions, type OntologyInternalAccess, type OntologyResolver, type OntologyRoute, type OntologyRouteDeclaration, type OntologyRouteFactory, type OntologyRouteParams, type OntologyServer, type OntologyServerBindingOptions, type OntologyServerOptions, type OntologyServerRoutes, type OpenedOntologyRoute, type ReplicaUpstream, makeOntologyServer, ontologyServerDispatch, ontologyServerHandlers };
|
package/lib/internalAccess.js
CHANGED
|
@@ -5,10 +5,7 @@ const withInternalCommands = (authorize, enabled) => (request, headers) => enabl
|
|
|
5
5
|
"ReplicaStatus",
|
|
6
6
|
"Traces",
|
|
7
7
|
"ControlOutbox",
|
|
8
|
-
"
|
|
9
|
-
"WatchPin",
|
|
10
|
-
"SetPin",
|
|
11
|
-
"ClearPin",
|
|
8
|
+
"Pins",
|
|
12
9
|
"DeleteLocalData",
|
|
13
10
|
"ReleaseOwner"
|
|
14
11
|
].includes(request.operation) ? Effect.void : authorize(request, headers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalAccess.js","names":[],"sources":["../src/internalAccess.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { OntologyRpcServerOptions } from \"./rpc.js\";\n\n/** Internal commands can inspect or change state outside the caller's IR policy.\n * Policy/context binding remain enforced. Without a policy, exposes raw capabilities.\n */\nexport type OntologyInternalAccess = true | ((context: Record<string, unknown>) => boolean);\n\n/** Adds internal commands without changing domain permissions or exposing raw replication. */\nexport const withInternalCommands =\n <R>(\n authorize: OntologyRpcServerOptions<R>[\"authorize\"],\n enabled: boolean\n ): OntologyRpcServerOptions<R>[\"authorize\"] =>\n (request, headers) =>\n enabled &&\n [\
|
|
1
|
+
{"version":3,"file":"internalAccess.js","names":[],"sources":["../src/internalAccess.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport type { OntologyRpcServerOptions } from \"./rpc.js\";\n\n/** Internal commands can inspect or change state outside the caller's IR policy.\n * Policy/context binding remain enforced. Without a policy, exposes raw capabilities.\n */\nexport type OntologyInternalAccess = true | ((context: Record<string, unknown>) => boolean);\n\n/** Adds internal commands without changing domain permissions or exposing raw replication. */\nexport const withInternalCommands =\n <R>(\n authorize: OntologyRpcServerOptions<R>[\"authorize\"],\n enabled: boolean\n ): OntologyRpcServerOptions<R>[\"authorize\"] =>\n (request, headers) =>\n enabled &&\n [\"ReplicaStatus\", \"Traces\", \"ControlOutbox\", \"Pins\", \"DeleteLocalData\", \"ReleaseOwner\"].includes(\n request.operation\n )\n ? Effect.void\n : authorize(request, headers);\n"],"mappings":";;;AASA,MAAa,wBAEL,WACA,aAEH,SAAS,YACN,WACA;CAAC;CAAiB;CAAU;CAAiB;CAAQ;CAAmB;AAAc,CAAC,CAAC,SACpF,QAAQ,SACZ,IACM,OAAO,OACP,UAAU,SAAS,OAAO"}
|