@segmentstream/ontology 0.172.0 → 0.174.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.174.0
4
+
5
+ Enroll verified SegmentStream browser accounts with workspace-defined roles independently of email sign-up.
6
+
7
+ ## 0.173.0
8
+
9
+ An ontology may declare 50 action triggers (`after(…)`), up from 20: as many as the workflows it may
10
+ declare. `MAX_ACTION_TRIGGERS` is 50, and `check` and publication report
11
+ `workflow_trigger_limit_exceeded` above it. Each trigger still adds its work to every action on its
12
+ entity, inside that action's transaction.
13
+
3
14
  ## 0.172.0
4
15
 
5
16
  Route the agent's persona by chat assignment, channel rules and workspace default.
package/README.md CHANGED
@@ -627,7 +627,7 @@ export default workflow("remindStaleLeads", {
627
627
  (`{ record, before, after }`, typed as the entity's records); `input` omitted means `{}`.
628
628
  `changed(field, { from?, to? })` is a `when` for the common case. A workflow reacts to an action,
629
629
  not to a field. The manifest records the kind, name, description, entity and action, never the
630
- functions. At most 20 action triggers per ontology; `check` reports `invalid-trigger`,
630
+ functions. At most 50 action triggers per ontology; `check` reports `invalid-trigger`,
631
631
  `trigger_action_unknown`, `trigger_function_async` and `workflow_trigger_limit_exceeded`.
632
632
  - `webhook(name, { description, signature?, headers? })` starts the workflow for each delivery a
633
633
  provider pushes to `/api/webhooks/<name>`, whose wire name is unique across the ontology. The
package/dist/analyze.js CHANGED
@@ -1801,6 +1801,9 @@ function signUpOptions(config, signIn, declaredRoles, report) {
1801
1801
  ? 'email is opened by signIn.policy "open" too; declare it in signUp only.'
1802
1802
  : `${channel} is opened by signIn.channels too; declare it in signUp only.`);
1803
1803
  }
1804
+ if (channel === "segmentstream" && !signIn.browser?.methods.includes("segmentstream")) {
1805
+ report("invalid-sign-in", "signUp.channels", "SegmentStream sign-up requires the segmentstream browser sign-in method.");
1806
+ }
1804
1807
  if (SIGN_UP_CHAT_CHANNELS.includes(channel)) {
1805
1808
  if (!declaresChatKind(config.chat, channel)) {
1806
1809
  report("invalid-sign-in", `signUp.channels`, `Signing up on ${channel} needs a matching chat.${channel} adapter.`);
@@ -381,8 +381,13 @@ function signIn(ontology, sql, claims) {
381
381
  yield* recordIdentity(String(invited.id), "invite");
382
382
  return userRow(linkedUser);
383
383
  }
384
- // `signUp` with `email` creates a user holding its roles; `policy: "open"` one holding member.
385
- const signUpRoles = signUpRolesOf(ontology.manifest, "email");
384
+ // A verified browser federation account can enroll through its own channel. Older
385
+ // workspaces without that declaration keep their existing email enrollment behavior.
386
+ const cloudRoles = account.provider === OIDC_PROVIDER && email !== undefined
387
+ ? signUpRolesOf(ontology.manifest, "segmentstream")
388
+ : undefined;
389
+ const channel = cloudRoles === undefined ? "email" : "segmentstream";
390
+ const signUpRoles = cloudRoles ?? signUpRolesOf(ontology.manifest, "email");
386
391
  // @legacy ontology.legacy-channel-admission
387
392
  if (signUpRoles === undefined && ontology.signIn.policy !== "open") {
388
393
  return yield* new PrincipalRejected({
@@ -398,7 +403,7 @@ function signIn(ontology, sql, claims) {
398
403
  identity_subject: claims.identitySubject,
399
404
  ...signedIn,
400
405
  });
401
- yield* recordUserCreation(sql, String(created.id), "email", signUpRoles !== undefined);
406
+ yield* recordUserCreation(sql, String(created.id), channel, signUpRoles !== undefined);
402
407
  if (signUpRoles !== undefined && signUpRoles.length > 0) {
403
408
  yield* platformRuntime(ontology, sql, MEMBER_HISTORY_ACTIONS.grantRoles)
404
409
  .members.grantRoles({ id: String(created.id), roles: signUpRoles })
package/dist/sign-in.d.ts CHANGED
@@ -17,7 +17,7 @@ export type ChannelProvider = (typeof CHANNEL_PROVIDERS)[number];
17
17
  * `guest` supersedes; the others are a first private message to the agent, or opening the
18
18
  * Telegram Mini App.
19
19
  */
20
- export declare const SIGN_UP_CHANNELS: readonly ["email", "telegram", "whatsapp", "web"];
20
+ export declare const SIGN_UP_CHANNELS: readonly ["email", "segmentstream", "telegram", "whatsapp", "web"];
21
21
  /**
22
22
  * The people of a channel the workspace defines in its own code, `channel:<name>`, such as
23
23
  * `channel:helpdesk`: the accounts they write from there, which are that channel's alone.
package/dist/sign-in.js CHANGED
@@ -16,7 +16,7 @@ export const CHANNEL_PROVIDERS = ["telegram"];
16
16
  * `guest` supersedes; the others are a first private message to the agent, or opening the
17
17
  * Telegram Mini App.
18
18
  */
19
- export const SIGN_UP_CHANNELS = ["email", "telegram", "whatsapp", "web"];
19
+ export const SIGN_UP_CHANNELS = ["email", "segmentstream", "telegram", "whatsapp", "web"];
20
20
  /** The sign-up channels a person reaches through a chat, which need a matching `chat` adapter. */
21
21
  export const SIGN_UP_CHAT_CHANNELS = ["telegram", "whatsapp"];
22
22
  export function isSignUpChannel(value) {
@@ -11,8 +11,14 @@ export declare const WorkflowTypeId: unique symbol;
11
11
  export declare const WorkflowTriggerTypeId: unique symbol;
12
12
  /** The most workflows one ontology may declare. */
13
13
  export declare const MAX_WORKFLOWS = 50;
14
- /** The most action triggers, `after(…)`, one ontology may declare across its workflows. */
15
- export declare const MAX_ACTION_TRIGGERS = 20;
14
+ /**
15
+ * The most action triggers, `after(…)`, one ontology may declare across its workflows. Every
16
+ * action evaluates the triggers on its entity inside its own transaction, so this bounds the work
17
+ * one action can add: about 4 to 6 ms per trigger for a batch create of 100 records, nothing
18
+ * measurable for a single update. It does not bound the runs a bulk action starts, one per edited
19
+ * record. As many as the workflows an ontology may declare.
20
+ */
21
+ export declare const MAX_ACTION_TRIGGERS = 50;
16
22
  /**
17
23
  * What a trigger listed in `defineOntology({ triggers })` runs instead of a workflow: one action,
18
24
  * in a durable run retried like a step, as the trigger's own workflow user holding `role`. The
package/dist/workflow.js CHANGED
@@ -5,8 +5,14 @@ export const WorkflowTypeId = Symbol.for("@segmentstream/ontology/Workflow");
5
5
  export const WorkflowTriggerTypeId = Symbol.for("@segmentstream/ontology/WorkflowTrigger");
6
6
  /** The most workflows one ontology may declare. */
7
7
  export const MAX_WORKFLOWS = 50;
8
- /** The most action triggers, `after(…)`, one ontology may declare across its workflows. */
9
- export const MAX_ACTION_TRIGGERS = 20;
8
+ /**
9
+ * The most action triggers, `after(…)`, one ontology may declare across its workflows. Every
10
+ * action evaluates the triggers on its entity inside its own transaction, so this bounds the work
11
+ * one action can add: about 4 to 6 ms per trigger for a batch create of 100 records, nothing
12
+ * measurable for a single update. It does not bound the runs a bulk action starts, one per edited
13
+ * record. As many as the workflows an ontology may declare.
14
+ */
15
+ export const MAX_ACTION_TRIGGERS = 50;
10
16
  /** Declares a cron trigger; list it in `workflow(name, { triggers })`. UTC, five fields. */
11
17
  export function cron(name, expression, options) {
12
18
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.172.0",
3
+ "version": "0.174.0",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",