@segmentstream/ontology 0.120.0 → 0.121.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/CHANGELOG.md +25 -0
- package/README.md +55 -38
- package/dist/analyze.d.ts +8 -3
- package/dist/analyze.js +71 -31
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +1 -0
- package/dist/feedback-config.d.ts +10 -1
- package/dist/feedback-config.js +46 -20
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/manifest.d.ts +29 -9
- package/dist/manifest.js +12 -5
- package/dist/permissions.d.ts +1 -1
- package/dist/permissions.js +1 -1
- package/dist/role.d.ts +22 -3
- package/dist/role.js +42 -6
- package/dist/runtime/generated-actions.js +14 -4
- package/dist/runtime/member-writes.d.ts +10 -4
- package/dist/runtime/member-writes.js +15 -7
- package/dist/runtime/model.d.ts +5 -0
- package/dist/runtime/model.js +5 -2
- package/dist/runtime/new-user-hook.js +7 -4
- package/dist/runtime/principals.d.ts +30 -10
- package/dist/runtime/principals.js +88 -44
- package/dist/runtime/records.js +1 -1
- package/dist/runtime/resolve-agent-identity.js +3 -3
- package/dist/runtime/sql-runtime.js +2 -1
- package/dist/runtime/user-roles.d.ts +8 -7
- package/dist/runtime/user-roles.js +17 -12
- package/dist/runtime/where.js +4 -4
- package/dist/service/agent/server.js +1 -0
- package/dist/service/agent/tasks.d.ts +2 -0
- package/dist/service/agent/tasks.js +7 -4
- package/dist/service/runtime-contract.d.ts +5 -0
- package/dist/service/service.js +2 -0
- package/dist/storage/authorization.js +9 -6
- package/dist/workflow.d.ts +7 -3
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { missingPermission, permissionsOf, principalScopes } from "../permissions.js";
|
|
3
3
|
import { PermissionDenied } from "../errors.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { FEEDBACK_REPORTER_ROLE, toSnakeCase } from "../names.js";
|
|
5
|
+
import { implicitRoleNames } from "../role.js";
|
|
6
|
+
import { rolesOf, workflowRoles } from "../runtime/principals.js";
|
|
6
7
|
import { PIPELINE_WORKER_PROVIDER } from "../runtime/workload.js";
|
|
7
8
|
import { WORKFLOW_USER_PROVIDER, workflowOfSubject } from "../runtime/workflow-users.js";
|
|
8
9
|
/** Re-read user and roles in the same transaction that authorizes a storage operation. */
|
|
@@ -24,9 +25,10 @@ workflowPrincipal) {
|
|
|
24
25
|
const users = yield* sql.unsafe(`SELECT kind::text, active, identity_provider, identity_subject FROM "user" WHERE id = $1::uuid FOR SHARE`, [principalId]);
|
|
25
26
|
const user = users[0];
|
|
26
27
|
const roles = yield* sql.unsafe(`SELECT role FROM "_user_roles" WHERE user_id = $1::uuid FOR SHARE`, [principalId]);
|
|
28
|
+
const reserved = implicitRoleNames(ontology.roles);
|
|
27
29
|
const held = roles
|
|
28
30
|
.map((row) => String(row.role))
|
|
29
|
-
.filter((name) => toSnakeCase(name)
|
|
31
|
+
.filter((name) => !(reserved.length > 0 && toSnakeCase(name) === FEEDBACK_REPORTER_ROLE));
|
|
30
32
|
// Reuse human principal resolution rather than reconstructing implicit authority here. The
|
|
31
33
|
// result rechecks required permissions and is the reader for scoped file reads; the caller's
|
|
32
34
|
// consent-narrowed principal still governs the rest of the operation.
|
|
@@ -41,8 +43,9 @@ workflowPrincipal) {
|
|
|
41
43
|
user?.kind === "service" &&
|
|
42
44
|
user.identity_provider === PIPELINE_WORKER_PROVIDER &&
|
|
43
45
|
user.identity_subject === `pipeline-workers:${execution.workspaceId}`;
|
|
44
|
-
// A workflow's runs hold what
|
|
45
|
-
// must assign exactly that role: an extra or
|
|
46
|
+
// A workflow's runs hold what the declared workflow's role grants (and the implicit member's,
|
|
47
|
+
// while the ontology declares one). The database must assign exactly that role: an extra or
|
|
48
|
+
// stale assignment widens nothing and is refused.
|
|
46
49
|
const workflowUser = user?.kind === "service" && user.identity_provider === WORKFLOW_USER_PROVIDER;
|
|
47
50
|
// The user's subject must be exactly the principal's, workspace id included.
|
|
48
51
|
const workflow = workflowUser &&
|
|
@@ -55,7 +58,7 @@ workflowPrincipal) {
|
|
|
55
58
|
execution === undefined &&
|
|
56
59
|
held.length === 1 &&
|
|
57
60
|
held[0] === workflow.role;
|
|
58
|
-
const liveHeld = workflowUser && workflow ?
|
|
61
|
+
const liveHeld = workflowUser && workflow ? workflowRoles(ontology, workflow.role) : (member?.roles ?? held);
|
|
59
62
|
const permissions = worker
|
|
60
63
|
? ["*:*"]
|
|
61
64
|
: workflowUser && !declaredWorkflow
|
package/dist/workflow.d.ts
CHANGED
|
@@ -22,7 +22,10 @@ export declare const MAX_ACTION_TRIGGERS = 20;
|
|
|
22
22
|
export interface TriggerRuns {
|
|
23
23
|
/** The action the trigger runs, as its handle: `Lead.actions.notify`. */
|
|
24
24
|
readonly runs?: AnyActionHandle;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* The declared role the runs hold, required with `runs`: exactly its permissions, with the
|
|
27
|
+
* built-in `member`'s while the ontology declares one.
|
|
28
|
+
*/
|
|
26
29
|
readonly role?: string;
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
@@ -264,8 +267,9 @@ export interface WorkflowOptions<S extends AnyInputSchema | undefined = undefine
|
|
|
264
267
|
/** Required, like every declaration: what the workflow does and why. */
|
|
265
268
|
readonly description: string;
|
|
266
269
|
/**
|
|
267
|
-
* The declared role
|
|
268
|
-
*
|
|
270
|
+
* The declared role whose permissions the workflow's runs hold: exactly its permissions, with
|
|
271
|
+
* the built-in `member`'s while the ontology declares one. Its runs act as the workflow's own
|
|
272
|
+
* service user.
|
|
269
273
|
*/
|
|
270
274
|
readonly role: string;
|
|
271
275
|
/** A `Schema.Struct` of the workflow's input. Omitted means `{}`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.121.0",
|
|
4
4
|
"description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|