@wirecat/cli-core 0.618.0 → 0.620.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 +453 -1
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES +3 -0
- package/dist/background/deliver.d.ts +5 -2
- package/dist/background/deliver.js +30 -12
- package/dist/background/report/render.d.ts +3 -1
- package/dist/background/report/render.js +3 -1
- package/dist/calendar/cli/answers.d.ts +1 -0
- package/dist/calendar/cli/answers.js +6 -1
- package/dist/calendar/cli/index.js +2 -14
- package/dist/calendar/cli/people-link.d.ts +3 -0
- package/dist/calendar/cli/people-link.js +23 -0
- package/dist/calendar/cli/search-all.d.ts +1 -1
- package/dist/calendar/cli/search-all.js +9 -10
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +1 -1
- package/dist/calendar/mcp/index.d.ts +12 -12
- package/dist/calendar/prepare.js +1 -0
- package/dist/cli/base-stages-command.d.ts +22 -0
- package/dist/cli/base-stages-command.js +174 -0
- package/dist/cli/bot/buttons.d.ts +3 -0
- package/dist/cli/bot/buttons.js +24 -0
- package/dist/cli/bot/messages.js +14 -1
- package/dist/cli/bot/port.d.ts +8 -0
- package/dist/cli/command-runs.d.ts +2 -0
- package/dist/cli/command-runs.js +3 -1
- package/dist/cli/config-command.js +6 -1
- package/dist/cli/context.js +1 -0
- package/dist/cli/contract-templates.js +31 -2
- package/dist/cli/group-lock.d.ts +42 -0
- package/dist/cli/group-lock.js +130 -0
- package/dist/cli/index.d.ts +7 -2
- package/dist/cli/index.js +7 -2
- package/dist/cli/messenger/backfill-command.js +27 -15
- package/dist/cli/messenger/contacts-command.js +12 -4
- package/dist/cli/messenger/context.js +1 -0
- package/dist/cli/messenger/conversations-command.js +2 -1
- package/dist/cli/messenger/doctor-command.js +3 -1
- package/dist/cli/messenger/message-items.js +1 -1
- package/dist/cli/messenger/models-command.js +1 -1
- package/dist/cli/messenger/search-answers.d.ts +5 -5
- package/dist/cli/messenger/search-answers.js +9 -20
- package/dist/cli/messenger/search-command.d.ts +2 -2
- package/dist/cli/messenger/search-command.js +8 -18
- package/dist/cli/messenger/store-maintenance-command.d.ts +22 -2
- package/dist/cli/messenger/store-maintenance-command.js +9 -4
- package/dist/cli/model-catalogue-command.d.ts +3 -1
- package/dist/cli/model-catalogue-command.js +48 -2
- package/dist/cli/profile.d.ts +8 -0
- package/dist/cli/profile.js +25 -0
- package/dist/cli/program.js +2 -0
- package/dist/cli/runs/search-query.d.ts +1 -1
- package/dist/cli/runs/search-query.js +4 -0
- package/dist/cli/runs/search.d.ts +5 -1
- package/dist/cli/runs/search.js +12 -1
- package/dist/cli/search-harder-consents-command.d.ts +18 -0
- package/dist/cli/search-harder-consents-command.js +83 -0
- package/dist/cli/search-left-out.d.ts +6 -1
- package/dist/cli/search-left-out.js +9 -4
- package/dist/cli/settings.d.ts +8 -0
- package/dist/cli/settings.js +17 -2
- package/dist/cli/shared-command-exports.d.ts +16 -0
- package/dist/cli/steps.js +0 -6
- package/dist/cli/store-recover.d.ts +3 -3
- package/dist/cli/store-recover.js +26 -26
- package/dist/cli/store-settings.d.ts +2 -0
- package/dist/cli/store-settings.js +37 -9
- package/dist/cli/templates-command.js +4 -4
- package/dist/crm/cli/index.js +40 -8
- package/dist/crm/cli/search-all.js +7 -6
- package/dist/crm/group-hint.d.ts +8 -0
- package/dist/crm/group-hint.js +13 -0
- package/dist/crm/source.d.ts +12 -1
- package/dist/crm/sync.d.ts +31 -2
- package/dist/crm/sync.js +110 -3
- package/dist/crm/testing/acme-scenario.d.ts +40 -0
- package/dist/crm/testing/acme-scenario.js +170 -0
- package/dist/crm/testing/index.d.ts +1 -0
- package/dist/crm/testing/index.js +1 -0
- package/dist/crm/testing/source-contract.js +12 -0
- package/dist/crm/testing/source.d.ts +2 -0
- package/dist/crm/testing/source.js +1 -0
- package/dist/domain/addresses.d.ts +13 -0
- package/dist/domain/addresses.js +63 -0
- package/dist/domain/categories.d.ts +3 -0
- package/dist/domain/categories.js +2 -0
- package/dist/domain/crm.d.ts +23 -0
- package/dist/domain/crm.js +7 -0
- package/dist/domain/mentions.d.ts +2 -12
- package/dist/domain/mentions.js +2 -19
- package/dist/domain/models.d.ts +2 -0
- package/dist/domain/orders.d.ts +8 -1
- package/dist/domain/orders.js +6 -2
- package/dist/domain/phones.d.ts +26 -0
- package/dist/domain/phones.js +48 -0
- package/dist/domain/record-types.d.ts +1 -1
- package/dist/domain/record-types.js +1 -0
- package/dist/domain/records.d.ts +5 -0
- package/dist/domain/ref-summaries.d.ts +39 -0
- package/dist/domain/ref-summaries.js +51 -3
- package/dist/domain/relations.d.ts +12 -2
- package/dist/domain/relations.js +14 -3
- package/dist/domain/vcard.d.ts +2 -2
- package/dist/domain/vcard.js +4 -10
- package/dist/embeddings/models.d.ts +11 -3
- package/dist/embeddings/models.js +28 -4
- package/dist/entities/business-context.d.ts +149 -0
- package/dist/entities/business-context.js +192 -0
- package/dist/entities/contact-activity.d.ts +2 -0
- package/dist/entities/contact-activity.js +7 -1
- package/dist/entities/contact-context.d.ts +160 -0
- package/dist/entities/contact-context.js +6 -0
- package/dist/entities/deal.d.ts +10 -0
- package/dist/entities/deal.js +2 -0
- package/dist/entities/hit.d.ts +9 -2
- package/dist/entities/hit.js +6 -2
- package/dist/entities/index.d.ts +32 -4
- package/dist/entities/index.js +5 -0
- package/dist/entities/mention.d.ts +4 -3
- package/dist/entities/mention.js +2 -1
- package/dist/entities/message-transfer.d.ts +4 -2
- package/dist/entities/message-transfer.js +2 -2
- package/dist/entities/model.d.ts +2 -2
- package/dist/entities/model.js +1 -1
- package/dist/entities/relationship.d.ts +4 -0
- package/dist/entities/relationship.js +4 -0
- package/dist/errors/reasons.js +39 -4
- package/dist/fetch/page.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/meetings/context-store.d.ts +2 -0
- package/dist/meetings/findings-rules.d.ts +4 -0
- package/dist/meetings/findings-rules.js +5 -2
- package/dist/meetings/hit-query.d.ts +1 -1
- package/dist/meetings/hit-query.js +2 -2
- package/dist/meetings/index.d.ts +1 -0
- package/dist/meetings/index.js +1 -0
- package/dist/meetings/result-items.d.ts +1 -0
- package/dist/meetings/result-items.js +1 -0
- package/dist/meetings/store.d.ts +4 -0
- package/dist/meetings/store.js +2 -1
- package/dist/models/anthropic.js +5 -0
- package/dist/models/index.js +22 -5
- package/dist/runs/events.d.ts +11 -1
- package/dist/runs/events.js +3 -1
- package/dist/runs/log-attributes.js +4 -0
- package/dist/runs/log-events.js +2 -0
- package/dist/runs/recording.d.ts +3 -0
- package/dist/runs/recording.js +36 -12
- package/dist/runs/run.d.ts +12 -3
- package/dist/runs/run.js +32 -13
- package/dist/search/account-list.d.ts +6 -0
- package/dist/search/account-list.js +9 -3
- package/dist/search/groups.d.ts +68 -0
- package/dist/search/groups.js +172 -0
- package/dist/search/question-period.d.ts +10 -0
- package/dist/search/question-period.js +133 -0
- package/dist/sends/buttons.d.ts +2 -0
- package/dist/sends/buttons.js +6 -1
- package/dist/services/account-groups.d.ts +28 -0
- package/dist/services/account-groups.js +89 -0
- package/dist/services/archive.d.ts +7 -1
- package/dist/services/archive.js +19 -3
- package/dist/services/business-context.d.ts +113 -0
- package/dist/services/business-context.js +156 -0
- package/dist/services/communications.d.ts +50 -0
- package/dist/services/communications.js +140 -0
- package/dist/services/deal-context.d.ts +90 -0
- package/dist/services/deal-context.js +131 -0
- package/dist/services/deps.d.ts +2 -0
- package/dist/services/enrichment.d.ts +12 -2
- package/dist/services/enrichment.js +47 -6
- package/dist/services/events-search.js +2 -1
- package/dist/services/group-guard.d.ts +28 -0
- package/dist/services/group-guard.js +131 -0
- package/dist/services/index.d.ts +19 -4
- package/dist/services/index.js +12 -3
- package/dist/services/ingest.d.ts +12 -0
- package/dist/services/ingest.js +4 -0
- package/dist/services/meaning-model.d.ts +7 -0
- package/dist/services/meaning-model.js +20 -0
- package/dist/services/meeting-context.d.ts +6 -1
- package/dist/services/meeting-context.js +12 -5
- package/dist/services/message-resolution.js +2 -3
- package/dist/services/messages-meaning.js +4 -5
- package/dist/services/messages-search.d.ts +5 -1
- package/dist/services/messages-search.js +1 -1
- package/dist/services/messages.d.ts +1 -4
- package/dist/services/messages.js +0 -2
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/model-downloads.d.ts +1 -1
- package/dist/services/model-downloads.js +6 -4
- package/dist/services/money-context.d.ts +73 -0
- package/dist/services/money-context.js +77 -0
- package/dist/services/notes-search.d.ts +4 -1
- package/dist/services/notes-search.js +19 -7
- package/dist/services/organization-context.d.ts +80 -0
- package/dist/services/organization-context.js +154 -0
- package/dist/services/people.d.ts +22 -6
- package/dist/services/people.js +38 -8
- package/dist/services/person-business.d.ts +43 -0
- package/dist/services/person-business.js +67 -0
- package/dist/services/person-context.d.ts +11 -1
- package/dist/services/person-context.js +25 -10
- package/dist/services/person-preparation.d.ts +5 -1
- package/dist/services/person-preparation.js +10 -3
- package/dist/services/person-timeline.d.ts +6 -1
- package/dist/services/person-timeline.js +10 -2
- package/dist/services/proposals/kinds/identity-link.d.ts +4 -0
- package/dist/services/proposals/kinds/identity-link.js +48 -0
- package/dist/services/proposals/kinds/orders.js +1 -1
- package/dist/services/proposals/registry.js +2 -0
- package/dist/services/search-all-deprecated.d.ts +40 -0
- package/dist/services/search-all-deprecated.js +10 -0
- package/dist/services/search-all-meetings.d.ts +50 -52
- package/dist/services/search-all-meetings.js +265 -272
- package/dist/services/search-all.d.ts +34 -6
- package/dist/services/search-all.js +118 -24
- package/dist/services/search-harder.d.ts +64 -0
- package/dist/services/search-harder.js +194 -0
- package/dist/services/search-kind.d.ts +12 -5
- package/dist/services/search-kind.js +49 -10
- package/dist/services/text-model-choice.js +1 -1
- package/dist/store/accounts.d.ts +18 -0
- package/dist/store/accounts.js +18 -3
- package/dist/store/chats.d.ts +3 -1
- package/dist/store/chats.js +6 -0
- package/dist/store/damage.d.ts +43 -10
- package/dist/store/damage.js +119 -36
- package/dist/store/decisions.js +3 -1
- package/dist/store/evidence-findings.d.ts +14 -0
- package/dist/store/evidence-findings.js +2 -0
- package/dist/store/exports.d.ts +2 -1
- package/dist/store/identity-links.d.ts +92 -0
- package/dist/store/identity-links.js +6 -0
- package/dist/store/index.d.ts +11 -5
- package/dist/store/index.js +5 -2
- package/dist/store/journal.d.ts +10 -0
- package/dist/store/journal.js +33 -0
- package/dist/store/marks.d.ts +19 -1
- package/dist/store/marks.js +23 -1
- package/dist/store/people.d.ts +28 -2
- package/dist/store/people.js +15 -1
- package/dist/store/sqlite/accounts.js +2 -0
- package/dist/store/sqlite/added-sources.d.ts +15 -3
- package/dist/store/sqlite/added-sources.js +26 -5
- package/dist/store/sqlite/base-stages.d.ts +122 -0
- package/dist/store/sqlite/base-stages.js +443 -0
- package/dist/store/sqlite/base-suggest.d.ts +13 -0
- package/dist/store/sqlite/base-suggest.js +62 -0
- package/dist/store/sqlite/business-contracts.js +10 -1
- package/dist/store/sqlite/chats.d.ts +2 -0
- package/dist/store/sqlite/chats.js +6 -0
- package/dist/store/sqlite/crm-settings.d.ts +12 -2
- package/dist/store/sqlite/crm-settings.js +56 -13
- package/dist/store/sqlite/crm.d.ts +13 -1
- package/dist/store/sqlite/crm.js +20 -4
- package/dist/store/sqlite/deals.d.ts +33 -0
- package/dist/store/sqlite/deals.js +42 -4
- package/dist/store/sqlite/decision-requests.js +7 -3
- package/dist/store/sqlite/email-index.js +8 -4
- package/dist/store/sqlite/evidence-findings.js +29 -5
- package/dist/store/sqlite/findings-core.js +4 -2
- package/dist/store/sqlite/identity-link-rows.d.ts +50 -0
- package/dist/store/sqlite/identity-link-rows.js +146 -0
- package/dist/store/sqlite/identity-proposals.d.ts +53 -0
- package/dist/store/sqlite/identity-proposals.js +234 -0
- package/dist/store/sqlite/involvements.d.ts +1 -1
- package/dist/store/sqlite/involvements.js +4 -2
- package/dist/store/sqlite/knowledge.js +2 -2
- package/dist/store/sqlite/link-kinds.d.ts +1 -0
- package/dist/store/sqlite/link-kinds.js +1 -0
- package/dist/store/sqlite/link-row.d.ts +6 -0
- package/dist/store/sqlite/link-row.js +35 -0
- package/dist/store/sqlite/link-source.d.ts +10 -0
- package/dist/store/sqlite/link-source.js +16 -0
- package/dist/store/sqlite/manifest.js +1 -0
- package/dist/store/sqlite/meeting-context-links.js +9 -6
- package/dist/store/sqlite/meeting-hit-query.d.ts +5 -0
- package/dist/store/sqlite/meeting-hit-query.js +33 -0
- package/dist/store/sqlite/meeting-hit-search.js +10 -8
- package/dist/store/sqlite/meetings.js +1 -1
- package/dist/store/sqlite/memories.js +9 -7
- package/dist/store/sqlite/mentions.d.ts +4 -1
- package/dist/store/sqlite/mentions.js +14 -9
- package/dist/store/sqlite/migrations.generated.js +8 -0
- package/dist/store/sqlite/notes.d.ts +8 -2
- package/dist/store/sqlite/notes.js +17 -34
- package/dist/store/sqlite/open-store.js +3 -0
- package/dist/store/sqlite/open.js +11 -2
- package/dist/store/sqlite/orders.d.ts +2 -0
- package/dist/store/sqlite/orders.js +9 -3
- package/dist/store/sqlite/organization-categories.d.ts +18 -0
- package/dist/store/sqlite/organization-categories.js +34 -0
- package/dist/store/sqlite/organizations.d.ts +5 -1
- package/dist/store/sqlite/organizations.js +14 -4
- package/dist/store/sqlite/person-links.d.ts +19 -4
- package/dist/store/sqlite/person-links.js +49 -11
- package/dist/store/sqlite/person-match-scan.d.ts +13 -0
- package/dist/store/sqlite/person-match-scan.js +251 -0
- package/dist/store/sqlite/person-matcher.d.ts +16 -0
- package/dist/store/sqlite/person-matcher.js +32 -0
- package/dist/store/sqlite/person-preparation.d.ts +7 -3
- package/dist/store/sqlite/person-preparation.js +20 -6
- package/dist/store/sqlite/proposed-actions.js +6 -0
- package/dist/store/sqlite/record-matching.d.ts +2 -8
- package/dist/store/sqlite/record-matching.js +8 -40
- package/dist/store/sqlite/record-projectors-phone.js +2 -1
- package/dist/store/sqlite/record-relationships.d.ts +52 -0
- package/dist/store/sqlite/record-relationships.js +243 -0
- package/dist/store/sqlite/record-run.d.ts +5 -0
- package/dist/store/sqlite/record-run.js +62 -2
- package/dist/store/sqlite/record-writes.d.ts +1 -1
- package/dist/store/sqlite/record-writes.js +4 -2
- package/dist/store/sqlite/records.js +27 -2
- package/dist/store/sqlite/ref-accounts.d.ts +13 -0
- package/dist/store/sqlite/ref-accounts.js +117 -0
- package/dist/store/sqlite/ref-summaries.js +5 -1
- package/dist/store/sqlite/relation-list.d.ts +4 -1
- package/dist/store/sqlite/relation-list.js +22 -4
- package/dist/store/sqlite/relation-proposals.d.ts +6 -0
- package/dist/store/sqlite/relation-proposals.js +3 -0
- package/dist/store/sqlite/relation-roles.js +12 -6
- package/dist/store/sqlite/reported-relations.d.ts +11 -1
- package/dist/store/sqlite/reported-relations.js +59 -18
- package/dist/store/sqlite/schema.d.ts +32 -0
- package/dist/store/sqlite/schema.js +3 -0
- package/dist/store/sqlite/transaction.js +11 -1
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/store/write-events.d.ts +18 -0
- package/dist/store/write-events.js +88 -0
- package/package.json +3 -3
- package/parity.json +37 -16
- package/schemas/records-envelope.v1.schema.json +3 -0
|
@@ -255,9 +255,10 @@ export const prepareReport = async (answer, { language, now, timeZone, templates
|
|
|
255
255
|
: {};
|
|
256
256
|
const web = viewFor("web");
|
|
257
257
|
const telegram = await renderReport(web, "telegram", templateOf(templates, "telegram"));
|
|
258
|
+
const email = await renderReport(web, "email", templateOf(templates, "email"));
|
|
258
259
|
const text = await renderReport(web, "text", templateOf(templates, "text"));
|
|
259
260
|
const terminal = await renderReport(viewFor("app"), "text", templateOf(templates, "text"));
|
|
260
|
-
const renderings = [telegram, text, terminal];
|
|
261
|
+
const renderings = [telegram, email, text, terminal];
|
|
261
262
|
const reasons = [
|
|
262
263
|
...(lookupFailed || renderings.some((one) => one.templateFailed) ? [REPORT_REASONS.templateFailed] : []),
|
|
263
264
|
...(renderings.some((one) => one.templateTags > 0) ? [REPORT_REASONS.templateTags] : []),
|
|
@@ -265,6 +266,7 @@ export const prepareReport = async (answer, { language, now, timeZone, templates
|
|
|
265
266
|
const title = text.text.split("\n")[0] ?? "";
|
|
266
267
|
return {
|
|
267
268
|
telegram: telegram.text,
|
|
269
|
+
email: email.text,
|
|
268
270
|
text: text.text,
|
|
269
271
|
terminal: terminal.text,
|
|
270
272
|
document: `${JSON.stringify(reportDocument(parsed.report), null, 2)}\n`,
|
|
@@ -487,6 +487,7 @@ export declare const calendarLinkedPerson: v.StrictObjectSchema<{
|
|
|
487
487
|
readonly person: v.StringSchema<undefined>;
|
|
488
488
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
489
489
|
readonly identities: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
490
|
+
readonly proposal: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
490
491
|
}, undefined>;
|
|
491
492
|
export declare const calendarLinkReview: v.StrictObjectSchema<{
|
|
492
493
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
|
|
@@ -238,7 +238,12 @@ export const calendarEventPreparation = v.strictObject({
|
|
|
238
238
|
limits: v.strictObject({ people: count, messages: count, bytes: count }),
|
|
239
239
|
untrusted,
|
|
240
240
|
});
|
|
241
|
-
export const calendarLinkedPerson = v.strictObject({
|
|
241
|
+
export const calendarLinkedPerson = v.strictObject({
|
|
242
|
+
person: text,
|
|
243
|
+
name: nullableText,
|
|
244
|
+
identities: v.array(text),
|
|
245
|
+
proposal: v.optional(text),
|
|
246
|
+
});
|
|
242
247
|
export const calendarLinkReview = v.strictObject({
|
|
243
248
|
id,
|
|
244
249
|
entry_id: id,
|
|
@@ -14,7 +14,6 @@ import { secretInput } from "../../runs/run-context.js";
|
|
|
14
14
|
import { searchEvents } from "../../services/events-search.js";
|
|
15
15
|
import { dateWindow } from "../../services/moment.js";
|
|
16
16
|
import { embedEvents } from "../../services/notes-search.js";
|
|
17
|
-
import { linkPeople } from "../../services/people.js";
|
|
18
17
|
import { BUSY_QUERY, BUSY_QUERY_NOTE, busyAnswer, busyQuery, workingHoursOf } from "../busy.js";
|
|
19
18
|
import { isFeedCalendar, isPlainHttp, syncWithFeeds } from "../feeds.js";
|
|
20
19
|
import { eventPreparation, nextMeeting, PREPARE_MESSAGES } from "../prepare.js";
|
|
@@ -27,6 +26,7 @@ import { CALENDARS_QUERY, declareCalendarAnswers, PEOPLE_QUERY } from "./answers
|
|
|
27
26
|
import { hitsBody, itemBody, listBody, messagesOf, pathOf } from "./bodies.js";
|
|
28
27
|
import { ICS_MAX_BYTES, readIcsFile, writeIcsFile } from "./files.js";
|
|
29
28
|
import { localTimesView } from "./local-times.js";
|
|
29
|
+
import { addPeopleLink } from "./people-link.js";
|
|
30
30
|
import { addRemind } from "./remind.js";
|
|
31
31
|
import { addSearchAll } from "./search-all.js";
|
|
32
32
|
const LOCAL_READ = { remote: "none", local: "read" };
|
|
@@ -444,19 +444,7 @@ const addCalendarCommandsDefinition = (program, options) => {
|
|
|
444
444
|
return listBody(command, eachMarked(found, ATTENDEE_UNTRUSTED));
|
|
445
445
|
});
|
|
446
446
|
});
|
|
447
|
-
|
|
448
|
-
.description("join an attendee to a person the owner knows elsewhere")
|
|
449
|
-
.argument("<person>", "an attendee's address as email:<address>, or a person:<id>")
|
|
450
|
-
.argument("<other>", "the same person in another tool, as <provider>:<person>, or me"), "people link email:ana@example.com telegram:12345").action(async (person, other, _opts, command) => {
|
|
451
|
-
await within(command, async (run) => {
|
|
452
|
-
const linked = await linkPeople(messagesOf(run, "people link"), run.account, person, other);
|
|
453
|
-
return itemBody({
|
|
454
|
-
person: `person:${linked.uid}`,
|
|
455
|
-
name: linked.name,
|
|
456
|
-
identities: linked.identities.map(({ provider, id }) => `${provider}:${id}`),
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
});
|
|
447
|
+
addPeopleLink(people, { within, example });
|
|
460
448
|
const links = annotate(program.command("links").description("calendar copies the rules could not join alone"), {
|
|
461
449
|
effects: GROUP,
|
|
462
450
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
2
|
+
import { actorOf } from "../../cli/author.js";
|
|
3
|
+
import { LOCAL_WRITE } from "../../cli/effects.js";
|
|
4
|
+
import { linkPeople } from "../../services/people.js";
|
|
5
|
+
import { itemBody, messagesOf } from "./bodies.js";
|
|
6
|
+
export const addPeopleLink = (people, { within, example }) => example(annotate(people.command("link"), { effects: LOCAL_WRITE })
|
|
7
|
+
.description("join an attendee to a person the owner knows elsewhere")
|
|
8
|
+
.argument("<person>", "an attendee's address as email:<address>, or a person:<id>")
|
|
9
|
+
.argument("<other>", "the same person in another tool, as <provider>:<person>, or me")
|
|
10
|
+
.option("--reason <text>", "why they are one person; an agent's link is a proposal and needs it"), "people link email:ana@example.com telegram:12345").action(async (person, other, opts, command) => {
|
|
11
|
+
await within(command, async (run) => {
|
|
12
|
+
const linked = await linkPeople(messagesOf(run, "people link"), run.account, person, other, {
|
|
13
|
+
by: actorOf(command),
|
|
14
|
+
reason: opts.reason,
|
|
15
|
+
});
|
|
16
|
+
return itemBody({
|
|
17
|
+
person: `person:${linked.uid}`,
|
|
18
|
+
name: linked.name,
|
|
19
|
+
identities: linked.identities.map(({ provider, id }) => `${provider}:${id}`),
|
|
20
|
+
...(linked.proposal === undefined ? {} : { proposal: linked.proposal }),
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -6,7 +6,7 @@ interface SearchAllHelpers extends Pick<CommandHelpers, "within" | "zone" | "exa
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* `search all` beside `search events`: the messenger's shared search over the store, without a messenger server.
|
|
9
|
-
* Events are the calendar's own kind and always read
|
|
9
|
+
* Events are the calendar's own kind and always read.
|
|
10
10
|
*/
|
|
11
11
|
export declare const addSearchAll: (searches: Command, { within, app, zone, example }: SearchAllHelpers) => void;
|
|
12
12
|
export {};
|
|
@@ -10,20 +10,20 @@ import { deniedKinds } from "../../cli/search-left-out.js";
|
|
|
10
10
|
import { commandAt, rootOf } from "../../cli/steps.js";
|
|
11
11
|
import { SAVE_HELP } from "../../meetings/index.js";
|
|
12
12
|
import { meaningLane } from "../../services/messages-meaning.js";
|
|
13
|
-
import {
|
|
13
|
+
import { searchAll } from "../../services/search-all.js";
|
|
14
14
|
import { messagesOf } from "./bodies.js";
|
|
15
15
|
const DEFAULT_LIMIT = 20;
|
|
16
16
|
/**
|
|
17
17
|
* `search all` beside `search events`: the messenger's shared search over the store, without a messenger server.
|
|
18
|
-
* Events are the calendar's own kind and always read
|
|
18
|
+
* Events are the calendar's own kind and always read.
|
|
19
19
|
*/
|
|
20
20
|
export const addSearchAll = (searches, { within, app, zone, example }) => {
|
|
21
21
|
const all = annotate(new Command("all"), { effects: LOCAL_READ, partial: true, output: { entity: "hit" } })
|
|
22
|
-
.summary("search stored messages, notes, calendar events and
|
|
23
|
-
.description("search calendar events, messages from the other WireCat tools
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
22
|
+
.summary("search stored messages, notes, calendar events and meetings")
|
|
23
|
+
.description("search calendar events, messages from the other WireCat tools, notes and meeting transcripts, chat and " +
|
|
24
|
+
"summaries in the local store — best match first; not mail (the separate memo CLI searches it: memo search " +
|
|
25
|
+
"mail). Use it when you do not know where something was written; search events reads the calendar with all " +
|
|
26
|
+
"its fields")
|
|
27
27
|
.argument("<query...>", 'strict Lucene query: words, "phrases", AND/OR/NOT, field groups and date ranges')
|
|
28
28
|
.addHelpText("after", SAVE_HELP)
|
|
29
29
|
.addHelpText("after", "--json: the list is items; each result's reference is ref, with its kind.");
|
|
@@ -43,7 +43,7 @@ export const addSearchAll = (searches, { within, app, zone, example }) => {
|
|
|
43
43
|
const limit = opts.limit ?? DEFAULT_LIMIT;
|
|
44
44
|
const offset = offsetOf(opts.page, limit);
|
|
45
45
|
const env = run.env ?? process.env;
|
|
46
|
-
const found = await
|
|
46
|
+
const found = await searchAll(store, run.account, {
|
|
47
47
|
text: words.join(" "),
|
|
48
48
|
limit,
|
|
49
49
|
...(offset === undefined ? {} : { offset }),
|
|
@@ -51,8 +51,8 @@ export const addSearchAll = (searches, { within, app, zone, example }) => {
|
|
|
51
51
|
timezone: opts.timezone ?? zone(),
|
|
52
52
|
env,
|
|
53
53
|
only,
|
|
54
|
+
...(opts.only?.includes("meetings") ? { meetingsAsked: true } : {}),
|
|
54
55
|
...(opts.source === undefined ? {} : { source: opts.source }),
|
|
55
|
-
...(opts.maxMeetings === undefined ? {} : { maxMeetings: opts.maxMeetings }),
|
|
56
56
|
...(run.locked ? { scope: { events: [run.account] } } : {}),
|
|
57
57
|
}, { app, hintCommand: commandAt(rootOf(leaf), "models download") ? app.command : null }, undefined, meaningLane({ env, messenger: { app }, store: async () => store }));
|
|
58
58
|
const note = (text) => outputFor(leaf).renderer.note(text);
|
|
@@ -71,7 +71,6 @@ export const addSearchAll = (searches, { within, app, zone, example }) => {
|
|
|
71
71
|
query: words.join(" "),
|
|
72
72
|
...(opts.only === undefined ? {} : { only: opts.only.join(",") }),
|
|
73
73
|
...(opts.source === undefined ? {} : { source: opts.source }),
|
|
74
|
-
...(opts.maxMeetings === undefined ? {} : { max_meetings: opts.maxMeetings }),
|
|
75
74
|
...(opts.exact ? { exact: true } : {}),
|
|
76
75
|
...(opts.timezone === undefined ? {} : { timezone: opts.timezone }),
|
|
77
76
|
};
|
package/dist/calendar/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type { CalendarAccessRole, CalendarInput, EntryAttachment, EntryAttachmen
|
|
|
2
2
|
export { expandSeries, localMoment, unexpandable } from "./expand.js";
|
|
3
3
|
export { type CalendarFeeds, FEED_LIMITS, FEED_PREFIX, type FeedLimits, type FeedRecord, type FeedRegistry, type FeedSyncStats, type FeedsSyncReport, feedAddress, fetchFeed, icsFeeds, isFeedCalendar, readFeed, syncWithFeeds, } from "./feeds.js";
|
|
4
4
|
export { type IcsEvent, type IcsOverride, type IcsRead, type IcsSkip, readIcs, writeIcs } from "./ics.js";
|
|
5
|
-
export { accountsMeta } from "./reads.js";
|
|
5
|
+
export { accountsMeta, EVENT_TYPES, EVENTS_QUERY, EVENTS_QUERY_NOTE, eventAnswer, eventOf, eventsAnswer, eventsFilter, type ReadAccount, sourceAccounts, } from "./reads.js";
|
|
6
6
|
export { repeatRule } from "./recurrence.js";
|
|
7
7
|
export type { BusyTimes, CalendarExpander, CalendarSource, CalendarSourceTraits, ChangePage, ChangeResult, FreeBusyRequest, SearchPage, SyncWindow, } from "./source.js";
|
|
8
8
|
export { type CalendarCursor, type CalendarSyncOptions, type CalendarSyncReport, type CalendarSyncResult, calendarStatus, calendarSyncWindow, type PendingRound, parseCalendarCursor, syncCalendars, } from "./sync.js";
|
package/dist/calendar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { expandSeries, localMoment, unexpandable } from "./expand.js";
|
|
2
2
|
export { FEED_LIMITS, FEED_PREFIX, feedAddress, fetchFeed, icsFeeds, isFeedCalendar, readFeed, syncWithFeeds, } from "./feeds.js";
|
|
3
3
|
export { readIcs, writeIcs } from "./ics.js";
|
|
4
|
-
export { accountsMeta } from "./reads.js";
|
|
4
|
+
export { accountsMeta, EVENT_TYPES, EVENTS_QUERY, EVENTS_QUERY_NOTE, eventAnswer, eventOf, eventsAnswer, eventsFilter, sourceAccounts, } from "./reads.js";
|
|
5
5
|
export { repeatRule } from "./recurrence.js";
|
|
6
6
|
export { calendarStatus, calendarSyncWindow, parseCalendarCursor, syncCalendars, } from "./sync.js";
|
|
7
7
|
export { CALENDAR_WRITE_DEFAULTS, CALENDAR_WRITE_KEYS, calendarConflict, EVENTS_DELETE_SERIES_KEY, EVENTS_NOTIFY_KEY, EVENTS_REMIND_HOOK_KEY, } from "./writer.js";
|
|
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
|
|
|
10
10
|
inputSchema: {
|
|
11
11
|
type: string;
|
|
12
12
|
properties: {
|
|
13
|
+
limit?: undefined;
|
|
13
14
|
account_id: {
|
|
14
15
|
type: string;
|
|
15
16
|
minimum: number;
|
|
16
17
|
};
|
|
17
18
|
query?: undefined;
|
|
18
19
|
timezone?: undefined;
|
|
19
|
-
limit?: undefined;
|
|
20
20
|
page?: undefined;
|
|
21
21
|
event?: undefined;
|
|
22
22
|
} | {
|
|
@@ -45,9 +45,9 @@ export declare const calendarTools: ({
|
|
|
45
45
|
};
|
|
46
46
|
event?: undefined;
|
|
47
47
|
} | {
|
|
48
|
+
limit?: undefined;
|
|
48
49
|
query?: undefined;
|
|
49
50
|
timezone?: undefined;
|
|
50
|
-
limit?: undefined;
|
|
51
51
|
page?: undefined;
|
|
52
52
|
event: {
|
|
53
53
|
type: string;
|
|
@@ -58,9 +58,9 @@ export declare const calendarTools: ({
|
|
|
58
58
|
minimum: number;
|
|
59
59
|
};
|
|
60
60
|
} | {
|
|
61
|
+
limit?: undefined;
|
|
61
62
|
query?: undefined;
|
|
62
63
|
timezone?: undefined;
|
|
63
|
-
limit?: undefined;
|
|
64
64
|
page?: undefined;
|
|
65
65
|
event?: undefined;
|
|
66
66
|
account_id?: undefined;
|
|
@@ -80,13 +80,13 @@ export declare const calendarTools: ({
|
|
|
80
80
|
inputSchema: {
|
|
81
81
|
type: string;
|
|
82
82
|
properties: {
|
|
83
|
+
limit?: undefined;
|
|
83
84
|
account_id: {
|
|
84
85
|
type: string;
|
|
85
86
|
minimum: number;
|
|
86
87
|
};
|
|
87
88
|
query?: undefined;
|
|
88
89
|
timezone?: undefined;
|
|
89
|
-
limit?: undefined;
|
|
90
90
|
page?: undefined;
|
|
91
91
|
event?: undefined;
|
|
92
92
|
} | {
|
|
@@ -115,9 +115,9 @@ export declare const calendarTools: ({
|
|
|
115
115
|
};
|
|
116
116
|
event?: undefined;
|
|
117
117
|
} | {
|
|
118
|
+
limit?: undefined;
|
|
118
119
|
query?: undefined;
|
|
119
120
|
timezone?: undefined;
|
|
120
|
-
limit?: undefined;
|
|
121
121
|
page?: undefined;
|
|
122
122
|
event: {
|
|
123
123
|
type: string;
|
|
@@ -128,9 +128,9 @@ export declare const calendarTools: ({
|
|
|
128
128
|
minimum: number;
|
|
129
129
|
};
|
|
130
130
|
} | {
|
|
131
|
+
limit?: undefined;
|
|
131
132
|
query?: undefined;
|
|
132
133
|
timezone?: undefined;
|
|
133
|
-
limit?: undefined;
|
|
134
134
|
page?: undefined;
|
|
135
135
|
event?: undefined;
|
|
136
136
|
account_id?: undefined;
|
|
@@ -150,13 +150,13 @@ export declare const calendarTools: ({
|
|
|
150
150
|
inputSchema: {
|
|
151
151
|
type: string;
|
|
152
152
|
properties: {
|
|
153
|
+
limit?: undefined;
|
|
153
154
|
account_id: {
|
|
154
155
|
type: string;
|
|
155
156
|
minimum: number;
|
|
156
157
|
};
|
|
157
158
|
query?: undefined;
|
|
158
159
|
timezone?: undefined;
|
|
159
|
-
limit?: undefined;
|
|
160
160
|
page?: undefined;
|
|
161
161
|
event?: undefined;
|
|
162
162
|
} | {
|
|
@@ -185,9 +185,9 @@ export declare const calendarTools: ({
|
|
|
185
185
|
};
|
|
186
186
|
event?: undefined;
|
|
187
187
|
} | {
|
|
188
|
+
limit?: undefined;
|
|
188
189
|
query?: undefined;
|
|
189
190
|
timezone?: undefined;
|
|
190
|
-
limit?: undefined;
|
|
191
191
|
page?: undefined;
|
|
192
192
|
event: {
|
|
193
193
|
type: string;
|
|
@@ -198,9 +198,9 @@ export declare const calendarTools: ({
|
|
|
198
198
|
minimum: number;
|
|
199
199
|
};
|
|
200
200
|
} | {
|
|
201
|
+
limit?: undefined;
|
|
201
202
|
query?: undefined;
|
|
202
203
|
timezone?: undefined;
|
|
203
|
-
limit?: undefined;
|
|
204
204
|
page?: undefined;
|
|
205
205
|
event?: undefined;
|
|
206
206
|
account_id?: undefined;
|
|
@@ -220,13 +220,13 @@ export declare const calendarTools: ({
|
|
|
220
220
|
inputSchema: {
|
|
221
221
|
type: string;
|
|
222
222
|
properties: {
|
|
223
|
+
limit?: undefined;
|
|
223
224
|
account_id: {
|
|
224
225
|
type: string;
|
|
225
226
|
minimum: number;
|
|
226
227
|
};
|
|
227
228
|
query?: undefined;
|
|
228
229
|
timezone?: undefined;
|
|
229
|
-
limit?: undefined;
|
|
230
230
|
page?: undefined;
|
|
231
231
|
event?: undefined;
|
|
232
232
|
} | {
|
|
@@ -255,9 +255,9 @@ export declare const calendarTools: ({
|
|
|
255
255
|
};
|
|
256
256
|
event?: undefined;
|
|
257
257
|
} | {
|
|
258
|
+
limit?: undefined;
|
|
258
259
|
query?: undefined;
|
|
259
260
|
timezone?: undefined;
|
|
260
|
-
limit?: undefined;
|
|
261
261
|
page?: undefined;
|
|
262
262
|
event: {
|
|
263
263
|
type: string;
|
|
@@ -268,9 +268,9 @@ export declare const calendarTools: ({
|
|
|
268
268
|
minimum: number;
|
|
269
269
|
};
|
|
270
270
|
} | {
|
|
271
|
+
limit?: undefined;
|
|
271
272
|
query?: undefined;
|
|
272
273
|
timezone?: undefined;
|
|
273
|
-
limit?: undefined;
|
|
274
274
|
page?: undefined;
|
|
275
275
|
event?: undefined;
|
|
276
276
|
account_id?: undefined;
|
package/dist/calendar/prepare.js
CHANGED
|
@@ -104,6 +104,7 @@ export const eventPreparation = async (details, options) => {
|
|
|
104
104
|
for (const { key } of reads)
|
|
105
105
|
read.set(nameOf(key), key);
|
|
106
106
|
const context = await recordContext(store, record, reads, readable, {
|
|
107
|
+
...(options.scopes === undefined ? {} : { scopes: options.scopes }),
|
|
107
108
|
messages: limit,
|
|
108
109
|
bytes: Math.min(left, PERSON_BYTES),
|
|
109
110
|
now,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { AppIdentity } from "../ports/app.js";
|
|
3
|
+
import type { MessageStore } from "../store/store.js";
|
|
4
|
+
import type { AccountKey } from "../store/types.js";
|
|
5
|
+
import { type Body } from "./envelope.js";
|
|
6
|
+
export interface BaseStagesCommandOptions {
|
|
7
|
+
/** The run's environment, read for an agent's markers: an agent suggests mappings, the owner confirms and edits. */
|
|
8
|
+
env: () => NodeJS.ProcessEnv;
|
|
9
|
+
/** The store for one command; the command closes it once its answer is built. */
|
|
10
|
+
open: (command: Command) => Promise<MessageStore>;
|
|
11
|
+
output: (answer: Body, command: Command) => void;
|
|
12
|
+
/**
|
|
13
|
+
* The CRM accounts the run may read and change, such as a group lock's; `undefined` for all. The owner's own
|
|
14
|
+
* pipelines are always in.
|
|
15
|
+
*/
|
|
16
|
+
accounts?: (store: MessageStore, command: Command) => Promise<readonly AccountKey[] | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `stages …`: the owner's base stages of deals and of leads, and the stages of every other pipeline mapped onto them. memo mounts it; a CRM
|
|
20
|
+
* CLI moves a card to a base stage with `deals move <deal> stage:<id>`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const baseStagesCommand: (app: AppIdentity, options: BaseStagesCommandOptions) => Command;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
3
|
+
import { Argument, Command, InvalidArgumentError, Option } from "commander";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { DEAL_KINDS, STAGE_OUTCOMES } from "../domain/deals.js";
|
|
6
|
+
import { count, reference, text, untrusted } from "../entities/fields.js";
|
|
7
|
+
import { agentOf } from "../runs/run-context.js";
|
|
8
|
+
import { answerEntity } from "./answer-entity.js";
|
|
9
|
+
import { environmentOf } from "./context.js";
|
|
10
|
+
import { LOCAL_READ, LOCAL_WRITE } from "./effects.js";
|
|
11
|
+
import { itemOf, listOf, snakeKeys } from "./envelope.js";
|
|
12
|
+
import { queryTerms, termField, withQuery } from "./list-query.js";
|
|
13
|
+
const outcome = v.picklist(STAGE_OUTCOMES);
|
|
14
|
+
const kind = v.picklist(DEAL_KINDS);
|
|
15
|
+
const named = v.strictObject({ ref: reference, name: text });
|
|
16
|
+
const baseSet = v.strictObject({
|
|
17
|
+
kind,
|
|
18
|
+
/** `null`, with each stage's `ref`, only when a read-only store is read before the set's first use made it. */
|
|
19
|
+
pipeline: v.nullable(reference),
|
|
20
|
+
stages: v.array(v.strictObject({ ref: v.nullable(reference), name: text, position: count, outcome, open: count, mapped: count })),
|
|
21
|
+
unsorted: v.strictObject({ open: count, stages: count }),
|
|
22
|
+
});
|
|
23
|
+
const stageMapping = v.strictObject({
|
|
24
|
+
...named.entries,
|
|
25
|
+
position: count,
|
|
26
|
+
outcome,
|
|
27
|
+
external_id: v.nullable(text),
|
|
28
|
+
kind,
|
|
29
|
+
pipeline: reference,
|
|
30
|
+
pipeline_name: text,
|
|
31
|
+
account: v.nullable(v.strictObject({ provider: text, account: text })),
|
|
32
|
+
base_stage: v.nullable(named),
|
|
33
|
+
confirmed: v.boolean(),
|
|
34
|
+
open: count,
|
|
35
|
+
untrusted,
|
|
36
|
+
});
|
|
37
|
+
/** A CRM's users named its stages and pipelines; the base set's names are the owner's. */
|
|
38
|
+
const MAPPING_UNTRUSTED = ["name", "pipeline_name"];
|
|
39
|
+
/** What `stages list` narrows by. */
|
|
40
|
+
const MAPPING_QUERY = {
|
|
41
|
+
entity: "stage_mapping",
|
|
42
|
+
backend: "native",
|
|
43
|
+
fields: [
|
|
44
|
+
termField("kind", "enum", "kind:deal", { values: DEAL_KINDS }),
|
|
45
|
+
termField("pipeline", "kw", "pipeline:Sales", { relation: "pipeline:<id>, or a name only one pipeline has" }),
|
|
46
|
+
termField("confirmed", "bool", "confirmed:false"),
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
const position = (value) => {
|
|
50
|
+
if (!/^[1-9]\d*$/.test(value))
|
|
51
|
+
throw new InvalidArgumentError("expected a position from 1");
|
|
52
|
+
return Number(value);
|
|
53
|
+
};
|
|
54
|
+
const kindArgument = () => new Argument("<kind>", "deal or lead: which base set").choices(DEAL_KINDS);
|
|
55
|
+
/**
|
|
56
|
+
* `stages …`: the owner's base stages of deals and of leads, and the stages of every other pipeline mapped onto them. memo mounts it; a CRM
|
|
57
|
+
* CLI moves a card to a base stage with `deals move <deal> stage:<id>`.
|
|
58
|
+
*/
|
|
59
|
+
export const baseStagesCommand = (app, options) => {
|
|
60
|
+
const isAgent = (command) => Boolean(environmentOf(command).agent || agentOf(options.env()));
|
|
61
|
+
// A guard against a change by mistake, not a boundary, as the owner-only store settings are.
|
|
62
|
+
const ownerOnly = (command, what) => {
|
|
63
|
+
if (isAgent(command))
|
|
64
|
+
throw new CliError("permission_error", `${what} is the owner's to do, in a terminal: an agent's run is stopped from changing it by mistake`, { reason: "stage.owner-only" });
|
|
65
|
+
};
|
|
66
|
+
const run = async (command, work) => {
|
|
67
|
+
const store = await options.open(command);
|
|
68
|
+
let body;
|
|
69
|
+
try {
|
|
70
|
+
const accounts = await options.accounts?.(store, command);
|
|
71
|
+
body = await work(store, accounts === undefined ? {} : { accounts });
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await store.close();
|
|
75
|
+
}
|
|
76
|
+
options.output(body, command);
|
|
77
|
+
};
|
|
78
|
+
const stages = annotate(new Command("stages"), { effects: LOCAL_READ })
|
|
79
|
+
.description("the owner's base stages of deals and of leads, the columns of a board across every pipeline and CRM, and " +
|
|
80
|
+
"how each other pipeline's stage maps onto them")
|
|
81
|
+
.summary("base stages and the stages mapped onto them");
|
|
82
|
+
const leaf = (name, effects, summary, ...examples) => annotate(stages.command(name), {
|
|
83
|
+
effects,
|
|
84
|
+
examples: examples.map((line) => `${app.command} stages ${line}`),
|
|
85
|
+
}).summary(summary);
|
|
86
|
+
const setAnswer = (set) => itemOf(snakeKeys(set));
|
|
87
|
+
const setCommand = (name, summary, ...examples) => answerEntity(leaf(name, LOCAL_WRITE, summary, ...examples), "base_stage_set", baseSet)
|
|
88
|
+
.addArgument(kindArgument())
|
|
89
|
+
.hook("preAction", (_root, command) => ownerOnly(command, `stages ${name}`));
|
|
90
|
+
const mappingRow = (row) => ({ ...snakeKeys(row), untrusted: MAPPING_UNTRUSTED });
|
|
91
|
+
const baseStage = "the base stage, by its stage:<id> or its name";
|
|
92
|
+
answerEntity(leaf("show", LOCAL_READ, "a base set's columns with what each holds", "show deal", "show lead --json"), "base_stage_set", baseSet)
|
|
93
|
+
.description("the base set in order, with the open rows and mapped stages each column holds, and what is unsorted (unmapped " +
|
|
94
|
+
"or only suggested); the first use takes the owner's only own pipeline of the kind, or makes the default set in " +
|
|
95
|
+
"the owner's language; a read-only store shows that set without making it")
|
|
96
|
+
.addArgument(kindArgument())
|
|
97
|
+
.action(async (chosen, _opts, command) => {
|
|
98
|
+
await run(command, async (store, scope) => setAnswer(await store.baseStages.show(chosen, scope)));
|
|
99
|
+
});
|
|
100
|
+
setCommand("create", "add a stage to a base set", 'create deal "Demo"', 'create lead "Spam" lost')
|
|
101
|
+
.description("add a stage to the base set: an open one goes before the first won or lost stage, a won or lost one last; " +
|
|
102
|
+
"move puts it elsewhere")
|
|
103
|
+
.argument("<name>", "the stage's name, once in its set")
|
|
104
|
+
.addArgument(new Argument("[outcome]", "open, won or lost; open by default").choices(STAGE_OUTCOMES))
|
|
105
|
+
.action(async (chosen, name, given, _opts, command) => {
|
|
106
|
+
await run(command, async (store) => setAnswer(await store.baseStages.add(chosen, { name, ...(given === undefined ? {} : { outcome: given }) })));
|
|
107
|
+
});
|
|
108
|
+
setCommand("rename", "rename a base stage", 'rename deal Proposal "Quote sent"')
|
|
109
|
+
.description("rename a base stage; what maps to it stays mapped")
|
|
110
|
+
.argument("<stage>", baseStage)
|
|
111
|
+
.argument("<name>", "its new name")
|
|
112
|
+
.action(async (chosen, stage, name, _opts, command) => {
|
|
113
|
+
await run(command, async (store) => setAnswer(await store.baseStages.rename(chosen, stage, name)));
|
|
114
|
+
});
|
|
115
|
+
setCommand("move", "put a base stage at another place in its set", "move deal Negotiation 2")
|
|
116
|
+
.description("put a base stage at another place in its set; unconfirmed suggestions follow the new order")
|
|
117
|
+
.argument("<stage>", baseStage)
|
|
118
|
+
.argument("<position>", "its new place, from 1", position)
|
|
119
|
+
.action(async (chosen, stage, at, _opts, command) => {
|
|
120
|
+
await run(command, async (store) => setAnswer(await store.baseStages.move(chosen, stage, at)));
|
|
121
|
+
});
|
|
122
|
+
setCommand("remove", "take a stage out of a base set", "remove deal Negotiation")
|
|
123
|
+
.description("take a stage out of the base set: refused for the last of its outcome and for one the owner's own rows stood " +
|
|
124
|
+
"in; what was mapped to it waits for a new confirm")
|
|
125
|
+
.argument("<stage>", baseStage)
|
|
126
|
+
.action(async (chosen, stage, _opts, command) => {
|
|
127
|
+
await run(command, async (store) => setAnswer(await store.baseStages.remove(chosen, stage)));
|
|
128
|
+
});
|
|
129
|
+
withQuery(answerEntity(leaf("list", LOCAL_READ, "every mapped stage with its base stage, confirmed or suggested", "list confirmed:false", "list kind:deal pipeline:pipeline:3 --json"), "stage_mapping", stageMapping).description("every stage outside the base sets in scope, a CRM's or an own pipeline's, with the base stage it maps to, and whether the owner confirmed that or it is the " +
|
|
130
|
+
"store's suggestion"), MAPPING_QUERY).action(async (words, _opts, command) => {
|
|
131
|
+
const terms = queryTerms(words, MAPPING_QUERY, "stages list");
|
|
132
|
+
await run(command, async (store, scope) => {
|
|
133
|
+
const rows = await store.baseStages.mappings({
|
|
134
|
+
...scope,
|
|
135
|
+
...(terms.has("kind") ? { kind: terms.get("kind") } : {}),
|
|
136
|
+
...(terms.has("pipeline") ? { pipeline: terms.get("pipeline") } : {}),
|
|
137
|
+
});
|
|
138
|
+
const confirmed = terms.get("confirmed");
|
|
139
|
+
const shown = confirmed === undefined ? rows : rows.filter((row) => row.confirmed === (confirmed === "true"));
|
|
140
|
+
return listOf("stages list", {
|
|
141
|
+
items: shown.map(mappingRow),
|
|
142
|
+
limit: Math.max(1, shown.length),
|
|
143
|
+
page: 1,
|
|
144
|
+
has_more: false,
|
|
145
|
+
...(words.length ? { args: { query: words } } : {}),
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
answerEntity(leaf("set", LOCAL_WRITE, "map one stage onto a base stage, confirmed", "set stage:41 Proposal"), "stage_mapping", stageMapping)
|
|
150
|
+
.description("map one stage of a CRM or own pipeline onto a base stage of its kind, confirmed, so a later sync keeps it; an agent's run records " +
|
|
151
|
+
"it as a suggestion the owner confirms")
|
|
152
|
+
.argument("<stage>", "the stage, by its stage:<id> as stages list shows it")
|
|
153
|
+
.argument("<base-stage>", baseStage)
|
|
154
|
+
.action(async (stage, target, _opts, command) => {
|
|
155
|
+
await run(command, async (store, scope) => itemOf(mappingRow(await store.baseStages.map(stage, target, scope, { confirmed: !isAgent(command) }))));
|
|
156
|
+
});
|
|
157
|
+
answerEntity(leaf("confirm", LOCAL_WRITE, "confirm the suggested mappings of a pipeline, or of all", "confirm --pipeline pipeline:3", "confirm --all"), "stage_mapping_confirm", v.strictObject({ confirmed: count }))
|
|
158
|
+
.description("confirm every suggestion of one pipeline, or of all of them in scope, as it stands")
|
|
159
|
+
.option("--pipeline <pipeline>", "pipeline:<id>, or a name only one pipeline has")
|
|
160
|
+
.option("--all", "every pipeline in scope")
|
|
161
|
+
.addOption(new Option("--kind <kind>", "with --all: only deal or only lead stages").choices(DEAL_KINDS))
|
|
162
|
+
.action(async (opts, command) => {
|
|
163
|
+
ownerOnly(command, "stages confirm");
|
|
164
|
+
if ((opts.pipeline === undefined) === (opts.all !== true))
|
|
165
|
+
throw new CliError("validation_error", "give --pipeline <pipeline> or --all", { reason: "stage.base-field" });
|
|
166
|
+
await run(command, async (store, scope) => {
|
|
167
|
+
const target = opts.pipeline === undefined
|
|
168
|
+
? { all: true, ...(opts.kind === undefined ? {} : { kind: opts.kind }) }
|
|
169
|
+
: { pipeline: opts.pipeline };
|
|
170
|
+
return itemOf({ confirmed: await store.baseStages.confirm(target, scope) });
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return stages;
|
|
174
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CliError } from "@wirecat/cli-base";
|
|
2
|
+
/** Telegram's limits; MAX's are looser, so one check serves both. */
|
|
3
|
+
const MAX_DATA_BYTES = 64;
|
|
4
|
+
const MAX_BUTTONS = 8;
|
|
5
|
+
/** `--button` values, `<text>=<data>` each, as one row; the text may not hold `=`, the data may. */
|
|
6
|
+
export const parseButtons = (values) => {
|
|
7
|
+
if (values.length > MAX_BUTTONS) {
|
|
8
|
+
throw new CliError("validation_error", `at most ${MAX_BUTTONS} buttons fit in a row; got ${values.length}`);
|
|
9
|
+
}
|
|
10
|
+
const row = values.map((value) => {
|
|
11
|
+
const cut = value.indexOf("=");
|
|
12
|
+
const text = (cut < 0 ? value : value.slice(0, cut)).trim();
|
|
13
|
+
const data = cut < 0 ? "" : value.slice(cut + 1);
|
|
14
|
+
if (cut < 0 || text === "") {
|
|
15
|
+
throw new CliError("validation_error", `--button wants <text>=<data>, got "${value}"`);
|
|
16
|
+
}
|
|
17
|
+
const bytes = Buffer.byteLength(data, "utf8");
|
|
18
|
+
if (bytes < 1 || bytes > MAX_DATA_BYTES) {
|
|
19
|
+
throw new CliError("validation_error", `--button "${text}": the callback data must be 1 to ${MAX_DATA_BYTES} bytes, got ${bytes}`);
|
|
20
|
+
}
|
|
21
|
+
return { text, data };
|
|
22
|
+
});
|
|
23
|
+
return row.length === 0 ? [] : [row];
|
|
24
|
+
};
|