@processfocus/cli 0.1.0-next.2 → 0.1.0-next.4

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 (45) hide show
  1. package/README.md +89 -698
  2. package/dist/bundle-organisation.mjs +2 -0
  3. package/dist/bundled-db-import.mjs +103 -120
  4. package/dist/bundled-graphql-schema.mjs +17 -15
  5. package/dist/command-reference.md +571 -0
  6. package/dist/main.mjs +326 -303
  7. package/dist/pfcli.usage.kdl +377 -0
  8. package/dist/prepare-deployment-artifact.mjs +2 -2
  9. package/dist/resources/cedar/policies.cedar +80 -38
  10. package/dist/resources/cedar/schema.cedarschema +39 -21
  11. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/migration.sql +1 -0
  12. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/snapshot.json +7708 -0
  13. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/migration.sql +14 -0
  14. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/snapshot.json +7852 -0
  15. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/migration.sql +4 -0
  16. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/snapshot.json +7908 -0
  17. package/dist/resources/system-migrations/20261023074259_previous_falcon/migration.sql +1 -0
  18. package/dist/resources/system-migrations/20261023074259_previous_falcon/snapshot.json +7918 -0
  19. package/dist/resources/system-migrations/20261023211931_black_vision/migration.sql +1 -0
  20. package/dist/resources/system-migrations/20261023211931_black_vision/snapshot.json +7928 -0
  21. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/migration.sql +4 -0
  22. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/snapshot.json +7968 -0
  23. package/dist/resources/system-migrations/20261025201326_confused_mordo/migration.sql +25 -0
  24. package/dist/resources/system-migrations/20261025201326_confused_mordo/snapshot.json +8141 -0
  25. package/dist/resources/system-migrations/20261025225809_pink_mysterio/migration.sql +20 -0
  26. package/dist/resources/system-migrations/20261025225809_pink_mysterio/snapshot.json +8350 -0
  27. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/migration.sql +1 -0
  28. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/snapshot.json +8360 -0
  29. package/dist/resources/system-migrations/20261101232313_curved_siren/migration.sql +3 -0
  30. package/dist/resources/system-migrations/20261101232313_curved_siren/snapshot.json +8390 -0
  31. package/dist/resources/system-migrations/20261111225459_real_overlord/migration.sql +13 -0
  32. package/dist/resources/system-migrations/20261111225459_real_overlord/snapshot.json +8511 -0
  33. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/migration.sql +1 -0
  34. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/snapshot.json +8501 -0
  35. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/migration.sql +1 -0
  36. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/snapshot.json +8511 -0
  37. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/migration.sql +3 -0
  38. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/snapshot.json +8511 -0
  39. package/dist/resources/system-migrations/20261119223342_lucky_lester/migration.sql +3 -0
  40. package/dist/resources/system-migrations/20261119223342_lucky_lester/snapshot.json +8367 -0
  41. package/dist/resources/system-migrations/20261123050259_sad_dagger/migration.sql +1 -0
  42. package/dist/resources/system-migrations/20261123050259_sad_dagger/snapshot.json +8377 -0
  43. package/dist/resources/system-migrations/20261127002114_worthless_hairball/migration.sql +17 -0
  44. package/dist/resources/system-migrations/20261127002114_worthless_hairball/snapshot.json +8550 -0
  45. package/package.json +11 -9
@@ -0,0 +1,377 @@
1
+ name "pfcli"
2
+ bin "pfcli"
3
+ version "0.1.0-next.4"
4
+ about "Process Focus CLI Tool"
5
+ cmd "init" help="Initialise a new organisation directory with template files and auth scaffolding" {
6
+ flag "--identity-provider" help="Identity provider to scaffold (repeatable: google, github, microsoft, apple, discord, spotify, slack, linkedin, twitch, yahoo, x, keycloak, cognito, jumpcloud, facebook)" var=#true {
7
+ arg "<choice>" {
8
+ choices "google" "github" "microsoft" "apple" "discord" "spotify" "slack" "linkedin" "twitch" "yahoo" "x" "keycloak" "cognito" "jumpcloud" "facebook"
9
+ }
10
+ }
11
+ flag "--email" help="Admin email used for the scaffolded invitation and Cedar policy" required=#true {
12
+ arg "<string>"
13
+ }
14
+ arg "<org-path>" help="Path to the organisation directory (or PF_ORG)"
15
+ }
16
+ cmd "import" help="Import organisation to SQLite database (uses PF_ORG, SQLITE_DATABASE_PATH, or $org-path/db/pf.db)" {
17
+ flag "--watch" help="Run an experimental watched import loop with debounce, timing and recovery" default="false"
18
+ flag "--watch-skip-initial" help="Start watch mode without its initial import after a separate bootstrap import has completed" default="false"
19
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
20
+ arg "<string>"
21
+ }
22
+ flag "--issuer-url" help="Frontend JWT issuer URL (overrides OAUTH_ISSUER_URL)" {
23
+ arg "<string>"
24
+ }
25
+ arg "<org-path>" help="Path to the organisation directory (or PF_ORG)"
26
+ }
27
+ cmd "build" help="Build organisation artifacts (bundled JS, GraphQL schema, Cedar policies)" {
28
+ flag "-o --output" help="Output directory for build artifacts" default="dist" {
29
+ arg "<string>"
30
+ }
31
+ arg "<org-path>" help="Path to the organisation directory"
32
+ }
33
+ cmd "projects" help="List projects in the Backend environment (tab-separated: number, name)"
34
+ cmd "project" help="Manage projects" {
35
+ cmd "create" help="Create a project and wait for its project-number receipt" {
36
+ flag "--name" required=#true {
37
+ arg "<string>"
38
+ }
39
+ flag "--region" required=#true {
40
+ arg "<string>"
41
+ }
42
+ }
43
+ }
44
+ cmd "workload" help="Manage OIDC federation registrations for GitHub Actions" {
45
+ cmd "list" {
46
+ flag "--project" required=#true {
47
+ arg "<string>"
48
+ }
49
+ flag "--client-id" {
50
+ arg "<string>"
51
+ }
52
+ }
53
+ cmd "save" {
54
+ flag "--project" required=#true {
55
+ arg "<string>"
56
+ }
57
+ flag "--client-id" {
58
+ arg "<string>"
59
+ }
60
+ flag "--name" required=#true {
61
+ arg "<string>"
62
+ }
63
+ flag "--repository" required=#true {
64
+ arg "<string>"
65
+ }
66
+ flag "--branch" required=#true {
67
+ arg "<string>"
68
+ }
69
+ flag "--workflow" required=#true {
70
+ arg "<string>"
71
+ }
72
+ flag "--environment" help="GitHub Environment name; omit for jobs without an environment (also clears the setting on edits)" {
73
+ arg "<string>"
74
+ }
75
+ flag "--permissions" help="Comma-separated deploy,create-environment,destroy-environment,database-download,database-upload" required=#true {
76
+ arg "<string>"
77
+ }
78
+ flag "--disabled" default="false"
79
+ flag "--events" default="push,workflow_dispatch" {
80
+ arg "<string>"
81
+ }
82
+ }
83
+ cmd "remove" {
84
+ flag "--project" required=#true {
85
+ arg "<string>"
86
+ }
87
+ flag "--client-id" required=#true {
88
+ arg "<string>"
89
+ }
90
+ }
91
+ cmd "enroll" help="Enroll federated identity"
92
+ }
93
+ cmd "deploy" help="Build and deploy an organisation. Ctrl-C stops waiting, not deployment. Use deploy status before retrying." {
94
+ flag "--project" help="Project number (or internal ID) to deploy" {
95
+ arg "<string>"
96
+ }
97
+ flag "--env" help="Environment name to deploy to" {
98
+ arg "<string>"
99
+ }
100
+ flag "--no-wait" help="Return after starting the deployment without waiting" default="false"
101
+ flag "--execution-id" help="Persisted execution identity for automation receipt reconciliation" {
102
+ arg "<string>"
103
+ }
104
+ flag "--wait-timeout-ms" help="Positive deployment inactivity timeout in milliseconds (overrides PFCLI_DEPLOY_WAIT_TIMEOUT_MS; incompatible with --no-wait)" {
105
+ arg "<int>"
106
+ }
107
+ arg "<org-path>" help="Path to the organisation directory"
108
+ cmd "status" help="Check the active Backend deployment without starting one" {
109
+ flag "--project" required=#true {
110
+ arg "<string>"
111
+ }
112
+ flag "--env" required=#true {
113
+ arg "<string>"
114
+ }
115
+ }
116
+ }
117
+ cmd "destroy" help="Destroy a hosted project environment and wait for completion by default" {
118
+ flag "--project" help="Project number (or internal ID) to destroy from" {
119
+ arg "<string>"
120
+ }
121
+ flag "--env" help="Environment name (or internal ID) to destroy" {
122
+ arg "<string>"
123
+ }
124
+ flag "--yes" help="Confirm deletion of the environment's AWS stacks and environment record" default="false"
125
+ flag "--no-wait" help="Return after starting destruction without waiting" default="false"
126
+ flag "--execution-id" help="Persisted execution identity for automation receipt reconciliation" {
127
+ arg "<string>"
128
+ }
129
+ }
130
+ cmd "logs" help="Show recent primary runtime logs" {
131
+ flag "--project" help="Project number (or internal ID) whose runtime logs to read" {
132
+ arg "<string>"
133
+ }
134
+ flag "--env" help="Environment name whose runtime logs to read" {
135
+ arg "<string>"
136
+ }
137
+ }
138
+ cmd "canary-logs" help="Show recent canary runtime logs" {
139
+ flag "--project" help="Project number (or internal ID) whose runtime logs to read" {
140
+ arg "<string>"
141
+ }
142
+ flag "--env" help="Environment name whose runtime logs to read" {
143
+ arg "<string>"
144
+ }
145
+ }
146
+ cmd "db" help="Database commands" {
147
+ cmd "rollback" help="Start a database rollback preparation process and wait for completion by default" {
148
+ flag "--project" help="Project number (or internal ID) to roll back" {
149
+ arg "<string>"
150
+ }
151
+ flag "--env" help="Environment name to roll back" {
152
+ arg "<string>"
153
+ }
154
+ flag "--timestamp" help="RFC3339 / ISO-8601 rollback timestamp; if no timezone is supplied, the local terminal timezone is used (for example 2026-04-16T18:00:00)" {
155
+ arg "<string>"
156
+ }
157
+ flag "--no-wait" help="Return after starting the rollback without waiting" default="false"
158
+ }
159
+ cmd "download" help="Download a hosted environment database to a local path" {
160
+ flag "--project" help="Project number (or internal ID) to download from" {
161
+ arg "<string>"
162
+ }
163
+ flag "--env" help="Environment name to download from" {
164
+ arg "<string>"
165
+ }
166
+ flag "--output" help="Output SQLite file path" {
167
+ arg "<string>"
168
+ }
169
+ }
170
+ cmd "upload" help="Upload and apply a local SQLite database through a signed document-store URL" {
171
+ flag "--project" help="Project number (or internal ID) to upload to" {
172
+ arg "<string>"
173
+ }
174
+ flag "--env" help="Environment name to upload to" {
175
+ arg "<string>"
176
+ }
177
+ flag "--mode" help="Upload mode: preserve destination authentication identity (data-copy) or restore all database state (exact-restore)" default="data-copy" {
178
+ arg "<choice>" {
179
+ choices "data-copy" "exact-restore"
180
+ }
181
+ }
182
+ arg "[sqlite-file]" help="Local SQLite database file to upload" required=#false
183
+ }
184
+ cmd "shell" help="Open an interactive Turso shell for a hosted environment database" {
185
+ flag "--project" help="Project number (or internal ID) to open a database shell for" {
186
+ arg "<string>"
187
+ }
188
+ flag "--env" help="Environment name to open a database shell for" {
189
+ arg "<string>"
190
+ }
191
+ flag "--ttl" help="Database Shell session TTL; bare numbers are seconds, for example \"900\", \"15m\", or \"1h\"" {
192
+ arg "<string>"
193
+ }
194
+ }
195
+ }
196
+ cmd "custom-domain" help="Show custom-domain certificate status and required DNS records" {
197
+ flag "--project" help="Project number or internal ID" required=#true {
198
+ arg "<string>"
199
+ }
200
+ flag "--env" help="Environment name" required=#true {
201
+ arg "<string>"
202
+ }
203
+ }
204
+ cmd "migrate" help="Run system and org schema migrations (uses SQLITE_DATABASE_PATH or $org-path/db/pf.db)" {
205
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
206
+ arg "<string>"
207
+ }
208
+ arg "<org-path>" help="Path to the organisation directory"
209
+ }
210
+ cmd "migrate-custom" help="Run custom schema migrations for organisation (uses SQLITE_DATABASE_PATH or $org-path/db/pf.db)" {
211
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
212
+ arg "<string>"
213
+ }
214
+ arg "<org-path>" help="Path to the organisation directory"
215
+ }
216
+ cmd "get-frontend-jwt" help="Output the stored frontend JWT token (created during import)" {
217
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
218
+ arg "<string>"
219
+ }
220
+ arg "<org-path>" help="Path to the organisation directory (or PF_ORG)"
221
+ }
222
+ cmd "refresh-frontend-jwt" help="Regenerate the frontend JWT token with the current issuer URL and signing keys" {
223
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
224
+ arg "<string>"
225
+ }
226
+ flag "--issuer-url" help="Frontend JWT issuer URL (overrides OAUTH_ISSUER_URL)" {
227
+ arg "<string>"
228
+ }
229
+ arg "<org-path>" help="Path to the organisation directory (or PF_ORG)"
230
+ }
231
+ cmd "config" help="Manage SSM configuration parameters" {
232
+ cmd "list" help="List all config parameters for a project and stage" {
233
+ flag "--project" help="Project number (or internal ID)" required=#true {
234
+ arg "<string>"
235
+ }
236
+ flag "--stage" help="Stage name" required=#true {
237
+ arg "<string>"
238
+ }
239
+ }
240
+ cmd "get" help="Get a config parameter value" {
241
+ flag "--project" help="Project number (or internal ID)" required=#true {
242
+ arg "<string>"
243
+ }
244
+ flag "--stage" help="Stage name" required=#true {
245
+ arg "<string>"
246
+ }
247
+ arg "<key>" help="Configuration parameter name"
248
+ }
249
+ cmd "set" help="Set a config parameter value" {
250
+ flag "--project" help="Project number (or internal ID)" required=#true {
251
+ arg "<string>"
252
+ }
253
+ flag "--stage" help="Stage name" required=#true {
254
+ arg "<string>"
255
+ }
256
+ flag "--secret" help="Store as a secret (SecureString in SSM)" default="false"
257
+ arg "[assignment]…" help="One of KEY, KEY=VALUE, or KEY VALUE" required=#false var=#true
258
+ }
259
+ cmd "delete" help="Delete a config parameter" {
260
+ flag "--project" help="Project number (or internal ID)" required=#true {
261
+ arg "<string>"
262
+ }
263
+ flag "--stage" help="Stage name" required=#true {
264
+ arg "<string>"
265
+ }
266
+ arg "<key>" help="Configuration parameter name"
267
+ }
268
+ cmd "copy-new" help="Copy only missing config parameters from another stage" {
269
+ flag "--project" help="Project number (or internal ID)" required=#true {
270
+ arg "<string>"
271
+ }
272
+ flag "--stage" help="Stage name" required=#true {
273
+ arg "<string>"
274
+ }
275
+ flag "--from-stage" help="Source stage name" required=#true {
276
+ arg "<string>"
277
+ }
278
+ }
279
+ }
280
+ cmd "stage" help="Manage project stages" {
281
+ cmd "list" help="List stages in a project" {
282
+ flag "--project" help="Project number (or internal ID)" required=#true {
283
+ arg "<string>"
284
+ }
285
+ }
286
+ cmd "add" help="Add a stage to a project" {
287
+ flag "--project" help="Project number (or internal ID)" required=#true {
288
+ arg "<string>"
289
+ }
290
+ arg "<stage-name>" help="Stage name to create"
291
+ }
292
+ }
293
+ cmd "env" help="Manage project environments" {
294
+ cmd "list" help="List environments in a project" {
295
+ flag "--project" help="Project number (or internal ID)" required=#true {
296
+ arg "<string>"
297
+ }
298
+ flag "--stage" help="Stage name" {
299
+ arg "<string>"
300
+ }
301
+ }
302
+ cmd "add" help="Add an environment to a stage" {
303
+ flag "--project" help="Project number (or internal ID)" required=#true {
304
+ arg "<string>"
305
+ }
306
+ flag "--stage" help="Stage name" required=#true {
307
+ arg "<string>"
308
+ }
309
+ arg "<env-name>" help="Environment name to create"
310
+ }
311
+ }
312
+ cmd "auth" help="Authentication commands" {
313
+ cmd "login" help="Login via browser-based OAuth (uses BASE_URL env var, defaults to https://console.processfocus.com)" {
314
+ flag "--base-url" help="Console HTTP(S) origin (overrides BASE_URL)" {
315
+ arg "<string>"
316
+ }
317
+ }
318
+ }
319
+ cmd "skills" help="Agent-oriented runtime skill guidance" {
320
+ cmd "list" help="List agent skills served by this pfcli version"
321
+ cmd "get" help="Print an agent skill for this pfcli version" {
322
+ arg "<name>" help="Skill name to print"
323
+ }
324
+ }
325
+ cmd "grant" help="Grant operations" {
326
+ cmd "role" help="Grant a role to a provider user locally or in a remote customer environment" {
327
+ flag "--role" help="Role path to grant (e.g. /Administrator)" required=#true {
328
+ arg "<string>"
329
+ }
330
+ flag "--user" help="Email address of the provider user" required=#true {
331
+ arg "<string>"
332
+ }
333
+ flag "--project" help="Project number or internal ID (remote mode)" {
334
+ arg "<string>"
335
+ }
336
+ flag "--env" help="Environment name (remote mode)" {
337
+ arg "<string>"
338
+ }
339
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
340
+ arg "<string>"
341
+ }
342
+ arg "[org-path]" help="Path to the organisation directory (local mode only)" required=#false
343
+ }
344
+ }
345
+ cmd "invitation" help="Invitation operations" {
346
+ cmd "create" help="Create a pending Invitation directly in a local organisation database" {
347
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
348
+ arg "<string>"
349
+ }
350
+ flag "--email" help="Invitee email address" required=#true {
351
+ arg "<string>"
352
+ }
353
+ flag "--role" help="Exact role path; repeat for multiple roles" required=#true var=#true var_min=1 {
354
+ arg "<string>"
355
+ }
356
+ arg "[org-path]" help="Path to the organisation directory (local mode only)" required=#false
357
+ }
358
+ cmd "registration-link" help="Issue a Registration Link or, with --rotate, recover an existing account locally or remotely" {
359
+ flag "--project" help="Project number or internal ID (remote mode)" {
360
+ arg "<string>"
361
+ }
362
+ flag "--env" help="Environment name (remote mode)" {
363
+ arg "<string>"
364
+ }
365
+ flag "--email" help="Normalized Email of the Invitation or existing account" {
366
+ arg "<string>"
367
+ }
368
+ flag "--rotate" help="Replace an active or expired Registration Link, or issue an existing account's Passkey Recovery Link" default="false"
369
+ flag "--database-path" help="Database path (overrides SQLITE_DATABASE_PATH; not available with --project/--env)" {
370
+ arg "<string>"
371
+ }
372
+ flag "--frontend-url" help="Local link frontend HTTP(S) origin, including port (overrides frontend URL environment variables)" {
373
+ arg "<string>"
374
+ }
375
+ arg "[org-path]" help="Path to the organisation directory (local mode only)" required=#false
376
+ }
377
+ }
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{Effect as H}from"effect";import{spawnSync as q}from"child_process";import{cpSync as m,existsSync as S,mkdtempSync as U,rmSync as K,writeFileSync as V}from"fs";import{tmpdir as J}from"os";import*as e from"path";import{DEPLOY_ARTIFACT_FILENAME as A,DEPLOY_ARTIFACT_FORMAT as Y,DEPLOY_ARTIFACT_VERSION as B}from"@processfocus/runtime";import{Effect as i}from"effect";import{Data as t}from"effect";class O extends t.TaggedError("OrgLoadError"){}class T extends t.TaggedError("BuildError"){}class R extends t.TaggedError("GraphqlSchemaError"){}class L extends t.TaggedError("PolicyFileError"){}class D extends t.TaggedError("InitError"){}class k extends t.TaggedError("MigrationError"){constructor(r){super({...r,message:r.statement?`Migration failed: ${r.reason}. Statement: ${r.statement}`:`Migration failed: ${r.reason}`})}}class M extends t.TaggedError("AuthLoginError"){}class d extends t.TaggedError("CliError"){}class N extends t.TaggedError("CustomDomainError"){}import{readFileSync as F}from"fs";import{fileURLToPath as b}from"url";import{Schema as a}from"effect";var j=a.Struct({name:a.String,version:a.String,dependencies:a.Record({key:a.String,value:a.String})}),G=JSON.parse(F(b(new URL("../package.json",import.meta.url)),"utf8")),g=a.decodeUnknownSync(j)(G),l=(r)=>{let o=g.dependencies[r];if(o===void 0)throw Error(`Invalid @processfocus/cli package metadata: missing ${r}`);return o},{name:f,version:y}=g,tr=l("processfocus"),or={"@cedar-policy/cedar-wasm":l("@cedar-policy/cedar-wasm"),"@tursodatabase/database":l("@tursodatabase/database"),"@tursodatabase/serverless":l("@tursodatabase/serverless"),"@tursodatabase/sync":l("@tursodatabase/sync")};var h={name:f,version:y};var W=(r)=>{let o=e.relative(process.cwd(),e.resolve(r));return o&&!o.startsWith("..")?o:r},w=(r,o)=>i.scoped(i.gen(function*(){let p=e.resolve(process.cwd(),r),c=yield*i.acquireRelease(i.sync(()=>U(e.join(J(),"pfcli-deploy-stage-"))),(n)=>i.sync(()=>K(n,{recursive:!0,force:!0}))),z=e.join(c,"dist"),I=e.join(c,A),u=e.join(p,"drizzle.config.ts"),P=e.join(c,"drizzle.config.ts"),E=e.join(p,"drizzle"),_=e.join(c,"drizzle"),v=JSON.stringify({format:Y,version:B,orgPath:W(r),producer:h}),s=yield*i.try({try:()=>{m(e.join(p,"dist"),z,{recursive:!0});let n=["dist",A];if(S(u))m(u,P),n.push("drizzle.config.ts");if(S(E))m(E,_,{recursive:!0}),n.push("drizzle");return V(I,`${v}
4
- `),q("zip",["-r","-q",o,...n],{cwd:c,encoding:"utf8"})},catch:(n)=>new d({message:"Failed to execute zip command",cause:n})});if(s.error)return yield*new d({message:`Failed to create deployment zip: ${s.error.message}`,cause:s.error});if(s.status!==0)return yield*new d({message:s.stderr?.trim()||`zip command failed with exit code ${String(s.status)}`})}));var x=process.argv[2],C=process.argv[3];if(x===void 0||C===void 0)throw Error("Usage: prepare-deployment-artifact <organisation-path> <artifact-path>");await H.runPromise(w(x,C));
3
+ import{Effect as H}from"effect";import{spawnSync as q}from"child_process";import{cpSync as m,existsSync as S,mkdtempSync as U,rmSync as K,writeFileSync as V}from"fs";import{tmpdir as J}from"os";import*as e from"path";import{DEPLOY_ARTIFACT_FILENAME as A,DEPLOY_ARTIFACT_FORMAT as Y,DEPLOY_ARTIFACT_VERSION as B}from"@processfocus/runtime";import{Effect as c}from"effect";import{Data as t}from"effect";class v extends t.TaggedError("OrgLoadError"){}class T extends t.TaggedError("BuildError"){}class R extends t.TaggedError("GraphqlSchemaError"){}class L extends t.TaggedError("PolicyFileError"){}class D extends t.TaggedError("InitError"){}class k extends t.TaggedError("MigrationError"){constructor(r){super({...r,message:r.statement?`Migration failed: ${r.reason}. Statement: ${r.statement}`:`Migration failed: ${r.reason}`})}}class M extends t.TaggedError("AuthLoginError"){}class p extends t.TaggedError("CliError"){}class N extends t.TaggedError("CustomDomainError"){}import{readFileSync as F}from"fs";import{fileURLToPath as b}from"url";import{Schema as s}from"effect";var j=s.Struct({name:s.String,version:s.String,dependencies:s.Record(s.String,s.String)}),G=JSON.parse(F(b(new URL("../package.json",import.meta.url)),"utf8")),l=s.decodeUnknownSync(j)(G),i=(r)=>{let o=l.dependencies[r];if(o===void 0)throw Error(`Invalid @processfocus/cli package metadata: missing ${r}`);return o},{name:f,version:y}=l,tr=i("processfocus"),or={"@processfocus/runtime":i("@processfocus/runtime"),"@cedar-policy/cedar-wasm":i("@cedar-policy/cedar-wasm"),"@tursodatabase/database":i("@tursodatabase/database"),"@tursodatabase/serverless":i("@tursodatabase/serverless"),"@tursodatabase/sync":i("@tursodatabase/sync")};var h={name:f,version:y};var W=(r)=>{let o=e.relative(process.cwd(),e.resolve(r));return o&&!o.startsWith("..")?o:r},w=(r,o)=>c.scoped(c.gen(function*(){let g=e.resolve(process.cwd(),r),d=yield*c.acquireRelease(c.sync(()=>U(e.join(J(),"pfcli-deploy-stage-"))),(n)=>c.sync(()=>K(n,{recursive:!0,force:!0}))),z=e.join(d,"dist"),I=e.join(d,A),u=e.join(g,"drizzle.config.ts"),P=e.join(d,"drizzle.config.ts"),E=e.join(g,"drizzle"),_=e.join(d,"drizzle"),O=JSON.stringify({format:Y,version:B,orgPath:W(r),producer:h}),a=yield*c.try({try:()=>{m(e.join(g,"dist"),z,{recursive:!0});let n=["dist",A];if(S(u))m(u,P),n.push("drizzle.config.ts");if(S(E))m(E,_,{recursive:!0}),n.push("drizzle");return V(I,`${O}
4
+ `),q("zip",["-r","-q",o,...n],{cwd:d,encoding:"utf8"})},catch:(n)=>new p({message:"Failed to execute zip command",cause:n})});if(a.error)return yield*new p({message:`Failed to create deployment zip: ${a.error.message}`,cause:a.error});if(a.status!==0)return yield*new p({message:a.stderr?.trim()||`zip command failed with exit code ${String(a.status)}`})}));var x=process.argv[2],C=process.argv[3];if(x===void 0||C===void 0)throw Error("Usage: prepare-deployment-artifact <organisation-path> <artifact-path>");await H.runPromise(w(x,C));
@@ -5,6 +5,7 @@
5
5
  // Ordinary work includes humans and their distinct Delegations.
6
6
  // Roles are explicit trusted facts, not inherited attributes.
7
7
  // Provider users can complete a step if they have the step's role.
8
+ // Direct assignment narrows this default grant to the assignee.
8
9
  permit (
9
10
  principal,
10
11
  action == PF::Action::"complete",
@@ -13,42 +14,29 @@ permit (
13
14
  when {
14
15
  (principal is PF::ProviderUser || principal is PF::Delegation) &&
15
16
  resource has role &&
17
+ principal has roles &&
16
18
  principal.roles.contains(resource.role)
17
- };
18
-
19
- // Provider users can complete active todos for role-authorized work.
20
- // Directly assigned todos are narrowed to the assigned provider user by default.
21
- permit (
22
- principal,
23
- action == PF::Action::"complete",
24
- resource is PF::Todo
25
- )
26
- when {
27
- (principal is PF::ProviderUser || principal is PF::Delegation) &&
28
- resource has role &&
29
- principal.roles.contains(resource.role) &&
30
- (
31
- !(resource has assignedTo) ||
32
- principal in resource.assignedTo
33
- )
19
+ }
20
+ unless {
21
+ context has assignedTo && !(principal in context.assignedTo)
34
22
  };
35
23
 
36
24
  // Provider users can correct Public Completion delivery failures through a
37
25
  // distinct action. Callers choose the responsible or execution-failure role
38
- // candidate when constructing the Todo resource.
26
+ // candidate when constructing the Step resource.
39
27
  permit (
40
28
  principal,
41
29
  action == PF::Action::"publicCompletionCorrection",
42
- resource is PF::Todo
30
+ resource is PF::Step
43
31
  )
44
32
  when {
45
33
  (principal is PF::ProviderUser || principal is PF::Delegation) &&
46
34
  resource has role &&
47
- principal.roles.contains(resource.role) &&
48
- (
49
- !(resource has assignedTo) ||
50
- principal in resource.assignedTo
51
- )
35
+ principal has roles &&
36
+ principal.roles.contains(resource.role)
37
+ }
38
+ unless {
39
+ context has assignedTo && !(principal in context.assignedTo)
52
40
  };
53
41
 
54
42
  // Service accounts with a requested role can complete unassigned role todos.
@@ -56,12 +44,13 @@ when {
56
44
  permit (
57
45
  principal is PF::ServiceAccount,
58
46
  action == PF::Action::"complete",
59
- resource is PF::Todo
47
+ resource is PF::Step
60
48
  )
61
49
  when {
50
+ context has todoId &&
62
51
  resource has role &&
63
52
  principal.roles.contains(resource.role) &&
64
- !(resource has assignedTo)
53
+ !(context has assignedTo)
65
54
  };
66
55
 
67
56
  // Provider users can modify submitted form fields if they have the field's role.
@@ -77,15 +66,15 @@ when {
77
66
  };
78
67
 
79
68
  // Public todo links can complete only the todo embedded in the encrypted token.
80
- // This is self-authorizing today, and intentionally keeps public-link scoping
81
- // in Cedar so future revocation/scoping rules can be policy-owned.
69
+ // The principal comes from the verified token; context identifies the actual work.
82
70
  permit (
83
71
  principal is PF::PublicLink,
84
72
  action == PF::Action::"complete",
85
- resource is PF::Todo
73
+ resource is PF::Step
86
74
  )
87
75
  when {
88
- principal.todo == resource
76
+ context has todoId &&
77
+ principal.todoId == context.todoId
89
78
  };
90
79
 
91
80
  // Provider users can login if they have at least one role.
@@ -145,9 +134,7 @@ when {
145
134
  principal.roles.contains(resource.role)
146
135
  };
147
136
 
148
- // Provider users with roles can access untagged GraphQL fields or fields tagged
149
- // for provider-user or embedded-form use. The embed tag is also used on shared
150
- // lookup fields that authenticated forms still call directly.
137
+ // Provider users with roles can access untagged or provider-user GraphQL fields.
151
138
  permit (
152
139
  principal,
153
140
  action in [PF::Action::"query", PF::Action::"mutation", PF::Action::"subscription"],
@@ -158,11 +145,23 @@ when {
158
145
  principal.roles.isEmpty() == false &&
159
146
  (
160
147
  !(resource has tag) ||
161
- resource.tag == "providerUser" ||
162
- resource.tag == "embed"
148
+ resource.tag == "providerUser"
163
149
  )
164
150
  };
165
151
 
152
+ // Frontend service account can invoke and read inert deployment probes.
153
+ permit (
154
+ principal == PF::ServiceAccount::"frontend",
155
+ action == PF::Action::"query",
156
+ resource == PF::GraphQLField::"Query.deploymentProbe"
157
+ );
158
+
159
+ permit (
160
+ principal == PF::ServiceAccount::"frontend",
161
+ action == PF::Action::"mutation",
162
+ resource == PF::GraphQLField::"Mutation.startDeploymentProbe"
163
+ );
164
+
166
165
  // Frontend service account can read bootstrap organization and Cedar policy data.
167
166
  permit (
168
167
  principal == PF::ServiceAccount::"frontend",
@@ -182,7 +181,48 @@ permit (
182
181
  resource is PF::GraphQLField
183
182
  )
184
183
  when {
185
- resource has tag && resource.tag == "embed"
184
+ resource has step && resource.step.embedded && resource.step.startsProcess
185
+ };
186
+
187
+ // Fixed public entrypoints still authorize the step, address or token in their resolver.
188
+ permit (
189
+ principal == PF::ServiceAccount::"frontend",
190
+ action == PF::Action::"query",
191
+ resource is PF::GraphQLField
192
+ )
193
+ when {
194
+ [
195
+ PF::GraphQLField::"Query.embeddedFormMetadata",
196
+ PF::GraphQLField::"Query.lookupSuggestions",
197
+ PF::GraphQLField::"Query.calendarSlots",
198
+ PF::GraphQLField::"Query.publicTodo",
199
+ PF::GraphQLField::"Query.publicTodoLookupSuggestions",
200
+ PF::GraphQLField::"Query.publicTodoCalendarSlots",
201
+ PF::GraphQLField::"Query.anonymousPage",
202
+ PF::GraphQLField::"Query.anonymousPageLookup"
203
+ ].contains(resource)
204
+ };
205
+
206
+ permit (
207
+ principal == PF::ServiceAccount::"frontend",
208
+ action == PF::Action::"mutation",
209
+ resource is PF::GraphQLField
210
+ )
211
+ when {
212
+ [
213
+ PF::GraphQLField::"Mutation.submitAnonymousPage",
214
+ PF::GraphQLField::"Mutation.completePublicTodo",
215
+ PF::GraphQLField::"Mutation.requestFreshPublicTodoLink"
216
+ ].contains(resource)
217
+ };
218
+
219
+ permit (
220
+ principal == PF::ServiceAccount::"frontend",
221
+ action == PF::Action::"viewEmbeddedForm",
222
+ resource is PF::Step
223
+ )
224
+ when {
225
+ resource.embedded && resource.startsProcess
186
226
  };
187
227
 
188
228
  permit (
@@ -205,7 +245,8 @@ when {
205
245
  };
206
246
 
207
247
  // Scheduler starts system-owned cron processes through the normal start-step
208
- // authorization path, so only role-less start steps are allowed by default.
248
+ // authorization path. Only role-less system starts with a cron schedule are
249
+ // allowed by default, even when a different start has no GraphQL field check.
209
250
  permit (
210
251
  principal == PF::ServiceAccount::"scheduler",
211
252
  action == PF::Action::"complete",
@@ -213,7 +254,8 @@ permit (
213
254
  )
214
255
  when {
215
256
  resource.startsProcess &&
216
- !(resource has role)
257
+ !(resource has role) &&
258
+ context has cronStart && context.cronStart
217
259
  };
218
260
 
219
261
  // Provider users can access a List if they have one of the list's allowed roles.