@selvajs/platform 0.16.1-beta.2 → 0.17.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 +25 -28
- package/dist/access/rules.d.ts +20 -26
- package/dist/access/rules.d.ts.map +1 -1
- package/dist/access/rules.js +16 -16
- package/dist/access/rules.js.map +1 -1
- package/dist/auth/interface.d.ts +99 -116
- package/dist/auth/interface.d.ts.map +1 -1
- package/dist/auth/types.d.ts +1 -4
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/bindings/interface.d.ts +19 -32
- package/dist/bindings/interface.d.ts.map +1 -1
- package/dist/bindings/interface.js +6 -12
- package/dist/bindings/interface.js.map +1 -1
- package/dist/computeServer/interface.d.ts +34 -41
- package/dist/computeServer/interface.d.ts.map +1 -1
- package/dist/computeServer/secrets.d.ts +16 -20
- package/dist/computeServer/secrets.d.ts.map +1 -1
- package/dist/computeServer/secrets.js +11 -12
- package/dist/computeServer/secrets.js.map +1 -1
- package/dist/computeServer/types.d.ts +15 -17
- package/dist/computeServer/types.d.ts.map +1 -1
- package/dist/computeServer/types.js.map +1 -1
- package/dist/computeServer/utils.d.ts +8 -14
- package/dist/computeServer/utils.d.ts.map +1 -1
- package/dist/computeServer/utils.js +8 -16
- package/dist/computeServer/utils.js.map +1 -1
- package/dist/config.d.ts +16 -39
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -2
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +12 -19
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +6 -10
- package/dist/context.js.map +1 -1
- package/dist/data/interface.d.ts +32 -47
- package/dist/data/interface.d.ts.map +1 -1
- package/dist/data/interface.js +7 -10
- package/dist/data/interface.js.map +1 -1
- package/dist/definitions/interface.d.ts +24 -31
- package/dist/definitions/interface.d.ts.map +1 -1
- package/dist/definitions/schemas.d.ts.map +1 -1
- package/dist/definitions/schemas.js +6 -9
- package/dist/definitions/schemas.js.map +1 -1
- package/dist/definitions/types.d.ts +26 -42
- package/dist/definitions/types.d.ts.map +1 -1
- package/dist/definitions/types.js +0 -1
- package/dist/definitions/types.js.map +1 -1
- package/dist/errors/interface.d.ts +4 -8
- package/dist/errors/interface.d.ts.map +1 -1
- package/dist/errors/interface.js.map +1 -1
- package/dist/errors.d.ts +2 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -5
- package/dist/errors.js.map +1 -1
- package/dist/events/audit.d.ts +13 -26
- package/dist/events/audit.d.ts.map +1 -1
- package/dist/events/interface.d.ts +17 -33
- package/dist/events/interface.d.ts.map +1 -1
- package/dist/events/interface.js +7 -22
- package/dist/events/interface.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/invites/interface.d.ts +3 -9
- package/dist/invites/interface.d.ts.map +1 -1
- package/dist/invites/types.d.ts +4 -11
- package/dist/invites/types.d.ts.map +1 -1
- package/dist/logging/interface.d.ts +19 -33
- package/dist/logging/interface.d.ts.map +1 -1
- package/dist/logging/interface.js +9 -17
- package/dist/logging/interface.js.map +1 -1
- package/dist/metrics/interface.d.ts +16 -31
- package/dist/metrics/interface.d.ts.map +1 -1
- package/dist/metrics/interface.js +1 -5
- package/dist/metrics/interface.js.map +1 -1
- package/dist/organizations/interface.d.ts +14 -23
- package/dist/organizations/interface.d.ts.map +1 -1
- package/dist/organizations/paths.d.ts +9 -12
- package/dist/organizations/paths.d.ts.map +1 -1
- package/dist/organizations/paths.js +12 -16
- package/dist/organizations/paths.js.map +1 -1
- package/dist/organizations/schemas.d.ts +10 -19
- package/dist/organizations/schemas.d.ts.map +1 -1
- package/dist/organizations/schemas.js +10 -19
- package/dist/organizations/schemas.js.map +1 -1
- package/dist/organizations/types.d.ts +3 -4
- package/dist/organizations/types.d.ts.map +1 -1
- package/dist/pagination.d.ts +13 -21
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js.map +1 -1
- package/dist/permissions/interface.d.ts +12 -21
- package/dist/permissions/interface.d.ts.map +1 -1
- package/dist/permissions/types.d.ts +5 -5
- package/dist/permissions/types.js +5 -5
- package/dist/platformProjects/interface.d.ts +7 -14
- package/dist/platformProjects/interface.d.ts.map +1 -1
- package/dist/platformProjects/types.d.ts +1 -4
- package/dist/platformProjects/types.d.ts.map +1 -1
- package/dist/projects/interface.d.ts +12 -17
- package/dist/projects/interface.d.ts.map +1 -1
- package/dist/shareLinks/interface.d.ts +5 -8
- package/dist/shareLinks/interface.d.ts.map +1 -1
- package/dist/shareLinks/schemas.d.ts.map +1 -1
- package/dist/shareLinks/schemas.js +1 -5
- package/dist/shareLinks/schemas.js.map +1 -1
- package/dist/shareLinks/types.d.ts +5 -6
- package/dist/shareLinks/types.d.ts.map +1 -1
- package/dist/shareLinks/types.js.map +1 -1
- package/dist/solveCache/interface.d.ts +32 -46
- package/dist/solveCache/interface.d.ts.map +1 -1
- package/dist/solveCache/interface.js.map +1 -1
- package/dist/storage/assetClasses.d.ts +16 -24
- package/dist/storage/assetClasses.d.ts.map +1 -1
- package/dist/storage/assetClasses.js +21 -28
- package/dist/storage/assetClasses.js.map +1 -1
- package/dist/storage/cacheBust.d.ts +12 -14
- package/dist/storage/cacheBust.d.ts.map +1 -1
- package/dist/storage/cacheBust.js +12 -14
- package/dist/storage/cacheBust.js.map +1 -1
- package/dist/storage/image.d.ts +9 -13
- package/dist/storage/image.d.ts.map +1 -1
- package/dist/storage/image.js +9 -13
- package/dist/storage/image.js.map +1 -1
- package/dist/userProfile/interface.d.ts +1 -1
- package/dist/userProfile/types.d.ts +1 -5
- package/dist/userProfile/types.d.ts.map +1 -1
- package/dist/userProfile/types.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @selvajs/platform
|
|
2
2
|
|
|
3
|
-
Pure TypeScript interfaces
|
|
3
|
+
Pure TypeScript interfaces defining Selva's contract with its backends — no runtime dependency on a specific database, storage, or auth service. Concrete adapters (local filesystem, Supabase, Azure, ...) live in their own packages and implement these interfaces.
|
|
4
4
|
|
|
5
5
|
This README is the contract. Read it before writing an adapter.
|
|
6
6
|
|
|
@@ -8,20 +8,21 @@ This README is the contract. Read it before writing an adapter.
|
|
|
8
8
|
|
|
9
9
|
## Interfaces at a glance
|
|
10
10
|
|
|
11
|
-
| Interface
|
|
12
|
-
|
|
|
13
|
-
| `IAuthProvider`
|
|
14
|
-
| `IPlatformPermissionStore`
|
|
15
|
-
| `IUserProfileStore`
|
|
16
|
-
| `IOrgStore`
|
|
17
|
-
| `IProjectStore`
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
| Interface | Purpose | Scoped by `RequestContext`? |
|
|
12
|
+
| ---------------------------- | --------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
13
|
+
| `IAuthProvider` | Verify tokens, manage users, issue sessions. Optional `passwordAuth?` capability. | No — the auth provider produces the identity that fills the context. |
|
|
14
|
+
| `IPlatformPermissionStore` | Per-user platform permissions; owns the sole-`instance_admin` invariant. | Yes — every method. |
|
|
15
|
+
| `IUserProfileStore` | Per-user profile (display name, starred definitions, recent runs). | Yes — adapters scope by `ctx.userId`. |
|
|
16
|
+
| `IOrgStore` | Orgs and org memberships. | Yes — every method. |
|
|
17
|
+
| `IProjectStore` | Projects and project memberships. | Yes — every method. |
|
|
18
|
+
| `IPlatformProjectGrantStore` | Instance-admin-managed grants onto `platform`-visibility projects. | Yes — every method. |
|
|
19
|
+
| `IDefinitionStore` | Definition metadata records + version history. | Yes — every method. |
|
|
20
|
+
| `IShareLinkStore` | Per-definition anonymous-access tokens. | Yes — every method. |
|
|
21
|
+
| `IInviteStore` | Pending org-membership invitations. | Yes — every method. |
|
|
22
|
+
| `IComputeServerStore` | Global + per-org compute-server config. | No — not tenant-scoped. |
|
|
23
|
+
| `IStorageProvider` | Path-based blob storage. Authorization is the caller's responsibility. | No — callers pass already-authorized paths. |
|
|
24
|
+
|
|
25
|
+
`IDataProvider` composes every store, plus optional `auditQuery` / `events` hooks and lifecycle methods `ensureUser` and `onUserDeleted`. An adapter typically implements one class per store and aggregates them.
|
|
25
26
|
|
|
26
27
|
---
|
|
27
28
|
|
|
@@ -38,15 +39,15 @@ This README is the contract. Read it before writing an adapter.
|
|
|
38
39
|
|
|
39
40
|
## Transaction ordering rules
|
|
40
41
|
|
|
41
|
-
Providers are two-phase: a metadata store (`IDataProvider`) and a blob store (`IStorageProvider`)
|
|
42
|
+
Providers are two-phase: a metadata store (`IDataProvider`) and a blob store (`IStorageProvider`) with no shared transaction. `DefinitionService` (`@selvajs/server/definitions`) composes them with fixed ordering so partial failure is recoverable.
|
|
42
43
|
|
|
43
|
-
**Create — metadata-first
|
|
44
|
+
**Create — metadata-first, `pending` → `draft`:**
|
|
44
45
|
|
|
45
46
|
1. Write the record with `status: 'pending'`.
|
|
46
47
|
2. Upload the blob.
|
|
47
|
-
3.
|
|
48
|
+
3. `attachInitialVersion` flips `status` to `'draft'`.
|
|
48
49
|
|
|
49
|
-
List queries filter `'pending'` by default (`
|
|
50
|
+
List queries filter `'pending'` and `'archived'` by default (`DefinitionListOptions.includePending` / `includeArchived` opt in). If step 2 fails, the record stays `'pending'` and is invisible to consumers.
|
|
50
51
|
|
|
51
52
|
**Delete — blob-first:**
|
|
52
53
|
|
|
@@ -55,10 +56,6 @@ List queries filter `'pending'` by default (`ListOptions.includePending` opts in
|
|
|
55
56
|
|
|
56
57
|
If step 2 fails, a retry re-deletes blobs (no-op) and succeeds.
|
|
57
58
|
|
|
58
|
-
**Update-file — best-effort, retry-safe:**
|
|
59
|
-
|
|
60
|
-
Archive current → append history → write new → prune history. These are four separate writes, so a crash can leave the sequence half-done. That is survivable because re-running the same update from the start lands on the same end state — each step either has already happened or still needs to, and repeating one is harmless.
|
|
61
|
-
|
|
62
59
|
---
|
|
63
60
|
|
|
64
61
|
## A minimal adapter
|
|
@@ -69,19 +66,19 @@ import type {
|
|
|
69
66
|
DefinitionRecord,
|
|
70
67
|
DefinitionRecordPatch,
|
|
71
68
|
RequestContext,
|
|
72
|
-
|
|
69
|
+
DefinitionListOptions,
|
|
73
70
|
Page
|
|
74
71
|
} from '@selvajs/platform';
|
|
75
72
|
|
|
76
73
|
export class MyDefinitionStore implements IDefinitionStore {
|
|
77
|
-
async list(ctx: RequestContext, opts?:
|
|
74
|
+
async list(ctx: RequestContext, opts?: DefinitionListOptions): Promise<Page<DefinitionRecord>> {
|
|
78
75
|
// Filter by ctx.actingOrgId; exclude status='pending' unless opts.includePending.
|
|
79
76
|
}
|
|
80
77
|
// ... etc
|
|
81
78
|
}
|
|
82
79
|
```
|
|
83
80
|
|
|
84
|
-
Wire it into a `SelvaConfig` via `defineConfig({ auth, data, storage })`. `data` is an `IDataProvider`
|
|
81
|
+
Wire it into a `SelvaConfig` via `defineConfig({ auth, data, storage })`. `data` is an `IDataProvider` composing every store.
|
|
85
82
|
|
|
86
83
|
---
|
|
87
84
|
|
|
@@ -99,7 +96,7 @@ runDefinitionStoreConformance({
|
|
|
99
96
|
});
|
|
100
97
|
```
|
|
101
98
|
|
|
102
|
-
The suites cover `ctx` scoping, `pending` filtering, `includePending` opt-in,
|
|
99
|
+
The suites cover `ctx` scoping, `pending` filtering, `includePending` opt-in, and `ProviderError` shapes. They do not cover performance or concurrency.
|
|
103
100
|
|
|
104
101
|
---
|
|
105
102
|
|
|
@@ -111,7 +108,7 @@ Throw `ProviderError` for user-facing failures (`new ProviderError('...', 404)`)
|
|
|
111
108
|
|
|
112
109
|
## Data privacy
|
|
113
110
|
|
|
114
|
-
|
|
111
|
+
Identity and credentials belong to whichever `IAuthProvider` is configured — for Supabase that's a separate service; for the local provider, Selva itself is the auth provider and holds credentials on disk. This package's own stores hold only opaque session data, user IDs, and authorization metadata. Details: [Providers](https://github.com/VektorNode/selva/blob/main/docs/self-hosting/providers/overview.md) and [Security & Limits](https://github.com/VektorNode/selva/blob/main/docs/self-hosting/concepts/security-and-limits.md).
|
|
115
112
|
|
|
116
113
|
---
|
|
117
114
|
|
package/dist/access/rules.d.ts
CHANGED
|
@@ -22,30 +22,27 @@ export interface ProjectAccessInput {
|
|
|
22
22
|
* admins — so the feature can be hidden silently without deleting data.
|
|
23
23
|
*/
|
|
24
24
|
enablePlatformProjects: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Grants for `platform`-visibility projects. Pass an empty array for
|
|
27
|
-
* non-platform projects — the rule only consults this for `platform`.
|
|
28
|
-
*/
|
|
25
|
+
/** Grants for `platform`-visibility projects; empty for non-platform ones. */
|
|
29
26
|
platformGrants: readonly PlatformProjectGrant[];
|
|
30
|
-
/** `ctx.actingOrgId` —
|
|
27
|
+
/** `ctx.actingOrgId` — matches org grants on platform projects. */
|
|
31
28
|
actingOrgId: string | null;
|
|
32
|
-
/** `ctx.userId` —
|
|
29
|
+
/** `ctx.userId` — matches user grants on platform projects. */
|
|
33
30
|
userId: string;
|
|
34
31
|
}
|
|
35
32
|
/**
|
|
36
|
-
* Authenticated-user view rule. Anonymous access
|
|
37
|
-
* tokens — the route resolves a valid token before this
|
|
33
|
+
* Authenticated-user view rule. Anonymous access goes through share-link
|
|
34
|
+
* tokens instead — the route resolves a valid token before this runs.
|
|
38
35
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
36
|
+
* Platform projects: `instance_admin` always passes; otherwise any grant
|
|
37
|
+
* (view-only or canSolve) satisfies view access.
|
|
41
38
|
*/
|
|
42
39
|
export declare function canView(input: ProjectAccessInput): boolean;
|
|
43
40
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
41
|
+
* Non-platform projects: same as `canView` — kept as a separate function so
|
|
42
|
+
* cost gating can diverge from view access later.
|
|
46
43
|
*
|
|
47
|
-
*
|
|
48
|
-
* satisfies `canView` but
|
|
44
|
+
* Platform projects: `instance_admin` always passes; a view-only grant
|
|
45
|
+
* satisfies `canView` but not `canSolve` — the grant needs `canSolve: true`.
|
|
49
46
|
*/
|
|
50
47
|
export declare function canSolve(input: ProjectAccessInput): boolean;
|
|
51
48
|
/**
|
|
@@ -92,11 +89,11 @@ export interface ReclaimAccessInput {
|
|
|
92
89
|
actingOrgId: string | null;
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
|
-
* Org leadership escape hatch
|
|
96
|
-
*
|
|
92
|
+
* Org leadership escape hatch: adds the actor as co-owner without demoting
|
|
93
|
+
* the existing owner. Tenancy must match.
|
|
97
94
|
*
|
|
98
|
-
* Platform projects
|
|
99
|
-
* management access to them
|
|
95
|
+
* Platform projects can't be reclaimed — `instance_admin` already has
|
|
96
|
+
* management access to them.
|
|
100
97
|
*/
|
|
101
98
|
export declare function canReclaim(input: ReclaimAccessInput): boolean;
|
|
102
99
|
export interface CreateProjectAccessInput {
|
|
@@ -106,22 +103,19 @@ export interface CreateProjectAccessInput {
|
|
|
106
103
|
targetOrgId: string;
|
|
107
104
|
}
|
|
108
105
|
/**
|
|
109
|
-
* Owner/admin can always create
|
|
106
|
+
* Owner/admin can always create; a `member` needs `manage_projects` org
|
|
110
107
|
* permission. Tenancy is enforced.
|
|
111
108
|
*
|
|
112
|
-
* Platform projects (`visibility
|
|
113
|
-
*
|
|
109
|
+
* Platform projects (`visibility: 'platform'`) go through the admin API,
|
|
110
|
+
* gated on `instance_admin` — this rule isn't consulted for them.
|
|
114
111
|
*/
|
|
115
112
|
export declare function canCreateProject(input: CreateProjectAccessInput): boolean;
|
|
116
113
|
/**
|
|
117
|
-
* Pre-flight check for project-owner removal
|
|
118
|
-
* loaded membership rows so route handlers can call it after `canManage`.
|
|
114
|
+
* Pre-flight check for project-owner removal, run after `canManage`.
|
|
119
115
|
*
|
|
120
116
|
* - `ok` — proceed
|
|
121
|
-
* - `sole_owner` — last owner; route surfaces 409
|
|
117
|
+
* - `sole_owner` — last owner; route surfaces 409 and suggests reclaim
|
|
122
118
|
* - `needs_confirm` — owner-on-owner removal without `?confirm=true`
|
|
123
|
-
*
|
|
124
|
-
* Non-owner targets always return `ok`.
|
|
125
119
|
*/
|
|
126
120
|
export type OwnerRemovalCheck = 'ok' | 'sole_owner' | 'needs_confirm';
|
|
127
121
|
export interface OwnerRemovalInput {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/access/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAezE,wBAAgB,eAAe,CAC9B,mBAAmB,EAAE,SAAS,kBAAkB,EAAE,EAClD,IAAI,EAAE,MAAM,OAAO,GACjB,OAAO,CAGT;AAED,MAAM,WAAW,kBAAkB;IAClC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,mBAAmB,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACnD,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,sBAAsB,EAAE,OAAO,CAAC;IAChC
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/access/rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACj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OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;KAAE,CAAC;IAChD,UAAU,EAAE,SAAS;QAAE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAA;KAAE,EAAE,CAAC;IAC/D,SAAS,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,iBAAiB,CAM7E"}
|
package/dist/access/rules.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* adapters. Mutating store methods MUST re-enforce the same predicate
|
|
4
4
|
* independently (RLS in SQL, code in local/JSON).
|
|
5
5
|
*
|
|
6
|
-
* `instance_admin` bypass is
|
|
6
|
+
* `instance_admin` bypass is not baked into rule bodies — wrap calls with
|
|
7
7
|
* `withAdminBypass` at the call site.
|
|
8
8
|
*/
|
|
9
9
|
function isInstanceAdmin(platformPermissions) {
|
|
@@ -15,11 +15,11 @@ export function withAdminBypass(platformPermissions, rule) {
|
|
|
15
15
|
return rule();
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Authenticated-user view rule. Anonymous access
|
|
19
|
-
* tokens — the route resolves a valid token before this
|
|
18
|
+
* Authenticated-user view rule. Anonymous access goes through share-link
|
|
19
|
+
* tokens instead — the route resolves a valid token before this runs.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* Platform projects: `instance_admin` always passes; otherwise any grant
|
|
22
|
+
* (view-only or canSolve) satisfies view access.
|
|
23
23
|
*/
|
|
24
24
|
export function canView(input) {
|
|
25
25
|
const { project, member, orgMember, allowCrossOrgPublic, enablePlatformProjects, platformPermissions, platformGrants, actingOrgId, userId } = input;
|
|
@@ -42,11 +42,11 @@ export function canView(input) {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* Non-platform projects: same as `canView` — kept as a separate function so
|
|
46
|
+
* cost gating can diverge from view access later.
|
|
47
47
|
*
|
|
48
|
-
*
|
|
49
|
-
* satisfies `canView` but
|
|
48
|
+
* Platform projects: `instance_admin` always passes; a view-only grant
|
|
49
|
+
* satisfies `canView` but not `canSolve` — the grant needs `canSolve: true`.
|
|
50
50
|
*/
|
|
51
51
|
export function canSolve(input) {
|
|
52
52
|
const { project, enablePlatformProjects, platformPermissions, platformGrants, actingOrgId, userId } = input;
|
|
@@ -124,11 +124,11 @@ export function canEditDefinition(input) {
|
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
|
-
* Org leadership escape hatch
|
|
128
|
-
*
|
|
127
|
+
* Org leadership escape hatch: adds the actor as co-owner without demoting
|
|
128
|
+
* the existing owner. Tenancy must match.
|
|
129
129
|
*
|
|
130
|
-
* Platform projects
|
|
131
|
-
* management access to them
|
|
130
|
+
* Platform projects can't be reclaimed — `instance_admin` already has
|
|
131
|
+
* management access to them.
|
|
132
132
|
*/
|
|
133
133
|
export function canReclaim(input) {
|
|
134
134
|
const { project, orgMember, actingOrgId } = input;
|
|
@@ -142,11 +142,11 @@ export function canReclaim(input) {
|
|
|
142
142
|
return role === 'owner' || role === 'admin';
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
145
|
-
* Owner/admin can always create
|
|
145
|
+
* Owner/admin can always create; a `member` needs `manage_projects` org
|
|
146
146
|
* permission. Tenancy is enforced.
|
|
147
147
|
*
|
|
148
|
-
* Platform projects (`visibility
|
|
149
|
-
*
|
|
148
|
+
* Platform projects (`visibility: 'platform'`) go through the admin API,
|
|
149
|
+
* gated on `instance_admin` — this rule isn't consulted for them.
|
|
150
150
|
*/
|
|
151
151
|
export function canCreateProject(input) {
|
|
152
152
|
const { orgMember, orgPermissions, actingOrgId, targetOrgId } = input;
|
package/dist/access/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/access/rules.ts"],"names":[],"mappings":"AAOA;;;;;;;GA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