@wirecat/cli-core 0.605.0 → 0.606.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 +98 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -0
- package/dist/cli/store-settings.js +38 -4
- package/dist/crm/cli/index.js +3 -1
- package/dist/crm/index.d.ts +2 -2
- package/dist/crm/index.js +1 -1
- package/dist/crm/source.d.ts +35 -5
- package/dist/crm/sync.d.ts +15 -7
- package/dist/crm/sync.js +169 -11
- package/dist/domain/crm.d.ts +41 -2
- package/dist/domain/deals.d.ts +5 -2
- package/dist/domain/deals.js +5 -2
- package/dist/domain/relations.d.ts +125 -0
- package/dist/domain/relations.js +107 -0
- package/dist/entities/deal.d.ts +2 -2
- package/dist/entities/deal.js +2 -1
- package/dist/entities/index.d.ts +17 -13
- package/dist/entities/relationship.d.ts +8 -2
- package/dist/entities/relationship.js +8 -2
- package/dist/entities/task-results.d.ts +10 -10
- package/dist/errors/reasons.js +12 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/mail/cli/review.js +20 -6
- package/dist/mail/index.d.ts +1 -1
- package/dist/mail/marks.d.ts +10 -5
- package/dist/mail/marks.js +16 -8
- package/dist/mail/review.d.ts +5 -0
- package/dist/services/link-scorers/scan.js +2 -1
- package/dist/services/link-scorers/shared.js +2 -1
- package/dist/services/project-status/index.js +2 -1
- package/dist/services/stored-project-gathering.js +4 -3
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/index.d.ts +6 -1
- package/dist/store/index.js +1 -0
- package/dist/store/project-transfer/request.d.ts +4 -1
- package/dist/store/project-transfer/schema.d.ts +9 -2
- package/dist/store/project-transfer/schema.js +4 -0
- package/dist/store/project-transfer/snapshot-model.d.ts +8 -2
- package/dist/store/sqlite/crm-settings.d.ts +28 -0
- package/dist/store/sqlite/crm-settings.js +80 -0
- package/dist/store/sqlite/crm.d.ts +42 -2
- package/dist/store/sqlite/crm.js +397 -36
- package/dist/store/sqlite/deals.js +3 -2
- package/dist/store/sqlite/involvement-queue.js +4 -3
- package/dist/store/sqlite/knowledge.d.ts +7 -3
- package/dist/store/sqlite/knowledge.js +43 -31
- package/dist/store/sqlite/link-kinds.d.ts +2 -3
- package/dist/store/sqlite/link-kinds.js +4 -2
- package/dist/store/sqlite/manifest.js +5 -0
- package/dist/store/sqlite/memories.d.ts +1 -1
- package/dist/store/sqlite/memories.js +33 -7
- package/dist/store/sqlite/migrations.generated.js +31 -0
- package/dist/store/sqlite/notes.d.ts +3 -2
- package/dist/store/sqlite/notes.js +23 -6
- package/dist/store/sqlite/organizations.d.ts +8 -0
- package/dist/store/sqlite/organizations.js +14 -0
- package/dist/store/sqlite/person-preparation.d.ts +1 -1
- package/dist/store/sqlite/person-preparation.js +3 -2
- package/dist/store/sqlite/project-transfer/records.js +14 -3
- package/dist/store/sqlite/project-transfer/snapshot.d.ts +4 -1
- package/dist/store/sqlite/project-transfer/snapshot.js +6 -0
- package/dist/store/sqlite/relation-list.d.ts +43 -0
- package/dist/store/sqlite/relation-list.js +133 -0
- package/dist/store/sqlite/relation-proposals.d.ts +28 -6
- package/dist/store/sqlite/relation-proposals.js +134 -10
- package/dist/store/sqlite/relation-reads.d.ts +8 -0
- package/dist/store/sqlite/relation-reads.js +7 -0
- package/dist/store/sqlite/relation-roles.d.ts +26 -0
- package/dist/store/sqlite/relation-roles.js +91 -0
- package/dist/store/sqlite/reported-relations.d.ts +63 -0
- package/dist/store/sqlite/reported-relations.js +132 -0
- package/dist/store/sqlite/schema/link-revisions.d.ts +136 -0
- package/dist/store/sqlite/schema/link-revisions.js +11 -0
- package/dist/store/sqlite/schema/links.d.ts +360 -0
- package/dist/store/sqlite/schema/links.js +32 -0
- package/dist/store/sqlite/schema.d.ts +2 -296
- package/dist/store/sqlite/schema.js +2 -24
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/package.json +3 -3
package/dist/domain/crm.d.ts
CHANGED
|
@@ -40,10 +40,14 @@ export interface CrmItem {
|
|
|
40
40
|
closedReason?: string | null;
|
|
41
41
|
/** A company's id. */
|
|
42
42
|
organization?: string | null;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Contacts on it, by their id, the part each plays and whether the CRM marks one its main contact. Left out, the CRM
|
|
45
|
+
* did not say who is on it, and the people stored stay.
|
|
46
|
+
*/
|
|
44
47
|
people?: {
|
|
45
48
|
externalId: string;
|
|
46
49
|
role: DealRole;
|
|
50
|
+
primary?: boolean;
|
|
47
51
|
}[];
|
|
48
52
|
/** A lead's: the deal it became. */
|
|
49
53
|
deal?: string | null;
|
|
@@ -52,7 +56,7 @@ export interface CrmItem {
|
|
|
52
56
|
updatedAt?: number | null;
|
|
53
57
|
/** The CRM's own page for it, http or https. */
|
|
54
58
|
url?: string | null;
|
|
55
|
-
/** The CRM user it is assigned to, by the user's id: never a contact's. */
|
|
59
|
+
/** The CRM user it is assigned to, by the user's id: never a contact's. It makes that user's person its `owner`. */
|
|
56
60
|
assignee?: string | null;
|
|
57
61
|
/**
|
|
58
62
|
* What the CRM sends that has no column; never a secret. Its own fields' values are here by code as `CrmValue`,
|
|
@@ -75,14 +79,49 @@ export interface CrmPerson {
|
|
|
75
79
|
name: string | null;
|
|
76
80
|
email?: string | null;
|
|
77
81
|
phone?: string | null;
|
|
82
|
+
/** The job title as the CRM writes it: kept beside the relationship, never a role. */
|
|
83
|
+
position?: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* The companies the contact represents, by their id; each becomes `member-of` with role `contact`. Left out, the CRM
|
|
86
|
+
* did not say, and the relationships stored stay.
|
|
87
|
+
*/
|
|
88
|
+
organizations?: {
|
|
89
|
+
externalId: string;
|
|
90
|
+
primary?: boolean;
|
|
91
|
+
sourceRole?: string | null;
|
|
92
|
+
}[];
|
|
78
93
|
}
|
|
79
94
|
/** A CRM company: it becomes an organization of its own, never one matched by name. */
|
|
80
95
|
export interface CrmOrganization {
|
|
81
96
|
externalId: string;
|
|
82
97
|
name: string;
|
|
83
98
|
url?: string | null;
|
|
99
|
+
/** One of the account's own companies, the owner's side of every deal, not a client. */
|
|
100
|
+
own?: boolean;
|
|
101
|
+
/** The CRM's company type code; `crm.<provider>:<account>.company-types` says what one means, nothing by default. */
|
|
102
|
+
type?: string | null;
|
|
84
103
|
metadata?: Record<string, unknown>;
|
|
85
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* A CRM user: someone of the owner's own company, such as a deal's owner. It becomes an identity of the CRM's provider,
|
|
107
|
+
* `<account>/user/<id>`, joined to a person by exact email only, and `member-of` the own company as an `employee`
|
|
108
|
+
* while it is active.
|
|
109
|
+
*/
|
|
110
|
+
export interface CrmUser {
|
|
111
|
+
externalId: string;
|
|
112
|
+
name: string | null;
|
|
113
|
+
email?: string | null;
|
|
114
|
+
position?: string | null;
|
|
115
|
+
departments?: string[];
|
|
116
|
+
active?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** A department of the own company: a user reports to its head, a head to the head of the parent. */
|
|
119
|
+
export interface CrmDepartment {
|
|
120
|
+
externalId: string;
|
|
121
|
+
name: string;
|
|
122
|
+
parent?: string | null;
|
|
123
|
+
head?: string | null;
|
|
124
|
+
}
|
|
86
125
|
/** One of a CRM account's own fields on a kind: what the code a row's `metadata` is keyed by means. */
|
|
87
126
|
export interface CrmField {
|
|
88
127
|
/** The CRM's key for it, unique in its kind. */
|
package/dist/domain/deals.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ export declare const DEAL_KINDS: readonly ["deal", "lead"];
|
|
|
4
4
|
export declare const DEAL_STATUSES: readonly ["open", "won", "lost"];
|
|
5
5
|
/** What reaching a stage means, as a CRM marks it: still open, or won or lost. */
|
|
6
6
|
export declare const STAGE_OUTCOMES: readonly ["open", "won", "lost"];
|
|
7
|
-
/**
|
|
8
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The part a person plays on a deal: the owner's side runs it (`owner`, the CRM's "responsible"), the client's side
|
|
9
|
+
* talks, decides or sways the decision.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEAL_ROLES: readonly ["owner", "contact", "decision-maker", "influencer"];
|
|
9
12
|
export type DealKind = (typeof DEAL_KINDS)[number];
|
|
10
13
|
export type DealStatus = (typeof DEAL_STATUSES)[number];
|
|
11
14
|
export type StageOutcome = DealStatus;
|
package/dist/domain/deals.js
CHANGED
|
@@ -5,8 +5,11 @@ export const DEAL_KINDS = ["deal", "lead"];
|
|
|
5
5
|
export const DEAL_STATUSES = ["open", "won", "lost"];
|
|
6
6
|
/** What reaching a stage means, as a CRM marks it: still open, or won or lost. */
|
|
7
7
|
export const STAGE_OUTCOMES = DEAL_STATUSES;
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The part a person plays on a deal: the owner's side runs it (`owner`, the CRM's "responsible"), the client's side
|
|
10
|
+
* talks, decides or sways the decision.
|
|
11
|
+
*/
|
|
12
|
+
export const DEAL_ROLES = ["owner", "contact", "decision-maker", "influencer"];
|
|
10
13
|
/** "Site redesign · Proposal, 500 000.00 RUB (won)": a ref summary's title, which `refLabel` prefixes. */
|
|
11
14
|
export const dealLine = (deal) => {
|
|
12
15
|
const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/** What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. */
|
|
2
|
+
export declare const ORGANIZATION_ROLES: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
|
|
3
|
+
export declare const PROJECT_ROLES: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
4
|
+
type End = "person" | "organization" | "project" | "task" | "chat" | "email_thread" | "deal" | "lead";
|
|
5
|
+
interface RelationSpec {
|
|
6
|
+
from: readonly End[];
|
|
7
|
+
to: readonly End[];
|
|
8
|
+
/** Role lists by the end that names them; where none applies, a role is free text. */
|
|
9
|
+
roles?: {
|
|
10
|
+
from?: Partial<Record<End, readonly string[]>>;
|
|
11
|
+
to?: Partial<Record<End, readonly string[]>>;
|
|
12
|
+
};
|
|
13
|
+
/** Shown when a relationship is read from its `to` end; never stored. */
|
|
14
|
+
inverse?: string;
|
|
15
|
+
/** Stored once, the lower id as `from`. */
|
|
16
|
+
symmetric?: true;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Every relationship `knowledge.relate` makes, its ends, its roles and how it reads backwards. An organization may
|
|
20
|
+
* still be a member: owner data from before this list holds such links.
|
|
21
|
+
*/
|
|
22
|
+
export declare const RELATIONS: {
|
|
23
|
+
readonly "member-of": {
|
|
24
|
+
readonly from: readonly ["person", "organization", "project", "chat", "email_thread"];
|
|
25
|
+
readonly to: readonly ["organization", "project"];
|
|
26
|
+
readonly roles: {
|
|
27
|
+
readonly to: {
|
|
28
|
+
readonly organization: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
|
|
29
|
+
readonly project: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
readonly "reports-to": {
|
|
34
|
+
readonly from: readonly ["person"];
|
|
35
|
+
readonly to: readonly ["person"];
|
|
36
|
+
readonly inverse: "manages";
|
|
37
|
+
};
|
|
38
|
+
readonly "customer-of": {
|
|
39
|
+
readonly from: readonly ["person", "organization"];
|
|
40
|
+
readonly to: readonly ["organization"];
|
|
41
|
+
readonly inverse: "supplier of";
|
|
42
|
+
};
|
|
43
|
+
readonly "partner-of": {
|
|
44
|
+
readonly from: readonly ["organization"];
|
|
45
|
+
readonly to: readonly ["organization"];
|
|
46
|
+
readonly symmetric: true;
|
|
47
|
+
};
|
|
48
|
+
readonly "related-to": {
|
|
49
|
+
readonly from: readonly ["person", "organization", "project", "task", "deal", "lead"];
|
|
50
|
+
readonly to: readonly ["person", "organization", "project", "task"];
|
|
51
|
+
readonly roles: {
|
|
52
|
+
readonly from: {
|
|
53
|
+
readonly deal: readonly ["owner", "contact", "decision-maker", "influencer"];
|
|
54
|
+
readonly lead: readonly ["owner", "contact", "decision-maker", "influencer"];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export type RelationKind = keyof typeof RELATIONS;
|
|
60
|
+
export declare const RELATION_KINDS: RelationKind[];
|
|
61
|
+
export declare const isRelationKind: (kind: string) => kind is RelationKind;
|
|
62
|
+
export declare const checkEnds: (kind: string, from: string, to: string) => RelationSpec;
|
|
63
|
+
/**
|
|
64
|
+
* The roles a relationship takes, or `undefined` for free text. A member's list is the organization's or the
|
|
65
|
+
* project's only when the member is a person: a chat's or a sub-project's role was never one of them.
|
|
66
|
+
*/
|
|
67
|
+
export declare const rolesOf: (kind: string, from: string, to: string) => readonly string[] | undefined;
|
|
68
|
+
/** The role lists the owner may add to; each is a list the registry gives some relationship's ends. */
|
|
69
|
+
export declare const ROLE_LISTS: {
|
|
70
|
+
readonly organization: readonly ["employee", "contractor", "founder", "owner", "manager", "adviser", "contact"];
|
|
71
|
+
readonly project: readonly ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
72
|
+
readonly deal: readonly ["owner", "contact", "decision-maker", "influencer"];
|
|
73
|
+
};
|
|
74
|
+
export type RoleList = keyof typeof ROLE_LISTS;
|
|
75
|
+
/** Which list a relationship's role comes from, or `undefined` where a role is free text. */
|
|
76
|
+
export declare const roleListOf: (kind: string, from: string, to: string) => RoleList | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* The role as given when the relationship has no list, or when it is on the list or among `extra` (the owner's own
|
|
79
|
+
* roles for that list); refused otherwise.
|
|
80
|
+
*/
|
|
81
|
+
export declare const checkRole: (kind: string, from: string, to: string, role: string, extra?: readonly string[]) => string;
|
|
82
|
+
export declare const isSymmetric: (kind: string) => boolean;
|
|
83
|
+
/** The label of a relationship read from its `to` end: `manages` for `reports-to`; the kind itself when symmetric. */
|
|
84
|
+
export declare const inverseOf: (kind: string) => string | null;
|
|
85
|
+
/**
|
|
86
|
+
* What an answer says about a relationship, derived, never stored: the owner's, a source's that nobody confirmed, an
|
|
87
|
+
* agent's suggestion waiting for review, or one that no longer holds.
|
|
88
|
+
*/
|
|
89
|
+
export declare const STANDINGS: readonly ["confirmed", "reported", "proposed", "ended"];
|
|
90
|
+
export type Standing = (typeof STANDINGS)[number];
|
|
91
|
+
/** A link's columns `standing` reads; a column an older store lacks is `null`. */
|
|
92
|
+
export interface StandingFields {
|
|
93
|
+
confirmed: boolean;
|
|
94
|
+
accountId?: number | null;
|
|
95
|
+
/** Epoch ms, exclusive. */
|
|
96
|
+
endsAt?: number | null;
|
|
97
|
+
deletedAt?: number | null;
|
|
98
|
+
}
|
|
99
|
+
/** What a `links` row of a relationship kind holds beyond any link, when set. */
|
|
100
|
+
export interface RelationshipColumns {
|
|
101
|
+
/** The `accounts` row of the source that reported it. */
|
|
102
|
+
accountId?: number;
|
|
103
|
+
/** When it held, epoch ms; `endsAt` exclusive. */
|
|
104
|
+
startsAt?: number;
|
|
105
|
+
endsAt?: number;
|
|
106
|
+
/** The source stopped reporting it. */
|
|
107
|
+
deletedAt?: number;
|
|
108
|
+
/** A job title beside it (`metadata.position`), never its role. */
|
|
109
|
+
position?: string;
|
|
110
|
+
/** The source's link this owner link overrides (`metadata.overrides`). */
|
|
111
|
+
overrides?: number;
|
|
112
|
+
}
|
|
113
|
+
/** The owner's confirmation outlives a source that stopped reporting it; only its own end date ends it. */
|
|
114
|
+
export declare const standingOf: (link: StandingFields, now: number) => Standing;
|
|
115
|
+
/** A relationship a context or a traversal counts: the owner's, or a source's that still holds. */
|
|
116
|
+
export declare const isUsable: (standing: Standing) => boolean;
|
|
117
|
+
export declare const usableLink: (link: StandingFields, now: number) => boolean;
|
|
118
|
+
/**
|
|
119
|
+
* The `links` row aliased `alias` has no owner link overriding it (`metadata.overrides`, an owner's edit of a link a
|
|
120
|
+
* source reported): where one does, the override is the answer.
|
|
121
|
+
*/
|
|
122
|
+
export declare const notOverriddenSql: (alias: string) => string;
|
|
123
|
+
/** `usableLink` as SQL over the `links` row aliased `alias`; without `now` an end date is not checked. */
|
|
124
|
+
export declare const usableLinkSql: (alias: string, now?: number) => string;
|
|
125
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { DEAL_ROLES } from "./deals.js";
|
|
3
|
+
/** What a person is to an organization; who reports to whom is `reports-to`, and a job title is never a role. */
|
|
4
|
+
export const ORGANIZATION_ROLES = [
|
|
5
|
+
"employee",
|
|
6
|
+
"contractor",
|
|
7
|
+
"founder",
|
|
8
|
+
"owner",
|
|
9
|
+
"manager",
|
|
10
|
+
"adviser",
|
|
11
|
+
"contact",
|
|
12
|
+
];
|
|
13
|
+
export const PROJECT_ROLES = ["owner", "manager", "contributor", "client-contact", "approver"];
|
|
14
|
+
/**
|
|
15
|
+
* Every relationship `knowledge.relate` makes, its ends, its roles and how it reads backwards. An organization may
|
|
16
|
+
* still be a member: owner data from before this list holds such links.
|
|
17
|
+
*/
|
|
18
|
+
export const RELATIONS = {
|
|
19
|
+
"member-of": {
|
|
20
|
+
from: ["person", "organization", "project", "chat", "email_thread"],
|
|
21
|
+
to: ["organization", "project"],
|
|
22
|
+
roles: { to: { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES } },
|
|
23
|
+
},
|
|
24
|
+
"reports-to": { from: ["person"], to: ["person"], inverse: "manages" },
|
|
25
|
+
"customer-of": { from: ["person", "organization"], to: ["organization"], inverse: "supplier of" },
|
|
26
|
+
"partner-of": { from: ["organization"], to: ["organization"], symmetric: true },
|
|
27
|
+
"related-to": {
|
|
28
|
+
from: ["person", "organization", "project", "task", "deal", "lead"],
|
|
29
|
+
to: ["person", "organization", "project", "task"],
|
|
30
|
+
roles: { from: { deal: DEAL_ROLES, lead: DEAL_ROLES } },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const RELATION_KINDS = Object.keys(RELATIONS);
|
|
34
|
+
const specOf = (kind) => Object.hasOwn(RELATIONS, kind) ? RELATIONS[kind] : undefined;
|
|
35
|
+
export const isRelationKind = (kind) => specOf(kind) !== undefined;
|
|
36
|
+
/** A chat or a mail thread is only ever a project's member: its reference names one account. */
|
|
37
|
+
const memberOnly = (type) => type === "chat" || type === "email_thread";
|
|
38
|
+
export const checkEnds = (kind, from, to) => {
|
|
39
|
+
const spec = specOf(kind);
|
|
40
|
+
if (!spec)
|
|
41
|
+
throw new CliError("validation_error", `a relationship's kind is one of ${RELATION_KINDS.join(", ")}`);
|
|
42
|
+
if (memberOnly(from) && (kind !== "member-of" || to !== "project"))
|
|
43
|
+
throw new CliError("validation_error", `a ${from === "chat" ? "chat" : "mail thread"} is related only as member-of a project`);
|
|
44
|
+
if (!spec.from.includes(from) || !spec.to.includes(to))
|
|
45
|
+
throw new CliError("validation_error", `${kind} joins ${spec.from.join(", ")} to ${spec.to.join(", ")}, not ${from} to ${to}`);
|
|
46
|
+
return spec;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The roles a relationship takes, or `undefined` for free text. A member's list is the organization's or the
|
|
50
|
+
* project's only when the member is a person: a chat's or a sub-project's role was never one of them.
|
|
51
|
+
*/
|
|
52
|
+
export const rolesOf = (kind, from, to) => {
|
|
53
|
+
const spec = specOf(kind);
|
|
54
|
+
if (kind === "member-of" && from !== "person")
|
|
55
|
+
return undefined;
|
|
56
|
+
return spec?.roles?.from?.[from] ?? spec?.roles?.to?.[to];
|
|
57
|
+
};
|
|
58
|
+
/** The role lists the owner may add to; each is a list the registry gives some relationship's ends. */
|
|
59
|
+
export const ROLE_LISTS = { organization: ORGANIZATION_ROLES, project: PROJECT_ROLES, deal: DEAL_ROLES };
|
|
60
|
+
/** Which list a relationship's role comes from, or `undefined` where a role is free text. */
|
|
61
|
+
export const roleListOf = (kind, from, to) => {
|
|
62
|
+
const roles = rolesOf(kind, from, to);
|
|
63
|
+
return Object.keys(ROLE_LISTS).find((list) => ROLE_LISTS[list] === roles);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The role as given when the relationship has no list, or when it is on the list or among `extra` (the owner's own
|
|
67
|
+
* roles for that list); refused otherwise.
|
|
68
|
+
*/
|
|
69
|
+
export const checkRole = (kind, from, to, role, extra = []) => {
|
|
70
|
+
const roles = rolesOf(kind, from, to)?.concat(extra);
|
|
71
|
+
if (roles && !roles.includes(role))
|
|
72
|
+
throw new CliError("validation_error", `a ${from}'s role on ${kind} ${to} is one of ${roles.join(", ")}`, {
|
|
73
|
+
reason: "relationship.role-unknown",
|
|
74
|
+
});
|
|
75
|
+
return role;
|
|
76
|
+
};
|
|
77
|
+
export const isSymmetric = (kind) => specOf(kind)?.symmetric === true;
|
|
78
|
+
/** The label of a relationship read from its `to` end: `manages` for `reports-to`; the kind itself when symmetric. */
|
|
79
|
+
export const inverseOf = (kind) => specOf(kind)?.symmetric ? kind : (specOf(kind)?.inverse ?? null);
|
|
80
|
+
/**
|
|
81
|
+
* What an answer says about a relationship, derived, never stored: the owner's, a source's that nobody confirmed, an
|
|
82
|
+
* agent's suggestion waiting for review, or one that no longer holds.
|
|
83
|
+
*/
|
|
84
|
+
export const STANDINGS = ["confirmed", "reported", "proposed", "ended"];
|
|
85
|
+
/** The owner's confirmation outlives a source that stopped reporting it; only its own end date ends it. */
|
|
86
|
+
export const standingOf = (link, now) => {
|
|
87
|
+
if (link.endsAt != null && link.endsAt <= now)
|
|
88
|
+
return "ended";
|
|
89
|
+
if (link.confirmed)
|
|
90
|
+
return "confirmed";
|
|
91
|
+
if (link.deletedAt != null)
|
|
92
|
+
return "ended";
|
|
93
|
+
return link.accountId != null ? "reported" : "proposed";
|
|
94
|
+
};
|
|
95
|
+
/** A relationship a context or a traversal counts: the owner's, or a source's that still holds. */
|
|
96
|
+
export const isUsable = (standing) => standing === "confirmed" || standing === "reported";
|
|
97
|
+
export const usableLink = (link, now) => isUsable(standingOf(link, now));
|
|
98
|
+
/**
|
|
99
|
+
* The `links` row aliased `alias` has no owner link overriding it (`metadata.overrides`, an owner's edit of a link a
|
|
100
|
+
* source reported): where one does, the override is the answer.
|
|
101
|
+
*/
|
|
102
|
+
export const notOverriddenSql = (alias) => `NOT EXISTS (SELECT 1 FROM links override WHERE override.kind = ${alias}.kind AND override.from_type = ${alias}.from_type ` +
|
|
103
|
+
`AND override.from_id = ${alias}.from_id AND override.to_type = ${alias}.to_type AND override.to_id = ${alias}.to_id ` +
|
|
104
|
+
`AND json_extract(override.metadata, '$.overrides') = ${alias}.id)`;
|
|
105
|
+
/** `usableLink` as SQL over the `links` row aliased `alias`; without `now` an end date is not checked. */
|
|
106
|
+
export const usableLinkSql = (alias, now) => `(${alias}.confirmed = 1 OR (${alias}.account_id IS NOT NULL AND ${alias}.deleted_at IS NULL))` +
|
|
107
|
+
(now === undefined ? "" : ` AND (${alias}.ends_at IS NULL OR ${alias}.ends_at > ${Math.trunc(now)})`);
|
package/dist/entities/deal.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare const deal: v.StrictObjectSchema<{
|
|
|
45
45
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
46
46
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
47
47
|
readonly owner: v.BooleanSchema<undefined>;
|
|
48
|
-
readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
|
|
48
|
+
readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
|
|
49
49
|
}, undefined>, undefined>;
|
|
50
50
|
readonly author: v.StrictObjectSchema<{
|
|
51
51
|
readonly type: v.PicklistSchema<["person", "bot"], undefined>;
|
|
@@ -106,7 +106,7 @@ export declare const lead: v.StrictObjectSchema<{
|
|
|
106
106
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
107
107
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
108
108
|
readonly owner: v.BooleanSchema<undefined>;
|
|
109
|
-
readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
|
|
109
|
+
readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
|
|
110
110
|
}, undefined>, undefined>;
|
|
111
111
|
readonly author: v.StrictObjectSchema<{
|
|
112
112
|
readonly type: v.PicklistSchema<["person", "bot"], undefined>;
|
package/dist/entities/deal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
+
import { DEAL_ROLES } from "../domain/deals.js";
|
|
2
3
|
import { count, id, reference, text, time, untrusted } from "./fields.js";
|
|
3
4
|
const nullableText = v.nullable(text);
|
|
4
5
|
const party = v.strictObject({ ref: reference, name: nullableText, owner: v.boolean() });
|
|
@@ -40,7 +41,7 @@ export const deal = v.strictObject({
|
|
|
40
41
|
value: v.unknown(),
|
|
41
42
|
option_id: v.optional(v.union([v.string(), v.array(v.string())])),
|
|
42
43
|
})),
|
|
43
|
-
people: v.array(v.strictObject({ ...party.entries, role: v.picklist(
|
|
44
|
+
people: v.array(v.strictObject({ ...party.entries, role: v.picklist(DEAL_ROLES) })),
|
|
44
45
|
author: v.strictObject({
|
|
45
46
|
type: v.picklist(["person", "bot"]),
|
|
46
47
|
id,
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ export declare const ENTITIES: {
|
|
|
272
272
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
273
273
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
274
274
|
readonly owner: v.BooleanSchema<undefined>;
|
|
275
|
-
readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
|
|
275
|
+
readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
|
|
276
276
|
}, undefined>, undefined>;
|
|
277
277
|
readonly author: v.StrictObjectSchema<{
|
|
278
278
|
readonly type: v.PicklistSchema<["person", "bot"], undefined>;
|
|
@@ -327,7 +327,7 @@ export declare const ENTITIES: {
|
|
|
327
327
|
readonly ref: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
328
328
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
329
329
|
readonly owner: v.BooleanSchema<undefined>;
|
|
330
|
-
readonly role: v.PicklistSchema<["owner", "contact", "decision-maker"], undefined>;
|
|
330
|
+
readonly role: v.PicklistSchema<readonly ["owner", "contact", "decision-maker", "influencer"], undefined>;
|
|
331
331
|
}, undefined>, undefined>;
|
|
332
332
|
readonly author: v.StrictObjectSchema<{
|
|
333
333
|
readonly type: v.PicklistSchema<["person", "bot"], undefined>;
|
|
@@ -4608,7 +4608,7 @@ export declare const ENTITIES: {
|
|
|
4608
4608
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4609
4609
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4610
4610
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4611
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4611
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4612
4612
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4613
4613
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4614
4614
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4623,7 +4623,7 @@ export declare const ENTITIES: {
|
|
|
4623
4623
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4624
4624
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4625
4625
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4626
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4626
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4627
4627
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4628
4628
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4629
4629
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4724,7 +4724,7 @@ export declare const ENTITIES: {
|
|
|
4724
4724
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4725
4725
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4726
4726
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4727
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4727
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4728
4728
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4729
4729
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4730
4730
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4739,7 +4739,7 @@ export declare const ENTITIES: {
|
|
|
4739
4739
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4740
4740
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4741
4741
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4742
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4742
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4743
4743
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4744
4744
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4745
4745
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4841,7 +4841,7 @@ export declare const ENTITIES: {
|
|
|
4841
4841
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4842
4842
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4843
4843
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4844
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4844
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4845
4845
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4846
4846
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4847
4847
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4856,7 +4856,7 @@ export declare const ENTITIES: {
|
|
|
4856
4856
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4857
4857
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4858
4858
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4859
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4859
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4860
4860
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4861
4861
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4862
4862
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4986,7 +4986,7 @@ export declare const ENTITIES: {
|
|
|
4986
4986
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4987
4987
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4988
4988
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
4989
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
4989
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
4990
4990
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4991
4991
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4992
4992
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5001,7 +5001,7 @@ export declare const ENTITIES: {
|
|
|
5001
5001
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5002
5002
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5003
5003
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
5004
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
5004
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
5005
5005
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5006
5006
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5007
5007
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5096,7 +5096,7 @@ export declare const ENTITIES: {
|
|
|
5096
5096
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5097
5097
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5098
5098
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
5099
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
5099
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
5100
5100
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5101
5101
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5102
5102
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5111,7 +5111,7 @@ export declare const ENTITIES: {
|
|
|
5111
5111
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5112
5112
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5113
5113
|
readonly to: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>, undefined>;
|
|
5114
|
-
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "assigned-to", "attached"], undefined>;
|
|
5114
|
+
readonly kind: v.PicklistSchema<readonly ["links-to", "blocked-by", "follow-up-of", "about", "member-of", "labelled", "answered-by", "evidence", "created-from", "duplicate-of", "related-to", "reports-to", "customer-of", "partner-of", "assigned-to", "attached"], undefined>;
|
|
5115
5115
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5116
5116
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5117
5117
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -6607,13 +6607,17 @@ export declare const ENTITIES: {
|
|
|
6607
6607
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
6608
6608
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
6609
6609
|
readonly to: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
6610
|
-
readonly kind: v.PicklistSchema<
|
|
6610
|
+
readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
|
|
6611
6611
|
readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6612
6612
|
readonly purpose: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6613
6613
|
readonly evidence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6614
6614
|
readonly confirmed: v.BooleanSchema<undefined>;
|
|
6615
6615
|
readonly provenance: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6616
6616
|
readonly confidence_category: v.PicklistSchema<["owner-confirmed", "weak"], undefined>;
|
|
6617
|
+
readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
|
|
6618
|
+
readonly position: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6619
|
+
readonly starts_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
6620
|
+
readonly ends_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
6617
6621
|
readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
6618
6622
|
}, undefined>;
|
|
6619
6623
|
readonly recipient: v.StrictObjectSchema<{
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
/** A link the owner
|
|
2
|
+
/** A link the owner, an agent or a source drew between people, organizations, projects, tasks and deals. */
|
|
3
3
|
export declare const relationship: v.StrictObjectSchema<{
|
|
4
4
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5
5
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
6
6
|
readonly to: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
7
|
-
readonly kind: v.PicklistSchema<
|
|
7
|
+
readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
|
|
8
8
|
readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
9
9
|
/** A purpose from memo's config; `null` means `work`. */
|
|
10
10
|
readonly purpose: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -13,5 +13,11 @@ export declare const relationship: v.StrictObjectSchema<{
|
|
|
13
13
|
readonly confirmed: v.BooleanSchema<undefined>;
|
|
14
14
|
readonly provenance: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
15
15
|
readonly confidence_category: v.PicklistSchema<["owner-confirmed", "weak"], undefined>;
|
|
16
|
+
/** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
|
|
17
|
+
readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
|
|
18
|
+
/** A job title beside it, never its role. */
|
|
19
|
+
readonly position: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
20
|
+
readonly starts_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
21
|
+
readonly ends_at: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>, undefined>;
|
|
16
22
|
readonly created_at: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time in UTC">, v.EndsWithAction<string, "Z", "an ISO 8601 time in UTC, ending in `Z`">]>;
|
|
17
23
|
}, undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
import { RELATION_KINDS } from "../
|
|
2
|
+
import { RELATION_KINDS, STANDINGS } from "../domain/relations.js";
|
|
3
3
|
import { id, reference, text, time } from "./fields.js";
|
|
4
|
-
/** A link the owner
|
|
4
|
+
/** A link the owner, an agent or a source drew between people, organizations, projects, tasks and deals. */
|
|
5
5
|
export const relationship = v.strictObject({
|
|
6
6
|
id,
|
|
7
7
|
from: reference,
|
|
@@ -15,5 +15,11 @@ export const relationship = v.strictObject({
|
|
|
15
15
|
confirmed: v.boolean(),
|
|
16
16
|
provenance: v.nullable(text),
|
|
17
17
|
confidence_category: v.picklist(["owner-confirmed", "weak"]),
|
|
18
|
+
/** `reported`: a CRM account says so and nobody confirmed it; `ended`: it no longer holds. */
|
|
19
|
+
standing: v.picklist(STANDINGS),
|
|
20
|
+
/** A job title beside it, never its role. */
|
|
21
|
+
position: v.nullable(text),
|
|
22
|
+
starts_at: v.nullable(time),
|
|
23
|
+
ends_at: v.nullable(time),
|
|
18
24
|
created_at: time,
|
|
19
25
|
});
|