@sekiban/dcb-runtime 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +86 -0
- package/README.md +13 -0
- package/dist/allocator/AllocatorDurableObject.d.ts +36 -0
- package/dist/allocator/AllocatorDurableObject.js +658 -0
- package/dist/allocator/IssuanceLedger.d.ts +188 -0
- package/dist/allocator/IssuanceLedger.js +608 -0
- package/dist/allocator/IssuanceReconciler.d.ts +41 -0
- package/dist/allocator/IssuanceReconciler.js +191 -0
- package/dist/allocator/OrderClock.d.ts +41 -0
- package/dist/allocator/OrderClock.js +92 -0
- package/dist/allocator/SortableUniqueId.d.ts +46 -0
- package/dist/allocator/SortableUniqueId.js +156 -0
- package/dist/allocator/types.d.ts +52 -0
- package/dist/allocator/types.js +1 -0
- package/dist/bootstrap/BootstrapCoordinatorDurableObject.d.ts +28 -0
- package/dist/bootstrap/BootstrapCoordinatorDurableObject.js +357 -0
- package/dist/bootstrap/BootstrapStoreAdapter.d.ts +51 -0
- package/dist/bootstrap/BootstrapStoreAdapter.js +162 -0
- package/dist/bootstrap/OperatorBootstrap.d.ts +20 -0
- package/dist/bootstrap/OperatorBootstrap.js +104 -0
- package/dist/bootstrap/manifest.d.ts +9 -0
- package/dist/bootstrap/manifest.js +115 -0
- package/dist/bootstrap/types.d.ts +75 -0
- package/dist/bootstrap/types.js +1 -0
- package/dist/cli/OperatorRepairCli.d.ts +11 -0
- package/dist/cli/OperatorRepairCli.js +108 -0
- package/dist/cloudflare.d.ts +164 -0
- package/dist/cloudflare.js +19487 -0
- package/dist/commit/CommitWorker.d.ts +101 -0
- package/dist/commit/CommitWorker.js +921 -0
- package/dist/commit/types.d.ts +25 -0
- package/dist/commit/types.js +13 -0
- package/dist/completeness/GlobalCompletenessReconciler.d.ts +77 -0
- package/dist/completeness/GlobalCompletenessReconciler.js +572 -0
- package/dist/completeness/types.d.ts +85 -0
- package/dist/completeness/types.js +6 -0
- package/dist/composition.d.ts +123 -0
- package/dist/composition.js +237 -0
- package/dist/cosmos.d.ts +11 -0
- package/dist/cosmos.js +1411 -0
- package/dist/d1-mv.d.ts +8 -0
- package/dist/d1-mv.js +2001 -0
- package/dist/d1.d.ts +16 -0
- package/dist/d1.js +3418 -0
- package/dist/diagnostics/G60DurableHop.d.ts +99 -0
- package/dist/diagnostics/G60DurableHop.js +248 -0
- package/dist/diagnostics/G65Admission.d.ts +23 -0
- package/dist/diagnostics/G65Admission.js +43 -0
- package/dist/diagnostics/G65DirectRing.d.ts +33 -0
- package/dist/diagnostics/G65DirectRing.js +85 -0
- package/dist/diagnostics/G69AdmissionAttempt.d.ts +43 -0
- package/dist/diagnostics/G69AdmissionAttempt.js +22 -0
- package/dist/downstream/DeliveryCore.d.ts +127 -0
- package/dist/downstream/DeliveryCore.js +304 -0
- package/dist/downstream/Doorbell.d.ts +43 -0
- package/dist/downstream/Doorbell.js +137 -0
- package/dist/downstream/DownstreamAdapter.d.ts +52 -0
- package/dist/downstream/DownstreamAdapter.js +299 -0
- package/dist/downstream/ExclusionLookup.d.ts +36 -0
- package/dist/downstream/ExclusionLookup.js +50 -0
- package/dist/downstream/InconsistencyDetector.d.ts +27 -0
- package/dist/downstream/InconsistencyDetector.js +82 -0
- package/dist/downstream/OutboxDrain.d.ts +35 -0
- package/dist/downstream/OutboxDrain.js +126 -0
- package/dist/downstream/types.d.ts +77 -0
- package/dist/downstream/types.js +64 -0
- package/dist/eventIdentity.d.ts +30 -0
- package/dist/eventIdentity.js +49 -0
- package/dist/eventRecord.d.ts +26 -0
- package/dist/eventRecord.js +53 -0
- package/dist/g42-probe.d.ts +9 -0
- package/dist/g42-probe.js +9 -0
- package/dist/http/SerializedQueryWorker.d.ts +58 -0
- package/dist/http/SerializedQueryWorker.js +497 -0
- package/dist/http/commitResponse.d.ts +46 -0
- package/dist/http/commitResponse.js +80 -0
- package/dist/http/testServiceId.d.ts +17 -0
- package/dist/http/testServiceId.js +14 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +19926 -0
- package/dist/journal/JournalDurableObject.d.ts +30 -0
- package/dist/journal/JournalDurableObject.js +481 -0
- package/dist/journal/JournalFirstTouchProbe.d.ts +190 -0
- package/dist/journal/JournalFirstTouchProbe.js +375 -0
- package/dist/journal/types.d.ts +116 -0
- package/dist/journal/types.js +52 -0
- package/dist/mv/MaterializedViewCatchUp.d.ts +60 -0
- package/dist/mv/MaterializedViewCatchUp.js +353 -0
- package/dist/mv/MaterializedViewRuntime.d.ts +80 -0
- package/dist/mv/MaterializedViewRuntime.js +328 -0
- package/dist/mv/MaterializedViewStore.d.ts +257 -0
- package/dist/mv/MaterializedViewStore.js +875 -0
- package/dist/mv/UnsafeWindowMaterializedView.d.ts +112 -0
- package/dist/mv/UnsafeWindowMaterializedView.js +495 -0
- package/dist/mv/index.d.ts +8 -0
- package/dist/mv/index.js +2357 -0
- package/dist/projection/LiveProjectionWorker.d.ts +86 -0
- package/dist/projection/LiveProjectionWorker.js +240 -0
- package/dist/projection/ProjectionRuntime.d.ts +113 -0
- package/dist/projection/ProjectionRuntime.js +346 -0
- package/dist/projection/ProjectorRegistry.d.ts +51 -0
- package/dist/projection/ProjectorRegistry.js +116 -0
- package/dist/query/ProjectionQueryStore.d.ts +102 -0
- package/dist/query/ProjectionQueryStore.js +185 -0
- package/dist/query/QueryRegistry.d.ts +22 -0
- package/dist/query/QueryRegistry.js +36 -0
- package/dist/read/SerializedReadWorker.d.ts +36 -0
- package/dist/read/SerializedReadWorker.js +225 -0
- package/dist/repair/RepairWorker.d.ts +72 -0
- package/dist/repair/RepairWorker.js +461 -0
- package/dist/safeWindow.d.ts +20 -0
- package/dist/safeWindow.js +36 -0
- package/dist/scope/ControlRouteScope.d.ts +22 -0
- package/dist/scope/ControlRouteScope.js +36 -0
- package/dist/scope/ScopeName.d.ts +34 -0
- package/dist/scope/ScopeName.js +67 -0
- package/dist/service/ServiceIdentityProvider.d.ts +35 -0
- package/dist/service/ServiceIdentityProvider.js +56 -0
- package/dist/store/CosmosEventStore.d.ts +126 -0
- package/dist/store/CosmosEventStore.js +950 -0
- package/dist/store/D1EventStore.d.ts +111 -0
- package/dist/store/D1EventStore.js +1111 -0
- package/dist/store/PostgresEventStore.d.ts +35 -0
- package/dist/store/PostgresEventStore.js +811 -0
- package/dist/store/provider.d.ts +25 -0
- package/dist/store/provider.js +32 -0
- package/dist/store/types.d.ts +205 -0
- package/dist/store/types.js +18 -0
- package/dist/tag/EventDigest.d.ts +40 -0
- package/dist/tag/EventDigest.js +158 -0
- package/dist/tag/TagDurableObject.d.ts +286 -0
- package/dist/tag/TagDurableObject.js +4071 -0
- package/dist/tag/TagSqlMeasurement.d.ts +26 -0
- package/dist/tag/TagSqlMeasurement.js +44 -0
- package/dist/tag/TagSqlSchema.d.ts +29 -0
- package/dist/tag/TagSqlSchema.js +211 -0
- package/dist/tag/types.d.ts +173 -0
- package/dist/tag/types.js +3 -0
- package/dist/tagstate/TagStateDurableObject.d.ts +57 -0
- package/dist/tagstate/TagStateDurableObject.js +499 -0
- package/dist/trace/AttributionRatio.d.ts +12 -0
- package/dist/trace/AttributionRatio.js +68 -0
- package/dist/trace/CloudflareTracing.d.ts +7 -0
- package/dist/trace/CloudflareTracing.js +9 -0
- package/dist/trace/CommitTrace.d.ts +405 -0
- package/dist/trace/CommitTrace.js +1008 -0
- package/dist/trace/CommitTraceConsoleSink.d.ts +68 -0
- package/dist/trace/CommitTraceConsoleSink.js +114 -0
- package/dist/trace/CommitTraceVerifier.d.ts +22 -0
- package/dist/trace/CommitTraceVerifier.js +295 -0
- package/dist/trace/ObservationStream.d.ts +118 -0
- package/dist/trace/ObservationStream.js +148 -0
- package/package.json +71 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one durable-object physical-name grammar used by the runtime.
|
|
3
|
+
*
|
|
4
|
+
* A scope name is deliberately not an application protocol value: C-0 makes
|
|
5
|
+
* old Durable Object instances unreachable when this grammar changes. The
|
|
6
|
+
* service, class, and identity parts remain individually inspectable while
|
|
7
|
+
* `/` is the only grammar separator.
|
|
8
|
+
*/
|
|
9
|
+
export const DURABLE_OBJECT_SCOPE_CLASSES = Object.freeze([
|
|
10
|
+
"tag",
|
|
11
|
+
"tag-state",
|
|
12
|
+
"allocator",
|
|
13
|
+
"bootstrap",
|
|
14
|
+
"journal",
|
|
15
|
+
]);
|
|
16
|
+
export class ScopeNameError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "ScopeNameError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** The existing deploy-time SDT_SERVICE_ID grammar, shared by scope names. */
|
|
23
|
+
export function isScopeServiceId(value) {
|
|
24
|
+
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,95}$/.test(value);
|
|
25
|
+
}
|
|
26
|
+
function isScopeClass(value) {
|
|
27
|
+
return DURABLE_OBJECT_SCOPE_CLASSES.includes(value);
|
|
28
|
+
}
|
|
29
|
+
function requireScope(scope) {
|
|
30
|
+
if (!isScopeServiceId(scope.serviceId)) {
|
|
31
|
+
throw new ScopeNameError("serviceId must be a valid non-empty deployment service identity");
|
|
32
|
+
}
|
|
33
|
+
if (!isScopeClass(scope.doClass)) {
|
|
34
|
+
throw new ScopeNameError("doClass is not a registered Durable Object scope class");
|
|
35
|
+
}
|
|
36
|
+
if (scope.identity.length === 0 || scope.identity.includes("/")) {
|
|
37
|
+
throw new ScopeNameError("identity must be a non-empty string without '/'");
|
|
38
|
+
}
|
|
39
|
+
return scope;
|
|
40
|
+
}
|
|
41
|
+
/** Builds the canonical `${serviceId}/${doClass}/${identity}` physical name. */
|
|
42
|
+
export function buildScopeName(scope) {
|
|
43
|
+
const value = requireScope(scope);
|
|
44
|
+
return `${value.serviceId}/${value.doClass}/${value.identity}`;
|
|
45
|
+
}
|
|
46
|
+
/** Parses and fully validates one canonical Durable Object physical name. */
|
|
47
|
+
export function parseScopeName(name) {
|
|
48
|
+
const parts = name.split("/");
|
|
49
|
+
if (parts.length !== 3) {
|
|
50
|
+
throw new ScopeNameError("scope name must contain exactly three slash-delimited parts");
|
|
51
|
+
}
|
|
52
|
+
return requireScope({
|
|
53
|
+
serviceId: parts[0],
|
|
54
|
+
doClass: parts[1],
|
|
55
|
+
identity: parts[2],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function scopeIdFor(namespace, scope) {
|
|
59
|
+
return namespace.idFromName(buildScopeName(scope));
|
|
60
|
+
}
|
|
61
|
+
/** A stable component encoding inside the single opaque tag-state identity. */
|
|
62
|
+
export function tagStateScopeIdentity(tag, projectorId) {
|
|
63
|
+
if (tag.length === 0 || projectorId.length === 0) {
|
|
64
|
+
throw new ScopeNameError("tag-state scope requires non-empty tag and projector identity");
|
|
65
|
+
}
|
|
66
|
+
return `${encodeURIComponent(tag)}:${encodeURIComponent(projectorId)}`;
|
|
67
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Miniflare-only request override. `.test` cannot be a deployed host. */
|
|
2
|
+
export declare const TEST_SERVICE_ID_HEADER = "x-sdt-g9-test-service-id";
|
|
3
|
+
/** Authenticated deployment-verification identity override. */
|
|
4
|
+
export declare const G11_SERVICE_ID_HEADER = "x-sdt-g11-service-id";
|
|
5
|
+
export type ServiceIdentityBehavior = "deployment" | "test-tld-header" | "g11-verification-header";
|
|
6
|
+
export interface ServiceIdentityResolution {
|
|
7
|
+
readonly serviceId: string;
|
|
8
|
+
readonly behavior: ServiceIdentityBehavior;
|
|
9
|
+
}
|
|
10
|
+
export interface ServiceIdentityRequestOptions {
|
|
11
|
+
/** Explicitly enables the authenticated G11 deployment-verification header. */
|
|
12
|
+
readonly allowG11Verification?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ServiceIdentityProvider {
|
|
15
|
+
/** Resolve the configured deployment identity without request overrides. */
|
|
16
|
+
readonly deployment: () => ServiceIdentityResolution;
|
|
17
|
+
/** Resolve identity for a request, with `.test` and G11 behaviour explicit. */
|
|
18
|
+
readonly forRequest: (request: Request, options?: ServiceIdentityRequestOptions) => ServiceIdentityResolution;
|
|
19
|
+
}
|
|
20
|
+
export interface ServiceIdentityEnvironment {
|
|
21
|
+
readonly SDT_SERVICE_ID?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class ServiceIdentityMissingError extends Error {
|
|
24
|
+
constructor(message?: string);
|
|
25
|
+
}
|
|
26
|
+
/** The deployed default: the Worker environment is the identity authority. */
|
|
27
|
+
export declare function envServiceIdentity(env: ServiceIdentityEnvironment): ServiceIdentityProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Host seam for embedding runtimes and tests. It has the same request
|
|
30
|
+
* behaviour as the environment-backed provider; only its configured source
|
|
31
|
+
* differs.
|
|
32
|
+
*/
|
|
33
|
+
export declare function injectableServiceIdentity(serviceId: string | undefined | (() => string | undefined)): ServiceIdentityProvider;
|
|
34
|
+
export declare function requireServiceIdentity(provider: ServiceIdentityProvider): string;
|
|
35
|
+
export declare function requestServiceIdentity(request: Request, provider: ServiceIdentityProvider, options?: ServiceIdentityRequestOptions): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isScopeServiceId } from "../scope/ScopeName";
|
|
2
|
+
/** Miniflare-only request override. `.test` cannot be a deployed host. */
|
|
3
|
+
export const TEST_SERVICE_ID_HEADER = "x-sdt-g9-test-service-id";
|
|
4
|
+
/** Authenticated deployment-verification identity override. */
|
|
5
|
+
export const G11_SERVICE_ID_HEADER = "x-sdt-g11-service-id";
|
|
6
|
+
export class ServiceIdentityMissingError extends Error {
|
|
7
|
+
constructor(message = "SDT_SERVICE_ID is required and must be a non-empty deployment service identity") {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "ServiceIdentityMissingError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function requireServiceId(value) {
|
|
13
|
+
if (isScopeServiceId(value))
|
|
14
|
+
return value;
|
|
15
|
+
throw new ServiceIdentityMissingError();
|
|
16
|
+
}
|
|
17
|
+
function providerFor(readConfiguredServiceId) {
|
|
18
|
+
const deployment = () => ({
|
|
19
|
+
serviceId: requireServiceId(readConfiguredServiceId()),
|
|
20
|
+
behavior: "deployment",
|
|
21
|
+
});
|
|
22
|
+
return Object.freeze({
|
|
23
|
+
deployment,
|
|
24
|
+
forRequest(request, options = {}) {
|
|
25
|
+
const hostname = new URL(request.url).hostname;
|
|
26
|
+
const g11ServiceId = request.headers.get(G11_SERVICE_ID_HEADER);
|
|
27
|
+
const testServiceId = request.headers.get(TEST_SERVICE_ID_HEADER);
|
|
28
|
+
const g11Allowed = hostname.endsWith(".test") || options.allowG11Verification === true;
|
|
29
|
+
if (g11Allowed && isScopeServiceId(g11ServiceId)) {
|
|
30
|
+
return { serviceId: g11ServiceId, behavior: "g11-verification-header" };
|
|
31
|
+
}
|
|
32
|
+
if (hostname.endsWith(".test") && isScopeServiceId(testServiceId)) {
|
|
33
|
+
return { serviceId: testServiceId, behavior: "test-tld-header" };
|
|
34
|
+
}
|
|
35
|
+
return deployment();
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/** The deployed default: the Worker environment is the identity authority. */
|
|
40
|
+
export function envServiceIdentity(env) {
|
|
41
|
+
return providerFor(() => env.SDT_SERVICE_ID);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Host seam for embedding runtimes and tests. It has the same request
|
|
45
|
+
* behaviour as the environment-backed provider; only its configured source
|
|
46
|
+
* differs.
|
|
47
|
+
*/
|
|
48
|
+
export function injectableServiceIdentity(serviceId) {
|
|
49
|
+
return providerFor(typeof serviceId === "function" ? serviceId : () => serviceId);
|
|
50
|
+
}
|
|
51
|
+
export function requireServiceIdentity(provider) {
|
|
52
|
+
return provider.deployment().serviceId;
|
|
53
|
+
}
|
|
54
|
+
export function requestServiceIdentity(request, provider, options = {}) {
|
|
55
|
+
return provider.forRequest(request, options).serviceId;
|
|
56
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { DeliverySource, DownstreamOutboxMessage } from "../downstream/types";
|
|
2
|
+
import { type DeliveryIncident, type DeliveryOutcome, type DetectorStore, type EventStore, type InconsistencyClassification, type InconsistencyFinding, type PendingArrivalRecord, type ProjectionCheckpoint, type ProjectionCheckpointAdvance, type ProjectionLag, type ProjectionStore, type StoredEvent } from "./types";
|
|
3
|
+
type JsonObject = Record<string, unknown>;
|
|
4
|
+
export interface CosmosDocumentRecord<T extends JsonObject = JsonObject> {
|
|
5
|
+
document: T;
|
|
6
|
+
etag?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Minimal document operations used by the adapter; it is also the fault-test seam. */
|
|
9
|
+
export interface CosmosDocumentClient {
|
|
10
|
+
initialize(): Promise<void>;
|
|
11
|
+
read<T extends JsonObject>(container: string, id: string, partitionKey: string): Promise<CosmosDocumentRecord<T> | undefined>;
|
|
12
|
+
create<T extends JsonObject>(container: string, document: T, partitionKey: string): Promise<CosmosDocumentRecord<T>>;
|
|
13
|
+
replace<T extends JsonObject>(container: string, document: T, partitionKey: string, etag?: string): Promise<boolean>;
|
|
14
|
+
/** Optional fault-test seam; the adapter deliberately never calls it. */
|
|
15
|
+
delete?(container: string, id: string, partitionKey: string): Promise<boolean>;
|
|
16
|
+
query<T extends JsonObject>(container: string, query: string, parameters: readonly {
|
|
17
|
+
name: string;
|
|
18
|
+
value: unknown;
|
|
19
|
+
}[], partitionKey?: string): Promise<CosmosDocumentRecord<T>[]>;
|
|
20
|
+
}
|
|
21
|
+
export type CosmosWriteBoundary = "event" | "lag" | "pending" | "finding" | "checkpoint" | "incident" | "incident-projection";
|
|
22
|
+
export interface CosmosContainerNames {
|
|
23
|
+
readonly events: string;
|
|
24
|
+
readonly lagEstimates: string;
|
|
25
|
+
readonly pendingArrivals: string;
|
|
26
|
+
readonly findings: string;
|
|
27
|
+
readonly checkpoints: string;
|
|
28
|
+
}
|
|
29
|
+
/** Sekiban.Dcb CosmosEvent's immutable logical-record partition. */
|
|
30
|
+
export declare const COSMOS_EVENT_PARTITION_KEY_PATH: "/pk";
|
|
31
|
+
/** TS-only auxiliary documents retain a service-local partition. */
|
|
32
|
+
export declare const COSMOS_AUXILIARY_PARTITION_KEY_PATH: "/serviceId";
|
|
33
|
+
/** @deprecated Kept as an alias for auxiliary-container callers. */
|
|
34
|
+
export declare const COSMOS_PARTITION_KEY_PATH: "/serviceId";
|
|
35
|
+
export declare const DEFAULT_COSMOS_CONTAINERS: CosmosContainerNames;
|
|
36
|
+
export interface CosmosContainerDefinition {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly partitionKeyPath: typeof COSMOS_EVENT_PARTITION_KEY_PATH | typeof COSMOS_AUXILIARY_PARTITION_KEY_PATH;
|
|
39
|
+
readonly partitionKeyValue: (serviceId: string, id?: string) => string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The layout is data rather than a comment so every adapter initialization and
|
|
43
|
+
* contract fixture can inspect the same five service-partitioned containers.
|
|
44
|
+
*/
|
|
45
|
+
export declare function cosmosContainerDefinitions(containers?: CosmosContainerNames): readonly CosmosContainerDefinition[];
|
|
46
|
+
export interface CosmosStoreOptions {
|
|
47
|
+
/** Cosmos account endpoint, including the trailing slash when supplied. */
|
|
48
|
+
readonly endpoint?: string;
|
|
49
|
+
/** Base64 account key. It is supplied by the runtime secret boundary only. */
|
|
50
|
+
readonly key?: string;
|
|
51
|
+
readonly database?: string;
|
|
52
|
+
readonly containers?: Partial<CosmosContainerNames>;
|
|
53
|
+
readonly fetcher?: typeof fetch;
|
|
54
|
+
readonly client?: CosmosDocumentClient;
|
|
55
|
+
readonly beforeWrite?: (boundary: CosmosWriteBoundary) => void | Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export declare class CosmosClientError extends Error {
|
|
58
|
+
readonly status: number;
|
|
59
|
+
constructor(status: number, message: string);
|
|
60
|
+
}
|
|
61
|
+
/** V1 SUIDs are opaque byte strings; never use locale or numeric ordering. */
|
|
62
|
+
export declare function compareCosmosSuid(left: string, right: string): number;
|
|
63
|
+
/** Fetch-based Cosmos SQL API client; it uses only Web APIs available in workerd. */
|
|
64
|
+
export declare class CosmosRestClient implements CosmosDocumentClient {
|
|
65
|
+
private initialized;
|
|
66
|
+
private readonly endpoint;
|
|
67
|
+
private readonly key;
|
|
68
|
+
private readonly database;
|
|
69
|
+
private readonly fetcher;
|
|
70
|
+
private readonly containers;
|
|
71
|
+
constructor(options: Required<Pick<CosmosStoreOptions, "endpoint" | "key" | "database">> & Pick<CosmosStoreOptions, "fetcher" | "containers">);
|
|
72
|
+
initialize(): Promise<void>;
|
|
73
|
+
read<T extends JsonObject>(container: string, id: string, partitionKey: string): Promise<CosmosDocumentRecord<T> | undefined>;
|
|
74
|
+
create<T extends JsonObject>(container: string, document: T, partitionKey: string): Promise<CosmosDocumentRecord<T>>;
|
|
75
|
+
replace<T extends JsonObject>(container: string, document: T, partitionKey: string, etag?: string): Promise<boolean>;
|
|
76
|
+
query<T extends JsonObject>(container: string, query: string, parameters: readonly {
|
|
77
|
+
name: string;
|
|
78
|
+
value: unknown;
|
|
79
|
+
}[], partitionKey?: string): Promise<CosmosDocumentRecord<T>[]>;
|
|
80
|
+
private ensureResource;
|
|
81
|
+
private request;
|
|
82
|
+
private errorFrom;
|
|
83
|
+
}
|
|
84
|
+
export declare class CosmosEventStore implements EventStore, DetectorStore, ProjectionStore {
|
|
85
|
+
private initialized;
|
|
86
|
+
private readonly client;
|
|
87
|
+
private readonly containers;
|
|
88
|
+
private readonly beforeWrite?;
|
|
89
|
+
constructor(options: CosmosStoreOptions);
|
|
90
|
+
initialize(): Promise<void>;
|
|
91
|
+
recordDelivery(message: DownstreamOutboxMessage, arrivedAt: number, deliverySource?: DeliverySource): Promise<DeliveryOutcome>;
|
|
92
|
+
readAllEvents(serviceId: string, since: string): Promise<StoredEvent[]>;
|
|
93
|
+
currentLagBound(serviceId: string, nowMs?: number): Promise<number>;
|
|
94
|
+
listProjectionTags(serviceId: string): Promise<string[]>;
|
|
95
|
+
readProjectionCheckpoint(serviceId: string, projectionId: string): Promise<ProjectionCheckpoint | undefined>;
|
|
96
|
+
advanceProjectionCheckpoint(input: ProjectionCheckpointAdvance): Promise<boolean>;
|
|
97
|
+
projectionLag(serviceId: string, projectionId: string, tag: string): Promise<ProjectionLag>;
|
|
98
|
+
upsertPending(message: DownstreamOutboxMessage, firstObservedAt: number, lagBoundMs: number): Promise<PendingArrivalRecord>;
|
|
99
|
+
listPending(serviceId?: string): Promise<PendingArrivalRecord[]>;
|
|
100
|
+
appendFinding(finding: InconsistencyFinding): Promise<void>;
|
|
101
|
+
appendDeliveryIncident(incident: DeliveryIncident): Promise<void>;
|
|
102
|
+
hasDeliveryIncident(serviceId: string, identityKey: string): Promise<boolean>;
|
|
103
|
+
listDeliveryIncidents(serviceId?: string): Promise<DeliveryIncident[]>;
|
|
104
|
+
/** Retryable async projection from the same-partition incident landing. */
|
|
105
|
+
projectDeliveryIncidents(serviceId?: string): Promise<number>;
|
|
106
|
+
private readLineageBinding;
|
|
107
|
+
private bindLineage;
|
|
108
|
+
/**
|
|
109
|
+
* Cosmos has no cross-document unique index. A same-partition SUID binding
|
|
110
|
+
* is the equivalent guard: the first EventId reserves the opaque SUID and
|
|
111
|
+
* every later delivery reuses or rejects that reservation before event
|
|
112
|
+
* mutation. Historical rows are still checked by eventDocuments above.
|
|
113
|
+
*/
|
|
114
|
+
private reserveSuid;
|
|
115
|
+
private persistIncident;
|
|
116
|
+
private projectIncident;
|
|
117
|
+
hasFinding(serviceId: string, eventId: string, path: string, classification: InconsistencyClassification): Promise<boolean>;
|
|
118
|
+
listFindings(serviceId?: string, eventId?: string): Promise<InconsistencyFinding[]>;
|
|
119
|
+
private eventDocuments;
|
|
120
|
+
private eventOps;
|
|
121
|
+
private mutateEvent;
|
|
122
|
+
private mutateEventOps;
|
|
123
|
+
private updateLag;
|
|
124
|
+
private ready;
|
|
125
|
+
}
|
|
126
|
+
export {};
|