@segmentstream/ontology 0.106.3 → 0.108.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 +64 -0
- package/README.md +45 -11
- package/dist/analyze.d.ts +7 -1
- package/dist/analyze.js +271 -16
- package/dist/authoring.js +6 -0
- package/dist/diagnostics.d.ts +3 -3
- package/dist/diagnostics.js +1 -0
- package/dist/emails.d.ts +36 -5
- package/dist/emails.js +139 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +5 -3
- package/dist/manifest.d.ts +262 -1
- package/dist/manifest.js +73 -4
- package/dist/migrate/apply.js +8 -1
- package/dist/migrate/model.d.ts +154 -0
- package/dist/migrate/storage.d.ts +2 -0
- package/dist/migrate/storage.js +8 -0
- package/dist/names.d.ts +5 -0
- package/dist/names.js +5 -0
- package/dist/ontology.d.ts +4 -1
- package/dist/permissions.d.ts +30 -2
- package/dist/permissions.js +51 -6
- package/dist/runtime/agent-counters.d.ts +5 -1
- package/dist/runtime/agent-counters.js +21 -6
- package/dist/runtime/agent-web.d.ts +9 -6
- package/dist/runtime/agent-web.js +101 -5
- package/dist/runtime/generated-actions.js +2 -3
- package/dist/runtime/guests.d.ts +32 -0
- package/dist/runtime/guests.js +64 -0
- package/dist/runtime/new-user-hook.js +2 -1
- package/dist/runtime/oauth.js +7 -1
- package/dist/runtime/pipeline.js +3 -2
- package/dist/runtime/principals.js +6 -4
- package/dist/runtime/sql-runtime.js +2 -1
- package/dist/runtime.d.ts +10 -2
- package/dist/service/agent/authentication.d.ts +6 -4
- package/dist/service/agent/authentication.js +20 -5
- package/dist/service/agent/protocol.d.ts +28 -2
- package/dist/service/agent/protocol.js +23 -10
- package/dist/service/agent/server.d.ts +9 -2
- package/dist/service/agent/server.js +12 -12
- package/dist/service/agent/tasks.d.ts +3 -0
- package/dist/service/agent/tasks.js +5 -3
- package/dist/service/agent/web-tokens.d.ts +28 -13
- package/dist/service/agent/web-tokens.js +91 -38
- package/dist/service/authentication.d.ts +6 -0
- package/dist/service/authentication.js +11 -2
- package/dist/service/chat/review-delivery.js +4 -0
- package/dist/service/mcp/server.js +3 -3
- package/dist/service/mcp/tools.d.ts +4 -2
- package/dist/service/mcp/tools.js +14 -2
- package/dist/service/oauth/protocol.js +8 -2
- package/dist/service/oauth/server.js +5 -1
- package/dist/service/runtime-contract.d.ts +58 -6
- package/dist/service/schemas.d.ts +40 -0
- package/dist/service/service.js +15 -4
- package/dist/sign-in.d.ts +66 -9
- package/dist/sign-in.js +87 -9
- package/package.json +1 -1
package/dist/analyze.js
CHANGED
|
@@ -6,13 +6,13 @@ import { isBlobAccept, MAX_BLOB_BYTES } from "./blob.js";
|
|
|
6
6
|
import { isAction } from "./action.js";
|
|
7
7
|
import { CONNECTION_KEY, isConnection } from "./connection.js";
|
|
8
8
|
import { isEntity } from "./entity.js";
|
|
9
|
-
import { QUERY_METRICS_ROUTE, LEGACY_MEMBER_NAME, ENTITY_ID, GENERATED_ACTIONS, GENERATED_UPSERT_PREFIX, HISTORY_SUFFIX, MCP_METRIC_TOOLS, MCP_READ_TOOLS, MCP_TOOL_NAME_MAX_LENGTH, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE, mcpToolName, RESERVED_ENTITY_NAMES, RESERVED_MEMBER_NAMES, RESERVED_RELATIONSHIP_NAMES, SNAKE_CASE_NAME, SYSTEM_PROPERTIES, humanize, isSystemProperty, toCamelCase, } from "./names.js";
|
|
9
|
+
import { QUERY_METRICS_ROUTE, LEGACY_MEMBER_NAME, ENTITY_ID, GENERATED_ACTIONS, GENERATED_UPSERT_PREFIX, HISTORY_SUFFIX, MCP_METRIC_TOOLS, MCP_READ_TOOLS, MCP_TOOL_NAME_MAX_LENGTH, MEMBER_ROLE, FEEDBACK_REPORTER_ROLE, GUEST_ROLE, mcpToolName, RESERVED_ENTITY_NAMES, RESERVED_MEMBER_NAMES, RESERVED_RELATIONSHIP_NAMES, SNAKE_CASE_NAME, SYSTEM_PROPERTIES, humanize, isSystemProperty, toCamelCase, } from "./names.js";
|
|
10
10
|
import { REFERENCE_ANNOTATION, propertyDefinition, propertyOptionNames, unknownPropertyOptions, referenceTarget, } from "./property.js";
|
|
11
|
-
import { EXPLICIT_GRANT_ENTITIES, generatedActionPermissions, grants, isAllowed, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, WORKSPACE_SOURCE, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
11
|
+
import { AGENT_TOOL, AGENT_TOOL_VERBS, EXPLICIT_GRANT_ENTITIES, generatedActionPermissions, grants, isAllowed, namesAgentTools, normalizePermission, parsePermission, parseWorkflowPermission, permissionOf, READ_VERB, rolesGranting, USER_IDENTITY_VERBS, USER_MEMBER_VERBS, WILDCARD, wildcardEntityCovers, WORKSPACE_SOURCE, WORKSPACE_SOURCE_PERMISSION, } from "./permissions.js";
|
|
12
12
|
import { ON_DELETE, isRelationship } from "./relationship.js";
|
|
13
13
|
import { isRole, member, role } from "./role.js";
|
|
14
|
-
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isSignInPolicy, isSignUpChannel,
|
|
15
|
-
import { emailOptions } from "./emails.js";
|
|
14
|
+
import { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, GUEST_CHANNELS, SIGN_UP_CHANNELS, SIGN_UP_CHAT_CHANNELS, isGuestChannel, isSignInPolicy, isSignUpChannel, websiteOrigin, } from "./sign-in.js";
|
|
15
|
+
import { BUILT_IN_EMAIL_VALUES, emailOptions, emailValueNames, } from "./emails.js";
|
|
16
16
|
import { AgentChat } from "./agent-chat.js";
|
|
17
17
|
import { AgentReview } from "./agent-review.js";
|
|
18
18
|
import { APP_FEEDBACK_ENTITIES } from "./app-feedback.js";
|
|
@@ -75,10 +75,15 @@ export function analyze(config, options = {}) {
|
|
|
75
75
|
!declaredRoles.some((candidate) => candidate.name === nameToWire(config.hooks.role)))) {
|
|
76
76
|
report("invalid-permission", "hooks.role", "hooks.role must name a declared ontology role.");
|
|
77
77
|
}
|
|
78
|
+
const emails = emailOptions(config.emails, report, (name, path) => camelCaseName(name, path, "agreementReview", "Email", report));
|
|
78
79
|
const signInDeclared = signInOptions(config, report);
|
|
80
|
+
const guest = guestOptions(config, report);
|
|
81
|
+
const invitationEmail = invitationEmailOption(config, emails, report);
|
|
79
82
|
const signIn = {
|
|
80
83
|
...signInDeclared,
|
|
81
84
|
...signUpOptions(config, signInDeclared, declaredRoles, report),
|
|
85
|
+
...(guest === undefined ? {} : { guest: guest.resolved }),
|
|
86
|
+
...(invitationEmail === undefined ? {} : { invitationEmail }),
|
|
82
87
|
};
|
|
83
88
|
const discovery = config.discovery;
|
|
84
89
|
if (discovery !== undefined &&
|
|
@@ -89,7 +94,6 @@ export function analyze(config, options = {}) {
|
|
|
89
94
|
report("invalid-discovery", "discovery", 'discovery takes { model: "<provider>/<model>" }, a decision model on AI Gateway such as ' +
|
|
90
95
|
'"typesafe-ai/jev-1.14.0".');
|
|
91
96
|
}
|
|
92
|
-
const emails = emailOptions(config.emails, report, (name, path) => camelCaseName(name, path, "agreementReview", "Email", report));
|
|
93
97
|
const connections = collectConnections(config, report);
|
|
94
98
|
const entitiesByName = new Map();
|
|
95
99
|
for (const candidate of entities) {
|
|
@@ -126,7 +130,9 @@ export function analyze(config, options = {}) {
|
|
|
126
130
|
definitions: new Set(entities.map((candidate) => candidate.definition)),
|
|
127
131
|
};
|
|
128
132
|
}
|
|
129
|
-
const { feedback, roles } = feedbackRoles(feedbackSetting, files, declaredRoles, report);
|
|
133
|
+
const { feedback, roles: feedbackAndDeclared } = feedbackRoles(feedbackSetting, files, declaredRoles, report);
|
|
134
|
+
// The guests' role comes last: no declared role, builder, workflow or sign-up may name it.
|
|
135
|
+
const roles = guest === undefined ? feedbackAndDeclared : [...feedbackAndDeclared, guest.role];
|
|
130
136
|
// Resolve authored entities before the optional feedback entities and the agent's reviews,
|
|
131
137
|
// preserving their ordering: built-ins added later never move an authored entity.
|
|
132
138
|
const isFeedback = (candidate) => APP_FEEDBACK_ENTITIES.some((feedback) => feedback.name === candidate.name);
|
|
@@ -231,12 +237,21 @@ export function analyze(config, options = {}) {
|
|
|
231
237
|
if (options.checkPermissions !== false) {
|
|
232
238
|
// Validate authored grants before augmentation can replace a scoped grant with an unscoped
|
|
233
239
|
// builder grant. Invalid authored scopes must remain errors; generated redundancy needs no warning.
|
|
234
|
-
checkPermissions(resolved, roles, workflows, report, [
|
|
240
|
+
checkPermissions(resolved, roles, workflows, report, [
|
|
241
|
+
...declaredRoles,
|
|
242
|
+
...roles.filter((candidate) => candidate.name === FEEDBACK_REPORTER_ROLE),
|
|
243
|
+
...(guest === undefined ? [] : [guest.role]),
|
|
244
|
+
], toolsets);
|
|
235
245
|
checkOpenWarehouseReads({ entities: resolved, roles, signIn, report });
|
|
236
246
|
checkOpenChannels({ config, entities: resolved, roles, signIn, report });
|
|
237
247
|
checkNewUserAction({ entities: resolved, roles, signIn, report });
|
|
238
248
|
checkSignUpRoles({ entities: resolved, roles, signIn, report });
|
|
239
249
|
checkSignUpAction({ entities: resolved, roles, signIn, report });
|
|
250
|
+
// Guests' permissions decide nothing about whether the workspace names agent tools.
|
|
251
|
+
checkAgentToolGrants(roles.filter((candidate) => !BUILT_IN_GUESTS.has(candidate)), report);
|
|
252
|
+
if (guest !== undefined) {
|
|
253
|
+
checkGuestPermissions({ entities: resolved, guest: guest.role, report });
|
|
254
|
+
}
|
|
240
255
|
if (feedback.enabled) {
|
|
241
256
|
checkFeedbackResponders(roles, report);
|
|
242
257
|
}
|
|
@@ -389,6 +404,10 @@ function resolveWorkflows(input) {
|
|
|
389
404
|
report("workflow_role_unknown", `${path}.role`, "feedback_reporter is implicit human authority and cannot be a workflow role.");
|
|
390
405
|
valid = false;
|
|
391
406
|
}
|
|
407
|
+
else if (declared !== undefined && BUILT_IN_GUESTS.has(declared)) {
|
|
408
|
+
report("workflow_role_unknown", `${path}.role`, "guest is the role of guests and cannot be a workflow role.");
|
|
409
|
+
valid = false;
|
|
410
|
+
}
|
|
392
411
|
else if (role === MEMBER_ROLE) {
|
|
393
412
|
report("workflow_role_is_member", `${path}.role`, "a workflow runs as a declared role of its own; its runs hold member's permissions " +
|
|
394
413
|
"anyway, so name the role that adds what the workflow does.");
|
|
@@ -929,6 +948,11 @@ function resolveToolsets(declared, entities, connections, report) {
|
|
|
929
948
|
"workspace's code; rename the toolset.");
|
|
930
949
|
return;
|
|
931
950
|
}
|
|
951
|
+
if (name === AGENT_TOOL) {
|
|
952
|
+
report("reserved-name", path, `${name} names the built-in permissions ${agentToolPermissions()}, which grant the ` +
|
|
953
|
+
"agent's own tools; rename the toolset.");
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
932
956
|
const definition = candidate.definition;
|
|
933
957
|
if (!isPlainObject(definition)) {
|
|
934
958
|
report("invalid-toolset", path, "a toolset takes { connection, api, lock, description }.");
|
|
@@ -1210,7 +1234,7 @@ function signInOptions(config, report) {
|
|
|
1210
1234
|
return fallback;
|
|
1211
1235
|
}
|
|
1212
1236
|
for (const key of Object.keys(options)) {
|
|
1213
|
-
if (!["policy", "channels", "onNewUser", "browser", "codeLink"].includes(key)) {
|
|
1237
|
+
if (!["policy", "channels", "onNewUser", "browser", "codeLink", "invitationEmail"].includes(key)) {
|
|
1214
1238
|
report("invalid-sign-in", `signIn.${key}`, `Unknown signIn key: ${key}.`);
|
|
1215
1239
|
}
|
|
1216
1240
|
}
|
|
@@ -1269,6 +1293,35 @@ function signInOptions(config, report) {
|
|
|
1269
1293
|
...(typeof codeLink === "boolean" ? { codeLink } : {}),
|
|
1270
1294
|
};
|
|
1271
1295
|
}
|
|
1296
|
+
/**
|
|
1297
|
+
* `signIn.invitationEmail`: the wire name of the declared email the platform sends instead of its
|
|
1298
|
+
* own invitation. Nothing fills an invitation's values, so the email may use only built-in ones.
|
|
1299
|
+
*/
|
|
1300
|
+
function invitationEmailOption(config, emails, report) {
|
|
1301
|
+
const options = config.signIn;
|
|
1302
|
+
const name = isPlainObject(options) ? options.invitationEmail : undefined;
|
|
1303
|
+
const path = "signIn.invitationEmail";
|
|
1304
|
+
if (name === undefined) {
|
|
1305
|
+
return undefined;
|
|
1306
|
+
}
|
|
1307
|
+
if (typeof name !== "string" || !/^[a-z][a-zA-Z0-9]*$/.test(name)) {
|
|
1308
|
+
report("invalid-sign-in", path, "invitationEmail names one of the ontology's emails, such as memberInvitation.");
|
|
1309
|
+
return undefined;
|
|
1310
|
+
}
|
|
1311
|
+
const wire = nameToWire(name);
|
|
1312
|
+
const template = emails[wire];
|
|
1313
|
+
if (template === undefined) {
|
|
1314
|
+
report("invalid-sign-in", path, `${name} is not one of the ontology's emails.`);
|
|
1315
|
+
return undefined;
|
|
1316
|
+
}
|
|
1317
|
+
const values = emailValueNames(template);
|
|
1318
|
+
if (values.length > 0) {
|
|
1319
|
+
report("invalid-email", `emails.${name}`, `${name} is the invitation, and nothing fills ${values.map((value) => `{{${value}}}`).join(", ")}: ` +
|
|
1320
|
+
`use only ${BUILT_IN_EMAIL_VALUES.map((value) => `{{${value}}}`).join(", ")}.`);
|
|
1321
|
+
return undefined;
|
|
1322
|
+
}
|
|
1323
|
+
return wire;
|
|
1324
|
+
}
|
|
1272
1325
|
/**
|
|
1273
1326
|
* Where strangers may sign up and the wire names of the roles each open channel grants, and the
|
|
1274
1327
|
* `onSignUp` action. Every role must be a declared one other than `member`. A channel opened both
|
|
@@ -1390,10 +1443,10 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1390
1443
|
}
|
|
1391
1444
|
else {
|
|
1392
1445
|
options.origins.forEach((candidate, index) => {
|
|
1393
|
-
const origin =
|
|
1446
|
+
const origin = websiteOrigin(candidate);
|
|
1394
1447
|
const path = `signUp.origins[${index}]`;
|
|
1395
1448
|
if (origin === undefined) {
|
|
1396
|
-
report("invalid-sign-in", path,
|
|
1449
|
+
report("invalid-sign-in", path, WEBSITE_ORIGIN_HINT);
|
|
1397
1450
|
}
|
|
1398
1451
|
else if (origins.includes(origin)) {
|
|
1399
1452
|
report("invalid-sign-in", path, `${origin} is listed twice.`);
|
|
@@ -1410,6 +1463,12 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1410
1463
|
(Array.isArray(options.origins) && options.origins.length === 0))) {
|
|
1411
1464
|
report("invalid-sign-in", "signUp.origins", "Signing up on web needs the websites' origins in signUp.origins.");
|
|
1412
1465
|
}
|
|
1466
|
+
// @legacy ontology.sign-up-web
|
|
1467
|
+
if (channels.includes("web")) {
|
|
1468
|
+
report("invalid-sign-in", "signUp.channels", "web makes every visitor of the websites a user of the app, though nobody proved who they " +
|
|
1469
|
+
"are; declare guest, whose visitors talk to the agent as guests without a user, and " +
|
|
1470
|
+
"remove web from signUp.channels.", "warning");
|
|
1471
|
+
}
|
|
1413
1472
|
if (channels.length > 0 && roles !== undefined) {
|
|
1414
1473
|
result.signUp = {
|
|
1415
1474
|
channels: Object.fromEntries(channels.map((channel) => [channel, byChannel[channel] ?? roles])),
|
|
@@ -1418,6 +1477,160 @@ function signUpOptions(config, signIn, declaredRoles, report) {
|
|
|
1418
1477
|
}
|
|
1419
1478
|
return result;
|
|
1420
1479
|
}
|
|
1480
|
+
/** How `guest.origins` and `signUp.origins` take a website. */
|
|
1481
|
+
const WEBSITE_ORIGIN_HINT = "Use an origin alone, such as https://www.example.com, or a pattern whose leftmost label is *, " +
|
|
1482
|
+
"such as https://*.example.com, under a domain of at least two labels; http only for " +
|
|
1483
|
+
"localhost and 127.0.0.1.";
|
|
1484
|
+
/** The built-in `guest` roles `defineOntology({ guest })` made, as opposed to a declared one. */
|
|
1485
|
+
const BUILT_IN_GUESTS = new WeakSet();
|
|
1486
|
+
/** The guest keys `defineOntology({ guest })` takes. */
|
|
1487
|
+
const GUEST_KEYS = ["channels", "origins", "permissions"];
|
|
1488
|
+
/**
|
|
1489
|
+
* Where guests talk to the agent, and the built-in role `guest` with their permissions, when the
|
|
1490
|
+
* definition declares `guest`. Every problem is reported; the role is made from the permissions
|
|
1491
|
+
* as they are, for the permission checks to report on.
|
|
1492
|
+
*/
|
|
1493
|
+
function guestOptions(config, report) {
|
|
1494
|
+
const options = config.guest;
|
|
1495
|
+
if (options === undefined) {
|
|
1496
|
+
return undefined;
|
|
1497
|
+
}
|
|
1498
|
+
const shape = `guest takes { channels: ["web"], origins: ["https://www.example.com"], permissions: [...] }.`;
|
|
1499
|
+
if (!isPlainObject(options)) {
|
|
1500
|
+
report("invalid-sign-in", "guest", shape);
|
|
1501
|
+
return undefined;
|
|
1502
|
+
}
|
|
1503
|
+
for (const key of Object.keys(options)) {
|
|
1504
|
+
if (!GUEST_KEYS.includes(key)) {
|
|
1505
|
+
report("invalid-sign-in", `guest.${key}`, `Unknown guest key: ${key}. ${shape}`);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
const channels = [];
|
|
1509
|
+
if (!Array.isArray(options.channels) || options.channels.length === 0) {
|
|
1510
|
+
report("invalid-sign-in", "guest.channels", `List where guests talk to the agent: ${GUEST_CHANNELS.join(", ")}.`);
|
|
1511
|
+
}
|
|
1512
|
+
else {
|
|
1513
|
+
options.channels.forEach((channel, index) => {
|
|
1514
|
+
const path = `guest.channels[${index}]`;
|
|
1515
|
+
if (!isGuestChannel(channel)) {
|
|
1516
|
+
report("invalid-sign-in", path, `Guests talk to the agent only on ${GUEST_CHANNELS.join(", ")}, not ${String(channel)}.`);
|
|
1517
|
+
}
|
|
1518
|
+
else if (channels.includes(channel)) {
|
|
1519
|
+
report("invalid-sign-in", path, `${channel} is listed twice.`);
|
|
1520
|
+
}
|
|
1521
|
+
else {
|
|
1522
|
+
channels.push(channel);
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
const origins = [];
|
|
1527
|
+
if (!Array.isArray(options.origins) || options.origins.length === 0) {
|
|
1528
|
+
report("invalid-sign-in", "guest.origins", "List the websites whose visitors are guests, such as https://www.example.com.");
|
|
1529
|
+
}
|
|
1530
|
+
else {
|
|
1531
|
+
options.origins.forEach((candidate, index) => {
|
|
1532
|
+
const origin = websiteOrigin(candidate);
|
|
1533
|
+
const path = `guest.origins[${index}]`;
|
|
1534
|
+
if (origin === undefined) {
|
|
1535
|
+
report("invalid-sign-in", path, WEBSITE_ORIGIN_HINT);
|
|
1536
|
+
}
|
|
1537
|
+
else if (origins.includes(origin)) {
|
|
1538
|
+
report("invalid-sign-in", path, `${origin} is listed twice.`);
|
|
1539
|
+
}
|
|
1540
|
+
else {
|
|
1541
|
+
origins.push(origin);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
if (!Array.isArray(options.permissions)) {
|
|
1546
|
+
report("missing-permissions", "guest.permissions", 'List what every guest may do, such as permissions: ["lead:submit"]; [] grants nothing.');
|
|
1547
|
+
}
|
|
1548
|
+
const guest = role(GUEST_ROLE, {
|
|
1549
|
+
description: "Every guest: a visitor of a declared website, who is no user.",
|
|
1550
|
+
permissions: Array.isArray(options.permissions)
|
|
1551
|
+
? options.permissions
|
|
1552
|
+
: [],
|
|
1553
|
+
});
|
|
1554
|
+
BUILT_IN_GUESTS.add(guest);
|
|
1555
|
+
return { resolved: { channels, origins }, role: guest };
|
|
1556
|
+
}
|
|
1557
|
+
/** Whether a scope's `where` names `me` or a path from it anywhere. */
|
|
1558
|
+
function usesMe(value) {
|
|
1559
|
+
if (mePathOf(value) !== undefined) {
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
if (Array.isArray(value)) {
|
|
1563
|
+
return value.some(usesMe);
|
|
1564
|
+
}
|
|
1565
|
+
return isPlainObject(value) && Object.values(value).some(usesMe);
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* The guests' permissions admit anyone who opens a declared website, so they are held to at least
|
|
1569
|
+
* the rules of sign-up roles: no entity wildcard, and no generated create, update, delete, link or
|
|
1570
|
+
* unlink on every record; an unscoped read of a stored entity is warned about. A guest is no user,
|
|
1571
|
+
* so a scope naming `me` would match nothing, and the built-in entities, which concern members,
|
|
1572
|
+
* are not a guest's to use. Of the agent's own tools a guest may hold `agent_tool:web`, never the
|
|
1573
|
+
* sandbox.
|
|
1574
|
+
*/
|
|
1575
|
+
function checkGuestPermissions(input) {
|
|
1576
|
+
const { entities, guest, report } = input;
|
|
1577
|
+
const permissions = guest.permissions;
|
|
1578
|
+
const path = "guest.permissions";
|
|
1579
|
+
if (!Array.isArray(permissions)) {
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
const scoped = new Set((guest.scopes ?? []).map((scope) => scope.permission));
|
|
1583
|
+
const hint = "Scope it to the records guests may change, or grant an action that checks them.";
|
|
1584
|
+
(guest.scopes ?? []).forEach((scope, index) => {
|
|
1585
|
+
if (usesMe(scope.where)) {
|
|
1586
|
+
report("invalid-scope", `guest.scopes[${index}]`, `A guest is no user, so me in the scope of ${scope.permission} matches nothing; ` +
|
|
1587
|
+
"scope it by the records' own fields.");
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
for (const permission of permissions) {
|
|
1591
|
+
const parsed = parsePermission(permission);
|
|
1592
|
+
if (parsed === undefined) {
|
|
1593
|
+
continue;
|
|
1594
|
+
}
|
|
1595
|
+
if (parsed.entity === WILDCARD) {
|
|
1596
|
+
report("invalid-sign-in", path, `Guests cannot hold ${String(permission)}; name the entities they may use.`);
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
// A guest may read the agent's listed websites, never run its sandbox: the sandbox reads the
|
|
1600
|
+
// records and files of whoever it acts for, and anyone opening the website is a guest.
|
|
1601
|
+
if (parsed.entity === AGENT_TOOL && (parsed.verb === "sandbox" || parsed.verb === WILDCARD)) {
|
|
1602
|
+
report("invalid-sign-in", path, `Guests cannot hold ${String(permission)}: the agent's sandbox is never a guest's. Name ` +
|
|
1603
|
+
`${AGENT_TOOL}:web alone for the agent to read the websites web.domains lists for them.`);
|
|
1604
|
+
continue;
|
|
1605
|
+
}
|
|
1606
|
+
const entity = entities.find((resolved) => resolved.name === parsed.entity);
|
|
1607
|
+
if (entity === undefined) {
|
|
1608
|
+
continue;
|
|
1609
|
+
}
|
|
1610
|
+
if (entity.builtIn) {
|
|
1611
|
+
report("invalid-sign-in", path, `Guests cannot hold ${String(permission)}: ${entity.name} concerns the app's users, and a ` +
|
|
1612
|
+
"guest is none.");
|
|
1613
|
+
continue;
|
|
1614
|
+
}
|
|
1615
|
+
if (scoped.has(String(permission))) {
|
|
1616
|
+
continue;
|
|
1617
|
+
}
|
|
1618
|
+
const generatedWrite = [
|
|
1619
|
+
entity.permissions.create,
|
|
1620
|
+
entity.permissions.update,
|
|
1621
|
+
entity.permissions.delete,
|
|
1622
|
+
entity.permissions.link,
|
|
1623
|
+
entity.permissions.unlink,
|
|
1624
|
+
].some((required) => required !== undefined && isAllowed(required, { permissions: [String(permission)] }));
|
|
1625
|
+
if (generatedWrite) {
|
|
1626
|
+
report("invalid-sign-in", path, `Guests cannot hold ${String(permission)} on every record. ${hint}`);
|
|
1627
|
+
}
|
|
1628
|
+
else if (isAllowed(entity.permissions.read, { permissions: [String(permission)] })) {
|
|
1629
|
+
report("invalid-sign-in", path, `${String(permission)} lets every visitor of the guests' websites read every ` +
|
|
1630
|
+
`${entity.name}. Review it, or scope it to the records guests may read.`, "warning");
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1421
1634
|
/**
|
|
1422
1635
|
* The roles sign-up grants admit strangers. Each must be explicitly reviewed: no entity wildcard,
|
|
1423
1636
|
* and no generated create, update, delete, link or unlink that is not scoped to the person's own
|
|
@@ -1510,6 +1723,11 @@ function collectRoles(config, report) {
|
|
|
1510
1723
|
report("reserved-name", path, `${candidate.name} is a reserved built-in role.`);
|
|
1511
1724
|
return;
|
|
1512
1725
|
}
|
|
1726
|
+
// A role of this name stays the workspace's own until the ontology declares guests.
|
|
1727
|
+
if (candidate.name === GUEST_ROLE && config.guest !== undefined) {
|
|
1728
|
+
report("reserved-name", path, "guest is the built-in role of guests once the ontology declares guest; rename this role.");
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1513
1731
|
if (roles.some((existing) => existing.name === candidate.name)) {
|
|
1514
1732
|
report("duplicate-name", path, `role "${candidate.name}" is declared twice.`);
|
|
1515
1733
|
return;
|
|
@@ -1547,6 +1765,10 @@ function resolveEntity(candidate, scope, resolvedProperties) {
|
|
|
1547
1765
|
report("reserved-name", name, `${WORKSPACE_SOURCE} names the built-in permission ${WORKSPACE_SOURCE_PERMISSION}, which ` +
|
|
1548
1766
|
"reads the workspace's code; choose another entity name.");
|
|
1549
1767
|
}
|
|
1768
|
+
else if (name === AGENT_TOOL) {
|
|
1769
|
+
report("reserved-name", name, `${AGENT_TOOL} names the built-in permissions ${agentToolPermissions()}, which grant the ` +
|
|
1770
|
+
"agent's own tools; choose another entity name.");
|
|
1771
|
+
}
|
|
1550
1772
|
else if (APP_FEEDBACK_ENTITIES.some((feedback) => feedback.name === name) &&
|
|
1551
1773
|
!scope.builtIns.has(definition)) {
|
|
1552
1774
|
report("reserved-name", name, `${name} is the SDK's app feedback; configure feedback on defineOntology ` +
|
|
@@ -2284,7 +2506,7 @@ function ownMembers(candidate, entitiesByName) {
|
|
|
2284
2506
|
* The verbs each entity has: `read`, its generated actions, and what its actions require. The
|
|
2285
2507
|
* built-in user also has its member management verbs, and the built-in sign-in identities their
|
|
2286
2508
|
* attach and revoke, which roles may grant. The built-in `workspace_source`, which is no entity,
|
|
2287
|
-
* has `read` only.
|
|
2509
|
+
* has `read` only, and the built-in `agent_tool`, no entity either, the agent's own tools.
|
|
2288
2510
|
*/
|
|
2289
2511
|
function knownVerbs(entities, toolsets = []) {
|
|
2290
2512
|
const verbs = new Map();
|
|
@@ -2322,8 +2544,13 @@ function knownVerbs(entities, toolsets = []) {
|
|
|
2322
2544
|
}
|
|
2323
2545
|
// Last, so that an entity or a toolset of the name, which check refuses, adds no verb to it.
|
|
2324
2546
|
verbs.set(WORKSPACE_SOURCE, new Set([READ_VERB]));
|
|
2547
|
+
verbs.set(AGENT_TOOL, new Set(AGENT_TOOL_VERBS));
|
|
2325
2548
|
return verbs;
|
|
2326
2549
|
}
|
|
2550
|
+
/** `agent_tool:sandbox and agent_tool:web`, for messages. */
|
|
2551
|
+
function agentToolPermissions() {
|
|
2552
|
+
return listed(AGENT_TOOL_VERBS.map((tool) => `${AGENT_TOOL}:${tool}`));
|
|
2553
|
+
}
|
|
2327
2554
|
/** Why a role's permission matches nothing in the ontology, or `undefined` when it matches. */
|
|
2328
2555
|
function unknownPermission(value, { entity, verb }, verbs) {
|
|
2329
2556
|
if (entity === WILDCARD) {
|
|
@@ -2384,15 +2611,16 @@ function listed(names) {
|
|
|
2384
2611
|
return names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
2385
2612
|
}
|
|
2386
2613
|
function checkRolePermissions(candidate, verbs, workflows, report) {
|
|
2387
|
-
const builtIn = candidate.name === MEMBER_ROLE;
|
|
2388
|
-
const path = builtIn ?
|
|
2614
|
+
const builtIn = candidate.name === MEMBER_ROLE || BUILT_IN_GUESTS.has(candidate);
|
|
2615
|
+
const path = builtIn ? `${candidate.name}.permissions` : `roles.${candidate.name}.permissions`;
|
|
2389
2616
|
const permissions = candidate.permissions;
|
|
2390
2617
|
if (!Array.isArray(permissions)) {
|
|
2391
2618
|
report("missing-permissions", path, "list what the role may do as <entity>:<verb> permissions, such as " +
|
|
2392
2619
|
'permissions: ["lead:read"].');
|
|
2393
2620
|
return;
|
|
2394
2621
|
}
|
|
2395
|
-
// An empty member list is a choice: members then hold only the roles they are given.
|
|
2622
|
+
// An empty member list is a choice: members then hold only the roles they are given. An empty
|
|
2623
|
+
// guest list lets guests talk to the agent and do nothing more.
|
|
2396
2624
|
if (permissions.length === 0 && !builtIn) {
|
|
2397
2625
|
report("missing-permissions", path, "a role without permissions can do nothing; list at least one, such as lead:read.");
|
|
2398
2626
|
}
|
|
@@ -2519,6 +2747,25 @@ function checkNewUserAction(input) {
|
|
|
2519
2747
|
fail("onNewUser cannot prepare or use external connections.");
|
|
2520
2748
|
}
|
|
2521
2749
|
}
|
|
2750
|
+
// @legacy ontology.implicit-agent-sandbox
|
|
2751
|
+
/** The day an ontology whose roles name no agent tool stops giving every caller the sandbox. */
|
|
2752
|
+
const IMPLICIT_AGENT_SANDBOX_ENDS = "2027-02-15";
|
|
2753
|
+
// @legacy ontology.implicit-agent-sandbox
|
|
2754
|
+
/**
|
|
2755
|
+
* While no role names an agent tool, the ontology tells the agent that every caller has the
|
|
2756
|
+
* sandbox, as before agent tools were permissions: people `signUp` admits included. Builders learn
|
|
2757
|
+
* here to grant the tools to the roles that should have them.
|
|
2758
|
+
*/
|
|
2759
|
+
function checkAgentToolGrants(roles, report) {
|
|
2760
|
+
if (namesAgentTools(roles)) {
|
|
2761
|
+
return;
|
|
2762
|
+
}
|
|
2763
|
+
const named = [...AGENT_TOOL_VERBS.map((tool) => `${AGENT_TOOL}:${tool}`), `${AGENT_TOOL}:*`];
|
|
2764
|
+
report("agent-tools-implicit", "roles", `no role names an ${AGENT_TOOL} permission, so the agent gives everyone it acts for, people ` +
|
|
2765
|
+
`who sign up included, its sandbox tools. From ${IMPLICIT_AGENT_SANDBOX_ENDS} only roles ` +
|
|
2766
|
+
`grant the agent's own tools: name ${named.slice(0, -1).join(", ")} or ${named.at(-1)} in ` +
|
|
2767
|
+
"the roles that may use them, such as member's permissions.", "warning");
|
|
2768
|
+
}
|
|
2522
2769
|
/** The member management verbs that act on members a page or an agent must first find. */
|
|
2523
2770
|
const ROSTER_VERBS = ["invite", "grant_roles"];
|
|
2524
2771
|
/**
|
|
@@ -2842,6 +3089,11 @@ function checkScope(input) {
|
|
|
2842
3089
|
`${WORKSPACE_SOURCE_PERMISSION} as a string in the roles that may read the code.`);
|
|
2843
3090
|
return;
|
|
2844
3091
|
}
|
|
3092
|
+
if (parsed.entity === AGENT_TOOL && verbs.get(AGENT_TOOL)?.has(parsed.verb) === true) {
|
|
3093
|
+
report("invalid-scope", path, `${permission} grants one of the agent's own tools, which has no records to scope; list ` +
|
|
3094
|
+
`${permission} as a string in the roles that may use it.`);
|
|
3095
|
+
return;
|
|
3096
|
+
}
|
|
2845
3097
|
const entity = entities.find((candidate) => candidate.name === parsed.entity);
|
|
2846
3098
|
if (entity === undefined && verbs.get(parsed.entity)?.has(parsed.verb) === true) {
|
|
2847
3099
|
report("invalid-scope", path, `${parsed.entity} is a toolset, which has no records to scope; list ${permission} as a ` +
|
|
@@ -2928,7 +3180,9 @@ function checkScopes(entities, roles, verbs, report) {
|
|
|
2928
3180
|
};
|
|
2929
3181
|
for (const candidate of roles) {
|
|
2930
3182
|
const scopes = Array.isArray(candidate.scopes) ? candidate.scopes : [];
|
|
2931
|
-
const base = candidate.name === MEMBER_ROLE
|
|
3183
|
+
const base = candidate.name === MEMBER_ROLE || BUILT_IN_GUESTS.has(candidate)
|
|
3184
|
+
? candidate.name
|
|
3185
|
+
: `roles.${candidate.name}`;
|
|
2932
3186
|
const unscoped = unscopedPermissions(candidate);
|
|
2933
3187
|
const unused = (permission, grant, by, path) => report("scope-unused", path, `${candidate.name} scopes ${permission}, but ${by} grants it on every record through ` +
|
|
2934
3188
|
`${grant}, so the scope never applies; remove ${grant} from ${by}, or the scoped entry ` +
|
|
@@ -2944,7 +3198,8 @@ function checkScopes(entities, roles, verbs, report) {
|
|
|
2944
3198
|
if (parsed !== undefined && parsed.entity !== WILDCARD && parsed.verb !== WILDCARD) {
|
|
2945
3199
|
const permission = scope.permission;
|
|
2946
3200
|
const own = unscoped.find((granted) => grants(granted, permission));
|
|
2947
|
-
|
|
3201
|
+
// A guest never holds member.
|
|
3202
|
+
const fromMember = candidate.name === MEMBER_ROLE || BUILT_IN_GUESTS.has(candidate)
|
|
2948
3203
|
? undefined
|
|
2949
3204
|
: memberGrants.find((granted) => grants(granted, permission));
|
|
2950
3205
|
if (own !== undefined) {
|
package/dist/authoring.js
CHANGED
|
@@ -330,5 +330,11 @@ export function authoringToWire(config, builtIns, report) {
|
|
|
330
330
|
permissions: config.member.permissions.map((permission) => encoder.permission(permission)),
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
+
if (isRecord(config.guest) && Array.isArray(config.guest.permissions)) {
|
|
334
|
+
normalized.guest = {
|
|
335
|
+
...config.guest,
|
|
336
|
+
permissions: config.guest.permissions.map((permission) => encoder.permission(permission)),
|
|
337
|
+
};
|
|
338
|
+
}
|
|
333
339
|
return { config: normalized, builtIns: builtIns.map((entity) => encoder.entity(entity)) };
|
|
334
340
|
}
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
export declare const DIAGNOSTIC_CODES: readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"];
|
|
2
|
+
export declare const DIAGNOSTIC_CODES: readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "agent-tools-implicit", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"];
|
|
3
3
|
export type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
|
|
4
4
|
/** A problem `check` found in an ontology definition. */
|
|
5
5
|
export declare const Diagnostic: Schema.Struct<{
|
|
6
6
|
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
7
|
-
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
7
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "agent-tools-implicit", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
8
8
|
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
9
9
|
readonly path: Schema.String;
|
|
10
10
|
readonly message: Schema.String;
|
|
@@ -14,7 +14,7 @@ declare const InvalidOntology_base: Schema.Class<InvalidOntology, Schema.TaggedS
|
|
|
14
14
|
readonly message: Schema.String;
|
|
15
15
|
readonly diagnostics: Schema.$Array<Schema.Struct<{
|
|
16
16
|
readonly severity: Schema.Literals<readonly ["error", "warning", "info"]>;
|
|
17
|
-
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
17
|
+
readonly code: Schema.Literals<readonly ["invalid-source", "missing-column", "invalid-column", "invalid-scope", "invalid-scope-path", "scope-reads-all", "scope-unused", "scope-member-overlap", "source-with-actions", "source-with-index", "invalid-metric", "unknown-metric", "circular-metric", "invalid-join", "missing-join", "invalid-entity", "invalid-property", "invalid-relationship", "invalid-actions", "invalid-action", "invalid-action-input", "invalid-role", "invalid-name", "reserved-name", "duplicate-name", "invalid-entity-id", "duplicate-entity-id", "missing-label", "missing-description", "invalid-title", "invalid-options", "invalid-default", "invalid-constraint", "unknown-relationship-target", "inverse-collision", "invalid-on-delete", "invalid-phrase", "invalid-index", "unknown-reference", "invalid-renamed-from", "earlier-name", "invalid-guide", "invalid-writes", "generated-update-empty", "managed-without-effect", "missing-permissions", "invalid-permission", "unknown-permission", "removed-allow", "unreachable-action", "wildcard-permission", "invalid-sign-in", "invalid-connection", "invalid-feedback", "invalid-discovery", "invalid-email", "feedback-unanswerable", "agent-tools-implicit", "unknown-connection", "unused-connection", "invalid-prepare", "invalid-tool-name", "invalid-toolset", "toolset-lock-mismatch", "invalid-alignment", "single-entity-model-metric", "invalid-workflow", "workflow_role_unknown", "workflow_role_is_member", "workflow_role_grants_nothing", "workflow_role_wildcard", "workflow_role_scoped", "workflow_cron_never_fires", "workflow_input_invalid", "workflow_cron_invalid", "workflow_run_missing", "invalid-trigger", "trigger_action_unknown", "trigger_function_async", "workflow_trigger_limit_exceeded", "workflow_webhook_duplicate", "workflow_webhook_input_invalid", "workflow_webhook_mixed_triggers", "workflow_webhook_signature_invalid", "workflow_webhook_verification_invalid", "workflow_webhook_headers_invalid", "workflow_webhook_limit_exceeded"]>;
|
|
18
18
|
/** Where the problem is, for example `lead.properties.status.options[1]`. */
|
|
19
19
|
readonly path: Schema.String;
|
|
20
20
|
readonly message: Schema.String;
|
package/dist/diagnostics.js
CHANGED
package/dist/emails.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Diagnostic } from "./diagnostics.js";
|
|
2
2
|
/**
|
|
3
3
|
* An email the workspace writes and the platform sends with a sign-in link, named by
|
|
4
|
-
* `User.sendSignInLink`. Every field is plain text, in which
|
|
5
|
-
* action passes, and `{{member.name}}`, `{{member.firstName}}
|
|
6
|
-
*
|
|
4
|
+
* `User.sendSignInLink` or by `signIn.invitationEmail`. Every field is plain text, in which
|
|
5
|
+
* `{{name}}` stands for a value the action passes, and `{{member.name}}`, `{{member.firstName}}`,
|
|
6
|
+
* `{{workspace.name}}`, `{{app.url}}` and `{{app.mcpUrl}}` for the recipient, the workspace, the
|
|
7
|
+
* app's address and its MCP server's. The platform lays the fields out, escapes them and adds the
|
|
7
8
|
* plain-text part; `action` labels the one button, which signs the person in and opens the path
|
|
8
9
|
* the action names. A field whose text is empty once filled in is left out.
|
|
9
10
|
*/
|
|
@@ -22,6 +23,8 @@ export interface EmailTemplate {
|
|
|
22
23
|
readonly paragraphs?: ReadonlyArray<string>;
|
|
23
24
|
/** The button's label. */
|
|
24
25
|
readonly action: string;
|
|
26
|
+
/** Boxes below the button, such as how to connect an AI assistant to the app. */
|
|
27
|
+
readonly sections?: ReadonlyArray<EmailSection>;
|
|
25
28
|
/** Small print at the bottom, such as why the person received the email. */
|
|
26
29
|
readonly footer?: string;
|
|
27
30
|
/**
|
|
@@ -31,8 +34,32 @@ export interface EmailTemplate {
|
|
|
31
34
|
*/
|
|
32
35
|
readonly replyTo?: string;
|
|
33
36
|
}
|
|
34
|
-
/**
|
|
35
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A box below an email's button: a title, a line of text, a value to copy shown large in a
|
|
39
|
+
* monospace box, such as an address, labelled items with text or a command, and a closing note.
|
|
40
|
+
*/
|
|
41
|
+
export interface EmailSection {
|
|
42
|
+
readonly title: string;
|
|
43
|
+
readonly text?: string;
|
|
44
|
+
/** A value the person copies into another app, such as an address. */
|
|
45
|
+
readonly copy?: {
|
|
46
|
+
readonly label?: string;
|
|
47
|
+
readonly value: string;
|
|
48
|
+
};
|
|
49
|
+
/** Labelled items, such as one per app: text, a command shown in a monospace box, or both. */
|
|
50
|
+
readonly items?: ReadonlyArray<EmailSectionItem>;
|
|
51
|
+
readonly note?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface EmailSectionItem {
|
|
54
|
+
readonly label: string;
|
|
55
|
+
readonly text?: string;
|
|
56
|
+
readonly code?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The values every email may use besides those the action passes: the recipient, the workspace,
|
|
60
|
+
* the app's production address and its MCP server's address, `/mcp` on the same domain.
|
|
61
|
+
*/
|
|
62
|
+
export declare const BUILT_IN_EMAIL_VALUES: readonly ["member.name", "member.firstName", "workspace.name", "app.url", "app.mcpUrl"];
|
|
36
63
|
/**
|
|
37
64
|
* The query parameter of the callback a sign-in link is requested with, naming the queued email it
|
|
38
65
|
* delivers. The platform reads it from Neon Auth's link and leaves it out of the path the person
|
|
@@ -51,6 +78,10 @@ export declare const MAX_EMAIL_PARAGRAPHS = 20;
|
|
|
51
78
|
export declare const MAX_EMAIL_VALUES = 50;
|
|
52
79
|
/** The longest path a sign-in link returns to. */
|
|
53
80
|
export declare const MAX_RETURN_PATH = 1024;
|
|
81
|
+
/** The most sections of one email. */
|
|
82
|
+
export declare const MAX_EMAIL_SECTIONS = 5;
|
|
83
|
+
/** The most items of one section. */
|
|
84
|
+
export declare const MAX_EMAIL_SECTION_ITEMS = 10;
|
|
54
85
|
type Report = (code: Diagnostic["code"], path: string, message: string, severity?: Diagnostic["severity"]) => void;
|
|
55
86
|
/** The values an action must pass for this email: its placeholders that are not built in. */
|
|
56
87
|
export declare function emailValueNames(template: EmailTemplate): ReadonlyArray<string>;
|