@powerhousedao/reactor-api 6.2.3-dev.85 → 6.2.3-dev.87
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/{base-document-models-DZfYOd9M.mjs → base-document-models-CNHrVpOU.mjs} +235 -4
- package/dist/{base-document-models-DZfYOd9M.mjs.map → base-document-models-CNHrVpOU.mjs.map} +1 -1
- package/dist/{error-info-BaEL50f5.mjs → error-info-Cr6oQACe.mjs} +119 -4
- package/dist/error-info-Cr6oQACe.mjs.map +1 -0
- package/dist/index.d.mts +114 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +324 -19
- package/dist/index.mjs.map +1 -1
- package/dist/{package-subgraph-check-DxZhf2lB.mjs → package-subgraph-check-DdZLhOHW.mjs} +4 -4
- package/dist/{package-subgraph-check-DxZhf2lB.mjs.map → package-subgraph-check-DdZLhOHW.mjs.map} +1 -1
- package/dist/{pglite-node-DGms6Ssa.mjs → pglite-node-CcX2YT-l.mjs} +33 -4
- package/dist/pglite-node-CcX2YT-l.mjs.map +1 -0
- package/dist/src/graphql/subgraph-types.mjs +1 -1
- package/dist/src/pglite/pglite-node.d.mts +43 -2
- package/dist/src/pglite/pglite-node.d.mts.map +1 -1
- package/dist/src/pglite/pglite-node.mjs +5 -5
- package/dist/src/pglite/worker/entry.mjs +51 -4
- package/dist/src/pglite/worker/entry.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/error-info-BaEL50f5.mjs.map +0 -1
- package/dist/pglite-node-DGms6Ssa.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e0118eab-dd2a-5bf7-a67c-c78a1da0b48f")}catch(e){}}();
|
|
3
3
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
4
4
|
import { A as RequestClientBinder, B as CanonicalDocumentIdResolutionError, C as loadDocumentModels, D as manifestDeclaredSubgraphs, E as loadSubgraphs, F as READABLE_DOCUMENTS_NAMESPACE, G as AuthEvaluationUnsupportedError, H as AuthorizationPolicy, I as ReadableDocumentsProjection, J as MalformedStoredOperationError, K as AuthenticationRequiredError, L as applyReadableFilter, M as createCredentialInvalidator, N as DEFAULT_ROOT_TYPES, O as BaseSubgraph, P as EVERYONE, R as isDocumentListed, T as loadScalars, U as AuthorizedDocumentHandle, V as createCanonicalDocumentIdResolver, W as createAuthorizationService, Y as RefusalNotRecordedError, _ as runDetached, a as PIECE_SOURCE_LIST, b as extractUpgradeManifests, c as piecesFromCdnList, d as buildGraphQlDocument, f as buildGraphQlDriveDocument, g as reportFailure, h as isSubgraphClass, j as AuthService, k as callerSubject, l as piecesFromListModule, m as buildGraphqlOperations, n as scalarExportsOf, p as buildGraphqlOperation, q as ForbiddenError, s as pieceListLocation, t as extractSubgraphs, u as extractDocumentModels, v as PACKAGE_MODULE_FAILED, w as loadProcessors, x as failedLoadHeader, y as debounce, z as readableDocumentsSubquery } from "./subgraph-extraction-BA9WKjn1.mjs";
|
|
5
|
-
import { A as getDocumentModelTypeDefs, C as createMergedSchema, D as generateDocumentModelSchema, E as findSubgraphTypeCollisions, F as typeDefinitionNames, I as getDocumentModelSchemaName, L as EMPTY_SCALAR_REGISTRY, M as hasOperationSchemas, N as reservedTypeNames, O as generatedTypesOf, P as reservedTypeNamesTaken, R as sameScalarRegistry, S as buildSubgraphSchemaModule, T as documentModelSubgraphTypes, _ as describeOwnershipConflicts, a as inspectionAdminTypeDefs, b as assembleSubgraphTypeDefs, c as HOST_ORIGIN, d as byClaimPriority, f as decideAdmission, g as collectSubgraphClaims, h as supergraphClaimLosers, i as inspectionTypeDefs, j as getGeneratedDocumentModelTypes, k as getDocumentModelSubgraphName, l as RegistrationOrder, m as documentModelSubgraphSources, n as systemTypeDefs, o as CORE_ORIGIN, p as describeOrigin, r as schema_default$2, s as DOCUMENT_MODEL_ORIGIN, t as baseDocumentModels, u as admitDocumentModels, v as DocumentModelSchemaCache, w as createSchema, x as buildDocumentModelSchema, y as SubgraphTypeCollisionError, z as schema_default$1 } from "./base-document-models-
|
|
5
|
+
import { A as getDocumentModelTypeDefs, C as createMergedSchema, D as generateDocumentModelSchema, E as findSubgraphTypeCollisions, F as typeDefinitionNames, I as getDocumentModelSchemaName, L as EMPTY_SCALAR_REGISTRY, M as hasOperationSchemas, N as reservedTypeNames, O as generatedTypesOf, P as reservedTypeNamesTaken, R as sameScalarRegistry, S as buildSubgraphSchemaModule, T as documentModelSubgraphTypes, _ as describeOwnershipConflicts, a as inspectionAdminTypeDefs, b as assembleSubgraphTypeDefs, c as HOST_ORIGIN, d as byClaimPriority, f as decideAdmission, g as collectSubgraphClaims, h as supergraphClaimLosers, i as inspectionTypeDefs, j as getGeneratedDocumentModelTypes, k as getDocumentModelSubgraphName, l as RegistrationOrder, m as documentModelSubgraphSources, n as systemTypeDefs, o as CORE_ORIGIN, p as describeOrigin, r as schema_default$2, s as DOCUMENT_MODEL_ORIGIN, t as baseDocumentModels, u as admitDocumentModels, v as DocumentModelSchemaCache, w as createSchema, x as buildDocumentModelSchema, y as SubgraphTypeCollisionError, z as schema_default$1 } from "./base-document-models-CNHrVpOU.mjs";
|
|
6
6
|
import { n as createApolloFetchHandler } from "./adapter-gateway-apollo-D-EdZ4e-.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { h as preparePgliteDataDir, m as openCurrentPgliteForVerify } from "./pglite-node-
|
|
7
|
+
import { _ as PGLITE_UTC_PARSERS, a as resolvePgliteMaintenance, r as createDurableNodeFs } from "./error-info-Cr6oQACe.mjs";
|
|
8
|
+
import { h as preparePgliteDataDir, m as openCurrentPgliteForVerify } from "./pglite-node-CcX2YT-l.mjs";
|
|
9
9
|
import nodeModule, { isBuiltin } from "node:module";
|
|
10
10
|
import { AttachmentBuilder, AttachmentNotFound, AttachmentReferenceIndexBuilder, createRef, createS3AttachmentBackend, parseAttachmentStorageConfig, parseRef, validateReserveMetadata } from "@powerhousedao/reactor-attachments";
|
|
11
11
|
import { ConsoleLogger, childLogger } from "document-model";
|
|
@@ -13,7 +13,7 @@ import { AnalyticsQueryEngine } from "@powerhousedao/analytics-engine-core";
|
|
|
13
13
|
import { AnalyticsModel, AnalyticsResolvers, typedefs } from "@powerhousedao/analytics-engine-graphql";
|
|
14
14
|
import { gql } from "graphql-tag";
|
|
15
15
|
import { GraphQLError, Kind, OperationTypeNode, buildASTSchema, getOperationAST, isTypeDefinitionNode, isTypeExtensionNode, parse, print, specifiedScalarTypes, validateSchema, valueFromASTUntyped, visit } from "graphql";
|
|
16
|
-
import { AuthEnforcementDisabledError, BareReadGate, BatchJobFailedError, CATCH_UP_LOAD_WINDOW_MS, ChannelError, ChannelErrorSource, DEFAULT_DRIVE_CONTAINER_TYPES, DriveCollectionId, DriveInspection, FacadeWriteClient, InvalidDeadLetterCursorError, JOB_NOT_FOUND_ERROR_NAME, JobStatus, ModelReadGate, PropagationMode as PropagationMode$1, READ_ONLY_ACCESS, SyncOperation, SyncScopeGate, consolidateSyncOperations, createReactorHostModuleBase, createReactorInspector, driveIdFromUrl, envelopesToSyncOperations, isCatchUpLevel, parseDriveUrl, readDecisionModel, supportsPurgeRefusals, syncOperationErrorType, toWireCatchUpPriority, toWireDeadLetter, toWireQueueState, warnOnce } from "@powerhousedao/reactor";
|
|
16
|
+
import { AuthEnforcementDisabledError, BareReadGate, BatchJobFailedError, CATCH_UP_LOAD_WINDOW_MS, ChannelError, ChannelErrorSource, DEFAULT_DRIVE_CONTAINER_TYPES, DriveCollectionId, DriveInspection, FacadeWriteClient, InvalidDeadLetterCursorError, JOB_NOT_FOUND_ERROR_NAME, JobStatus, ModelReadGate, PropagationMode as PropagationMode$1, READ_ONLY_ACCESS, SyncOperation, SyncScopeGate, consolidateSyncOperations, createReactorHostModuleBase, createReactorInspector, driveIdFromUrl, envelopesToSyncOperations, isCatchUpLevel, isMemoryTelemetryOutput, parseDriveUrl, readDecisionModel, supportsPurgeRefusals, syncOperationErrorType, toWireCatchUpPriority, toWireDeadLetter, toWireQueueState, warnOnce } from "@powerhousedao/reactor";
|
|
17
17
|
import { deserializeSignature, readPeerManifest, serializeSignature, setName } from "@powerhousedao/shared/document-model";
|
|
18
18
|
import { createRelationalDb, getCodegenStatusRegistry } from "@powerhousedao/shared/processors";
|
|
19
19
|
import { Kysely, Migrator, sql } from "kysely";
|
|
@@ -25,8 +25,8 @@ import posix from "node:path/posix";
|
|
|
25
25
|
import { Readable } from "node:stream";
|
|
26
26
|
import { pipeline } from "node:stream/promises";
|
|
27
27
|
import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
28
|
-
import nodeFs, { existsSync, readFileSync, watchFile } from "node:fs";
|
|
29
|
-
import { monitorEventLoopDelay } from "node:perf_hooks";
|
|
28
|
+
import nodeFs, { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, watchFile } from "node:fs";
|
|
29
|
+
import { PerformanceObserver, constants, monitorEventLoopDelay } from "node:perf_hooks";
|
|
30
30
|
import { pathToFileURL } from "node:url";
|
|
31
31
|
import { SCALAR_DEFINITION_VERSION, getCatalogScalar } from "document-model/scalars";
|
|
32
32
|
import * as z$1 from "zod";
|
|
@@ -51,7 +51,7 @@ import EventEmitter from "node:events";
|
|
|
51
51
|
import { PostgresAnalyticsStore } from "@powerhousedao/analytics-engine-pg";
|
|
52
52
|
import { createAttachmentClient } from "@powerhousedao/reactor-attachments/client";
|
|
53
53
|
import { setupMcpServer } from "@powerhousedao/reactor-mcp";
|
|
54
|
-
import { tmpdir } from "node:os";
|
|
54
|
+
import { freemem, tmpdir } from "node:os";
|
|
55
55
|
import { WebSocketServer } from "ws";
|
|
56
56
|
import { isAttachmentHash, readGateAllowsAttachmentRead, scopeGateAllowsAttachmentRead } from "@powerhousedao/reactor-attachments/replication";
|
|
57
57
|
import { PGlite } from "@electric-sql/pglite";
|
|
@@ -59,6 +59,8 @@ import { NodeFS } from "@electric-sql/pglite/nodefs";
|
|
|
59
59
|
import knex from "knex";
|
|
60
60
|
import ClientPgLite from "knex-pglite";
|
|
61
61
|
import { KyselyKnexDialect, PGColdDialect } from "kysely-knex";
|
|
62
|
+
import { getHeapSpaceStatistics, getHeapStatistics, writeHeapSnapshot } from "node:v8";
|
|
63
|
+
import { resolvePhDir as resolvePhDir$1 } from "@powerhousedao/shared/clis";
|
|
62
64
|
//#region src/graphql/gateway/types.ts
|
|
63
65
|
/** No authenticated caller resolved, and REQUIRE_AUTHENTICATED_CALLER wants one. */
|
|
64
66
|
const WS_CLOSE_REASON_AUTHENTICATION_REQUIRED = "authentication-required";
|
|
@@ -1658,7 +1660,7 @@ var HttpScope = class {
|
|
|
1658
1660
|
const method = req.method ?? "GET";
|
|
1659
1661
|
const url = `${ctx.transport.baseUrl}${req.url ?? "/"}`;
|
|
1660
1662
|
const controller = new AbortController();
|
|
1661
|
-
|
|
1663
|
+
res.once("close", () => controller.abort());
|
|
1662
1664
|
let raw;
|
|
1663
1665
|
let init = {
|
|
1664
1666
|
method,
|
|
@@ -2561,6 +2563,22 @@ const GetCreateProtocolVersionsDocument = gql`
|
|
|
2561
2563
|
}
|
|
2562
2564
|
}
|
|
2563
2565
|
`;
|
|
2566
|
+
const GetUndoRedoTargetsDocument = gql`
|
|
2567
|
+
query GetUndoRedoTargets(
|
|
2568
|
+
$documentIdOrSlug: String!
|
|
2569
|
+
$scope: String
|
|
2570
|
+
$branch: String
|
|
2571
|
+
) {
|
|
2572
|
+
undoRedoTargets(
|
|
2573
|
+
documentIdOrSlug: $documentIdOrSlug
|
|
2574
|
+
scope: $scope
|
|
2575
|
+
branch: $branch
|
|
2576
|
+
) {
|
|
2577
|
+
undoTarget
|
|
2578
|
+
redoTarget
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
`;
|
|
2564
2582
|
const GetDriveNodesDocument = gql`
|
|
2565
2583
|
query GetDriveNodes(
|
|
2566
2584
|
$driveId: ID!
|
|
@@ -2983,6 +3001,9 @@ function getSdk(requester) {
|
|
|
2983
3001
|
GetCreateProtocolVersions(variables, options) {
|
|
2984
3002
|
return requester(GetCreateProtocolVersionsDocument, variables, options);
|
|
2985
3003
|
},
|
|
3004
|
+
GetUndoRedoTargets(variables, options) {
|
|
3005
|
+
return requester(GetUndoRedoTargetsDocument, variables, options);
|
|
3006
|
+
},
|
|
2986
3007
|
GetDriveNodes(variables, options) {
|
|
2987
3008
|
return requester(GetDriveNodesDocument, variables, options);
|
|
2988
3009
|
},
|
|
@@ -3470,6 +3491,7 @@ const DEFAULT_BRANCH = "main";
|
|
|
3470
3491
|
/** The `Query.<field>` coordinates handed the write client outside a mutation. */
|
|
3471
3492
|
const WRITE_CLIENT_QUERIES = Object.entries({
|
|
3472
3493
|
evaluateActions: "write",
|
|
3494
|
+
undoRedoTargets: "write",
|
|
3473
3495
|
pollSyncEnvelopes: "syncManager",
|
|
3474
3496
|
syncHolds: "syncManager",
|
|
3475
3497
|
peerAgreement: "syncManager",
|
|
@@ -3532,6 +3554,17 @@ async function createDefaults(read, parentIdOrSlug, documentType) {
|
|
|
3532
3554
|
protocolVersions
|
|
3533
3555
|
};
|
|
3534
3556
|
}
|
|
3557
|
+
/** Read-gated by the client: a scope the subject may not read has none. */
|
|
3558
|
+
async function undoRedoTargets(write, args, subject) {
|
|
3559
|
+
const targets = await write.undoRedoTargets(args.documentIdOrSlug, fromInputMaybe(args.scope) ?? void 0, {
|
|
3560
|
+
branch: fromInputMaybe(args.branch) ?? void 0,
|
|
3561
|
+
subject
|
|
3562
|
+
});
|
|
3563
|
+
return {
|
|
3564
|
+
undoTarget: targets.undoTarget ?? null,
|
|
3565
|
+
redoTarget: targets.redoTarget ?? null
|
|
3566
|
+
};
|
|
3567
|
+
}
|
|
3535
3568
|
async function documentModels(read, args) {
|
|
3536
3569
|
const namespace = fromInputMaybe(args.namespace);
|
|
3537
3570
|
let paging;
|
|
@@ -7114,6 +7147,8 @@ function createInspectionResolvers(source, sync, gate) {
|
|
|
7114
7147
|
}),
|
|
7115
7148
|
queueState: operator(async () => toWireQueueState(await inspector.getQueueState())),
|
|
7116
7149
|
processors: operator(async () => (await inspector.getProcessors()).map(toWireProcessor)),
|
|
7150
|
+
processorTiming: operator(() => inspector.getProcessorTiming()),
|
|
7151
|
+
memoryTelemetry: operator((args) => inspector.getMemoryTelemetry(args.limit ?? void 0, args.sinceIso ?? void 0)),
|
|
7117
7152
|
catchUpStatus: operator(() => inspector.getCatchUpStatus()),
|
|
7118
7153
|
catchUpPriority: operator(async () => toWireCatchUpPriority(await inspector.getCatchUpPriority())),
|
|
7119
7154
|
storageHealth: operator(() => inspector.getStorageHealth()),
|
|
@@ -7227,6 +7262,19 @@ function catchUpPrioritySettingOf(args) {
|
|
|
7227
7262
|
level
|
|
7228
7263
|
};
|
|
7229
7264
|
}
|
|
7265
|
+
/** The change `args` name; throws BAD_USER_INPUT for an unknown output. */
|
|
7266
|
+
function memoryTelemetryChangeOf(args) {
|
|
7267
|
+
const unknown = args.outputs?.find((o) => !isMemoryTelemetryOutput(o));
|
|
7268
|
+
if (unknown !== void 0) throw badInput(`Memory telemetry has no output ${JSON.stringify(unknown)}`);
|
|
7269
|
+
return {
|
|
7270
|
+
enabled: args.enabled,
|
|
7271
|
+
intervalMs: args.intervalMs ?? void 0,
|
|
7272
|
+
outputs: args.outputs?.filter(isMemoryTelemetryOutput)
|
|
7273
|
+
};
|
|
7274
|
+
}
|
|
7275
|
+
function refused(error) {
|
|
7276
|
+
return new GraphQLError(error instanceof Error ? error.message : String(error), { extensions: { code: "LEVER_REFUSED" } });
|
|
7277
|
+
}
|
|
7230
7278
|
/** How long a mutation waits on its lever before answering that it started. */
|
|
7231
7279
|
const LEVER_ANSWER_WINDOW_MS = 2e3;
|
|
7232
7280
|
/**
|
|
@@ -7248,6 +7296,14 @@ async function pulled(lever, onLateFailure, windowMs) {
|
|
|
7248
7296
|
}
|
|
7249
7297
|
return true;
|
|
7250
7298
|
}
|
|
7299
|
+
/** Passes a lever's refusal to the caller as LEVER_REFUSED. */
|
|
7300
|
+
async function refusable(lever) {
|
|
7301
|
+
try {
|
|
7302
|
+
return await lever();
|
|
7303
|
+
} catch (error) {
|
|
7304
|
+
throw new GraphQLError(error instanceof Error ? error.message : String(error), { extensions: { code: "LEVER_REFUSED" } });
|
|
7305
|
+
}
|
|
7306
|
+
}
|
|
7251
7307
|
/** Inspection levers for listed admins, kept apart from the read-only inspection subgraph. */
|
|
7252
7308
|
var InspectionAdminSubgraph = class extends BaseSubgraph {
|
|
7253
7309
|
name = "inspection-admin";
|
|
@@ -7269,10 +7325,16 @@ var InspectionAdminSubgraph = class extends BaseSubgraph {
|
|
|
7269
7325
|
return run(args);
|
|
7270
7326
|
};
|
|
7271
7327
|
return {
|
|
7272
|
-
Query: {
|
|
7273
|
-
|
|
7274
|
-
|
|
7275
|
-
|
|
7328
|
+
Query: {
|
|
7329
|
+
inspectionAdmin: listed(() => ({
|
|
7330
|
+
processors: true,
|
|
7331
|
+
catchUpPriority: true,
|
|
7332
|
+
memoryTelemetry: true,
|
|
7333
|
+
keyframes: true
|
|
7334
|
+
})),
|
|
7335
|
+
inspectionKeyframeCleanup: listed(() => admin.getKeyframeCleanup()),
|
|
7336
|
+
inspectionKeyframeReclaim: listed(() => admin.getKeyframeReclaim())
|
|
7337
|
+
},
|
|
7276
7338
|
Mutation: {
|
|
7277
7339
|
inspectionRetryProcessor: listed(({ processorId }) => pulled(() => admin.retryProcessor(processorId), (error) => this.leverFailed("Retry", processorId, error), this.answerWindowMs)),
|
|
7278
7340
|
inspectionRerunProcessor: listed(({ processorId, clear, fromOrdinal }) => pulled(() => admin.rerunProcessor(processorId, {
|
|
@@ -7284,10 +7346,32 @@ var InspectionAdminSubgraph = class extends BaseSubgraph {
|
|
|
7284
7346
|
try {
|
|
7285
7347
|
await admin.setCatchUpPriority(setting);
|
|
7286
7348
|
} catch (error) {
|
|
7287
|
-
throw
|
|
7349
|
+
throw refused(error);
|
|
7350
|
+
}
|
|
7351
|
+
return true;
|
|
7352
|
+
}),
|
|
7353
|
+
inspectionSetMemoryTelemetry: listed(async (args) => {
|
|
7354
|
+
const change = memoryTelemetryChangeOf(args);
|
|
7355
|
+
try {
|
|
7356
|
+
await admin.setMemoryTelemetry(change);
|
|
7357
|
+
} catch (error) {
|
|
7358
|
+
throw refused(error);
|
|
7359
|
+
}
|
|
7360
|
+
return true;
|
|
7361
|
+
}),
|
|
7362
|
+
inspectionWriteHeapSnapshot: listed(async ({ force }) => {
|
|
7363
|
+
try {
|
|
7364
|
+
return await admin.writeHeapSnapshot(force ?? false);
|
|
7365
|
+
} catch (error) {
|
|
7366
|
+
throw refused(error);
|
|
7288
7367
|
}
|
|
7368
|
+
}),
|
|
7369
|
+
inspectionStartKeyframeCleanup: listed(({ dryRun }) => refusable(() => admin.startKeyframeCleanup({ dryRun }))),
|
|
7370
|
+
inspectionCancelKeyframeCleanup: listed(async () => {
|
|
7371
|
+
await admin.cancelKeyframeCleanup();
|
|
7289
7372
|
return true;
|
|
7290
|
-
})
|
|
7373
|
+
}),
|
|
7374
|
+
inspectionReclaimKeyframeSpace: listed(() => refusable(() => admin.reclaimKeyframeSpace()))
|
|
7291
7375
|
}
|
|
7292
7376
|
};
|
|
7293
7377
|
}
|
|
@@ -7757,6 +7841,10 @@ const CreateDefaultsDTO = z.object({
|
|
|
7757
7841
|
signaturePolicy: z.string(),
|
|
7758
7842
|
protocolVersions: JSONObjectDTO
|
|
7759
7843
|
}).strip();
|
|
7844
|
+
const UndoRedoTargetsDTO = z.object({
|
|
7845
|
+
undoTarget: z.string().nullable().optional(),
|
|
7846
|
+
redoTarget: z.string().nullable().optional()
|
|
7847
|
+
}).strip();
|
|
7760
7848
|
const DriveNodeDTO = z.object({
|
|
7761
7849
|
id: z.string(),
|
|
7762
7850
|
driveId: z.string(),
|
|
@@ -7827,6 +7915,9 @@ const operationValidators = {
|
|
|
7827
7915
|
GetCreateProtocolVersions: (data) => {
|
|
7828
7916
|
if (data.createDefaults) CreateDefaultsDTO.pick({ protocolVersions: true }).parse(data.createDefaults);
|
|
7829
7917
|
},
|
|
7918
|
+
GetUndoRedoTargets: (data) => {
|
|
7919
|
+
if (data.undoRedoTargets) UndoRedoTargetsDTO.parse(data.undoRedoTargets);
|
|
7920
|
+
},
|
|
7830
7921
|
GetDriveNodes: (data) => {
|
|
7831
7922
|
if (data.driveNodes) DriveNodePageDTO.parse(data.driveNodes);
|
|
7832
7923
|
},
|
|
@@ -8439,6 +8530,20 @@ var ReactorSubgraph = class extends BaseSubgraph {
|
|
|
8439
8530
|
throw error;
|
|
8440
8531
|
}
|
|
8441
8532
|
},
|
|
8533
|
+
undoRedoTargets: async (_parent, args, ctx) => {
|
|
8534
|
+
this.logger.debug("undoRedoTargets(@args)", args);
|
|
8535
|
+
try {
|
|
8536
|
+
const handle = await this.assertCanRead(args.documentIdOrSlug, ctx);
|
|
8537
|
+
return await undoRedoTargets(this.clientsOf(ctx).write, {
|
|
8538
|
+
documentIdOrSlug: handle.fetchIdentifier,
|
|
8539
|
+
scope: args.scope,
|
|
8540
|
+
branch: args.branch
|
|
8541
|
+
}, this.viewSubject(ctx));
|
|
8542
|
+
} catch (error) {
|
|
8543
|
+
this.logger.error("Error in undoRedoTargets: @Error", error);
|
|
8544
|
+
throw error;
|
|
8545
|
+
}
|
|
8546
|
+
},
|
|
8442
8547
|
documentOperations: async (_parent, args, ctx) => {
|
|
8443
8548
|
this.logger.debug("documentOperations(@args)", args);
|
|
8444
8549
|
try {
|
|
@@ -8923,10 +9028,10 @@ const ADMIN_USERS = new Proxy([], {
|
|
|
8923
9028
|
//#endregion
|
|
8924
9029
|
//#region src/graphql/system/version.ts
|
|
8925
9030
|
function getVersion() {
|
|
8926
|
-
return "6.2.3-dev.
|
|
9031
|
+
return "6.2.3-dev.87";
|
|
8927
9032
|
}
|
|
8928
9033
|
function getGitHash() {
|
|
8929
|
-
return "
|
|
9034
|
+
return "f0fdb1915e2d19e5b45f04dbef71f024fecb4d40";
|
|
8930
9035
|
}
|
|
8931
9036
|
function getGitUrl() {
|
|
8932
9037
|
return buildTreeUrl(getGitHash());
|
|
@@ -12412,7 +12517,207 @@ var PackageManagementService = class {
|
|
|
12412
12517
|
}
|
|
12413
12518
|
};
|
|
12414
12519
|
//#endregion
|
|
12415
|
-
|
|
12520
|
+
//#region src/telemetry/jsonl-sink.ts
|
|
12521
|
+
const MIB = 1048576;
|
|
12522
|
+
/** An ISO time usable in a Windows file name. */
|
|
12523
|
+
function fileTimestamp(date) {
|
|
12524
|
+
return date.toISOString().replace(/[:.]/g, "-");
|
|
12525
|
+
}
|
|
12526
|
+
/** Where telemetry files land: `<phDir>/telemetry`, following `PH_USER_DATA_DIR`. */
|
|
12527
|
+
function telemetryDir(env = process.env) {
|
|
12528
|
+
return path.join(resolvePhDir$1(void 0, env), "telemetry");
|
|
12529
|
+
}
|
|
12530
|
+
/**
|
|
12531
|
+
* Appends one JSON line at a time and rotates at `maxBytes`: the full file moves
|
|
12532
|
+
* to `<stem>.<n>.jsonl`, and the oldest beyond `keep` is deleted. Each append is
|
|
12533
|
+
* synchronous and small, so a hard kill loses nothing written so far.
|
|
12534
|
+
*/
|
|
12535
|
+
var JsonlFile = class {
|
|
12536
|
+
options;
|
|
12537
|
+
path;
|
|
12538
|
+
size = 0;
|
|
12539
|
+
rotation = 0;
|
|
12540
|
+
failed = false;
|
|
12541
|
+
stem;
|
|
12542
|
+
dir;
|
|
12543
|
+
constructor(options) {
|
|
12544
|
+
this.options = options;
|
|
12545
|
+
this.path = options.path;
|
|
12546
|
+
this.dir = path.dirname(options.path);
|
|
12547
|
+
this.stem = path.basename(options.path, ".jsonl");
|
|
12548
|
+
mkdirSync(this.dir, { recursive: true });
|
|
12549
|
+
this.append(`${JSON.stringify(options.header)}\n`);
|
|
12550
|
+
}
|
|
12551
|
+
writeLine(value) {
|
|
12552
|
+
const line = `${JSON.stringify(value)}\n`;
|
|
12553
|
+
if (this.size + line.length > this.options.maxBytes) this.rotate();
|
|
12554
|
+
this.append(line);
|
|
12555
|
+
}
|
|
12556
|
+
append(line) {
|
|
12557
|
+
try {
|
|
12558
|
+
appendFileSync(this.path, line);
|
|
12559
|
+
this.size += line.length;
|
|
12560
|
+
this.failed = false;
|
|
12561
|
+
} catch (error) {
|
|
12562
|
+
if (!this.failed) this.options.logger?.warn("Telemetry file '@Path' cannot be written: @Error", this.path, error);
|
|
12563
|
+
this.failed = true;
|
|
12564
|
+
}
|
|
12565
|
+
}
|
|
12566
|
+
rotate() {
|
|
12567
|
+
this.rotation++;
|
|
12568
|
+
try {
|
|
12569
|
+
renameSync(this.path, path.join(this.dir, `${this.stem}.${this.rotation}.jsonl`));
|
|
12570
|
+
} catch {}
|
|
12571
|
+
this.size = 0;
|
|
12572
|
+
this.prune();
|
|
12573
|
+
this.append(`${JSON.stringify(this.options.header)}\n`);
|
|
12574
|
+
}
|
|
12575
|
+
prune() {
|
|
12576
|
+
const rotated = readdirSync(this.dir).map((name) => ({
|
|
12577
|
+
name,
|
|
12578
|
+
n: new RegExp(`^${escapeRegExp(this.stem)}\\.(\\d+)\\.jsonl$`).exec(name)?.[1]
|
|
12579
|
+
})).filter((file) => file.n !== void 0).sort((a, b) => Number(a.n) - Number(b.n));
|
|
12580
|
+
const excess = rotated.length - (this.options.keep - 1);
|
|
12581
|
+
for (const file of rotated.slice(0, Math.max(excess, 0))) rmSync(path.join(this.dir, file.name), { force: true });
|
|
12582
|
+
}
|
|
12583
|
+
};
|
|
12584
|
+
function escapeRegExp(text) {
|
|
12585
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12586
|
+
}
|
|
12587
|
+
/** Opens the memory telemetry's JSONL file; the header holds no env values. */
|
|
12588
|
+
function memoryFileSink(config, options = {}) {
|
|
12589
|
+
const now = options.now?.() ?? /* @__PURE__ */ new Date();
|
|
12590
|
+
const file = new JsonlFile({
|
|
12591
|
+
path: config.filePath ?? path.join(options.dir ?? telemetryDir(options.env), `memory-${fileTimestamp(now)}-${process.pid}.jsonl`),
|
|
12592
|
+
maxBytes: config.fileMaxMb * MIB,
|
|
12593
|
+
keep: config.fileKeep,
|
|
12594
|
+
header: {
|
|
12595
|
+
telemetry: "memory",
|
|
12596
|
+
startedAt: now.toISOString(),
|
|
12597
|
+
pid: process.pid,
|
|
12598
|
+
node: process.version,
|
|
12599
|
+
argv: process.argv,
|
|
12600
|
+
config
|
|
12601
|
+
},
|
|
12602
|
+
logger: options.logger
|
|
12603
|
+
});
|
|
12604
|
+
return {
|
|
12605
|
+
path: file.path,
|
|
12606
|
+
write: (sample) => file.writeLine(sample),
|
|
12607
|
+
close: () => void 0
|
|
12608
|
+
};
|
|
12609
|
+
}
|
|
12610
|
+
//#endregion
|
|
12611
|
+
//#region src/telemetry/heap-snapshot.ts
|
|
12612
|
+
const COOLDOWN_MS = 12e4;
|
|
12613
|
+
/** Writing a snapshot needs memory close to the heap's size. */
|
|
12614
|
+
const FREE_MEMORY_FACTOR = 1.5;
|
|
12615
|
+
/**
|
|
12616
|
+
* A guarded writer of main-thread heap snapshots: one at a time, at most one
|
|
12617
|
+
* every two minutes, and refused without room for it unless forced. A snapshot
|
|
12618
|
+
* can hold document state, so it stays on the host. It blocks the event loop
|
|
12619
|
+
* for seconds to minutes; take it at 2-4 GB, not at 10 GB.
|
|
12620
|
+
*/
|
|
12621
|
+
function createHeapSnapshotWriter(options) {
|
|
12622
|
+
const now = options.now ?? (() => Date.now());
|
|
12623
|
+
const freeMemory = options.freeMemory ?? freemem;
|
|
12624
|
+
const heapUsed = options.heapUsed ?? (() => process.memoryUsage().heapUsed);
|
|
12625
|
+
const write = options.write ?? ((file) => writeHeapSnapshot(file));
|
|
12626
|
+
let writing = false;
|
|
12627
|
+
let lastAt;
|
|
12628
|
+
return (force) => {
|
|
12629
|
+
if (writing) return Promise.reject(/* @__PURE__ */ new Error("A heap snapshot is already being written"));
|
|
12630
|
+
if (lastAt !== void 0 && now() - lastAt < COOLDOWN_MS) return Promise.reject(/* @__PURE__ */ new Error("A heap snapshot was written in the last two minutes"));
|
|
12631
|
+
const needed = FREE_MEMORY_FACTOR * heapUsed();
|
|
12632
|
+
if (!force && freeMemory() < needed) return Promise.reject(/* @__PURE__ */ new Error(`Too little free memory for a heap snapshot: ${Math.round(freeMemory() / 1048576)} MB free, ${Math.round(needed / 1048576)} MB needed; force overrides this`));
|
|
12633
|
+
writing = true;
|
|
12634
|
+
try {
|
|
12635
|
+
mkdirSync(options.dir, { recursive: true });
|
|
12636
|
+
const stamp = fileTimestamp(new Date(now()));
|
|
12637
|
+
const file = path.resolve(options.dir, `heap-${stamp}-${process.pid}.heapsnapshot`);
|
|
12638
|
+
const written = write(file);
|
|
12639
|
+
lastAt = now();
|
|
12640
|
+
return Promise.resolve(written);
|
|
12641
|
+
} catch (error) {
|
|
12642
|
+
return Promise.reject(error instanceof Error ? error : new Error(String(error)));
|
|
12643
|
+
} finally {
|
|
12644
|
+
writing = false;
|
|
12645
|
+
}
|
|
12646
|
+
};
|
|
12647
|
+
}
|
|
12648
|
+
//#endregion
|
|
12649
|
+
//#region src/telemetry/node-memory-sampler.ts
|
|
12650
|
+
const LOOP_RESOLUTION_MS = 20;
|
|
12651
|
+
const NANOS_PER_MS = 1e6;
|
|
12652
|
+
function spaceBytes(name) {
|
|
12653
|
+
return getHeapSpaceStatistics().find((space) => space.space_name === name)?.space_used_size ?? 0;
|
|
12654
|
+
}
|
|
12655
|
+
/**
|
|
12656
|
+
* Reads the process's memory. `heapUsed` alone saw-tooths, so a GC observer
|
|
12657
|
+
* keeps the used heap right after each major collection, which needs no
|
|
12658
|
+
* `--expose-gc`.
|
|
12659
|
+
*/
|
|
12660
|
+
var NodeMemorySampler = class {
|
|
12661
|
+
observer;
|
|
12662
|
+
loop;
|
|
12663
|
+
postGcHeap = null;
|
|
12664
|
+
postGcAt = null;
|
|
12665
|
+
start() {
|
|
12666
|
+
this.observer = new PerformanceObserver((list) => {
|
|
12667
|
+
for (const entry of list.getEntries()) {
|
|
12668
|
+
const { detail } = entry;
|
|
12669
|
+
if (detail?.kind === constants.NODE_PERFORMANCE_GC_MAJOR) {
|
|
12670
|
+
this.postGcHeap = getHeapStatistics().used_heap_size;
|
|
12671
|
+
this.postGcAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
12672
|
+
}
|
|
12673
|
+
}
|
|
12674
|
+
});
|
|
12675
|
+
this.observer.observe({ entryTypes: ["gc"] });
|
|
12676
|
+
this.loop = monitorEventLoopDelay({ resolution: LOOP_RESOLUTION_MS });
|
|
12677
|
+
this.loop.enable();
|
|
12678
|
+
}
|
|
12679
|
+
stop() {
|
|
12680
|
+
this.observer?.disconnect();
|
|
12681
|
+
this.observer = void 0;
|
|
12682
|
+
this.loop?.disable();
|
|
12683
|
+
this.loop = void 0;
|
|
12684
|
+
}
|
|
12685
|
+
sample() {
|
|
12686
|
+
const memory = process.memoryUsage();
|
|
12687
|
+
const heap = getHeapStatistics();
|
|
12688
|
+
const loop = {
|
|
12689
|
+
p50: (this.loop?.percentile(50) ?? 0) / NANOS_PER_MS,
|
|
12690
|
+
p99: (this.loop?.percentile(99) ?? 0) / NANOS_PER_MS
|
|
12691
|
+
};
|
|
12692
|
+
this.loop?.reset();
|
|
12693
|
+
return {
|
|
12694
|
+
rss: memory.rss,
|
|
12695
|
+
maxRss: process.resourceUsage().maxRSS * 1024,
|
|
12696
|
+
heapUsed: memory.heapUsed,
|
|
12697
|
+
heapTotal: memory.heapTotal,
|
|
12698
|
+
heapLimit: heap.heap_size_limit,
|
|
12699
|
+
external: memory.external,
|
|
12700
|
+
arrayBuffers: memory.arrayBuffers,
|
|
12701
|
+
mallocedMemory: heap.malloced_memory,
|
|
12702
|
+
postGcHeap: this.postGcHeap,
|
|
12703
|
+
postGcAt: this.postGcAt,
|
|
12704
|
+
spaces: {
|
|
12705
|
+
old: spaceBytes("old_space"),
|
|
12706
|
+
lo: spaceBytes("large_object_space"),
|
|
12707
|
+
code: spaceBytes("code_space"),
|
|
12708
|
+
new: spaceBytes("new_space")
|
|
12709
|
+
},
|
|
12710
|
+
contexts: {
|
|
12711
|
+
native: heap.number_of_native_contexts,
|
|
12712
|
+
detached: heap.number_of_detached_contexts
|
|
12713
|
+
},
|
|
12714
|
+
loop,
|
|
12715
|
+
freemem: freemem()
|
|
12716
|
+
};
|
|
12717
|
+
}
|
|
12718
|
+
};
|
|
12719
|
+
//#endregion
|
|
12720
|
+
export { ADMIN_USERS, ActionCandidateInputSchema, ActionContextInputSchema, ActionInputSchema, AddRelationshipDocument, AnalyticsSubgraph, AttachmentAccessFailed, AttachmentAccessService, AttachmentAccessUnavailable, AttachmentClientProvider, AuthDecision, AuthDecisionSchema, AuthEvaluationUnsupportedError, AuthService, AuthSubgraph, AuthenticationRequiredError, AuthorizationPolicy, AuthorizedAttachmentService, AuthorizedDocumentHandle, BaseSubgraph, CORE_PACKAGE_NAME, CanonicalDocumentIdResolutionError, ChannelMetaInputSchema, ConsistencyCoordinateInputSchema, ConsistencyTokenInputSchema, CreateDocumentDocument, CreateEmptyDocumentDocument, DEFAULT_INSPECTION_THROTTLE, DEFAULT_PERMISSION_CACHE_OPTIONS, DEFAULT_PERMISSION_CACHE_TTL_MS, DEFAULT_ROOT_TYPES, DeleteDocumentDocument, DeleteDocumentsDocument, DocumentChangeType, DocumentChangeTypeSchema, DocumentChangesDocument, DocumentModelSchemaCache, DocumentOperationsFilterInputSchema, DocumentPermissionService, DocumentPermissionSnapshot, DocumentRelationshipFieldsFragmentDoc, DriveNodeFieldsFragmentDoc, DriveNodeKind, DriveNodeKindSchema, EVERYONE, EvaluateActionsDocument, ExecuteBatchDocument, ExecutionJobInputSchema, FindDocumentsDocument, ForbiddenError, GetCreateDefaultsDocument, GetCreateProtocolVersionsDocument, GetDocumentDocument, GetDocumentIncomingRelationshipEdgesDocument, GetDocumentIncomingRelationshipsDocument, GetDocumentModelsDocument, GetDocumentOperationsDocument, GetDocumentOutgoingRelationshipEdgesDocument, GetDocumentOutgoingRelationshipsDocument, GetDocumentServedDocument, GetDocumentWithOperationsDocument, GetDriveDescendantsDocument, GetDriveNodeDocument, GetDriveNodesDocument, GetJobStatusDocument, GetUndoRedoTargetsDocument, GraphQLManager, HttpDocumentModelLoader, HttpPackageLoader, HttpRouteService, ImportPackageLoader, InMemoryPackageStorage, InspectionAdminSubgraph, InspectionSubgraph, InspectionThrottle, InspectionThrottledError, InvalidNamespaceError, JobChangesDocument, JobInfoFieldsFragmentDoc, JsonlFile, MalformedStoredOperationError, MemoryWebhookStore, MoveRelationshipDocument, MutateDocumentAsyncDocument, MutateDocumentDocument, NodeEventLoopDelay, NodeMemorySampler, OperationContextInputSchema, OperationInputSchema, OperationWithContextInputSchema, OperationsFilterInputSchema, PACKAGE_ROUTE_SEGMENT, PGLITE_UTC_PARSERS, PackageManagementService, PackageManager, PackagesSubgraph, PagingInputSchema, PermissionCache, PhDocumentFieldsFragmentDoc, PollSyncEnvelopesDocument, PrivacyPermissionAdapter, PropagationMode, PropagationModeSchema, PushSyncEnvelopesDocument, READABLE_DOCUMENTS_NAMESPACE, ReactorSignerAppInputSchema, ReactorSignerInputSchema, ReactorSignerUserInputSchema, ReactorSubgraph, ReadableDocumentsProjection, RefusalNotRecordedError, RelationalWebhookStore, RemoteCursorInputSchema, RemoteFilterInputSchema, RemoveRelationshipDocument, RenameDocumentDocument, RequestLoadRecorder, SearchFilterInputSchema, SetPreferredEditorDocument, SubgraphTypeCollisionError, SyncEnvelopeInputSchema, SyncEnvelopeType, SyncEnvelopeTypeSchema, SyncRefusalInputSchema, SystemSubgraph, TouchChannelDocument, TouchChannelInputSchema, UpdateRelationshipDocument, ViewFilterInputSchema, WEBHOOK_SEGMENT, WS_AUTH_CLOSE_REASONS, WS_CLOSE_REASON_AUTHENTICATION_REQUIRED, WS_CLOSE_REASON_BEARER_REJECTED, WS_CLOSE_REASON_CREDENTIAL_REVOKED, WebhookService, applyReadableFilter, assembleSubgraphTypeDefs, assertAttachmentPolicyReadsAllowed, assertAuthRequiredForDocumentPermissions, assertCredentialVerifierForSource, assertHostMountPath, assertIndexAccessComplete, assertRequireAuthenticatedCallerAllowed, assertSkipCredentialVerificationAllowed, baseDocumentModels, buildDocumentModelSchema, buildGraphQlDocument, buildGraphQlDriveDocument, buildGraphqlOperation, buildGraphqlOperations, buildSubgraphSchemaModule, callerSubject, createAuthFetchMiddleware, createCanonicalDocumentIdResolver, createCredentialInvalidator, createGatewayAdapter, createHeapSnapshotWriter, createHttpAdapter, createInspectionResolvers, createMergedSchema, createReactorGraphQLClient, createReactorInspectionSource, createRenownCredentialVerifier, createSchema, createWsAuthHandlers, decodeExplorerUrlState, defineIndexSubgraph, definedNonNullAnySchema, documentModelSubgraphTypes, driveIdFromUrl, extractSubgraphs, extractSubgraphsFromModule, fileTimestamp, findSubgraphTypeCollisions, generateDocumentModelSchema, generatedTypesOf, getAuthContext, getDbClient, getDocumentModelSchemaName, getDocumentModelSubgraphName, getDocumentModelTypeDefs, getExplorerPrefix, getGeneratedDocumentModelTypes, getGitHash, getGitUrl, getSdk, getUniqueDocumentModels, getUniqueUpgradeManifests, getVersion, hasOperationSchemas, initAnalyticsStoreSql, initializeAndStartAPI, inspectionAdminTypeDefs, inspectionTypeDefs, isCountedRequest, isDefinedNonNullAny, isDocumentListed, isExpectedLoaderMiss, isListedAdmin, isPostgresConnectionString, isSubgraphClass, memoryFileSink, namespacePath, namespaceSegments, newWebhookToken, parseDriveUrl, parseWebhookBody, piecesBaseUrl, reactorApiConfigFromEnv, readableDocumentsSubquery, redactHeaders, renderGraphqlPlayground, reportFailure, reservedTypeNames, reservedTypeNamesTaken, resolveCredentialCacheTtlMs, resolvePackageName, resolvePermissionCacheTtlMs, resolveRenownConfig, runDetached, setAuthContext, telemetryDir, typeDefinitionNames, verifyWebhook };
|
|
12416
12721
|
|
|
12417
12722
|
//# sourceMappingURL=index.mjs.map
|
|
12418
|
-
//# debugId=
|
|
12723
|
+
//# debugId=e0118eab-dd2a-5bf7-a67c-c78a1da0b48f
|