@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
|
@@ -15,10 +15,19 @@ export interface ResolvedFeedback {
|
|
|
15
15
|
type Report = (code: Diagnostic["code"], path: string, message: string, severity?: Diagnostic["severity"]) => void;
|
|
16
16
|
/** Validate the declaration without consulting storage or any other provider. */
|
|
17
17
|
export declare function feedbackOptions(value: unknown, report: Report): FeedbackOptions | boolean;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Add the builders' grants to the workspace's roles, and, while the ontology keeps the implicit
|
|
20
|
+
* `member`, the implicit reporter role people hold beside it. Without the implicit `member`, the
|
|
21
|
+
* workspace's own roles grant `app_feedback:submit` and reading and acknowledging one's own items.
|
|
22
|
+
*/
|
|
19
23
|
export declare function feedbackRoles(options: FeedbackOptions | boolean, files: boolean, roles: ReadonlyArray<Role>, report: Report): {
|
|
20
24
|
readonly feedback: ResolvedFeedback;
|
|
21
25
|
readonly roles: ReadonlyArray<Role>;
|
|
22
26
|
};
|
|
23
27
|
export declare function checkFeedbackResponders(roles: ReadonlyArray<Role>, report: Report): void;
|
|
28
|
+
/**
|
|
29
|
+
* Without the implicit reporter, the workspace's roles say who may report: warn when feedback is on
|
|
30
|
+
* and no role grants `app_feedback:submit`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkFeedbackReporters(roles: ReadonlyArray<Role>, report: Report): void;
|
|
24
33
|
export {};
|
package/dist/feedback-config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { nameToWire } from "./authoring-names.js";
|
|
2
|
-
import { FEEDBACK_REPORTER_ROLE
|
|
2
|
+
import { FEEDBACK_REPORTER_ROLE } from "./names.js";
|
|
3
3
|
import { isAllowed, normalizePermission } from "./permissions.js";
|
|
4
|
-
import { isRole, role, roleEntries } from "./role.js";
|
|
4
|
+
import { implicitMemberOf, implicitRole, isImplicitRole, isRole, role, roleEntries, } from "./role.js";
|
|
5
5
|
/** Validate the declaration without consulting storage or any other provider. */
|
|
6
6
|
export function feedbackOptions(value, report) {
|
|
7
7
|
if (value === undefined) {
|
|
@@ -39,16 +39,22 @@ export function feedbackOptions(value, report) {
|
|
|
39
39
|
...(Array.isArray(options.builders) ? { builders: options.builders } : {}),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Add the builders' grants to the workspace's roles, and, while the ontology keeps the implicit
|
|
44
|
+
* `member`, the implicit reporter role people hold beside it. Without the implicit `member`, the
|
|
45
|
+
* workspace's own roles grant `app_feedback:submit` and reading and acknowledging one's own items.
|
|
46
|
+
*/
|
|
43
47
|
export function feedbackRoles(options, files, roles, report) {
|
|
44
48
|
if (options === false) {
|
|
45
49
|
return { feedback: { enabled: false, files: false, builders: [] }, roles };
|
|
46
50
|
}
|
|
47
51
|
const configured = typeof options === "object" ? options.builders : undefined;
|
|
48
52
|
const builders = new Set();
|
|
53
|
+
// @legacy ontology.implicit-member
|
|
54
|
+
const implicit = implicitMemberOf(roles);
|
|
49
55
|
if (configured === undefined) {
|
|
50
56
|
for (const candidate of roles) {
|
|
51
|
-
if (candidate
|
|
57
|
+
if (!isImplicitRole(candidate) &&
|
|
52
58
|
Array.isArray(candidate.permissions) &&
|
|
53
59
|
candidate.permissions.some((permission) => ["user:grant_roles", "user:*"].includes(normalizePermission(permission)))) {
|
|
54
60
|
builders.add(candidate.name);
|
|
@@ -63,10 +69,11 @@ export function feedbackRoles(options, files, roles, report) {
|
|
|
63
69
|
? nameToWire(candidate.name)
|
|
64
70
|
: undefined;
|
|
65
71
|
if (name === undefined ||
|
|
66
|
-
name ===
|
|
67
|
-
name === FEEDBACK_REPORTER_ROLE
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
!roles.some((declared) => declared.name === name && !isImplicitRole(declared)) ||
|
|
73
|
+
(implicit !== undefined && name === FEEDBACK_REPORTER_ROLE)) {
|
|
74
|
+
report("invalid-feedback", `feedback.builders[${index}]`, implicit === undefined
|
|
75
|
+
? "A builder must name a declared role."
|
|
76
|
+
: "A builder must name a declared role other than member or feedback_reporter.");
|
|
70
77
|
}
|
|
71
78
|
else {
|
|
72
79
|
builders.add(name);
|
|
@@ -94,7 +101,11 @@ export function feedbackRoles(options, files, roles, report) {
|
|
|
94
101
|
});
|
|
95
102
|
});
|
|
96
103
|
const own = { reporter: { $me: [] } };
|
|
97
|
-
|
|
104
|
+
// @legacy ontology.implicit-member
|
|
105
|
+
if (implicit === undefined) {
|
|
106
|
+
return { feedback: resolvedFeedback(options, files, builders), roles: resolved };
|
|
107
|
+
}
|
|
108
|
+
resolved.push(implicitRole(role(FEEDBACK_REPORTER_ROLE, {
|
|
98
109
|
description: "Implicit feedback authority of authenticated human members; never assigned.",
|
|
99
110
|
permissions: [
|
|
100
111
|
"app_feedback:submit",
|
|
@@ -107,21 +118,22 @@ export function feedbackRoles(options, files, roles, report) {
|
|
|
107
118
|
]
|
|
108
119
|
: []),
|
|
109
120
|
],
|
|
110
|
-
}));
|
|
121
|
+
})));
|
|
122
|
+
return { feedback: resolvedFeedback(options, files, builders), roles: resolved };
|
|
123
|
+
}
|
|
124
|
+
function resolvedFeedback(options, files, builders) {
|
|
111
125
|
return {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
: {}),
|
|
119
|
-
},
|
|
120
|
-
roles: resolved,
|
|
126
|
+
enabled: true,
|
|
127
|
+
files,
|
|
128
|
+
builders: [...builders],
|
|
129
|
+
...(typeof options === "object" && options.automaticFailureReports === true
|
|
130
|
+
? { automaticFailureReports: true }
|
|
131
|
+
: {}),
|
|
121
132
|
};
|
|
122
133
|
}
|
|
123
134
|
export function checkFeedbackResponders(roles, report) {
|
|
124
|
-
|
|
135
|
+
// @legacy ontology.implicit-member
|
|
136
|
+
const member = implicitMemberOf(roles);
|
|
125
137
|
if (!roles.some((candidate) => {
|
|
126
138
|
const permissions = [
|
|
127
139
|
...(Array.isArray(member?.permissions) ? member.permissions : []),
|
|
@@ -133,3 +145,17 @@ export function checkFeedbackResponders(roles, report) {
|
|
|
133
145
|
report("feedback-unanswerable", "feedback.builders", "No effective role can read and answer feedback. Configure feedback: { builders: [...] }.", "warning");
|
|
134
146
|
}
|
|
135
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Without the implicit reporter, the workspace's roles say who may report: warn when feedback is on
|
|
150
|
+
* and no role grants `app_feedback:submit`.
|
|
151
|
+
*/
|
|
152
|
+
export function checkFeedbackReporters(roles, report) {
|
|
153
|
+
if (roles.some((candidate) => isAllowed("app_feedback:submit", {
|
|
154
|
+
permissions: Array.isArray(candidate.permissions) ? candidate.permissions : [],
|
|
155
|
+
}))) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
report("feedback-unreportable", "feedback", "No role grants app_feedback:submit, so nobody can report feedback. Grant it, with " +
|
|
159
|
+
"app_feedback:read and app_feedback:acknowledge scoped to { reporter: me }, to the roles " +
|
|
160
|
+
"that may report, or set feedback: false.", "warning");
|
|
161
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export { ON_DELETE, rel } from "./relationship.js";
|
|
|
41
41
|
export type { AnyRelationship, EntityTarget, LazyEntity, ManyOptions, ManyRelationship, OnDelete, OneOptions, OneRelationship, Phrase, } from "./relationship.js";
|
|
42
42
|
export { renderCatalog } from "./render.js";
|
|
43
43
|
export type { RenderOptions } from "./render.js";
|
|
44
|
-
export { member, role, roleEntries, rolePermissions } from "./role.js";
|
|
44
|
+
export { implicitMemberOf, implicitRoleNames, isImplicitRole, member, role, roleEntries, rolePermissions, } from "./role.js";
|
|
45
45
|
export type { Role, RoleOptions, RolePermission } from "./role.js";
|
|
46
46
|
export type { FeedbackOptions, ResolvedFeedback } from "./feedback-config.js";
|
|
47
47
|
export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, nextCronTime, webhook, workflow, } from "./workflow.js";
|
|
@@ -75,8 +75,8 @@ export type { GeneratedActionManifest, GeneratedActions } from "./runtime/genera
|
|
|
75
75
|
export { Change, Edit, EditKind, HistoryEntry } from "./runtime/history.js";
|
|
76
76
|
export { ActionOutcome, ActionValidation, findAction, PREPARE_TIMEOUT, resolveAction, runAction, } from "./runtime/pipeline.js";
|
|
77
77
|
export type { ActionRequest, AfterCommit, CommittedAction, FoundAction, } from "./runtime/pipeline.js";
|
|
78
|
-
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
79
|
-
export type { ApiKeyCredential, ApiKeyParts, ApiKeySummary, CreatedApiKey, IdentityClaims, MemberKey, MemberRolesChange, MemberStatus, MemberSummary, PrincipalsManifest, } from "./runtime/principals.js";
|
|
78
|
+
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, implicitRoleNamesOf, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, workflowRoles, } from "./runtime/principals.js";
|
|
79
|
+
export type { ApiKeyCredential, ApiKeyParts, ApiKeySummary, CreatedApiKey, IdentityClaims, MemberKey, MemberRolesChange, MemberStatus, MemberSummary, PrincipalsManifest, StoredRolesListing, } from "./runtime/principals.js";
|
|
80
80
|
export { backendLayer, postgresLayer, sqlServiceRuntime } from "./runtime/service-binding.js";
|
|
81
81
|
export { makeOntologyRuntime } from "./runtime/sql-runtime.js";
|
|
82
82
|
export type { SqlOntologyRuntime, WriteScope } from "./runtime/sql-runtime.js";
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { AGENT_TOOL_VERBS, agentToolPermission, agentToolsOf, DEFAULT_MEMBER_PER
|
|
|
23
23
|
export { p, PROPERTY_TYPES, propertyDefinition } from "./property.js";
|
|
24
24
|
export { ON_DELETE, rel } from "./relationship.js";
|
|
25
25
|
export { renderCatalog } from "./render.js";
|
|
26
|
-
export { member, role, roleEntries, rolePermissions } from "./role.js";
|
|
26
|
+
export { implicitMemberOf, implicitRoleNames, isImplicitRole, member, role, roleEntries, rolePermissions, } from "./role.js";
|
|
27
27
|
export { after, changed, cron, cronNeverFires, cronProblem, isWorkflow, isWorkflowTrigger, MAX_ACTION_TRIGGERS, MAX_WORKFLOWS, nextCronTime, webhook, workflow, } from "./workflow.js";
|
|
28
28
|
export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADERS, MAX_WEBHOOKS, WEBHOOK_BASE_PATH, WEBHOOK_SIGNATURE_SCHEMES, webhookDelivery, webhookHeaderProblem, webhookPath, } from "./webhooks.js";
|
|
29
29
|
export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite,
|
|
@@ -46,7 +46,7 @@ export { InvalidQuery, InvalidValues, MemberNotFound, PrincipalRejected, StoredR
|
|
|
46
46
|
export { generatedActionManifests, generatedActions, upsertActionName, } from "./runtime/generated-actions.js";
|
|
47
47
|
export { Change, Edit, EditKind, HistoryEntry } from "./runtime/history.js";
|
|
48
48
|
export { ActionOutcome, ActionValidation, findAction, PREPARE_TIMEOUT, resolveAction, runAction, } from "./runtime/pipeline.js";
|
|
49
|
-
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, } from "./runtime/principals.js";
|
|
49
|
+
export { API_KEY_ITERATIONS, API_KEY_PREFIX, checkSignIn, createApiKey, createServiceUser, findApiKey, generateApiKey, grantMemberRoles, hashApiKeySecret, implicitRoleNamesOf, listApiKeys, listMembers, countUsersWithoutEmailIdentity, countUsersWithoutSegmentStreamIdentity, MEMBER_HISTORY_ACTIONS, parseApiKey, principalsOntology, resolveApiKeyCredential, resolvePrincipalByApiKey, resolvePrincipalByIdentity, reconcileWorkflowUsers, resolveWorkflowUser, revokeApiKey, WORKFLOW_USER_PROVIDER, workflowSubject, revokeMemberRoles, setMemberActive, setMemberBlocked, revokeMemberSessions, setUserRoles, SIGN_IN_RECORD_INTERVAL_MS, updateMemberRoles, workflowRoles, } from "./runtime/principals.js";
|
|
50
50
|
export { backendLayer, postgresLayer, sqlServiceRuntime } from "./runtime/service-binding.js";
|
|
51
51
|
export { makeOntologyRuntime } from "./runtime/sql-runtime.js";
|
|
52
52
|
// The HTTP service derived from the ontology.
|
package/dist/manifest.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CHAT_KINDS } from "./chat-channel.js";
|
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
4
|
import type { ResolvedConnection, ResolvedEntity } from "./analyze.js";
|
|
5
5
|
import type { ResolvedFeedback } from "./feedback-config.js";
|
|
6
|
-
import type
|
|
6
|
+
import { type Role } from "./role.js";
|
|
7
7
|
import type { ResolvedToolset } from "./toolset.js";
|
|
8
8
|
import { type ResolvedGuest, type ResolvedSignInOptions, type SignInPolicy } from "./sign-in.js";
|
|
9
9
|
/**
|
|
@@ -413,10 +413,15 @@ export type ScopeManifest = typeof ScopeManifest.Type;
|
|
|
413
413
|
export declare const RoleManifest: Schema.Struct<{
|
|
414
414
|
readonly name: Schema.String;
|
|
415
415
|
readonly description: Schema.String;
|
|
416
|
+
/**
|
|
417
|
+
* Whether the platform built the role in rather than the workspace declaring it: the guests' role,
|
|
418
|
+
* and the implicit `member` and `feedback_reporter` of an ontology declaring `member`. A role the
|
|
419
|
+
* workspace names `member` is not built in.
|
|
420
|
+
*/
|
|
416
421
|
readonly builtIn: Schema.Boolean;
|
|
417
422
|
/**
|
|
418
|
-
* What the role may do, wildcards included; for the built-in `member`, what every
|
|
419
|
-
* may do. Always written; absent from version 1 manifests.
|
|
423
|
+
* What the role may do, wildcards included; for the built-in `member`, what every invited or
|
|
424
|
+
* paired user may do. Always written; absent from version 1 manifests.
|
|
420
425
|
*/
|
|
421
426
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
422
427
|
/**
|
|
@@ -1012,10 +1017,15 @@ export declare const OntologyManifestWire: Schema.encodeKeys<Schema.Struct<{
|
|
|
1012
1017
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
1013
1018
|
readonly name: Schema.String;
|
|
1014
1019
|
readonly description: Schema.String;
|
|
1020
|
+
/**
|
|
1021
|
+
* Whether the platform built the role in rather than the workspace declaring it: the guests' role,
|
|
1022
|
+
* and the implicit `member` and `feedback_reporter` of an ontology declaring `member`. A role the
|
|
1023
|
+
* workspace names `member` is not built in.
|
|
1024
|
+
*/
|
|
1015
1025
|
readonly builtIn: Schema.Boolean;
|
|
1016
1026
|
/**
|
|
1017
|
-
* What the role may do, wildcards included; for the built-in `member`, what every
|
|
1018
|
-
* may do. Always written; absent from version 1 manifests.
|
|
1027
|
+
* What the role may do, wildcards included; for the built-in `member`, what every invited or
|
|
1028
|
+
* paired user may do. Always written; absent from version 1 manifests.
|
|
1019
1029
|
*/
|
|
1020
1030
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
1021
1031
|
/**
|
|
@@ -2719,10 +2729,15 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
2719
2729
|
readonly roles: Schema.$Array<Schema.encodeKeys<Schema.Struct<{
|
|
2720
2730
|
readonly name: Schema.String;
|
|
2721
2731
|
readonly description: Schema.String;
|
|
2732
|
+
/**
|
|
2733
|
+
* Whether the platform built the role in rather than the workspace declaring it: the guests' role,
|
|
2734
|
+
* and the implicit `member` and `feedback_reporter` of an ontology declaring `member`. A role the
|
|
2735
|
+
* workspace names `member` is not built in.
|
|
2736
|
+
*/
|
|
2722
2737
|
readonly builtIn: Schema.Boolean;
|
|
2723
2738
|
/**
|
|
2724
|
-
* What the role may do, wildcards included; for the built-in `member`, what every
|
|
2725
|
-
* may do. Always written; absent from version 1 manifests.
|
|
2739
|
+
* What the role may do, wildcards included; for the built-in `member`, what every invited or
|
|
2740
|
+
* paired user may do. Always written; absent from version 1 manifests.
|
|
2726
2741
|
*/
|
|
2727
2742
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
2728
2743
|
/**
|
|
@@ -3163,10 +3178,15 @@ export declare const OntologyManifest: Schema.declareConstructor<{
|
|
|
3163
3178
|
readonly roles: Schema.$Array<Schema.Struct<{
|
|
3164
3179
|
readonly name: Schema.String;
|
|
3165
3180
|
readonly description: Schema.String;
|
|
3181
|
+
/**
|
|
3182
|
+
* Whether the platform built the role in rather than the workspace declaring it: the guests' role,
|
|
3183
|
+
* and the implicit `member` and `feedback_reporter` of an ontology declaring `member`. A role the
|
|
3184
|
+
* workspace names `member` is not built in.
|
|
3185
|
+
*/
|
|
3166
3186
|
readonly builtIn: Schema.Boolean;
|
|
3167
3187
|
/**
|
|
3168
|
-
* What the role may do, wildcards included; for the built-in `member`, what every
|
|
3169
|
-
* may do. Always written; absent from version 1 manifests.
|
|
3188
|
+
* What the role may do, wildcards included; for the built-in `member`, what every invited or
|
|
3189
|
+
* paired user may do. Always written; absent from version 1 manifests.
|
|
3170
3190
|
*/
|
|
3171
3191
|
readonly permissions: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
3172
3192
|
/**
|
package/dist/manifest.js
CHANGED
|
@@ -2,9 +2,10 @@ import { CHAT_CHANNEL_NAME, CHAT_KINDS } from "./chat-channel.js";
|
|
|
2
2
|
import { balancesOf, metricExpression } from "./metric.js";
|
|
3
3
|
import { Effect, Schema, SchemaTransformation } from "effect";
|
|
4
4
|
import { acceptingEarlierManifestNames, withEarlierManifestNames } from "./legacy.js";
|
|
5
|
-
import { humanize,
|
|
5
|
+
import { humanize, GUEST_ROLE } from "./names.js";
|
|
6
6
|
import { PROPERTY_TYPES } from "./property.js";
|
|
7
7
|
import { ON_DELETE } from "./relationship.js";
|
|
8
|
+
import { isImplicitRole } from "./role.js";
|
|
8
9
|
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, isGuestBotCheckScheme, isGuestChannel, isSignInPolicy, isSignUpChannel, websiteOrigin, } from "./sign-in.js";
|
|
9
10
|
/**
|
|
10
11
|
* The manifest format this SDK writes. Readers accept any version and ignore unknown fields. Version
|
|
@@ -289,10 +290,15 @@ export const ScopeManifest = Schema.Struct({
|
|
|
289
290
|
export const RoleManifest = Schema.Struct({
|
|
290
291
|
name: Schema.String,
|
|
291
292
|
description: Schema.String,
|
|
293
|
+
/**
|
|
294
|
+
* Whether the platform built the role in rather than the workspace declaring it: the guests' role,
|
|
295
|
+
* and the implicit `member` and `feedback_reporter` of an ontology declaring `member`. A role the
|
|
296
|
+
* workspace names `member` is not built in.
|
|
297
|
+
*/
|
|
292
298
|
builtIn: Schema.Boolean,
|
|
293
299
|
/**
|
|
294
|
-
* What the role may do, wildcards included; for the built-in `member`, what every
|
|
295
|
-
* may do. Always written; absent from version 1 manifests.
|
|
300
|
+
* What the role may do, wildcards included; for the built-in `member`, what every invited or
|
|
301
|
+
* paired user may do. Always written; absent from version 1 manifests.
|
|
296
302
|
*/
|
|
297
303
|
permissions: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
298
304
|
/**
|
|
@@ -935,8 +941,9 @@ export function buildManifest(input) {
|
|
|
935
941
|
roles: input.roles.map((candidate) => ({
|
|
936
942
|
name: candidate.name,
|
|
937
943
|
description: candidate.description,
|
|
938
|
-
|
|
939
|
-
|
|
944
|
+
// @legacy ontology.implicit-member
|
|
945
|
+
// The implicit `member` and reporter are built in only while the ontology declares `member`.
|
|
946
|
+
builtIn: isImplicitRole(candidate) ||
|
|
940
947
|
(candidate.name === GUEST_ROLE && input.signIn.guest !== undefined),
|
|
941
948
|
permissions: [...candidate.permissions],
|
|
942
949
|
...((candidate.scopes ?? []).length > 0
|
package/dist/permissions.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export type UserIdentityVerb = (typeof USER_IDENTITY_VERBS)[number];
|
|
|
85
85
|
export declare const WILDCARD_ENTITY_VERBS: ReadonlyMap<string, ReadonlySet<string>>;
|
|
86
86
|
/** Whether a wildcard entity covers this verb of this entity, both in snake_case. */
|
|
87
87
|
export declare function wildcardEntityCovers(entity: string, verb: string): boolean;
|
|
88
|
-
/** What the
|
|
88
|
+
/** What the deprecated `member` export grants: reading everything. */
|
|
89
89
|
export declare const DEFAULT_MEMBER_PERMISSIONS: ReadonlyArray<string>;
|
|
90
90
|
export interface ParsedPermission {
|
|
91
91
|
/** An entity name, or `*`. */
|
package/dist/permissions.js
CHANGED
|
@@ -107,7 +107,7 @@ export function wildcardEntityCovers(entity, verb) {
|
|
|
107
107
|
const verbs = WILDCARD_ENTITY_VERBS.get(entity);
|
|
108
108
|
return verbs === undefined || verbs.has(verb);
|
|
109
109
|
}
|
|
110
|
-
/** What the
|
|
110
|
+
/** What the deprecated `member` export grants: reading everything. */
|
|
111
111
|
export const DEFAULT_MEMBER_PERMISSIONS = [`${WILDCARD}:${READ_VERB}`];
|
|
112
112
|
/** `<entity>:<verb>` with lowercase snake_case entities and lowercase snake_case verbs, or `*` for either. */
|
|
113
113
|
const PERMISSION = /^(\*|[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*):(\*|[a-z][a-zA-Z0-9]*(?:_[a-z0-9]+)*)$/;
|
package/dist/role.d.ts
CHANGED
|
@@ -53,9 +53,28 @@ export declare function rolePermissions(entries: ReadonlyArray<RolePermission>):
|
|
|
53
53
|
export declare function roleEntries(permissions: ReadonlyArray<string>, scopes: ReadonlyArray<ScopedPermission>): ReadonlyArray<RolePermission>;
|
|
54
54
|
export declare function role<const Name extends string>(name: Name, options: RoleOptions): Role<Name>;
|
|
55
55
|
export declare function isRole(value: unknown): value is Role;
|
|
56
|
+
/** A role the platform builds in while the ontology keeps the implicit `member`. */
|
|
57
|
+
export declare function implicitRole<Candidate extends Role>(candidate: Candidate): Candidate;
|
|
58
|
+
/** Whether the platform built this role in, rather than the workspace declaring it. */
|
|
59
|
+
export declare function isImplicitRole(candidate: Role): boolean;
|
|
56
60
|
/**
|
|
57
|
-
* The built-in
|
|
58
|
-
*
|
|
59
|
-
|
|
61
|
+
* The built-in `member` every invited or paired user, workflow and agent task holds, while the
|
|
62
|
+
* ontology declares `defineOntology({ member })`; `undefined` once it does not.
|
|
63
|
+
*/
|
|
64
|
+
export declare function implicitMemberOf(roles: ReadonlyArray<Role>): Role | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Whether a role name is reserved: `member` and `feedback_reporter`, only while the ontology keeps
|
|
67
|
+
* the implicit `member`. Stored assignments of a reserved name grant nothing and are never written.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isReservedRoleName(roles: ReadonlyArray<Role>, name: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The role names reserved while the ontology keeps the implicit `member`: `member` and
|
|
72
|
+
* `feedback_reporter`. Without it, none: a stored assignment of either is a role like any other.
|
|
73
|
+
*/
|
|
74
|
+
export declare function implicitRoleNames(roles: ReadonlyArray<Role>): ReadonlyArray<string>;
|
|
75
|
+
/**
|
|
76
|
+
* The earlier built-in role with its default permissions, `*:read`, which an ontology declaring
|
|
77
|
+
* `defineOntology({ member })` lists. An ontology without `member` declares roles of its own, such
|
|
78
|
+
* as `role("team", { … })`, instead.
|
|
60
79
|
*/
|
|
61
80
|
export declare const member: Role<"member">;
|
package/dist/role.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MEMBER_ROLE } from "./names.js";
|
|
1
|
+
import { FEEDBACK_REPORTER_ROLE, MEMBER_ROLE, toSnakeCase } from "./names.js";
|
|
2
2
|
import { DEFAULT_MEMBER_PERMISSIONS, normalizePermission, } from "./permissions.js";
|
|
3
3
|
export const RoleTypeId = Symbol.for("@segmentstream/ontology/Role");
|
|
4
4
|
function isScoped(value) {
|
|
@@ -65,12 +65,48 @@ export function role(name, options) {
|
|
|
65
65
|
export function isRole(value) {
|
|
66
66
|
return typeof value === "object" && value !== null && RoleTypeId in value;
|
|
67
67
|
}
|
|
68
|
+
// @legacy ontology.implicit-member
|
|
69
|
+
// The roles held without being granted: the built-in `member` an ontology declaring
|
|
70
|
+
// `defineOntology({ member })` keeps, and people's feedback reporter beside it. An ontology without
|
|
71
|
+
// `member` builds in no role, and `member` and `feedback_reporter` are names like any other.
|
|
72
|
+
// The mark is a symbol property, so a copy of the role, `{ ...role, permissions }`, keeps it.
|
|
73
|
+
const ImplicitRoleId = Symbol.for("@segmentstream/ontology/ImplicitRole");
|
|
74
|
+
/** A role the platform builds in while the ontology keeps the implicit `member`. */
|
|
75
|
+
export function implicitRole(candidate) {
|
|
76
|
+
return { ...candidate, [ImplicitRoleId]: true };
|
|
77
|
+
}
|
|
78
|
+
/** Whether the platform built this role in, rather than the workspace declaring it. */
|
|
79
|
+
export function isImplicitRole(candidate) {
|
|
80
|
+
return candidate[ImplicitRoleId] === true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The built-in `member` every invited or paired user, workflow and agent task holds, while the
|
|
84
|
+
* ontology declares `defineOntology({ member })`; `undefined` once it does not.
|
|
85
|
+
*/
|
|
86
|
+
export function implicitMemberOf(roles) {
|
|
87
|
+
return roles.find((candidate) => candidate.name === MEMBER_ROLE && isImplicitRole(candidate));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether a role name is reserved: `member` and `feedback_reporter`, only while the ontology keeps
|
|
91
|
+
* the implicit `member`. Stored assignments of a reserved name grant nothing and are never written.
|
|
92
|
+
*/
|
|
93
|
+
export function isReservedRoleName(roles, name) {
|
|
94
|
+
return (implicitMemberOf(roles) !== undefined &&
|
|
95
|
+
(name === MEMBER_ROLE || toSnakeCase(name) === FEEDBACK_REPORTER_ROLE));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The role names reserved while the ontology keeps the implicit `member`: `member` and
|
|
99
|
+
* `feedback_reporter`. Without it, none: a stored assignment of either is a role like any other.
|
|
100
|
+
*/
|
|
101
|
+
export function implicitRoleNames(roles) {
|
|
102
|
+
return implicitMemberOf(roles) === undefined ? [] : [MEMBER_ROLE, FEEDBACK_REPORTER_ROLE];
|
|
103
|
+
}
|
|
68
104
|
/**
|
|
69
|
-
* The built-in role
|
|
70
|
-
*
|
|
71
|
-
*
|
|
105
|
+
* The earlier built-in role with its default permissions, `*:read`, which an ontology declaring
|
|
106
|
+
* `defineOntology({ member })` lists. An ontology without `member` declares roles of its own, such
|
|
107
|
+
* as `role("team", { … })`, instead.
|
|
72
108
|
*/
|
|
73
|
-
export const member = role(MEMBER_ROLE, {
|
|
109
|
+
export const member = implicitRole(role(MEMBER_ROLE, {
|
|
74
110
|
description: "Every active app user.",
|
|
75
111
|
permissions: DEFAULT_MEMBER_PERMISSIONS,
|
|
76
|
-
});
|
|
112
|
+
}));
|
|
@@ -2,6 +2,7 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { uploadInput, BLOB_UPLOAD_ANNOTATION } from "../blob.js";
|
|
3
3
|
import { action } from "../action.js";
|
|
4
4
|
import { GENERATED_UPSERT_PREFIX, MEMBER_ROLE } from "../names.js";
|
|
5
|
+
import { implicitMemberOf, implicitRoleNames } from "../role.js";
|
|
5
6
|
import { generatedActionPermissions } from "../permissions.js";
|
|
6
7
|
import { p, REFERENCE_ANNOTATION } from "../property.js";
|
|
7
8
|
import { isCalendarDate, isInstant } from "../query.js";
|
|
@@ -138,13 +139,22 @@ export function writesOnlyThroughActions(ontology, entityName, actionName) {
|
|
|
138
139
|
}
|
|
139
140
|
/** A role a member may be granted: one the ontology declares, never the implicit `member`. */
|
|
140
141
|
function grantableRole(ontology) {
|
|
141
|
-
const declared = userRoleNames(ontology).filter((name) => name
|
|
142
|
+
const declared = userRoleNames(ontology).filter((name) => !implicitRoleNames(ontology.roles).includes(name));
|
|
142
143
|
return declared.length > 0
|
|
143
144
|
? Schema.Literals(declared)
|
|
144
145
|
: Schema.String.check(Schema.makeFilter(() => "Expected a role of the ontology, which declares none"));
|
|
145
146
|
}
|
|
146
|
-
/**
|
|
147
|
-
|
|
147
|
+
/**
|
|
148
|
+
* A role to revoke: any assigned role, including one the ontology no longer declares, but not the
|
|
149
|
+
* implicit `member` while the ontology declares one.
|
|
150
|
+
*/
|
|
151
|
+
function revocableRole(ontology) {
|
|
152
|
+
// @legacy ontology.implicit-member
|
|
153
|
+
const implicit = implicitMemberOf(ontology.roles) !== undefined;
|
|
154
|
+
return Schema.String.check(Schema.makeFilter((role) => !implicit ||
|
|
155
|
+
role !== MEMBER_ROLE ||
|
|
156
|
+
`${MEMBER_ROLE} is held by every active member and is never revoked`));
|
|
157
|
+
}
|
|
148
158
|
/**
|
|
149
159
|
* The built-in user's actions: inviting a member and changing a member's roles and activation, each
|
|
150
160
|
* through the runtime's member writes, which the `User` handle and the console share. Each returns
|
|
@@ -186,7 +196,7 @@ function memberActions(ontology, entity) {
|
|
|
186
196
|
"ignored. Give roles or all, not both.",
|
|
187
197
|
input: Schema.Struct({
|
|
188
198
|
id: member("revoke the roles from"),
|
|
189
|
-
roles: Schema.optionalKey(Schema.Array(revocableRole).annotate({ description: "The roles to revoke." })),
|
|
199
|
+
roles: Schema.optionalKey(Schema.Array(revocableRole(ontology)).annotate({ description: "The roles to revoke." })),
|
|
190
200
|
all: Schema.optionalKey(Schema.Literal(true).annotate({ description: "Revoke every role the member holds." })),
|
|
191
201
|
}).check(Schema.makeFilter((input) => (input.roles === undefined) !== (input.all === undefined) ||
|
|
192
202
|
"Expected roles or all: true, not both")),
|
|
@@ -17,13 +17,19 @@ import { type WriteContext } from "./writes.js";
|
|
|
17
17
|
export interface MemberWriteContext extends WriteContext {
|
|
18
18
|
/** The client whose transaction the write runs on, for the tables beside the user. */
|
|
19
19
|
readonly sql: SqlClient.SqlClient;
|
|
20
|
-
/** The roles the ontology declares, `member` included. */
|
|
20
|
+
/** The roles the ontology declares, the implicit `member` included while it declares one. */
|
|
21
21
|
readonly roles: ReadonlyArray<string>;
|
|
22
|
+
/** The role names the ontology reserves, as `implicitRoleNames` says: never granted or revoked. */
|
|
23
|
+
readonly reserved: ReadonlyArray<string>;
|
|
22
24
|
}
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Implicit human roles cannot be assigned or revoked; their authority comes from resolution. Only
|
|
27
|
+
* the names the ontology reserves, `reserved`, are implicit: none once it no longer declares
|
|
28
|
+
* `member`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function refuseMember(roles: ReadonlyArray<string>, reserved: ReadonlyArray<string>): Effect.Effect<void, UnknownRole>;
|
|
25
31
|
/** Only declared business roles may be granted; implicit built-in roles are never assignable. */
|
|
26
|
-
export declare function requireGrantable(declared: ReadonlyArray<string>, roles: ReadonlyArray<string>): Effect.Effect<void, UnknownRole>;
|
|
32
|
+
export declare function requireGrantable(declared: ReadonlyArray<string>, roles: ReadonlyArray<string>, reserved: ReadonlyArray<string>): Effect.Effect<void, UnknownRole>;
|
|
27
33
|
/** Grants declared roles to a member. A role the member holds changes nothing. */
|
|
28
34
|
export declare function grantMemberRoles(context: MemberWriteContext, entity: EntityModel, input: {
|
|
29
35
|
readonly id: string;
|
|
@@ -8,8 +8,16 @@ import { uuidv7 } from "./ids.js";
|
|
|
8
8
|
import { recordUserCreation, revokeMemberSessions } from "./member-tables.js";
|
|
9
9
|
import { loadRecord, notFound } from "./reads.js";
|
|
10
10
|
import { changeUserRoles, createRecord, updateRecord } from "./writes.js";
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Implicit human roles cannot be assigned or revoked; their authority comes from resolution. Only
|
|
13
|
+
* the names the ontology reserves, `reserved`, are implicit: none once it no longer declares
|
|
14
|
+
* `member`.
|
|
15
|
+
*/
|
|
16
|
+
export function refuseMember(roles, reserved) {
|
|
17
|
+
// @legacy ontology.implicit-member
|
|
18
|
+
if (reserved.length === 0) {
|
|
19
|
+
return Effect.void;
|
|
20
|
+
}
|
|
13
21
|
const reporter = roles.find((name) => toSnakeCase(name) === FEEDBACK_REPORTER_ROLE);
|
|
14
22
|
if (reporter !== undefined) {
|
|
15
23
|
return Effect.fail(new UnknownRole({
|
|
@@ -26,9 +34,9 @@ export function refuseMember(roles) {
|
|
|
26
34
|
}));
|
|
27
35
|
}
|
|
28
36
|
/** Only declared business roles may be granted; implicit built-in roles are never assignable. */
|
|
29
|
-
export function requireGrantable(declared, roles) {
|
|
37
|
+
export function requireGrantable(declared, roles, reserved) {
|
|
30
38
|
return Effect.gen(function* () {
|
|
31
|
-
yield* refuseMember(roles);
|
|
39
|
+
yield* refuseMember(roles, reserved);
|
|
32
40
|
const unknown = roles.find((candidate) => !declared.includes(candidate));
|
|
33
41
|
if (unknown !== undefined) {
|
|
34
42
|
return yield* new UnknownRole({
|
|
@@ -51,7 +59,7 @@ function lockMember(context, entity, id) {
|
|
|
51
59
|
/** Grants declared roles to a member. A role the member holds changes nothing. */
|
|
52
60
|
export function grantMemberRoles(context, entity, input) {
|
|
53
61
|
return Effect.gen(function* () {
|
|
54
|
-
yield* requireGrantable(context.roles, input.roles);
|
|
62
|
+
yield* requireGrantable(context.roles, input.roles, context.reserved);
|
|
55
63
|
yield* lockMember(context, entity, input.id);
|
|
56
64
|
return yield* changeUserRoles(context, entity, input.id, { grant: input.roles });
|
|
57
65
|
});
|
|
@@ -62,7 +70,7 @@ export function grantMemberRoles(context, entity, input) {
|
|
|
62
70
|
*/
|
|
63
71
|
export function revokeMemberRoles(context, entity, input) {
|
|
64
72
|
return Effect.gen(function* () {
|
|
65
|
-
yield* refuseMember(input.roles === "all" ? [] : input.roles);
|
|
73
|
+
yield* refuseMember(input.roles === "all" ? [] : input.roles, context.reserved);
|
|
66
74
|
yield* lockMember(context, entity, input.id);
|
|
67
75
|
return yield* changeUserRoles(context, entity, input.id, { revoke: input.roles });
|
|
68
76
|
});
|
|
@@ -76,7 +84,7 @@ export function revokeMemberRoles(context, entity, input) {
|
|
|
76
84
|
export function inviteMember(context, entity, input) {
|
|
77
85
|
return Effect.gen(function* () {
|
|
78
86
|
const roles = input.roles ?? [];
|
|
79
|
-
yield* requireGrantable(context.roles, roles);
|
|
87
|
+
yield* requireGrantable(context.roles, roles, context.reserved);
|
|
80
88
|
// Emails are stored lowercased, as sign-in links them.
|
|
81
89
|
const email = input.email.trim().toLowerCase();
|
|
82
90
|
const user = yield* createRecord(context, entity, {
|
package/dist/runtime/model.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export interface FieldModel extends QueryField {
|
|
|
17
17
|
readonly property?: ResolvedProperty;
|
|
18
18
|
/** The relationship whose key the field holds, for `<relationship>_id`. */
|
|
19
19
|
readonly relationship?: string;
|
|
20
|
+
/**
|
|
21
|
+
* For the user's `roles`, the stored role names it never lists or matches: those the ontology
|
|
22
|
+
* reserves, as {@link implicitRoleNames} says.
|
|
23
|
+
*/
|
|
24
|
+
readonly hiddenRoles?: ReadonlyArray<string>;
|
|
20
25
|
}
|
|
21
26
|
/** A declared `rel.one`: this entity's key column points at the target's id. */
|
|
22
27
|
export interface KeyLink extends QueryLink {
|
package/dist/runtime/model.js
CHANGED
|
@@ -3,6 +3,7 @@ import { entityQuerySchema, entityRecordSchema, findEntityManifest, queryFields,
|
|
|
3
3
|
import { COLUMN_TYPES, columnName, enumTypeName, historyTableName, joinColumnNames, joinTableName, quoteIdentifier, relationshipColumnName, SYSTEM_COLUMNS, tableName, } from "../migrate/storage.js";
|
|
4
4
|
import { User } from "../user.js";
|
|
5
5
|
import { USER_ROLES_PROPERTY } from "./user-roles.js";
|
|
6
|
+
import { implicitRoleNames } from "../role.js";
|
|
6
7
|
/**
|
|
7
8
|
* The type a field's parameters are cast to: the planner's column type, the enum type of a
|
|
8
9
|
* `select`, `uuid` for ids and keys, and the item type of a `list`, whose filters bind items.
|
|
@@ -47,7 +48,8 @@ export function entityModel(model, name) {
|
|
|
47
48
|
function buildEntity(ontology, resolved) {
|
|
48
49
|
const manifest = findEntityManifest(ontology.manifest, resolved.name);
|
|
49
50
|
const properties = new Map(resolved.properties.map((property) => [property.name, property]));
|
|
50
|
-
const
|
|
51
|
+
const hiddenRoles = implicitRoleNames(ontology.roles);
|
|
52
|
+
const fields = queryFields(manifest).map((field) => buildField(resolved.name, field, properties, hiddenRoles));
|
|
51
53
|
return {
|
|
52
54
|
name: resolved.name,
|
|
53
55
|
label: manifest.label,
|
|
@@ -65,7 +67,7 @@ function buildEntity(ontology, resolved) {
|
|
|
65
67
|
querySchema: entityQuerySchema(ontology.manifest, resolved.name),
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
|
-
function buildField(entity, field, properties) {
|
|
70
|
+
function buildField(entity, field, properties, hiddenRoles) {
|
|
69
71
|
const property = properties.get(field.name);
|
|
70
72
|
const system = SYSTEM_COLUMNS[field.name];
|
|
71
73
|
if (system !== undefined) {
|
|
@@ -86,6 +88,7 @@ function buildField(entity, field, properties) {
|
|
|
86
88
|
column: SYSTEM_COLUMNS.id,
|
|
87
89
|
sqlType: sqlType(field.storage, entity, field.name),
|
|
88
90
|
source: "projection",
|
|
91
|
+
hiddenRoles,
|
|
89
92
|
property,
|
|
90
93
|
};
|
|
91
94
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Cause, Effect } from "effect";
|
|
2
2
|
import { SqlClient } from "effect/unstable/sql";
|
|
3
3
|
import { CHANNEL_USERS_TABLE } from "../migrate/storage.js";
|
|
4
|
-
import {
|
|
4
|
+
import { MEMBER_ROLE } from "../names.js";
|
|
5
|
+
import { implicitRoleNames } from "../role.js";
|
|
5
6
|
import { permissionsOf, principalScopes } from "../permissions.js";
|
|
6
7
|
import { userRoleNames } from "./guests.js";
|
|
7
8
|
import { signUpPending } from "./member-tables.js";
|
|
@@ -22,9 +23,11 @@ export function runNewUserHook(ontology, sql, principal) {
|
|
|
22
23
|
return false;
|
|
23
24
|
}
|
|
24
25
|
const declared = new Set(userRoleNames(ontology));
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const reserved = implicitRoleNames(ontology.roles);
|
|
27
|
+
const assigned = principal.roles.filter((role) => declared.has(role) && !reserved.includes(role));
|
|
28
|
+
// @legacy ontology.implicit-member
|
|
29
|
+
// An earlier channel user's hook acts with the implicit member alone.
|
|
30
|
+
const roles = signedUp || reserved.length === 0 ? assigned : [MEMBER_ROLE];
|
|
28
31
|
const [entity, action] = hook.split(":");
|
|
29
32
|
yield* runAction(ontology, {
|
|
30
33
|
entity: entity,
|