@powerhousedao/reactor-api 6.2.3-dev.79 → 6.2.3-dev.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-gateway-apollo-D-EdZ4e-.mjs +2 -2
- package/dist/adapter-gateway-apollo-D-EdZ4e-.mjs.map +1 -1
- package/dist/{base-document-models-ux7TZ9X3.mjs → base-document-models-D-cmBBYJ.mjs} +116 -27
- package/dist/base-document-models-D-cmBBYJ.mjs.map +1 -0
- package/dist/{create-schema-BUk-IQCT.d.mts → create-schema-Dio_7akA.d.mts} +22 -7
- package/dist/create-schema-Dio_7akA.d.mts.map +1 -0
- package/dist/error-info-BaEL50f5.mjs +2 -2
- package/dist/error-info-BaEL50f5.mjs.map +1 -1
- package/dist/index.d.mts +297 -7
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +607 -138
- package/dist/index.mjs.map +1 -1
- package/dist/{package-subgraph-check-BGfeyfnc.mjs → package-subgraph-check-C0PD_Tj9.mjs} +4 -4
- package/dist/{package-subgraph-check-BGfeyfnc.mjs.map → package-subgraph-check-C0PD_Tj9.mjs.map} +1 -1
- package/dist/src/graphql/subgraph-types.d.mts +1 -1
- package/dist/src/graphql/subgraph-types.mjs +1 -1
- package/dist/src/packages/vite-loader.d.mts +4 -1
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +31 -13
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/{subgraph-extraction-BYKOycxo.mjs → subgraph-extraction-BA9WKjn1.mjs} +470 -10
- package/dist/subgraph-extraction-BA9WKjn1.mjs.map +1 -0
- package/dist/{types-BEpxtyKW.d.mts → types-PXB1ctpi.d.mts} +19 -2
- package/dist/types-PXB1ctpi.d.mts.map +1 -0
- package/package.json +13 -14
- package/dist/base-document-models-ux7TZ9X3.mjs.map +0 -1
- package/dist/create-schema-BUk-IQCT.d.mts.map +0 -1
- package/dist/subgraph-extraction-BYKOycxo.mjs.map +0 -1
- package/dist/types-BEpxtyKW.d.mts.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as PGLITE_UTC_PARSERS, t as PGliteLike } from "./pglite-like-CKQEL_Q0.mjs";
|
|
2
|
-
import { a as IPackagePieceSource, c as PackageManagerResult, d as
|
|
3
|
-
import { C as hasOperationSchemas, E as typeDefinitionNames, S as getGeneratedDocumentModelTypes, T as reservedTypeNamesTaken, _ as generateDocumentModelSchema, a as GeneratedDocumentModelTypes, b as getDocumentModelSubgraphName, c as SubgraphSchemaOptions, d as buildDocumentModelSchema, f as buildSubgraphSchemaModule, g as findSubgraphTypeCollisions, h as documentModelSubgraphTypes, i as DocumentModelSource, l as SubgraphTypeCollisionError, m as createSchema, n as DocumentModelSchemaCache, o as ReservedTypeNames, p as createMergedSchema, r as DocumentModelSchemaOptions, s as ResolvedDocumentModelSchema, t as DocumentModelSchema, u as assembleSubgraphTypeDefs, v as generatedTypesOf, w as reservedTypeNames, x as getDocumentModelTypeDefs, y as getDocumentModelSchemaName } from "./create-schema-
|
|
2
|
+
import { a as IPackagePieceSource, c as PackageManagerResult, d as ScalarExport, f as ReportError, h as runDetached, i as IPackageManagerOptions, l as PackagePiece, m as reportFailure, n as IPackageLoaderOptions, p as RunDetachedOptions, r as IPackageManager, t as IPackageLoader, u as PackagePieceEntry } from "./types-PXB1ctpi.mjs";
|
|
3
|
+
import { C as hasOperationSchemas, D as RegisteredScalar, E as typeDefinitionNames, O as ScalarRegistry, S as getGeneratedDocumentModelTypes, T as reservedTypeNamesTaken, _ as generateDocumentModelSchema, a as GeneratedDocumentModelTypes, b as getDocumentModelSubgraphName, c as SubgraphSchemaOptions, d as buildDocumentModelSchema, f as buildSubgraphSchemaModule, g as findSubgraphTypeCollisions, h as documentModelSubgraphTypes, i as DocumentModelSource, l as SubgraphTypeCollisionError, m as createSchema, n as DocumentModelSchemaCache, o as ReservedTypeNames, p as createMergedSchema, r as DocumentModelSchemaOptions, s as ResolvedDocumentModelSchema, t as DocumentModelSchema, u as assembleSubgraphTypeDefs, v as generatedTypesOf, w as reservedTypeNames, x as getDocumentModelTypeDefs, y as getDocumentModelSchemaName } from "./create-schema-Dio_7akA.mjs";
|
|
4
4
|
import { AttachmentBuildResult, AttachmentDownloadOptions, AttachmentDownloadTarget, AttachmentDownloadTargetOptions, AttachmentHeader, AttachmentReferenceIndexBuildResult, AttachmentResponse, AttachmentStatOptions, AttachmentStorageConfig, IAttachmentReferenceReader, IAttachmentReferenceWriter, IAttachmentService, IAttachmentUpload, ReserveAttachmentOptions } from "@powerhousedao/reactor-attachments";
|
|
5
5
|
import { ILogger } from "document-model";
|
|
6
6
|
import { IAnalyticsStore } from "@powerhousedao/analytics-engine-core";
|
|
@@ -8,14 +8,14 @@ import { AnalyticsModel } from "@powerhousedao/analytics-engine-graphql";
|
|
|
8
8
|
import { DocumentNode, GraphQLError, GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig, GraphQLSchema } from "graphql";
|
|
9
9
|
import { AttachmentRef, CatchUpLoadSample, DocumentModelSource as DocumentModelSource$1, ICatchUpLoadSource, IDocumentModelLoader, IDocumentModelRegistry, IDriveClient, IDriveNodeSource, IInspectableAttachmentStore, IInspector, IInspectorAdmin, IInspectorStorageHealthProvider, INSPECTOR_OPS, IReactorClient, IReactorFactsSink, IReactorProcessorHostModuleBase, IReactorReadClient, IReactorWriteClient, IRelationalDb, ISyncInspector, ISyncManager, InProcessReactorClientModule, InProcessReactorModule, InspectorDocumentReader, InspectorReadOpKey, PagedResults, ParsedDriveUrl, ProcessorFactoryBuilder as ProcessorFactoryBuilder$1, Remote, SYNC_INSPECTION_OPS, SearchFilter, SyncInspectionReadOpKey, SyncScopeGate, ViewFilter, driveIdFromUrl, parseDriveUrl } from "@powerhousedao/reactor";
|
|
10
10
|
import { AuthSubject, DocumentModelModule, Operation, PHDocument, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
11
|
-
import {
|
|
11
|
+
import { AuthorizerResult, IHttpScope, IRelationalDb as IRelationalDb$1, IWebhookEndpoints, IWebhookScope, NodeRouteSpec, ProcessorApp, ProcessorFactory, RouteActor, RouteAuth, RouteAuthorizer, RouteBody, RouteContext, RouteHandler, RouteMethod, RouteOptions, RouteSpec, RouteTransport, RouteUser, RouteUser as RouteUser$1, ScopedRouteHandle, WebhookEndpointInfo, WebhookField, WebhookHashAlgorithm, WebhookPolicy, WebhookReply, WebhookRequest, WebhookScheme, WebhookSignatureEncoding, WebhookSpec, WebhookVerification } from "@powerhousedao/shared/processors";
|
|
12
|
+
import { Generated, Kysely, RawBuilder } from "kysely";
|
|
12
13
|
import * as z$1 from "zod";
|
|
14
|
+
import { GraphQLResolverMap } from "@apollo/subgraph";
|
|
13
15
|
import { DocumentDriveDocument, DocumentDriveGlobalState } from "@powerhousedao/shared/document-drive";
|
|
14
|
-
import { AuthorizerResult, IHttpScope, IRelationalDb as IRelationalDb$1, IWebhookEndpoints, IWebhookScope, NodeRouteSpec, ProcessorApp, ProcessorFactory, RouteActor, RouteAuth, RouteAuthorizer, RouteBody, RouteContext, RouteHandler, RouteMethod, RouteOptions, RouteSpec, RouteTransport, RouteUser, RouteUser as RouteUser$1, ScopedRouteHandle, WebhookEndpointInfo, WebhookField, WebhookHashAlgorithm, WebhookPolicy, WebhookReply, WebhookRequest, WebhookScheme, WebhookSignatureEncoding, WebhookSpec, WebhookVerification } from "@powerhousedao/shared/processors";
|
|
15
16
|
import { IAttachmentClient } from "@powerhousedao/reactor-attachments/client";
|
|
16
17
|
import { WebSocketServer } from "ws";
|
|
17
18
|
import { AttachmentReadGate, IDocumentScopeGate } from "@powerhousedao/reactor-attachments/replication";
|
|
18
|
-
import { Generated, Kysely } from "kysely";
|
|
19
19
|
import { PGlite } from "@electric-sql/pglite";
|
|
20
20
|
import { Knex } from "knex";
|
|
21
21
|
import http from "node:http";
|
|
@@ -709,6 +709,7 @@ export interface DocumentPermissionConfig {
|
|
|
709
709
|
* - Users can be granted permission to execute specific operations
|
|
710
710
|
*/
|
|
711
711
|
export declare class DocumentPermissionService {
|
|
712
|
+
#private;
|
|
712
713
|
private readonly db;
|
|
713
714
|
readonly config: DocumentPermissionConfig;
|
|
714
715
|
/**
|
|
@@ -718,6 +719,13 @@ export declare class DocumentPermissionService {
|
|
|
718
719
|
*/
|
|
719
720
|
readonly permissionCache: PermissionCache;
|
|
720
721
|
constructor(db: Kysely<DocumentPermissionDatabase>, config?: DocumentPermissionConfig, cacheOptions?: PermissionCacheOptions);
|
|
722
|
+
/**
|
|
723
|
+
* Called with the document id after every write through this service
|
|
724
|
+
* (grant, revoke, protection, owner, deletion), once the cache entry is
|
|
725
|
+
* invalidated: what a projection of the permission data (the readable
|
|
726
|
+
* documents read model) follows. Returns the unsubscribe.
|
|
727
|
+
*/
|
|
728
|
+
onChange(listener: (documentId: string) => void): () => void;
|
|
721
729
|
/**
|
|
722
730
|
* Get the permission level for a user on a specific document.
|
|
723
731
|
* Returns null if no permission is set.
|
|
@@ -1085,6 +1093,126 @@ export declare class AttachmentClientProvider implements IAttachmentClientProvid
|
|
|
1085
1093
|
forSubject(subject: AuthSubject): IAttachmentClient;
|
|
1086
1094
|
}
|
|
1087
1095
|
//#endregion
|
|
1096
|
+
//#region src/services/readable-documents.d.ts
|
|
1097
|
+
/**
|
|
1098
|
+
* The read-permission closure as a read model: `readable_documents(user_id,
|
|
1099
|
+
* document_id)` in the processors' relational database, so an index subgraph
|
|
1100
|
+
* decides "may the caller see this row" with one join instead of one
|
|
1101
|
+
* authorization call per row.
|
|
1102
|
+
*
|
|
1103
|
+
* It is a projection of the host's own permission data, never an authority:
|
|
1104
|
+
* the write path keeps deciding from the permission tables in the reactor
|
|
1105
|
+
* store (`IAuthorizationService`), and nothing here is consulted for a
|
|
1106
|
+
* write. The projection mirrors four small facts into its own namespace,
|
|
1107
|
+
* documents, `child` edges, protection and grants, and recomputes the
|
|
1108
|
+
* closure from them in one SQL statement whenever one of them changes:
|
|
1109
|
+
*
|
|
1110
|
+
* - `'*'` for a document that is unprotected along its whole ancestor chain
|
|
1111
|
+
* (everyone may read it; `DEFAULT_PROTECTION` fills a missing row),
|
|
1112
|
+
* - the owner of a protected document,
|
|
1113
|
+
* - every holder of a grant on the document or any ancestor (READ is the
|
|
1114
|
+
* floor, so any level counts).
|
|
1115
|
+
*
|
|
1116
|
+
* Listed admins are a bypass, never rows. Under OPEN everyone reads
|
|
1117
|
+
* everything and under ADMIN_ONLY only admins read, so the projection keeps
|
|
1118
|
+
* no rows for those policies; `filterFor` answers from the policy alone.
|
|
1119
|
+
*
|
|
1120
|
+
* Kept current by the permission service's change notifications and the
|
|
1121
|
+
* reactor's document and relationship change events; rebuilt from the
|
|
1122
|
+
* reactor and the permission service at start. Eventually consistent, no
|
|
1123
|
+
* worse than the permission cache's TTL. The document's own `state.auth`
|
|
1124
|
+
* policy (the reactor's read gate under `authEnforcement`) is not projected
|
|
1125
|
+
* here; a subgraph that must honour it keeps the per-document reactor check.
|
|
1126
|
+
*/
|
|
1127
|
+
export declare const READABLE_DOCUMENTS_NAMESPACE = "ph_readable_documents";
|
|
1128
|
+
/** The `user_id` that stands for every caller, anonymous included. */
|
|
1129
|
+
export declare const EVERYONE = "*";
|
|
1130
|
+
/** Document types that root the `child` hierarchy: drives. */
|
|
1131
|
+
export declare const DEFAULT_ROOT_TYPES: readonly string[];
|
|
1132
|
+
/**
|
|
1133
|
+
* What a subgraph applies to a document-keyed query for one caller: every
|
|
1134
|
+
* row, no row, or the rows whose document the projection lists for the user.
|
|
1135
|
+
*/
|
|
1136
|
+
export type ReadableFilter = {
|
|
1137
|
+
kind: "all";
|
|
1138
|
+
} | {
|
|
1139
|
+
kind: "none";
|
|
1140
|
+
} | {
|
|
1141
|
+
kind: "ids";
|
|
1142
|
+
schema: string;
|
|
1143
|
+
userId: string;
|
|
1144
|
+
};
|
|
1145
|
+
export interface ReadableDocumentsLike {
|
|
1146
|
+
/** The projection's table schema in the relational database. */
|
|
1147
|
+
readonly schema: string;
|
|
1148
|
+
/** Resolves when the first rebuild has finished; fails closed before that. */
|
|
1149
|
+
readonly ready: Promise<void>;
|
|
1150
|
+
filterFor(userAddress: string | undefined): ReadableFilter;
|
|
1151
|
+
}
|
|
1152
|
+
export interface ReadableDocumentsDeps {
|
|
1153
|
+
relationalDb: IRelationalDb$1;
|
|
1154
|
+
read: Pick<IReactorReadClient, "find" | "getOutgoingRelationshipEdges" | "subscribe">;
|
|
1155
|
+
/** Absent under OPEN and ADMIN_ONLY, where the projection keeps no rows. */
|
|
1156
|
+
permissions?: DocumentPermissionService;
|
|
1157
|
+
config: AuthorizationConfig;
|
|
1158
|
+
logger?: {
|
|
1159
|
+
info(message: string, ...args: unknown[]): void;
|
|
1160
|
+
warn(message: string, ...args: unknown[]): void;
|
|
1161
|
+
error(message: string, ...args: unknown[]): void;
|
|
1162
|
+
};
|
|
1163
|
+
/** How long changes are coalesced before one recompute (default 100 ms). */
|
|
1164
|
+
debounceMs?: number;
|
|
1165
|
+
rootTypes?: readonly string[];
|
|
1166
|
+
pageSize?: number;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* `select document_id from <schema>.readable_documents where user_id in
|
|
1170
|
+
* (:user, '*')`, for a `where document_id in (...)` on an index table.
|
|
1171
|
+
*/
|
|
1172
|
+
export declare function readableDocumentsSubquery(filter: Extract<ReadableFilter, {
|
|
1173
|
+
kind: "ids";
|
|
1174
|
+
}>): RawBuilder<string>;
|
|
1175
|
+
export interface ApplyReadableFilterOptions {
|
|
1176
|
+
/**
|
|
1177
|
+
* Rows that pass whatever the filter says, named by a column value: the
|
|
1178
|
+
* structure rows of an index that are not documents (a files listing's
|
|
1179
|
+
* folders), which are listed whenever their scope is.
|
|
1180
|
+
*/
|
|
1181
|
+
passWhen?: {
|
|
1182
|
+
column: string;
|
|
1183
|
+
equals: string | number | boolean;
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Applies a caller's filter to a query over a document-keyed index table:
|
|
1188
|
+
* unchanged for `all`, no row for `none`, `where <column> in (readable ids)`
|
|
1189
|
+
* for `ids`. `column` is the table's document id column, qualified when the
|
|
1190
|
+
* query joins.
|
|
1191
|
+
*/
|
|
1192
|
+
export declare function applyReadableFilter<QB extends {
|
|
1193
|
+
where(...args: any[]): QB;
|
|
1194
|
+
}>(query: QB, column: string, filter: ReadableFilter, options?: ApplyReadableFilterOptions): QB;
|
|
1195
|
+
/**
|
|
1196
|
+
* Whether `filter` lists one document: the scope gate of an index query (its
|
|
1197
|
+
* drive or folder), asked of the same rows the row filter joins on.
|
|
1198
|
+
*/
|
|
1199
|
+
export declare function isDocumentListed(db: Kysely<unknown>, filter: ReadableFilter, documentId: string): Promise<boolean>;
|
|
1200
|
+
export declare class ReadableDocumentsProjection implements ReadableDocumentsLike {
|
|
1201
|
+
#private;
|
|
1202
|
+
readonly schema: string;
|
|
1203
|
+
readonly ready: Promise<void>;
|
|
1204
|
+
constructor(deps: ReadableDocumentsDeps);
|
|
1205
|
+
/** Creates the tables, rebuilds the closure, and follows changes. */
|
|
1206
|
+
start(): Promise<void>;
|
|
1207
|
+
stop(): Promise<void>;
|
|
1208
|
+
filterFor(userAddress: string | undefined): ReadableFilter;
|
|
1209
|
+
/**
|
|
1210
|
+
* Rebuilds the mirrors from the reactor and the permission service, then
|
|
1211
|
+
* recomputes the closure. Serialised with the incremental updates.
|
|
1212
|
+
*/
|
|
1213
|
+
rebuild(): Promise<void>;
|
|
1214
|
+
}
|
|
1215
|
+
//#endregion
|
|
1088
1216
|
//#region src/graphql/request-clients.d.ts
|
|
1089
1217
|
/**
|
|
1090
1218
|
* The reactor client halves a resolver may use, carried on the GraphQL
|
|
@@ -1131,6 +1259,13 @@ export declare class BaseSubgraph implements ISubgraph$1 {
|
|
|
1131
1259
|
documentPermissionService?: DocumentPermissionService;
|
|
1132
1260
|
authorizationService: IAuthorizationService;
|
|
1133
1261
|
syncServingGate?: SyncScopeGate;
|
|
1262
|
+
/**
|
|
1263
|
+
* The readable-documents read model (`services/readable-documents.ts`):
|
|
1264
|
+
* the host ACL's read closure as rows an index table joins on. Absent on
|
|
1265
|
+
* a host that does not serve it; `readableFilter` then fails closed for
|
|
1266
|
+
* every caller but a listed admin.
|
|
1267
|
+
*/
|
|
1268
|
+
readableDocuments?: ReadableDocumentsLike;
|
|
1134
1269
|
/**
|
|
1135
1270
|
* The host's credential cache, for a package that revokes credentials:
|
|
1136
1271
|
* call `this.credentials.invalidateCredential(address, chainId?, appDid?)`
|
|
@@ -1184,6 +1319,25 @@ export declare class BaseSubgraph implements ISubgraph$1 {
|
|
|
1184
1319
|
readableByHost<T extends {
|
|
1185
1320
|
id: string;
|
|
1186
1321
|
}>(items: readonly T[], ctx: Context): Promise<T[]>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Whether the caller is in the ADMINS list. Not `isSupremeAdmin`: under
|
|
1324
|
+
* OPEN that admits every caller, anonymous included.
|
|
1325
|
+
*/
|
|
1326
|
+
isListedAdmin(ctx: Context): boolean;
|
|
1327
|
+
/**
|
|
1328
|
+
* The readable-documents filter for this request's caller, for a query
|
|
1329
|
+
* over an index table keyed by document (`applyReadableFilter`). Without
|
|
1330
|
+
* the read model only a listed admin reads anything: an index must never
|
|
1331
|
+
* serve more than the host would.
|
|
1332
|
+
*/
|
|
1333
|
+
readableFilter(ctx: Context): ReadableFilter;
|
|
1334
|
+
/**
|
|
1335
|
+
* The row filter for an index query scoped to one document (its drive or
|
|
1336
|
+
* folder): `none` when the caller may not read the scope itself, the
|
|
1337
|
+
* caller's `readableFilter` otherwise. One call per resolver, then
|
|
1338
|
+
* `applyReadableFilter` on every query it runs.
|
|
1339
|
+
*/
|
|
1340
|
+
indexAccess(ctx: Context, scopeDocumentId: string): Promise<ReadableFilter>;
|
|
1187
1341
|
/**
|
|
1188
1342
|
* The principal a request decides as: the authenticated caller's address, and
|
|
1189
1343
|
* the did:key of the app instance whose token authenticated it.
|
|
@@ -1342,6 +1496,11 @@ export type SubgraphArgs = {
|
|
|
1342
1496
|
* to the host's permission tables alone.
|
|
1343
1497
|
*/
|
|
1344
1498
|
syncServingGate?: SyncScopeGate;
|
|
1499
|
+
/**
|
|
1500
|
+
* The readable-documents read model, for an index subgraph's row filter
|
|
1501
|
+
* (`BaseSubgraph.readableFilter`). Absent on a host that does not serve it.
|
|
1502
|
+
*/
|
|
1503
|
+
readableDocuments?: ReadableDocumentsLike;
|
|
1345
1504
|
/**
|
|
1346
1505
|
* Attachments as the request's caller may use them. Bind per request with
|
|
1347
1506
|
* `BaseSubgraph.attachmentsFor(ctx)`.
|
|
@@ -1690,10 +1849,90 @@ export declare class AuthSubgraph extends BaseSubgraph {
|
|
|
1690
1849
|
onSetup(): Promise<void>;
|
|
1691
1850
|
}
|
|
1692
1851
|
//#endregion
|
|
1852
|
+
//#region src/graphql/index-subgraph.d.ts
|
|
1853
|
+
/**
|
|
1854
|
+
* An index subgraph: a read model's query surface with the permission check
|
|
1855
|
+
* declared, not hand-written. The subgraph says, per GraphQL field, which
|
|
1856
|
+
* argument names the scope (the drive) and how its rows relate to documents;
|
|
1857
|
+
* one wrapper applies the host's readable-documents filter around the
|
|
1858
|
+
* handler, so no query can forget it and a coverage check can prove it.
|
|
1859
|
+
*
|
|
1860
|
+
* Row shapes:
|
|
1861
|
+
* - `document`: one row is one document, named by `column`;
|
|
1862
|
+
* - `derived`: a row is computed over document rows (a count, a total, a
|
|
1863
|
+
* facet) and is filtered through the same column before aggregation, so
|
|
1864
|
+
* it never counts a document the caller could not open;
|
|
1865
|
+
* - `public`: the field serves nothing document-derived; said explicitly.
|
|
1866
|
+
*
|
|
1867
|
+
* A handler is a pure data function: it gets the drive's namespaced query
|
|
1868
|
+
* builder, the arguments, and `restrict(query, column?)`, which applies the
|
|
1869
|
+
* caller's filter to any query over the index (a refused caller gets `where
|
|
1870
|
+
* false`, so the handler never branches on access).
|
|
1871
|
+
*/
|
|
1872
|
+
export type IndexRowShape = "document" | "derived";
|
|
1873
|
+
export type IndexFieldAccess = {
|
|
1874
|
+
rows: IndexRowShape;
|
|
1875
|
+
/** The column naming the row's document; qualified when the query joins. */
|
|
1876
|
+
column: string;
|
|
1877
|
+
passWhen?: ApplyReadableFilterOptions["passWhen"];
|
|
1878
|
+
} | {
|
|
1879
|
+
public: true;
|
|
1880
|
+
};
|
|
1881
|
+
export interface IndexAccess {
|
|
1882
|
+
/** The argument that names the scope document, on every field. */
|
|
1883
|
+
scope: {
|
|
1884
|
+
drive: string;
|
|
1885
|
+
};
|
|
1886
|
+
/** Per `Type.field`, for every field of every query container type. */
|
|
1887
|
+
fields: Record<string, IndexFieldAccess>;
|
|
1888
|
+
}
|
|
1889
|
+
export interface IndexQuery<QB, TArgs = Record<string, unknown>> {
|
|
1890
|
+
args: TArgs;
|
|
1891
|
+
ctx: Context;
|
|
1892
|
+
/** The index's query builder for the scope drive. */
|
|
1893
|
+
db: QB;
|
|
1894
|
+
scope: {
|
|
1895
|
+
drive: string;
|
|
1896
|
+
};
|
|
1897
|
+
access: ReadableFilter;
|
|
1898
|
+
/** The caller's filter on a query over the index; `column` defaults to the field's. */
|
|
1899
|
+
restrict: <Q extends {
|
|
1900
|
+
where(...args: any[]): Q;
|
|
1901
|
+
}>(query: Q, column?: string) => Q;
|
|
1902
|
+
}
|
|
1903
|
+
export type IndexQueryHandler<QB> = (query: IndexQuery<QB, any>) => unknown;
|
|
1904
|
+
export interface IndexSubgraphDefinition<QB> {
|
|
1905
|
+
name: string;
|
|
1906
|
+
typeDefs: DocumentNode;
|
|
1907
|
+
/** The index's namespaced query builder for a drive (the processor's `query`). */
|
|
1908
|
+
index: (driveId: string, relationalDb: IRelationalDb$1) => QB;
|
|
1909
|
+
access: IndexAccess;
|
|
1910
|
+
/** Per `Type.field`: the pure handler. */
|
|
1911
|
+
queries: Record<string, IndexQueryHandler<QB>>;
|
|
1912
|
+
/** Everything else: root objects, enum and field mappers. */
|
|
1913
|
+
resolvers?: Record<string, Record<string, unknown>>;
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Every field of every query container type has a handler and an access
|
|
1917
|
+
* entry whose scope argument the field takes; nothing is declared that the
|
|
1918
|
+
* schema does not have. Throws naming each gap: the definition fails where
|
|
1919
|
+
* it is written, not on the first refused request.
|
|
1920
|
+
*/
|
|
1921
|
+
export declare function assertIndexAccessComplete<QB>(definition: Pick<IndexSubgraphDefinition<QB>, "name" | "typeDefs" | "access" | "queries">): void;
|
|
1922
|
+
/** The subgraph class the host registers; validated at definition time. */
|
|
1923
|
+
export declare function defineIndexSubgraph<QB>(definition: IndexSubgraphDefinition<QB>): new (args: ConstructorParameters<typeof BaseSubgraph>[0]) => BaseSubgraph;
|
|
1924
|
+
//#endregion
|
|
1693
1925
|
//#region src/graphql/gateway/auth-middleware.d.ts
|
|
1694
1926
|
export type AuthFetchMiddleware = (handler: FetchHandler) => FetchHandler;
|
|
1695
1927
|
/** Internal — only `graphql-manager.ts` should call this. */
|
|
1696
1928
|
export declare function getAuthContext(request: globalThis.Request): AuthContext | undefined;
|
|
1929
|
+
/**
|
|
1930
|
+
* Internal — for a request the host builds itself (an in-process subgraph
|
|
1931
|
+
* query on behalf of a principal it already knows), what the auth
|
|
1932
|
+
* middleware would have recorded had the request carried that principal's
|
|
1933
|
+
* bearer. Only `graphql-manager.ts` should call this.
|
|
1934
|
+
*/
|
|
1935
|
+
export declare function setAuthContext(request: globalThis.Request, context: AuthContext): void;
|
|
1697
1936
|
export declare function createAuthFetchMiddleware(authService: AuthService): AuthFetchMiddleware;
|
|
1698
1937
|
//#endregion
|
|
1699
1938
|
//#region src/graphql/gateway/drive-ownership-cache.d.ts
|
|
@@ -1807,6 +2046,8 @@ export type GraphQLManagerOptions = {
|
|
|
1807
2046
|
/** Defaults to 4001. */
|
|
1808
2047
|
port?: number;
|
|
1809
2048
|
authorizationService: IAuthorizationService;
|
|
2049
|
+
/** The readable-documents read model, handed to every subgraph. */
|
|
2050
|
+
readableDocuments?: ReadableDocumentsLike;
|
|
1810
2051
|
/** Resolvers dispatch to it for reactor-drive parents. */
|
|
1811
2052
|
reactorDriveClient?: IDriveClient;
|
|
1812
2053
|
/**
|
|
@@ -1885,16 +2126,39 @@ export declare class GraphQLManager {
|
|
|
1885
2126
|
private readonly featureFlags;
|
|
1886
2127
|
private readonly port;
|
|
1887
2128
|
private readonly syncServingGate?;
|
|
2129
|
+
private readonly readableDocuments?;
|
|
1888
2130
|
private readonly httpRoutes?;
|
|
1889
2131
|
private readonly attachments?;
|
|
1890
2132
|
private readonly inspection?;
|
|
1891
2133
|
constructor(options: GraphQLManagerOptions);
|
|
1892
|
-
init(coreSubgraphs: SubgraphClass$1[], authMiddleware?: AuthFetchMiddleware, requireAuthMiddleware?: RequireAuthFetchMiddleware): Promise<void>;
|
|
2134
|
+
init(coreSubgraphs: SubgraphClass$1[], authMiddleware?: AuthFetchMiddleware, requireAuthMiddleware?: RequireAuthFetchMiddleware, scalars?: ScalarRegistry): Promise<void>;
|
|
2135
|
+
/** Rejects when the rebuild fails; the next change retries it. */
|
|
2136
|
+
applyScalarRegistry(scalars: ScalarRegistry): Promise<void>;
|
|
1893
2137
|
/**
|
|
1894
2138
|
* Regenerate document model subgraphs when models are dynamically loaded.
|
|
1895
2139
|
* Fetches current modules from reactor client (source of truth).
|
|
1896
2140
|
*/
|
|
1897
2141
|
regenerateDocumentModelSubgraphs(): Promise<void>;
|
|
2142
|
+
/**
|
|
2143
|
+
* Runs a query against one registered subgraph in process, as `user`:
|
|
2144
|
+
* the same resolvers, the same request context and the same
|
|
2145
|
+
* authenticated-caller floor an HTTP request to `/graphql/<name>` gets,
|
|
2146
|
+
* without HTTP. For a host-side caller that acts for a principal (the
|
|
2147
|
+
* workflow runtime, for a piece's index lookup as the run's user).
|
|
2148
|
+
*
|
|
2149
|
+
* Only `query` operations: a mutation is a write, and writes go through
|
|
2150
|
+
* the write half, which signs and journals them.
|
|
2151
|
+
*/
|
|
2152
|
+
executeSubgraph(name: string, request: {
|
|
2153
|
+
query: string;
|
|
2154
|
+
variables?: Record<string, unknown>;
|
|
2155
|
+
user?: Context$1["user"];
|
|
2156
|
+
}): Promise<{
|
|
2157
|
+
data?: Record<string, unknown> | null;
|
|
2158
|
+
errors?: {
|
|
2159
|
+
message: string;
|
|
2160
|
+
}[];
|
|
2161
|
+
}>;
|
|
1898
2162
|
/**
|
|
1899
2163
|
* Register a pre-constructed subgraph instance.
|
|
1900
2164
|
* Use this when you need to pass custom dependencies to a subgraph.
|
|
@@ -2095,6 +2359,12 @@ export type API = {
|
|
|
2095
2359
|
/** The read-model relational store, for the same host-composed component:
|
|
2096
2360
|
* its tables belong in this database and nothing else hands one over. */
|
|
2097
2361
|
relationalDb: IRelationalDb$1;
|
|
2362
|
+
/**
|
|
2363
|
+
* The readable-documents read model: the host ACL's read closure in the
|
|
2364
|
+
* relational store, for index subgraphs to join on. Maintained by the API
|
|
2365
|
+
* and stopped with it.
|
|
2366
|
+
*/
|
|
2367
|
+
readableDocuments: ReadableDocumentsLike;
|
|
2098
2368
|
/** Present when the host serves inspection; `facts` takes late-bound facts. */
|
|
2099
2369
|
inspection?: IReactorInspectionSource;
|
|
2100
2370
|
/**
|
|
@@ -2122,6 +2392,7 @@ export type Processor = ProcessorFactoryBuilder[];
|
|
|
2122
2392
|
declare const PACKAGE_ENTRIES: {
|
|
2123
2393
|
readonly documentModels: "node/document-models/index.mjs";
|
|
2124
2394
|
readonly subgraphs: "node/subgraphs/index.mjs";
|
|
2395
|
+
readonly scalars: "node/scalars/index.mjs";
|
|
2125
2396
|
readonly processors: "node/processors/index.mjs";
|
|
2126
2397
|
};
|
|
2127
2398
|
type PackageEntryKind = keyof typeof PACKAGE_ENTRIES;
|
|
@@ -2238,6 +2509,7 @@ export declare class HttpPackageLoader implements IPackageLoader {
|
|
|
2238
2509
|
loadDocumentModels(packageSpec: string): Promise<DocumentModelModule[]>;
|
|
2239
2510
|
loadUpgradeManifests(packageSpec: string): Promise<UpgradeManifest<readonly number[]>[]>;
|
|
2240
2511
|
loadSubgraphs(packageSpec: string): Promise<SubgraphClass$1[]>;
|
|
2512
|
+
loadScalars(packageSpec: string): Promise<ScalarExport[]>;
|
|
2241
2513
|
loadProcessors(packageSpec: string): Promise<ProcessorFactoryBuilder | null>;
|
|
2242
2514
|
loadPieces(packageSpec: string): Promise<PackagePieceEntry[]>;
|
|
2243
2515
|
/**
|
|
@@ -5006,6 +5278,12 @@ export declare function createReactorGraphQLClient(url: string, fetchImpl?: Fetc
|
|
|
5006
5278
|
export declare class ReactorSubgraph extends BaseSubgraph {
|
|
5007
5279
|
#private;
|
|
5008
5280
|
private logger;
|
|
5281
|
+
/**
|
|
5282
|
+
* A resolver's failure: a document that does not exist is an answer (a
|
|
5283
|
+
* client asking for one it just removed), logged at info; anything else
|
|
5284
|
+
* is an error.
|
|
5285
|
+
*/
|
|
5286
|
+
private logFailure;
|
|
5009
5287
|
constructor(args: SubgraphArgs);
|
|
5010
5288
|
name: string;
|
|
5011
5289
|
hasSubscriptions: boolean;
|
|
@@ -5138,6 +5416,7 @@ export declare class ImportPackageLoader implements IPackageLoader {
|
|
|
5138
5416
|
loadDocumentModels(identifier: string): Promise<DocumentModelModule[]>;
|
|
5139
5417
|
loadUpgradeManifests(identifier: string): Promise<UpgradeManifest<readonly number[]>[]>;
|
|
5140
5418
|
loadSubgraphs(identifier: string): Promise<SubgraphClass$1[]>;
|
|
5419
|
+
loadScalars(identifier: string): Promise<ScalarExport[]>;
|
|
5141
5420
|
loadProcessors(identifier: string): Promise<ProcessorFactoryBuilder | null>;
|
|
5142
5421
|
loadPieces(identifier: string): Promise<PackagePieceEntry[]>;
|
|
5143
5422
|
private reportUnbuilt;
|
|
@@ -5166,6 +5445,9 @@ export declare class PackageManager implements IPackageManager {
|
|
|
5166
5445
|
private docModelsMap;
|
|
5167
5446
|
private upgradeManifestsMap;
|
|
5168
5447
|
private subgraphsMap;
|
|
5448
|
+
private scalarsMap;
|
|
5449
|
+
private scalarRegistry;
|
|
5450
|
+
private loggedScalarRefusals;
|
|
5169
5451
|
private processorMap;
|
|
5170
5452
|
private piecesMap;
|
|
5171
5453
|
private configWatcher;
|
|
@@ -5189,12 +5471,15 @@ export declare class PackageManager implements IPackageManager {
|
|
|
5189
5471
|
getUniqueUpgradeManifests(): UpgradeManifest<readonly number[]>[];
|
|
5190
5472
|
private loadUpgradeManifests;
|
|
5191
5473
|
private loadSubgraphs;
|
|
5474
|
+
private loadScalars;
|
|
5192
5475
|
private loadProcessors;
|
|
5193
5476
|
private loadPieces;
|
|
5194
5477
|
private maybeWarnAllLoadersFailed;
|
|
5478
|
+
private warnFailedLoad;
|
|
5195
5479
|
private withReload;
|
|
5196
5480
|
private updateDocumentModelsForPackage;
|
|
5197
5481
|
private updateSubgraphsForPackage;
|
|
5482
|
+
private updateScalarsForPackage;
|
|
5198
5483
|
private updateProcessorsForPackage;
|
|
5199
5484
|
private updatePiecesForPackage;
|
|
5200
5485
|
/** Debounced per key so repeated subscribePackages calls reuse one timer. */
|
|
@@ -5205,10 +5490,13 @@ export declare class PackageManager implements IPackageManager {
|
|
|
5205
5490
|
private initConfigFileWatcher;
|
|
5206
5491
|
private updatePackagesMap;
|
|
5207
5492
|
private updateSubgraphsMap;
|
|
5493
|
+
private updateScalarsMap;
|
|
5208
5494
|
private updateProcessorsMap;
|
|
5209
5495
|
private updatePiecesMap;
|
|
5210
5496
|
/** The document models every loaded package ships, keyed by the package. */
|
|
5211
5497
|
getDocumentModels(): Map<string, DocumentModelModule[]>;
|
|
5498
|
+
/** The scalars registered from every loaded package's `./scalars` entry. */
|
|
5499
|
+
getScalarRegistry(): ScalarRegistry;
|
|
5212
5500
|
/** The pieces every loaded package ships, keyed by the package. */
|
|
5213
5501
|
getPieces(): Map<string, PackagePieceEntry[]>;
|
|
5214
5502
|
hasPackage(pkg: string): boolean;
|
|
@@ -5216,6 +5504,8 @@ export declare class PackageManager implements IPackageManager {
|
|
|
5216
5504
|
removePackage(pkg: string): void;
|
|
5217
5505
|
onDocumentModelsChange(handler: (documentModels: Record<string, DocumentModelModule[]>) => unknown): void;
|
|
5218
5506
|
onSubgraphsChange(handler: (subgraphs: Map<string, SubgraphClass$1[]>) => unknown): void;
|
|
5507
|
+
/** Called when the registry changes; an equal rebuild is not a change. */
|
|
5508
|
+
onScalarsChange(handler: (scalars: ScalarRegistry) => unknown): void;
|
|
5219
5509
|
onProcessorsChange(handler: (processors: Map<string, Processor$1>) => unknown): void;
|
|
5220
5510
|
onPiecesChange(handler: (pieces: Map<string, PackagePieceEntry[]>) => unknown): void;
|
|
5221
5511
|
}
|
|
@@ -5474,6 +5764,6 @@ export declare class PrivacyPermissionAdapter {
|
|
|
5474
5764
|
erasePermissions(documentId: string): Promise<Record<string, number>>;
|
|
5475
5765
|
}
|
|
5476
5766
|
//#endregion
|
|
5477
|
-
export { type AttachmentReadGate, type AuthorizationConfig, type AuthorizerResult, type CanonicalDocumentId, DocumentModelSchema, DocumentModelSchemaCache, DocumentModelSchemaOptions, DocumentModelSource, GeneratedDocumentModelTypes, type HttpRouteServiceOptions, type IAuthorizationService, type IDocumentScopeGate, type IEventLoopDelaySource, type IHttpScope, type IPackageLoader, type IPackageLoaderOptions, type IPackagePieceSource, type IReactorInspectionSource, type IWebhookEndpoints, type IWebhookScope, type IWebhookStore, type InspectionCallerGate, type InspectionReadField, type InspectionThrottleConfig, type NodeRouteSpec, PGLITE_UTC_PARSERS, type PackagePiece, type PackagePieceEntry, type PackagesSubgraphArgs, type ParsedDriveUrl, type PublicOrigin, type ReactorInspectionOptions, ReportError, type RequestClients, type RequestLoadRecorderOptions, ReservedTypeNames, ResolvedDocumentModelSchema, type RouteActor, type RouteAuth, type RouteAuthorizer, type RouteBody, type RouteContext, type RouteHandler, type RouteMethod, type RouteOptions, type RouteSpec, type RouteTransport, type RouteUser, RunDetachedOptions, type ScopedRouteHandle, SubgraphSchemaOptions, SubgraphTypeCollisionError, type WebhookEndpointInfo, type WebhookEndpointRow, type WebhookField, type WebhookHashAlgorithm, type WebhookPolicy, type WebhookReply, type WebhookRequest, type WebhookScheme, type WebhookSignatureEncoding, type WebhookSpec, type WebhookVerification, assembleSubgraphTypeDefs, buildDocumentModelSchema, buildSubgraphSchemaModule, createMergedSchema, createSchema, documentModelSubgraphTypes, driveIdFromUrl, findSubgraphTypeCollisions, generateDocumentModelSchema, generatedTypesOf, getDocumentModelSchemaName, getDocumentModelSubgraphName, getDocumentModelTypeDefs, getGeneratedDocumentModelTypes, hasOperationSchemas, parseDriveUrl, reportFailure, reservedTypeNames, reservedTypeNamesTaken, runDetached, typeDefinitionNames };
|
|
5767
|
+
export { type AttachmentReadGate, type AuthorizationConfig, type AuthorizerResult, type CanonicalDocumentId, DocumentModelSchema, DocumentModelSchemaCache, DocumentModelSchemaOptions, DocumentModelSource, GeneratedDocumentModelTypes, type HttpRouteServiceOptions, type IAuthorizationService, type IDocumentScopeGate, type IEventLoopDelaySource, type IHttpScope, type IPackageLoader, type IPackageLoaderOptions, type IPackagePieceSource, type IReactorInspectionSource, type IWebhookEndpoints, type IWebhookScope, type IWebhookStore, type InspectionCallerGate, type InspectionReadField, type InspectionThrottleConfig, type NodeRouteSpec, PGLITE_UTC_PARSERS, type PackagePiece, type PackagePieceEntry, type PackagesSubgraphArgs, type ParsedDriveUrl, type PublicOrigin, type ReactorInspectionOptions, type RegisteredScalar, ReportError, type RequestClients, type RequestLoadRecorderOptions, ReservedTypeNames, ResolvedDocumentModelSchema, type RouteActor, type RouteAuth, type RouteAuthorizer, type RouteBody, type RouteContext, type RouteHandler, type RouteMethod, type RouteOptions, type RouteSpec, type RouteTransport, type RouteUser, RunDetachedOptions, type ScalarExport, type ScalarRegistry, type ScopedRouteHandle, SubgraphSchemaOptions, SubgraphTypeCollisionError, type WebhookEndpointInfo, type WebhookEndpointRow, type WebhookField, type WebhookHashAlgorithm, type WebhookPolicy, type WebhookReply, type WebhookRequest, type WebhookScheme, type WebhookSignatureEncoding, type WebhookSpec, type WebhookVerification, assembleSubgraphTypeDefs, buildDocumentModelSchema, buildSubgraphSchemaModule, createMergedSchema, createSchema, documentModelSubgraphTypes, driveIdFromUrl, findSubgraphTypeCollisions, generateDocumentModelSchema, generatedTypesOf, getDocumentModelSchemaName, getDocumentModelSubgraphName, getDocumentModelTypeDefs, getGeneratedDocumentModelTypes, hasOperationSchemas, parseDriveUrl, reportFailure, reservedTypeNames, reservedTypeNamesTaken, runDetached, typeDefinitionNames };
|
|
5478
5768
|
export {};
|
|
5479
5769
|
//# sourceMappingURL=index.d.mts.map
|