@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
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
1
|
+
import { type PgColumnBuilderBase, type PgTextBuilderInitial } from 'drizzle-orm/pg-core';
|
|
2
|
+
import type { RunAttributeFields } from '@swirls/looms/core';
|
|
3
|
+
import { type NoAdditionalFields } from './columns';
|
|
3
4
|
/** Column builders for `looms_run_index`. Call again for each table; do not reuse the result. */
|
|
4
5
|
export declare function loomsRunIndexColumns(): {
|
|
5
|
-
runId: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<
|
|
6
|
-
status: import("drizzle-orm").NotNull<
|
|
7
|
-
kind:
|
|
8
|
-
definitionName:
|
|
9
|
-
definitionVersion:
|
|
10
|
-
rootThreadId:
|
|
11
|
-
parentRunId:
|
|
12
|
-
launchedByEffectId:
|
|
13
|
-
correlationId:
|
|
6
|
+
runId: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<PgTextBuilderInitial<"run_id", [string, ...string[]]>>>;
|
|
7
|
+
status: import("drizzle-orm").NotNull<PgTextBuilderInitial<"status", [string, ...string[]]>>;
|
|
8
|
+
kind: PgTextBuilderInitial<"kind", [string, ...string[]]>;
|
|
9
|
+
definitionName: PgTextBuilderInitial<"definition_name", [string, ...string[]]>;
|
|
10
|
+
definitionVersion: PgTextBuilderInitial<"definition_version", [string, ...string[]]>;
|
|
11
|
+
rootThreadId: PgTextBuilderInitial<"root_thread_id", [string, ...string[]]>;
|
|
12
|
+
parentRunId: PgTextBuilderInitial<"parent_run_id", [string, ...string[]]>;
|
|
13
|
+
launchedByEffectId: PgTextBuilderInitial<"launched_by_effect_id", [string, ...string[]]>;
|
|
14
|
+
correlationId: PgTextBuilderInitial<"correlation_id", [string, ...string[]]>;
|
|
14
15
|
attributes: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm").$Type<import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"attributes">, Record<string, string>>>>;
|
|
15
|
-
tenant: import("drizzle-orm/pg-core").PgTextBuilderInitial<"tenant", [string, ...string[]]>;
|
|
16
|
-
project: import("drizzle-orm/pg-core").PgTextBuilderInitial<"project", [string, ...string[]]>;
|
|
17
|
-
org: import("drizzle-orm/pg-core").PgTextBuilderInitial<"org", [string, ...string[]]>;
|
|
18
16
|
startedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"started_at">;
|
|
19
17
|
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"updated_at">>>;
|
|
20
18
|
completedAt: import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"completed_at">;
|
|
@@ -23,43 +21,43 @@ export declare function loomsRunIndexColumns(): {
|
|
|
23
21
|
};
|
|
24
22
|
/** Column builders for `looms_run_events`. */
|
|
25
23
|
export declare function loomsRunEventsColumns(): {
|
|
26
|
-
runId: import("drizzle-orm").NotNull<
|
|
24
|
+
runId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"run_id", [string, ...string[]]>>;
|
|
27
25
|
seq: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBigInt53BuilderInitial<"seq">>;
|
|
28
|
-
eventId: import("drizzle-orm").NotNull<
|
|
26
|
+
eventId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"event_id", [string, ...string[]]>>;
|
|
29
27
|
ts: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"ts">>;
|
|
30
|
-
type: import("drizzle-orm").NotNull<
|
|
28
|
+
type: import("drizzle-orm").NotNull<PgTextBuilderInitial<"type", [string, ...string[]]>>;
|
|
31
29
|
payload: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"payload">>;
|
|
32
|
-
threadId:
|
|
33
|
-
parentThreadId:
|
|
34
|
-
causationId:
|
|
35
|
-
correlationId:
|
|
36
|
-
effectId:
|
|
30
|
+
threadId: PgTextBuilderInitial<"thread_id", [string, ...string[]]>;
|
|
31
|
+
parentThreadId: PgTextBuilderInitial<"parent_thread_id", [string, ...string[]]>;
|
|
32
|
+
causationId: PgTextBuilderInitial<"causation_id", [string, ...string[]]>;
|
|
33
|
+
correlationId: PgTextBuilderInitial<"correlation_id", [string, ...string[]]>;
|
|
34
|
+
effectId: PgTextBuilderInitial<"effect_id", [string, ...string[]]>;
|
|
37
35
|
origin: import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgJsonbBuilderInitial<"origin">>;
|
|
38
|
-
idempotencyKey:
|
|
36
|
+
idempotencyKey: PgTextBuilderInitial<"idempotency_key", [string, ...string[]]>;
|
|
39
37
|
ephemeral: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgBooleanBuilderInitial<"ephemeral">>>;
|
|
40
38
|
};
|
|
41
39
|
/** Column builders for `looms_run_actors`. */
|
|
42
40
|
export declare function loomsRunActorsColumns(): {
|
|
43
|
-
runId: import("drizzle-orm").NotNull<
|
|
44
|
-
actorId: import("drizzle-orm").NotNull<
|
|
45
|
-
kind:
|
|
46
|
-
status:
|
|
47
|
-
definitionName:
|
|
48
|
-
parentActorId:
|
|
49
|
-
launchedByRunId:
|
|
50
|
-
launchedByEffectId:
|
|
51
|
-
correlationId:
|
|
41
|
+
runId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"run_id", [string, ...string[]]>>;
|
|
42
|
+
actorId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"actor_id", [string, ...string[]]>>;
|
|
43
|
+
kind: PgTextBuilderInitial<"kind", [string, ...string[]]>;
|
|
44
|
+
status: PgTextBuilderInitial<"status", [string, ...string[]]>;
|
|
45
|
+
definitionName: PgTextBuilderInitial<"definition_name", [string, ...string[]]>;
|
|
46
|
+
parentActorId: PgTextBuilderInitial<"parent_actor_id", [string, ...string[]]>;
|
|
47
|
+
launchedByRunId: PgTextBuilderInitial<"launched_by_run_id", [string, ...string[]]>;
|
|
48
|
+
launchedByEffectId: PgTextBuilderInitial<"launched_by_effect_id", [string, ...string[]]>;
|
|
49
|
+
correlationId: PgTextBuilderInitial<"correlation_id", [string, ...string[]]>;
|
|
52
50
|
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"updated_at">>>;
|
|
53
51
|
};
|
|
54
52
|
/** Column builders for `looms_run_reviews`. */
|
|
55
53
|
export declare function loomsRunReviewsColumns(): {
|
|
56
|
-
runId: import("drizzle-orm").NotNull<
|
|
57
|
-
reviewId: import("drizzle-orm").NotNull<
|
|
58
|
-
status: import("drizzle-orm").NotNull<
|
|
59
|
-
title: import("drizzle-orm").NotNull<
|
|
54
|
+
runId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"run_id", [string, ...string[]]>>;
|
|
55
|
+
reviewId: import("drizzle-orm").NotNull<PgTextBuilderInitial<"review_id", [string, ...string[]]>>;
|
|
56
|
+
status: import("drizzle-orm").NotNull<PgTextBuilderInitial<"status", [string, ...string[]]>>;
|
|
57
|
+
title: import("drizzle-orm").NotNull<PgTextBuilderInitial<"title", [string, ...string[]]>>;
|
|
60
58
|
updatedAt: import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgTimestampBuilderInitial<"updated_at">>>;
|
|
61
59
|
};
|
|
62
|
-
export declare const loomsSchemaMigrations: PgTableWithColumns<{
|
|
60
|
+
export declare const loomsSchemaMigrations: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
63
61
|
name: "looms_schema_migrations";
|
|
64
62
|
schema: undefined;
|
|
65
63
|
columns: {
|
|
@@ -101,24 +99,34 @@ export declare const loomsSchemaMigrations: PgTableWithColumns<{
|
|
|
101
99
|
dialect: 'pg';
|
|
102
100
|
}>;
|
|
103
101
|
type RunIndexExtras = Record<string, PgColumnBuilderBase>;
|
|
104
|
-
|
|
105
|
-
type
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
/** One text column per declared attribute, keyed by attribute name. */
|
|
103
|
+
type AttributeColumnBuilders<Fields extends RunAttributeFields> = {
|
|
104
|
+
[Key in keyof Fields & string]: PgTextBuilderInitial<'', [string, ...string[]]>;
|
|
105
|
+
};
|
|
106
|
+
type RunIndexColumns<Extra extends RunIndexExtras, Fields extends RunAttributeFields> = ReturnType<typeof loomsRunIndexColumns> & AttributeColumnBuilders<Fields> & Extra;
|
|
107
|
+
export interface LoomsReplicaTablesOptions<Extra extends RunIndexExtras = Record<never, never>, Fields extends RunAttributeFields = NoAdditionalFields> {
|
|
108
|
+
/** Declared run attributes. Pass the same declaration the replica uses. */
|
|
109
|
+
readonly additionalFields?: Fields;
|
|
112
110
|
/** Host-owned columns on `looms_run_index`. Looms never writes these. */
|
|
113
111
|
readonly runIndex?: Extra;
|
|
114
112
|
}
|
|
115
113
|
/**
|
|
116
|
-
* Drizzle tables for the replica.
|
|
117
|
-
*
|
|
114
|
+
* Drizzle tables for the replica. `additionalFields` adds a column per declared attribute,
|
|
115
|
+
* keyed by attribute name, with its index. `runIndex` adds columns the host owns
|
|
116
|
+
* (`input`, `error`, and so on); those are not in Looms migrations.
|
|
118
117
|
*/
|
|
119
|
-
export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record<never, never
|
|
120
|
-
loomsRunIndex:
|
|
121
|
-
|
|
118
|
+
export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record<never, never>, const Fields extends RunAttributeFields = NoAdditionalFields>(options?: LoomsReplicaTablesOptions<Extra, Fields>): {
|
|
119
|
+
loomsRunIndex: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
120
|
+
name: "looms_run_index";
|
|
121
|
+
schema: undefined;
|
|
122
|
+
columns: RunIndexColumns<Extra, Fields> extends infer T extends Record<string, import("drizzle-orm").ColumnBuilderBase<import("drizzle-orm").ColumnBuilderBaseConfig<import("drizzle-orm").ColumnDataType, string>, object>> ? { [Key in keyof T]: import("drizzle-orm").BuildColumn<TTableName, {
|
|
123
|
+
_: Omit<T[Key]["_"], "name"> & {
|
|
124
|
+
name: T[Key]["_"]["name"] extends "" ? import("drizzle-orm").Assume<Key, string> : T[Key]["_"]["name"];
|
|
125
|
+
};
|
|
126
|
+
}, TDialect>; } : never;
|
|
127
|
+
dialect: 'pg';
|
|
128
|
+
}>;
|
|
129
|
+
loomsRunEvents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
122
130
|
name: "looms_run_events";
|
|
123
131
|
schema: undefined;
|
|
124
132
|
columns: {
|
|
@@ -363,7 +371,7 @@ export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record
|
|
|
363
371
|
};
|
|
364
372
|
dialect: 'pg';
|
|
365
373
|
}>;
|
|
366
|
-
loomsRunActors: PgTableWithColumns<{
|
|
374
|
+
loomsRunActors: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
367
375
|
name: "looms_run_actors";
|
|
368
376
|
schema: undefined;
|
|
369
377
|
columns: {
|
|
@@ -540,7 +548,7 @@ export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record
|
|
|
540
548
|
};
|
|
541
549
|
dialect: 'pg';
|
|
542
550
|
}>;
|
|
543
|
-
loomsRunReviews: PgTableWithColumns<{
|
|
551
|
+
loomsRunReviews: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
544
552
|
name: "looms_run_reviews";
|
|
545
553
|
schema: undefined;
|
|
546
554
|
columns: {
|
|
@@ -632,7 +640,7 @@ export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record
|
|
|
632
640
|
};
|
|
633
641
|
dialect: 'pg';
|
|
634
642
|
}>;
|
|
635
|
-
loomsSchemaMigrations: PgTableWithColumns<{
|
|
643
|
+
loomsSchemaMigrations: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
636
644
|
name: "looms_schema_migrations";
|
|
637
645
|
schema: undefined;
|
|
638
646
|
columns: {
|
|
@@ -674,8 +682,271 @@ export declare function loomsReplicaTables<Extra extends RunIndexExtras = Record
|
|
|
674
682
|
dialect: 'pg';
|
|
675
683
|
}>;
|
|
676
684
|
};
|
|
677
|
-
export declare const loomsRunIndex:
|
|
678
|
-
|
|
685
|
+
export declare const loomsRunIndex: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
686
|
+
name: "looms_run_index";
|
|
687
|
+
schema: undefined;
|
|
688
|
+
columns: {
|
|
689
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
690
|
+
name: "run_id";
|
|
691
|
+
tableName: "looms_run_index";
|
|
692
|
+
dataType: "string";
|
|
693
|
+
columnType: "PgText";
|
|
694
|
+
data: string;
|
|
695
|
+
driverParam: string;
|
|
696
|
+
notNull: true;
|
|
697
|
+
hasDefault: false;
|
|
698
|
+
isPrimaryKey: true;
|
|
699
|
+
isAutoincrement: false;
|
|
700
|
+
hasRuntimeDefault: false;
|
|
701
|
+
enumValues: [string, ...string[]];
|
|
702
|
+
baseColumn: never;
|
|
703
|
+
identity: undefined;
|
|
704
|
+
generated: undefined;
|
|
705
|
+
}, {}, {}>;
|
|
706
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
707
|
+
name: "status";
|
|
708
|
+
tableName: "looms_run_index";
|
|
709
|
+
dataType: "string";
|
|
710
|
+
columnType: "PgText";
|
|
711
|
+
data: string;
|
|
712
|
+
driverParam: string;
|
|
713
|
+
notNull: true;
|
|
714
|
+
hasDefault: false;
|
|
715
|
+
isPrimaryKey: false;
|
|
716
|
+
isAutoincrement: false;
|
|
717
|
+
hasRuntimeDefault: false;
|
|
718
|
+
enumValues: [string, ...string[]];
|
|
719
|
+
baseColumn: never;
|
|
720
|
+
identity: undefined;
|
|
721
|
+
generated: undefined;
|
|
722
|
+
}, {}, {}>;
|
|
723
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
724
|
+
name: "kind";
|
|
725
|
+
tableName: "looms_run_index";
|
|
726
|
+
dataType: "string";
|
|
727
|
+
columnType: "PgText";
|
|
728
|
+
data: string;
|
|
729
|
+
driverParam: string;
|
|
730
|
+
notNull: false;
|
|
731
|
+
hasDefault: false;
|
|
732
|
+
isPrimaryKey: false;
|
|
733
|
+
isAutoincrement: false;
|
|
734
|
+
hasRuntimeDefault: false;
|
|
735
|
+
enumValues: [string, ...string[]];
|
|
736
|
+
baseColumn: never;
|
|
737
|
+
identity: undefined;
|
|
738
|
+
generated: undefined;
|
|
739
|
+
}, {}, {}>;
|
|
740
|
+
definitionName: import("drizzle-orm/pg-core").PgColumn<{
|
|
741
|
+
name: "definition_name";
|
|
742
|
+
tableName: "looms_run_index";
|
|
743
|
+
dataType: "string";
|
|
744
|
+
columnType: "PgText";
|
|
745
|
+
data: string;
|
|
746
|
+
driverParam: string;
|
|
747
|
+
notNull: false;
|
|
748
|
+
hasDefault: false;
|
|
749
|
+
isPrimaryKey: false;
|
|
750
|
+
isAutoincrement: false;
|
|
751
|
+
hasRuntimeDefault: false;
|
|
752
|
+
enumValues: [string, ...string[]];
|
|
753
|
+
baseColumn: never;
|
|
754
|
+
identity: undefined;
|
|
755
|
+
generated: undefined;
|
|
756
|
+
}, {}, {}>;
|
|
757
|
+
definitionVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
758
|
+
name: "definition_version";
|
|
759
|
+
tableName: "looms_run_index";
|
|
760
|
+
dataType: "string";
|
|
761
|
+
columnType: "PgText";
|
|
762
|
+
data: string;
|
|
763
|
+
driverParam: string;
|
|
764
|
+
notNull: false;
|
|
765
|
+
hasDefault: false;
|
|
766
|
+
isPrimaryKey: false;
|
|
767
|
+
isAutoincrement: false;
|
|
768
|
+
hasRuntimeDefault: false;
|
|
769
|
+
enumValues: [string, ...string[]];
|
|
770
|
+
baseColumn: never;
|
|
771
|
+
identity: undefined;
|
|
772
|
+
generated: undefined;
|
|
773
|
+
}, {}, {}>;
|
|
774
|
+
rootThreadId: import("drizzle-orm/pg-core").PgColumn<{
|
|
775
|
+
name: "root_thread_id";
|
|
776
|
+
tableName: "looms_run_index";
|
|
777
|
+
dataType: "string";
|
|
778
|
+
columnType: "PgText";
|
|
779
|
+
data: string;
|
|
780
|
+
driverParam: string;
|
|
781
|
+
notNull: false;
|
|
782
|
+
hasDefault: false;
|
|
783
|
+
isPrimaryKey: false;
|
|
784
|
+
isAutoincrement: false;
|
|
785
|
+
hasRuntimeDefault: false;
|
|
786
|
+
enumValues: [string, ...string[]];
|
|
787
|
+
baseColumn: never;
|
|
788
|
+
identity: undefined;
|
|
789
|
+
generated: undefined;
|
|
790
|
+
}, {}, {}>;
|
|
791
|
+
parentRunId: import("drizzle-orm/pg-core").PgColumn<{
|
|
792
|
+
name: "parent_run_id";
|
|
793
|
+
tableName: "looms_run_index";
|
|
794
|
+
dataType: "string";
|
|
795
|
+
columnType: "PgText";
|
|
796
|
+
data: string;
|
|
797
|
+
driverParam: string;
|
|
798
|
+
notNull: false;
|
|
799
|
+
hasDefault: false;
|
|
800
|
+
isPrimaryKey: false;
|
|
801
|
+
isAutoincrement: false;
|
|
802
|
+
hasRuntimeDefault: false;
|
|
803
|
+
enumValues: [string, ...string[]];
|
|
804
|
+
baseColumn: never;
|
|
805
|
+
identity: undefined;
|
|
806
|
+
generated: undefined;
|
|
807
|
+
}, {}, {}>;
|
|
808
|
+
launchedByEffectId: import("drizzle-orm/pg-core").PgColumn<{
|
|
809
|
+
name: "launched_by_effect_id";
|
|
810
|
+
tableName: "looms_run_index";
|
|
811
|
+
dataType: "string";
|
|
812
|
+
columnType: "PgText";
|
|
813
|
+
data: string;
|
|
814
|
+
driverParam: string;
|
|
815
|
+
notNull: false;
|
|
816
|
+
hasDefault: false;
|
|
817
|
+
isPrimaryKey: false;
|
|
818
|
+
isAutoincrement: false;
|
|
819
|
+
hasRuntimeDefault: false;
|
|
820
|
+
enumValues: [string, ...string[]];
|
|
821
|
+
baseColumn: never;
|
|
822
|
+
identity: undefined;
|
|
823
|
+
generated: undefined;
|
|
824
|
+
}, {}, {}>;
|
|
825
|
+
correlationId: import("drizzle-orm/pg-core").PgColumn<{
|
|
826
|
+
name: "correlation_id";
|
|
827
|
+
tableName: "looms_run_index";
|
|
828
|
+
dataType: "string";
|
|
829
|
+
columnType: "PgText";
|
|
830
|
+
data: string;
|
|
831
|
+
driverParam: string;
|
|
832
|
+
notNull: false;
|
|
833
|
+
hasDefault: false;
|
|
834
|
+
isPrimaryKey: false;
|
|
835
|
+
isAutoincrement: false;
|
|
836
|
+
hasRuntimeDefault: false;
|
|
837
|
+
enumValues: [string, ...string[]];
|
|
838
|
+
baseColumn: never;
|
|
839
|
+
identity: undefined;
|
|
840
|
+
generated: undefined;
|
|
841
|
+
}, {}, {}>;
|
|
842
|
+
attributes: import("drizzle-orm/pg-core").PgColumn<{
|
|
843
|
+
name: "attributes";
|
|
844
|
+
tableName: "looms_run_index";
|
|
845
|
+
dataType: "json";
|
|
846
|
+
columnType: "PgJsonb";
|
|
847
|
+
data: Record<string, string>;
|
|
848
|
+
driverParam: unknown;
|
|
849
|
+
notNull: true;
|
|
850
|
+
hasDefault: true;
|
|
851
|
+
isPrimaryKey: false;
|
|
852
|
+
isAutoincrement: false;
|
|
853
|
+
hasRuntimeDefault: false;
|
|
854
|
+
enumValues: undefined;
|
|
855
|
+
baseColumn: never;
|
|
856
|
+
identity: undefined;
|
|
857
|
+
generated: undefined;
|
|
858
|
+
}, {}, {
|
|
859
|
+
$type: Record<string, string>;
|
|
860
|
+
}>;
|
|
861
|
+
startedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
862
|
+
name: "started_at";
|
|
863
|
+
tableName: "looms_run_index";
|
|
864
|
+
dataType: "date";
|
|
865
|
+
columnType: "PgTimestamp";
|
|
866
|
+
data: Date;
|
|
867
|
+
driverParam: string;
|
|
868
|
+
notNull: false;
|
|
869
|
+
hasDefault: false;
|
|
870
|
+
isPrimaryKey: false;
|
|
871
|
+
isAutoincrement: false;
|
|
872
|
+
hasRuntimeDefault: false;
|
|
873
|
+
enumValues: undefined;
|
|
874
|
+
baseColumn: never;
|
|
875
|
+
identity: undefined;
|
|
876
|
+
generated: undefined;
|
|
877
|
+
}, {}, {}>;
|
|
878
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
879
|
+
name: "updated_at";
|
|
880
|
+
tableName: "looms_run_index";
|
|
881
|
+
dataType: "date";
|
|
882
|
+
columnType: "PgTimestamp";
|
|
883
|
+
data: Date;
|
|
884
|
+
driverParam: string;
|
|
885
|
+
notNull: true;
|
|
886
|
+
hasDefault: true;
|
|
887
|
+
isPrimaryKey: false;
|
|
888
|
+
isAutoincrement: false;
|
|
889
|
+
hasRuntimeDefault: false;
|
|
890
|
+
enumValues: undefined;
|
|
891
|
+
baseColumn: never;
|
|
892
|
+
identity: undefined;
|
|
893
|
+
generated: undefined;
|
|
894
|
+
}, {}, {}>;
|
|
895
|
+
completedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
896
|
+
name: "completed_at";
|
|
897
|
+
tableName: "looms_run_index";
|
|
898
|
+
dataType: "date";
|
|
899
|
+
columnType: "PgTimestamp";
|
|
900
|
+
data: Date;
|
|
901
|
+
driverParam: string;
|
|
902
|
+
notNull: false;
|
|
903
|
+
hasDefault: false;
|
|
904
|
+
isPrimaryKey: false;
|
|
905
|
+
isAutoincrement: false;
|
|
906
|
+
hasRuntimeDefault: false;
|
|
907
|
+
enumValues: undefined;
|
|
908
|
+
baseColumn: never;
|
|
909
|
+
identity: undefined;
|
|
910
|
+
generated: undefined;
|
|
911
|
+
}, {}, {}>;
|
|
912
|
+
replicatedSeq: import("drizzle-orm/pg-core").PgColumn<{
|
|
913
|
+
name: "replicated_seq";
|
|
914
|
+
tableName: "looms_run_index";
|
|
915
|
+
dataType: "number";
|
|
916
|
+
columnType: "PgBigInt53";
|
|
917
|
+
data: number;
|
|
918
|
+
driverParam: string | number;
|
|
919
|
+
notNull: true;
|
|
920
|
+
hasDefault: true;
|
|
921
|
+
isPrimaryKey: false;
|
|
922
|
+
isAutoincrement: false;
|
|
923
|
+
hasRuntimeDefault: false;
|
|
924
|
+
enumValues: undefined;
|
|
925
|
+
baseColumn: never;
|
|
926
|
+
identity: undefined;
|
|
927
|
+
generated: undefined;
|
|
928
|
+
}, {}, {}>;
|
|
929
|
+
purgedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
930
|
+
name: "purged_at";
|
|
931
|
+
tableName: "looms_run_index";
|
|
932
|
+
dataType: "date";
|
|
933
|
+
columnType: "PgTimestamp";
|
|
934
|
+
data: Date;
|
|
935
|
+
driverParam: string;
|
|
936
|
+
notNull: false;
|
|
937
|
+
hasDefault: false;
|
|
938
|
+
isPrimaryKey: false;
|
|
939
|
+
isAutoincrement: false;
|
|
940
|
+
hasRuntimeDefault: false;
|
|
941
|
+
enumValues: undefined;
|
|
942
|
+
baseColumn: never;
|
|
943
|
+
identity: undefined;
|
|
944
|
+
generated: undefined;
|
|
945
|
+
}, {}, {}>;
|
|
946
|
+
};
|
|
947
|
+
dialect: 'pg';
|
|
948
|
+
}>;
|
|
949
|
+
export declare const loomsRunEvents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
679
950
|
name: "looms_run_events";
|
|
680
951
|
schema: undefined;
|
|
681
952
|
columns: {
|
|
@@ -920,7 +1191,7 @@ export declare const loomsRunEvents: PgTableWithColumns<{
|
|
|
920
1191
|
};
|
|
921
1192
|
dialect: 'pg';
|
|
922
1193
|
}>;
|
|
923
|
-
export declare const loomsRunActors: PgTableWithColumns<{
|
|
1194
|
+
export declare const loomsRunActors: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
924
1195
|
name: "looms_run_actors";
|
|
925
1196
|
schema: undefined;
|
|
926
1197
|
columns: {
|
|
@@ -1097,7 +1368,7 @@ export declare const loomsRunActors: PgTableWithColumns<{
|
|
|
1097
1368
|
};
|
|
1098
1369
|
dialect: 'pg';
|
|
1099
1370
|
}>;
|
|
1100
|
-
export declare const loomsRunReviews: PgTableWithColumns<{
|
|
1371
|
+
export declare const loomsRunReviews: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
1101
1372
|
name: "looms_run_reviews";
|
|
1102
1373
|
schema: undefined;
|
|
1103
1374
|
columns: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sql } from 'drizzle-orm';
|
|
2
2
|
import { bigint, boolean, index, jsonb, pgTable, primaryKey, text, timestamp, } from 'drizzle-orm/pg-core';
|
|
3
|
+
import { resolveReplicaColumns } from './columns.js';
|
|
3
4
|
/** Column builders for `looms_run_index`. Call again for each table; do not reuse the result. */
|
|
4
5
|
export function loomsRunIndexColumns() {
|
|
5
6
|
return {
|
|
@@ -16,9 +17,6 @@ export function loomsRunIndexColumns() {
|
|
|
16
17
|
.$type()
|
|
17
18
|
.notNull()
|
|
18
19
|
.default(sql `'{}'::jsonb`),
|
|
19
|
-
tenant: text('tenant'),
|
|
20
|
-
project: text('project'),
|
|
21
|
-
org: text('org'),
|
|
22
20
|
startedAt: timestamp('started_at', { withTimezone: true }),
|
|
23
21
|
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
|
24
22
|
completedAt: timestamp('completed_at', { withTimezone: true }),
|
|
@@ -75,23 +73,29 @@ export const loomsSchemaMigrations = pgTable('looms_schema_migrations', {
|
|
|
75
73
|
appliedAt: timestamp('applied_at', { withTimezone: true }).notNull().defaultNow(),
|
|
76
74
|
});
|
|
77
75
|
/**
|
|
78
|
-
* Drizzle tables for the replica.
|
|
79
|
-
*
|
|
76
|
+
* Drizzle tables for the replica. `additionalFields` adds a column per declared attribute,
|
|
77
|
+
* keyed by attribute name, with its index. `runIndex` adds columns the host owns
|
|
78
|
+
* (`input`, `error`, and so on); those are not in Looms migrations.
|
|
80
79
|
*/
|
|
81
80
|
export function loomsReplicaTables(options) {
|
|
81
|
+
const attributeColumns = resolveReplicaColumns(options?.additionalFields);
|
|
82
|
+
// SAFETY: resolveReplicaColumns returns one column for each key of Fields, and runIndex is Extra.
|
|
82
83
|
const columns = {
|
|
83
84
|
...loomsRunIndexColumns(),
|
|
85
|
+
...Object.fromEntries(attributeColumns.map((column) => [column.key, text(column.name)])),
|
|
84
86
|
...options?.runIndex,
|
|
85
87
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const runIndex = pgTable('looms_run_index', columns, (table) => {
|
|
89
|
+
const byKey = table;
|
|
90
|
+
return [
|
|
91
|
+
index('looms_run_index_parent').on(table.parentRunId),
|
|
92
|
+
index('looms_run_index_status').on(table.status),
|
|
93
|
+
...attributeColumns.flatMap((column) => {
|
|
94
|
+
const built = byKey[column.key];
|
|
95
|
+
return column.index && built ? [index(`looms_run_index_${column.name}`).on(built)] : [];
|
|
96
|
+
}),
|
|
97
|
+
];
|
|
98
|
+
});
|
|
95
99
|
const loomsRunEvents = pgTable('looms_run_events', loomsRunEventsColumns(), (table) => [
|
|
96
100
|
primaryKey({ columns: [table.runId, table.seq] }),
|
|
97
101
|
index('looms_run_events_type_ts').on(table.type, table.ts),
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { Sql, TransactionSql } from 'postgres';
|
|
2
|
+
import type { RunAttributeFields } from '@swirls/looms/core';
|
|
3
|
+
import { type ReplicaMigration, type ResolvedReplicaColumn } from './columns';
|
|
4
|
+
export type { ReplicaMigration };
|
|
1
5
|
/**
|
|
2
6
|
* Actors and reviews. Same statements the Postgres index projector has always
|
|
3
7
|
* applied, so a database created by an older Looms keeps working.
|
|
@@ -9,12 +13,26 @@ export declare const POSTGRES_SCHEMA_SQL: string;
|
|
|
9
13
|
* `ADD COLUMN IF NOT EXISTS`.
|
|
10
14
|
*/
|
|
11
15
|
export declare const POSTGRES_EVENT_LOG_SCHEMA_SQL: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/** Tracks applied Looms migrations, including attribute column migrations. */
|
|
17
|
+
export declare const POSTGRES_SCHEMA_MIGRATIONS_SQL: string;
|
|
18
|
+
/**
|
|
19
|
+
* Adds one attribute column and copies it from `attributes` for runs already in the table.
|
|
20
|
+
* Safe to repeat: the backfill only touches rows that have the attribute and an empty column.
|
|
21
|
+
*/
|
|
22
|
+
export declare function postgresColumnSql(column: ResolvedReplicaColumn): string;
|
|
23
|
+
export declare function postgresColumnIndexSql(column: ResolvedReplicaColumn): string;
|
|
24
|
+
/**
|
|
25
|
+
* Attribute column and index migrations for Postgres.
|
|
26
|
+
* Each runs once when recorded in `looms_schema_migrations`, including the backfill UPDATE.
|
|
27
|
+
*/
|
|
28
|
+
export declare function postgresAttributeMigrations(additionalFields?: RunAttributeFields): readonly ReplicaMigration[];
|
|
29
|
+
/** Ids recorded in `looms_schema_migrations`, or none when the table does not exist yet. */
|
|
30
|
+
export declare function appliedPostgresMigrationIds(sql: Sql | TransactionSql): Promise<ReadonlySet<string>>;
|
|
31
|
+
/** Applies each migration that is not recorded yet, in order, under one advisory lock. */
|
|
32
|
+
export declare function applyPostgresMigrations(sql: Sql, migrations: readonly ReplicaMigration[]): Promise<void>;
|
|
33
|
+
/** Versioned DDL for the Postgres replica with no attribute columns. Looms only creates and alters `looms_*` objects. */
|
|
17
34
|
export declare const POSTGRES_REPLICA_MIGRATIONS: readonly ReplicaMigration[];
|
|
35
|
+
export declare function postgresReplicaMigrations(additionalFields?: RunAttributeFields): readonly ReplicaMigration[];
|
|
18
36
|
export type ReplicaDialect = 'postgres' | 'sqlite';
|
|
19
37
|
export interface GenerateReplicaMigrationsOptions {
|
|
20
38
|
/** Directory of SQL migrations the host already applies. */
|
|
@@ -25,6 +43,8 @@ export interface GenerateReplicaMigrationsOptions {
|
|
|
25
43
|
readonly check?: boolean;
|
|
26
44
|
/** Which replica DDL to write. Defaults to Postgres. */
|
|
27
45
|
readonly dialect?: ReplicaDialect;
|
|
46
|
+
/** Declared run attributes. Pass the same declaration the replica uses. */
|
|
47
|
+
readonly additionalFields?: RunAttributeFields;
|
|
28
48
|
}
|
|
29
49
|
export interface GenerateReplicaMigrationsResult {
|
|
30
50
|
readonly written: readonly string[];
|