/// import { Awaitable } from '@miniflare/shared'; import { Context } from '@miniflare/shared'; import { MiniflareError } from '@miniflare/shared'; import { Mount } from '@miniflare/shared'; import { Plugin } from '@miniflare/shared'; import { PluginContext } from '@miniflare/shared'; import { Request } from '@miniflare/core'; import { RequestInfo } from '@miniflare/core'; import { RequestInit } from '@miniflare/core'; import { Response } from '@miniflare/core'; import { SetupResult } from '@miniflare/shared'; import { Storage } from '@miniflare/shared'; import { StorageFactory } from '@miniflare/shared'; import { StorageListOptions } from '@miniflare/shared'; import { StorageListResult } from '@miniflare/shared'; import { StoredKey } from '@miniflare/shared'; import { StoredValue } from '@miniflare/shared'; export declare const ALARM_KEY = "__MINIFLARE_ALARMS__"; export declare class AlarmStore { #private; setupStore(storage: StorageFactory, persist?: boolean | string): Promise; setupAlarms(callback?: (objectKey: string) => Promise): Promise; buildBridge(objectKey: string): DurableObjectAlarmBridge; setAlarm(objectKey: string, scheduledTime: number | Date): Promise; deleteAlarm(key: string): Promise; flushAlarms(keys?: string[]): Promise; dispose(): void; } export declare interface DurableObject { fetch(request: Request): Awaitable; alarm?(): Awaitable; } export declare interface DurableObjectAlarm { scheduledTime: number; timeout?: NodeJS.Timeout; } export declare interface DurableObjectAlarmBridge { setAlarm: (scheduledTime: number | Date) => Promise; deleteAlarm: () => Promise; } export declare interface DurableObjectConstructor { new (state: DurableObjectState, env: Context): DurableObject; } export declare class DurableObjectError extends MiniflareError { } export declare type DurableObjectErrorCode = "ERR_SCRIPT_NOT_FOUND" | "ERR_CLASS_NOT_FOUND" | "ERR_RESPONSE_TYPE" | "ERR_DESERIALIZATION" | "ERR_NO_HANDLER"; export declare type DurableObjectFactory = (id: DurableObjectId) => Promise; export declare interface DurableObjectGetAlarmOptions { allowConcurrency?: boolean; } export declare interface DurableObjectGetOptions { allowConcurrency?: boolean; noCache?: boolean; } export declare class DurableObjectId { #private; readonly name?: string | undefined; readonly [kObjectName]: string; constructor(objectName: string, hexId: string, name?: string | undefined); equals(other: DurableObjectId): boolean; toString(): string; } export declare interface DurableObjectListOptions extends DurableObjectGetOptions { start?: string; startAfter?: string; end?: string; prefix?: string; reverse?: boolean; limit?: number; } export declare class DurableObjectNamespace { #private; constructor(objectName: string, factory: DurableObjectFactory, ctx?: PluginContext); jurisdiction(name: string): DurableObjectNamespace; newUniqueId(options?: NewUniqueIdOptions): DurableObjectId; idFromName(name: string): DurableObjectId; idFromString(hexId: string): DurableObjectId; get(id: DurableObjectId): DurableObjectStub; } export declare interface DurableObjectOperator { get(key: string, options?: DurableObjectGetOptions): Promise; get(keys: string[], options?: DurableObjectGetOptions): Promise>; put(key: string, value: Value, options?: DurableObjectPutOptions): Promise; put(entries: Record, options?: DurableObjectPutOptions): Promise; delete(key: string, options?: DurableObjectPutOptions): Promise; delete(keys: string[], options?: DurableObjectPutOptions): Promise; list(options?: DurableObjectListOptions): Promise>; getAlarm(options?: DurableObjectGetAlarmOptions): Promise; setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise; deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise; } export declare interface DurableObjectPutOptions extends DurableObjectGetOptions { allowUnconfirmed?: boolean; } export declare interface DurableObjectSetAlarmOptions { allowConcurrency?: boolean; allowUnconfirmed?: boolean; } export declare type DurableObjectsObjectsOptions = Record; export declare interface DurableObjectsOptions { durableObjects?: DurableObjectsObjectsOptions; durableObjectsPersist?: boolean | string; durableObjectsAlarms?: boolean; } export declare class DurableObjectsPlugin extends Plugin implements DurableObjectsOptions { #private; durableObjects?: DurableObjectsObjectsOptions; durableObjectsPersist?: boolean | string; durableObjectsAlarms?: boolean; constructor(ctx: PluginContext, options?: DurableObjectsOptions); getStorage(storage: StorageFactory, id: DurableObjectId): DurableObjectStorage; getObject(storage: StorageFactory, id: DurableObjectId): Promise; getInstance(storage: StorageFactory, id: DurableObjectId): Promise; getNamespace(storage: StorageFactory, objectName: string): DurableObjectNamespace; setup(storageFactory: StorageFactory): Promise; flushAlarms(storageFactory: StorageFactory, ids?: DurableObjectId[]): Promise; getObjects(storageFactory: StorageFactory, namespace: string): DurableObjectId[]; beforeReload(): Promise; reload(bindings: Context, moduleExports: Context, mounts: Map): void; dispose(): Promise; } export declare class DurableObjectState { #private; readonly id: DurableObjectId; readonly storage: DurableObjectStorage; [kInstance]?: DurableObject; constructor(id: DurableObjectId, storage: DurableObjectStorage); waitUntil(_promise: Promise): void; blockConcurrencyWhile(closure: () => Promise): Promise; /* Excluded from this release type: [_kRunWithGates] */ [kFetch](request: Request): Promise; [kAlarm](): Promise; } export declare class DurableObjectStorage implements DurableObjectOperator { #private; [kAlarmExists]: boolean; constructor(inner: Storage, alarmBridge?: DurableObjectAlarmBridge); transaction(closure: (txn: DurableObjectTransaction) => Promise): Promise; get(key: string, options?: DurableObjectGetOptions): Promise; get(keys: string[], options?: DurableObjectGetOptions): Promise>; put(key: string, value: Value, options?: DurableObjectPutOptions): Promise; put(entries: Record, options?: DurableObjectPutOptions): Promise; delete(key: string, options?: DurableObjectPutOptions): Promise; delete(keys: string[], options?: DurableObjectPutOptions): Promise; deleteAll(options?: DurableObjectPutOptions): Promise; list(options?: DurableObjectListOptions): Promise>; getAlarm(options?: DurableObjectGetAlarmOptions): Promise; setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise; deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise; sync(): Promise; } export declare class DurableObjectStub { #private; readonly id: DurableObjectId; constructor(factory: DurableObjectFactory, id: DurableObjectId, ctx?: PluginContext); get name(): string | undefined; fetch(input: RequestInfo, init?: RequestInit): Promise; } export declare class DurableObjectTransaction implements DurableObjectOperator { #private; readonly [kInner]: ShadowStorage; readonly [kStartTxnCount]: number; [kRolledback]: boolean; [kCommitted]: boolean; readonly [kWriteSet]: Set; readonly [kAlarmExists]: boolean; constructor(inner: Storage, startTxnCount: number, alarmExists: boolean); get(key: string, options?: DurableObjectGetOptions): Promise; get(keys: string[], options?: DurableObjectGetOptions): Promise>; put(key: string, value: Value, options?: DurableObjectPutOptions): Promise; put(entries: Record, options?: DurableObjectPutOptions): Promise; delete(key: string, options?: DurableObjectPutOptions): Promise; delete(keys: string[], options?: DurableObjectPutOptions): Promise; deleteAll(): never; list(options?: DurableObjectListOptions): Promise>; getAlarm(options?: DurableObjectGetAlarmOptions): Promise; setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise; deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise; rollback(): void; } declare const kAlarm: unique symbol; export declare const kAlarmExists: unique symbol; declare const kCommitted: unique symbol; declare const kFetch: unique symbol; declare const kInner: unique symbol; declare const kInstance: unique symbol; declare const kObjectName: unique symbol; declare const kRolledback: unique symbol; /* Excluded from this release type: _kRunWithGates */ declare const kStartTxnCount: unique symbol; declare const kWriteSet: unique symbol; export declare interface NewUniqueIdOptions { jurisdiction?: string; } export declare class ReadWriteMutex { private readLockCount; private writeLocked; private readResolveQueue; private writeResolveQueue; private readLock; private writeLock; private unlock; runWithRead(closure: () => Awaitable): Promise; runWithWrite(closure: () => Awaitable): Promise; } export declare class ShadowStorage extends Storage { protected readonly inner: Storage; readonly readSet?: Set; readonly copies: Map; alarm?: number | null; constructor(inner: Storage, recordReads?: boolean); has(key: string): Promise; hasMany(keys: string[]): Promise; head(_key: string): Promise; get(key: string): Promise; getMany(keys: string[]): Promise<(StoredValue | undefined)[]>; getRange(_key: string): Promise; put(key: string, value: StoredValue): void; delete(key: string): Promise; deleteMany(keys: string[]): Promise; list(options?: Omit): Promise>; getAlarm(): Promise; setAlarm(scheduledTime: number | Date): Promise; deleteAlarm(): Promise; } export { }