@wirecat/cli-core 0.648.0 → 0.650.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 +97 -0
- package/dist/analysis/anthropic.js +2 -1
- package/dist/background/daily-archive-timer.d.ts +1 -1
- package/dist/cli/account-remove.d.ts +2 -0
- package/dist/cli/account-remove.js +46 -10
- package/dist/cli/messenger/messages-search-command.js +6 -1
- package/dist/cli/messenger/search-answers.d.ts +3 -1
- package/dist/cli/messenger/search-answers.js +3 -1
- package/dist/cli/steps.js +9 -0
- package/dist/cli/unknown-profile.js +1 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/index.js +14 -0
- package/dist/crm/cli/index.js +30 -5
- package/dist/crm/source.d.ts +8 -1
- package/dist/crm/stage-tasks.d.ts +3 -1
- package/dist/crm/stage-tasks.js +8 -4
- package/dist/crm/sync.d.ts +1 -1
- package/dist/crm/sync.js +54 -0
- package/dist/domain/crm.d.ts +15 -0
- package/dist/domain/phones.d.ts +2 -0
- package/dist/domain/phones.js +3 -0
- package/dist/domain/providers.d.ts +4 -1
- package/dist/domain/providers.js +9 -2
- package/dist/domain/record-types.d.ts +24 -3
- package/dist/domain/record-types.js +23 -2
- package/dist/domain/records-table.js +4 -3
- package/dist/domain/records.d.ts +1 -1
- package/dist/domain/records.js +3 -2
- package/dist/entities/contact-context.d.ts +6 -0
- package/dist/entities/contact-context.js +3 -0
- package/dist/entities/deal.d.ts +4 -0
- package/dist/entities/deal.js +3 -0
- package/dist/entities/index.d.ts +12 -0
- package/dist/entities/recorded-meeting.d.ts +17 -0
- package/dist/entities/recorded-meeting.js +15 -0
- package/dist/errors/reasons.js +3 -4
- package/dist/index.d.ts +1 -1
- package/dist/meetings/answers.d.ts +5 -0
- package/dist/meetings/answers.js +3 -0
- package/dist/meetings/index.d.ts +1 -1
- package/dist/meetings/participant-search.d.ts +5 -0
- package/dist/meetings/pull.js +2 -1
- package/dist/meetings/read-answers.d.ts +4 -0
- package/dist/meetings/read-answers.js +1 -0
- package/dist/meetings/source.d.ts +5 -0
- package/dist/meetings/store.d.ts +10 -1
- package/dist/models/ai.js +2 -2
- package/dist/models/endpoint.d.ts +7 -0
- package/dist/models/endpoint.js +10 -0
- package/dist/models/index.js +2 -2
- package/dist/oauth/keeper.js +1 -1
- package/dist/sends/guard.js +8 -6
- package/dist/services/communications.d.ts +2 -2
- package/dist/services/communications.js +24 -2
- package/dist/services/document-source.js +9 -1
- package/dist/services/meeting-model.js +2 -1
- package/dist/services/notes-search.d.ts +10 -5
- package/dist/services/notes-search.js +19 -7
- package/dist/services/person-context.d.ts +3 -0
- package/dist/services/person-context.js +9 -1
- package/dist/services/person-meetings.d.ts +36 -0
- package/dist/services/person-meetings.js +57 -0
- package/dist/services/search-all.js +18 -10
- package/dist/speech/openai.js +5 -2
- package/dist/store/sqlite/added-sources.d.ts +38 -0
- package/dist/store/sqlite/added-sources.js +80 -50
- package/dist/store/sqlite/crm-settings.d.ts +5 -1
- package/dist/store/sqlite/crm-settings.js +8 -0
- package/dist/store/sqlite/crm-stage-entries.d.ts +15 -0
- package/dist/store/sqlite/crm-stage-entries.js +74 -0
- package/dist/store/sqlite/crm.d.ts +8 -1
- package/dist/store/sqlite/crm.js +7 -1
- package/dist/store/sqlite/identities.js +3 -1
- package/dist/store/sqlite/involvements.d.ts +2 -0
- package/dist/store/sqlite/involvements.js +4 -1
- package/dist/store/sqlite/meeting-participant-search.js +9 -3
- package/dist/store/sqlite/meetings.js +7 -2
- package/dist/store/sqlite/person-match-scan.js +39 -15
- package/dist/store/sqlite/record-projectors-document.d.ts +12 -0
- package/dist/store/sqlite/record-projectors-document.js +81 -0
- package/dist/store/sqlite/record-projectors.js +2 -0
- package/dist/update/index.d.ts +1 -1
- package/dist/update/index.js +4 -2
- package/package.json +1 -1
- package/schemas/records-envelope.v1.schema.json +57 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { documentWritesOver } from "./added-sources.js";
|
|
2
|
+
import { linkKind } from "./link-kinds.js";
|
|
3
|
+
import { requiredThing } from "./notes.js";
|
|
4
|
+
import { given } from "./record-projection.js";
|
|
5
|
+
const TEXT_ONLY = { storage: "text", localPath: null };
|
|
6
|
+
const textOf = ({ fields, externalId }) => {
|
|
7
|
+
const text = String(fields.text ?? "");
|
|
8
|
+
return {
|
|
9
|
+
kind: "text",
|
|
10
|
+
title: given(fields, "title") ?? externalId.slice(0, 500),
|
|
11
|
+
fileName: null,
|
|
12
|
+
extension: null,
|
|
13
|
+
url: given(fields, "url") ?? null,
|
|
14
|
+
mime: null,
|
|
15
|
+
size: null,
|
|
16
|
+
hash: null,
|
|
17
|
+
text,
|
|
18
|
+
extraction: text ? "text" : "none",
|
|
19
|
+
metadata: null,
|
|
20
|
+
language: null,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const momentOf = (fields, name) => {
|
|
24
|
+
const at = Date.parse(given(fields, name) ?? "");
|
|
25
|
+
return Number.isNaN(at) ? null : at;
|
|
26
|
+
};
|
|
27
|
+
/** The import's own `about` links, written again from the record each time; the owner's stay as they are. */
|
|
28
|
+
const relinkAbout = ({ database, now }, id, subjects) => {
|
|
29
|
+
database
|
|
30
|
+
.prepare(`DELETE FROM links WHERE from_type = 'document' AND from_id = ? AND kind = ${linkKind("about")} AND source = 'import'`)
|
|
31
|
+
.run(id);
|
|
32
|
+
const at = now();
|
|
33
|
+
for (const subject of subjects) {
|
|
34
|
+
const thing = requiredThing(database, subject, "a subject");
|
|
35
|
+
database
|
|
36
|
+
.prepare(`INSERT OR IGNORE INTO links (from_type, from_id, to_type, to_id, kind, source, confirmed, created_at, author,
|
|
37
|
+
updated_at) VALUES ('document', ?, ?, ?, ${linkKind("about")}, 'import', 1, ?, 'import', ?)`)
|
|
38
|
+
.run(id, thing.type, thing.id, at, at);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** A document of the envelope's own account under the record's external id: changed text is its next revision. */
|
|
42
|
+
const saveDocument = (projection, { context }) => {
|
|
43
|
+
const { database } = context;
|
|
44
|
+
const writes = documentWritesOver(context);
|
|
45
|
+
const document = textOf(projection);
|
|
46
|
+
const at = context.now();
|
|
47
|
+
const own = database
|
|
48
|
+
.prepare("SELECT * FROM documents WHERE account_id = ? AND external_id = ?")
|
|
49
|
+
.get(projection.accountId, projection.externalId);
|
|
50
|
+
let id;
|
|
51
|
+
if (own === undefined)
|
|
52
|
+
id = writes.insert(projection.accountId, projection.externalId, document, TEXT_ONLY, at);
|
|
53
|
+
else {
|
|
54
|
+
id = Number(own.id);
|
|
55
|
+
if (own.deleted_at != null)
|
|
56
|
+
writes.revive(id, document, TEXT_ONLY, at);
|
|
57
|
+
else
|
|
58
|
+
writes.update(own, document, at, String(own.body ?? "") !== document.text);
|
|
59
|
+
}
|
|
60
|
+
database
|
|
61
|
+
.prepare("UPDATE documents SET external_created_at = ?, external_updated_at = ? WHERE id = ?")
|
|
62
|
+
.run(momentOf(projection.fields, "created_at"), momentOf(projection.fields, "updated_at"), id);
|
|
63
|
+
writes.place(id, at, document.title ?? projection.externalId);
|
|
64
|
+
relinkAbout(context, id, projection.related.get("about") ?? []);
|
|
65
|
+
return `document:${id}`;
|
|
66
|
+
};
|
|
67
|
+
export const DOCUMENT_PROJECTORS = {
|
|
68
|
+
document: {
|
|
69
|
+
create: saveDocument,
|
|
70
|
+
update: (_ref, projection, tools) => {
|
|
71
|
+
saveDocument(projection, tools);
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
remove: (ref, { context }) => {
|
|
75
|
+
documentWritesOver(context).remove(requiredThing(context.database, ref).id, context.now());
|
|
76
|
+
},
|
|
77
|
+
restore: (_ref, projection, tools) => {
|
|
78
|
+
saveDocument(projection, tools);
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DIRECT_PROJECTORS } from "./record-projectors-direct.js";
|
|
2
|
+
import { DOCUMENT_PROJECTORS } from "./record-projectors-document.js";
|
|
2
3
|
import { MONEY_PROJECTORS } from "./record-projectors-money.js";
|
|
3
4
|
import { PHONE_PROJECTORS } from "./record-projectors-phone.js";
|
|
4
5
|
/** One projector per registered type; `null` for the types whose entity is matched or made from identifiers. */
|
|
@@ -6,6 +7,7 @@ export const RECORD_PROJECTORS = {
|
|
|
6
7
|
...MONEY_PROJECTORS,
|
|
7
8
|
...DIRECT_PROJECTORS,
|
|
8
9
|
...PHONE_PROJECTORS,
|
|
10
|
+
...DOCUMENT_PROJECTORS,
|
|
9
11
|
person: null,
|
|
10
12
|
organization: null,
|
|
11
13
|
project: null,
|
package/dist/update/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FetchLike } from "@wirecat/cli-base/http";
|
|
2
2
|
import { type Installer } from "@wirecat/cli-base/update";
|
|
3
3
|
/** npm, the clock, the terminal and the package manager as `<app> upgrade` sees them — faked in a test. */
|
|
4
4
|
export interface UpdateEnvironment {
|
package/dist/update/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { realpathSync } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { hostFetch } from "@wirecat/cli-base/http";
|
|
3
4
|
import { installerOf, latestVersion, runUpdate as runPackageManager, updateNotice as sharedNotice, } from "@wirecat/cli-base/update";
|
|
5
|
+
const npmRegistry = () => hostFetch({ hosts: ["registry.npmjs.org"] });
|
|
4
6
|
/** Words after which a line on stderr would land in a machine's answer, or would only repeat the command. */
|
|
5
7
|
export const QUIET_WORDS = [
|
|
6
8
|
"--help",
|
|
@@ -27,7 +29,7 @@ export const appUpdate = (app) => {
|
|
|
27
29
|
};
|
|
28
30
|
return {
|
|
29
31
|
installer,
|
|
30
|
-
latest: (environment = {}) => latestVersion(app.packageName, environment.fetch ??
|
|
32
|
+
latest: (environment = {}) => latestVersion(app.packageName, environment.fetch ?? npmRegistry(), { timeoutMs: 3000 }),
|
|
31
33
|
/** The package manager's output goes to stderr, so stdout stays one result. */
|
|
32
34
|
runUpdate: (argv, environment = {}) => environment.spawn ? environment.spawn(argv) : runPackageManager(argv),
|
|
33
35
|
/**
|
|
@@ -48,7 +50,7 @@ export const appUpdate = (app) => {
|
|
|
48
50
|
command: app.command,
|
|
49
51
|
version: app.version,
|
|
50
52
|
statePath: app.statePath(env),
|
|
51
|
-
fetch: environment.fetch ??
|
|
53
|
+
fetch: environment.fetch ?? npmRegistry(),
|
|
52
54
|
...(environment.now ? { now: environment.now } : {}),
|
|
53
55
|
format: pretty ? "pretty" : "json",
|
|
54
56
|
stderrIsTTY: environment.stderrIsTTY ?? process.stderr.isTTY === true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.650.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"type": {
|
|
76
76
|
"type": "string",
|
|
77
|
-
"pattern": "^(invoice|payment|person|organization|project|order|product|contract|subscription|wallet|transaction|deal|lead|message|event|pipeline|custom:[a-z0-9][a-z0-9_-]{0,62})$"
|
|
77
|
+
"pattern": "^(invoice|payment|person|organization|project|order|product|contract|subscription|wallet|transaction|deal|lead|message|event|document|pipeline|custom:[a-z0-9][a-z0-9_-]{0,62})$"
|
|
78
78
|
},
|
|
79
79
|
"external_id": {
|
|
80
80
|
"type": "string",
|
|
@@ -357,6 +357,23 @@
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
|
+
{
|
|
361
|
+
"if": {
|
|
362
|
+
"properties": {
|
|
363
|
+
"type": {
|
|
364
|
+
"const": "document"
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
"required": ["type"]
|
|
368
|
+
},
|
|
369
|
+
"then": {
|
|
370
|
+
"properties": {
|
|
371
|
+
"fields": {
|
|
372
|
+
"$ref": "#/$defs/fields-document"
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
360
377
|
{
|
|
361
378
|
"if": {
|
|
362
379
|
"properties": {
|
|
@@ -395,7 +412,7 @@
|
|
|
395
412
|
},
|
|
396
413
|
"type": {
|
|
397
414
|
"type": "string",
|
|
398
|
-
"pattern": "^(invoice|payment|person|organization|project|order|product|contract|subscription|wallet|transaction|deal|lead|message|event|pipeline|custom:[a-z0-9][a-z0-9_-]{0,62})$"
|
|
415
|
+
"pattern": "^(invoice|payment|person|organization|project|order|product|contract|subscription|wallet|transaction|deal|lead|message|event|document|pipeline|custom:[a-z0-9][a-z0-9_-]{0,62})$"
|
|
399
416
|
},
|
|
400
417
|
"external_id": {
|
|
401
418
|
"type": "string",
|
|
@@ -1215,6 +1232,44 @@
|
|
|
1215
1232
|
"required": ["kind", "direction", "phone", "started_at"],
|
|
1216
1233
|
"additionalProperties": true
|
|
1217
1234
|
},
|
|
1235
|
+
"fields-document": {
|
|
1236
|
+
"type": "object",
|
|
1237
|
+
"properties": {
|
|
1238
|
+
"title": {
|
|
1239
|
+
"type": ["string", "null"],
|
|
1240
|
+
"minLength": 1,
|
|
1241
|
+
"maxLength": 500,
|
|
1242
|
+
"description": "What the document is called; its external id when left out"
|
|
1243
|
+
},
|
|
1244
|
+
"text": {
|
|
1245
|
+
"type": "string",
|
|
1246
|
+
"maxLength": 1000000,
|
|
1247
|
+
"description": "The text search reads"
|
|
1248
|
+
},
|
|
1249
|
+
"created_at": {
|
|
1250
|
+
"type": ["string", "null"],
|
|
1251
|
+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(:[0-9]{2}(\\.[0-9]{1,9})?)?(Z|[+-][0-9]{2}:[0-9]{2})$",
|
|
1252
|
+
"description": "When the source made it"
|
|
1253
|
+
},
|
|
1254
|
+
"updated_at": {
|
|
1255
|
+
"type": ["string", "null"],
|
|
1256
|
+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(:[0-9]{2}(\\.[0-9]{1,9})?)?(Z|[+-][0-9]{2}:[0-9]{2})$",
|
|
1257
|
+
"description": "When the source last changed it: what date: reads"
|
|
1258
|
+
},
|
|
1259
|
+
"url": {
|
|
1260
|
+
"type": ["string", "null"],
|
|
1261
|
+
"minLength": 1,
|
|
1262
|
+
"maxLength": 4096,
|
|
1263
|
+
"description": "Where the original is"
|
|
1264
|
+
},
|
|
1265
|
+
"metadata": {
|
|
1266
|
+
"type": ["object", "null"],
|
|
1267
|
+
"description": "Anything else the source knows about it, kept as sent"
|
|
1268
|
+
}
|
|
1269
|
+
},
|
|
1270
|
+
"required": ["text"],
|
|
1271
|
+
"additionalProperties": true
|
|
1272
|
+
},
|
|
1218
1273
|
"fields-pipeline": {
|
|
1219
1274
|
"type": "object",
|
|
1220
1275
|
"properties": {
|