@opencxh/domain 1.170.0 → 1.172.1

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.
Files changed (41) hide show
  1. package/dist/entities/ai-budget/types.d.ts +7 -3
  2. package/dist/entities/ai-profile/types.d.ts +7 -5
  3. package/dist/entities/analytics/dashboard.d.ts +1 -1
  4. package/dist/entities/artifact/types.d.ts +1 -1
  5. package/dist/entities/calendar-event/types.d.ts +1 -1
  6. package/dist/entities/communication/message-template.d.ts +1 -1
  7. package/dist/entities/company/types.d.ts +1 -1
  8. package/dist/entities/contact/provider.d.ts +2 -1
  9. package/dist/entities/contact/types.d.ts +1 -10
  10. package/dist/entities/live-lens/types.d.ts +1 -1
  11. package/dist/entities/memory/ingest.d.ts +14 -1
  12. package/dist/entities/memory/kind.d.ts +1 -1
  13. package/dist/entities/playbook/actor.d.ts +3 -2
  14. package/dist/entities/playbook/types.d.ts +1 -1
  15. package/dist/entities/scope/actor.d.ts +16 -0
  16. package/dist/entities/{note → scope}/index.d.ts +1 -0
  17. package/dist/entities/scope/scope.test.d.ts +1 -0
  18. package/dist/entities/scope/types.d.ts +53 -0
  19. package/dist/entities/task/types.d.ts +1 -1
  20. package/dist/entities/time-entry/types.d.ts +1 -1
  21. package/dist/entities/topic/types.d.ts +7 -5
  22. package/dist/entities/work/types.d.ts +1 -1
  23. package/dist/index.cjs +6 -6
  24. package/dist/index.d.ts +2 -6
  25. package/dist/index.js +493 -473
  26. package/dist/platform/api.d.ts +3 -1
  27. package/dist/platform/call-lines.d.ts +74 -0
  28. package/dist/platform/call-lines.test.d.ts +1 -0
  29. package/dist/platform/communication.d.ts +16 -0
  30. package/dist/platform/provider.d.ts +0 -61
  31. package/dist/platform/scope.d.ts +1 -1
  32. package/dist/platform/settings.d.ts +0 -14
  33. package/dist/platform/storage.d.ts +1 -1
  34. package/package.json +1 -4
  35. package/dist/entities/note/types.d.ts +0 -14
  36. package/dist/entities/shopify/index.d.ts +0 -1
  37. package/dist/entities/shopify/types.d.ts +0 -79
  38. package/dist/platform/lifecycle.d.ts +0 -13
  39. package/dist/platform/reactive.d.ts +0 -13
  40. package/dist/platform/sdk.d.ts +0 -172
  41. package/dist/platform/service-registry.d.ts +0 -13
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  /**
3
3
  * A ceiling on what may be spent on AI in one period.
4
4
  *
@@ -18,8 +18,12 @@ export interface AiBudget {
18
18
  * tenant, including the ones attributed to nobody (kb indexing, transcription,
19
19
  * playbooks running as the organisation). That unattributed spend is real and
20
20
  * it has to land somewhere.
21
+ *
22
+ * Named `ownerScope` like every other scoped entity. It was `scope` — the one
23
+ * deviation from the platform's convention, where `scope` is reserved for OAuth
24
+ * scopes, an unrelated concept that happens to share the word.
21
25
  */
22
- scope: OwnerScope;
26
+ ownerScope: OwnerScope;
23
27
  /**
24
28
  * Warn here. Absent = never warn, only block. Both absent is allowed and means
25
29
  * the budget does nothing — the UI says so rather than pretending it is armed.
@@ -57,7 +61,7 @@ export type AiBudgetClearable = "softLimitNanos" | "hardLimitNanos";
57
61
  * what an ambiguous sentinel (`0`? that is a real limit) never could.
58
62
  */
59
63
  export interface AiBudgetInput {
60
- scope?: OwnerScope;
64
+ ownerScope?: OwnerScope;
61
65
  softLimitNanos?: number;
62
66
  hardLimitNanos?: number;
63
67
  period?: AiBudgetPeriod;
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OrgTeamScope } from '../scope/types';
2
2
  export interface PredefinedPrompt {
3
3
  name: string;
4
4
  prompt: string;
@@ -7,11 +7,13 @@ export interface AIProfile<T extends Record<string, any> = Record<string, any>>
7
7
  id: string;
8
8
  organizationId: string;
9
9
  /**
10
- * Who may use this profile. Company-wide (`org`) or bound to a `team`; profiles
11
- * are never personal. The server resolves one on create (`normalizeProfileScope`),
12
- * so it is always present.
10
+ * Who may use this profile. Company-wide (`org`) or bound to a `team`; profiles are
11
+ * never personal. The server resolves one on create (`normalizeProfileScope`), so it is
12
+ * always present.
13
+ *
14
+ * "Never personal" was prose while the type allowed it. `OrgTeamScope` states it.
13
15
  */
14
- ownerScope: OwnerScope;
16
+ ownerScope: OrgTeamScope;
15
17
  name: string;
16
18
  description?: string;
17
19
  accountId: string;
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  import { DimensionId } from './dimensions';
3
3
  import { WidgetConfig } from './report';
4
4
  /**
@@ -1,5 +1,5 @@
1
1
  import { ToolSource } from '../../platform/ai-tools';
2
- import { OwnerScope } from '../contact/types';
2
+ import { OwnerScope } from '../scope/types';
3
3
  import { ArtifactBlock } from './blocks';
4
4
  /**
5
5
  * Een artefact: een afgerond, deelbaar snapshot-document dat de assistent maakt
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  export type CalendarEventStatus = "confirmed" | "cancelled" | "tentative";
3
3
  export type AttendeeResponse = "accepted" | "declined" | "tentative" | "none";
4
4
  export interface EventAttendee {
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  export interface MessageTemplate {
3
3
  id: string;
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  /** Where a company row came from. `local` is a row somebody created by hand. */
3
3
  export interface CompanySource {
4
4
  providerId: string;
@@ -1,5 +1,6 @@
1
1
  import { CommunicationScheme } from '../../platform/communication';
2
- import { Contact, OwnerScope } from './types';
2
+ import { OwnerScope } from '../scope/types';
3
+ import { Contact } from './types';
3
4
  export interface ContactSearchQuery {
4
5
  text?: string;
5
6
  scope?: OwnerScope[];
@@ -1,20 +1,11 @@
1
1
  import { CommunicationScheme } from '../../platform/communication';
2
+ import { OwnerScope } from '../scope/types';
2
3
  export interface ContactEndpoint {
3
4
  scheme: CommunicationScheme;
4
5
  resource: string;
5
6
  label?: string;
6
7
  primary?: boolean;
7
8
  }
8
- export type OwnerScope = {
9
- kind: "personal";
10
- userId: string;
11
- } | {
12
- kind: "team";
13
- teamId: string;
14
- } | {
15
- kind: "org";
16
- organizationId: string;
17
- };
18
9
  export interface ContactSource {
19
10
  providerId: string;
20
11
  externalId?: string;
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  import { ConditionStep, ForEachStep, LookupStep, ParallelStep, Step } from '../playbook/types';
3
3
  /**
4
4
  * Een **leesbaan**: wat er meeleest tijdens een levend gesprek, en aan wie het iets toont.
@@ -53,9 +53,22 @@ export interface MemoryReplaceRequest {
53
53
  * Bron-gestuurd wissen. De **bron** pusht dit; de hub interpreteert geen deletes: de
54
54
  * mapping van een verwijderd contact naar zijn interacties leeft in comms, en
55
55
  * `contacts:deleted` publiceert alleen `{ id }` — zonder `organizationId`.
56
+ *
57
+ * ## Er staat geen `source` in, en dat was de bug
58
+ *
59
+ * Dit veld bestond en de purge filterde erop: alleen geheugen mét die bron werd gewist. De
60
+ * serverkant leidde hem af uit de *aanroepende* app (`requireApp`), dus comms wiste met
61
+ * `source: "communication"` en crm zou met `"crm"` wissen. Maar geheugen wordt geschreven door
62
+ * de app die het *vastlegt* — `"context"` voor een notitie, `ctx.app` voor de
63
+ * `memory_remember`-tool. Nooit door de app die het subject verwijdert.
64
+ *
65
+ * Netto matchte de purge dus niets: een verwijderd contact of gesprek liet zijn geheugen
66
+ * staan. Een retentie-lek, en niet zichtbaar, want `{ removed: 0 }` is een geldig antwoord.
67
+ *
68
+ * Een purge is subject-gescopeerd en niet bron-gescopeerd: "dit subject bestaat niet meer, haal
69
+ * alles erover weg". Dat de aanroeper een app moet zijn blijft de poort; het is geen filter.
56
70
  */
57
71
  export interface MemoryPurgeRequest {
58
72
  organizationId: string;
59
- source: string;
60
73
  subjects: MemorySubjectKey[];
61
74
  }
@@ -1,5 +1,5 @@
1
1
  import { LocaleBundle } from '../analytics/dashboard';
2
- import { OwnerScope } from '../contact/types';
2
+ import { OwnerScope } from '../scope/types';
3
3
  import { MemoryKindId, MemoryVisibility } from './item';
4
4
  /**
5
5
  * Wat er onthouden mág worden, en met welke regels.
@@ -1,5 +1,6 @@
1
1
  import { ActingIdentity } from '../../platform/identity';
2
- import { OwnerScope } from '../contact/types';
2
+ import { toActingIdentity } from '../scope/actor';
3
+ import { OwnerScope } from '../scope/types';
3
4
  /**
4
5
  * `ownerScope` **is** de actor van een playbook: er is geen apart `runAs`-veld.
5
6
  * Zichtbaarheid, werkgebied en toeschrijving volgen dus uit hetzelfde veld.
@@ -8,7 +9,7 @@ import { OwnerScope } from '../contact/types';
8
9
  * entity), aan de uitvoerkant `user` (zoals elke andere acting identity). Deze
9
10
  * functie is die vertaling, en de enige plek waar hij hoort.
10
11
  */
11
- export declare function playbookActor(scope: OwnerScope): ActingIdentity;
12
+ export declare const playbookActor: typeof toActingIdentity;
12
13
  /**
13
14
  * Namens wie deze run handelt.
14
15
  *
@@ -1,6 +1,6 @@
1
1
  import { ActingIdentity } from '../../platform/identity';
2
2
  import { ResourceRef } from '../../platform/resource';
3
- import { OwnerScope } from '../contact/types';
3
+ import { OwnerScope } from '../scope/types';
4
4
  /**
5
5
  * Playbooks — event-driven automation met AI-stappen. Zie docs/PLAYBOOKS.md.
6
6
  *
@@ -0,0 +1,16 @@
1
+ import { ActingIdentity } from '../../platform/identity';
2
+ import { OwnerScope } from './types';
3
+ /**
4
+ * An owner scope as the identity that acts for it.
5
+ *
6
+ * Storage calls the personal rung `personal`, execution calls it `user`, and `org`
7
+ * carries an id on one side and not on the other. This is that translation, and it is
8
+ * meant to be the only one: a hand-rolled `kind === "personal" ? "user" : …` at a call
9
+ * site is how two vocabularies for the same three rungs drift apart.
10
+ *
11
+ * It arrived as `playbookActor` in `entities/playbook/`, whose own docstring already
12
+ * claimed to be "the only place this belongs" — correct, but it read as
13
+ * playbook-specific while every scoped entity needs the same conversion. `playbookActor`
14
+ * stays as a name so the playbook call sites and their tests keep working.
15
+ */
16
+ export declare function toActingIdentity(scope: OwnerScope): ActingIdentity;
@@ -1 +1,2 @@
1
+ export * from './actor';
1
2
  export * from './types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ /**
2
+ * One vocabulary for "whose is this".
3
+ *
4
+ * ## Why this is its own module
5
+ *
6
+ * `OwnerScope` lived in `entities/contact/types.ts`, and nineteen other entities —
7
+ * work, task, topic, playbook, artifact, calendar-event, time-entry, memory, … —
8
+ * imported the platform's scoping primitive *from the contact entity*. Nothing was
9
+ * broken by that; it just meant the answer to "which type do I use to say who owns
10
+ * this" was somewhere nobody would look, and a new entity picked whatever it found
11
+ * first. The audit counted six different spellings in use.
12
+ *
13
+ * ## The field-name convention
14
+ *
15
+ * **The field is always called `ownerScope`.** `scope` is reserved for OAuth scopes,
16
+ * which are an unrelated concept that happens to share the word — `AiBudget.scope` is
17
+ * the one place that still deviates.
18
+ *
19
+ * ## The three rungs, and the fourth spelling
20
+ *
21
+ * Storage says `personal` / `team` / `org`. The execution side —
22
+ * {@link ActingIdentity} in `platform/identity.ts` — says `user` / `team` / `org`, and
23
+ * its `org` carries no id because the tenant is already in context there. Those are
24
+ * genuinely two vocabularies for two layers, not an accident, and the bridge between
25
+ * them is `toActingIdentity` next door. That function is the **only** place the
26
+ * translation belongs; a hand-rolled `kind === "personal" ? "user" : …` at a call site
27
+ * is how the two drift apart.
28
+ */
29
+ export type OwnerScope = {
30
+ kind: "personal";
31
+ userId: string;
32
+ } | {
33
+ kind: "team";
34
+ teamId: string;
35
+ } | {
36
+ kind: "org";
37
+ organizationId: string;
38
+ };
39
+ /**
40
+ * A scope that cannot be personal.
41
+ *
42
+ * For records that are shared by definition: a topic one person can see cannot be read
43
+ * by the colleague who takes over the conversation, and the same goes for an AI profile
44
+ * or a work type. Those rules exist today as prose in the entity's docstring, with the
45
+ * type still permitting `personal` — which means nothing enforces them.
46
+ *
47
+ * Applying this to an existing entity is a type *tightening*, so it can surface rows
48
+ * that already violate the rule. Query for personal-scoped rows first; that is why it
49
+ * is offered here rather than applied everywhere at once.
50
+ */
51
+ export type OrgTeamScope = Exclude<OwnerScope, {
52
+ kind: "personal";
53
+ }>;
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  export type TaskStatus = "open" | "in_progress" | "done" | "cancelled";
3
3
  export type TaskPriority = "low" | "normal" | "high" | "urgent";
4
4
  export type TaskInitiator = "user" | "system";
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  /**
3
3
  * Waar een urenregel in zijn leven staat.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OrgTeamScope } from '../scope/types';
2
2
  /**
3
3
  * Een onderwerp is een **etiket** op een gesprek: waar gaat dit over. Verder niets.
4
4
  *
@@ -12,11 +12,13 @@ export interface Topic {
12
12
  id: string;
13
13
  organizationId: string;
14
14
  /**
15
- * Van wie dit onderwerp is. `org` of `team`; **`personal` wordt geweigerd bij het schrijven** —
16
- * een onderwerp dat maar één persoon kent, kan een collega niet lezen op een gesprek dat hij
17
- * overneemt. Het type laat het toe omdat `OwnerScope` gedeeld is; de validatie niet.
15
+ * Van wie dit onderwerp is: `org` of `team`. Een onderwerp dat maar één persoon kent, kan
16
+ * een collega niet lezen op een gesprek dat hij overneemt.
17
+ *
18
+ * Dit stond hier als proza terwijl het type `personal` toestond, dus handhaafde niets het
19
+ * behalve de schrijfvalidatie. `OrgTeamScope` zegt het nu in het type.
18
20
  */
19
- ownerScope: OwnerScope;
21
+ ownerScope: OrgTeamScope;
20
22
  name: string;
21
23
  description: string;
22
24
  /**
@@ -1,4 +1,4 @@
1
- import { OwnerScope } from '../contact/types';
1
+ import { OwnerScope } from '../scope/types';
2
2
  /**
3
3
  * Work management — één entiteit voor alles wat *werk* is.
4
4
  *