create-protobase 0.96.8 → 0.96.9

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.
Files changed (30) hide show
  1. package/dist/templates/automations/.env.example +8 -0
  2. package/dist/templates/automations/AGENTS.md +28 -0
  3. package/dist/templates/automations/_.gitignore +4 -0
  4. package/dist/templates/automations/_bunfig.toml +4 -0
  5. package/dist/templates/automations/config/index.ts +4 -0
  6. package/dist/templates/automations/config/user-menu.ts +4 -0
  7. package/dist/templates/automations/db/connection.ts +8 -0
  8. package/dist/templates/automations/db/migrate.ts +31 -0
  9. package/dist/templates/automations/db/migrations/.gitkeep +0 -0
  10. package/dist/templates/automations/db/migrations/001_auth.sql +36 -0
  11. package/dist/templates/automations/db/migrations/002_auth_snake_case.sql +109 -0
  12. package/dist/templates/automations/db/migrations/003_auth.sql +6 -0
  13. package/dist/templates/automations/db/migrations/004_auth.sql +4 -0
  14. package/dist/templates/automations/db/migrations/005_auth.sql +4 -0
  15. package/dist/templates/automations/db/migrations/006_auth.sql +319 -0
  16. package/dist/templates/automations/db/migrations/007_auth.sql +19 -0
  17. package/dist/templates/automations/db/migrations/008_auth.sql +20 -0
  18. package/dist/templates/automations/db/migrations/009_auth.sql +7 -0
  19. package/dist/templates/automations/db/migrations/010_jobs.sql +576 -0
  20. package/dist/templates/automations/db/migrations/011_workflows.sql +367 -0
  21. package/dist/templates/automations/node-types.d.ts +1 -0
  22. package/dist/templates/automations/package.json +39 -0
  23. package/dist/templates/automations/protobase.config.ts +15 -0
  24. package/dist/templates/automations/tsconfig.json +24 -0
  25. package/dist/templates/automations/vitest.config.ts +4 -0
  26. package/dist/templates/erp/package.json +6 -6
  27. package/dist/templates/property-portal/package.json +6 -6
  28. package/dist/templates/real-estate/package.json +6 -6
  29. package/dist/templates/scratch/package.json +6 -6
  30. package/package.json +2 -2
@@ -0,0 +1,367 @@
1
+ -- The workflows, their versions, runs and steps, written by `protobase migration`.
2
+ -- Applied with the project's other migrations; edit or remove statements the project handles differently.
3
+
4
+ create schema if not exists "workflows";
5
+
6
+ create table if not exists "workflows"."workflows" (
7
+ "id" uuid primary key default gen_random_uuid(),
8
+ "name" text not null,
9
+ "description" text,
10
+ "definition" jsonb not null,
11
+ "version" integer,
12
+ "tenant_id" text,
13
+ "created_at" timestamptz not null default now(),
14
+ "updated_at" timestamptz not null default now()
15
+ );
16
+
17
+ create table if not exists "workflows"."versions" (
18
+ "workflow_id" uuid not null references "workflows"."workflows" ("id") on delete cascade,
19
+ "version" integer not null,
20
+ "definition" jsonb not null,
21
+ "saved_by" text,
22
+ "tenant_id" text,
23
+ "saved_at" timestamptz not null default now(),
24
+ primary key ("workflow_id", "version")
25
+ );
26
+
27
+ create table if not exists "workflows"."runs" (
28
+ "id" uuid primary key default gen_random_uuid(),
29
+ "workflow_id" uuid not null references "workflows"."workflows" ("id") on delete cascade,
30
+ "version" integer,
31
+ "input" jsonb,
32
+ "key" text,
33
+ "status" text not null default 'queued' check ("status" in ('queued', 'running', 'waiting', 'succeeded', 'failed')),
34
+ "output" jsonb,
35
+ "error" text,
36
+ "cause" text,
37
+ "resume_at" timestamptz,
38
+ "started_by" text,
39
+ "rerun_of" uuid references "workflows"."runs" ("id") on delete set null,
40
+ "replay" boolean,
41
+ "rerun_from" text,
42
+ "tenant_id" text,
43
+ "created_at" timestamptz not null default now(),
44
+ "finished_at" timestamptz,
45
+ "duration_ms" bigint generated always as ((floor(extract(epoch from ("finished_at" - "created_at")) * 1000)::bigint)) stored,
46
+ foreign key ("workflow_id", "version") references "workflows"."versions" ("workflow_id", "version")
47
+ );
48
+
49
+ create table if not exists "workflows"."checkpoints" (
50
+ "run_id" uuid not null references "workflows"."runs" ("id") on delete cascade,
51
+ "scope" text not null,
52
+ "seq" integer not null,
53
+ "follows" integer not null,
54
+ "state" text not null,
55
+ "type" text not null,
56
+ "status" text not null check ("status" in ('succeeded', 'retrying', 'caught')),
57
+ "fetched_at" timestamptz not null,
58
+ "next" text,
59
+ "value" jsonb,
60
+ "variables" jsonb not null,
61
+ "attempt" integer not null,
62
+ "failures" jsonb not null,
63
+ "visits" jsonb not null,
64
+ "resume_at" timestamptz,
65
+ "clock" timestamptz not null,
66
+ primary key ("run_id", "scope")
67
+ );
68
+ alter table "workflows"."runs" add column if not exists "trace" text check ("trace" in ('all', 'failed', 'none'));
69
+ alter table "workflows"."runs" add column if not exists "trace_file" text;
70
+
71
+ drop table if exists "workflows"."steps";
72
+
73
+ alter table "workflows"."workflows" add column if not exists "enabled_version" integer;
74
+ do $$ begin
75
+ if not exists (select 1 from pg_constraint where conname = 'workflows_enabled_version' and connamespace = 'workflows'::regnamespace) then
76
+ alter table "workflows"."workflows" add constraint "workflows_enabled_version" foreign key ("id", "enabled_version") references "workflows"."versions" ("workflow_id", "version") deferrable initially deferred;
77
+ end if;
78
+ end $$;
79
+ -- Who turned the version on, signed in as themselves: the consent its runs sign in through their connections with.
80
+ alter table "workflows"."versions" add column if not exists "enabled_by" text;
81
+ create table if not exists "workflows"."triggers" (
82
+ "id" uuid primary key default gen_random_uuid(),
83
+ "workflow_id" uuid references "workflows"."workflows" ("id") on delete set null,
84
+ "version" integer not null,
85
+ "tenant_id" text,
86
+ "type" text not null,
87
+ "input" jsonb not null,
88
+ "connection_id" text,
89
+ "status" text not null check ("status" in ('active', 'failing', 'needs_sign_in', 'stopping')),
90
+ "generation" integer not null,
91
+ "cursor" jsonb check (octet_length("cursor"::text) <= 65536),
92
+ "store" jsonb check (octet_length("store"::text) <= 65536),
93
+ "poll_job_id" text,
94
+ "poll_attempt" integer,
95
+ "consecutive_failures" integer not null,
96
+ "last_error" jsonb,
97
+ "next_poll_at" timestamptz,
98
+ "created_at" timestamptz not null default now(),
99
+ "updated_at" timestamptz not null default now()
100
+ );
101
+ alter table "workflows"."triggers" add column if not exists "poll_attempt" integer;
102
+ -- Who turned the trigger's version on: the only person whose account its stop job ends the subscription through.
103
+ alter table "workflows"."triggers" add column if not exists "enabled_by" text;
104
+ -- A deleted workflow's trigger stays, without its workflow, until its stop job unsubscribed it at its provider.
105
+ alter table "workflows"."triggers" alter column "workflow_id" drop not null;
106
+ do $$ begin
107
+ if exists (select 1 from pg_constraint where conname = 'triggers_workflow_id_fkey' and confdeltype = 'c' and connamespace = 'workflows'::regnamespace) then
108
+ alter table "workflows"."triggers" drop constraint "triggers_workflow_id_fkey";
109
+ alter table "workflows"."triggers" add constraint "triggers_workflow_id_fkey" foreign key ("workflow_id") references "workflows"."workflows" ("id") on delete set null;
110
+ end if;
111
+ end $$;
112
+ create unique index if not exists "triggers_workflow" on "workflows"."triggers" ("workflow_id") where "status" <> 'stopping';
113
+ create index if not exists "triggers_workflow_id" on "workflows"."triggers" ("workflow_id");
114
+ create index if not exists "triggers_updated_at" on "workflows"."triggers" ("updated_at");
115
+ create index if not exists "triggers_status_type" on "workflows"."triggers" ("status", "type");
116
+ create index if not exists "triggers_connection" on "workflows"."triggers" ("connection_id");
117
+ create index if not exists "triggers_tenant" on "workflows"."triggers" ("tenant_id");
118
+
119
+ create table if not exists "workflows"."effects" (
120
+ "run_id" uuid not null references "workflows"."runs" ("id") on delete cascade,
121
+ "key" text not null,
122
+ "result" jsonb,
123
+ primary key ("run_id", "key")
124
+ );
125
+
126
+ create table if not exists "workflows"."connection_revocations" (
127
+ "id" uuid primary key default gen_random_uuid(),
128
+ "provider" text not null,
129
+ "hint" text not null check ("hint" in ('refresh_token', 'access_token')),
130
+ "token" text not null,
131
+ "created_at" timestamptz not null default now()
132
+ );
133
+
134
+ create table if not exists "workflows"."hooks" (
135
+ "workflow_id" uuid primary key references "workflows"."workflows" ("id") on delete cascade,
136
+ "key_hash" text not null unique,
137
+ "secret" text,
138
+ "secret_hash" text not null,
139
+ "tenant_id" text,
140
+ "created_at" timestamptz not null default now()
141
+ );
142
+
143
+ create table if not exists "workflows"."step_cache" (
144
+ "type" text not null,
145
+ "key" text not null,
146
+ "who" jsonb not null,
147
+ "tenant_id" text,
148
+ "output" jsonb,
149
+ "secrets" jsonb not null,
150
+ "cached_at" timestamptz not null default now(),
151
+ "expires_at" timestamptz not null,
152
+ primary key ("type", "key", "who")
153
+ );
154
+ create index if not exists "step_cache_expires" on "workflows"."step_cache" ("type", "tenant_id", "expires_at");
155
+ create table if not exists "workflows"."step_cache_shapes" (
156
+ "type" text not null,
157
+ "shape" jsonb not null,
158
+ primary key ("type", "shape")
159
+ );
160
+
161
+ create extension if not exists pg_trgm;
162
+ create index if not exists "workflows_tenant" on "workflows"."workflows" ("tenant_id");
163
+ create index if not exists "workflows_name" on "workflows"."workflows" ("name");
164
+ create index if not exists "workflows_updated_at" on "workflows"."workflows" ("updated_at");
165
+ create index if not exists "workflows_name_search" on "workflows"."workflows" using gin ("name" gin_trgm_ops);
166
+ create index if not exists "versions_tenant" on "workflows"."versions" ("tenant_id");
167
+ create index if not exists "versions_version" on "workflows"."versions" ("version");
168
+ alter table "workflows"."runs" add column if not exists "key" text;
169
+ create unique index if not exists "runs_key" on "workflows"."runs" ("workflow_id", "key");
170
+ alter table "workflows"."runs" add column if not exists "rerun_of" uuid references "workflows"."runs" ("id") on delete set null;
171
+ create index if not exists "runs_rerun_of" on "workflows"."runs" ("rerun_of");
172
+ alter table "workflows"."runs" add column if not exists "replay" boolean;
173
+ create index if not exists "runs_workflow" on "workflows"."runs" ("workflow_id", "created_at");
174
+ create index if not exists "runs_tenant" on "workflows"."runs" ("tenant_id");
175
+ create index if not exists "runs_status" on "workflows"."runs" ("status");
176
+ create index if not exists "runs_created_at" on "workflows"."runs" ("created_at");
177
+
178
+ alter table "workflows"."runs" add column if not exists "block_of" uuid references "workflows"."runs" ("id") on delete set null;
179
+ alter table "workflows"."runs" add column if not exists "block_state" text;
180
+ alter table "workflows"."runs" add column if not exists "block_visit" text;
181
+ alter table "workflows"."runs" add column if not exists "output_blanked" boolean;
182
+ create index if not exists "runs_block_of" on "workflows"."runs" ("block_of");
183
+ create unique index if not exists "runs_block_visit" on "workflows"."runs" ("block_of", "block_visit") where "block_of" is not null;
184
+ alter table "workflows"."runs" add column if not exists "block_key" text;
185
+ alter table "workflows"."runs" add column if not exists "block_who" text;
186
+ alter table "workflows"."runs" drop constraint if exists "runs_block_shared";
187
+ alter table "workflows"."runs" add constraint "runs_block_shared" check (("block_key" is null) = ("block_who" is null));
188
+ create unique index if not exists "runs_block_in_flight" on "workflows"."runs" ("block_key", "block_who") where "block_key" is not null and "block_who" is not null and "status" in ('queued', 'running', 'waiting');
189
+ create table if not exists "workflows"."block_waiters" (
190
+ "parent" uuid not null references "workflows"."runs" ("id") on delete cascade,
191
+ "visit" text not null,
192
+ "run_id" uuid not null references "workflows"."runs" ("id") on delete cascade,
193
+ primary key ("parent", "visit")
194
+ );
195
+ create index if not exists "block_waiters_run" on "workflows"."block_waiters" ("run_id");
196
+
197
+ alter table "workflows"."runs" add column if not exists "rerun_from" text;
198
+
199
+ alter table "workflows"."workflows" alter column "definition" set default '{"trigger":{"manual":{}},"stateMachine":{"QueryLanguage":"JSONata","StartAt":"","States":{}}}'::jsonb;
200
+
201
+ create or replace function "workflows"."workflow_version"() returns trigger
202
+ language plpgsql as $$
203
+ begin
204
+ if tg_op = 'INSERT' then
205
+ new.version := 1;
206
+ return new;
207
+ end if;
208
+ -- The write holds the row, so a save in another transaction numbers its version after this one.
209
+ new.version := case when new.definition is distinct from old.definition then coalesce(old.version, 0) + 1 else old.version end;
210
+ -- Its status, which runs ending and marks as resolved write, is no change to the workflow itself.
211
+ -- Otherwise never the same twice, nor now(): two writes in one transaction, as a batch that saves and publishes, are two ETags.
212
+ if to_jsonb(new) - array['run_status', 'status_run_id', 'status_run_at', 'unresolved_failures', 'resolved_at', 'resolved_by', 'updated_at'] is distinct from to_jsonb(old) - array['run_status', 'status_run_id', 'status_run_at', 'unresolved_failures', 'resolved_at', 'resolved_by', 'updated_at'] then
213
+ new.updated_at := greatest(clock_timestamp(), old.updated_at + interval '1 microsecond');
214
+ end if;
215
+ return new;
216
+ end
217
+ $$;
218
+ drop trigger if exists "workflow_version" on "workflows"."workflows";
219
+ create trigger "workflow_version" before insert or update on "workflows"."workflows" for each row execute function "workflows"."workflow_version"();
220
+
221
+ create or replace function "workflows"."run_version"() returns trigger
222
+ language plpgsql as $$
223
+ declare
224
+ found record;
225
+ begin
226
+ select w.id, w.version, w.enabled_version, w.tenant_id into found from "workflows"."workflows" w where w.id = new.workflow_id;
227
+ -- Another tenant's workflow is refused as one that is not there, so a start tells nothing of other tenants.
228
+ if found.id is null or new.tenant_id is distinct from found.tenant_id then
229
+ raise exception 'There is no workflow % here', new.workflow_id using errcode = '23503';
230
+ end if;
231
+ if found.version is null then
232
+ raise exception 'Workflow % has no saved version', new.workflow_id using errcode = '23503';
233
+ end if;
234
+ if new.version is not null and not exists (select from "workflows"."versions" v where v.workflow_id = new.workflow_id and v.version = new.version) then
235
+ raise exception 'Workflow % has no version %', new.workflow_id, new.version using errcode = '23503';
236
+ end if;
237
+ -- A replay replays a run of this workflow and tenant.
238
+ if new.replay then
239
+ if not exists (select from "workflows"."runs" r
240
+ where r.id = new.rerun_of and r.workflow_id = new.workflow_id and r.tenant_id is not distinct from new.tenant_id) then
241
+ raise exception 'There is no run % of workflow % here to replay', new.rerun_of, new.workflow_id using errcode = '23503';
242
+ end if;
243
+ end if;
244
+ -- A re-run or a replay tries a fix, so it runs the version saved last. Any other start not naming its version runs
245
+ -- what is published, so a saved change stays out of production until it is, or the version saved last on a workflow that is off.
246
+ if new.version is null then
247
+ new.version := case when new.rerun_of is null then coalesce(found.enabled_version, found.version) else found.version end;
248
+ end if;
249
+ -- Checked on the version the run takes, which a re-run or a replay takes otherwise than a start
250
+ if exists (select from "workflows"."versions" v where v.workflow_id = new.workflow_id and v.version = new.version and v.definition -> 'stateMachine' -> 'States' = '{}'::jsonb) then
251
+ raise exception 'Workflow % has no steps to run', new.workflow_id using errcode = '23503';
252
+ end if;
253
+ -- A re-run or a replay of a block's run runs that Block's processor again, alone.
254
+ if new.rerun_of is not null then
255
+ select r.input, r.block_state into new.input, new.block_state from "workflows"."runs" r where r.id = new.rerun_of and r.workflow_id = new.workflow_id;
256
+ end if;
257
+ return new;
258
+ end
259
+ $$;
260
+ comment on function "workflows"."run_version"() is 'Protobase workflows 22';
261
+ drop trigger if exists "run_version" on "workflows"."runs";
262
+ create trigger "run_version" before insert on "workflows"."runs" for each row execute function "workflows"."run_version"();
263
+
264
+ alter table "workflows"."workflows" add column if not exists "run_status" text not null default 'no_runs';
265
+ alter table "workflows"."workflows" add column if not exists "status_run_id" uuid;
266
+ alter table "workflows"."workflows" add column if not exists "status_run_at" timestamptz;
267
+ alter table "workflows"."workflows" add column if not exists "unresolved_failures" integer not null default 0;
268
+ alter table "workflows"."workflows" add column if not exists "resolved_at" timestamptz;
269
+ alter table "workflows"."workflows" add column if not exists "resolved_by" text;
270
+ do $$ begin
271
+ if not exists (select 1 from pg_constraint where conname = 'workflows_run_status' and connamespace = 'workflows'::regnamespace) then
272
+ alter table "workflows"."workflows" add constraint "workflows_run_status" check ("run_status" in ('failing', 'unresolved', 'healthy', 'no_runs', 'resolved', 'new_version'));
273
+ end if;
274
+ end $$;
275
+ create table if not exists "workflows"."resolutions" (
276
+ "id" uuid primary key default gen_random_uuid(),
277
+ "workflow_id" uuid not null references "workflows"."workflows" ("id") on delete cascade,
278
+ "resolved_by" text,
279
+ "tenant_id" text,
280
+ "resolved_at" timestamptz not null default now()
281
+ );
282
+ create index if not exists "resolutions_workflow" on "workflows"."resolutions" ("workflow_id", "resolved_at");
283
+ create index if not exists "resolutions_tenant" on "workflows"."resolutions" ("tenant_id");
284
+ create index if not exists "resolutions_resolved_at" on "workflows"."resolutions" ("resolved_at");
285
+ create index if not exists "runs_ended" on "workflows"."runs" ("workflow_id", "finished_at" desc, "id" desc) where "status" in ('succeeded', 'failed');
286
+ -- The runs a workflow's status counts, so its status skips no blocks' runs, of which a run starts many, to find them.
287
+ create index if not exists "runs_ended_top" on "workflows"."runs" ("workflow_id", "finished_at" desc, "id" desc) where "status" in ('succeeded', 'failed') and "block_of" is null;
288
+
289
+ -- The status of a workflow at its version and last mark as resolved, from its last 10 ended runs, blocks' runs left out
290
+ -- (a block's failure is its run's): the run its
291
+ -- reason names is the latest for failing and healthy, the latest failure that counts for unresolved, none for the gray ones.
292
+ create or replace function "workflows"."workflow_status"(workflow uuid, current_version integer, resolved timestamptz)
293
+ returns table ("run_status" text, "status_run_id" uuid, "status_run_at" timestamptz, "unresolved_failures" integer)
294
+ language sql stable as $$
295
+ with ended as (
296
+ select r.id, r.finished_at, r.version, r.status = 'failed' as failed,
297
+ r.status = 'failed' and r.version = current_version and (resolved is null or r.finished_at > resolved) as counts,
298
+ row_number() over (order by r.finished_at desc, r.id desc) as n
299
+ from (select * from "workflows"."runs" where workflow_id = workflow and block_of is null and status in ('succeeded', 'failed') order by finished_at desc, id desc limit 10) r
300
+ ),
301
+ latest as (select * from ended where n = 1),
302
+ failure as (select * from ended where counts order by n limit 1),
303
+ shown as (
304
+ select case
305
+ when l.id is null then 'no_runs'
306
+ when l.counts then 'failing'
307
+ when l.failed and l.version is distinct from current_version then 'new_version'
308
+ when l.failed then 'resolved'
309
+ when f.id is not null then 'unresolved'
310
+ else 'healthy'
311
+ end as status, l.id as latest_id, l.finished_at as latest_at, f.id as failure_id, f.finished_at as failure_at
312
+ from (select) one left join latest l on true left join failure f on true
313
+ )
314
+ select status,
315
+ case status when 'unresolved' then failure_id when 'failing' then latest_id when 'healthy' then latest_id end,
316
+ case status when 'unresolved' then failure_at when 'failing' then latest_at when 'healthy' then latest_at end,
317
+ (select count(*)::integer from ended where counts)
318
+ from shown
319
+ $$;
320
+
321
+ -- A new version or a mark as resolved counts the failures again. Named to run after "workflow_version", which numbers the version.
322
+ create or replace function "workflows"."workflow_version_status"() returns trigger
323
+ language plpgsql as $$
324
+ begin
325
+ if new.version is distinct from old.version or new.resolved_at is distinct from old.resolved_at then
326
+ select st.run_status, st.status_run_id, st.status_run_at, st.unresolved_failures
327
+ into new.run_status, new.status_run_id, new.status_run_at, new.unresolved_failures
328
+ from "workflows"."workflow_status"(new.id, new.version, new.resolved_at) st;
329
+ end if;
330
+ return new;
331
+ end
332
+ $$;
333
+ drop trigger if exists "workflow_version_status" on "workflows"."workflows";
334
+ create trigger "workflow_version_status" before update on "workflows"."workflows" for each row execute function "workflows"."workflow_version_status"();
335
+
336
+ -- A run that ends computes its workflow's status again. The workflow is locked first, in a statement of its own, so a
337
+ -- run of it ending at the same time has committed before the update's snapshot is taken, and the status counts both.
338
+ create or replace function "workflows"."run_status"() returns trigger
339
+ language plpgsql as $$
340
+ begin
341
+ perform 1 from "workflows"."workflows" where id = new.workflow_id for no key update;
342
+ update "workflows"."workflows" w set ("run_status", "status_run_id", "status_run_at", "unresolved_failures") =
343
+ (select st.run_status, st.status_run_id, st.status_run_at, st.unresolved_failures from "workflows"."workflow_status"(w.id, w.version, w.resolved_at) st)
344
+ where w.id = new.workflow_id;
345
+ return null;
346
+ end
347
+ $$;
348
+ drop trigger if exists "run_status" on "workflows"."runs";
349
+ create trigger "run_status" after update of "status" on "workflows"."runs" for each row
350
+ when (new.status in ('succeeded', 'failed') and old.status is distinct from new.status and new.block_of is null) execute function "workflows"."run_status"();
351
+
352
+ -- Marking a workflow resolved: refused for another tenant's workflow as one that is not there, then copied onto it.
353
+ create or replace function "workflows"."resolution"() returns trigger
354
+ language plpgsql as $$
355
+ begin
356
+ if not exists (select from "workflows"."workflows" w where w.id = new.workflow_id and w.tenant_id is not distinct from new.tenant_id) then
357
+ raise exception 'There is no workflow % here', new.workflow_id using errcode = '23503';
358
+ end if;
359
+ update "workflows"."workflows" set "resolved_at" = new.resolved_at, "resolved_by" = new.resolved_by where id = new.workflow_id;
360
+ return null;
361
+ end
362
+ $$;
363
+ drop trigger if exists "resolution" on "workflows"."resolutions";
364
+ create trigger "resolution" after insert on "workflows"."resolutions" for each row execute function "workflows"."resolution"();
365
+
366
+ update "workflows"."workflows" w set ("run_status", "status_run_id", "status_run_at", "unresolved_failures") =
367
+ (select st.run_status, st.status_run_id, st.status_run_at, st.unresolved_failures from "workflows"."workflow_status"(w.id, w.version, w.resolved_at) st);
@@ -0,0 +1 @@
1
+ /// <reference types="node" />
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "automations",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "db:migrate": "protobase run db/migrate.ts",
8
+ "typecheck": "protobase types && tsc --noEmit",
9
+ "test": "protobase types && vitest run",
10
+ "protobase": "protobase",
11
+ "build": "protobase build",
12
+ "serve": "protobase build && protobase serve dist",
13
+ "dev": "protobase dev"
14
+ },
15
+ "dependencies": {
16
+ "better-auth": "^1.7.12",
17
+ "jose": "^6.2.12",
18
+ "kysely": "^0.29.6",
19
+ "pg": "^8.23.1",
20
+ "postgres": "^3.4.9",
21
+ "react": "^19.3.0",
22
+ "react-email": "^6.11.1",
23
+ "sharp": "^0.35.5",
24
+ "zod": "^4.6.5"
25
+ },
26
+ "devDependencies": {
27
+ "@protobase/cli": "^0.96.9",
28
+ "@protobase/config": "^0.96.9",
29
+ "@protobase/layout": "^0.96.9",
30
+ "@protobase/schema": "^0.96.9",
31
+ "@protobase/server": "^0.96.9",
32
+ "@protobase/ui": "^0.96.9",
33
+ "@types/node": "^22.20.5",
34
+ "@types/pg": "^8.23.1",
35
+ "@types/react": "^19.3.0",
36
+ "typescript": "^6.0.3",
37
+ "vitest": "^5.0.3"
38
+ }
39
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from '@protobase/config'
2
+
3
+ // The whole app, as one object; it grows as the app does. Its resources are found in config/. Its address and secret
4
+ // are Protobase's defaults, PROTOBASE_URL and PROTOBASE_SECRET (see .env.example).
5
+ export default defineConfig({
6
+ auth: {
7
+ // No defaultRole on purpose: every account is created with an explicit role (`protobase users create --role`).
8
+ roles: ['admin'],
9
+ },
10
+ // Every user works in tenant 1, which access rules can compare with an organization_id column.
11
+ authenticate: { tenant: 1 },
12
+ // Workflows on, with their jobs: build, test-run and publish them on the Workflows page. Their traces and stored
13
+ // files stay in this folder's data/ directory.
14
+ workflows: {},
15
+ })
@@ -0,0 +1,24 @@
1
+ {
2
+ "extends": "./.protobase/tsconfig.json",
3
+ "compilerOptions": {
4
+ "target": "ES2023",
5
+ "lib": [
6
+ "ES2023",
7
+ "DOM",
8
+ "DOM.Iterable"
9
+ ],
10
+ "module": "ESNext",
11
+ "moduleResolution": "Bundler",
12
+ "jsx": "react-jsx",
13
+ "strict": true,
14
+ "noUncheckedIndexedAccess": true,
15
+ "verbatimModuleSyntax": true,
16
+ "isolatedModules": true,
17
+ "skipLibCheck": true,
18
+ "noEmit": true
19
+ },
20
+ "exclude": [
21
+ "node_modules",
22
+ "dist"
23
+ ]
24
+ }
@@ -0,0 +1,4 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ // Unit tests sit next to the code they test; a new project has none yet.
4
+ export default defineConfig({ test: { include: ['**/*.test.ts'], exclude: ['node_modules/**', 'dist/**'], passWithNoTests: true } })
@@ -27,12 +27,12 @@
27
27
  "zod": "^4.6.5"
28
28
  },
29
29
  "devDependencies": {
30
- "@protobase/cli": "^0.96.8",
31
- "@protobase/config": "^0.96.8",
32
- "@protobase/layout": "^0.96.8",
33
- "@protobase/schema": "^0.96.8",
34
- "@protobase/server": "^0.96.8",
35
- "@protobase/ui": "^0.96.8",
30
+ "@protobase/cli": "^0.96.9",
31
+ "@protobase/config": "^0.96.9",
32
+ "@protobase/layout": "^0.96.9",
33
+ "@protobase/schema": "^0.96.9",
34
+ "@protobase/server": "^0.96.9",
35
+ "@protobase/ui": "^0.96.9",
36
36
  "@types/node": "^22.20.5",
37
37
  "@types/pg": "^8.23.1",
38
38
  "@types/react": "^19.3.0",
@@ -27,12 +27,12 @@
27
27
  "zod": "^4.6.5"
28
28
  },
29
29
  "devDependencies": {
30
- "@protobase/cli": "^0.96.8",
31
- "@protobase/config": "^0.96.8",
32
- "@protobase/layout": "^0.96.8",
33
- "@protobase/schema": "^0.96.8",
34
- "@protobase/server": "^0.96.8",
35
- "@protobase/ui": "^0.96.8",
30
+ "@protobase/cli": "^0.96.9",
31
+ "@protobase/config": "^0.96.9",
32
+ "@protobase/layout": "^0.96.9",
33
+ "@protobase/schema": "^0.96.9",
34
+ "@protobase/server": "^0.96.9",
35
+ "@protobase/ui": "^0.96.9",
36
36
  "@types/node": "^22.20.5",
37
37
  "@types/pg": "^8.23.1",
38
38
  "@types/react": "^19.3.0",
@@ -27,12 +27,12 @@
27
27
  "zod": "^4.6.5"
28
28
  },
29
29
  "devDependencies": {
30
- "@protobase/cli": "^0.96.8",
31
- "@protobase/config": "^0.96.8",
32
- "@protobase/layout": "^0.96.8",
33
- "@protobase/schema": "^0.96.8",
34
- "@protobase/server": "^0.96.8",
35
- "@protobase/ui": "^0.96.8",
30
+ "@protobase/cli": "^0.96.9",
31
+ "@protobase/config": "^0.96.9",
32
+ "@protobase/layout": "^0.96.9",
33
+ "@protobase/schema": "^0.96.9",
34
+ "@protobase/server": "^0.96.9",
35
+ "@protobase/ui": "^0.96.9",
36
36
  "@types/node": "^22.20.5",
37
37
  "@types/pg": "^8.23.1",
38
38
  "@types/react": "^19.3.0",
@@ -24,12 +24,12 @@
24
24
  "zod": "^4.6.5"
25
25
  },
26
26
  "devDependencies": {
27
- "@protobase/cli": "^0.96.8",
28
- "@protobase/config": "^0.96.8",
29
- "@protobase/layout": "^0.96.8",
30
- "@protobase/schema": "^0.96.8",
31
- "@protobase/server": "^0.96.8",
32
- "@protobase/ui": "^0.96.8",
27
+ "@protobase/cli": "^0.96.9",
28
+ "@protobase/config": "^0.96.9",
29
+ "@protobase/layout": "^0.96.9",
30
+ "@protobase/schema": "^0.96.9",
31
+ "@protobase/server": "^0.96.9",
32
+ "@protobase/ui": "^0.96.9",
33
33
  "@types/node": "^22.20.5",
34
34
  "@types/pg": "^8.23.1",
35
35
  "@types/react": "^19.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-protobase",
3
- "version": "0.96.8",
3
+ "version": "0.96.9",
4
4
  "description": "npm create protobase: starts a new Protobase project from one of its presets, or on an existing Postgres database.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "postgres": "^3.4.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@protobase/cli": "0.96.8"
31
+ "@protobase/cli": "0.96.9"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"