@wirecat/cli-core 0.605.0 → 0.607.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 +284 -1
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/reads.js +5 -0
- package/dist/cli/app-mcp-command.d.ts +6 -2
- package/dist/cli/app-mcp-command.js +11 -2
- package/dist/cli/csv.d.ts +10 -0
- package/dist/cli/csv.js +22 -0
- package/dist/cli/early-refusal.d.ts +10 -0
- package/dist/cli/early-refusal.js +19 -0
- package/dist/cli/index.d.ts +4 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/profile-token.d.ts +29 -0
- package/dist/cli/profile-token.js +65 -0
- package/dist/cli/program.js +4 -2
- package/dist/cli/store-settings.js +38 -4
- package/dist/crm/cli/csv.d.ts +23 -0
- package/dist/crm/cli/csv.js +135 -0
- package/dist/crm/cli/index.d.ts +1 -1
- package/dist/crm/cli/index.js +36 -22
- package/dist/crm/cli/pipeline-view.d.ts +3 -0
- package/dist/crm/cli/pipeline-view.js +36 -0
- 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/crm/writes.d.ts +6 -4
- package/dist/crm/writes.js +17 -13
- package/dist/documents.d.ts +2 -0
- package/dist/documents.js +2 -0
- package/dist/domain/business.d.ts +79 -0
- package/dist/domain/business.js +42 -0
- 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/finance.d.ts +2 -0
- package/dist/domain/finance.js +2 -2
- package/dist/domain/google-documents.d.ts +2 -0
- package/dist/domain/google-documents.js +3 -1
- package/dist/domain/money.d.ts +2 -0
- package/dist/domain/money.js +11 -3
- package/dist/domain/providers.d.ts +36 -1
- package/dist/domain/providers.js +69 -7
- package/dist/domain/record-fields.d.ts +42 -0
- package/dist/domain/record-fields.js +122 -0
- package/dist/domain/record-types.d.ts +489 -16
- package/dist/domain/record-types.js +374 -7
- package/dist/domain/records.d.ts +96 -5
- package/dist/domain/records.js +178 -32
- package/dist/domain/ref-summaries.js +5 -0
- package/dist/domain/references.d.ts +1 -1
- package/dist/domain/references.js +5 -0
- package/dist/domain/relations.d.ts +125 -0
- package/dist/domain/relations.js +107 -0
- package/dist/domain/vcard.d.ts +25 -0
- package/dist/domain/vcard.js +267 -0
- package/dist/entities/deal.d.ts +16 -2
- package/dist/entities/deal.js +5 -1
- package/dist/entities/index.d.ts +29 -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 +73 -2
- package/dist/fetch/addresses.d.ts +5 -0
- package/dist/fetch/addresses.js +76 -0
- package/dist/fetch/page.d.ts +64 -0
- package/dist/fetch/page.js +256 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +6 -3
- 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/meetings/calendar-text.d.ts +1 -1
- package/dist/meetings/calendar-text.js +4 -0
- package/dist/meetings/event-store.d.ts +2 -2
- package/dist/search/account-list.d.ts +4 -0
- package/dist/search/account-list.js +19 -8
- package/dist/search/query.js +2 -2
- package/dist/services/events-search.js +2 -2
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/ingest.d.ts +56 -8
- package/dist/services/ingest.js +95 -61
- package/dist/services/link-scorers/scan.js +2 -1
- package/dist/services/link-scorers/shared.js +2 -1
- package/dist/services/messages-search.js +3 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/notes-search.js +1 -0
- package/dist/services/project-status/index.js +2 -1
- package/dist/services/proposals/kinds/contracts.d.ts +4 -0
- package/dist/services/proposals/kinds/contracts.js +9 -0
- package/dist/services/proposals/kinds/finance.d.ts +4 -0
- package/dist/services/proposals/kinds/finance.js +14 -35
- package/dist/services/proposals/kinds/orders.js +7 -30
- package/dist/services/proposals/kinds/shared.d.ts +27 -1
- package/dist/services/proposals/kinds/shared.js +34 -0
- package/dist/services/proposals/kinds/source-review.d.ts +4 -0
- package/dist/services/proposals/kinds/source-review.js +45 -0
- package/dist/services/proposals/kinds/subscriptions.d.ts +9 -0
- package/dist/services/proposals/kinds/subscriptions.js +24 -0
- package/dist/services/proposals/kinds/transactions.d.ts +4 -0
- package/dist/services/proposals/kinds/transactions.js +10 -0
- package/dist/services/proposals/registry.js +9 -0
- package/dist/services/search-all-meetings.js +2 -2
- package/dist/services/search-all.js +4 -3
- package/dist/services/search-kind.js +3 -3
- package/dist/services/stored-project-gathering.js +4 -3
- package/dist/store/decisions.js +5 -1
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/index.d.ts +20 -4
- package/dist/store/index.js +4 -0
- package/dist/store/people.js +1 -1
- 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/source-review.d.ts +64 -0
- package/dist/store/source-review.js +7 -0
- package/dist/store/sqlite/accounts.d.ts +1 -1
- package/dist/store/sqlite/accounts.js +24 -1
- package/dist/store/sqlite/added-sources.d.ts +82 -0
- package/dist/store/sqlite/added-sources.js +237 -0
- package/dist/store/sqlite/business-contracts.d.ts +90 -0
- package/dist/store/sqlite/business-contracts.js +182 -0
- package/dist/store/sqlite/calendar-events.js +7 -3
- package/dist/store/sqlite/calendar-forget.js +3 -0
- package/dist/store/sqlite/calendar.d.ts +21 -1
- package/dist/store/sqlite/calendar.js +27 -7
- package/dist/store/sqlite/chat-rekey.js +7 -0
- package/dist/store/sqlite/chats.d.ts +3 -1
- package/dist/store/sqlite/chats.js +15 -1
- package/dist/store/sqlite/crm-rows.d.ts +44 -0
- package/dist/store/sqlite/crm-rows.js +195 -0
- 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 -11
- package/dist/store/sqlite/crm.js +402 -196
- package/dist/store/sqlite/deals.d.ts +4 -8
- package/dist/store/sqlite/deals.js +8 -5
- package/dist/store/sqlite/document-transfer/snapshot.js +2 -2
- package/dist/store/sqlite/emails.js +2 -0
- package/dist/store/sqlite/entity-types.d.ts +14 -9
- package/dist/store/sqlite/entity-types.js +4 -10
- package/dist/store/sqlite/evidence-signature.d.ts +114 -0
- package/dist/store/sqlite/evidence-signature.js +349 -0
- package/dist/store/sqlite/evidence-sources.d.ts +2 -1
- package/dist/store/sqlite/evidence-sources.js +7 -3
- package/dist/store/sqlite/facts.d.ts +7 -2
- package/dist/store/sqlite/facts.js +21 -5
- package/dist/store/sqlite/finance.d.ts +18 -105
- package/dist/store/sqlite/finance.js +100 -219
- package/dist/store/sqlite/involvement-queue.js +4 -3
- package/dist/store/sqlite/knowledge.d.ts +14 -4
- package/dist/store/sqlite/knowledge.js +108 -102
- package/dist/store/sqlite/labelled.d.ts +3 -0
- package/dist/store/sqlite/labelled.js +11 -0
- package/dist/store/sqlite/link-kinds.d.ts +4 -3
- package/dist/store/sqlite/link-kinds.js +6 -2
- package/dist/store/sqlite/manifest.js +7 -0
- package/dist/store/sqlite/memories.d.ts +24 -10
- package/dist/store/sqlite/memories.js +73 -19
- package/dist/store/sqlite/messages.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +134 -0
- package/dist/store/sqlite/money-lines.d.ts +48 -0
- package/dist/store/sqlite/money-lines.js +76 -0
- package/dist/store/sqlite/money-transactions.d.ts +132 -0
- package/dist/store/sqlite/money-transactions.js +295 -0
- package/dist/store/sqlite/notes.d.ts +14 -4
- package/dist/store/sqlite/notes.js +43 -31
- package/dist/store/sqlite/orders.d.ts +36 -6
- package/dist/store/sqlite/orders.js +126 -46
- package/dist/store/sqlite/organizations.d.ts +8 -0
- package/dist/store/sqlite/organizations.js +14 -0
- package/dist/store/sqlite/payment-facts.js +1 -1
- package/dist/store/sqlite/person-preparation.d.ts +1 -1
- package/dist/store/sqlite/person-preparation.js +3 -2
- package/dist/store/sqlite/private-people.js +2 -0
- package/dist/store/sqlite/products.d.ts +78 -0
- package/dist/store/sqlite/products.js +131 -0
- package/dist/store/sqlite/project-transfer/records.js +39 -3
- package/dist/store/sqlite/project-transfer/snapshot.d.ts +4 -1
- package/dist/store/sqlite/project-transfer/snapshot.js +11 -3
- package/dist/store/sqlite/proposed-actions.d.ts +1 -1
- package/dist/store/sqlite/proposed-actions.js +24 -7
- package/dist/store/sqlite/providers.d.ts +0 -4
- package/dist/store/sqlite/providers.js +20 -2
- package/dist/store/sqlite/record-matching.d.ts +80 -0
- package/dist/store/sqlite/record-matching.js +264 -0
- package/dist/store/sqlite/record-projection.d.ts +89 -0
- package/dist/store/sqlite/record-projection.js +50 -0
- package/dist/store/sqlite/record-projectors-direct.d.ts +17 -0
- package/dist/store/sqlite/record-projectors-direct.js +125 -0
- package/dist/store/sqlite/record-projectors-money.d.ts +26 -0
- package/dist/store/sqlite/record-projectors-money.js +214 -0
- package/dist/store/sqlite/record-projectors-phone.d.ts +28 -0
- package/dist/store/sqlite/record-projectors-phone.js +212 -0
- package/dist/store/sqlite/record-projectors.d.ts +3 -44
- package/dist/store/sqlite/record-projectors.js +7 -67
- package/dist/store/sqlite/record-relations.d.ts +24 -0
- package/dist/store/sqlite/record-relations.js +92 -0
- package/dist/store/sqlite/record-remap.d.ts +12 -0
- package/dist/store/sqlite/record-remap.js +92 -0
- package/dist/store/sqlite/record-run.d.ts +71 -0
- package/dist/store/sqlite/record-run.js +179 -0
- package/dist/store/sqlite/record-settling.d.ts +9 -0
- package/dist/store/sqlite/record-settling.js +74 -0
- package/dist/store/sqlite/record-stamps.d.ts +13 -0
- package/dist/store/sqlite/record-stamps.js +30 -0
- package/dist/store/sqlite/record-writes.d.ts +43 -0
- package/dist/store/sqlite/record-writes.js +307 -0
- package/dist/store/sqlite/records.d.ts +52 -42
- package/dist/store/sqlite/records.js +123 -353
- package/dist/store/sqlite/ref-summaries.d.ts +6 -5
- package/dist/store/sqlite/ref-summaries.js +60 -8
- package/dist/store/sqlite/refunds.d.ts +31 -0
- package/dist/store/sqlite/refunds.js +112 -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/reviewed.d.ts +109 -0
- package/dist/store/sqlite/reviewed.js +173 -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 +2769 -306
- package/dist/store/sqlite/schema.js +258 -25
- package/dist/store/sqlite/source-review-marks.d.ts +54 -0
- package/dist/store/sqlite/source-review-marks.js +143 -0
- package/dist/store/sqlite/source-review.d.ts +54 -0
- package/dist/store/sqlite/source-review.js +221 -0
- package/dist/store/sqlite/stage-amounts.d.ts +14 -0
- package/dist/store/sqlite/stage-amounts.js +23 -0
- package/dist/store/sqlite/subscriptions.d.ts +135 -0
- package/dist/store/sqlite/subscriptions.js +294 -0
- package/dist/store/sqlite/text-input.d.ts +3 -0
- package/dist/store/sqlite/text-input.js +13 -0
- package/dist/store/sqlite/things.js +2 -9
- package/dist/store/sqlite/transaction.d.ts +15 -0
- package/dist/store/sqlite/transaction.js +57 -0
- package/dist/store/sqlite/wallets.d.ts +88 -0
- package/dist/store/sqlite/wallets.js +143 -0
- package/dist/store/store-errors.d.ts +1 -0
- package/dist/store/store-errors.js +45 -0
- package/dist/store/store.d.ts +19 -1
- package/dist/store/store.js +35 -6
- package/package.json +6 -3
- package/schemas/examples/records-business.jsonl +11 -0
- package/schemas/records-envelope.v1.schema.json +1160 -5
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { typedPhone } from "./mentions.js";
|
|
3
|
+
import { WORD_BODY } from "./record-types.js";
|
|
4
|
+
const MAX_ID = 512;
|
|
5
|
+
const AS_WORD = new RegExp(`^${WORD_BODY}$`);
|
|
6
|
+
/** Whether a file is a vCard address book rather than a JSON or JSONL envelope. */
|
|
7
|
+
export const isVcard = (text) => /^?\s*BEGIN:VCARD\b/i.test(text);
|
|
8
|
+
const isQuotedPrintable = (line) => {
|
|
9
|
+
const colon = line.indexOf(":");
|
|
10
|
+
return /;(ENCODING=)?QUOTED-PRINTABLE\b/i.test(colon < 0 ? line : line.slice(0, colon));
|
|
11
|
+
};
|
|
12
|
+
const PROPERTY_START = /^([A-Za-z0-9-]+\.)?[A-Za-z][A-Za-z0-9-]*(;[^:]*)?:/;
|
|
13
|
+
const isSoft = (line) => line !== undefined && isQuotedPrintable(line) && line.endsWith("=");
|
|
14
|
+
/**
|
|
15
|
+
* Joins folded lines (RFC 6350 3.2) and quoted-printable soft breaks, which vCard 2.1 writes without indent. A soft
|
|
16
|
+
* break never takes a card's BEGIN or END or the next property, and one with nothing after it is dropped.
|
|
17
|
+
*/
|
|
18
|
+
const unfolded = (text) => {
|
|
19
|
+
const lines = [];
|
|
20
|
+
for (const raw of text.replace(/^\uFEFF/, "").split(/\r\n|\r|\n/)) {
|
|
21
|
+
const last = lines.length - 1;
|
|
22
|
+
const previous = lines[last];
|
|
23
|
+
const bounds = /^(BEGIN|END):/i.test(raw);
|
|
24
|
+
// A soft break's next line is encoded text; one that reads as `NAME[;params]:` starts the next property.
|
|
25
|
+
if (isSoft(previous) && !bounds && !PROPERTY_START.test(raw))
|
|
26
|
+
lines[last] = previous.slice(0, -1) + raw.replace(/^[ \t]/, "");
|
|
27
|
+
else if (previous !== undefined && /^[ \t]/.test(raw) && !bounds)
|
|
28
|
+
lines[last] = previous + raw.slice(1);
|
|
29
|
+
else {
|
|
30
|
+
if (isSoft(previous))
|
|
31
|
+
lines[last] = previous.slice(0, -1);
|
|
32
|
+
lines.push(raw);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const last = lines.length - 1;
|
|
36
|
+
if (isSoft(lines[last]))
|
|
37
|
+
lines[last] = lines[last].slice(0, -1);
|
|
38
|
+
return lines.filter((line) => line.trim() !== "");
|
|
39
|
+
};
|
|
40
|
+
/** Splits at the first `:` outside a quoted parameter value. */
|
|
41
|
+
const propertyOf = (line) => {
|
|
42
|
+
let quoted = false;
|
|
43
|
+
let colon = -1;
|
|
44
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
45
|
+
if (line[index] === '"')
|
|
46
|
+
quoted = !quoted;
|
|
47
|
+
else if (line[index] === ":" && !quoted) {
|
|
48
|
+
colon = index;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (colon < 0)
|
|
53
|
+
return undefined;
|
|
54
|
+
const [head = "", ...rest] = line.slice(0, colon).split(";");
|
|
55
|
+
const params = new Map();
|
|
56
|
+
for (const part of rest) {
|
|
57
|
+
const equals = part.indexOf("=");
|
|
58
|
+
// vCard 2.1 writes a bare type or encoding: `TEL;CELL;VOICE`, `;QUOTED-PRINTABLE`.
|
|
59
|
+
const key = equals < 0 ? (/^(QUOTED-PRINTABLE|BASE64|8BIT|7BIT|B)$/i.test(part) ? "ENCODING" : "TYPE") : part.slice(0, equals);
|
|
60
|
+
const values = (equals < 0 ? part : part.slice(equals + 1)).replaceAll('"', "").split(",");
|
|
61
|
+
params.set(key.toUpperCase(), [...(params.get(key.toUpperCase()) ?? []), ...values.map((one) => one.toUpperCase())]);
|
|
62
|
+
}
|
|
63
|
+
const name = head.replace(/^[^.]*\./, "").toUpperCase();
|
|
64
|
+
return { name, params, value: line.slice(colon + 1) };
|
|
65
|
+
};
|
|
66
|
+
const encoder = new TextEncoder();
|
|
67
|
+
const decoded = (property, report) => {
|
|
68
|
+
const encoding = property.params.get("ENCODING")?.[0];
|
|
69
|
+
if (encoding !== "QUOTED-PRINTABLE")
|
|
70
|
+
return property.value;
|
|
71
|
+
const bytes = [];
|
|
72
|
+
const { value } = property;
|
|
73
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
74
|
+
const hex = value.slice(index + 1, index + 3);
|
|
75
|
+
if (value[index] === "=" && /^[0-9A-F]{2}$/i.test(hex)) {
|
|
76
|
+
bytes.push(Number.parseInt(hex, 16));
|
|
77
|
+
index += 2;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
for (const byte of encoder.encode(value[index]))
|
|
81
|
+
bytes.push(byte);
|
|
82
|
+
}
|
|
83
|
+
const charset = property.params.get("CHARSET")?.[0]?.toLowerCase() ?? "utf-8";
|
|
84
|
+
try {
|
|
85
|
+
return new TextDecoder(charset).decode(new Uint8Array(bytes));
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
report(`${property.name} names the unknown charset ${charset}: read as UTF-8`);
|
|
89
|
+
return new TextDecoder("utf-8").decode(new Uint8Array(bytes));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/** The value's components (`N`, `ORG`), each with vCard 3.0/4.0's backslash escapes undone. */
|
|
93
|
+
const components = (value) => {
|
|
94
|
+
const parts = [""];
|
|
95
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
96
|
+
const char = value[index];
|
|
97
|
+
if (char === "\\" && index + 1 < value.length) {
|
|
98
|
+
const next = value[index + 1];
|
|
99
|
+
parts[parts.length - 1] += next === "n" || next === "N" ? "\n" : next;
|
|
100
|
+
index += 1;
|
|
101
|
+
}
|
|
102
|
+
else if (char === ";")
|
|
103
|
+
parts.push("");
|
|
104
|
+
else
|
|
105
|
+
parts[parts.length - 1] += char;
|
|
106
|
+
}
|
|
107
|
+
return parts.map((part) => part.trim());
|
|
108
|
+
};
|
|
109
|
+
const textOf = (property, report) => components(decoded(property, report)).join(";").trim();
|
|
110
|
+
/** E.164, or `undefined` when the number has no country of its own and none is given. */
|
|
111
|
+
const e164 = (typed, region) => {
|
|
112
|
+
const text = typed.replace(/^tel:/i, "").replace(/;.*$/, "").trim();
|
|
113
|
+
const international = /^(\+|00)/.test(text);
|
|
114
|
+
if (!international && region === undefined)
|
|
115
|
+
return undefined;
|
|
116
|
+
const value = typedPhone(text, region === undefined ? {} : { phoneCountries: [region] })?.value;
|
|
117
|
+
return value?.startsWith("+") ? value : undefined;
|
|
118
|
+
};
|
|
119
|
+
const foldedName = (name) => name.normalize("NFKC").toLowerCase().replace(/\s+/g, " ").trim();
|
|
120
|
+
const hashed = (prefix, parts) => `${prefix}${createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 32)}`;
|
|
121
|
+
const organizationId = (name) => {
|
|
122
|
+
const id = `org:${foldedName(name)}`;
|
|
123
|
+
return id.length <= MAX_ID ? id : hashed("org:", [foldedName(name)]);
|
|
124
|
+
};
|
|
125
|
+
const titleWord = (title) => {
|
|
126
|
+
const word = title.toLowerCase().trim().replace(/\s+/g, "-");
|
|
127
|
+
return AS_WORD.test(word) ? word : undefined;
|
|
128
|
+
};
|
|
129
|
+
const nameOf = (properties, report) => {
|
|
130
|
+
const full = properties.find(({ name }) => name === "FN");
|
|
131
|
+
const text = full ? textOf(full, report) : "";
|
|
132
|
+
if (text)
|
|
133
|
+
return text;
|
|
134
|
+
const structured = properties.find(({ name }) => name === "N");
|
|
135
|
+
if (!structured)
|
|
136
|
+
return undefined;
|
|
137
|
+
const [family = "", given = "", additional = ""] = components(decoded(structured, report));
|
|
138
|
+
return [given, additional, family].filter(Boolean).join(" ") || undefined;
|
|
139
|
+
};
|
|
140
|
+
const SKIPPED = new Set(["PHOTO", "LOGO", "SOUND", "KEY"]);
|
|
141
|
+
/** The cards, each kept even when its END is missing; what was cut off is reported, never dropped quietly. */
|
|
142
|
+
const cardsOf = (text) => {
|
|
143
|
+
const cards = [];
|
|
144
|
+
const issues = [];
|
|
145
|
+
let card;
|
|
146
|
+
const isBound = (property, name) => property.name === name && property.value.trim().toUpperCase() === "VCARD";
|
|
147
|
+
for (const line of unfolded(text)) {
|
|
148
|
+
const property = propertyOf(line);
|
|
149
|
+
if (!property)
|
|
150
|
+
continue;
|
|
151
|
+
if (isBound(property, "BEGIN")) {
|
|
152
|
+
if (card) {
|
|
153
|
+
issues.push({ card: cards.length, message: "BEGIN:VCARD inside a card: the card ends there, unfinished" });
|
|
154
|
+
cards.push(card);
|
|
155
|
+
}
|
|
156
|
+
card = [];
|
|
157
|
+
}
|
|
158
|
+
else if (isBound(property, "END")) {
|
|
159
|
+
if (card)
|
|
160
|
+
cards.push(card);
|
|
161
|
+
card = undefined;
|
|
162
|
+
}
|
|
163
|
+
else if (card && !SKIPPED.has(property.name))
|
|
164
|
+
card.push(property);
|
|
165
|
+
}
|
|
166
|
+
if (card) {
|
|
167
|
+
issues.push({ card: cards.length, message: "the file ends inside a card, with no END:VCARD" });
|
|
168
|
+
cards.push(card);
|
|
169
|
+
}
|
|
170
|
+
return { cards, issues };
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* A vCard file (2.1, 3.0 or 4.0) as a records envelope: one person per card, matched later by its numbers and
|
|
174
|
+
* addresses, and one organization per `ORG` name the person is a member of. Nothing is guessed: a national number
|
|
175
|
+
* is read only in `region`, and a card says nothing about a person it does not hold.
|
|
176
|
+
*/
|
|
177
|
+
export const envelopeOfVcard = (text, { provider, account, batchId, region }) => {
|
|
178
|
+
const { cards, issues } = cardsOf(text);
|
|
179
|
+
const people = [];
|
|
180
|
+
const organizations = new Map();
|
|
181
|
+
const seen = new Set();
|
|
182
|
+
for (const [index, properties] of cards.entries()) {
|
|
183
|
+
const report = (message) => {
|
|
184
|
+
if (!issues.some((one) => one.card === index && one.message === message))
|
|
185
|
+
issues.push({ card: index, message });
|
|
186
|
+
};
|
|
187
|
+
const values = (wanted) => properties
|
|
188
|
+
.filter(({ name }) => name === wanted)
|
|
189
|
+
.map((one) => textOf(one, report))
|
|
190
|
+
.filter(Boolean);
|
|
191
|
+
const name = nameOf(properties, report);
|
|
192
|
+
const phones = [];
|
|
193
|
+
const unread = [];
|
|
194
|
+
for (const typed of values("TEL")) {
|
|
195
|
+
const value = e164(typed, region);
|
|
196
|
+
if (value !== undefined) {
|
|
197
|
+
if (!phones.includes(value))
|
|
198
|
+
phones.push(value);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
unread.push(typed);
|
|
202
|
+
issues.push({
|
|
203
|
+
card: index,
|
|
204
|
+
message: `${typed} has no country code${region === undefined ? " and no region was given" : ` in ${region}`}: kept, not matched`,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const emails = [...new Set(values("EMAIL").map((one) => one.replace(/^mailto:/i, "").toLowerCase()))];
|
|
209
|
+
if (name === undefined && phones.length === 0 && unread.length === 0 && emails.length === 0) {
|
|
210
|
+
report("the card holds no name, number or address: left out");
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const uid = values("UID")[0];
|
|
214
|
+
// A cut UID would make two long ones the same record; hashed, as an organization's long name is.
|
|
215
|
+
const externalId = uid === undefined
|
|
216
|
+
? hashed("vcard:", [name ?? "", ...[...phones].sort(), ...emails.sort()])
|
|
217
|
+
: uid.length <= MAX_ID
|
|
218
|
+
? uid
|
|
219
|
+
: hashed("vcard:", [uid]);
|
|
220
|
+
if (seen.has(externalId)) {
|
|
221
|
+
issues.push({ card: index, message: `another card of the file is ${externalId}: left out` });
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
seen.add(externalId);
|
|
225
|
+
const organization = properties.find(({ name }) => name === "ORG");
|
|
226
|
+
const organizationName = organization ? components(decoded(organization, report))[0] : undefined;
|
|
227
|
+
const title = values("TITLE")[0];
|
|
228
|
+
const relations = [];
|
|
229
|
+
if (organizationName) {
|
|
230
|
+
const id = organizationId(organizationName);
|
|
231
|
+
if (!organizations.has(id))
|
|
232
|
+
organizations.set(id, {
|
|
233
|
+
key: id,
|
|
234
|
+
type: "organization",
|
|
235
|
+
external_id: id,
|
|
236
|
+
operation: "upsert",
|
|
237
|
+
fields: { name: organizationName },
|
|
238
|
+
});
|
|
239
|
+
const as = title === undefined ? undefined : titleWord(title);
|
|
240
|
+
relations.push({ role: "member-of", type: "organization", external_id: id, ...(as ? { as } : {}) });
|
|
241
|
+
}
|
|
242
|
+
people.push({
|
|
243
|
+
key: `person:${externalId}`,
|
|
244
|
+
type: "person",
|
|
245
|
+
external_id: externalId,
|
|
246
|
+
operation: "upsert",
|
|
247
|
+
fields: {
|
|
248
|
+
...(name === undefined ? {} : { name }),
|
|
249
|
+
...(phones.length ? { phone: phones } : {}),
|
|
250
|
+
...(emails.length ? { email: emails } : {}),
|
|
251
|
+
...(unread.length ? { phone_unread: unread } : {}),
|
|
252
|
+
...(organizationName ? { organization: organizationName } : {}),
|
|
253
|
+
...(title === undefined ? {} : { title }),
|
|
254
|
+
},
|
|
255
|
+
...(relations.length ? { relations } : {}),
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
envelope: {
|
|
260
|
+
schema_version: 1,
|
|
261
|
+
source: { provider, account, batch_id: batchId },
|
|
262
|
+
...(region === undefined ? {} : { options: { phone_region: region } }),
|
|
263
|
+
records: [...organizations.values(), ...people],
|
|
264
|
+
},
|
|
265
|
+
issues,
|
|
266
|
+
};
|
|
267
|
+
};
|
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>;
|
|
@@ -145,6 +145,13 @@ export declare const pipeline: v.StrictObjectSchema<{
|
|
|
145
145
|
/** With a funnel: rows that got this far, and the share of them that reached the next stage. */
|
|
146
146
|
readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
147
147
|
readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
148
|
+
/** With a funnel: rows standing in it now, and their sum per currency, never converted. */
|
|
149
|
+
readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
150
|
+
readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
151
|
+
readonly amount: v.StringSchema<undefined>;
|
|
152
|
+
readonly currency: v.StringSchema<undefined>;
|
|
153
|
+
readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
154
|
+
}, undefined>, undefined>, undefined>;
|
|
148
155
|
}, undefined>, undefined>;
|
|
149
156
|
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`">]>;
|
|
150
157
|
readonly totals: v.OptionalSchema<v.StrictObjectSchema<{
|
|
@@ -168,6 +175,13 @@ export declare const stage: v.StrictObjectSchema<{
|
|
|
168
175
|
/** With a funnel: rows that got this far, and the share of them that reached the next stage. */
|
|
169
176
|
readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
170
177
|
readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
178
|
+
/** With a funnel: rows standing in it now, and their sum per currency, never converted. */
|
|
179
|
+
readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
180
|
+
readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
181
|
+
readonly amount: v.StringSchema<undefined>;
|
|
182
|
+
readonly currency: v.StringSchema<undefined>;
|
|
183
|
+
readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
184
|
+
}, undefined>, undefined>, undefined>;
|
|
171
185
|
readonly pipeline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
172
186
|
readonly pipeline_name: v.StringSchema<undefined>;
|
|
173
187
|
readonly kind: v.PicklistSchema<["deal", "lead"], 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,
|
|
@@ -69,6 +70,9 @@ const pipelineStage = v.strictObject({
|
|
|
69
70
|
/** With a funnel: rows that got this far, and the share of them that reached the next stage. */
|
|
70
71
|
reached: v.optional(count),
|
|
71
72
|
conversion: v.optional(v.nullable(v.number())),
|
|
73
|
+
/** With a funnel: rows standing in it now, and their sum per currency, never converted. */
|
|
74
|
+
items: v.optional(count),
|
|
75
|
+
amounts: v.optional(v.array(v.strictObject({ amount: text, currency: text, items: count }))),
|
|
72
76
|
});
|
|
73
77
|
/** A pipeline (`pipeline:<id>`) with its stages in order; `pipelines show` adds the funnel. */
|
|
74
78
|
export const pipeline = v.strictObject({
|
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>;
|
|
@@ -363,6 +363,12 @@ export declare const ENTITIES: {
|
|
|
363
363
|
readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
364
364
|
readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
365
365
|
readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
366
|
+
readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
367
|
+
readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
368
|
+
readonly amount: v.StringSchema<undefined>;
|
|
369
|
+
readonly currency: v.StringSchema<undefined>;
|
|
370
|
+
readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
371
|
+
}, undefined>, undefined>, undefined>;
|
|
366
372
|
}, undefined>, undefined>;
|
|
367
373
|
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`">]>;
|
|
368
374
|
readonly totals: v.OptionalSchema<v.StrictObjectSchema<{
|
|
@@ -383,6 +389,12 @@ export declare const ENTITIES: {
|
|
|
383
389
|
readonly open: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
384
390
|
readonly reached: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
385
391
|
readonly conversion: v.OptionalSchema<v.NullableSchema<v.NumberSchema<undefined>, undefined>, undefined>;
|
|
392
|
+
readonly items: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>;
|
|
393
|
+
readonly amounts: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
|
|
394
|
+
readonly amount: v.StringSchema<undefined>;
|
|
395
|
+
readonly currency: v.StringSchema<undefined>;
|
|
396
|
+
readonly items: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
397
|
+
}, undefined>, undefined>, undefined>;
|
|
386
398
|
readonly pipeline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
387
399
|
readonly pipeline_name: v.StringSchema<undefined>;
|
|
388
400
|
readonly kind: v.PicklistSchema<["deal", "lead"], undefined>;
|
|
@@ -4608,7 +4620,7 @@ export declare const ENTITIES: {
|
|
|
4608
4620
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4609
4621
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4610
4622
|
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>;
|
|
4623
|
+
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
4624
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4613
4625
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4614
4626
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4623,7 +4635,7 @@ export declare const ENTITIES: {
|
|
|
4623
4635
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4624
4636
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4625
4637
|
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>;
|
|
4638
|
+
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
4639
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4628
4640
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4629
4641
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4724,7 +4736,7 @@ export declare const ENTITIES: {
|
|
|
4724
4736
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4725
4737
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4726
4738
|
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>;
|
|
4739
|
+
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
4740
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4729
4741
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4730
4742
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4739,7 +4751,7 @@ export declare const ENTITIES: {
|
|
|
4739
4751
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4740
4752
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4741
4753
|
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>;
|
|
4754
|
+
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
4755
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4744
4756
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4745
4757
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4841,7 +4853,7 @@ export declare const ENTITIES: {
|
|
|
4841
4853
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4842
4854
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4843
4855
|
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>;
|
|
4856
|
+
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
4857
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4846
4858
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4847
4859
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4856,7 +4868,7 @@ export declare const ENTITIES: {
|
|
|
4856
4868
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4857
4869
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4858
4870
|
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>;
|
|
4871
|
+
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
4872
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4861
4873
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4862
4874
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -4986,7 +4998,7 @@ export declare const ENTITIES: {
|
|
|
4986
4998
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
4987
4999
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
4988
5000
|
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>;
|
|
5001
|
+
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
5002
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
4991
5003
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
4992
5004
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5001,7 +5013,7 @@ export declare const ENTITIES: {
|
|
|
5001
5013
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5002
5014
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5003
5015
|
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>;
|
|
5016
|
+
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
5017
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5006
5018
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5007
5019
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5096,7 +5108,7 @@ export declare const ENTITIES: {
|
|
|
5096
5108
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5097
5109
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5098
5110
|
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>;
|
|
5111
|
+
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
5112
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5101
5113
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5102
5114
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -5111,7 +5123,7 @@ export declare const ENTITIES: {
|
|
|
5111
5123
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
5112
5124
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
5113
5125
|
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>;
|
|
5126
|
+
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
5127
|
readonly anchor: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
5116
5128
|
readonly origin: v.PicklistSchema<readonly ["file", "owner", "suggested", "message", "calendar"], undefined>;
|
|
5117
5129
|
readonly target_text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -6607,13 +6619,17 @@ export declare const ENTITIES: {
|
|
|
6607
6619
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
6608
6620
|
readonly from: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
6609
6621
|
readonly to: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a reference such as `note:42`">]>;
|
|
6610
|
-
readonly kind: v.PicklistSchema<
|
|
6622
|
+
readonly kind: v.PicklistSchema<("customer-of" | "member-of" | "partner-of" | "related-to" | "reports-to")[], undefined>;
|
|
6611
6623
|
readonly role: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6612
6624
|
readonly purpose: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6613
6625
|
readonly evidence: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6614
6626
|
readonly confirmed: v.BooleanSchema<undefined>;
|
|
6615
6627
|
readonly provenance: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6616
6628
|
readonly confidence_category: v.PicklistSchema<["owner-confirmed", "weak"], undefined>;
|
|
6629
|
+
readonly standing: v.PicklistSchema<readonly ["confirmed", "reported", "proposed", "ended"], undefined>;
|
|
6630
|
+
readonly position: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
6631
|
+
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>;
|
|
6632
|
+
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
6633
|
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
6634
|
}, undefined>;
|
|
6619
6635
|
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
|
});
|