target-supabase-sdk 0.2.4 → 0.2.6
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/browser.d.ts +2 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -1
- package/dist/chunks/{enable-log-persist-B8rg_wXG.js → enable-log-persist-BL2FaGQp.js} +6 -3
- package/dist/chunks/enable-log-persist-BL2FaGQp.js.map +1 -0
- package/dist/chunks/{word.interface-B_fbVFOW.js → task-queue-D_7kYBx3.js} +196 -7
- package/dist/chunks/task-queue-D_7kYBx3.js.map +1 -0
- package/dist/node/fs/json-state-store.d.ts.map +1 -1
- package/dist/node/fs/runtime-state-path.d.ts +17 -0
- package/dist/node/fs/runtime-state-path.d.ts.map +1 -0
- package/dist/node/fs/sharded-json-state-store.d.ts +19 -0
- package/dist/node/fs/sharded-json-state-store.d.ts.map +1 -0
- package/dist/node/runtime-state/create-service-runtime-state-store.d.ts +6 -2
- package/dist/node/runtime-state/create-service-runtime-state-store.d.ts.map +1 -1
- package/dist/node.js +164 -21
- package/dist/node.js.map +1 -1
- package/dist/preload.js +1 -1
- package/dist/service/config.api.d.ts.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/registry.service.d.ts +42 -0
- package/dist/service/registry.service.d.ts.map +1 -1
- package/package.json +1 -3
- package/src/browser.ts +7 -1
- package/src/node/fs/json-state-store.ts +5 -2
- package/src/node/fs/runtime-state-path.ts +35 -0
- package/src/node/fs/sharded-json-state-store.ts +157 -0
- package/src/node/runtime-state/create-service-runtime-state-store.ts +17 -17
- package/src/service/config.api.ts +1 -0
- package/src/service/index.ts +7 -0
- package/src/service/registry.service.ts +273 -0
- package/dist/chunks/enable-log-persist-B8rg_wXG.js.map +0 -1
- package/dist/chunks/word.interface-B_fbVFOW.js.map +0 -1
- package/dist/word/word.api.d.ts +0 -15
- package/dist/word/word.api.d.ts.map +0 -1
- package/dist/word/word.interface.d.ts +0 -20
- package/dist/word/word.interface.d.ts.map +0 -1
- package/src/word/word.api.ts +0 -41
- package/src/word/word.interface.ts +0 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-state-store.d.ts","sourceRoot":"","sources":["../../../src/node/fs/json-state-store.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG;KACrF,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK;IAC5E,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,+BAA+B,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK;IACzF,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,sEAAsE;IACtE,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;IAClB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;CAC1B;AAoCD,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK,EACjF,OAAO,EAAE,+BAA+B,CAAC,CAAC,EAAE,EAAE,CAAC,GAChD,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"json-state-store.d.ts","sourceRoot":"","sources":["../../../src/node/fs/json-state-store.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG;KACrF,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK;IAC5E,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,+BAA+B,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK;IACzF,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,sEAAsE;IACtE,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC;IAClB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;CAC1B;AAoCD,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,GAAG,KAAK,EACjF,OAAO,EAAE,+BAA+B,CAAC,CAAC,EAAE,EAAE,CAAC,GAChD,kBAAkB,CAAC,CAAC,EAAE,EAAE,CAAC,CAwC3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ResolvedRuntimeStatePaths {
|
|
2
|
+
/** Directory holding one JSON file per top-level slice. */
|
|
3
|
+
stateDir: string;
|
|
4
|
+
/** Legacy monolithic `state.json` — migrated on read/reset when present. */
|
|
5
|
+
legacyFilePath: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolve sharded runtime state layout from {@link CreateServiceRuntimeStateStoreOptions.filePath}.
|
|
9
|
+
*
|
|
10
|
+
* | `filePath` | Shard dir | Legacy |
|
|
11
|
+
* |-------------------------|-----------------------------------|---------------|
|
|
12
|
+
* | `.../state.json` | `.../runtime-state/` | `state.json` |
|
|
13
|
+
* | `.../runtime-state/` | same directory | none |
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveRuntimeStatePaths(filePath: string): ResolvedRuntimeStatePaths;
|
|
16
|
+
export declare function runtimeStateShardPath(stateDir: string, sliceKey: string): string;
|
|
17
|
+
//# sourceMappingURL=runtime-state-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-state-path.d.ts","sourceRoot":"","sources":["../../../src/node/fs/runtime-state-path.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,yBAAyB;IACtC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,yBAAyB,CAWpF;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEhF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type JsonStatePatch } from "./json-state-store";
|
|
2
|
+
export interface CreateShardedJsonFileStateStoreOptions<T extends object, NK extends keyof T> {
|
|
3
|
+
/** Monolithic legacy path or shard directory root (see {@link resolveRuntimeStatePaths}). */
|
|
4
|
+
filePath: string;
|
|
5
|
+
defaultState: T;
|
|
6
|
+
/** Top-level keys persisted as separate shard files. */
|
|
7
|
+
nestedKeys: NK[];
|
|
8
|
+
updatedAtKey?: keyof T;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* JSON runtime state with **one file per top-level slice** (log-persist registry pattern).
|
|
12
|
+
* Eliminates cross-slice lost updates when guard/scheduler/worker write concurrently.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createShardedJsonFileStateStore<T extends object, NK extends keyof T>(options: CreateShardedJsonFileStateStoreOptions<T, NK>): {
|
|
15
|
+
read(): Promise<T>;
|
|
16
|
+
write(patch: JsonStatePatch<T, NK>): Promise<T>;
|
|
17
|
+
reset(): Promise<T>;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=sharded-json-state-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sharded-json-state-store.d.ts","sourceRoot":"","sources":["../../../src/node/fs/sharded-json-state-store.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGnF,MAAM,WAAW,sCAAsC,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC;IACxF,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,wDAAwD;IACxD,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;CAC1B;AAcD;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,SAAS,MAAM,CAAC,EAChF,OAAO,EAAE,sCAAsC,CAAC,CAAC,EAAE,EAAE,CAAC,GACvD;IACC,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CACvB,CAyHA"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JsonStatePatch } from "../fs/json-state-store";
|
|
2
2
|
import type { DefaultExtraRuntimeSlices, ServiceRuntimeExtraSlicePatch, ServiceRuntimeNestedKeys, ServiceRuntimeState } from "./service-runtime-state.types";
|
|
3
3
|
export interface CreateServiceRuntimeStateStoreOptions<TExtraSlices extends Record<string, object> = DefaultExtraRuntimeSlices> {
|
|
4
|
+
/**
|
|
5
|
+
* Monolithic legacy path (`…/state.json`) or shard directory (`…/runtime-state/`).
|
|
6
|
+
* Legacy files migrate automatically to `dirname/state.json → runtime-state/*.json`.
|
|
7
|
+
*/
|
|
4
8
|
filePath: string;
|
|
5
9
|
/** Default values for service-specific top-level nested slices. */
|
|
6
10
|
extraDefaults?: TExtraSlices;
|
|
@@ -18,6 +22,6 @@ export interface ServiceRuntimeStateStore<TExtraSlices extends Record<string, ob
|
|
|
18
22
|
resetRuntimeStateForStartup(): Promise<ServiceRuntimeState<TExtraSlices>>;
|
|
19
23
|
finishRunnerTick(options: FinishRunnerTickOptions<TExtraSlices>): Promise<void>;
|
|
20
24
|
}
|
|
21
|
-
/** JSON
|
|
25
|
+
/** Sharded JSON runtime state (L3 blueprint) — one file per slice under `runtime-state/`. */
|
|
22
26
|
export declare function createServiceRuntimeStateStore<TExtraSlices extends Record<string, object> = DefaultExtraRuntimeSlices>(options: CreateServiceRuntimeStateStoreOptions<TExtraSlices>): ServiceRuntimeStateStore<TExtraSlices>;
|
|
23
27
|
//# sourceMappingURL=create-service-runtime-state-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-runtime-state-store.d.ts","sourceRoot":"","sources":["../../../src/node/runtime-state/create-service-runtime-state-store.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-service-runtime-state-store.d.ts","sourceRoot":"","sources":["../../../src/node/runtime-state/create-service-runtime-state-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EACR,yBAAyB,EAIzB,6BAA6B,EAC7B,wBAAwB,EACxB,mBAAmB,EAEtB,MAAM,+BAA+B,CAAC;AAIvC,MAAM,WAAW,qCAAqC,CAClD,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,yBAAyB;IAEvE;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,aAAa,CAAC,EAAE,YAAY,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,yBAAyB;IAC5G,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,KAAK,CAAC,EAAE,6BAA6B,CAAC,YAAY,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,wBAAwB,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,yBAAyB;IAC7G,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/D,iBAAiB,CACb,KAAK,EAAE,cAAc,CAAC,mBAAmB,CAAC,YAAY,CAAC,EAAE,wBAAwB,CAAC,YAAY,CAAC,CAAC,GACjG,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9C,2BAA2B,IAAI,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC;IAC1E,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AA0CD,6FAA6F;AAC7F,wBAAgB,8BAA8B,CAAC,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,yBAAyB,EAClH,OAAO,EAAE,qCAAqC,CAAC,YAAY,CAAC,GAC7D,wBAAwB,CAAC,YAAY,CAAC,CAoCxC"}
|
package/dist/node.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { M as MAX_POLL_TARGET_LIST_SIZE, G as validateWithSchema, f as createLogger, w as pollTargetList, i as generateResponse, g as createTarget, D as supabase, u as logManager, I as createScope, c as LogLevel, J as patchScope, A as scanTargetList, K as withModule, j as getPossibleTarget, r as isOptimisticLockResponse, E as updateTargetDetails } from './chunks/list.api-Ab9v8yOg.js';
|
|
3
3
|
export { B as BaseValidator, C as CREATE_TARGET_ALREADY_EXISTS_MESSAGE, a as CategoryList, L as LOG_BATCH_LOADER_KEY, b as LOG_PERSIST_LOADER_KEY, d as MAX_TARGET_LIST_PAGE_SIZE, O as OPTIMISTIC_LOCK_ERROR_CODE, e as OPTIMISTIC_LOCK_FAILED_MESSAGE, P as PostListValidator, S as StatusCode, h as deleteTarget, k as getTarget, l as getTargetList, m as getTargetTotalCount, n as handleSupabaseError, o as isCreateTargetAlreadyExistsError, p as isDevEnvironment, q as isOptimisticLockError, s as logDev, t as logDevGroup, v as patchTarget, x as postListCreate, y as postLogListCreate, z as postTarget, F as validateWith } from './chunks/list.api-Ab9v8yOg.js';
|
|
4
|
-
import { l as loadEnvFiles, b as readEnv, c as requireEnv, d as createJsonFileStateStore, a as logPersistEnabledFromEnv, e as disableLogPersist, g as getLogPersistStats, s as snapshotLogPersistReady, w as waitForLogPersistReady, f as ensureLogPersistFromEnv } from './chunks/enable-log-persist-
|
|
5
|
-
export { C as CLI_PROD_FLAG, S as SERVICE_ENV_PROFILE_ENV_KEY, h as SERVICE_ENV_PROFILE_PROD, i as enableLogPersist, j as envBool, k as envInt, m as envMs, n as envNumber, o as envPort, q as envProfileFromProcess, t as parseEnvFile, u as parseEnvLine, p as pinEnvProfileFromArgv, x as pollUntil, y as resolveDefaultEnvFiles, z as resolveLogPersistRegistryPath, r as resolveProjectRootByPackageName, A as resolveProjectRootFromModule, v as validateLogPersistPreloadEnv } from './chunks/enable-log-persist-
|
|
6
|
-
import { access, stat, readFile, mkdir, writeFile, readdir } from 'node:fs/promises';
|
|
7
|
-
import { resolve,
|
|
8
|
-
import {
|
|
9
|
-
export { A as ApiMethod, C as CategoryConfig, a as CategoryExtraction, b as CategoryIdea, c as CategoryLink, e as CategoryParcel, g as CategoryService, h as CategoryTask,
|
|
4
|
+
import { l as loadEnvFiles, b as readEnv, c as requireEnv, d as createJsonFileStateStore, a as logPersistEnabledFromEnv, e as disableLogPersist, g as getLogPersistStats, s as snapshotLogPersistReady, w as waitForLogPersistReady, f as ensureLogPersistFromEnv } from './chunks/enable-log-persist-BL2FaGQp.js';
|
|
5
|
+
export { C as CLI_PROD_FLAG, S as SERVICE_ENV_PROFILE_ENV_KEY, h as SERVICE_ENV_PROFILE_PROD, i as enableLogPersist, j as envBool, k as envInt, m as envMs, n as envNumber, o as envPort, q as envProfileFromProcess, t as parseEnvFile, u as parseEnvLine, p as pinEnvProfileFromArgv, x as pollUntil, y as resolveDefaultEnvFiles, z as resolveLogPersistRegistryPath, r as resolveProjectRootByPackageName, A as resolveProjectRootFromModule, v as validateLogPersistPreloadEnv } from './chunks/enable-log-persist-BL2FaGQp.js';
|
|
6
|
+
import { access, stat, readFile, mkdir, unlink, writeFile, readdir } from 'node:fs/promises';
|
|
7
|
+
import { resolve, join, dirname, isAbsolute } from 'node:path';
|
|
8
|
+
import { bd as sha256Hex, bi as getErrorMessage, aI as postRegisterNode, am as patchChangeNodeStatus, N as NodeStatus, ax as patchStopNode, au as patchNodeHeartBeat, E as EMPTY_REGISTRY_SLOT_RUNTIME_STATE, b3 as runRegistrySlotGuardCheck, aW as registrySlotRuntimePatchFromGuardResult, d as CategoryNode, L as evaluateBusyNodeLiveness, aw as patchServiceRuntime, k as ServiceRegistryError, v as claimServiceRegistrySlot, f as CategoryRepo, R as ResultCode, bj as LOG_TOPIC_TASK, m as TASK_REPO_USAGE, a4 as getScanRemoteRepoValues, aq as patchClaimTask, bk as CRITICAL_UNKNOWN_TASK_TRACE_ID, ao as patchChangeTaskStatus, o as TaskStatusAction, bl as toError, aQ as postTaskSchema, bm as createTaskRow, n as TaskStatus } from './chunks/task-queue-D_7kYBx3.js';
|
|
9
|
+
export { A as ApiMethod, C as CategoryConfig, a as CategoryExtraction, b as CategoryIdea, c as CategoryLink, e as CategoryParcel, g as CategoryService, h as CategoryTask, D as DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS, M as Market, P as POST_TASK_DEFAULT_MAX_ATTEMPTS, i as ParcelManager, j as PostLinkValidator, S as ServiceLifecycleStatus, l as ServiceSlotStatus, T as TARGET_SYSTEM_REGISTRY_KEY, p as apiDetailsSchema, q as appendSystemRegistrySlots, r as assertRegistrySlotAvailable, s as assertRegistrySlotOwner, t as buildEmptyServiceSlots, u as buildSystemRegistryConfigDetails, w as classifyNetworkError, x as countTasksByType, y as createActiveServiceLifecycle, z as createClaimedRegistrySlotRuntimeState, B as createStorageProviderRegistry, F as createUploadTracker, G as decodeLogBatch, H as decodeLogBatchList, I as defaultL3ServiceDetails, J as deleteParcel, K as deleteParcelSchema, O as fetchBinaryWithRetry, Q as fetchWithRetry, U as fieldDefinitionSchema, V as flattenLogBatch, W as flattenLogBatches, X as formatNetworkError, Y as getApi, Z as getApiSchema, _ as getConfig, $ as getConfigSchema, a0 as getExtraction, a1 as getExtractionSchema, a2 as getParcel, a3 as getParcelSchema, a5 as getScanRemoteRepoValuesSchema, a6 as getService, a7 as getServiceSchema, a8 as getTargetSystemRegistry, a9 as getValueAtPath, aa as installChunkFetchRegistry, ab as isHttpUrl, ac as isLocalFilesystemPath, ad as isLogBatchList, ae as isLogEntry, af as isOpaqueChunkUrl, ag as isRetryableHttpStatus, ah as parcelDetailsSchema, ai as parseLogBatchMeta, aj as parseProviderPrefixedUrl, ak as parseServiceSlot, al as parseServiceSlots, an as patchChangeNodeStatusSchema, ap as patchChangeTaskStatusSchema, ar as patchClaimTaskSchema, as as patchExtractionObjects, at as patchExtractionObjectsSchema, av as patchNodeHeartBeatSchema, ay as patchStopNodeSchema, az as patchTaskProgress, aA as patchTaskProgressSchema, aB as postApi, aC as postApiSchema, aD as postExtraction, aE as postExtractionSchema, aF as postLinkCreate, aG as postParcel, aH as postParcelSchema, aJ as postRegisterNodeSchema, aK as postService, aL as postServiceInstance, aM as postServiceSchema, aN as postSystemRegistryConfig, aO as postSystemRegistryConfigSchema, aP as postTask, aR as postTaskWithRetry, aS as publishParcel, aT as registerProviderChunkResolver, aU as registerService, aV as registerServiceAtStartup, aX as releaseSystemRegistrySlots, aY as requestHasBody, aZ as resetSystemRegistryConfig, a_ as resetSystemRegistryConfigSchema, a$ as resolveActiveRegistryServiceId, b0 as resolveFetchUrl, b1 as restoreParcel, b2 as restoreParcelById, b4 as sanitizeFileName, b5 as sanitizeParcelFileName, b6 as scanExtractionList, b7 as scanExtractionListSchema, b8 as schemaDefinitionSchema, b9 as serviceDetailsSchema, ba as serviceLifecycleSchema, bb as serviceNodeSnapshotSchema, bc as serviceRuntimeSchema, be as summarizeTaskQueue, bf as systemRegistrySeedSlotSchema, bg as unregisterService, bh as unregisterServiceAtShutdown } from './chunks/task-queue-D_7kYBx3.js';
|
|
10
10
|
import { spawn } from 'node:child_process';
|
|
11
11
|
import { createHash } from 'node:crypto';
|
|
12
12
|
import { tmpdir } from 'node:os';
|
|
@@ -892,6 +892,153 @@ async function waitForServiceReady(gate, options) {
|
|
|
892
892
|
throw new Error(message);
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
+
const RUNTIME_STATE_SHARD_DIR = "runtime-state";
|
|
896
|
+
/**
|
|
897
|
+
* Resolve sharded runtime state layout from {@link CreateServiceRuntimeStateStoreOptions.filePath}.
|
|
898
|
+
*
|
|
899
|
+
* | `filePath` | Shard dir | Legacy |
|
|
900
|
+
* |-------------------------|-----------------------------------|---------------|
|
|
901
|
+
* | `.../state.json` | `.../runtime-state/` | `state.json` |
|
|
902
|
+
* | `.../runtime-state/` | same directory | none |
|
|
903
|
+
*/
|
|
904
|
+
function resolveRuntimeStatePaths(filePath) {
|
|
905
|
+
if (filePath.endsWith(".json")) {
|
|
906
|
+
return {
|
|
907
|
+
stateDir: join(dirname(filePath), RUNTIME_STATE_SHARD_DIR),
|
|
908
|
+
legacyFilePath: filePath,
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
return {
|
|
912
|
+
stateDir: filePath,
|
|
913
|
+
legacyFilePath: null,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
function runtimeStateShardPath(stateDir, sliceKey) {
|
|
917
|
+
return join(stateDir, `${sliceKey}.json`);
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
function isPlainObject(value) {
|
|
921
|
+
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
922
|
+
}
|
|
923
|
+
function mergeSlice(defaults, key, patchValue) {
|
|
924
|
+
const base = defaults[key];
|
|
925
|
+
if (isPlainObject(base) && isPlainObject(patchValue)) {
|
|
926
|
+
return { ...base, ...patchValue };
|
|
927
|
+
}
|
|
928
|
+
return patchValue;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* JSON runtime state with **one file per top-level slice** (log-persist registry pattern).
|
|
932
|
+
* Eliminates cross-slice lost updates when guard/scheduler/worker write concurrently.
|
|
933
|
+
*/
|
|
934
|
+
function createShardedJsonFileStateStore(options) {
|
|
935
|
+
const { defaultState, nestedKeys, updatedAtKey } = options;
|
|
936
|
+
const { stateDir, legacyFilePath } = resolveRuntimeStatePaths(options.filePath);
|
|
937
|
+
const shardStores = new Map();
|
|
938
|
+
function shardStore(sliceKey) {
|
|
939
|
+
const key = String(sliceKey);
|
|
940
|
+
let store = shardStores.get(key);
|
|
941
|
+
if (store == null) {
|
|
942
|
+
store = createJsonFileStateStore({
|
|
943
|
+
filePath: runtimeStateShardPath(stateDir, key),
|
|
944
|
+
defaultState: defaultState[sliceKey],
|
|
945
|
+
});
|
|
946
|
+
shardStores.set(key, store);
|
|
947
|
+
}
|
|
948
|
+
return store;
|
|
949
|
+
}
|
|
950
|
+
async function readUpdatedAtFromShardMtimes() {
|
|
951
|
+
let maxMtimeMs = 0;
|
|
952
|
+
for (const sliceKey of nestedKeys) {
|
|
953
|
+
try {
|
|
954
|
+
const shardStat = await stat(runtimeStateShardPath(stateDir, String(sliceKey)));
|
|
955
|
+
maxMtimeMs = Math.max(maxMtimeMs, shardStat.mtimeMs);
|
|
956
|
+
}
|
|
957
|
+
catch (error) {
|
|
958
|
+
if (error.code !== "ENOENT") {
|
|
959
|
+
throw error;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
if (maxMtimeMs <= 0) {
|
|
964
|
+
return defaultState[updatedAtKey];
|
|
965
|
+
}
|
|
966
|
+
return new Date(maxMtimeMs).toISOString();
|
|
967
|
+
}
|
|
968
|
+
async function migrateLegacyMonolithicIfPresent() {
|
|
969
|
+
if (legacyFilePath == null) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
let raw;
|
|
973
|
+
try {
|
|
974
|
+
raw = await readFile(legacyFilePath, "utf8");
|
|
975
|
+
}
|
|
976
|
+
catch (error) {
|
|
977
|
+
if (error.code === "ENOENT") {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
throw error;
|
|
981
|
+
}
|
|
982
|
+
let parsed;
|
|
983
|
+
try {
|
|
984
|
+
parsed = JSON.parse(raw);
|
|
985
|
+
}
|
|
986
|
+
catch {
|
|
987
|
+
await unlink(legacyFilePath).catch(() => undefined);
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
await mkdir(stateDir, { recursive: true });
|
|
991
|
+
for (const sliceKey of nestedKeys) {
|
|
992
|
+
const slice = parsed[sliceKey];
|
|
993
|
+
if (slice != null) {
|
|
994
|
+
await shardStore(sliceKey).write(slice);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
await unlink(legacyFilePath).catch(() => undefined);
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
async read() {
|
|
1001
|
+
await mkdir(stateDir, { recursive: true });
|
|
1002
|
+
await migrateLegacyMonolithicIfPresent();
|
|
1003
|
+
const merged = { ...defaultState };
|
|
1004
|
+
for (const sliceKey of nestedKeys) {
|
|
1005
|
+
merged[sliceKey] = (await shardStore(sliceKey).read());
|
|
1006
|
+
}
|
|
1007
|
+
{
|
|
1008
|
+
merged[updatedAtKey] = (await readUpdatedAtFromShardMtimes());
|
|
1009
|
+
}
|
|
1010
|
+
return merged;
|
|
1011
|
+
},
|
|
1012
|
+
async write(patch) {
|
|
1013
|
+
await mkdir(stateDir, { recursive: true });
|
|
1014
|
+
await migrateLegacyMonolithicIfPresent();
|
|
1015
|
+
for (const sliceKey of nestedKeys) {
|
|
1016
|
+
const patchSlice = patch[sliceKey];
|
|
1017
|
+
if (patchSlice == null) {
|
|
1018
|
+
continue;
|
|
1019
|
+
}
|
|
1020
|
+
const current = await shardStore(sliceKey).read();
|
|
1021
|
+
const nextSlice = mergeSlice(defaultState, sliceKey, {
|
|
1022
|
+
...current,
|
|
1023
|
+
...patchSlice,
|
|
1024
|
+
});
|
|
1025
|
+
await shardStore(sliceKey).write(nextSlice);
|
|
1026
|
+
}
|
|
1027
|
+
return this.read();
|
|
1028
|
+
},
|
|
1029
|
+
async reset() {
|
|
1030
|
+
await mkdir(stateDir, { recursive: true });
|
|
1031
|
+
for (const sliceKey of nestedKeys) {
|
|
1032
|
+
await shardStore(sliceKey).reset();
|
|
1033
|
+
}
|
|
1034
|
+
if (legacyFilePath != null) {
|
|
1035
|
+
await unlink(legacyFilePath).catch(() => undefined);
|
|
1036
|
+
}
|
|
1037
|
+
return this.read();
|
|
1038
|
+
},
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
|
|
895
1042
|
const EPOCH_ISO = new Date(0).toISOString();
|
|
896
1043
|
function createDefaultServiceRuntimeState(options) {
|
|
897
1044
|
const readiness = {
|
|
@@ -929,7 +1076,7 @@ function createDefaultServiceRuntimeState(options) {
|
|
|
929
1076
|
...(options.extraDefaults ?? {}),
|
|
930
1077
|
};
|
|
931
1078
|
}
|
|
932
|
-
/** JSON
|
|
1079
|
+
/** Sharded JSON runtime state (L3 blueprint) — one file per slice under `runtime-state/`. */
|
|
933
1080
|
function createServiceRuntimeStateStore(options) {
|
|
934
1081
|
const defaultState = createDefaultServiceRuntimeState(options);
|
|
935
1082
|
const nestedKeys = [
|
|
@@ -940,22 +1087,18 @@ function createServiceRuntimeStateStore(options) {
|
|
|
940
1087
|
"registry",
|
|
941
1088
|
...Object.keys(options.extraDefaults ?? {}),
|
|
942
1089
|
];
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
updatedAtKey: "updatedAt",
|
|
950
|
-
});
|
|
951
|
-
return store;
|
|
952
|
-
}
|
|
1090
|
+
const store = createShardedJsonFileStateStore({
|
|
1091
|
+
filePath: options.filePath,
|
|
1092
|
+
defaultState,
|
|
1093
|
+
nestedKeys,
|
|
1094
|
+
updatedAtKey: "updatedAt",
|
|
1095
|
+
});
|
|
953
1096
|
return {
|
|
954
|
-
readRuntimeState: () =>
|
|
955
|
-
writeRuntimeState: (patch) =>
|
|
956
|
-
resetRuntimeStateForStartup: () =>
|
|
1097
|
+
readRuntimeState: () => store.read(),
|
|
1098
|
+
writeRuntimeState: (patch) => store.write(patch),
|
|
1099
|
+
resetRuntimeStateForStartup: () => store.reset(),
|
|
957
1100
|
finishRunnerTick: async ({ nowMs, lastFired, postedCount, extra }) => {
|
|
958
|
-
await
|
|
1101
|
+
await store.write({
|
|
959
1102
|
scheduler: {
|
|
960
1103
|
lastTickAt: new Date(nowMs).toISOString(),
|
|
961
1104
|
lastFired,
|