@20baht/runs 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +123 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/pg.d.ts +530 -0
- package/dist/pg.js +416 -0
- package/dist/types.d.ts +182 -0
- package/dist/types.js +11 -0
- package/package.json +69 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nattapong Promthong
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @20baht/runs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workflow runs kept on a server. A workflow with approval steps is rarely walked by one person in one
|
|
4
|
+
sitting: the requester fills a form, and each later step waits for someone else. This package keeps the
|
|
5
|
+
run (the step it stands on and its data), opens an approval step's tasks, records each decision, and
|
|
6
|
+
moves the run with **the same engine the browser's `<baht-workflow>` uses**, so the two never disagree
|
|
7
|
+
about the path.
|
|
8
|
+
|
|
9
|
+
Persistence is [drizzle-orm](https://orm.drizzle.team) on **Postgres**. Who a step is asked of, and who
|
|
10
|
+
may decide, are two functions you supply: the package never sees a token, a session or an org chart.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
bun add @20baht/runs drizzle-orm
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Tables
|
|
17
|
+
|
|
18
|
+
Add them to your drizzle schema, so your own migrations (`drizzle-kit generate`) create them:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// schema.ts
|
|
22
|
+
import { runTables } from '@20baht/runs/pg';
|
|
23
|
+
|
|
24
|
+
export const { definitions, runs, tasks } = runTables(); // baht_run_definitions, baht_runs, baht_run_tasks
|
|
25
|
+
// runTables({ prefix: 'wf_' }) names them wf_…
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Column keys are the column names (`form_name`, `created_at`), so a row reads the same in SQL, in
|
|
29
|
+
TypeScript and in the JSON a route sends.
|
|
30
|
+
|
|
31
|
+
## The service
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { createRuns, byAssignment } from '@20baht/runs/pg';
|
|
35
|
+
import { definitions, runs, tasks } from './schema';
|
|
36
|
+
|
|
37
|
+
export const workflowRuns = createRuns({
|
|
38
|
+
db, // any drizzle Postgres database: node-postgres, postgres.js, PGlite, Neon…
|
|
39
|
+
tables: { definitions, runs, tasks },
|
|
40
|
+
|
|
41
|
+
// when a step opens: who is this target asked of?
|
|
42
|
+
resolve: async (target, { run }) => {
|
|
43
|
+
if (target.type === 'requester') return [{ person: run.requester }];
|
|
44
|
+
if (target.type === 'manager') return [{ person: await managerOf(run.requester, target.hops ?? 1) }];
|
|
45
|
+
if (target.type === 'role') return (await holdersOf(target.value)).map((person) => ({ person }));
|
|
46
|
+
if (target.type === 'group') return [{ position: `group:${target.value}` }]; // anyone in it may claim
|
|
47
|
+
return []; // nobody you can name: kept as an `unassigned` task, never dropped
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// when a claim or a decision arrives: may this caller act, as things stand now?
|
|
51
|
+
authorize: byAssignment, // the named person, or anyone holding the position
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// the requester sends the first form: validated, stored, moved to the first approval
|
|
57
|
+
const started = await workflowRuns.start({ definition, requester: user.id, data: body });
|
|
58
|
+
if (!started.ok) return status(422, started); // { reason: 'invalid', issues } and nothing stored
|
|
59
|
+
notify(started.opened); // the tasks this call opened
|
|
60
|
+
|
|
61
|
+
// what waits for me
|
|
62
|
+
const mine = await workflowRuns.inbox({ id: user.id, positions: user.groups.map((g) => `group:${g}`) });
|
|
63
|
+
|
|
64
|
+
// a decision
|
|
65
|
+
const result = await workflowRuns.decide(taskId, { by: caller, decision: 'approved', comment });
|
|
66
|
+
// result.outcome: 'pending' (the step waits for others) | 'approved' | 'rejected'
|
|
67
|
+
// result.run: where the run stands now; result.opened: the next step's tasks
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| Call | What it does |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| `start({ definition, requester, data? })` | A new run on the first step. With `data` (the first form's flat body) it is submitted at once; an invalid first form stores nothing |
|
|
73
|
+
| `submit(run_id, { by, data })` | The requester sends the form step the run stands on (also after a rejection sent it back) |
|
|
74
|
+
| `decide(task_id, { by, decision, comment? })` | One person's decision. The run moves only when the step's `rule` is settled |
|
|
75
|
+
| `claim(task_id, by)` / `release(task_id, by)` | Take a position's task so nobody else works on it; give it back |
|
|
76
|
+
| `inbox(caller)` | The caller's open tasks, the ones they claimed, and open ones of `caller.positions` |
|
|
77
|
+
| `get(run_id)` | The run, the definition it is pinned to, and every task |
|
|
78
|
+
|
|
79
|
+
Every call answers `{ ok: true, … }` or `{ ok: false, reason, message }`; nothing here throws for a refusal.
|
|
80
|
+
Reasons: `not-found`, `not-active`, `not-open`, `not-a-form-step`, `not-claimable`, `claimed`, `invalid`
|
|
81
|
+
(with `issues`), `invalid-definition`, `comment-required`, `denied`, `unavailable`, `blocked`, `no-step`.
|
|
82
|
+
|
|
83
|
+
## What it holds to
|
|
84
|
+
|
|
85
|
+
- **The engine decides the path.** `advanceRun` says where a run goes (rules, `transitions`, `on_reject`),
|
|
86
|
+
`settleStep` when a step is decided (`any` / `all` / `{ quorum }`), `validateWorkflowData` whether a
|
|
87
|
+
form step is valid. None of it is re-implemented here.
|
|
88
|
+
- **A run is pinned to its definition.** `start` stores the definition by its content (checked with
|
|
89
|
+
`parseSchema` the first time it is seen); a later edit starts new runs on the new one and moves no old
|
|
90
|
+
run. Keep your own table of versions if you publish them; this one is only the pin.
|
|
91
|
+
- **One transaction per change, holding the run's row.** A decision, the re-count of its step and the
|
|
92
|
+
move come from one snapshot: two people approving the last two places of a quorum are counted one
|
|
93
|
+
after the other.
|
|
94
|
+
- **`unavailable` is not a yes.** When `authorize` cannot find out, nothing is decided.
|
|
95
|
+
- **A target that points at nobody stays**, as an `unassigned` task: under `all` such a step can only be
|
|
96
|
+
rejected. Surface it; do not drop it.
|
|
97
|
+
- **A step that asks nobody waits** (every target's `when` failed). A definition that wants it passed
|
|
98
|
+
over says so with a `skipForm` rule on the same condition.
|
|
99
|
+
- **A rejection that sends a run back** (`on_reject: goto`) sets the tasks of the steps it revisits
|
|
100
|
+
aside (`superseded`) when they open again; the history stays in the table.
|
|
101
|
+
|
|
102
|
+
## The two ports
|
|
103
|
+
|
|
104
|
+
`resolve(target, { run, form_name })` answers with people (`{ person }`), with positions anyone entitled
|
|
105
|
+
may claim (`{ position }`), or with nothing. `all` and a quorum count heads, so they need people. It runs
|
|
106
|
+
inside the transaction that moves the run: keep it to lookups.
|
|
107
|
+
|
|
108
|
+
`authorize({ target, task, run }, caller)` answers `{ verdict: 'allowed', evidence? }`,
|
|
109
|
+
`{ verdict: 'denied', reason }` or `{ verdict: 'unavailable' }`. `evidence` is an opaque string stored
|
|
110
|
+
with the decision and never read (a signed attestation, an audit id). The check is made when the
|
|
111
|
+
decision arrives, not when the step opened: someone who lost the role no longer decides. A step with no
|
|
112
|
+
`assignment` opens one task with nobody named on it, which `byAssignment` refuses: give such workflows a
|
|
113
|
+
rule of your own.
|
|
114
|
+
|
|
115
|
+
## Not in 0.1
|
|
116
|
+
|
|
117
|
+
- **Postgres only.** The tables are drizzle `pgTable`s and the lock is `SELECT … FOR UPDATE`. SQLite and
|
|
118
|
+
D1 (no interactive transactions) need another entry and another way to serialise a step.
|
|
119
|
+
- **Form steps belong to the requester.** A form step in the middle of a run that someone else fills is
|
|
120
|
+
not modelled yet.
|
|
121
|
+
- **No routes.** Mount these calls on your own Elysia routes, behind your own sign-in.
|
|
122
|
+
- **No deadlines, reminders or notifications.** `opened` is what a call hands you to notify with; the
|
|
123
|
+
deadline keys of `assignment` are passed through unread (spec 03 §4.1 leaves them undecided).
|
|
124
|
+
- **No cancel, no reassign, no delegation.** Delegation can live in your `authorize`.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { byAssignment } from './types.js';
|
|
2
|
+
export type { Asked, Authorize, Caller, ClaimResult, DecideResult, Issue, Moved, Refused, Requirement, Resolve, ResolveContext, Run, RunDetail, Runs, RunsBehaviour, RunStatus, RunTask, StartResult, SubmitResult, TaskState, Verdict, } from './types.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { byAssignment } from './types.js';
|
package/dist/pg.d.ts
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { type ApprovalDecision, type AssignTarget, type NestedData, type WorkflowDefinition } from '@20baht/engine';
|
|
2
|
+
import { type PgDatabase, type PgQueryResultHKT } from 'drizzle-orm/pg-core';
|
|
3
|
+
import type { Runs, RunsBehaviour, RunStatus, TaskState } from './types.js';
|
|
4
|
+
export * from './index.js';
|
|
5
|
+
/**
|
|
6
|
+
* The three tables, for the host's drizzle schema: `export const { definitions, runs, tasks } =
|
|
7
|
+
* runTables()`. `prefix` names them (`baht_runs`, `baht_run_tasks`, `baht_run_definitions`).
|
|
8
|
+
* Column keys are the column names, so a row reads the same in SQL, in TypeScript and on the wire.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTables(options?: {
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}): {
|
|
13
|
+
definitions: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
14
|
+
name: `${string}run_definitions`;
|
|
15
|
+
schema: undefined;
|
|
16
|
+
columns: {
|
|
17
|
+
hash: import("drizzle-orm/pg-core").PgColumn<{
|
|
18
|
+
name: "hash";
|
|
19
|
+
tableName: `${string}run_definitions`;
|
|
20
|
+
dataType: "string";
|
|
21
|
+
columnType: "PgText";
|
|
22
|
+
data: string;
|
|
23
|
+
driverParam: string;
|
|
24
|
+
notNull: true;
|
|
25
|
+
hasDefault: false;
|
|
26
|
+
isPrimaryKey: true;
|
|
27
|
+
isAutoincrement: false;
|
|
28
|
+
hasRuntimeDefault: false;
|
|
29
|
+
enumValues: [string, ...string[]];
|
|
30
|
+
baseColumn: never;
|
|
31
|
+
identity: undefined;
|
|
32
|
+
generated: undefined;
|
|
33
|
+
}, {}, {}>;
|
|
34
|
+
workflow_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
35
|
+
name: "workflow_id";
|
|
36
|
+
tableName: `${string}run_definitions`;
|
|
37
|
+
dataType: "string";
|
|
38
|
+
columnType: "PgText";
|
|
39
|
+
data: string;
|
|
40
|
+
driverParam: string;
|
|
41
|
+
notNull: true;
|
|
42
|
+
hasDefault: false;
|
|
43
|
+
isPrimaryKey: false;
|
|
44
|
+
isAutoincrement: false;
|
|
45
|
+
hasRuntimeDefault: false;
|
|
46
|
+
enumValues: [string, ...string[]];
|
|
47
|
+
baseColumn: never;
|
|
48
|
+
identity: undefined;
|
|
49
|
+
generated: undefined;
|
|
50
|
+
}, {}, {}>;
|
|
51
|
+
definition: import("drizzle-orm/pg-core").PgColumn<{
|
|
52
|
+
name: "definition";
|
|
53
|
+
tableName: `${string}run_definitions`;
|
|
54
|
+
dataType: "json";
|
|
55
|
+
columnType: "PgJsonb";
|
|
56
|
+
data: WorkflowDefinition;
|
|
57
|
+
driverParam: unknown;
|
|
58
|
+
notNull: true;
|
|
59
|
+
hasDefault: false;
|
|
60
|
+
isPrimaryKey: false;
|
|
61
|
+
isAutoincrement: false;
|
|
62
|
+
hasRuntimeDefault: false;
|
|
63
|
+
enumValues: undefined;
|
|
64
|
+
baseColumn: never;
|
|
65
|
+
identity: undefined;
|
|
66
|
+
generated: undefined;
|
|
67
|
+
}, {}, {
|
|
68
|
+
$type: WorkflowDefinition;
|
|
69
|
+
}>;
|
|
70
|
+
created_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
71
|
+
name: "created_at";
|
|
72
|
+
tableName: `${string}run_definitions`;
|
|
73
|
+
dataType: "date";
|
|
74
|
+
columnType: "PgTimestamp";
|
|
75
|
+
data: Date;
|
|
76
|
+
driverParam: string;
|
|
77
|
+
notNull: true;
|
|
78
|
+
hasDefault: false;
|
|
79
|
+
isPrimaryKey: false;
|
|
80
|
+
isAutoincrement: false;
|
|
81
|
+
hasRuntimeDefault: false;
|
|
82
|
+
enumValues: undefined;
|
|
83
|
+
baseColumn: never;
|
|
84
|
+
identity: undefined;
|
|
85
|
+
generated: undefined;
|
|
86
|
+
}, {}, {}>;
|
|
87
|
+
};
|
|
88
|
+
dialect: "pg";
|
|
89
|
+
}>;
|
|
90
|
+
runs: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
91
|
+
name: `${string}runs`;
|
|
92
|
+
schema: undefined;
|
|
93
|
+
columns: {
|
|
94
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
95
|
+
name: "id";
|
|
96
|
+
tableName: `${string}runs`;
|
|
97
|
+
dataType: "string";
|
|
98
|
+
columnType: "PgText";
|
|
99
|
+
data: string;
|
|
100
|
+
driverParam: string;
|
|
101
|
+
notNull: true;
|
|
102
|
+
hasDefault: false;
|
|
103
|
+
isPrimaryKey: true;
|
|
104
|
+
isAutoincrement: false;
|
|
105
|
+
hasRuntimeDefault: false;
|
|
106
|
+
enumValues: [string, ...string[]];
|
|
107
|
+
baseColumn: never;
|
|
108
|
+
identity: undefined;
|
|
109
|
+
generated: undefined;
|
|
110
|
+
}, {}, {}>;
|
|
111
|
+
workflow_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
112
|
+
name: "workflow_id";
|
|
113
|
+
tableName: `${string}runs`;
|
|
114
|
+
dataType: "string";
|
|
115
|
+
columnType: "PgText";
|
|
116
|
+
data: string;
|
|
117
|
+
driverParam: string;
|
|
118
|
+
notNull: true;
|
|
119
|
+
hasDefault: false;
|
|
120
|
+
isPrimaryKey: false;
|
|
121
|
+
isAutoincrement: false;
|
|
122
|
+
hasRuntimeDefault: false;
|
|
123
|
+
enumValues: [string, ...string[]];
|
|
124
|
+
baseColumn: never;
|
|
125
|
+
identity: undefined;
|
|
126
|
+
generated: undefined;
|
|
127
|
+
}, {}, {}>;
|
|
128
|
+
definition_hash: import("drizzle-orm/pg-core").PgColumn<{
|
|
129
|
+
name: "definition_hash";
|
|
130
|
+
tableName: `${string}runs`;
|
|
131
|
+
dataType: "string";
|
|
132
|
+
columnType: "PgText";
|
|
133
|
+
data: string;
|
|
134
|
+
driverParam: string;
|
|
135
|
+
notNull: true;
|
|
136
|
+
hasDefault: false;
|
|
137
|
+
isPrimaryKey: false;
|
|
138
|
+
isAutoincrement: false;
|
|
139
|
+
hasRuntimeDefault: false;
|
|
140
|
+
enumValues: [string, ...string[]];
|
|
141
|
+
baseColumn: never;
|
|
142
|
+
identity: undefined;
|
|
143
|
+
generated: undefined;
|
|
144
|
+
}, {}, {}>;
|
|
145
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
146
|
+
name: "status";
|
|
147
|
+
tableName: `${string}runs`;
|
|
148
|
+
dataType: "string";
|
|
149
|
+
columnType: "PgText";
|
|
150
|
+
data: RunStatus;
|
|
151
|
+
driverParam: string;
|
|
152
|
+
notNull: true;
|
|
153
|
+
hasDefault: false;
|
|
154
|
+
isPrimaryKey: false;
|
|
155
|
+
isAutoincrement: false;
|
|
156
|
+
hasRuntimeDefault: false;
|
|
157
|
+
enumValues: [string, ...string[]];
|
|
158
|
+
baseColumn: never;
|
|
159
|
+
identity: undefined;
|
|
160
|
+
generated: undefined;
|
|
161
|
+
}, {}, {
|
|
162
|
+
$type: RunStatus;
|
|
163
|
+
}>;
|
|
164
|
+
form_name: import("drizzle-orm/pg-core").PgColumn<{
|
|
165
|
+
name: "form_name";
|
|
166
|
+
tableName: `${string}runs`;
|
|
167
|
+
dataType: "string";
|
|
168
|
+
columnType: "PgText";
|
|
169
|
+
data: string;
|
|
170
|
+
driverParam: string;
|
|
171
|
+
notNull: true;
|
|
172
|
+
hasDefault: false;
|
|
173
|
+
isPrimaryKey: false;
|
|
174
|
+
isAutoincrement: false;
|
|
175
|
+
hasRuntimeDefault: false;
|
|
176
|
+
enumValues: [string, ...string[]];
|
|
177
|
+
baseColumn: never;
|
|
178
|
+
identity: undefined;
|
|
179
|
+
generated: undefined;
|
|
180
|
+
}, {}, {}>;
|
|
181
|
+
data: import("drizzle-orm/pg-core").PgColumn<{
|
|
182
|
+
name: "data";
|
|
183
|
+
tableName: `${string}runs`;
|
|
184
|
+
dataType: "json";
|
|
185
|
+
columnType: "PgJsonb";
|
|
186
|
+
data: NestedData;
|
|
187
|
+
driverParam: unknown;
|
|
188
|
+
notNull: true;
|
|
189
|
+
hasDefault: false;
|
|
190
|
+
isPrimaryKey: false;
|
|
191
|
+
isAutoincrement: false;
|
|
192
|
+
hasRuntimeDefault: false;
|
|
193
|
+
enumValues: undefined;
|
|
194
|
+
baseColumn: never;
|
|
195
|
+
identity: undefined;
|
|
196
|
+
generated: undefined;
|
|
197
|
+
}, {}, {
|
|
198
|
+
$type: NestedData;
|
|
199
|
+
}>;
|
|
200
|
+
requester: import("drizzle-orm/pg-core").PgColumn<{
|
|
201
|
+
name: "requester";
|
|
202
|
+
tableName: `${string}runs`;
|
|
203
|
+
dataType: "string";
|
|
204
|
+
columnType: "PgText";
|
|
205
|
+
data: string;
|
|
206
|
+
driverParam: string;
|
|
207
|
+
notNull: true;
|
|
208
|
+
hasDefault: false;
|
|
209
|
+
isPrimaryKey: false;
|
|
210
|
+
isAutoincrement: false;
|
|
211
|
+
hasRuntimeDefault: false;
|
|
212
|
+
enumValues: [string, ...string[]];
|
|
213
|
+
baseColumn: never;
|
|
214
|
+
identity: undefined;
|
|
215
|
+
generated: undefined;
|
|
216
|
+
}, {}, {}>;
|
|
217
|
+
created_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
218
|
+
name: "created_at";
|
|
219
|
+
tableName: `${string}runs`;
|
|
220
|
+
dataType: "date";
|
|
221
|
+
columnType: "PgTimestamp";
|
|
222
|
+
data: Date;
|
|
223
|
+
driverParam: string;
|
|
224
|
+
notNull: true;
|
|
225
|
+
hasDefault: false;
|
|
226
|
+
isPrimaryKey: false;
|
|
227
|
+
isAutoincrement: false;
|
|
228
|
+
hasRuntimeDefault: false;
|
|
229
|
+
enumValues: undefined;
|
|
230
|
+
baseColumn: never;
|
|
231
|
+
identity: undefined;
|
|
232
|
+
generated: undefined;
|
|
233
|
+
}, {}, {}>;
|
|
234
|
+
updated_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
235
|
+
name: "updated_at";
|
|
236
|
+
tableName: `${string}runs`;
|
|
237
|
+
dataType: "date";
|
|
238
|
+
columnType: "PgTimestamp";
|
|
239
|
+
data: Date;
|
|
240
|
+
driverParam: string;
|
|
241
|
+
notNull: true;
|
|
242
|
+
hasDefault: false;
|
|
243
|
+
isPrimaryKey: false;
|
|
244
|
+
isAutoincrement: false;
|
|
245
|
+
hasRuntimeDefault: false;
|
|
246
|
+
enumValues: undefined;
|
|
247
|
+
baseColumn: never;
|
|
248
|
+
identity: undefined;
|
|
249
|
+
generated: undefined;
|
|
250
|
+
}, {}, {}>;
|
|
251
|
+
};
|
|
252
|
+
dialect: "pg";
|
|
253
|
+
}>;
|
|
254
|
+
tasks: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
255
|
+
name: `${string}run_tasks`;
|
|
256
|
+
schema: undefined;
|
|
257
|
+
columns: {
|
|
258
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
259
|
+
name: "id";
|
|
260
|
+
tableName: `${string}run_tasks`;
|
|
261
|
+
dataType: "string";
|
|
262
|
+
columnType: "PgText";
|
|
263
|
+
data: string;
|
|
264
|
+
driverParam: string;
|
|
265
|
+
notNull: true;
|
|
266
|
+
hasDefault: false;
|
|
267
|
+
isPrimaryKey: true;
|
|
268
|
+
isAutoincrement: false;
|
|
269
|
+
hasRuntimeDefault: false;
|
|
270
|
+
enumValues: [string, ...string[]];
|
|
271
|
+
baseColumn: never;
|
|
272
|
+
identity: undefined;
|
|
273
|
+
generated: undefined;
|
|
274
|
+
}, {}, {}>;
|
|
275
|
+
run_id: import("drizzle-orm/pg-core").PgColumn<{
|
|
276
|
+
name: "run_id";
|
|
277
|
+
tableName: `${string}run_tasks`;
|
|
278
|
+
dataType: "string";
|
|
279
|
+
columnType: "PgText";
|
|
280
|
+
data: string;
|
|
281
|
+
driverParam: string;
|
|
282
|
+
notNull: true;
|
|
283
|
+
hasDefault: false;
|
|
284
|
+
isPrimaryKey: false;
|
|
285
|
+
isAutoincrement: false;
|
|
286
|
+
hasRuntimeDefault: false;
|
|
287
|
+
enumValues: [string, ...string[]];
|
|
288
|
+
baseColumn: never;
|
|
289
|
+
identity: undefined;
|
|
290
|
+
generated: undefined;
|
|
291
|
+
}, {}, {}>;
|
|
292
|
+
form_name: import("drizzle-orm/pg-core").PgColumn<{
|
|
293
|
+
name: "form_name";
|
|
294
|
+
tableName: `${string}run_tasks`;
|
|
295
|
+
dataType: "string";
|
|
296
|
+
columnType: "PgText";
|
|
297
|
+
data: string;
|
|
298
|
+
driverParam: string;
|
|
299
|
+
notNull: true;
|
|
300
|
+
hasDefault: false;
|
|
301
|
+
isPrimaryKey: false;
|
|
302
|
+
isAutoincrement: false;
|
|
303
|
+
hasRuntimeDefault: false;
|
|
304
|
+
enumValues: [string, ...string[]];
|
|
305
|
+
baseColumn: never;
|
|
306
|
+
identity: undefined;
|
|
307
|
+
generated: undefined;
|
|
308
|
+
}, {}, {}>;
|
|
309
|
+
label: import("drizzle-orm/pg-core").PgColumn<{
|
|
310
|
+
name: "label";
|
|
311
|
+
tableName: `${string}run_tasks`;
|
|
312
|
+
dataType: "string";
|
|
313
|
+
columnType: "PgText";
|
|
314
|
+
data: string;
|
|
315
|
+
driverParam: string;
|
|
316
|
+
notNull: true;
|
|
317
|
+
hasDefault: false;
|
|
318
|
+
isPrimaryKey: false;
|
|
319
|
+
isAutoincrement: false;
|
|
320
|
+
hasRuntimeDefault: false;
|
|
321
|
+
enumValues: [string, ...string[]];
|
|
322
|
+
baseColumn: never;
|
|
323
|
+
identity: undefined;
|
|
324
|
+
generated: undefined;
|
|
325
|
+
}, {}, {}>;
|
|
326
|
+
assignee: import("drizzle-orm/pg-core").PgColumn<{
|
|
327
|
+
name: "assignee";
|
|
328
|
+
tableName: `${string}run_tasks`;
|
|
329
|
+
dataType: "string";
|
|
330
|
+
columnType: "PgText";
|
|
331
|
+
data: string;
|
|
332
|
+
driverParam: string;
|
|
333
|
+
notNull: false;
|
|
334
|
+
hasDefault: false;
|
|
335
|
+
isPrimaryKey: false;
|
|
336
|
+
isAutoincrement: false;
|
|
337
|
+
hasRuntimeDefault: false;
|
|
338
|
+
enumValues: [string, ...string[]];
|
|
339
|
+
baseColumn: never;
|
|
340
|
+
identity: undefined;
|
|
341
|
+
generated: undefined;
|
|
342
|
+
}, {}, {}>;
|
|
343
|
+
position: import("drizzle-orm/pg-core").PgColumn<{
|
|
344
|
+
name: "position";
|
|
345
|
+
tableName: `${string}run_tasks`;
|
|
346
|
+
dataType: "string";
|
|
347
|
+
columnType: "PgText";
|
|
348
|
+
data: string;
|
|
349
|
+
driverParam: string;
|
|
350
|
+
notNull: false;
|
|
351
|
+
hasDefault: false;
|
|
352
|
+
isPrimaryKey: false;
|
|
353
|
+
isAutoincrement: false;
|
|
354
|
+
hasRuntimeDefault: false;
|
|
355
|
+
enumValues: [string, ...string[]];
|
|
356
|
+
baseColumn: never;
|
|
357
|
+
identity: undefined;
|
|
358
|
+
generated: undefined;
|
|
359
|
+
}, {}, {}>;
|
|
360
|
+
target: import("drizzle-orm/pg-core").PgColumn<{
|
|
361
|
+
name: "target";
|
|
362
|
+
tableName: `${string}run_tasks`;
|
|
363
|
+
dataType: "json";
|
|
364
|
+
columnType: "PgJsonb";
|
|
365
|
+
data: AssignTarget | null;
|
|
366
|
+
driverParam: unknown;
|
|
367
|
+
notNull: false;
|
|
368
|
+
hasDefault: false;
|
|
369
|
+
isPrimaryKey: false;
|
|
370
|
+
isAutoincrement: false;
|
|
371
|
+
hasRuntimeDefault: false;
|
|
372
|
+
enumValues: undefined;
|
|
373
|
+
baseColumn: never;
|
|
374
|
+
identity: undefined;
|
|
375
|
+
generated: undefined;
|
|
376
|
+
}, {}, {
|
|
377
|
+
$type: AssignTarget | null;
|
|
378
|
+
}>;
|
|
379
|
+
state: import("drizzle-orm/pg-core").PgColumn<{
|
|
380
|
+
name: "state";
|
|
381
|
+
tableName: `${string}run_tasks`;
|
|
382
|
+
dataType: "string";
|
|
383
|
+
columnType: "PgText";
|
|
384
|
+
data: TaskState;
|
|
385
|
+
driverParam: string;
|
|
386
|
+
notNull: true;
|
|
387
|
+
hasDefault: false;
|
|
388
|
+
isPrimaryKey: false;
|
|
389
|
+
isAutoincrement: false;
|
|
390
|
+
hasRuntimeDefault: false;
|
|
391
|
+
enumValues: [string, ...string[]];
|
|
392
|
+
baseColumn: never;
|
|
393
|
+
identity: undefined;
|
|
394
|
+
generated: undefined;
|
|
395
|
+
}, {}, {
|
|
396
|
+
$type: TaskState;
|
|
397
|
+
}>;
|
|
398
|
+
decision: import("drizzle-orm/pg-core").PgColumn<{
|
|
399
|
+
name: "decision";
|
|
400
|
+
tableName: `${string}run_tasks`;
|
|
401
|
+
dataType: "string";
|
|
402
|
+
columnType: "PgText";
|
|
403
|
+
data: ApprovalDecision;
|
|
404
|
+
driverParam: string;
|
|
405
|
+
notNull: false;
|
|
406
|
+
hasDefault: false;
|
|
407
|
+
isPrimaryKey: false;
|
|
408
|
+
isAutoincrement: false;
|
|
409
|
+
hasRuntimeDefault: false;
|
|
410
|
+
enumValues: [string, ...string[]];
|
|
411
|
+
baseColumn: never;
|
|
412
|
+
identity: undefined;
|
|
413
|
+
generated: undefined;
|
|
414
|
+
}, {}, {
|
|
415
|
+
$type: ApprovalDecision;
|
|
416
|
+
}>;
|
|
417
|
+
comment: import("drizzle-orm/pg-core").PgColumn<{
|
|
418
|
+
name: "comment";
|
|
419
|
+
tableName: `${string}run_tasks`;
|
|
420
|
+
dataType: "string";
|
|
421
|
+
columnType: "PgText";
|
|
422
|
+
data: string;
|
|
423
|
+
driverParam: string;
|
|
424
|
+
notNull: false;
|
|
425
|
+
hasDefault: false;
|
|
426
|
+
isPrimaryKey: false;
|
|
427
|
+
isAutoincrement: false;
|
|
428
|
+
hasRuntimeDefault: false;
|
|
429
|
+
enumValues: [string, ...string[]];
|
|
430
|
+
baseColumn: never;
|
|
431
|
+
identity: undefined;
|
|
432
|
+
generated: undefined;
|
|
433
|
+
}, {}, {}>;
|
|
434
|
+
claimed_by: import("drizzle-orm/pg-core").PgColumn<{
|
|
435
|
+
name: "claimed_by";
|
|
436
|
+
tableName: `${string}run_tasks`;
|
|
437
|
+
dataType: "string";
|
|
438
|
+
columnType: "PgText";
|
|
439
|
+
data: string;
|
|
440
|
+
driverParam: string;
|
|
441
|
+
notNull: false;
|
|
442
|
+
hasDefault: false;
|
|
443
|
+
isPrimaryKey: false;
|
|
444
|
+
isAutoincrement: false;
|
|
445
|
+
hasRuntimeDefault: false;
|
|
446
|
+
enumValues: [string, ...string[]];
|
|
447
|
+
baseColumn: never;
|
|
448
|
+
identity: undefined;
|
|
449
|
+
generated: undefined;
|
|
450
|
+
}, {}, {}>;
|
|
451
|
+
decided_by: import("drizzle-orm/pg-core").PgColumn<{
|
|
452
|
+
name: "decided_by";
|
|
453
|
+
tableName: `${string}run_tasks`;
|
|
454
|
+
dataType: "string";
|
|
455
|
+
columnType: "PgText";
|
|
456
|
+
data: string;
|
|
457
|
+
driverParam: string;
|
|
458
|
+
notNull: false;
|
|
459
|
+
hasDefault: false;
|
|
460
|
+
isPrimaryKey: false;
|
|
461
|
+
isAutoincrement: false;
|
|
462
|
+
hasRuntimeDefault: false;
|
|
463
|
+
enumValues: [string, ...string[]];
|
|
464
|
+
baseColumn: never;
|
|
465
|
+
identity: undefined;
|
|
466
|
+
generated: undefined;
|
|
467
|
+
}, {}, {}>;
|
|
468
|
+
decided_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
469
|
+
name: "decided_at";
|
|
470
|
+
tableName: `${string}run_tasks`;
|
|
471
|
+
dataType: "date";
|
|
472
|
+
columnType: "PgTimestamp";
|
|
473
|
+
data: Date;
|
|
474
|
+
driverParam: string;
|
|
475
|
+
notNull: false;
|
|
476
|
+
hasDefault: false;
|
|
477
|
+
isPrimaryKey: false;
|
|
478
|
+
isAutoincrement: false;
|
|
479
|
+
hasRuntimeDefault: false;
|
|
480
|
+
enumValues: undefined;
|
|
481
|
+
baseColumn: never;
|
|
482
|
+
identity: undefined;
|
|
483
|
+
generated: undefined;
|
|
484
|
+
}, {}, {}>;
|
|
485
|
+
evidence: import("drizzle-orm/pg-core").PgColumn<{
|
|
486
|
+
name: "evidence";
|
|
487
|
+
tableName: `${string}run_tasks`;
|
|
488
|
+
dataType: "string";
|
|
489
|
+
columnType: "PgText";
|
|
490
|
+
data: string;
|
|
491
|
+
driverParam: string;
|
|
492
|
+
notNull: false;
|
|
493
|
+
hasDefault: false;
|
|
494
|
+
isPrimaryKey: false;
|
|
495
|
+
isAutoincrement: false;
|
|
496
|
+
hasRuntimeDefault: false;
|
|
497
|
+
enumValues: [string, ...string[]];
|
|
498
|
+
baseColumn: never;
|
|
499
|
+
identity: undefined;
|
|
500
|
+
generated: undefined;
|
|
501
|
+
}, {}, {}>;
|
|
502
|
+
created_at: import("drizzle-orm/pg-core").PgColumn<{
|
|
503
|
+
name: "created_at";
|
|
504
|
+
tableName: `${string}run_tasks`;
|
|
505
|
+
dataType: "date";
|
|
506
|
+
columnType: "PgTimestamp";
|
|
507
|
+
data: Date;
|
|
508
|
+
driverParam: string;
|
|
509
|
+
notNull: true;
|
|
510
|
+
hasDefault: false;
|
|
511
|
+
isPrimaryKey: false;
|
|
512
|
+
isAutoincrement: false;
|
|
513
|
+
hasRuntimeDefault: false;
|
|
514
|
+
enumValues: undefined;
|
|
515
|
+
baseColumn: never;
|
|
516
|
+
identity: undefined;
|
|
517
|
+
generated: undefined;
|
|
518
|
+
}, {}, {}>;
|
|
519
|
+
};
|
|
520
|
+
dialect: "pg";
|
|
521
|
+
}>;
|
|
522
|
+
};
|
|
523
|
+
export type RunTables = ReturnType<typeof runTables>;
|
|
524
|
+
/** Any drizzle Postgres database (node-postgres, postgres.js, PGlite, Neon, …), whatever its schema. */
|
|
525
|
+
export type RunsDatabase = PgDatabase<PgQueryResultHKT, any>;
|
|
526
|
+
export interface RunsOptions extends RunsBehaviour {
|
|
527
|
+
db: RunsDatabase;
|
|
528
|
+
tables: RunTables;
|
|
529
|
+
}
|
|
530
|
+
export declare function createRuns(options: RunsOptions): Runs;
|