@lunora/server 1.0.0-alpha.162 → 1.0.0-alpha.163

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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Validator, Infer, v, Id, ValidatorMap, InferValidatorMap, ColumnValidator } from '@lunora/values';
2
2
  export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
3
3
  import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, DurableStreamOptions, RegisteredStream, FunctionKind, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, GlobalBackend, RelationDefinition, OnDeleteAction, SearchLanguage, SearchStrategy, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, DurableObjectJurisdiction, AggregateIndexDefinition, RankIndexDefinition, Secrets, LifecycleEvent, ShardInitEvent, RegisteredLifecycleHook, WhisperEvent } from "./types.mjs";
4
- export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
4
+ export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceEvent, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.mjs";
5
5
  import { LunoraError } from '@lunora/errors';
6
6
  export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
7
7
  import { Context, Hono } from 'hono';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Validator, Infer, v, Id, ValidatorMap, InferValidatorMap, ColumnValidator } from '@lunora/values';
2
2
  export { type ColumnValidator, type GeoPoint, type Id, type Infer, ValidationError, type Validator, type ValidatorKind, v } from '@lunora/values';
3
3
  import { ArgsValidator, InferArgs, RegisteredAction, ExposeConfig, X402ProcedureConfig, ActionCtx, MutationCtx, RegisteredMutation, QueryCtx, RegisteredQuery, DurableStreamOptions, RegisteredStream, FunctionKind, TableDefinition, RegisteredFunction, VectorIndexDefinition, Schema, AggregateOp, GlobalBackend, RelationDefinition, OnDeleteAction, SearchLanguage, SearchStrategy, ExternalSourceDefinition, TriggerBuilder, TriggerDefinition, VectorEmbedder, VectorMetric, DurableObjectJurisdiction, AggregateIndexDefinition, RankIndexDefinition, Secrets, LifecycleEvent, ShardInitEvent, RegisteredLifecycleHook, WhisperEvent } from "./types.js";
4
- export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
4
+ export { type AnyApi, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type IndexDefinition, type IndexRangeBuilder, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationStorage, type PaginationOptions, type PaginationResult, type RankSortKey, type ReadOnlyStorage, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type SearchFilterBuilder, type SearchIndexDefinition, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerCtx, type TriggerDatabase, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorMatch, type VectorMatches, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceEvent, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, anyApi } from "./types.js";
5
5
  import { LunoraError } from '@lunora/errors';
6
6
  export { LunoraError, type LunoraErrorCode } from '@lunora/errors';
7
7
  import { Context, Hono } from 'hono';
package/dist/types.d.mts CHANGED
@@ -841,7 +841,7 @@ interface ScheduledFunctionDoc {
841
841
  /** Routing hint forwarded so dispatch lands on the right shard. */
842
842
  shardKey?: string;
843
843
  /**
844
- * The `WORKFLOW_*`/`AGENT_*` binding a fresh durable instance is started from
844
+ * The workflow/agent export key (its generated class name) a fresh durable instance is started from
845
845
  * on fire (the {@link ScheduledFunctionDoc.args} become its `params`). Set
846
846
  * instead of {@link ScheduledFunctionDoc.functionPath}.
847
847
  */
@@ -1411,7 +1411,7 @@ interface ScheduledJob {
1411
1411
  /** Routing hint forwarded so dispatch lands on the right shard. */
1412
1412
  shardKey?: string;
1413
1413
  /**
1414
- * The `WORKFLOW_*`/`AGENT_*` binding name a fresh durable instance is started
1414
+ * The workflow/agent export key a fresh durable instance is started
1415
1415
  * from on fire (the {@link ScheduledJob.args} become its `params`). Set
1416
1416
  * instead of {@link ScheduledJob.functionPath}.
1417
1417
  */
@@ -1419,15 +1419,15 @@ interface ScheduledJob {
1419
1419
  }
1420
1420
  /**
1421
1421
  * A schedulable durable-workflow reference — the generated `workflows.<name>` /
1422
- * `agents.<name>` object, which carries its `WORKFLOW_*`/`AGENT_*` binding and
1422
+ * `agents.<name>` object, which carries its export key (the generated class name) and
1423
1423
  * stable name. Structural mirror of `@lunora/scheduler`'s `WorkflowReference` so
1424
1424
  * `ctx.scheduler` can target a workflow/agent without a dependency on
1425
1425
  * `@lunora/scheduler` / `@lunora/workflow`. A scheduled workflow target starts a
1426
1426
  * fresh instance on fire (the args become its `params`).
1427
1427
  */
1428
1428
  interface SchedulableWorkflowReference {
1429
- /** The `WORKFLOW_*`/`AGENT_*` binding name (present on a generated ref). */
1430
- readonly binding?: string;
1429
+ /** The workflow/agent export key — its generated class name (present on a generated ref). */
1430
+ readonly className?: string;
1431
1431
  readonly isLunoraWorkflow: true;
1432
1432
  /** The workflow/agent export/stable name (present on a generated ref). */
1433
1433
  readonly name?: string;
@@ -1486,7 +1486,7 @@ interface WorkflowCreateOptions<Params = Record<string, unknown>> {
1486
1486
  id?: string;
1487
1487
  /** The event payload the instance is triggered with — surfaced as `event.payload`. */
1488
1488
  params?: Params;
1489
- /** Instance retention policy (defaults to the account maximum). */
1489
+ /** Instance retention policy (defaults to the workflow's `defaultRetention`, else the plan default). */
1490
1490
  retention?: {
1491
1491
  errorRetention?: string;
1492
1492
  successRetention?: string;
@@ -1502,8 +1502,17 @@ interface WorkflowEventDefinition<Payload = unknown> {
1502
1502
  readonly payload: Validator<Payload>;
1503
1503
  readonly type: string;
1504
1504
  }
1505
+ /** One event `WorkflowInstance.subscribe()` streams. Mirrors `@lunora/workflow`'s `WorkflowInstanceEventLike`. */
1506
+ interface WorkflowInstanceEvent {
1507
+ [field: string]: unknown;
1508
+ eventId: number;
1509
+ instanceId: string;
1510
+ timestamp: number;
1511
+ type: string;
1512
+ }
1505
1513
  /** A live handle to a single workflow instance. Mirrors `@lunora/workflow`'s `WorkflowInstanceLike`. */
1506
1514
  interface WorkflowInstance {
1515
+ delete: () => Promise<void>;
1507
1516
  readonly id: string;
1508
1517
  pause: () => Promise<void>;
1509
1518
  restart: () => Promise<void>;
@@ -1513,6 +1522,13 @@ interface WorkflowInstance {
1513
1522
  type: string;
1514
1523
  }) => Promise<void>;
1515
1524
  status: () => Promise<WorkflowStatusResult>;
1525
+ /** Stream the instance's events — its full history first, then new ones as it runs. */
1526
+ subscribe: (options?: {
1527
+ cursor?: number;
1528
+ filter?: string[];
1529
+ }) => Promise<{
1530
+ next: () => Promise<IteratorResult<WorkflowInstanceEvent, void>>;
1531
+ }>;
1516
1532
  terminate: () => Promise<void>;
1517
1533
  }
1518
1534
  /**
@@ -1524,6 +1540,17 @@ interface WorkflowHandle<Params = Record<string, unknown>> {
1524
1540
  create: (options?: WorkflowCreateOptions<Params>) => Promise<WorkflowInstance>;
1525
1541
  /** Start many instances in one batched RPC. */
1526
1542
  createBatch: (batch: ReadonlyArray<WorkflowCreateOptions<Params>>) => Promise<WorkflowInstance[]>;
1543
+ /** Delete up to 100 instances and their stored state; ids that do not exist come back as per-instance errors. */
1544
+ deleteBatch: (instanceIds: ReadonlyArray<string>) => Promise<{
1545
+ deleted: {
1546
+ id: string;
1547
+ }[];
1548
+ errors: {
1549
+ code: number;
1550
+ id: string;
1551
+ message: string;
1552
+ }[];
1553
+ }>;
1527
1554
  /** Get a handle to an existing instance by id. */
1528
1555
  get: (id: string) => Promise<WorkflowInstance>;
1529
1556
  /** Deliver a declared event (`defineWorkflowEvent`) to one instance; the payload is validated before the send. */
@@ -2586,4 +2613,4 @@ interface ActionCtx {
2586
2613
  */
2587
2614
  type AnyApi = Record<string, Record<string, RegisteredFunction<ArgsValidator, unknown, FunctionKind>>>;
2588
2615
  declare const anyApi: AnyApi;
2589
- export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinition, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WhisperEvent, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
2616
+ export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinition, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WhisperEvent, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceEvent, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
package/dist/types.d.ts CHANGED
@@ -841,7 +841,7 @@ interface ScheduledFunctionDoc {
841
841
  /** Routing hint forwarded so dispatch lands on the right shard. */
842
842
  shardKey?: string;
843
843
  /**
844
- * The `WORKFLOW_*`/`AGENT_*` binding a fresh durable instance is started from
844
+ * The workflow/agent export key (its generated class name) a fresh durable instance is started from
845
845
  * on fire (the {@link ScheduledFunctionDoc.args} become its `params`). Set
846
846
  * instead of {@link ScheduledFunctionDoc.functionPath}.
847
847
  */
@@ -1411,7 +1411,7 @@ interface ScheduledJob {
1411
1411
  /** Routing hint forwarded so dispatch lands on the right shard. */
1412
1412
  shardKey?: string;
1413
1413
  /**
1414
- * The `WORKFLOW_*`/`AGENT_*` binding name a fresh durable instance is started
1414
+ * The workflow/agent export key a fresh durable instance is started
1415
1415
  * from on fire (the {@link ScheduledJob.args} become its `params`). Set
1416
1416
  * instead of {@link ScheduledJob.functionPath}.
1417
1417
  */
@@ -1419,15 +1419,15 @@ interface ScheduledJob {
1419
1419
  }
1420
1420
  /**
1421
1421
  * A schedulable durable-workflow reference — the generated `workflows.<name>` /
1422
- * `agents.<name>` object, which carries its `WORKFLOW_*`/`AGENT_*` binding and
1422
+ * `agents.<name>` object, which carries its export key (the generated class name) and
1423
1423
  * stable name. Structural mirror of `@lunora/scheduler`'s `WorkflowReference` so
1424
1424
  * `ctx.scheduler` can target a workflow/agent without a dependency on
1425
1425
  * `@lunora/scheduler` / `@lunora/workflow`. A scheduled workflow target starts a
1426
1426
  * fresh instance on fire (the args become its `params`).
1427
1427
  */
1428
1428
  interface SchedulableWorkflowReference {
1429
- /** The `WORKFLOW_*`/`AGENT_*` binding name (present on a generated ref). */
1430
- readonly binding?: string;
1429
+ /** The workflow/agent export key — its generated class name (present on a generated ref). */
1430
+ readonly className?: string;
1431
1431
  readonly isLunoraWorkflow: true;
1432
1432
  /** The workflow/agent export/stable name (present on a generated ref). */
1433
1433
  readonly name?: string;
@@ -1486,7 +1486,7 @@ interface WorkflowCreateOptions<Params = Record<string, unknown>> {
1486
1486
  id?: string;
1487
1487
  /** The event payload the instance is triggered with — surfaced as `event.payload`. */
1488
1488
  params?: Params;
1489
- /** Instance retention policy (defaults to the account maximum). */
1489
+ /** Instance retention policy (defaults to the workflow's `defaultRetention`, else the plan default). */
1490
1490
  retention?: {
1491
1491
  errorRetention?: string;
1492
1492
  successRetention?: string;
@@ -1502,8 +1502,17 @@ interface WorkflowEventDefinition<Payload = unknown> {
1502
1502
  readonly payload: Validator<Payload>;
1503
1503
  readonly type: string;
1504
1504
  }
1505
+ /** One event `WorkflowInstance.subscribe()` streams. Mirrors `@lunora/workflow`'s `WorkflowInstanceEventLike`. */
1506
+ interface WorkflowInstanceEvent {
1507
+ [field: string]: unknown;
1508
+ eventId: number;
1509
+ instanceId: string;
1510
+ timestamp: number;
1511
+ type: string;
1512
+ }
1505
1513
  /** A live handle to a single workflow instance. Mirrors `@lunora/workflow`'s `WorkflowInstanceLike`. */
1506
1514
  interface WorkflowInstance {
1515
+ delete: () => Promise<void>;
1507
1516
  readonly id: string;
1508
1517
  pause: () => Promise<void>;
1509
1518
  restart: () => Promise<void>;
@@ -1513,6 +1522,13 @@ interface WorkflowInstance {
1513
1522
  type: string;
1514
1523
  }) => Promise<void>;
1515
1524
  status: () => Promise<WorkflowStatusResult>;
1525
+ /** Stream the instance's events — its full history first, then new ones as it runs. */
1526
+ subscribe: (options?: {
1527
+ cursor?: number;
1528
+ filter?: string[];
1529
+ }) => Promise<{
1530
+ next: () => Promise<IteratorResult<WorkflowInstanceEvent, void>>;
1531
+ }>;
1516
1532
  terminate: () => Promise<void>;
1517
1533
  }
1518
1534
  /**
@@ -1524,6 +1540,17 @@ interface WorkflowHandle<Params = Record<string, unknown>> {
1524
1540
  create: (options?: WorkflowCreateOptions<Params>) => Promise<WorkflowInstance>;
1525
1541
  /** Start many instances in one batched RPC. */
1526
1542
  createBatch: (batch: ReadonlyArray<WorkflowCreateOptions<Params>>) => Promise<WorkflowInstance[]>;
1543
+ /** Delete up to 100 instances and their stored state; ids that do not exist come back as per-instance errors. */
1544
+ deleteBatch: (instanceIds: ReadonlyArray<string>) => Promise<{
1545
+ deleted: {
1546
+ id: string;
1547
+ }[];
1548
+ errors: {
1549
+ code: number;
1550
+ id: string;
1551
+ message: string;
1552
+ }[];
1553
+ }>;
1527
1554
  /** Get a handle to an existing instance by id. */
1528
1555
  get: (id: string) => Promise<WorkflowInstance>;
1529
1556
  /** Deliver a declared event (`defineWorkflowEvent`) to one instance; the payload is validated before the send. */
@@ -2586,4 +2613,4 @@ interface ActionCtx {
2586
2613
  */
2587
2614
  type AnyApi = Record<string, Record<string, RegisteredFunction<ArgsValidator, unknown, FunctionKind>>>;
2588
2615
  declare const anyApi: AnyApi;
2589
- export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinition, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WhisperEvent, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
2616
+ export { type ActionCtx, type AggregateIndexDefinition, type AggregateOp, type AnyApi, type ArgsValidator, type AuthState, type CachePurge, type DatabaseReader, type DatabaseWriter, type DurableObjectJurisdiction, type DurableStreamOptions, type ExposeConfig, type ExternalSourceCursor, type ExternalSourceDefinition, type ExternalSourceMode, type ExternalSourceRefresh, type FunctionKind, type FunctionVisibility, type GeoBoundingBox, type GeoFilterBuilder, type GeoIndexDefinition, type GeoPointInput, type GlobalBackend, type IndexDefinition, type IndexRangeBuilder, type InferArgs, type LifecycleEvent, type LifecycleEventKind, type LogFields, type LunoraLogMethod, type LunoraLogger, type LunoraMetrics, type LunoraTracer, type LunoraWideEvent, type MutationCtx, type MutationStorage, type OnDeleteAction, type PaginationOptions, type PaginationResult, type QueryCtx, type RankIndexDefinition, type RankSortKey, type ReadOnlyStorage, type RegisteredAction, type RegisteredFunction, type RegisteredLifecycleHook, type RegisteredMutation, type RegisteredQuery, type RegisteredStream, type RelatedDirection, type RelatedNode, type RelatedOptions, type RelatedPage, type RelatedStart, type RelatedStartReference, type RelationDefinition, type RestCacheConfig, type RetryPolicy, type RunQueryOptions, type ScheduledFunctionDoc, type ScheduledJob, type Scheduler, type Schema, type SearchFilterBuilder, type SearchIndexDefinition, type SearchLanguage, type SearchStrategy, type Secrets, type SecretsStoreSecretLike, type ShardInitEvent, type ShardMode, type SpanContextIds, type SpanEvaluation, type SpanHandle, type SpanIdentity, type SpanKind, type SpanLink, type SpanOptions, type Storage, type StorageMetadata, type StorageObjectBody, type StorageObjectHead, type StorageRange, type SystemDatabaseReader, type SystemDoc, type SystemQuery, type SystemTableName, type TableDefinition, type TableReader, type TableVectorIndex, type TriggerAggregateOptions, type TriggerBuilder, type TriggerCtx, type TriggerDatabase, type TriggerDefinition, type TriggerDeleteEvent, type TriggerEvent, type TriggerGroupByEntry, type TriggerGroupByOptions, type TriggerHandler, type TriggerInsertEvent, type TriggerOp, type TriggerQueryArgs, type TriggerQueryPage, type TriggerRankOptions, type TriggerRankPageOptions, type TriggerRankResult, type TriggerRow, type TriggerTiming, type TriggerUpdateEvent, type TtlDefinition, type VectorEmbedder, type VectorIndexDefinition, type VectorMatch, type VectorMatches, type VectorMetric, type VectorQueryInput, type VectorRecord, type VectorSearch, type VectorSearchReader, type VectorUpsertInput, type WhisperEvent, type WorkflowCreateOptions, type WorkflowEventDefinition, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceEvent, type WorkflowInstanceStatus, type WorkflowStatusResult, type Workflows, type X402ProcedureConfig, anyApi };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/server",
3
- "version": "1.0.0-alpha.162",
3
+ "version": "1.0.0-alpha.163",
4
4
  "description": "Server primitives for Lunora: defineSchema, defineTable, query, mutation, and action",
5
5
  "keywords": [
6
6
  "backend",
@@ -66,10 +66,10 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@lunora/errors": "1.0.0-alpha.47",
70
- "@lunora/scheduler": "1.0.0-alpha.99",
71
- "@lunora/shard-engine": "1.0.0-alpha.101",
72
- "@lunora/values": "1.0.0-alpha.57",
69
+ "@lunora/errors": "1.0.0-alpha.48",
70
+ "@lunora/scheduler": "1.0.0-alpha.100",
71
+ "@lunora/shard-engine": "1.0.0-alpha.102",
72
+ "@lunora/values": "1.0.0-alpha.58",
73
73
  "drizzle-orm": "^0.45.2",
74
74
  "hono": "^4.13.7"
75
75
  },