@swirls/looms 0.10.0 → 0.11.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/CHANGELOG.md +26 -0
- package/dist/actor/cell.d.ts +3 -1
- package/dist/actor/cell.js +1 -0
- package/dist/actor/host.d.ts +3 -1
- package/dist/actor/host.js +1 -0
- package/dist/agent/module.d.ts +512 -512
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +47 -12
- package/dist/client/client.d.ts +20 -21
- package/dist/client/client.js +2 -1
- package/dist/cloudflare/delete-terminal-run-storage.d.ts +39 -0
- package/dist/cloudflare/delete-terminal-run-storage.js +98 -0
- package/dist/cloudflare/durable-object.d.ts +11 -1
- package/dist/cloudflare/durable-object.js +23 -0
- package/dist/cloudflare/index.d.ts +1 -0
- package/dist/cloudflare/index.js +1 -0
- package/dist/core/run-context.d.ts +50 -0
- package/dist/core/run-context.js +21 -1
- package/dist/debugger/app/assets/{index-D-2Q7ecG.js → index-VTotlHcm.js} +2 -2
- package/dist/debugger/app/assets/{routes-lvmllT60.js → routes-CEdsN9DO.js} +2 -2
- package/dist/debugger/app/index.html +1 -1
- package/dist/projectors/event-log-ops.d.ts +0 -6
- package/dist/projectors/event-log-ops.js +2 -12
- package/dist/projectors/event-log.d.ts +10 -5
- package/dist/projectors/event-log.js +26 -22
- package/dist/projectors/replica/columns.d.ts +41 -0
- package/dist/projectors/replica/columns.js +77 -0
- package/dist/projectors/replica/drizzle.d.ts +328 -57
- package/dist/projectors/replica/drizzle.js +18 -14
- package/dist/projectors/replica/migrations.d.ts +25 -5
- package/dist/projectors/replica/migrations.js +62 -14
- package/dist/projectors/replica/postgres.d.ts +12 -11
- package/dist/projectors/replica/postgres.js +12 -26
- package/dist/projectors/replica/sqlite-bun.d.ts +3 -1
- package/dist/projectors/replica/sqlite-bun.js +6 -2
- package/dist/projectors/replica/sqlite-migrations.d.ts +5 -5
- package/dist/projectors/replica/sqlite-migrations.js +22 -9
- package/dist/projectors/replica/sqlite.d.ts +12 -11
- package/dist/projectors/replica/sqlite.js +23 -16
- package/dist/runtime/looms.d.ts +27 -36
- package/dist/runtime/looms.js +1 -0
- package/dist/runtime/runtime.js +7 -1
- package/dist/runtime/server/http.js +4 -2
- package/dist/runtime/types.d.ts +6 -1
- package/package.json +1 -1
package/dist/runtime/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Clock, Effect, ManagedRuntime, Predicate } from 'effect';
|
|
2
|
-
import { cachedDefinitionResolver, chainDefinitionResolvers, composeModules, createEvent, createThreadId, createRunId, DEFAULT_DEFINITION_VERSION, DEFAULT_SNAPSHOT_EVERY, staticDefinitionResolver, descendantThreadIds, EventStoreTag, foldRun, hasEntries, isRunTerminal, unavailableRunLauncher, planFork, project, readTraceContext, replayTo, sameStringRecord, summarizeRun, } from '@swirls/looms/core';
|
|
2
|
+
import { cachedDefinitionResolver, chainDefinitionResolvers, composeModules, createEvent, createThreadId, createRunId, DEFAULT_DEFINITION_VERSION, DEFAULT_SNAPSHOT_EVERY, staticDefinitionResolver, descendantThreadIds, EventStoreTag, foldRun, hasEntries, InvalidRunAttributesError, isRunTerminal, runAttributeIssues, unavailableRunLauncher, planFork, project, readTraceContext, replayTo, sameStringRecord, summarizeRun, } from '@swirls/looms/core';
|
|
3
3
|
import { createCancellation } from './cancellation.js';
|
|
4
4
|
import { nextRuntimeDeadline } from './deadline-transition-planner.js';
|
|
5
5
|
import { ForkConflictError, RunNotFinishedError, RunNotFoundError, RunTerminalError, RuntimeExecutionError, SecretContextConflictError, StartRunConflictError, } from './errors.js';
|
|
@@ -158,6 +158,12 @@ export function createRuntime(options) {
|
|
|
158
158
|
return committed.value;
|
|
159
159
|
});
|
|
160
160
|
const commitStart = (args, runId) => Effect.gen(function* () {
|
|
161
|
+
if (options.attributes) {
|
|
162
|
+
const issues = runAttributeIssues(options.attributes, args.attributes ?? {});
|
|
163
|
+
if (issues.length > 0) {
|
|
164
|
+
return yield* new InvalidRunAttributesError(issues);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
161
167
|
const definitionVersion = args.definitionVersion ?? DEFAULT_DEFINITION_VERSION;
|
|
162
168
|
const resolved = yield* definitionResolver.resolve(args.kind, args.definitionName, definitionVersion);
|
|
163
169
|
if (!resolved) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Data, Effect, Schema } from 'effect';
|
|
2
|
-
import { EventStoreTag, ForkSourceError, InvalidEventError, InvalidInputError, JsonValueSchema, } from '@swirls/looms/core';
|
|
2
|
+
import { EventStoreTag, ForkSourceError, InvalidEventError, InvalidInputError, InvalidRunAttributesError, JsonValueSchema, } from '@swirls/looms/core';
|
|
3
3
|
import { ForkConflictError, RunNotFinishedError, RunNotFoundError, RunOverloadedError, RunTerminalError, StartRunConflictError, } from '../runtime.js';
|
|
4
4
|
export class RequestBodyError extends Data.TaggedError('RequestBodyError') {
|
|
5
5
|
constructor(cause) {
|
|
@@ -57,7 +57,9 @@ export function toErrorResponse(err) {
|
|
|
57
57
|
if (err instanceof RequestBodyError || err instanceof RequestQueryError) {
|
|
58
58
|
return Response.json({ error: err.message }, { status: 400 });
|
|
59
59
|
}
|
|
60
|
-
if (err instanceof InvalidInputError ||
|
|
60
|
+
if (err instanceof InvalidInputError ||
|
|
61
|
+
err instanceof InvalidEventError ||
|
|
62
|
+
err instanceof InvalidRunAttributesError) {
|
|
61
63
|
return Response.json({ error: err.message, issues: err.issues }, { status: 400 });
|
|
62
64
|
}
|
|
63
65
|
if (err instanceof RunOverloadedError) {
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Effect } from 'effect';
|
|
2
|
-
import type { AnyRuntimeModule, ComposedRegistry, DefinitionResolver, EventEnvelope, EventInput, WorkerCallback, WorkerCallbackInput, DefinitionResolveError, WorkerCallbackResult, WorkerSecretsResult, EventStore, EventStoreAppendError, EventStoreError, EventStoreFencedError, EventStoreTag, EventStoreTrimCoverage, RunLauncher, RunLaunchSource, RunAttributes, SecretContext, TraceContext, EventStoreTruncationError, JsonValue, ProjectionDefinition, ReplayStep, RunState, RunSummary, SnapshotStore, SnapshotStoreError } from '@swirls/looms/core';
|
|
2
|
+
import type { AnyRuntimeModule, ComposedRegistry, DefinitionResolver, EventEnvelope, EventInput, WorkerCallback, WorkerCallbackInput, DefinitionResolveError, WorkerCallbackResult, WorkerSecretsResult, EventStore, EventStoreAppendError, EventStoreError, EventStoreFencedError, EventStoreTag, EventStoreTrimCoverage, RunLauncher, RunLaunchSource, RunAttributeFields, RunAttributes, SecretContext, TraceContext, EventStoreTruncationError, JsonValue, ProjectionDefinition, ReplayStep, RunState, RunSummary, SnapshotStore, SnapshotStoreError } from '@swirls/looms/core';
|
|
3
3
|
import type { EventStoreTrimmedError } from '@swirls/looms/core';
|
|
4
4
|
import type { DuplicateEffectDispatchError, MaxWakeIterationsError } from './errors';
|
|
5
5
|
import type { RuntimeObserver } from './observer';
|
|
@@ -57,6 +57,11 @@ export interface CreateRuntimeOptions<TModules extends readonly AnyRuntimeModule
|
|
|
57
57
|
readonly worker?: EffectWorker;
|
|
58
58
|
/** Failure-isolated, framework-neutral operational event sink. */
|
|
59
59
|
readonly observer?: RuntimeObserver;
|
|
60
|
+
/**
|
|
61
|
+
* Declared run attributes. When set, a start that misses a `required` attribute or sends an
|
|
62
|
+
* undeclared one fails with `InvalidRunAttributesError` and writes no events.
|
|
63
|
+
*/
|
|
64
|
+
readonly attributes?: RunAttributeFields;
|
|
60
65
|
}
|
|
61
66
|
export interface EffectWorkerTask {
|
|
62
67
|
readonly runId: string;
|