@wirecat/cli-core 0.642.0 → 0.643.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 +188 -0
- package/dist/attachments/ocr.js +27 -18
- package/dist/attachments/picture-reading.d.ts +51 -0
- package/dist/attachments/picture-reading.js +207 -0
- package/dist/background/backfill.d.ts +4 -2
- package/dist/background/backfill.js +3 -3
- package/dist/background/schedules.d.ts +23 -1
- package/dist/background/schedules.js +45 -17
- package/dist/background/units.d.ts +2 -0
- package/dist/background/units.js +8 -9
- package/dist/calendar/cli/index.js +10 -2
- package/dist/calendar/feeds.js +2 -2
- package/dist/calendar/server-search.js +2 -2
- package/dist/calendar/source.d.ts +4 -3
- package/dist/calendar/sync.js +12 -10
- package/dist/calendar/testing/source-contract.js +5 -4
- package/dist/calendar/testing/source.js +3 -2
- package/dist/cli/complete-command.d.ts +23 -0
- package/dist/cli/complete-command.js +80 -0
- package/dist/cli/context.js +7 -1
- package/dist/cli/effects.d.ts +2 -0
- package/dist/cli/effects.js +2 -0
- package/dist/cli/envelope.js +6 -1
- package/dist/cli/help/first-screen.js +5 -0
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.js +2 -1
- package/dist/cli/list-query.d.ts +3 -1
- package/dist/cli/list-query.js +5 -3
- package/dist/cli/local-only-command.js +9 -0
- package/dist/cli/messenger/backfill-command.js +1 -1
- package/dist/cli/messenger/chat-queries.js +2 -1
- package/dist/cli/messenger/complete-command.d.ts +4 -7
- package/dist/cli/messenger/complete-command.js +31 -98
- package/dist/cli/messenger/contacts-command.js +4 -0
- package/dist/cli/messenger/guard-commands.js +1 -1
- package/dist/cli/messenger/images-command.js +32 -0
- package/dist/cli/messenger/list-result-queries.d.ts +1 -0
- package/dist/cli/messenger/list-result-queries.js +2 -1
- package/dist/cli/messenger/mentions-command.js +3 -3
- package/dist/cli/messenger/message-items.js +1 -0
- package/dist/cli/messenger/messages-command.js +7 -6
- package/dist/cli/messenger/people-queries.d.ts +2 -2
- package/dist/cli/messenger/people-queries.js +4 -4
- package/dist/cli/messenger/search-answers.js +2 -2
- package/dist/cli/messenger/search-command.js +3 -3
- package/dist/cli/messenger/searches-command.js +1 -1
- package/dist/cli/messenger/store-maintenance-command.js +4 -0
- package/dist/cli/messenger/tasks-analysis-command.js +1 -1
- package/dist/cli/messenger/tasks-command.js +2 -2
- package/dist/cli/model-catalogue-command.js +2 -0
- package/dist/cli/picture-reading-command.d.ts +12 -0
- package/dist/cli/picture-reading-command.js +82 -0
- package/dist/cli/program.d.ts +6 -0
- package/dist/cli/program.js +28 -2
- package/dist/cli/schedule/agent-start.d.ts +23 -0
- package/dist/cli/schedule/agent-start.js +115 -0
- package/dist/cli/schedule/harnesses.d.ts +203 -0
- package/dist/cli/schedule/harnesses.js +278 -0
- package/dist/cli/schedule/schedule-command.d.ts +9 -5
- package/dist/cli/schedule/schedule-command.js +89 -79
- package/dist/cli/shared-command-exports.d.ts +186 -0
- package/dist/cli/shared-command-exports.js +2 -0
- package/dist/cli/untrusted-marks.d.ts +25 -0
- package/dist/cli/untrusted-marks.js +102 -0
- package/dist/crm/cli/index.d.ts +1 -0
- package/dist/crm/cli/index.js +6 -5
- package/dist/crm/cli/store.d.ts +30 -0
- package/dist/crm/cli/store.js +63 -0
- package/dist/crm/source.d.ts +6 -4
- package/dist/crm/sync.js +10 -6
- package/dist/crm/testing/source-contract.js +9 -7
- package/dist/crm/testing/source.js +6 -2
- package/dist/crm/testing/sync-contract.js +4 -4
- package/dist/crm/writes.d.ts +5 -2
- package/dist/crm/writes.js +1 -1
- package/dist/documents.d.ts +1 -0
- package/dist/documents.js +1 -0
- package/dist/domain/addresses.d.ts +2 -0
- package/dist/domain/addresses.js +7 -0
- package/dist/domain/attachments.d.ts +2 -0
- package/dist/domain/attachments.js +2 -1
- package/dist/domain/models.d.ts +2 -0
- package/dist/entities/attachment-results.d.ts +3 -0
- package/dist/entities/attachment-results.js +3 -0
- package/dist/entities/attachment.d.ts +2 -0
- package/dist/entities/attachment.js +8 -1
- package/dist/entities/hit.d.ts +1 -0
- package/dist/entities/index.d.ts +21 -4
- package/dist/entities/index.js +3 -2
- package/dist/entities/list-results.d.ts +33 -5
- package/dist/entities/list-results.js +33 -5
- package/dist/errors/reasons.js +30 -1
- package/dist/mail/cli/index.js +7 -6
- package/dist/mcp/agent.d.ts +2 -1
- package/dist/mcp/agent.js +5 -0
- package/dist/mcp/app-server.js +10 -0
- package/dist/mcp/surface.d.ts +7 -2
- package/dist/mcp/surface.js +49 -10
- package/dist/meetings/cli/index.js +6 -1
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/meetings/mcp/index.js +6 -3
- package/dist/meetings/participant-search.d.ts +2 -2
- package/dist/meetings/project-discovery.d.ts +1 -1
- package/dist/meetings/project-evidence-answer.js +2 -2
- package/dist/meetings/reads.d.ts +2 -2
- package/dist/meetings/reads.js +6 -6
- package/dist/meetings/store.d.ts +2 -1
- package/dist/meetings/testing/contract.js +6 -6
- package/dist/meetings/testing/memory.js +7 -2
- package/dist/models/ai.d.ts +1 -1
- package/dist/models/ai.js +3 -1
- package/dist/models/anthropic.js +15 -9
- package/dist/models/index.js +5 -3
- package/dist/models/openai.js +24 -11
- package/dist/models/types.d.ts +8 -0
- package/dist/models/types.js +11 -1
- package/dist/ports/app.d.ts +17 -1
- package/dist/ports/app.js +63 -3
- package/dist/search/lucene/plain.js +45 -3
- package/dist/search/lucene/registry.d.ts +15 -4
- package/dist/search/lucene/registry.js +70 -12
- package/dist/search/lucene/types.d.ts +2 -0
- package/dist/search/lucene/types.js +12 -0
- package/dist/sends/upload.d.ts +8 -1
- package/dist/sends/upload.js +35 -14
- package/dist/services/account-groups.d.ts +11 -0
- package/dist/services/account-groups.js +29 -0
- package/dist/services/agenda.js +1 -0
- package/dist/services/attachments.d.ts +18 -4
- package/dist/services/attachments.js +66 -15
- package/dist/services/conversations.d.ts +2 -4
- package/dist/services/conversations.js +1 -1
- package/dist/services/deal-context.js +5 -5
- package/dist/services/documents/ingestion.js +3 -3
- package/dist/services/documents/knowledge.d.ts +6 -6
- package/dist/services/documents/knowledge.js +1 -2
- package/dist/services/events-search.d.ts +3 -3
- package/dist/services/events-search.js +7 -7
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/meeting-project-discovery.js +1 -1
- package/dist/services/message-resolution.js +10 -3
- package/dist/services/messages-search.js +6 -4
- package/dist/services/metadata.d.ts +1 -1
- package/dist/services/notes-search.d.ts +3 -3
- package/dist/services/notes-search.js +3 -3
- package/dist/services/organization-context.js +12 -9
- package/dist/services/people.d.ts +2 -0
- package/dist/services/people.js +4 -2
- package/dist/services/pictures.d.ts +9 -0
- package/dist/services/pictures.js +34 -28
- package/dist/services/project-status/index.js +1 -1
- package/dist/services/project-status/signals/payments.js +4 -2
- package/dist/services/project-status/signals/promises.js +5 -2
- package/dist/services/proposals/kinds/action.js +1 -1
- package/dist/services/proposals/kinds/fact.js +1 -1
- package/dist/services/proposals/kinds/findings.d.ts +2 -1
- package/dist/services/proposals/kinds/findings.js +12 -5
- package/dist/services/proposals/kinds/identity-link.js +1 -1
- package/dist/services/proposals/kinds/identity-split.js +1 -1
- package/dist/services/proposals/kinds/key-document.js +1 -1
- package/dist/services/proposals/kinds/mail-findings.d.ts +1 -1
- package/dist/services/proposals/kinds/mail-findings.js +11 -5
- package/dist/services/proposals/kinds/meeting-findings.js +10 -4
- package/dist/services/proposals/kinds/memory.js +1 -1
- package/dist/services/proposals/kinds/organization.js +1 -1
- package/dist/services/proposals/kinds/relationship-update.js +1 -1
- package/dist/services/proposals/kinds/relationship.js +1 -1
- package/dist/services/proposals/kinds/shared.d.ts +3 -2
- package/dist/services/proposals/kinds/shared.js +4 -4
- package/dist/services/proposals/kinds/source-review.js +1 -1
- package/dist/services/proposals/kinds/task-close.js +2 -2
- package/dist/services/proposals/registry.js +1 -1
- package/dist/services/proposals/types.d.ts +2 -1
- package/dist/services/search-all-business.js +3 -4
- package/dist/services/search-all.js +13 -14
- package/dist/services/searches.d.ts +2 -4
- package/dist/services/searches.js +1 -4
- package/dist/services/stored-project-gathering.js +6 -1
- package/dist/services/tags.d.ts +2 -4
- package/dist/services/tags.js +1 -1
- package/dist/services/tasks.d.ts +1 -1
- package/dist/services/tasks.js +4 -3
- package/dist/store/account-store.d.ts +2 -1
- package/dist/store/account-store.js +3 -1
- package/dist/store/accounts.d.ts +2 -0
- package/dist/store/accounts.js +8 -0
- package/dist/store/chats.d.ts +5 -0
- package/dist/store/chats.js +4 -0
- package/dist/store/evidence-findings.d.ts +9 -0
- package/dist/store/exports.d.ts +1 -1
- package/dist/store/exports.js +1 -1
- package/dist/store/identity-links.d.ts +3 -1
- package/dist/store/mail-findings.d.ts +9 -0
- package/dist/store/meeting-findings.d.ts +9 -0
- package/dist/store/searches.d.ts +3 -2
- package/dist/store/sqlite/accounts.js +37 -0
- package/dist/store/sqlite/agent-actions.d.ts +2 -1
- package/dist/store/sqlite/agent-actions.js +10 -4
- package/dist/store/sqlite/business-contracts.d.ts +3 -1
- package/dist/store/sqlite/business-contracts.js +7 -3
- package/dist/store/sqlite/business-search.d.ts +2 -1
- package/dist/store/sqlite/business-search.js +6 -4
- package/dist/store/sqlite/deals.d.ts +6 -4
- package/dist/store/sqlite/deals.js +12 -7
- package/dist/store/sqlite/evidence-findings.js +78 -9
- package/dist/store/sqlite/facts.d.ts +2 -1
- package/dist/store/sqlite/facts.js +6 -2
- package/dist/store/sqlite/finance.d.ts +4 -2
- package/dist/store/sqlite/finance.js +13 -6
- package/dist/store/sqlite/findings-core.d.ts +56 -2
- package/dist/store/sqlite/findings-core.js +109 -22
- package/dist/store/sqlite/identities.d.ts +4 -0
- package/dist/store/sqlite/identities.js +12 -3
- package/dist/store/sqlite/identity-proposals.js +34 -4
- package/dist/store/sqlite/lucene-fields.d.ts +2 -0
- package/dist/store/sqlite/lucene-fields.js +28 -2
- package/dist/store/sqlite/lucene.js +21 -10
- package/dist/store/sqlite/mail-findings.js +60 -22
- package/dist/store/sqlite/meeting-findings.js +53 -7
- package/dist/store/sqlite/meeting-participant-search.js +4 -5
- package/dist/store/sqlite/meetings.js +7 -3
- package/dist/store/sqlite/memories.d.ts +4 -2
- package/dist/store/sqlite/memories.js +13 -6
- package/dist/store/sqlite/money-transactions.d.ts +3 -1
- package/dist/store/sqlite/money-transactions.js +7 -3
- package/dist/store/sqlite/name-traces.d.ts +3 -3
- package/dist/store/sqlite/name-traces.js +29 -2
- package/dist/store/sqlite/orders.d.ts +3 -1
- package/dist/store/sqlite/orders.js +5 -2
- package/dist/store/sqlite/people-list.js +67 -22
- package/dist/store/sqlite/person-match-scan.d.ts +3 -1
- package/dist/store/sqlite/person-match-scan.js +97 -7
- package/dist/store/sqlite/products.d.ts +3 -1
- package/dist/store/sqlite/products.js +5 -2
- package/dist/store/sqlite/proposed-actions.d.ts +2 -1
- package/dist/store/sqlite/proposed-actions.js +7 -3
- package/dist/store/sqlite/query-filter.d.ts +4 -0
- package/dist/store/sqlite/query-filter.js +14 -0
- package/dist/store/sqlite/reads.d.ts +1 -0
- package/dist/store/sqlite/reads.js +14 -0
- package/dist/store/sqlite/records.d.ts +3 -1
- package/dist/store/sqlite/records.js +7 -5
- package/dist/store/sqlite/rows-page.d.ts +3 -0
- package/dist/store/sqlite/rows-page.js +4 -0
- package/dist/store/sqlite/searches.d.ts +2 -1
- package/dist/store/sqlite/searches.js +3 -1
- package/dist/store/sqlite/subscriptions.d.ts +5 -2
- package/dist/store/sqlite/subscriptions.js +13 -6
- package/dist/store/sqlite/task-board.js +27 -0
- package/dist/store/sqlite/task-find.d.ts +15 -0
- package/dist/store/sqlite/task-find.js +1 -0
- package/dist/store/sqlite/wallets.d.ts +3 -1
- package/dist/store/sqlite/wallets.js +7 -3
- package/dist/store/sqlite/work-tasks.d.ts +3 -11
- package/dist/store/sqlite/work-tasks.js +8 -4
- package/package.json +2 -2
- package/parity.json +24 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import type { StoreContext } from "./open.js";
|
|
2
3
|
/** Unnamed runs kept, newest first; a saved search is never pruned. */
|
|
3
4
|
export declare const HISTORY_KEPT = 1000;
|
|
@@ -28,7 +29,7 @@ export declare const findSearch: ({ database }: StoreContext, reference: string)
|
|
|
28
29
|
export declare const saveSearch: (context: StoreContext, name: string, search: SearchRecord, replace: boolean) => StoredSearch;
|
|
29
30
|
export declare const savedSearches: ({ database }: StoreContext, commands?: readonly SearchCommand[]) => StoredSearch[];
|
|
30
31
|
/** Runs, newest first: unnamed ones and saved searches that have run. One more than `limit` says there are more. */
|
|
31
|
-
export declare const searchHistory: ({ database }: StoreContext, limit: number, offset?: number, commands?: readonly SearchCommand[]) => StoredSearch
|
|
32
|
+
export declare const searchHistory: ({ database }: StoreContext, limit: number, offset?: number, commands?: readonly SearchCommand[]) => ListResult<StoredSearch>;
|
|
32
33
|
export declare const deleteSearch: (context: StoreContext, reference: string) => StoredSearch;
|
|
33
34
|
/** Unnamed runs only; saved searches stay. */
|
|
34
35
|
export declare const clearHistory: ({ database }: StoreContext, commands?: readonly SearchCommand[]) => number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliError, singleLine } from "@wirecat/cli-base";
|
|
2
|
+
import { pageOfRows } from "./rows-page.js";
|
|
2
3
|
import { toIso } from "./values.js";
|
|
3
4
|
/** Unnamed runs kept, newest first; a saved search is never pruned. */
|
|
4
5
|
export const HISTORY_KEPT = 1000;
|
|
@@ -74,10 +75,11 @@ export const savedSearches = ({ database }, commands) => {
|
|
|
74
75
|
/** Runs, newest first: unnamed ones and saved searches that have run. One more than `limit` says there are more. */
|
|
75
76
|
export const searchHistory = ({ database }, limit, offset = 0, commands) => {
|
|
76
77
|
const only = commandFilter(commands);
|
|
77
|
-
|
|
78
|
+
const rows = database
|
|
78
79
|
.prepare(`SELECT ${COLUMNS} FROM searches WHERE last_run_at IS NOT NULL${only.sql} ORDER BY last_run_at DESC, id DESC LIMIT ? OFFSET ?`)
|
|
79
80
|
.all(...only.values, limit + 1, offset)
|
|
80
81
|
.map(searchOf);
|
|
82
|
+
return pageOfRows(rows, limit, offset);
|
|
81
83
|
};
|
|
82
84
|
export const deleteSearch = (context, reference) => {
|
|
83
85
|
const found = mustFind(context, reference);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import { type Interval, type SubscriptionStatus } from "../../domain/business.js";
|
|
2
3
|
import { type FinanceReview, type InvoiceDirection } from "../../domain/finance.js";
|
|
3
4
|
import { type Money } from "../../domain/money.js";
|
|
@@ -99,12 +100,14 @@ export interface SubscriptionFilter {
|
|
|
99
100
|
renewsBy?: string;
|
|
100
101
|
/** 1–500, 100 by default; newest written first. */
|
|
101
102
|
limit?: number;
|
|
103
|
+
offset?: number;
|
|
102
104
|
}
|
|
103
105
|
export interface PriceFilter {
|
|
104
106
|
review?: FinanceReview;
|
|
105
107
|
proposedBy?: ProposedByFilter;
|
|
106
108
|
/** 1–500, 100 by default; newest written first. */
|
|
107
109
|
limit?: number;
|
|
110
|
+
offset?: number;
|
|
108
111
|
}
|
|
109
112
|
/**
|
|
110
113
|
* Subscriptions the owner bills or pays, and their prices. A price is a row of its own and never changes. Confirming a
|
|
@@ -115,7 +118,7 @@ export interface PriceFilter {
|
|
|
115
118
|
export interface SubscriptionsStore {
|
|
116
119
|
add(input: SubscriptionInput): Promise<SubscriptionDetail>;
|
|
117
120
|
get(reference: string): Promise<SubscriptionDetail>;
|
|
118
|
-
list(filter?: SubscriptionFilter): Promise<Subscription
|
|
121
|
+
list(filter?: SubscriptionFilter): Promise<ListResult<Subscription>>;
|
|
119
122
|
/** The owner changes any; a bot only one it proposed that is still proposed. */
|
|
120
123
|
update(reference: string, input: SubscriptionUpdate): Promise<SubscriptionDetail>;
|
|
121
124
|
addPrice(reference: string, input: PriceInput & Omit<Written, "project" | "evidence">): Promise<SubscriptionPrice>;
|
|
@@ -125,7 +128,7 @@ export interface SubscriptionsStore {
|
|
|
125
128
|
/** `subscription_price:<id>`. */
|
|
126
129
|
price(reference: string): Promise<SubscriptionPrice>;
|
|
127
130
|
/** Proposed or decided prices, newest written first, as the review inbox lists them. */
|
|
128
|
-
prices(filter?: PriceFilter): Promise<SubscriptionPrice
|
|
131
|
+
prices(filter?: PriceFilter): Promise<ListResult<SubscriptionPrice>>;
|
|
129
132
|
}
|
|
130
133
|
type SubscriptionOperations = {
|
|
131
134
|
[K in keyof SubscriptionsStore]: SubscriptionsStore[K] extends (...args: infer A) => Promise<infer R> ? (...args: A) => R : never;
|
|
@@ -6,6 +6,7 @@ import { ownerPerson, proposedBySql } from "./actors.js";
|
|
|
6
6
|
import { authorOf, projectId } from "./memories.js";
|
|
7
7
|
import { requiredThing } from "./notes.js";
|
|
8
8
|
import { iso, isoDate, limitOf, oneOf, reasonOf, refuse, reviewedRowsOver, text, } from "./reviewed.js";
|
|
9
|
+
import { pageOfRows } from "./rows-page.js";
|
|
9
10
|
import { write } from "./transaction.js";
|
|
10
11
|
const SUBSCRIPTIONS = "SELECT s.*, b.name AS author_name, b.kind AS author_kind FROM subscriptions s " +
|
|
11
12
|
"LEFT JOIN bots b ON s.author_type = 'bot' AND b.id = s.author_id";
|
|
@@ -224,6 +225,8 @@ export const subscriptionOperationsOver = (context) => {
|
|
|
224
225
|
},
|
|
225
226
|
get: (reference) => detailOf(reference),
|
|
226
227
|
list: (filter = {}) => {
|
|
228
|
+
const limit = limitOf(filter.limit);
|
|
229
|
+
const offset = Math.max(filter.offset ?? 0, 0);
|
|
227
230
|
const project = filter.project === undefined ? null : projectId(database, filter.project);
|
|
228
231
|
const supplier = partyThing(filter.supplier, "the supplier");
|
|
229
232
|
const customer = partyThing(filter.customer, "the customer");
|
|
@@ -232,14 +235,15 @@ export const subscriptionOperationsOver = (context) => {
|
|
|
232
235
|
const review = filter.review === undefined ? null : oneOf(filter.review, FINANCE_REVIEWS, "a review");
|
|
233
236
|
const renews = isoDate(filter.renewsBy, "the last renewal day");
|
|
234
237
|
const by = proposedBySql("s.author_type", "s.author_id", filter.proposedBy);
|
|
235
|
-
|
|
238
|
+
const rows = database
|
|
236
239
|
.prepare(`${SUBSCRIPTIONS} WHERE s.deleted_at IS NULL AND (? IS NULL OR s.status = ?) AND (? IS NULL OR s.direction = ?) ` +
|
|
237
240
|
"AND (? IS NULL OR s.review = ?) AND (? IS NULL OR s.project_id = ?) " +
|
|
238
241
|
"AND (? IS NULL OR (s.supplier_type = ? AND s.supplier_id = ?)) " +
|
|
239
242
|
"AND (? IS NULL OR (s.customer_type = ? AND s.customer_id = ?)) " +
|
|
240
|
-
`AND (? IS NULL OR s.next_renewal_date <= ?) AND ${by.sql} ORDER BY s.created_at DESC, s.id DESC LIMIT ?`)
|
|
241
|
-
.all(status, status, direction, direction, review, review, project, project, supplier?.type ?? null, supplier?.type ?? null, supplier?.id ?? null, customer?.type ?? null, customer?.type ?? null, customer?.id ?? null, renews, renews, ...by.params,
|
|
243
|
+
`AND (? IS NULL OR s.next_renewal_date <= ?) AND ${by.sql} ORDER BY s.created_at DESC, s.id DESC LIMIT ? OFFSET ?`)
|
|
244
|
+
.all(status, status, direction, direction, review, review, project, project, supplier?.type ?? null, supplier?.type ?? null, supplier?.id ?? null, customer?.type ?? null, customer?.type ?? null, customer?.id ?? null, renews, renews, ...by.params, limit + 1, offset)
|
|
242
245
|
.map(subscriptionOf);
|
|
246
|
+
return pageOfRows(rows, limit, offset);
|
|
243
247
|
},
|
|
244
248
|
update: (reference, { by, ...fields }) => {
|
|
245
249
|
const row = rowOf(reference);
|
|
@@ -269,12 +273,15 @@ export const subscriptionOperationsOver = (context) => {
|
|
|
269
273
|
reject: (reference, by, reason) => decide(reference, by, reason, false),
|
|
270
274
|
price: (reference) => priceOf(priceRowOf(reference)),
|
|
271
275
|
prices: (filter = {}) => {
|
|
276
|
+
const limit = limitOf(filter.limit);
|
|
277
|
+
const offset = Math.max(filter.offset ?? 0, 0);
|
|
272
278
|
const review = filter.review === undefined ? null : oneOf(filter.review, FINANCE_REVIEWS, "a review");
|
|
273
279
|
const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
|
|
274
|
-
|
|
275
|
-
.prepare(`${PRICES} WHERE (? IS NULL OR p.review = ?) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ?`)
|
|
276
|
-
.all(review, review, ...by.params,
|
|
280
|
+
const rows = database
|
|
281
|
+
.prepare(`${PRICES} WHERE (? IS NULL OR p.review = ?) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ? OFFSET ?`)
|
|
282
|
+
.all(review, review, ...by.params, limit + 1, offset)
|
|
277
283
|
.map(priceOf);
|
|
284
|
+
return pageOfRows(rows, limit, offset);
|
|
278
285
|
},
|
|
279
286
|
};
|
|
280
287
|
};
|
|
@@ -29,6 +29,11 @@ export const PROJECT_TASK_FIELDS = [
|
|
|
29
29
|
}),
|
|
30
30
|
field("agent", "kw", "agent:hermes", { relation: "the agent working on it, by name; none or any" }),
|
|
31
31
|
field("parent", "kw", "parent:HRB-1", { relation: "the subtasks of a task, by its key; none or any" }),
|
|
32
|
+
field("related", "ref", 'related:"deal:7"', {
|
|
33
|
+
operators: ["term", "phrase"],
|
|
34
|
+
relation: "the tasks of a deal, lead or organization: its project's tasks and those its CRM stages opened; an " +
|
|
35
|
+
"organization's are its projects', its deals' and its leads'",
|
|
36
|
+
}),
|
|
32
37
|
field("due", "time", "due:[today TO 2026-12-31]", {
|
|
33
38
|
relation: "the due date; today, tomorrow and yesterday are your calendar days; NOT due:* has none",
|
|
34
39
|
}),
|
|
@@ -154,6 +159,27 @@ const parentWhere = (node) => {
|
|
|
154
159
|
params: [key.toUpperCase(), key, key.toUpperCase()],
|
|
155
160
|
};
|
|
156
161
|
};
|
|
162
|
+
const PROJECTS_OF_DEALS = (table, by) => `SELECT project_id FROM ${table} WHERE ${by} = ? AND deleted_at IS NULL AND project_id IS NOT NULL`;
|
|
163
|
+
const REFS_OF_DEALS = (table, kind) => `SELECT '${kind}:' || id FROM ${table} WHERE organization_id = ? AND deleted_at IS NULL`;
|
|
164
|
+
/** What `deals context` and `organizations context` count as a deal's or an organization's tasks, as one filter. */
|
|
165
|
+
const relatedWhere = (node) => {
|
|
166
|
+
const [, kind, id] = /^(deal|lead|organization):(\d+)$/.exec(node.value.trim().toLowerCase()) ?? [];
|
|
167
|
+
if (kind === undefined || id === undefined)
|
|
168
|
+
throw new CliError("validation_error", `related: takes "deal:<id>", "lead:<id>" or "organization:<id>", not "${node.value}"`);
|
|
169
|
+
const number = Number(id);
|
|
170
|
+
if (kind === "organization")
|
|
171
|
+
return {
|
|
172
|
+
sql: `(t.project_id IN (SELECT id FROM projects WHERE organization_id = ? AND deleted_at IS NULL UNION ` +
|
|
173
|
+
`${PROJECTS_OF_DEALS("deals", "organization_id")} UNION ${PROJECTS_OF_DEALS("leads", "organization_id")}) ` +
|
|
174
|
+
`OR t.source_group IN (${REFS_OF_DEALS("deals", "deal")} UNION ${REFS_OF_DEALS("leads", "lead")}))`,
|
|
175
|
+
params: [number, number, number, number, number],
|
|
176
|
+
};
|
|
177
|
+
const table = kind === "deal" ? "deals" : "leads";
|
|
178
|
+
return {
|
|
179
|
+
sql: `(t.source_group = ? OR t.project_id IN (${PROJECTS_OF_DEALS(table, "id")}))`,
|
|
180
|
+
params: [`${kind}:${number}`, number],
|
|
181
|
+
};
|
|
182
|
+
};
|
|
157
183
|
const truth = (node, sql) => ({
|
|
158
184
|
sql: node.value.toLowerCase() === "true" ? sql : `NOT (${sql})`,
|
|
159
185
|
params: [],
|
|
@@ -187,6 +213,7 @@ export const projectTaskColumns = (now, zone, database) => ({
|
|
|
187
213
|
priority: { where: priorityWhere },
|
|
188
214
|
agent: { where: agentWhere },
|
|
189
215
|
parent: { where: parentWhere },
|
|
216
|
+
related: { where: relatedWhere },
|
|
190
217
|
due: { type: "time", sql: "t.due_at" },
|
|
191
218
|
created: { type: "time", sql: "t.created_at" },
|
|
192
219
|
closed: { type: "time", sql: "t.closed_at" },
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TaskState } from "../../tasks/index.js";
|
|
2
|
+
import type { Where } from "./query-filter.js";
|
|
3
|
+
import type { TaskType } from "./work-tasks.js";
|
|
4
|
+
/** What `tasks.find` narrows by. */
|
|
5
|
+
export interface TaskFind {
|
|
6
|
+
project?: string;
|
|
7
|
+
type?: TaskType;
|
|
8
|
+
status?: TaskState;
|
|
9
|
+
/** `person:<id>`, in any role. */
|
|
10
|
+
assignee?: string;
|
|
11
|
+
/** A compiled list query over `tasks t`. */
|
|
12
|
+
where?: Where;
|
|
13
|
+
limit?: number;
|
|
14
|
+
offset?: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
1
2
|
import { type WalletKind } from "../../domain/business.js";
|
|
2
3
|
import { type Money } from "../../domain/money.js";
|
|
3
4
|
import { type Author } from "./memories.js";
|
|
@@ -69,6 +70,7 @@ export interface WalletFilter {
|
|
|
69
70
|
closed?: boolean;
|
|
70
71
|
/** 1–500, 100 by default; by name. */
|
|
71
72
|
limit?: number;
|
|
73
|
+
offset?: number;
|
|
72
74
|
}
|
|
73
75
|
/** Bank accounts, cards, cash and wallets (`wallet:<id>`), written directly; their balances are computed. */
|
|
74
76
|
export interface WalletsStore {
|
|
@@ -77,7 +79,7 @@ export interface WalletsStore {
|
|
|
77
79
|
get(reference: string, options?: {
|
|
78
80
|
until?: string;
|
|
79
81
|
}): Promise<Wallet>;
|
|
80
|
-
list(filter?: WalletFilter): Promise<Wallet
|
|
82
|
+
list(filter?: WalletFilter): Promise<ListResult<Wallet>>;
|
|
81
83
|
update(reference: string, input: WalletUpdate): Promise<Wallet>;
|
|
82
84
|
}
|
|
83
85
|
type WalletOperations = {
|
|
@@ -4,6 +4,7 @@ import { fold } from "../normalize.js";
|
|
|
4
4
|
import { authorActor, authorOf } from "./memories.js";
|
|
5
5
|
import { requiredThing } from "./notes.js";
|
|
6
6
|
import { iso, isoDate, limitOf, oneOf, refuse, reviewedRowsOver, text, } from "./reviewed.js";
|
|
7
|
+
import { pageOfRows } from "./rows-page.js";
|
|
7
8
|
import { write } from "./transaction.js";
|
|
8
9
|
const WALLETS = "SELECT w.*, b.name AS author_name, b.kind AS author_kind FROM financial_accounts w " +
|
|
9
10
|
"LEFT JOIN bots b ON w.author_type = 'bot' AND b.id = w.author_id";
|
|
@@ -103,14 +104,17 @@ export const walletOperationsOver = (context) => {
|
|
|
103
104
|
},
|
|
104
105
|
get: (reference, options = {}) => walletOf(rowOf(reference), isoDate(options.until, "the last day counted") ?? today()),
|
|
105
106
|
list: (filter = {}) => {
|
|
107
|
+
const limit = limitOf(filter.limit);
|
|
108
|
+
const offset = Math.max(filter.offset ?? 0, 0);
|
|
106
109
|
const kind = filter.kind === undefined ? null : oneOf(filter.kind, WALLET_KINDS, "a kind");
|
|
107
110
|
const currency = filter.currency === undefined ? null : currencyOf(filter.currency);
|
|
108
111
|
const closed = filter.closed === undefined ? null : filter.closed ? 1 : 0;
|
|
109
|
-
|
|
112
|
+
const rows = database
|
|
110
113
|
.prepare(`${WALLETS} WHERE w.deleted_at IS NULL AND (? IS NULL OR w.kind = ?) AND (? IS NULL OR w.currency = ?) ` +
|
|
111
|
-
"AND (? IS NULL OR (w.closed_date IS NOT NULL) = ?) ORDER BY w.name_folded, w.id LIMIT ?")
|
|
112
|
-
.all(kind, kind, currency, currency, closed, closed,
|
|
114
|
+
"AND (? IS NULL OR (w.closed_date IS NOT NULL) = ?) ORDER BY w.name_folded, w.id LIMIT ? OFFSET ?")
|
|
115
|
+
.all(kind, kind, currency, currency, closed, closed, limit + 1, offset)
|
|
113
116
|
.map((row) => walletOf(row, today()));
|
|
117
|
+
return pageOfRows(rows, limit, offset);
|
|
114
118
|
},
|
|
115
119
|
update: (reference, input) => {
|
|
116
120
|
const row = rowOf(reference);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { QueryAst } from "@wirecat/cli-base/query";
|
|
2
|
+
import type { ListResult } from "@wirecat/cli-base/standards";
|
|
2
3
|
import { TASK_TYPES, WORK_TASK_TYPES } from "../../domain/knowledge.js";
|
|
3
4
|
import { type PriorityLabel, type TaskState, type TaskVerdict } from "../../tasks/index.js";
|
|
4
5
|
import type { CacheDatabase } from "../driver.js";
|
|
5
6
|
import type { Actor } from "./actors.js";
|
|
6
7
|
import { type Author } from "./memories.js";
|
|
7
8
|
import type { StoreContext } from "./open.js";
|
|
8
|
-
import { type Where } from "./query-filter.js";
|
|
9
9
|
import { type DueGroup, type TaskSort } from "./task-board.js";
|
|
10
10
|
import { type CloseSuggestion } from "./task-close.js";
|
|
11
11
|
import { type NamedAuthor, type TaskComment } from "./task-comments.js";
|
|
12
|
+
import type { TaskFind } from "./task-find.js";
|
|
12
13
|
import { type TaskRelationsStore } from "./task-relations.js";
|
|
13
14
|
export declare const TASK_ROLES: readonly ["assignee", "reviewer", "watcher"];
|
|
14
15
|
export declare const TASK_EVENT_KINDS: readonly ["created", "title", "description", "status", "assigned", "unassigned", "due", "priority", "moved", "linked", "unlinked", "category", "close-suggestion", "agent", "claimed", "released", "next-check", "resolution", "verdict", "close-certainty", "tags", "project", "type"];
|
|
@@ -205,16 +206,7 @@ export interface WorkTasks extends TaskRelationsStore {
|
|
|
205
206
|
* account's task, a deleted one or none.
|
|
206
207
|
*/
|
|
207
208
|
projectTask(id: string): Promise<boolean>;
|
|
208
|
-
find(filter:
|
|
209
|
-
project?: string;
|
|
210
|
-
type?: TaskType;
|
|
211
|
-
status?: TaskState;
|
|
212
|
-
/** `person:<id>`, in any role. */
|
|
213
|
-
assignee?: string;
|
|
214
|
-
/** A compiled list query over `tasks t`. */
|
|
215
|
-
where?: Where;
|
|
216
|
-
limit?: number;
|
|
217
|
-
}): Promise<TaskDetails[]>;
|
|
209
|
+
find(filter: TaskFind): Promise<ListResult<TaskDetails>>;
|
|
218
210
|
events(id: string): Promise<TaskEvent[]>;
|
|
219
211
|
/** A note about the task in the author's name, as an agent's comment is the agent's; the revision stays. */
|
|
220
212
|
comment(id: string, text: string, by: Author): Promise<TaskComment>;
|
|
@@ -9,6 +9,7 @@ import { idsOf } from "./merged-persons.js";
|
|
|
9
9
|
import { CORPORA, drainCorpus } from "./note-index.js";
|
|
10
10
|
import { requiredThing } from "./notes.js";
|
|
11
11
|
import { queryFilter } from "./query-filter.js";
|
|
12
|
+
import { pageOfRows } from "./rows-page.js";
|
|
12
13
|
import { stemmerCache } from "./stems.js";
|
|
13
14
|
import { BOARD_SCOPE, boardOrder, dueGroups, mergedAssignees, projectTaskColumns, TASK_PEOPLE, withoutField, } from "./task-board.js";
|
|
14
15
|
import { closeSuggestionOf, SUGGESTION_COLUMNS } from "./task-close.js";
|
|
@@ -505,18 +506,21 @@ export const workTaskOperationsOver = (context) => {
|
|
|
505
506
|
.get(row);
|
|
506
507
|
return project !== undefined && String(project.key) !== inboxKey(String(project.name));
|
|
507
508
|
},
|
|
508
|
-
find: async ({ project, type, status, assignee, where, limit = 100 }) => {
|
|
509
|
+
find: async ({ project, type, status, assignee, where, limit = 100, offset = 0 }) => {
|
|
509
510
|
if (type !== undefined && !TASK_TYPES.includes(type))
|
|
510
511
|
throw new CliError("validation_error", `a task's type is one of ${TASK_TYPES.join(", ")}`);
|
|
511
512
|
const projectId = project === undefined ? null : projectOf(project);
|
|
512
513
|
const person = assignee === undefined ? null : personOf(assignee);
|
|
513
|
-
|
|
514
|
+
const most = Math.min(Math.max(limit, 1), 500);
|
|
515
|
+
const from = Math.max(0, Math.trunc(offset));
|
|
516
|
+
const rows = database
|
|
514
517
|
.prepare("SELECT * FROM tasks t WHERE deleted_at IS NULL AND (? IS NULL OR project_id = ?) AND (? IS NULL OR type = ?) " +
|
|
515
518
|
"AND (? IS NULL OR status = ?) AND (? IS NULL OR EXISTS (SELECT 1 FROM task_assignments a " +
|
|
516
519
|
"WHERE a.task_id = t.id AND a.assignee_type = 'person' AND a.assignee_id = ?)) " +
|
|
517
|
-
`AND (${where?.sql || "1"}) ORDER BY priority_score IS NULL, priority_score DESC, created_at, id LIMIT ?`)
|
|
518
|
-
.all(projectId, projectId, type ?? null, type ?? null, status ?? null, status ?? null, person, person, ...(where?.params ?? []),
|
|
520
|
+
`AND (${where?.sql || "1"}) ORDER BY priority_score IS NULL, priority_score DESC, created_at, id LIMIT ? OFFSET ?`)
|
|
521
|
+
.all(projectId, projectId, type ?? null, type ?? null, status ?? null, status ?? null, person, person, ...(where?.params ?? []), most + 1, from)
|
|
519
522
|
.map(detailsOf);
|
|
523
|
+
return pageOfRows(rows, most, from);
|
|
520
524
|
},
|
|
521
525
|
claim: async (id, holder, until) => {
|
|
522
526
|
const task = required(id);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.643.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",
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
"@types/node": "^22.20.5",
|
|
279
279
|
"@types/pngjs": "6.0.5",
|
|
280
280
|
"@vitest/coverage-v8": "^5.0.5",
|
|
281
|
-
"@wirecat/cli-base": "0.
|
|
281
|
+
"@wirecat/cli-base": "0.97.0",
|
|
282
282
|
"@wirecat/cli-core-legacy-tags": "npm:@wirecat/cli-core@0.414.0",
|
|
283
283
|
"ajv": "8.17.1",
|
|
284
284
|
"commander": "15.0.0",
|
package/parity.json
CHANGED
|
@@ -3235,6 +3235,12 @@
|
|
|
3235
3235
|
"images models list": {
|
|
3236
3236
|
"in": "all"
|
|
3237
3237
|
},
|
|
3238
|
+
"images read": {
|
|
3239
|
+
"in": "all",
|
|
3240
|
+
"options": {
|
|
3241
|
+
"--attachment": "all"
|
|
3242
|
+
}
|
|
3243
|
+
},
|
|
3238
3244
|
"inbox": {
|
|
3239
3245
|
"in": "all",
|
|
3240
3246
|
"options": {
|
|
@@ -4017,6 +4023,12 @@
|
|
|
4017
4023
|
"wa": "wa backlog: mount the shared schedule command"
|
|
4018
4024
|
},
|
|
4019
4025
|
"options": {
|
|
4026
|
+
"--allow-dangerous": {
|
|
4027
|
+
"in": ["max", "tg"],
|
|
4028
|
+
"planned": {
|
|
4029
|
+
"wa": "wa backlog: mount the shared schedule command"
|
|
4030
|
+
}
|
|
4031
|
+
},
|
|
4020
4032
|
"--at": {
|
|
4021
4033
|
"in": ["max", "tg"],
|
|
4022
4034
|
"planned": {
|
|
@@ -4067,6 +4079,18 @@
|
|
|
4067
4079
|
}
|
|
4068
4080
|
}
|
|
4069
4081
|
},
|
|
4082
|
+
"schedule agents": {
|
|
4083
|
+
"in": ["max", "tg"],
|
|
4084
|
+
"planned": {
|
|
4085
|
+
"wa": "wa backlog: mount the shared schedule command"
|
|
4086
|
+
}
|
|
4087
|
+
},
|
|
4088
|
+
"schedule agents list": {
|
|
4089
|
+
"in": ["max", "tg"],
|
|
4090
|
+
"planned": {
|
|
4091
|
+
"wa": "wa backlog: mount the shared schedule command"
|
|
4092
|
+
}
|
|
4093
|
+
},
|
|
4070
4094
|
"schedule command": {
|
|
4071
4095
|
"in": ["max", "tg"],
|
|
4072
4096
|
"planned": {
|