@sequenceholdings/studio-cli 0.2.2 → 0.3.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/README.md +150 -49
- package/dist/access/commands.d.ts +3 -0
- package/dist/access/commands.js +91 -0
- package/dist/app/application-registration.d.ts +5 -1
- package/dist/app/application-registration.js +2 -1
- package/dist/app/deploy.js +4 -2
- package/dist/app/manifest.d.ts +19 -5
- package/dist/app/manifest.js +15 -5
- package/dist/auth-cmds/commands.d.ts +1 -1
- package/dist/auth-cmds/commands.js +16 -0
- package/dist/command-input.d.ts +15 -0
- package/dist/command-input.js +33 -0
- package/dist/functions/commands.d.ts +2 -1
- package/dist/functions/commands.js +59 -30
- package/dist/functions/manifest.d.ts +7 -1
- package/dist/functions/manifest.js +40 -12
- package/dist/functions/secret-reconcile.d.ts +3 -3
- package/dist/functions/secret-reconcile.js +5 -7
- package/dist/main.d.ts +2 -0
- package/dist/main.js +17 -5
- package/dist/manifest-roles-notice.d.ts +33 -0
- package/dist/manifest-roles-notice.js +75 -0
- package/dist/orm/delegate.js +2 -0
- package/dist/pipeline/stage-secrets.d.ts +4 -1
- package/dist/pipeline/stage-secrets.js +6 -2
- package/dist/process/commands.js +4 -0
- package/dist/repos/commands.d.ts +10 -1
- package/dist/repos/commands.js +6 -1
- package/dist/repos/pulls.d.ts +3 -0
- package/dist/repos/pulls.js +131 -0
- package/dist/secrets/commands.d.ts +1 -1
- package/dist/secrets/commands.js +97 -16
- package/dist/service-accounts/commands.d.ts +3 -0
- package/dist/service-accounts/commands.js +50 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ locations, dependencies, and deployment selection.
|
|
|
146
146
|
|
|
147
147
|
> **Availability:** App orchestration remains an internal workflow. Standalone
|
|
148
148
|
> primitives retain their documented public/Preview availability. This change
|
|
149
|
-
> does not
|
|
149
|
+
> does not publish app orchestration. Standalone caller-mode Function-to-ORM execution is supported by the SDK helper described below; service-identity execution remains outside that helper.
|
|
150
150
|
|
|
151
151
|
| Command | What it does |
|
|
152
152
|
|---------|--------------|
|
|
@@ -332,34 +332,20 @@ root pnpm workspace if you want shared builds. Adding an agent, process, or pipe
|
|
|
332
332
|
|
|
333
333
|
### Application roles (schema version 3)
|
|
334
334
|
|
|
335
|
-
Version 3 is version 2 plus
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
- { primitive: score-fn, role: invoker } # end_user also works
|
|
350
|
-
- { primitive: loans-orm, role: end_user }
|
|
351
|
-
reviewer:
|
|
352
|
-
inherits: [member]
|
|
353
|
-
includes:
|
|
354
|
-
- { primitive: admin-ui, role: approver }
|
|
355
|
-
- { primitive: loans-orm, capability: loan-read }
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
- Includes can reach `artifact`, `function`, `orm`, and `process` primitives.
|
|
359
|
-
`role: end_user` is a member's end-user access; `invoker` is accepted on
|
|
360
|
-
functions and processes. Any other `role` is one of the member's registered
|
|
361
|
-
roles, and `capability` one of its capabilities. Including a member role or
|
|
362
|
-
capability also grants that member's end-user access.
|
|
335
|
+
Version 3 is version 2 plus Application registration: after its primitives
|
|
336
|
+
deploy, the app is registered with Atlas as an **Application**. Create its
|
|
337
|
+
roles in Atlas — Permissions → Applications → the app → **Edit roles**, or
|
|
338
|
+
`POST /api/custom-roles/applications/<id>/roles` — so granting someone one
|
|
339
|
+
Application role gives them everything the app needs: each member's end-user
|
|
340
|
+
access plus the member roles and capabilities the role bundles. Grants are made
|
|
341
|
+
in Atlas too, never in the manifest.
|
|
342
|
+
|
|
343
|
+
- A role's includes can reach `artifact`, `function`, `orm`, and `process`
|
|
344
|
+
primitives: a member's end-user access (`invoker` on functions and
|
|
345
|
+
processes), one of its registered roles, or one of its capabilities.
|
|
346
|
+
A member role or capability doesn't grant end-user access by itself — as on
|
|
347
|
+
the primitive, a role needs an explicit end-user include on each member its
|
|
348
|
+
holders should be able to open.
|
|
363
349
|
- A `process` primitive offers only end-user access (starting runs), and a role
|
|
364
350
|
can include it only when it deploys exactly one process, `only: [<process-id>]`:
|
|
365
351
|
|
|
@@ -369,9 +355,6 @@ roles:
|
|
|
369
355
|
- The Application registers after every primitive deploys; if one fails, it
|
|
370
356
|
is skipped. Registering requires capability admin on every member (owner,
|
|
371
357
|
for a process), checked on every deploy.
|
|
372
|
-
- Each role is created the first time a deploy sees it. After that Atlas owns
|
|
373
|
-
it: edit it in Atlas, and the deploy reports a changed definition here as
|
|
374
|
-
drift instead of applying it.
|
|
375
358
|
- Members are synced every deploy. Removing one removes every role's access
|
|
376
359
|
into it.
|
|
377
360
|
- A Next.js artifact is an ordinary `artifact` member. Its server calls ORM and
|
|
@@ -381,31 +364,46 @@ roles:
|
|
|
381
364
|
for any artifact's browser `capabilities`). The deploy prints an
|
|
382
365
|
`access_gap` warning for each one a role misses; it never adds them for you.
|
|
383
366
|
|
|
384
|
-
|
|
367
|
+
#### Deprecated: role definitions in YAML
|
|
385
368
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
369
|
+
**Capabilities are code, roles are data.** Capabilities live in YAML because your code checks them; roles
|
|
370
|
+
are bundles of capabilities that admins create and change in Atlas.
|
|
371
|
+
|
|
372
|
+
`roles:` and `collaborators:` blocks in `sequence.app.yml` — like
|
|
373
|
+
`capabilities.roles.definitions` in `artifact.bundle.yml`,
|
|
374
|
+
`managed-function.yml`, and `namespace.yaml` — are **deprecated**. They are
|
|
375
|
+
still accepted as a one-time seed: a deploy creates any role Atlas doesn't have
|
|
376
|
+
yet and **never updates it after**; a changed definition is reported as drift,
|
|
377
|
+
not applied. `seq-studio` prints a notice when a manifest it deploys defines
|
|
378
|
+
roles. Don't add new ones — create roles in Atlas. Capabilities stay in YAML:
|
|
379
|
+
they're the contract your code checks.
|
|
380
|
+
|
|
381
|
+
The legacy seed format, for reading existing manifests:
|
|
390
382
|
|
|
391
383
|
```yaml
|
|
392
|
-
|
|
384
|
+
roles:
|
|
393
385
|
definitions:
|
|
394
|
-
|
|
395
|
-
description: Reads the code and data model
|
|
386
|
+
member:
|
|
396
387
|
includes:
|
|
397
|
-
- { primitive: admin-ui,
|
|
398
|
-
- { primitive: loans-orm,
|
|
388
|
+
- { primitive: admin-ui, role: end_user }
|
|
389
|
+
- { primitive: loans-orm, capability: loan-read }
|
|
390
|
+
collaborators:
|
|
391
|
+
definitions:
|
|
399
392
|
maintainer:
|
|
400
|
-
description: Ships changes to the desk, its API and its data model
|
|
401
|
-
inherits: [reviewer]
|
|
402
393
|
includes:
|
|
403
394
|
- { primitive: admin-ui, tier: writer }
|
|
404
|
-
- { primitive: score-fn, tier: editor }
|
|
405
|
-
- { primitive: loans-orm, tier: writer }
|
|
406
|
-
- { primitive: approval-flow, tier: editor }
|
|
407
395
|
```
|
|
408
396
|
|
|
397
|
+
### Collaborator roles (schema version 3)
|
|
398
|
+
|
|
399
|
+
Runtime roles bundle use. **Collaborator roles** bundle the tiers that let
|
|
400
|
+
people change the members: one grant can make someone a writer on the UI, an
|
|
401
|
+
editor on its function, and a writer on its namespace. Create them in Atlas
|
|
402
|
+
(the Application's **Collaborator access** tab, or `?kind=collaborator` on the
|
|
403
|
+
roles API) — a `collaborators:` block here is the deprecated seed described
|
|
404
|
+
above. The two kinds never mix: a collaborator role includes only member tiers
|
|
405
|
+
and inherits only other collaborator roles.
|
|
406
|
+
|
|
409
407
|
| Kind | Tiers a collaborator role can bundle |
|
|
410
408
|
|---|---|
|
|
411
409
|
| `artifact` | `reader`, `writer` |
|
|
@@ -896,10 +894,42 @@ the deployed `tables` declaration before requesting broader user grants.
|
|
|
896
894
|
|
|
897
895
|
| Command | What it does |
|
|
898
896
|
|---------|--------------|
|
|
899
|
-
| `seq-studio secrets create <NAME> -e <env> [--org <slug>]` | Register an org-owned secret (
|
|
900
|
-
| `seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>]` | Set
|
|
897
|
+
| `seq-studio secrets create <NAME> -e <env> [--type key-value\|single] [--org <slug>]` | Register an org-owned secret with an immutable type (CLI defaults to `single` for existing scripts) |
|
|
898
|
+
| `seq-studio secrets set <NAME> -e <env> [--org <slug>] [--from-file <path>\|--from-json <path>]` | Set one value or a complete key/value set (write-only; file is not echoed) |
|
|
901
899
|
| `seq-studio secrets list -e <env>` | Secrets you can see (never values) |
|
|
902
900
|
|
|
901
|
+
For a grouped credential, create a key/value set and write its complete value from a JSON file:
|
|
902
|
+
|
|
903
|
+
```bash
|
|
904
|
+
seq-studio secrets create CANDESCENT -e staging --type key-value
|
|
905
|
+
seq-studio secrets set CANDESCENT -e staging --from-json ../private/candescent-secrets.json
|
|
906
|
+
seq-studio functions deploy -e staging
|
|
907
|
+
```
|
|
908
|
+
|
|
909
|
+
The function's `managed-function.yml` names the set and maps its entries into the environment variables the code reads:
|
|
910
|
+
|
|
911
|
+
```yaml
|
|
912
|
+
secrets:
|
|
913
|
+
- secret: CANDESCENT
|
|
914
|
+
entries:
|
|
915
|
+
BASE_URL: CANDESCENT_BASE_URL
|
|
916
|
+
INSTITUTION_ID: CANDESCENT_INSTITUTION_ID
|
|
917
|
+
PRIVATE_KEY: CANDESCENT_PRIVATE_KEY
|
|
918
|
+
PUBLIC_KEY: CANDESCENT_PUBLIC_KEY
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
For a single-value secret, `secrets: [API_KEY]` still supplies the secret named `API_KEY` as `process.env.API_KEY`. Deployment resolves manifest bindings automatically; no separate function attachment command is required.
|
|
922
|
+
|
|
923
|
+
If using `seq-studio secrets attach <NAME> --fn <slug>`, the function's active manifest must already declare that same secret source and exact environment variable mapping. An attachment cannot override a different manifest secret; update `managed-function.yml` and redeploy to change the source or mapping.
|
|
924
|
+
|
|
925
|
+
The JSON file contains an object of uppercase entry names and string values. Keep it outside git **and outside the function directory**, since function files are uploaded during deployment. A set is one version and one permission grant; changing any entry writes a new complete version. Redeploy functions tracking the default to apply it. Function code reads the mapped `process.env` names as before. Missing entries and undeclared environment variables fail deployment.
|
|
926
|
+
|
|
927
|
+
To change only selected entries without reading or re-entering the others, put the changes in a JSON file and run `seq-studio secrets set CANDESCENT -e staging --from-json ./changes.json --merge`. Use `null` for an entry to remove it. The CLI checks the active version before writing and asks you to retry if another edit won the race.
|
|
928
|
+
|
|
929
|
+
Pipeline stages can select one entry from a set for each symbolic credential: `seq-studio secrets attach CANDESCENT --stage my-stage -e staging --credential api_key --entry PRIVATE_KEY`. The selected entry is copied at plan/deploy into that stage's credential scope. Artifact Studio applications currently require a single-value secret.
|
|
930
|
+
|
|
931
|
+
Existing single-value secrets keep their type. To consolidate them, create a new set, provide or rotate the entry values, update each consumer's manifest mapping, redeploy, verify the consumer, then retire the old secrets. The CLI and UI cannot read back existing secret values, so an agent needs the values from an authorized source or must rotate them during consolidation.
|
|
932
|
+
|
|
903
933
|
`--org` targets a managed-scope org other than the login tenant and selects
|
|
904
934
|
the intended same-named secret for `set`, `attach`, `detach`, `versions`,
|
|
905
935
|
`set-default`, and `pin`; it is required when the name exists in multiple
|
|
@@ -1517,3 +1547,74 @@ For local full-stack integration, use `artifact dev`, `functions deploy`, `orm a
|
|
|
1517
1547
|
and `storage apply` against the same `-e local` (or `local:<worktree>`). Storage uses
|
|
1518
1548
|
the normal local Atlas authorization and lifecycle, with a dedicated development
|
|
1519
1549
|
GCS bucket. The standalone `functions dev` harness does not mint storage delegation.
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
## Composed applications (0.3.0)
|
|
1553
|
+
|
|
1554
|
+
The public builder path combines standalone Artifacts, ORM namespaces, and Managed
|
|
1555
|
+
Functions in a platform repository. Use the environment's `/docs/getting-started/builder-handoff`
|
|
1556
|
+
and `/docs/examples/persisted-application` for the full source example and grant order.
|
|
1557
|
+
The matching package set is Artifact Studio 0.4.0, ORM 2.1.1, and Managed Functions
|
|
1558
|
+
0.2.0. Confirm registry publication before a clean installation; local builds of
|
|
1559
|
+
unreleased packages do not prove a public-registry workflow.
|
|
1560
|
+
|
|
1561
|
+
- `createArtifactOrmExecutor({namespace, manifest})` from the Artifact SDK root
|
|
1562
|
+
uses the host-authenticated bridge. Declare only the exact namespace API write
|
|
1563
|
+
scope, even for persisted queries. No browser token extraction is required.
|
|
1564
|
+
- `createFunctionOrmExecutor({request, baseUrl, namespace, manifest})` from
|
|
1565
|
+
`@sequenceholdings/managed-functions/orm` uses invocation-scoped human caller
|
|
1566
|
+
authority. Construct it inside the handler, supply the trusted configured
|
|
1567
|
+
environment origin, and declare a service-account binding and data scopes.
|
|
1568
|
+
It does not choose service mode or authenticate arbitrary public HTTP ingress.
|
|
1569
|
+
- The shared execution dependency contains no ORM authoring/compiler dependencies.
|
|
1570
|
+
Keep namespace generation in the development package, outside the Function runtime.
|
|
1571
|
+
|
|
1572
|
+
### Verify identity and provision bindings
|
|
1573
|
+
|
|
1574
|
+
```bash
|
|
1575
|
+
seq-studio auth whoami -e <env> --json
|
|
1576
|
+
seq-studio service-accounts list -e <env>
|
|
1577
|
+
seq-studio service-accounts create task-runtime --display-name "Task runtime" -e <env>
|
|
1578
|
+
seq-studio service-accounts show <account-id> -e <env>
|
|
1579
|
+
```
|
|
1580
|
+
|
|
1581
|
+
`whoami` reports the server-verified subject/email and environment, never credentials.
|
|
1582
|
+
Account creation requires existing administrator authority and issues no credentials.
|
|
1583
|
+
Provide the account ID/slug and act-as permission to the deployer. All new commands
|
|
1584
|
+
require an explicit environment; help is offline, including `doctor --help`.
|
|
1585
|
+
|
|
1586
|
+
### Runtime access
|
|
1587
|
+
|
|
1588
|
+
```bash
|
|
1589
|
+
seq-studio access definitions orm <namespace> -e <env>
|
|
1590
|
+
seq-studio access resolve orm <namespace> -e <env>
|
|
1591
|
+
seq-studio access list orm <namespace> --floor -e <env>
|
|
1592
|
+
seq-studio access grant orm <namespace> --floor --principal-type user --principal-id <subject> -e <env>
|
|
1593
|
+
seq-studio access grant orm <namespace> --key <role> --principal-type user --principal-id <subject> -e <env>
|
|
1594
|
+
seq-studio access revoke orm <namespace> --key <role> --principal-type user --principal-id <subject> -e <env>
|
|
1595
|
+
```
|
|
1596
|
+
|
|
1597
|
+
Resource types are `artifact`, `function`, and `orm`; their IDs are project UUID,
|
|
1598
|
+
Function UUID, and namespace name respectively. The runtime floor means `end_user`
|
|
1599
|
+
for Artifact/ORM and `invoker` for Function. `list` defaults to direct role/capability
|
|
1600
|
+
grants; `resolve` evaluates only the signed-in caller. Grant/revoke require existing
|
|
1601
|
+
grant-management authority. Roles and pins do not assign users; `capabilities.uses`
|
|
1602
|
+
must declare every capability consumed. Fresh previews do not register new role keys;
|
|
1603
|
+
activate a release before granting them. Authoring/collaborator permissions remain separate.
|
|
1604
|
+
|
|
1605
|
+
### Repository Pulls
|
|
1606
|
+
|
|
1607
|
+
```bash
|
|
1608
|
+
seq-studio repos pulls create <namespace/name> --head <branch> --base main --title "Build task app" --body-file review.md -e <env>
|
|
1609
|
+
seq-studio repos pulls list <namespace/name> --state open -e <env>
|
|
1610
|
+
seq-studio repos pulls show <namespace/name> <number> -e <env>
|
|
1611
|
+
seq-studio repos pulls diff <namespace/name> <number> -e <env>
|
|
1612
|
+
seq-studio repos pulls merge <namespace/name> <number> --method squash -e <env>
|
|
1613
|
+
```
|
|
1614
|
+
|
|
1615
|
+
All results are JSON (`--json` is accepted). Listing returns one page and `nextCursor`;
|
|
1616
|
+
use `--cursor` to continue. Diff accepts `--max-files` (maximum 500) and reports truncation.
|
|
1617
|
+
Merge requires merge/admin authority, confirmation (or approved automation's `--yes`),
|
|
1618
|
+
and the existing server review/check policy. It merges the current branch head; a
|
|
1619
|
+
displayed SHA is not a head-lock or policy bypass. Complete reviews before merging.
|
|
1620
|
+
`repos pull` remains the singular source-snapshot command.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../process/commands.js';
|
|
2
|
+
export declare const ACCESS_USAGE = "usage:\n seq-studio access definitions <artifact|function|orm> <resource-id> -e <env>\n seq-studio access resolve <artifact|function|orm> <resource-id> -e <env>\n seq-studio access list <artifact|function|orm> <resource-id> -e <env> [--floor | --key <key>]\n seq-studio access grant <artifact|function|orm> <resource-id> -e <env>\n (--floor | --key <key>) --principal-type <user|group|organization> --principal-id <id>\n seq-studio access revoke <artifact|function|orm> <resource-id> -e <env>\n (--floor | --key <key>) --principal-type <user|group|organization> --principal-id <id>\n\n All results are JSON (--json is also accepted). Authenticate: seq-studio login --env <env>.\n Resource IDs are artifact project IDs, function IDs, or ORM namespace names.\n definitions lists declared roles/capabilities; resolve shows the CALLER's effective claims.\n list defaults to direct role/capability grants; --floor lists runtime entry access.\n --floor is end_user for artifacts/ORM and invoker for functions. A custom key can\n be granted with --key; it must be declared and grantable on that resource.\n User IDs are authenticated subjects (auth whoami); groups use directory IDs;\n organizations use tenant slugs. Service accounts use --principal-type user\n --principal-id 'service-account|<account-id>'. Never pass an email in place of an ID.\n Grant/list/revoke require existing grant-manager authority on the resource.\n Service-account grants also require authority to act as that account.\n These commands manage runtime access; deployment/collaborator permissions remain separate.\n";
|
|
3
|
+
export declare function runAccessCommand(sub: string | undefined, args: ParsedArgs): Promise<number>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { deleteJson, getJson, postJson } from '../atlas-client.js';
|
|
2
|
+
import { printCliError } from '../cli-errors.js';
|
|
3
|
+
import { requiredStringFlag, validateCommandInput, wantsHelp } from '../command-input.js';
|
|
4
|
+
import { buildContext, clientOptions } from '../functions/commands.js';
|
|
5
|
+
export const ACCESS_USAGE = `usage:
|
|
6
|
+
seq-studio access definitions <artifact|function|orm> <resource-id> -e <env>
|
|
7
|
+
seq-studio access resolve <artifact|function|orm> <resource-id> -e <env>
|
|
8
|
+
seq-studio access list <artifact|function|orm> <resource-id> -e <env> [--floor | --key <key>]
|
|
9
|
+
seq-studio access grant <artifact|function|orm> <resource-id> -e <env>
|
|
10
|
+
(--floor | --key <key>) --principal-type <user|group|organization> --principal-id <id>
|
|
11
|
+
seq-studio access revoke <artifact|function|orm> <resource-id> -e <env>
|
|
12
|
+
(--floor | --key <key>) --principal-type <user|group|organization> --principal-id <id>
|
|
13
|
+
|
|
14
|
+
All results are JSON (--json is also accepted). Authenticate: seq-studio login --env <env>.
|
|
15
|
+
Resource IDs are artifact project IDs, function IDs, or ORM namespace names.
|
|
16
|
+
definitions lists declared roles/capabilities; resolve shows the CALLER's effective claims.
|
|
17
|
+
list defaults to direct role/capability grants; --floor lists runtime entry access.
|
|
18
|
+
--floor is end_user for artifacts/ORM and invoker for functions. A custom key can
|
|
19
|
+
be granted with --key; it must be declared and grantable on that resource.
|
|
20
|
+
User IDs are authenticated subjects (auth whoami); groups use directory IDs;
|
|
21
|
+
organizations use tenant slugs. Service accounts use --principal-type user
|
|
22
|
+
--principal-id 'service-account|<account-id>'. Never pass an email in place of an ID.
|
|
23
|
+
Grant/list/revoke require existing grant-manager authority on the resource.
|
|
24
|
+
Service-account grants also require authority to act as that account.
|
|
25
|
+
These commands manage runtime access; deployment/collaborator permissions remain separate.
|
|
26
|
+
`;
|
|
27
|
+
function parsePrincipal(args) {
|
|
28
|
+
const type = requiredStringFlag({ args, key: 'principal-type' });
|
|
29
|
+
const id = requiredStringFlag({ args, key: 'principal-id' });
|
|
30
|
+
if (!['user', 'group', 'organization'].includes(type)) {
|
|
31
|
+
throw new Error('--principal-type must be user, group, or organization.');
|
|
32
|
+
}
|
|
33
|
+
if (type === 'user' && (/[#*\s]/.test(id) || (!id.includes('|') && !id.endsWith('@clients')))) {
|
|
34
|
+
throw new Error('User principal IDs must be authenticated subjects, not emails or display names. Use auth whoami; service accounts use service-account|<id>.');
|
|
35
|
+
}
|
|
36
|
+
return { type, id };
|
|
37
|
+
}
|
|
38
|
+
function parseGrantSelection({ args, mutation }) {
|
|
39
|
+
const floor = args.flags.floor === true;
|
|
40
|
+
const key = args.flags.key;
|
|
41
|
+
if ((floor && key !== undefined) || (mutation && !floor && key === undefined)) {
|
|
42
|
+
throw new Error('Choose exactly one of --floor or --key <key>.');
|
|
43
|
+
}
|
|
44
|
+
return { floor, key };
|
|
45
|
+
}
|
|
46
|
+
function parseAccessTarget({ sub, args }) {
|
|
47
|
+
if (!['definitions', 'resolve', 'list', 'grant', 'revoke'].includes(sub)) {
|
|
48
|
+
throw new Error(`Unknown access command: ${sub}. See: seq-studio access --help`);
|
|
49
|
+
}
|
|
50
|
+
const mutation = sub === 'grant' || sub === 'revoke';
|
|
51
|
+
const flags = {};
|
|
52
|
+
if (sub === 'list' || mutation)
|
|
53
|
+
Object.assign(flags, { floor: 'boolean', key: 'string' });
|
|
54
|
+
if (mutation)
|
|
55
|
+
Object.assign(flags, { 'principal-type': 'string', 'principal-id': 'string' });
|
|
56
|
+
validateCommandInput({ args, flags, positional: 2 });
|
|
57
|
+
const [hostType, hostId] = args.positional;
|
|
58
|
+
if (!hostType || !['artifact', 'function', 'orm'].includes(hostType)) {
|
|
59
|
+
throw new Error('Resource type must be artifact, function, or orm.');
|
|
60
|
+
}
|
|
61
|
+
if (!hostId?.trim())
|
|
62
|
+
throw new Error('A resource ID is required.');
|
|
63
|
+
const { floor, key } = parseGrantSelection({ args, mutation });
|
|
64
|
+
const principal = mutation ? parsePrincipal(args) : undefined;
|
|
65
|
+
const suffix = sub === 'definitions' || sub === 'resolve' ? sub : floor ? 'end-users' : 'grants';
|
|
66
|
+
const query = sub === 'list' && typeof key === 'string' ? `?key=${encodeURIComponent(key)}` : '';
|
|
67
|
+
return {
|
|
68
|
+
path: `/api/custom-roles/${hostType}/${encodeURIComponent(hostId)}/${suffix}${query}`,
|
|
69
|
+
body: principal ? (floor ? { principal } : { key, principal }) : undefined,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export async function runAccessCommand(sub, args) {
|
|
73
|
+
if (!sub || wantsHelp({ sub, args })) {
|
|
74
|
+
console.log(ACCESS_USAGE);
|
|
75
|
+
return sub ? 0 : 1;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const { path, body } = parseAccessTarget({ sub, args });
|
|
79
|
+
const ctx = await buildContext(args);
|
|
80
|
+
const request = { ...clientOptions(ctx), path };
|
|
81
|
+
const result = sub === 'grant' ? await postJson({ ...request, body })
|
|
82
|
+
: sub === 'revoke' ? await deleteJson({ ...request, body })
|
|
83
|
+
: await getJson(request);
|
|
84
|
+
console.log(JSON.stringify(result, null, 2));
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
printCliError(error);
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -58,11 +58,15 @@ export interface ApplicationDeployBody {
|
|
|
58
58
|
roles: Record<string, ApplicationDeployRole>;
|
|
59
59
|
/** Collaborator roles: member tiers only. */
|
|
60
60
|
collaborators: Record<string, ApplicationDeployRole>;
|
|
61
|
+
/** The Application's own capabilities; members pin them as `app/<id>/<key>`. */
|
|
62
|
+
capabilities: Record<string, {
|
|
63
|
+
description?: string;
|
|
64
|
+
}>;
|
|
61
65
|
}
|
|
62
66
|
export interface ApplicationDeployWarning {
|
|
63
67
|
type: string;
|
|
64
68
|
role: string;
|
|
65
|
-
/** `collaborator` for a collaborator role; older servers send none. */
|
|
69
|
+
/** `collaborator` for a collaborator role, `capability` for an Application capability (`role` is then its key); older servers send none. */
|
|
66
70
|
kind?: string;
|
|
67
71
|
detail: string;
|
|
68
72
|
}
|
|
@@ -79,6 +79,7 @@ export function buildApplicationDeployBody(manifest) {
|
|
|
79
79
|
edges: manifest.primitives.flatMap((entry) => entry.uses.map((use) => ({ from: entry.id, to: use.primitive, ...(use.as !== undefined ? { label: use.as } : {}) }))),
|
|
80
80
|
roles,
|
|
81
81
|
collaborators: collaboratorRolesOf(manifest),
|
|
82
|
+
capabilities: manifest.capabilities ?? {},
|
|
82
83
|
};
|
|
83
84
|
}
|
|
84
85
|
function asRecord(value) {
|
|
@@ -134,7 +135,7 @@ export function logApplicationRegistration({ appId, registration, }) {
|
|
|
134
135
|
}
|
|
135
136
|
console.log(`${LOG} ✓ Application "${appId}" ${registration.created ? 'registered' : 'synced'}`);
|
|
136
137
|
for (const warning of registration.warnings) {
|
|
137
|
-
const section = warning.kind === 'collaborator' ? 'collaborators' : 'roles';
|
|
138
|
+
const section = warning.kind === 'collaborator' ? 'collaborators' : warning.kind === 'capability' ? 'capabilities' : 'roles';
|
|
138
139
|
console.warn(`${LOG} ! ${section}.${warning.role}: ${warning.detail}`);
|
|
139
140
|
}
|
|
140
141
|
}
|
package/dist/app/deploy.js
CHANGED
|
@@ -19,6 +19,7 @@ import { localGitMetadata } from '@sequenceholdings/artifact-studio/source-resol
|
|
|
19
19
|
import { assertActiveDeployProvenance } from '@sequenceholdings/artifact-studio/active-deploy-policy';
|
|
20
20
|
export { createDefaultDeployers } from './adapters.js';
|
|
21
21
|
import { defaultDeployOrder, loadAppManifest, usesAppGraph, } from './manifest.js';
|
|
22
|
+
import { warnOnManifestRoles } from '../manifest-roles-notice.js';
|
|
22
23
|
const LOG = '[seq-studio]';
|
|
23
24
|
const APP_MANIFEST_HINT = 'sequence.app.yml';
|
|
24
25
|
/**
|
|
@@ -92,6 +93,7 @@ function assertAppDeploymentSource({ manifest, options, rootDir, entries }) {
|
|
|
92
93
|
export async function deployApp(options) {
|
|
93
94
|
const rootDir = resolve(options.rootDir);
|
|
94
95
|
const manifest = await loadAppManifest(rootDir);
|
|
96
|
+
await warnOnManifestRoles({ dir: rootDir, file: 'sequence.app.yml', kind: 'application' });
|
|
95
97
|
const entries = resolveDeployEntries({ manifest, only: options.only });
|
|
96
98
|
const onError = manifest.deploy.on_error;
|
|
97
99
|
const deployers = options.deployers ?? (await createDefaultDeployers());
|
|
@@ -131,8 +133,8 @@ export async function deployApp(options) {
|
|
|
131
133
|
if (manifest.schema_version === 3) {
|
|
132
134
|
const body = buildApplicationDeployBody(manifest);
|
|
133
135
|
console.log(`${LOG} dry-run: would register Application "${manifest.app.id}" ` +
|
|
134
|
-
`(${body.members.length} member(s), ${Object.keys(body.
|
|
135
|
-
`${Object.keys(body.collaborators).length} collaborator role(s) to seed)`);
|
|
136
|
+
`(${body.members.length} member(s), ${Object.keys(body.capabilities).length} capability(ies), ` +
|
|
137
|
+
`${Object.keys(body.roles).length} role(s) and ${Object.keys(body.collaborators).length} collaborator role(s) to seed)`);
|
|
136
138
|
}
|
|
137
139
|
console.log(`${LOG} dry-run: no primitives deployed`);
|
|
138
140
|
return {
|
package/dist/app/manifest.d.ts
CHANGED
|
@@ -50,9 +50,10 @@ export declare const FLOOR_ROLE_ALIASES: readonly ["end_user", "invoker"];
|
|
|
50
50
|
export type FloorRoleAlias = (typeof FLOOR_ROLE_ALIASES)[number];
|
|
51
51
|
export declare function isFloorRoleAlias(value: string): value is FloorRoleAlias;
|
|
52
52
|
/**
|
|
53
|
-
* Application roles (schema_version 3).
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* Application roles (schema_version 3). DEPRECATED: create and edit roles in
|
|
54
|
+
* Atlas instead. Still accepted as a one-time seed — the first deploy that
|
|
55
|
+
* sees a key creates it; after that Atlas owns the role and a changed
|
|
56
|
+
* definition here is reported as drift, never applied.
|
|
56
57
|
*/
|
|
57
58
|
export declare const applicationRolesSchema: z.ZodObject<{
|
|
58
59
|
definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -65,6 +66,16 @@ export declare const applicationRolesSchema: z.ZodObject<{
|
|
|
65
66
|
}, z.core.$strict>>>;
|
|
66
67
|
}, z.core.$strict>>;
|
|
67
68
|
}, z.core.$strict>;
|
|
69
|
+
/**
|
|
70
|
+
* The Application's own capabilities (schema_version 3). Unlike roles these
|
|
71
|
+
* are code, like a primitive's capabilities: every deploy reconciles them
|
|
72
|
+
* (new keys published, removed keys deprecated). A member checks one by
|
|
73
|
+
* pinning `app/<app.id>/<key>` in its own `capabilities.uses`; roles, created
|
|
74
|
+
* in Atlas, grant them.
|
|
75
|
+
*/
|
|
76
|
+
export declare const applicationCapabilitiesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
77
|
+
description: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strict>>;
|
|
68
79
|
/**
|
|
69
80
|
* The member tiers a collaborator role can bundle. Which tier each primitive
|
|
70
81
|
* kind offers is checked in manifest-validation.ts; admin and owner never
|
|
@@ -74,8 +85,8 @@ export declare const COLLABORATOR_TIERS: readonly ["reader", "writer", "editor"]
|
|
|
74
85
|
export type CollaboratorTier = (typeof COLLABORATOR_TIERS)[number];
|
|
75
86
|
/**
|
|
76
87
|
* Application collaborator roles (schema_version 3): bundle the tiers that
|
|
77
|
-
* let someone change a member — never use-only access, never admin.
|
|
78
|
-
*
|
|
88
|
+
* let someone change a member — never use-only access, never admin.
|
|
89
|
+
* DEPRECATED here the same way `roles` are: create them in Atlas.
|
|
79
90
|
*/
|
|
80
91
|
export declare const applicationCollaboratorsSchema: z.ZodObject<{
|
|
81
92
|
definitions: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -164,6 +175,9 @@ export declare const appManifestSchema: z.ZodObject<{
|
|
|
164
175
|
}, z.core.$strict>>>;
|
|
165
176
|
}, z.core.$strict>>;
|
|
166
177
|
}, z.core.$strict>>;
|
|
178
|
+
capabilities: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
179
|
+
description: z.ZodOptional<z.ZodString>;
|
|
180
|
+
}, z.core.$strict>>>;
|
|
167
181
|
}, z.core.$strict>;
|
|
168
182
|
export type AppManifest = z.infer<typeof appManifestSchema>;
|
|
169
183
|
export type ApplicationRoles = z.infer<typeof applicationRolesSchema>;
|
package/dist/app/manifest.js
CHANGED
|
@@ -113,13 +113,22 @@ const applicationRoleDefinitionSchema = z
|
|
|
113
113
|
})
|
|
114
114
|
.strict();
|
|
115
115
|
/**
|
|
116
|
-
* Application roles (schema_version 3).
|
|
117
|
-
*
|
|
118
|
-
*
|
|
116
|
+
* Application roles (schema_version 3). DEPRECATED: create and edit roles in
|
|
117
|
+
* Atlas instead. Still accepted as a one-time seed — the first deploy that
|
|
118
|
+
* sees a key creates it; after that Atlas owns the role and a changed
|
|
119
|
+
* definition here is reported as drift, never applied.
|
|
119
120
|
*/
|
|
120
121
|
export const applicationRolesSchema = z
|
|
121
122
|
.object({ definitions: z.record(roleKeySchema, applicationRoleDefinitionSchema) })
|
|
122
123
|
.strict();
|
|
124
|
+
/**
|
|
125
|
+
* The Application's own capabilities (schema_version 3). Unlike roles these
|
|
126
|
+
* are code, like a primitive's capabilities: every deploy reconciles them
|
|
127
|
+
* (new keys published, removed keys deprecated). A member checks one by
|
|
128
|
+
* pinning `app/<app.id>/<key>` in its own `capabilities.uses`; roles, created
|
|
129
|
+
* in Atlas, grant them.
|
|
130
|
+
*/
|
|
131
|
+
export const applicationCapabilitiesSchema = z.record(roleKeySchema, z.object({ description: z.string().max(1024).optional() }).strict());
|
|
123
132
|
/**
|
|
124
133
|
* The member tiers a collaborator role can bundle. Which tier each primitive
|
|
125
134
|
* kind offers is checked in manifest-validation.ts; admin and owner never
|
|
@@ -137,8 +146,8 @@ const applicationCollaboratorDefinitionSchema = z
|
|
|
137
146
|
.strict();
|
|
138
147
|
/**
|
|
139
148
|
* Application collaborator roles (schema_version 3): bundle the tiers that
|
|
140
|
-
* let someone change a member — never use-only access, never admin.
|
|
141
|
-
*
|
|
149
|
+
* let someone change a member — never use-only access, never admin.
|
|
150
|
+
* DEPRECATED here the same way `roles` are: create them in Atlas.
|
|
142
151
|
*/
|
|
143
152
|
export const applicationCollaboratorsSchema = z
|
|
144
153
|
.object({ definitions: z.record(roleKeySchema, applicationCollaboratorDefinitionSchema) })
|
|
@@ -170,6 +179,7 @@ export const appManifestSchema = z
|
|
|
170
179
|
.default({ on_error: 'stop' }),
|
|
171
180
|
roles: applicationRolesSchema.optional(),
|
|
172
181
|
collaborators: applicationCollaboratorsSchema.optional(),
|
|
182
|
+
capabilities: applicationCapabilitiesSchema.optional(),
|
|
173
183
|
}).strict()
|
|
174
184
|
.superRefine(validateManifestGraph);
|
|
175
185
|
/** Local helper so schema refinement does not depend on later exports. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ParsedArgs } from '../process/commands.js';
|
|
2
2
|
declare const PAT_SCOPES: readonly ["repo:read", "repo:write", "repo:admin"];
|
|
3
3
|
type PatScope = (typeof PAT_SCOPES)[number];
|
|
4
|
-
export declare const AUTH_USAGE = "usage:\n seq-studio auth pat create --name <n> -e <env> [--scopes repo:read,repo:write]\n [--expires 1d|7d|30d|90d|1y|never] [--store-credentials]\n seq-studio auth pat list -e <env>\n seq-studio auth pat revoke <id> -e <env> [--yes]\n\n Issue a personal access token for git clone / git push against the platform\n git service.\n\n Authenticate with `seq-studio login`, then run `auth pat create -e <env>`.\n Alternatively, open Atlas \u2192 Settings \u2192 Tokens:\n https://<atlas-host>/settings/tokens\n Sign in, create a token (repo:read / repo:write), copy once, then:\n export ATLAS_GIT_PAT=<token>\n repo:write covers push and PR open; merging a PR requires an FGA Merge\n (or Admin) grant on the repository, not a PAT scope.\n\n On create the raw token is printed ONCE \u2014 store it; Atlas cannot re-show it.\n Git Basic auth: any username (e.g. git), PAT as the password.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n";
|
|
4
|
+
export declare const AUTH_USAGE = "usage:\n seq-studio auth whoami -e <env> [--json] server-verified identity and target (no tokens)\n seq-studio auth pat create --name <n> -e <env> [--scopes repo:read,repo:write]\n [--expires 1d|7d|30d|90d|1y|never] [--store-credentials]\n seq-studio auth pat list -e <env>\n seq-studio auth pat revoke <id> -e <env> [--yes]\n\n Issue a personal access token for git clone / git push against the platform\n git service.\n\n Authenticate with `seq-studio login`, then run `auth pat create -e <env>`.\n Alternatively, open Atlas \u2192 Settings \u2192 Tokens:\n https://<atlas-host>/settings/tokens\n Sign in, create a token (repo:read / repo:write), copy once, then:\n export ATLAS_GIT_PAT=<token>\n repo:write covers push and PR open; merging a PR requires an FGA Merge\n (or Admin) grant on the repository, not a PAT scope.\n\n On create the raw token is printed ONCE \u2014 store it; Atlas cannot re-show it.\n Git Basic auth: any username (e.g. git), PAT as the password.\n\n Flags: -e/--env <env> (required; see: seq-studio envs list)\n";
|
|
5
5
|
export declare function parsePatScopes(raw: string | undefined): PatScope[];
|
|
6
6
|
/**
|
|
7
7
|
* Map UI-style duration choices to an absolute ISO-8601 expiresAt, or undefined
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* The raw token is printed exactly once on create; use it as the Basic-auth
|
|
9
9
|
* password for `git clone` / `git push` (username is ignored).
|
|
10
10
|
*/
|
|
11
|
+
import { validateCommandInput, wantsHelp } from '../command-input.js';
|
|
11
12
|
import { deleteNoContent, getJson, postJson } from '../atlas-client.js';
|
|
12
13
|
import { printCliError } from '../cli-errors.js';
|
|
13
14
|
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from '../env-flags.js';
|
|
@@ -39,6 +40,7 @@ function stringFlag(flags, key) {
|
|
|
39
40
|
return value;
|
|
40
41
|
}
|
|
41
42
|
export const AUTH_USAGE = `usage:
|
|
43
|
+
seq-studio auth whoami -e <env> [--json] server-verified identity and target (no tokens)
|
|
42
44
|
seq-studio auth pat create --name <n> -e <env> [--scopes repo:read,repo:write]
|
|
43
45
|
[--expires 1d|7d|30d|90d|1y|never] [--store-credentials]
|
|
44
46
|
seq-studio auth pat list -e <env>
|
|
@@ -223,7 +225,21 @@ export async function authPatRevokeCommand(args) {
|
|
|
223
225
|
}
|
|
224
226
|
export async function runAuthCommand(sub, args) {
|
|
225
227
|
try {
|
|
228
|
+
if (wantsHelp({ sub, args })) {
|
|
229
|
+
console.log(AUTH_USAGE);
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
226
232
|
switch (sub) {
|
|
233
|
+
case 'whoami': {
|
|
234
|
+
validateCommandInput({ args, flags: {}, positional: 0 });
|
|
235
|
+
const ctx = await buildContext(args);
|
|
236
|
+
const { sub: subject, email, name, tenantSlug, roles, permissions } = await getJson({ ...clientOptions(ctx), path: '/api/me' });
|
|
237
|
+
console.log(JSON.stringify({
|
|
238
|
+
environment: ctx.env.name, url: ctx.env.url, authMode: ctx.authMode,
|
|
239
|
+
identity: { sub: subject, email, name, tenantSlug, roles, permissions },
|
|
240
|
+
}, null, 2));
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
227
243
|
case 'pat': {
|
|
228
244
|
const action = args.positional[0];
|
|
229
245
|
const nested = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ParsedArgs } from './process/commands.js';
|
|
2
|
+
/** Validate before authentication: a typo must never silently widen a mutation. */
|
|
3
|
+
export declare function validateCommandInput({ args, flags, positional, }: {
|
|
4
|
+
args: ParsedArgs;
|
|
5
|
+
flags: Record<string, 'string' | 'boolean'>;
|
|
6
|
+
positional: number;
|
|
7
|
+
}): void;
|
|
8
|
+
export declare function requiredStringFlag({ args, key }: {
|
|
9
|
+
args: ParsedArgs;
|
|
10
|
+
key: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export declare function wantsHelp({ sub, args }: {
|
|
13
|
+
sub?: string;
|
|
14
|
+
args: ParsedArgs;
|
|
15
|
+
}): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { REQUIRE_EXPLICIT_ENV_MESSAGE } from './env-flags.js';
|
|
2
|
+
/** Validate before authentication: a typo must never silently widen a mutation. */
|
|
3
|
+
export function validateCommandInput({ args, flags, positional, }) {
|
|
4
|
+
const allowed = { ...flags, env: 'string', e: 'string', json: 'boolean' };
|
|
5
|
+
for (const [key, value] of Object.entries(args.flags)) {
|
|
6
|
+
if (!Object.hasOwn(allowed, key))
|
|
7
|
+
throw new Error(`Unknown flag --${key}. See --help.`);
|
|
8
|
+
if (allowed[key] === 'string' && (typeof value !== 'string' || !value.trim())) {
|
|
9
|
+
throw new Error(`--${key} requires a non-empty value.`);
|
|
10
|
+
}
|
|
11
|
+
if (allowed[key] === 'boolean' && value !== true) {
|
|
12
|
+
throw new Error(`--${key} does not take a value.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const envs = [args.flags.env, args.flags.e, ...(args.repeatedFlags?.env ?? []), ...(args.repeatedFlags?.e ?? [])]
|
|
16
|
+
.filter((value) => typeof value === 'string');
|
|
17
|
+
if (new Set(envs).size > 1)
|
|
18
|
+
throw new Error('Specify only one environment per command.');
|
|
19
|
+
if (envs.length === 0)
|
|
20
|
+
throw new Error(REQUIRE_EXPLICIT_ENV_MESSAGE);
|
|
21
|
+
if (args.positional.length !== positional) {
|
|
22
|
+
throw new Error(`Expected ${positional} positional argument(s). See --help.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function requiredStringFlag({ args, key }) {
|
|
26
|
+
const value = args.flags[key];
|
|
27
|
+
if (typeof value !== 'string' || !value.trim())
|
|
28
|
+
throw new Error(`--${key} requires a value.`);
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
export function wantsHelp({ sub, args }) {
|
|
32
|
+
return sub === 'help' || sub === '--help' || sub === '-h' || args.flags.help === true || args.positional.includes('-h');
|
|
33
|
+
}
|