@swirls/looms 0.10.0 → 0.11.1
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 +32 -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/effects.d.ts +256 -256
- package/dist/agent/module.d.ts +512 -512
- package/dist/agent/signals.d.ts +6 -2
- package/dist/agent/signals.js +7 -3
- package/dist/agent/threads.js +3 -0
- 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-BPu-NBr5.js} +2 -2
- package/dist/debugger/app/assets/{routes-lvmllT60.js → routes-FLQryDcz.js} +3 -3
- 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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readdir, readFile, writeFile, mkdir } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { Predicate } from 'effect';
|
|
4
|
-
import {
|
|
4
|
+
import { columnMigrations, sqlStringLiteral, } from './columns.js';
|
|
5
|
+
import { sqliteReplicaMigrations } from './sqlite-migrations.js';
|
|
5
6
|
/**
|
|
6
7
|
* Actors and reviews. Same statements the Postgres index projector has always
|
|
7
8
|
* applied, so a database created by an older Looms keeps working.
|
|
@@ -76,9 +77,6 @@ CREATE TABLE IF NOT EXISTS looms_run_index (
|
|
|
76
77
|
launched_by_effect_id TEXT,
|
|
77
78
|
correlation_id TEXT,
|
|
78
79
|
attributes JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
79
|
-
tenant TEXT,
|
|
80
|
-
project TEXT,
|
|
81
|
-
org TEXT,
|
|
82
80
|
started_at TIMESTAMPTZ,
|
|
83
81
|
updated_at TIMESTAMPTZ NOT NULL,
|
|
84
82
|
completed_at TIMESTAMPTZ,
|
|
@@ -89,13 +87,11 @@ CREATE TABLE IF NOT EXISTS looms_run_index (
|
|
|
89
87
|
ALTER TABLE looms_run_index ADD COLUMN IF NOT EXISTS replicated_seq BIGINT NOT NULL DEFAULT 0;
|
|
90
88
|
ALTER TABLE looms_run_index ADD COLUMN IF NOT EXISTS purged_at TIMESTAMPTZ;
|
|
91
89
|
|
|
92
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_tenant ON looms_run_index (tenant);
|
|
93
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_project ON looms_run_index (project);
|
|
94
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_org ON looms_run_index (org);
|
|
95
90
|
CREATE INDEX IF NOT EXISTS looms_run_index_parent ON looms_run_index (parent_run_id);
|
|
96
91
|
CREATE INDEX IF NOT EXISTS looms_run_index_status ON looms_run_index (status);
|
|
97
92
|
`.trim();
|
|
98
|
-
|
|
93
|
+
/** Tracks applied Looms migrations, including attribute column migrations. */
|
|
94
|
+
export const POSTGRES_SCHEMA_MIGRATIONS_SQL = `
|
|
99
95
|
CREATE TABLE IF NOT EXISTS looms_schema_migrations (
|
|
100
96
|
id TEXT PRIMARY KEY,
|
|
101
97
|
applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
@@ -110,14 +106,66 @@ function replicaMigration(id, statements) {
|
|
|
110
106
|
].join('\n\n'),
|
|
111
107
|
};
|
|
112
108
|
}
|
|
113
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Adds one attribute column and copies it from `attributes` for runs already in the table.
|
|
111
|
+
* Safe to repeat: the backfill only touches rows that have the attribute and an empty column.
|
|
112
|
+
*/
|
|
113
|
+
export function postgresColumnSql(column) {
|
|
114
|
+
const name = `"${column.name}"`;
|
|
115
|
+
const attribute = sqlStringLiteral(column.key);
|
|
116
|
+
return `
|
|
117
|
+
ALTER TABLE looms_run_index ADD COLUMN IF NOT EXISTS ${name} TEXT;
|
|
118
|
+
|
|
119
|
+
UPDATE looms_run_index SET ${name} = attributes ->> ${attribute}
|
|
120
|
+
WHERE ${name} IS NULL AND attributes ? ${attribute};
|
|
121
|
+
`.trim();
|
|
122
|
+
}
|
|
123
|
+
export function postgresColumnIndexSql(column) {
|
|
124
|
+
return `CREATE INDEX IF NOT EXISTS looms_run_index_${column.name} ON looms_run_index ("${column.name}");`;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Attribute column and index migrations for Postgres.
|
|
128
|
+
* Each runs once when recorded in `looms_schema_migrations`, including the backfill UPDATE.
|
|
129
|
+
*/
|
|
130
|
+
export function postgresAttributeMigrations(additionalFields) {
|
|
131
|
+
return columnMigrations(additionalFields, (id, sql) => replicaMigration(id, [sql]), postgresColumnSql, postgresColumnIndexSql);
|
|
132
|
+
}
|
|
133
|
+
/** Serializes Looms migrations across processes that share one database. */
|
|
134
|
+
const MIGRATION_LOCK_KEY = 814_764;
|
|
135
|
+
/** Ids recorded in `looms_schema_migrations`, or none when the table does not exist yet. */
|
|
136
|
+
export async function appliedPostgresMigrationIds(sql) {
|
|
137
|
+
const [table] = await sql `
|
|
138
|
+
SELECT to_regclass('public.looms_schema_migrations') AS name
|
|
139
|
+
`;
|
|
140
|
+
if (!table?.name) {
|
|
141
|
+
return new Set();
|
|
142
|
+
}
|
|
143
|
+
const rows = await sql `SELECT id FROM looms_schema_migrations`;
|
|
144
|
+
return new Set(rows.map((row) => row.id));
|
|
145
|
+
}
|
|
146
|
+
/** Applies each migration that is not recorded yet, in order, under one advisory lock. */
|
|
147
|
+
export async function applyPostgresMigrations(sql, migrations) {
|
|
148
|
+
await sql.begin(async (tx) => {
|
|
149
|
+
await tx `SELECT pg_advisory_xact_lock(${MIGRATION_LOCK_KEY})`;
|
|
150
|
+
const applied = await appliedPostgresMigrationIds(tx);
|
|
151
|
+
for (const migration of migrations) {
|
|
152
|
+
if (!applied.has(migration.id)) {
|
|
153
|
+
await tx.unsafe(migration.sql);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** Versioned DDL for the Postgres replica with no attribute columns. Looms only creates and alters `looms_*` objects. */
|
|
114
159
|
export const POSTGRES_REPLICA_MIGRATIONS = [
|
|
115
160
|
replicaMigration('0001_replica', [
|
|
116
161
|
POSTGRES_SCHEMA_SQL,
|
|
117
162
|
POSTGRES_EVENT_LOG_SCHEMA_SQL,
|
|
118
|
-
|
|
163
|
+
POSTGRES_SCHEMA_MIGRATIONS_SQL,
|
|
119
164
|
]),
|
|
120
165
|
];
|
|
166
|
+
export function postgresReplicaMigrations(additionalFields) {
|
|
167
|
+
return [...POSTGRES_REPLICA_MIGRATIONS, ...postgresAttributeMigrations(additionalFields)];
|
|
168
|
+
}
|
|
121
169
|
const MIGRATION_HEADER = /^-- looms-migration:\s+(\S+)/m;
|
|
122
170
|
async function recordedMigrationIds(directory) {
|
|
123
171
|
let names;
|
|
@@ -201,12 +249,12 @@ async function appendDrizzleJournal(directory, tags) {
|
|
|
201
249
|
* A file counts as applied when it contains `-- looms-migration: <id>`.
|
|
202
250
|
* The numeric prefix continues after the highest `NNNN_` file already in `out`.
|
|
203
251
|
*/
|
|
204
|
-
function migrationsFor(dialect) {
|
|
252
|
+
function migrationsFor(dialect, additionalFields) {
|
|
205
253
|
switch (dialect) {
|
|
206
254
|
case 'postgres':
|
|
207
|
-
return
|
|
255
|
+
return postgresReplicaMigrations(additionalFields);
|
|
208
256
|
case 'sqlite':
|
|
209
|
-
return
|
|
257
|
+
return sqliteReplicaMigrations(additionalFields);
|
|
210
258
|
default: {
|
|
211
259
|
const unexpected = dialect;
|
|
212
260
|
return unexpected;
|
|
@@ -219,7 +267,7 @@ export async function generateReplicaMigrations(options) {
|
|
|
219
267
|
throw new Error('Drizzle journal output is only supported for the Postgres replica.');
|
|
220
268
|
}
|
|
221
269
|
const recorded = await recordedMigrationIds(options.out);
|
|
222
|
-
const pending = migrationsFor(dialect).filter((migration) => !recorded.has(migration.id));
|
|
270
|
+
const pending = migrationsFor(dialect, options.additionalFields).filter((migration) => !recorded.has(migration.id));
|
|
223
271
|
if (options.check || pending.length === 0) {
|
|
224
272
|
return { written: [], pending: pending.map((migration) => migration.id) };
|
|
225
273
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type Sql } from 'postgres';
|
|
2
|
-
import { type EventStore, type FoldRegistry, type RunState } from '@swirls/looms/core';
|
|
2
|
+
import { type EventStore, type FoldRegistry, type RunAttributeFields, type RunState } from '@swirls/looms/core';
|
|
3
3
|
import { ReplicaGapError, type Projector } from '../projector';
|
|
4
|
+
import { type NoAdditionalFields, type ReplicaPurgeOptions } from './columns';
|
|
5
|
+
export type { NoAdditionalFields, ReplicaPurgeOptions } from './columns';
|
|
4
6
|
export interface ReplicaStatus {
|
|
5
7
|
/** Highest sequence copied with no hole in front of it. */
|
|
6
8
|
readonly replicatedSeq: number;
|
|
@@ -11,17 +13,11 @@ export interface ReplicaStatus {
|
|
|
11
13
|
/** Set once retention has deleted the event copy. */
|
|
12
14
|
readonly purgedAt: number | null;
|
|
13
15
|
}
|
|
14
|
-
export interface ReplicaPurgeOptions {
|
|
15
|
-
/** Delete event copies for runs that finished before this epoch millisecond. */
|
|
16
|
-
readonly finishedBefore: number;
|
|
17
|
-
/** Keep the run summary row. Defaults to true. */
|
|
18
|
-
readonly keepIndex?: boolean;
|
|
19
|
-
}
|
|
20
16
|
export interface ReplicaPurgeResult {
|
|
21
17
|
readonly runs: number;
|
|
22
18
|
}
|
|
23
19
|
export type PostgresReplicaMigrate = 'auto' | 'verify';
|
|
24
|
-
export type PostgresReplicaOptions = ({
|
|
20
|
+
export type PostgresReplicaOptions<Fields extends RunAttributeFields = NoAdditionalFields> = ({
|
|
25
21
|
readonly url: string;
|
|
26
22
|
} | {
|
|
27
23
|
readonly sql: Sql;
|
|
@@ -32,12 +28,17 @@ export type PostgresReplicaOptions = ({
|
|
|
32
28
|
* `looms replica generate` so the host can commit the SQL.
|
|
33
29
|
*/
|
|
34
30
|
readonly migrate: PostgresReplicaMigrate;
|
|
31
|
+
/**
|
|
32
|
+
* Declared run attributes, from `defineRunAttributes`. Each one is a `looms_run_index`
|
|
33
|
+
* column, and each column and index is its own migration. `purge({ where })` filters on them.
|
|
34
|
+
*/
|
|
35
|
+
readonly additionalFields?: Fields;
|
|
35
36
|
};
|
|
36
37
|
/**
|
|
37
38
|
* A complete, gap-checked copy of every run, plus the run summary folded in the same transaction.
|
|
38
39
|
* Reading an event back returns the envelope the source returned.
|
|
39
40
|
*/
|
|
40
|
-
export interface PostgresReplica extends Projector {
|
|
41
|
+
export interface PostgresReplica<Fields extends RunAttributeFields = NoAdditionalFields> extends Projector {
|
|
41
42
|
readonly position: (runId: string) => Promise<number | null>;
|
|
42
43
|
/** Apply pending migrations. `init` does this only when `migrate` is `auto`. */
|
|
43
44
|
readonly migrate: () => Promise<void>;
|
|
@@ -49,9 +50,9 @@ export interface PostgresReplica extends Projector {
|
|
|
49
50
|
/** How far the copy has got, and whether it is safe to treat as complete. */
|
|
50
51
|
readonly status: (runId: string) => Promise<ReplicaStatus | null>;
|
|
51
52
|
/** Delete event copies for finished runs. Later deliveries for those runs are skipped. */
|
|
52
|
-
readonly purge: (options: ReplicaPurgeOptions) => Promise<ReplicaPurgeResult>;
|
|
53
|
+
readonly purge: (options: ReplicaPurgeOptions<Fields>) => Promise<ReplicaPurgeResult>;
|
|
53
54
|
/** Copy every run in `source`. Purged runs are left alone. */
|
|
54
55
|
readonly rebuild: (source: EventStore) => Promise<number>;
|
|
55
56
|
}
|
|
56
|
-
export declare function postgresReplica(options: PostgresReplicaOptions): PostgresReplica
|
|
57
|
+
export declare function postgresReplica<const Fields extends RunAttributeFields = NoAdditionalFields>(options: PostgresReplicaOptions<Fields>): PostgresReplica<Fields>;
|
|
57
58
|
export { ReplicaGapError };
|
|
@@ -5,10 +5,10 @@ import { applyRunIndexOps, eventLogOps, insertRunEvents } from '../event-log.js'
|
|
|
5
5
|
import { indexOpsFor } from '../index-model.js';
|
|
6
6
|
import { applyIndexOps } from '../postgres.js';
|
|
7
7
|
import { ReplicaGapError } from '../projector.js';
|
|
8
|
-
import {
|
|
8
|
+
import { purgeFilters, resolveReplicaColumns, } from './columns.js';
|
|
9
|
+
import { appliedPostgresMigrationIds, applyPostgresMigrations, postgresReplicaMigrations, } from './migrations.js';
|
|
9
10
|
const REPLICA_NAME = 'postgres-replica';
|
|
10
11
|
const REPLICA_VERSION = '1';
|
|
11
|
-
const ADVISORY_LOCK_KEY = 814_764;
|
|
12
12
|
const READ_PAGE = 500;
|
|
13
13
|
const terminalStatuses = new Set(['completed', 'failed', 'cancelled']);
|
|
14
14
|
function replicaClient(options) {
|
|
@@ -92,16 +92,6 @@ function contiguousSeq(runId, replicatedSeq, events) {
|
|
|
92
92
|
}
|
|
93
93
|
return cursor;
|
|
94
94
|
}
|
|
95
|
-
async function appliedMigrationIds(sql) {
|
|
96
|
-
const [table] = await sql `
|
|
97
|
-
SELECT to_regclass('public.looms_schema_migrations') AS name
|
|
98
|
-
`;
|
|
99
|
-
if (!table?.name) {
|
|
100
|
-
return new Set();
|
|
101
|
-
}
|
|
102
|
-
const rows = await sql `SELECT id FROM looms_schema_migrations`;
|
|
103
|
-
return new Set(rows.map((row) => row.id));
|
|
104
|
-
}
|
|
105
95
|
async function readPage(sql, runId, fromSeq, limit) {
|
|
106
96
|
const rows = await sql `
|
|
107
97
|
SELECT run_id, seq, event_id, ts, type, payload, thread_id, parent_thread_id,
|
|
@@ -114,23 +104,17 @@ async function readPage(sql, runId, fromSeq, limit) {
|
|
|
114
104
|
return rows.map(envelope);
|
|
115
105
|
}
|
|
116
106
|
export function postgresReplica(options) {
|
|
107
|
+
const columns = resolveReplicaColumns(options.additionalFields);
|
|
108
|
+
const migrations = postgresReplicaMigrations(options.additionalFields);
|
|
117
109
|
const { sql, owned } = replicaClient(options);
|
|
118
110
|
let ready;
|
|
119
111
|
const pendingMigrations = async () => {
|
|
120
|
-
const applied = await
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
await sql.begin(async (tx) => {
|
|
125
|
-
await tx `SELECT pg_advisory_xact_lock(${ADVISORY_LOCK_KEY})`;
|
|
126
|
-
const applied = await appliedMigrationIds(tx);
|
|
127
|
-
for (const migration of POSTGRES_REPLICA_MIGRATIONS) {
|
|
128
|
-
if (!applied.has(migration.id)) {
|
|
129
|
-
await tx.unsafe(migration.sql);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
112
|
+
const applied = await appliedPostgresMigrationIds(sql);
|
|
113
|
+
return migrations
|
|
114
|
+
.filter((migration) => !applied.has(migration.id))
|
|
115
|
+
.map((migration) => migration.id);
|
|
133
116
|
};
|
|
117
|
+
const migrate = () => applyPostgresMigrations(sql, migrations);
|
|
134
118
|
const init = () => {
|
|
135
119
|
ready ??= (options.migrate === 'verify' ? verify() : migrate()).catch((cause) => {
|
|
136
120
|
ready = undefined;
|
|
@@ -165,7 +149,7 @@ export function postgresReplica(options) {
|
|
|
165
149
|
const durable = batch.filter((event) => !event.ephemeral);
|
|
166
150
|
const last = batch.at(-1);
|
|
167
151
|
await insertRunEvents(tx, batch);
|
|
168
|
-
await applyRunIndexOps(tx, durable.flatMap((event) => eventLogOps(event)));
|
|
152
|
+
await applyRunIndexOps(tx, durable.flatMap((event) => eventLogOps(event)), columns);
|
|
169
153
|
await applyIndexOps(tx, durable.flatMap(indexOpsFor));
|
|
170
154
|
if (next === replicatedSeq || !last) {
|
|
171
155
|
continue;
|
|
@@ -292,6 +276,7 @@ export function postgresReplica(options) {
|
|
|
292
276
|
const purge = async (purgeOptions) => {
|
|
293
277
|
const cutoff = utcDate(purgeOptions.finishedBefore);
|
|
294
278
|
const keepIndex = purgeOptions.keepIndex !== false;
|
|
279
|
+
const filters = purgeFilters(columns, purgeOptions.where);
|
|
295
280
|
return sql.begin(async (tx) => {
|
|
296
281
|
const doomed = await tx `
|
|
297
282
|
UPDATE looms_run_index
|
|
@@ -300,6 +285,7 @@ export function postgresReplica(options) {
|
|
|
300
285
|
AND status IN ('completed', 'failed', 'cancelled')
|
|
301
286
|
AND completed_at IS NOT NULL
|
|
302
287
|
AND completed_at < ${cutoff}
|
|
288
|
+
${filters.reduce((clause, filter) => tx `${clause} AND ${tx(filter.column)} = ${filter.value}`, tx ``)}
|
|
303
289
|
RETURNING run_id
|
|
304
290
|
`;
|
|
305
291
|
const ids = doomed.map((row) => row.run_id);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Database } from 'bun:sqlite';
|
|
2
|
+
import type { RunAttributeFields } from '@swirls/looms/core';
|
|
3
|
+
import type { NoAdditionalFields } from './columns';
|
|
2
4
|
import { type SqliteReplica, type SqliteReplicaDatabase, type SqliteReplicaMigrate } from './sqlite';
|
|
3
5
|
/** Opens a SQLite file. The replica closes it on `dispose`. */
|
|
4
|
-
export declare function openSqliteReplicaFile(filename: string, migrate: SqliteReplicaMigrate): SqliteReplica
|
|
6
|
+
export declare function openSqliteReplicaFile<const Fields extends RunAttributeFields = NoAdditionalFields>(filename: string, migrate: SqliteReplicaMigrate, additionalFields?: Fields): SqliteReplica<Fields>;
|
|
5
7
|
export declare function bunSqliteReplicaDatabase(db: Database): SqliteReplicaDatabase;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { Database } from 'bun:sqlite';
|
|
2
2
|
import { sqliteReplica, } from './sqlite.js';
|
|
3
3
|
/** Opens a SQLite file. The replica closes it on `dispose`. */
|
|
4
|
-
export function openSqliteReplicaFile(filename, migrate) {
|
|
4
|
+
export function openSqliteReplicaFile(filename, migrate, additionalFields) {
|
|
5
5
|
const db = new Database(filename);
|
|
6
|
-
const replica = sqliteReplica({
|
|
6
|
+
const replica = sqliteReplica({
|
|
7
|
+
database: bunSqliteReplicaDatabase(db),
|
|
8
|
+
migrate,
|
|
9
|
+
additionalFields,
|
|
10
|
+
});
|
|
7
11
|
return {
|
|
8
12
|
...replica,
|
|
9
13
|
dispose: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { RunAttributeFields } from '@swirls/looms/core';
|
|
2
|
+
import { type ReplicaMigration } from './columns';
|
|
3
|
+
/** Versioned DDL for the SQLite replica with no attribute columns, including D1. Looms only creates `looms_*` objects. */
|
|
4
|
+
export declare const SQLITE_REPLICA_MIGRATIONS: readonly ReplicaMigration[];
|
|
5
|
+
export declare function sqliteReplicaMigrations(additionalFields?: RunAttributeFields): readonly ReplicaMigration[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { columnMigrations, sqlStringLiteral, } from './columns.js';
|
|
1
2
|
/**
|
|
2
3
|
* Same tables as the Postgres replica, in SQLite types.
|
|
3
4
|
* Timestamps are epoch milliseconds. JSON is text. Booleans are 0 or 1.
|
|
4
5
|
* A fresh database gets every column from `CREATE TABLE`. SQLite has no
|
|
5
|
-
* `ADD COLUMN IF NOT EXISTS
|
|
6
|
-
* add columns the way the index projector does: read `PRAGMA table_info` first.
|
|
6
|
+
* `ADD COLUMN IF NOT EXISTS`, so an attribute column is added once, by its own migration.
|
|
7
7
|
*/
|
|
8
8
|
const SQLITE_REPLICA_SCHEMA_SQL = `
|
|
9
9
|
CREATE TABLE IF NOT EXISTS looms_run_actors (
|
|
@@ -63,9 +63,6 @@ CREATE TABLE IF NOT EXISTS looms_run_index (
|
|
|
63
63
|
launched_by_effect_id TEXT,
|
|
64
64
|
correlation_id TEXT,
|
|
65
65
|
attributes TEXT NOT NULL DEFAULT '{}',
|
|
66
|
-
tenant TEXT,
|
|
67
|
-
project TEXT,
|
|
68
|
-
org TEXT,
|
|
69
66
|
started_at INTEGER,
|
|
70
67
|
updated_at INTEGER NOT NULL,
|
|
71
68
|
completed_at INTEGER,
|
|
@@ -73,9 +70,6 @@ CREATE TABLE IF NOT EXISTS looms_run_index (
|
|
|
73
70
|
purged_at INTEGER
|
|
74
71
|
);
|
|
75
72
|
|
|
76
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_tenant ON looms_run_index (tenant);
|
|
77
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_project ON looms_run_index (project);
|
|
78
|
-
CREATE INDEX IF NOT EXISTS looms_run_index_org ON looms_run_index (org);
|
|
79
73
|
CREATE INDEX IF NOT EXISTS looms_run_index_parent ON looms_run_index (parent_run_id);
|
|
80
74
|
CREATE INDEX IF NOT EXISTS looms_run_index_status ON looms_run_index (status);
|
|
81
75
|
|
|
@@ -93,7 +87,26 @@ function sqliteReplicaMigration(id, sql) {
|
|
|
93
87
|
].join('\n\n'),
|
|
94
88
|
};
|
|
95
89
|
}
|
|
96
|
-
|
|
90
|
+
function sqliteColumnSql(column) {
|
|
91
|
+
const name = `"${column.name}"`;
|
|
92
|
+
const value = `(SELECT value FROM json_each(looms_run_index.attributes) WHERE key = ${sqlStringLiteral(column.key)})`;
|
|
93
|
+
return `
|
|
94
|
+
ALTER TABLE looms_run_index ADD COLUMN ${name} TEXT;
|
|
95
|
+
|
|
96
|
+
UPDATE looms_run_index SET ${name} = ${value}
|
|
97
|
+
WHERE ${name} IS NULL AND ${value} IS NOT NULL;
|
|
98
|
+
`.trim();
|
|
99
|
+
}
|
|
100
|
+
function sqliteColumnIndexSql(column) {
|
|
101
|
+
return `CREATE INDEX IF NOT EXISTS looms_run_index_${column.name} ON looms_run_index ("${column.name}");`;
|
|
102
|
+
}
|
|
103
|
+
/** Versioned DDL for the SQLite replica with no attribute columns, including D1. Looms only creates `looms_*` objects. */
|
|
97
104
|
export const SQLITE_REPLICA_MIGRATIONS = [
|
|
98
105
|
sqliteReplicaMigration('0001_replica', SQLITE_REPLICA_SCHEMA_SQL),
|
|
99
106
|
];
|
|
107
|
+
export function sqliteReplicaMigrations(additionalFields) {
|
|
108
|
+
return [
|
|
109
|
+
...SQLITE_REPLICA_MIGRATIONS,
|
|
110
|
+
...columnMigrations(additionalFields, sqliteReplicaMigration, sqliteColumnSql, sqliteColumnIndexSql),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type EventStore, type FoldRegistry, type RunState } from '@swirls/looms/core';
|
|
1
|
+
import { type EventStore, type FoldRegistry, type RunAttributeFields, type RunState } from '@swirls/looms/core';
|
|
2
2
|
import { ReplicaGapError, type Projector } from '../projector';
|
|
3
|
+
import { type NoAdditionalFields, type ReplicaPurgeOptions } from './columns';
|
|
4
|
+
export type { NoAdditionalFields, ReplicaPurgeOptions } from './columns';
|
|
3
5
|
export interface ReplicaStatus {
|
|
4
6
|
/** Highest sequence copied with no hole in front of it. */
|
|
5
7
|
readonly replicatedSeq: number;
|
|
@@ -10,12 +12,6 @@ export interface ReplicaStatus {
|
|
|
10
12
|
/** Set once retention has deleted the event copy. */
|
|
11
13
|
readonly purgedAt: number | null;
|
|
12
14
|
}
|
|
13
|
-
export interface ReplicaPurgeOptions {
|
|
14
|
-
/** Delete event copies for runs that finished before this epoch millisecond. */
|
|
15
|
-
readonly finishedBefore: number;
|
|
16
|
-
/** Keep the run summary row. Defaults to true. */
|
|
17
|
-
readonly keepIndex?: boolean;
|
|
18
|
-
}
|
|
19
15
|
export interface ReplicaPurgeResult {
|
|
20
16
|
readonly runs: number;
|
|
21
17
|
}
|
|
@@ -46,7 +42,7 @@ export interface D1BoundStatement {
|
|
|
46
42
|
}>;
|
|
47
43
|
first<T>(): Promise<T | null>;
|
|
48
44
|
}
|
|
49
|
-
export type SqliteReplicaOptions = {
|
|
45
|
+
export type SqliteReplicaOptions<Fields extends RunAttributeFields = NoAdditionalFields> = {
|
|
50
46
|
readonly database: SqliteReplicaDatabase;
|
|
51
47
|
/**
|
|
52
48
|
* `auto` applies pending migrations on init.
|
|
@@ -54,6 +50,11 @@ export type SqliteReplicaOptions = {
|
|
|
54
50
|
* `looms replica generate --dialect sqlite` so the host can commit the SQL.
|
|
55
51
|
*/
|
|
56
52
|
readonly migrate: SqliteReplicaMigrate;
|
|
53
|
+
/**
|
|
54
|
+
* Declared run attributes, from `defineRunAttributes`. Each one is a `looms_run_index`
|
|
55
|
+
* column, and each column and index is its own migration. `purge({ where })` filters on them.
|
|
56
|
+
*/
|
|
57
|
+
readonly additionalFields?: Fields;
|
|
57
58
|
};
|
|
58
59
|
/**
|
|
59
60
|
* Adapts Cloudflare D1.
|
|
@@ -75,7 +76,7 @@ export declare function d1ReplicaDatabase<Statement extends D1BoundStatement>(d1
|
|
|
75
76
|
* Reading an event back returns the envelope the source returned.
|
|
76
77
|
* Targets a shared SQLite database or D1, not the per-run actor store.
|
|
77
78
|
*/
|
|
78
|
-
export interface SqliteReplica extends Projector {
|
|
79
|
+
export interface SqliteReplica<Fields extends RunAttributeFields = NoAdditionalFields> extends Projector {
|
|
79
80
|
readonly position: (runId: string) => Promise<number | null>;
|
|
80
81
|
/** Apply pending migrations. `init` does this only when `migrate` is `auto`. */
|
|
81
82
|
readonly migrate: () => Promise<void>;
|
|
@@ -87,9 +88,9 @@ export interface SqliteReplica extends Projector {
|
|
|
87
88
|
/** How far the copy has got, and whether it is safe to treat as complete. */
|
|
88
89
|
readonly status: (runId: string) => Promise<ReplicaStatus | null>;
|
|
89
90
|
/** Delete event copies for finished runs. Later deliveries for those runs are skipped. */
|
|
90
|
-
readonly purge: (options: ReplicaPurgeOptions) => Promise<ReplicaPurgeResult>;
|
|
91
|
+
readonly purge: (options: ReplicaPurgeOptions<Fields>) => Promise<ReplicaPurgeResult>;
|
|
91
92
|
/** Copy every run in `source`. Purged runs are left alone. */
|
|
92
93
|
readonly rebuild: (source: EventStore) => Promise<number>;
|
|
93
94
|
}
|
|
94
|
-
export declare function sqliteReplica(options: SqliteReplicaOptions): SqliteReplica
|
|
95
|
+
export declare function sqliteReplica<const Fields extends RunAttributeFields = NoAdditionalFields>(options: SqliteReplicaOptions<Fields>): SqliteReplica<Fields>;
|
|
95
96
|
export { ReplicaGapError };
|
|
@@ -3,7 +3,8 @@ import { EventOriginSchema, EventStoreError, JsonValueSchema, foldRun, } from '@
|
|
|
3
3
|
import { eventLogOps } from '../event-log-ops.js';
|
|
4
4
|
import { indexOpsFor } from '../index-model.js';
|
|
5
5
|
import { ReplicaGapError } from '../projector.js';
|
|
6
|
-
import {
|
|
6
|
+
import { columnValues, purgeFilters, resolveReplicaColumns, } from './columns.js';
|
|
7
|
+
import { sqliteReplicaMigrations } from './sqlite-migrations.js';
|
|
7
8
|
const REPLICA_NAME = 'sqlite-replica';
|
|
8
9
|
const REPLICA_VERSION = '1';
|
|
9
10
|
const READ_PAGE = 500;
|
|
@@ -176,13 +177,15 @@ function runIndexPatches(ops) {
|
|
|
176
177
|
}
|
|
177
178
|
return [...patches.values()];
|
|
178
179
|
}
|
|
179
|
-
function upsertRun(patch) {
|
|
180
|
+
function upsertRun(patch, columns) {
|
|
180
181
|
const start = patch.start;
|
|
182
|
+
const hostNames = columns.map((column) => `"${column.name}"`);
|
|
183
|
+
const hostSet = hostNames.map((name) => `${name} = COALESCE(looms_run_index.${name}, excluded.${name}),`);
|
|
181
184
|
return sqlStatement(`INSERT INTO looms_run_index (
|
|
182
185
|
run_id, status, kind, definition_name, definition_version, root_thread_id,
|
|
183
186
|
parent_run_id, launched_by_effect_id, correlation_id, attributes,
|
|
184
|
-
|
|
185
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
|
187
|
+
started_at, updated_at, completed_at${hostNames.map((name) => `, ${name}`).join('')}
|
|
188
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?${', ?'.repeat(columns.length)})
|
|
186
189
|
ON CONFLICT (run_id) DO UPDATE SET
|
|
187
190
|
status = CASE
|
|
188
191
|
WHEN excluded.completed_at IS NOT NULL THEN excluded.status
|
|
@@ -200,9 +203,7 @@ function upsertRun(patch) {
|
|
|
200
203
|
WHEN looms_run_index.attributes = '{}' THEN excluded.attributes
|
|
201
204
|
ELSE looms_run_index.attributes
|
|
202
205
|
END,
|
|
203
|
-
|
|
204
|
-
project = COALESCE(looms_run_index.project, excluded.project),
|
|
205
|
-
org = COALESCE(looms_run_index.org, excluded.org),
|
|
206
|
+
${hostSet.join('\n ')}
|
|
206
207
|
started_at = COALESCE(looms_run_index.started_at, excluded.started_at),
|
|
207
208
|
updated_at = MAX(looms_run_index.updated_at, excluded.updated_at),
|
|
208
209
|
completed_at = COALESCE(looms_run_index.completed_at, excluded.completed_at)`, [
|
|
@@ -216,19 +217,17 @@ function upsertRun(patch) {
|
|
|
216
217
|
start?.launchedByEffectId ?? null,
|
|
217
218
|
start?.correlationId ?? null,
|
|
218
219
|
jsonText(start?.attributes ?? {}),
|
|
219
|
-
start?.tenant ?? null,
|
|
220
|
-
start?.project ?? null,
|
|
221
|
-
start?.org ?? null,
|
|
222
220
|
start ? start.at : null,
|
|
223
221
|
patch.updatedAt,
|
|
224
222
|
patch.completedAt,
|
|
223
|
+
...columnValues(columns, start?.attributes),
|
|
225
224
|
]);
|
|
226
225
|
}
|
|
227
|
-
function runIndexStatements(ops) {
|
|
226
|
+
function runIndexStatements(ops, columns) {
|
|
228
227
|
const statements = [];
|
|
229
228
|
for (const patch of runIndexPatches(ops)) {
|
|
230
229
|
if (patch.start || patch.finish) {
|
|
231
|
-
statements.push(upsertRun(patch));
|
|
230
|
+
statements.push(upsertRun(patch, columns));
|
|
232
231
|
continue;
|
|
233
232
|
}
|
|
234
233
|
statements.push(sqlStatement(`UPDATE looms_run_index SET updated_at = MAX(updated_at, ?) WHERE run_id = ?`, [
|
|
@@ -289,6 +288,8 @@ function indexStatements(ops) {
|
|
|
289
288
|
}
|
|
290
289
|
export function sqliteReplica(options) {
|
|
291
290
|
const database = options.database;
|
|
291
|
+
const columns = resolveReplicaColumns(options.additionalFields);
|
|
292
|
+
const migrations = sqliteReplicaMigrations(options.additionalFields);
|
|
292
293
|
let ready;
|
|
293
294
|
const appliedMigrationIds = async () => {
|
|
294
295
|
const table = await database.get(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'looms_schema_migrations'`);
|
|
@@ -300,11 +301,13 @@ export function sqliteReplica(options) {
|
|
|
300
301
|
};
|
|
301
302
|
const pendingMigrations = async () => {
|
|
302
303
|
const applied = await appliedMigrationIds();
|
|
303
|
-
return
|
|
304
|
+
return migrations
|
|
305
|
+
.filter((migration) => !applied.has(migration.id))
|
|
306
|
+
.map((migration) => migration.id);
|
|
304
307
|
};
|
|
305
308
|
const migrate = async () => {
|
|
306
309
|
const applied = await appliedMigrationIds();
|
|
307
|
-
for (const migration of
|
|
310
|
+
for (const migration of migrations) {
|
|
308
311
|
if (!applied.has(migration.id)) {
|
|
309
312
|
await database.exec(migration.sql);
|
|
310
313
|
}
|
|
@@ -339,7 +342,7 @@ export function sqliteReplica(options) {
|
|
|
339
342
|
const durable = batch.filter((event) => !event.ephemeral);
|
|
340
343
|
const last = batch.at(-1);
|
|
341
344
|
statements.push(...insertEvents(batch));
|
|
342
|
-
statements.push(...runIndexStatements(durable.flatMap((event) => eventLogOps(event))));
|
|
345
|
+
statements.push(...runIndexStatements(durable.flatMap((event) => eventLogOps(event)), columns));
|
|
343
346
|
statements.push(...indexStatements(durable.flatMap(indexOpsFor)));
|
|
344
347
|
if (next === replicatedSeq || !last) {
|
|
345
348
|
continue;
|
|
@@ -458,11 +461,15 @@ export function sqliteReplica(options) {
|
|
|
458
461
|
};
|
|
459
462
|
const purge = async (purgeOptions) => {
|
|
460
463
|
const keepIndex = purgeOptions.keepIndex !== false;
|
|
464
|
+
const filters = purgeFilters(columns, purgeOptions.where);
|
|
465
|
+
const filterSql = filters.map((filter) => `AND "${filter.column}" = ?`).join(' ');
|
|
466
|
+
const filterParams = filters.map((filter) => filter.value);
|
|
461
467
|
const doomed = await database.all(`SELECT run_id FROM looms_run_index
|
|
462
468
|
WHERE purged_at IS NULL
|
|
463
469
|
AND status IN ('completed', 'failed', 'cancelled')
|
|
464
470
|
AND completed_at IS NOT NULL
|
|
465
|
-
AND completed_at <
|
|
471
|
+
AND completed_at < ?
|
|
472
|
+
${filterSql}`, [purgeOptions.finishedBefore, ...filterParams]);
|
|
466
473
|
if (doomed.length === 0) {
|
|
467
474
|
return { runs: 0 };
|
|
468
475
|
}
|
package/dist/runtime/looms.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { type AnyRuntimeModule, type DebuggerHost, type DefinitionInput, type DefinitionRef, type DefinitionResolver, type EventEnvelope, type EventInput, type BlobStore, type EventStore, type EventStoreTrimCoverage, type JsonValue, type SnapshotStore, type ProjectionDefinition, type ReplayStep, type RunLauncher, type RunState } from '@swirls/looms/core';
|
|
1
|
+
import { type AnyRuntimeModule, type DebuggerHost, type DefinitionInput, type DefinitionRef, type DefinitionResolver, type EventEnvelope, type EventInput, type BlobStore, type EventStore, type EventStoreTrimCoverage, type JsonValue, type SnapshotStore, type ProjectionDefinition, type HasRequiredAttributes, type ReplayStep, type RunAttributeFields, type RunAttributesOption, type RunLauncher, type RunState } from '@swirls/looms/core';
|
|
2
2
|
import type { RuntimeObserver } from './observer';
|
|
3
3
|
import { type EffectWorker, type LoomsRuntime, type RunOperationalStatus, type StartRunArgs, type WakeScheduler, type WorkerCallbackInput, type WorkerCallbackResult } from './runtime';
|
|
4
4
|
import { type Authorize, type RunningServer } from './server';
|
|
5
|
-
export interface CreateLoomsOptions {
|
|
5
|
+
export interface CreateLoomsOptions<Fields extends RunAttributeFields = RunAttributeFields> {
|
|
6
6
|
/** Runtime modules to enable. Pass `agent()`, `workflow()`, `approval()`, and/or your own. */
|
|
7
7
|
readonly modules?: readonly AnyRuntimeModule[];
|
|
8
|
+
/**
|
|
9
|
+
* Declared run attributes, from `defineRunAttributes`. They type `attributes` on every start.
|
|
10
|
+
* A start that misses a `required` attribute or sends an undeclared one is rejected.
|
|
11
|
+
*/
|
|
12
|
+
readonly attributes?: Fields;
|
|
8
13
|
/**
|
|
9
14
|
* Loads a definition that was not registered on a module. Registered definitions are checked
|
|
10
15
|
* first. A run pins the resolved version on its start event.
|
|
@@ -64,7 +69,22 @@ export interface StartResult {
|
|
|
64
69
|
readonly threadId: string;
|
|
65
70
|
readonly state: RunState;
|
|
66
71
|
}
|
|
67
|
-
export
|
|
72
|
+
export type LoomsStartOptions<Fields extends RunAttributeFields = RunAttributeFields> = {
|
|
73
|
+
runId?: string;
|
|
74
|
+
threadId?: string;
|
|
75
|
+
idempotencyKey?: string;
|
|
76
|
+
secrets?: StartRunArgs['secrets'];
|
|
77
|
+
trace?: StartRunArgs['trace'];
|
|
78
|
+
} & RunAttributesOption<Fields>;
|
|
79
|
+
export type LoomsStartRunArgs<Fields extends RunAttributeFields = RunAttributeFields> = {
|
|
80
|
+
kind: string;
|
|
81
|
+
definitionName: string;
|
|
82
|
+
definitionVersion?: string;
|
|
83
|
+
input?: JsonValue;
|
|
84
|
+
} & LoomsStartOptions<Fields>;
|
|
85
|
+
/** `start`'s arguments after the definition. Options are required when an attribute is. */
|
|
86
|
+
export type LoomsStartArgs<TDef extends DefinitionRef, Fields extends RunAttributeFields = RunAttributeFields> = HasRequiredAttributes<Fields> extends true ? [input: DefinitionInput<TDef> | undefined, options: LoomsStartOptions<Fields>] : [input?: DefinitionInput<TDef>, options?: LoomsStartOptions<Fields>];
|
|
87
|
+
export interface Looms<Fields extends RunAttributeFields = RunAttributeFields> {
|
|
68
88
|
readonly runtime: Promise<LoomsRuntime>;
|
|
69
89
|
readonly store: Promise<EventStore>;
|
|
70
90
|
ready(): Promise<{
|
|
@@ -72,40 +92,11 @@ export interface Looms {
|
|
|
72
92
|
runtime: LoomsRuntime;
|
|
73
93
|
}>;
|
|
74
94
|
/** Start a run from a definition object; the input type follows the definition's schema. */
|
|
75
|
-
start<TDef extends DefinitionRef>(definition: TDef,
|
|
76
|
-
runId?: string;
|
|
77
|
-
threadId?: string;
|
|
78
|
-
idempotencyKey?: string;
|
|
79
|
-
attributes?: StartRunArgs['attributes'];
|
|
80
|
-
secrets?: StartRunArgs['secrets'];
|
|
81
|
-
trace?: StartRunArgs['trace'];
|
|
82
|
-
}): Promise<StartResult>;
|
|
95
|
+
start<TDef extends DefinitionRef>(definition: TDef, ...args: LoomsStartArgs<TDef, Fields>): Promise<StartResult>;
|
|
83
96
|
/** Start a run by `{ kind, definitionName }` when you only have names (HTTP bodies, CLIs). */
|
|
84
|
-
startRun(args:
|
|
85
|
-
kind: string;
|
|
86
|
-
definitionName: string;
|
|
87
|
-
definitionVersion?: string;
|
|
88
|
-
input?: JsonValue;
|
|
89
|
-
runId?: string;
|
|
90
|
-
threadId?: string;
|
|
91
|
-
idempotencyKey?: string;
|
|
92
|
-
attributes?: StartRunArgs['attributes'];
|
|
93
|
-
secrets?: StartRunArgs['secrets'];
|
|
94
|
-
trace?: StartRunArgs['trace'];
|
|
95
|
-
}): Promise<StartResult>;
|
|
97
|
+
startRun(args: LoomsStartRunArgs<Fields>): Promise<StartResult>;
|
|
96
98
|
/** Commit a run's start and schedule a wake without waiting for it. */
|
|
97
|
-
launchRun(args:
|
|
98
|
-
kind: string;
|
|
99
|
-
definitionName: string;
|
|
100
|
-
definitionVersion?: string;
|
|
101
|
-
input?: JsonValue;
|
|
102
|
-
runId?: string;
|
|
103
|
-
threadId?: string;
|
|
104
|
-
idempotencyKey?: string;
|
|
105
|
-
attributes?: StartRunArgs['attributes'];
|
|
106
|
-
secrets?: StartRunArgs['secrets'];
|
|
107
|
-
trace?: StartRunArgs['trace'];
|
|
108
|
-
}): Promise<StartResult>;
|
|
99
|
+
launchRun(args: LoomsStartRunArgs<Fields>): Promise<StartResult>;
|
|
109
100
|
getRun(runId: string): Promise<RunState>;
|
|
110
101
|
getEvents(runId: string, options?: {
|
|
111
102
|
fromSeq?: number;
|
|
@@ -135,4 +126,4 @@ export interface Looms {
|
|
|
135
126
|
}): RunningServer;
|
|
136
127
|
stop(): Promise<void>;
|
|
137
128
|
}
|
|
138
|
-
export declare function createLooms(options?: CreateLoomsOptions): Looms
|
|
129
|
+
export declare function createLooms<const Fields extends RunAttributeFields = RunAttributeFields>(options?: CreateLoomsOptions<Fields>): Looms<Fields>;
|
package/dist/runtime/looms.js
CHANGED
|
@@ -55,6 +55,7 @@ export function createLooms(options = {}) {
|
|
|
55
55
|
maxInFlightWorkerEffects: options.maxInFlightWorkerEffects,
|
|
56
56
|
observer: options.observer,
|
|
57
57
|
definitionResolver: options.definitionResolver,
|
|
58
|
+
attributes: options.attributes,
|
|
58
59
|
});
|
|
59
60
|
if (options.rescanTimers !== false) {
|
|
60
61
|
yield* runtime.rescanTimers.pipe(Effect.provideService(EventStoreTag, store), Effect.tapError(Effect.logError), Effect.ignore);
|