@wirecat/cli-core 0.696.0 → 0.697.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 +30 -0
- package/dist/cli/bot/api-http.d.ts +1 -1
- package/dist/cli/bot/api-http.js +77 -5
- package/dist/cli/bot/api-input.d.ts +5 -0
- package/dist/cli/bot/api-input.js +55 -0
- package/dist/cli/bot/api.d.ts +2 -0
- package/dist/cli/bot/api.js +12 -3
- package/dist/cli/messenger/store-maintenance-command.js +3 -2
- package/dist/cli/service-api-manifest.js +7 -4
- package/dist/cli/service-api.js +6 -2
- package/dist/crm/manifest/manifest.d.ts +2 -0
- package/dist/crm/manifest/manifest.js +2 -1
- package/dist/crm/manifest/map.d.ts +2 -1
- package/dist/crm/manifest/map.js +2 -1
- package/dist/domain/tracker.d.ts +100 -0
- package/dist/domain/tracker.js +28 -0
- package/dist/errors/reasons.js +1 -0
- package/dist/manifest/index.d.ts +9 -5
- package/dist/manifest/index.js +18 -7
- package/dist/store/exports.d.ts +1 -0
- package/dist/store/exports.js +1 -0
- package/dist/store/recover.js +2 -0
- package/dist/store/sqlite/account-purge.js +1 -0
- package/dist/store/sqlite/crm-files.d.ts +3 -0
- package/dist/store/sqlite/crm-files.js +2 -2
- package/dist/store/sqlite/manifest.js +2 -0
- package/dist/store/sqlite/migrations.generated.js +17 -0
- package/dist/store/sqlite/schema.d.ts +252 -0
- package/dist/store/sqlite/schema.js +28 -0
- package/dist/store/sqlite/tracker.d.ts +82 -0
- package/dist/store/sqlite/tracker.js +210 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store/store.js +5 -0
- package/dist/tracker/cli/index.d.ts +24 -0
- package/dist/tracker/cli/index.js +279 -0
- package/dist/tracker/index.d.ts +8 -0
- package/dist/tracker/index.js +7 -0
- package/dist/tracker/manifest/manifest.d.ts +76 -0
- package/dist/tracker/manifest/manifest.js +139 -0
- package/dist/tracker/manifest/map.d.ts +10 -0
- package/dist/tracker/manifest/map.js +86 -0
- package/dist/tracker/manifest/source.d.ts +18 -0
- package/dist/tracker/manifest/source.js +174 -0
- package/dist/tracker/source.d.ts +55 -0
- package/dist/tracker/source.js +1 -0
- package/dist/tracker/sync.d.ts +60 -0
- package/dist/tracker/sync.js +254 -0
- package/dist/tracker/tasks.d.ts +18 -0
- package/dist/tracker/tasks.js +29 -0
- package/dist/tracker/testing/index.d.ts +2 -0
- package/dist/tracker/testing/index.js +2 -0
- package/dist/tracker/testing/source-contract.d.ts +46 -0
- package/dist/tracker/testing/source-contract.js +246 -0
- package/dist/tracker/testing/source.d.ts +31 -0
- package/dist/tracker/testing/source.js +141 -0
- package/package.json +12 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { trackerBodyOf, trackerParentOf, trackerTitleOf, } from "../../domain/tracker.js";
|
|
2
|
+
import { fold, normalize } from "../normalize.js";
|
|
3
|
+
import { accountPk, findAccountPk } from "./accounts.js";
|
|
4
|
+
import { excerptOf, matchOf } from "./crm-files.js";
|
|
5
|
+
import { write } from "./transaction.js";
|
|
6
|
+
const MOST = 500;
|
|
7
|
+
const itemOf = (row) => ({
|
|
8
|
+
kind: String(row.kind),
|
|
9
|
+
record: JSON.parse(String(row.data)),
|
|
10
|
+
deletedAt: row.deleted_at == null ? null : Number(row.deleted_at),
|
|
11
|
+
syncedAt: Number(row.synced_at),
|
|
12
|
+
});
|
|
13
|
+
const COLUMNS = "t.kind, t.data, t.deleted_at, t.synced_at";
|
|
14
|
+
const definedOnly = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
15
|
+
/** `store rebuild`: the normalized copies follow the current normalizer, then the word index is filled again. */
|
|
16
|
+
export const resetTrackerItemWords = (database) => {
|
|
17
|
+
if (!database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'tracker_item_words'").get())
|
|
18
|
+
return 0;
|
|
19
|
+
return write(database, () => {
|
|
20
|
+
const update = database.prepare("UPDATE tracker_items SET normalized_text = ? WHERE id = ?");
|
|
21
|
+
for (const row of database.prepare("SELECT id, title, body, normalized_text FROM tracker_items").all()) {
|
|
22
|
+
const normalized = normalize([row.title, row.body].filter(Boolean).join("\n"));
|
|
23
|
+
if (normalized !== row.normalized_text)
|
|
24
|
+
update.run(normalized, Number(row.id));
|
|
25
|
+
}
|
|
26
|
+
database.exec("INSERT INTO tracker_item_words (tracker_item_words) VALUES ('delete-all')");
|
|
27
|
+
const { changes } = database
|
|
28
|
+
.prepare("INSERT INTO tracker_item_words (rowid, normalized_text) SELECT id, normalized_text FROM tracker_items " +
|
|
29
|
+
"WHERE normalized_text <> ''")
|
|
30
|
+
.run();
|
|
31
|
+
return Number(changes);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const ISSUE_FIELDS = { assignee: "assignee", project: "project", state: "state" };
|
|
35
|
+
export const trackerStoreOver = (context) => {
|
|
36
|
+
const { database } = context;
|
|
37
|
+
const save = (key, kind, records, now) => write(database, () => {
|
|
38
|
+
const accountId = accountPk(context, key);
|
|
39
|
+
const stored = database.prepare("SELECT data FROM tracker_items WHERE account_id = ? AND kind = ? AND external_id = ?");
|
|
40
|
+
const upsert = database.prepare("INSERT INTO tracker_items (account_id, kind, external_id, parent_id, title, title_folded, body, " +
|
|
41
|
+
"normalized_text, data, source_created_at, source_updated_at, archived_at, deleted_at, synced_at) " +
|
|
42
|
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?) " +
|
|
43
|
+
"ON CONFLICT (account_id, kind, external_id) DO UPDATE SET parent_id = excluded.parent_id, " +
|
|
44
|
+
"title = excluded.title, title_folded = excluded.title_folded, body = excluded.body, " +
|
|
45
|
+
"normalized_text = excluded.normalized_text, data = excluded.data, " +
|
|
46
|
+
"source_created_at = excluded.source_created_at, source_updated_at = excluded.source_updated_at, " +
|
|
47
|
+
"archived_at = excluded.archived_at, deleted_at = NULL, synced_at = excluded.synced_at");
|
|
48
|
+
for (const record of records) {
|
|
49
|
+
const before = stored.get(accountId, kind, record.externalId);
|
|
50
|
+
// A field the tracker left out of this read keeps what the store knew: a read never erases by omission.
|
|
51
|
+
const merged = {
|
|
52
|
+
...(before ? JSON.parse(String(before.data)) : {}),
|
|
53
|
+
...definedOnly(record),
|
|
54
|
+
};
|
|
55
|
+
const title = trackerTitleOf(kind, merged);
|
|
56
|
+
const body = trackerBodyOf(kind, merged) ?? null;
|
|
57
|
+
upsert.run(accountId, kind, merged.externalId, trackerParentOf(kind, merged) ?? null, title, fold(title), body, normalize([title, body].filter(Boolean).join("\n")), JSON.stringify(merged), merged.createdAt ?? null, merged.updatedAt ?? null, merged.archivedAt ?? null, now);
|
|
58
|
+
}
|
|
59
|
+
return records.length;
|
|
60
|
+
});
|
|
61
|
+
const removeUnlisted = (key, kind, listed, before, now, { dryRun = false } = {}) => {
|
|
62
|
+
const accountId = findAccountPk(context, key);
|
|
63
|
+
if (accountId === undefined)
|
|
64
|
+
return 0;
|
|
65
|
+
const keep = new Set(listed);
|
|
66
|
+
return write(database, () => {
|
|
67
|
+
const mark = database.prepare("UPDATE tracker_items SET deleted_at = ? WHERE id = ?");
|
|
68
|
+
let removed = 0;
|
|
69
|
+
for (const row of database
|
|
70
|
+
.prepare("SELECT id, external_id FROM tracker_items WHERE account_id = ? AND kind = ? AND deleted_at IS NULL " +
|
|
71
|
+
"AND synced_at < ?")
|
|
72
|
+
.all(accountId, kind, before)) {
|
|
73
|
+
if (keep.has(String(row.external_id)))
|
|
74
|
+
continue;
|
|
75
|
+
if (!dryRun)
|
|
76
|
+
mark.run(now, Number(row.id));
|
|
77
|
+
removed += 1;
|
|
78
|
+
}
|
|
79
|
+
return removed;
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const list = (key, kind, filter = {}) => {
|
|
83
|
+
const accountId = findAccountPk(context, key);
|
|
84
|
+
if (accountId === undefined)
|
|
85
|
+
return { items: [], hasMore: false };
|
|
86
|
+
const limit = Math.min(Math.max(filter.limit ?? 100, 1), MOST);
|
|
87
|
+
const params = [accountId, kind];
|
|
88
|
+
let sql = `SELECT ${COLUMNS} FROM tracker_items t WHERE t.account_id = ? AND t.kind = ? AND t.deleted_at IS NULL`;
|
|
89
|
+
if (!filter.archived)
|
|
90
|
+
sql += " AND t.archived_at IS NULL";
|
|
91
|
+
if (filter.parent !== undefined) {
|
|
92
|
+
sql += " AND t.parent_id = ?";
|
|
93
|
+
params.push(filter.parent);
|
|
94
|
+
}
|
|
95
|
+
for (const [name, field] of Object.entries(ISSUE_FIELDS)) {
|
|
96
|
+
const value = filter[name];
|
|
97
|
+
if (value === undefined)
|
|
98
|
+
continue;
|
|
99
|
+
if (value === null)
|
|
100
|
+
sql += ` AND json_extract(t.data, '$.${field}') IS NULL`;
|
|
101
|
+
else {
|
|
102
|
+
sql += ` AND json_extract(t.data, '$.${field}') = ?`;
|
|
103
|
+
params.push(value);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (filter.label !== undefined) {
|
|
107
|
+
sql += " AND EXISTS (SELECT 1 FROM json_each(t.data, '$.labels') l WHERE l.value = ?)";
|
|
108
|
+
params.push(filter.label);
|
|
109
|
+
}
|
|
110
|
+
if (filter.stateTypes?.length) {
|
|
111
|
+
sql +=
|
|
112
|
+
" AND EXISTS (SELECT 1 FROM tracker_items s WHERE s.account_id = t.account_id AND s.kind = 'state' " +
|
|
113
|
+
`AND s.external_id = json_extract(t.data, '$.state') AND json_extract(s.data, '$.type') IN (${filter.stateTypes
|
|
114
|
+
.map(() => "?")
|
|
115
|
+
.join(", ")}))`;
|
|
116
|
+
for (const type of filter.stateTypes)
|
|
117
|
+
params.push(type);
|
|
118
|
+
}
|
|
119
|
+
sql += " ORDER BY coalesce(t.source_updated_at, t.synced_at) DESC, t.id DESC LIMIT ? OFFSET ?";
|
|
120
|
+
params.push(limit + 1, filter.offset ?? 0);
|
|
121
|
+
const rows = database.prepare(sql).all(...params);
|
|
122
|
+
return { items: rows.slice(0, limit).map((row) => itemOf(row)), hasMore: rows.length > limit };
|
|
123
|
+
};
|
|
124
|
+
const find = ({ words, anyWord = false, exact = false, accounts, kinds, limit, offset = 0 }) => {
|
|
125
|
+
const match = matchOf(words, anyWord, exact);
|
|
126
|
+
if (!match)
|
|
127
|
+
return { items: [], hasMore: false };
|
|
128
|
+
const most = Math.min(Math.max(limit ?? 100, 1), MOST);
|
|
129
|
+
const scoped = accounts?.map((one) => findAccountPk(context, one)).filter((one) => one !== undefined) ?? [];
|
|
130
|
+
if (accounts !== undefined && !scoped.length)
|
|
131
|
+
return { items: [], hasMore: false };
|
|
132
|
+
const params = [match];
|
|
133
|
+
let sql = `SELECT ${COLUMNS}, t.title, t.body, a.provider, a.external_id AS account FROM tracker_items t ` +
|
|
134
|
+
"JOIN accounts a ON a.id = t.account_id " +
|
|
135
|
+
"JOIN (SELECT rowid, rank FROM tracker_item_words WHERE tracker_item_words MATCH ?) w ON w.rowid = t.id " +
|
|
136
|
+
"WHERE t.deleted_at IS NULL";
|
|
137
|
+
if (accounts !== undefined) {
|
|
138
|
+
sql += ` AND t.account_id IN (${scoped.map(() => "?").join(", ")})`;
|
|
139
|
+
for (const id of scoped)
|
|
140
|
+
params.push(id);
|
|
141
|
+
}
|
|
142
|
+
if (kinds?.length) {
|
|
143
|
+
sql += ` AND t.kind IN (${kinds.map(() => "?").join(", ")})`;
|
|
144
|
+
for (const kind of kinds)
|
|
145
|
+
params.push(kind);
|
|
146
|
+
}
|
|
147
|
+
sql += " ORDER BY w.rank, t.source_updated_at DESC, t.id DESC LIMIT ? OFFSET ?";
|
|
148
|
+
params.push(most + 1, offset);
|
|
149
|
+
const rows = database.prepare(sql).all(...params);
|
|
150
|
+
return {
|
|
151
|
+
items: rows.slice(0, most).map((row) => ({
|
|
152
|
+
account: { provider: String(row.provider), account: String(row.account) },
|
|
153
|
+
item: itemOf(row),
|
|
154
|
+
excerpt: excerptOf([row.title, row.body].filter(Boolean).join("\n"), words),
|
|
155
|
+
})),
|
|
156
|
+
hasMore: rows.length > most,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
return {
|
|
160
|
+
save: async (key, kind, records, now) => save(key, kind, records, now),
|
|
161
|
+
removeUnlisted: async (key, kind, listed, before, now, options) => removeUnlisted(key, kind, listed, before, now, options),
|
|
162
|
+
get: async (key, kind, externalId) => {
|
|
163
|
+
const accountId = findAccountPk(context, key);
|
|
164
|
+
if (accountId === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
const row = database
|
|
167
|
+
.prepare(`SELECT ${COLUMNS} FROM tracker_items t WHERE t.account_id = ? AND t.kind = ? AND t.external_id = ?`)
|
|
168
|
+
.get(accountId, kind, externalId);
|
|
169
|
+
return row ? itemOf(row) : undefined;
|
|
170
|
+
},
|
|
171
|
+
issueByKey: async (key, issueKey) => {
|
|
172
|
+
const accountId = findAccountPk(context, key);
|
|
173
|
+
if (accountId === undefined)
|
|
174
|
+
return undefined;
|
|
175
|
+
const row = database
|
|
176
|
+
.prepare(`SELECT ${COLUMNS} FROM tracker_items t WHERE t.account_id = ? AND t.kind = 'issue' ` +
|
|
177
|
+
"AND upper(json_extract(t.data, '$.key')) = upper(?) ORDER BY t.deleted_at IS NOT NULL LIMIT 1")
|
|
178
|
+
.get(accountId, issueKey);
|
|
179
|
+
return row ? itemOf(row) : undefined;
|
|
180
|
+
},
|
|
181
|
+
list: async (key, kind, filter) => list(key, kind, filter),
|
|
182
|
+
find: async (search) => find(search),
|
|
183
|
+
count: async (key, kind) => {
|
|
184
|
+
const accountId = findAccountPk(context, key);
|
|
185
|
+
if (accountId === undefined)
|
|
186
|
+
return 0;
|
|
187
|
+
return Number(database
|
|
188
|
+
.prepare("SELECT count(*) AS n FROM tracker_items WHERE account_id = ? AND kind = ? AND deleted_at IS NULL")
|
|
189
|
+
.get(accountId, kind)?.n ?? 0);
|
|
190
|
+
},
|
|
191
|
+
people: async (key, users) => {
|
|
192
|
+
const accountId = findAccountPk(context, key);
|
|
193
|
+
if (accountId === undefined || users.length === 0)
|
|
194
|
+
return [];
|
|
195
|
+
return database
|
|
196
|
+
.prepare("SELECT u.external_id AS user, p.id AS person, p.name AS name FROM tracker_items u " +
|
|
197
|
+
"JOIN identities i ON i.email IS NOT NULL AND lower(i.email) = lower(json_extract(u.data, '$.email')) " +
|
|
198
|
+
"JOIN identity_links l ON l.identity_id = i.id JOIN persons p ON p.id = l.person_id " +
|
|
199
|
+
`WHERE u.account_id = ? AND u.kind = 'user' AND u.external_id IN (${users.map(() => "?").join(", ")}) ` +
|
|
200
|
+
// Two persons behind one address say nothing about which one this user is.
|
|
201
|
+
"GROUP BY u.external_id HAVING count(DISTINCT p.id) = 1 ORDER BY u.external_id")
|
|
202
|
+
.all(accountId, ...users)
|
|
203
|
+
.map((row) => ({
|
|
204
|
+
user: String(row.user),
|
|
205
|
+
person: `person:${String(row.person)}`,
|
|
206
|
+
name: row.name == null ? null : String(row.name),
|
|
207
|
+
}));
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
};
|
package/dist/store/store.d.ts
CHANGED
|
@@ -54,6 +54,7 @@ import { type RelationsStore } from "./sqlite/reported-relations.js";
|
|
|
54
54
|
import { type SubscriptionsStore } from "./sqlite/subscriptions.js";
|
|
55
55
|
import { type StoreTaskStore } from "./sqlite/tasks.js";
|
|
56
56
|
import { type TemplateStore } from "./sqlite/templates.js";
|
|
57
|
+
import { type TrackerStore } from "./sqlite/tracker.js";
|
|
57
58
|
import { type WalletsStore } from "./sqlite/wallets.js";
|
|
58
59
|
import { type SyncStore } from "./sync.js";
|
|
59
60
|
import { type TagsStore } from "./tags.js";
|
|
@@ -142,6 +143,8 @@ export interface MessageStore {
|
|
|
142
143
|
readonly crm: CrmCopies;
|
|
143
144
|
/** The CRM files the owner downloaded, with their text; only CRM code reads them, under the copy's viewer rule. */
|
|
144
145
|
readonly crmFiles: CrmFileStore;
|
|
146
|
+
/** Issue trackers' copies: teams, users, states, labels, projects, issues and comments, as last synced. */
|
|
147
|
+
readonly tracker: TrackerStore;
|
|
145
148
|
/** Relationships a source account reports, written as a diff that never overrides the owner's. */
|
|
146
149
|
readonly relations: RelationsStore;
|
|
147
150
|
/** The one-time keys behind the buttons of a message that asks the owner to decide a batch. */
|
package/dist/store/store.js
CHANGED
|
@@ -60,6 +60,7 @@ import * as stems from "./sqlite/stems.js";
|
|
|
60
60
|
import { subscriptionsStoreOver } from "./sqlite/subscriptions.js";
|
|
61
61
|
import { taskStoreOver } from "./sqlite/tasks.js";
|
|
62
62
|
import { templateStoreOver } from "./sqlite/templates.js";
|
|
63
|
+
import { trackerStoreOver } from "./sqlite/tracker.js";
|
|
63
64
|
import { walletsStoreOver } from "./sqlite/wallets.js";
|
|
64
65
|
import { storeErrors } from "./store-errors.js";
|
|
65
66
|
import { syncStoreOver } from "./sync.js";
|
|
@@ -141,6 +142,7 @@ const storeOver = (context) => {
|
|
|
141
142
|
const transactions = once(() => transactionsStoreOver(context));
|
|
142
143
|
const crm = once(() => crmCopiesOver(context, accountPeopleOver(context)));
|
|
143
144
|
const crmFiles = once(() => crmFilesOver(context));
|
|
145
|
+
const tracker = once(() => trackerStoreOver(context));
|
|
144
146
|
const relations = once(() => relationsStoreOver(context));
|
|
145
147
|
const decisionRequests = once(() => decisionRequestStoreOver(context));
|
|
146
148
|
const templates = once(() => templateStoreOver(context));
|
|
@@ -286,6 +288,9 @@ const storeOver = (context) => {
|
|
|
286
288
|
get crm() {
|
|
287
289
|
return crm();
|
|
288
290
|
},
|
|
291
|
+
get tracker() {
|
|
292
|
+
return tracker();
|
|
293
|
+
},
|
|
289
294
|
get crmFiles() {
|
|
290
295
|
return crmFiles();
|
|
291
296
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type 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 { TrackerSource } from "../source.js";
|
|
6
|
+
/** The selected profile's tracker account, opened for one command and closed before its answer is printed. */
|
|
7
|
+
export interface TrackerRun {
|
|
8
|
+
account: AccountKey;
|
|
9
|
+
store: MessageStore;
|
|
10
|
+
/** The tracker, built on first use: a command that only reads the store never reads the sign-in. */
|
|
11
|
+
source: () => TrackerSource;
|
|
12
|
+
close?: () => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface TrackerCommandOptions {
|
|
15
|
+
/** The CLI itself: the first word of examples. */
|
|
16
|
+
app: AppIdentity;
|
|
17
|
+
/** Opens the selected profile for one command; `readOnly` when the command only reads the store. */
|
|
18
|
+
open: (command: Command, access: {
|
|
19
|
+
readOnly: boolean;
|
|
20
|
+
}) => Promise<TrackerRun>;
|
|
21
|
+
now?: () => number;
|
|
22
|
+
}
|
|
23
|
+
/** The tracker's commands: `sync`, `issues list|show|search|task`, and a `list` of each other kind. */
|
|
24
|
+
export declare const addTrackerCommands: (program: Command, options: TrackerCommandOptions) => void;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { annotate, sharedCommand } from "@wirecat/cli-base/commands";
|
|
2
|
+
import { InvalidArgumentError } from "commander";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { answerEntity } from "../../cli/answer-entity.js";
|
|
5
|
+
import { environmentOf, inCommandRun, outputFor, runBudgetOf } from "../../cli/context.js";
|
|
6
|
+
import { honoursDryRun } from "../../cli/dry-run-guard.js";
|
|
7
|
+
import { FETCH, LOCAL_READ, LOCAL_WRITE, NO_EFFECTS } from "../../cli/effects.js";
|
|
8
|
+
import { itemOf, listOf, renderAnswer } from "../../cli/envelope.js";
|
|
9
|
+
import { STATE_TYPES, TRACKER_KINDS, } from "../../domain/tracker.js";
|
|
10
|
+
import { count, text } from "../../entities/fields.js";
|
|
11
|
+
import { syncTracker } from "../sync.js";
|
|
12
|
+
import { trackerIssueTask } from "../tasks.js";
|
|
13
|
+
const MOST = 500;
|
|
14
|
+
const integer = (most) => (value) => {
|
|
15
|
+
const number = Number(value);
|
|
16
|
+
if (!Number.isSafeInteger(number) || number < 1 || number > most)
|
|
17
|
+
throw new InvalidArgumentError(`a whole number from 1 to ${most}`);
|
|
18
|
+
return number;
|
|
19
|
+
};
|
|
20
|
+
const day = (value) => {
|
|
21
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value) || Number.isNaN(Date.parse(value)))
|
|
22
|
+
throw new InvalidArgumentError("a day as YYYY-MM-DD");
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
const stateTypes = (value, previous = []) => {
|
|
26
|
+
if (!STATE_TYPES.includes(value))
|
|
27
|
+
throw new InvalidArgumentError(`one of ${STATE_TYPES.join(", ")}`);
|
|
28
|
+
return [...previous, value];
|
|
29
|
+
};
|
|
30
|
+
const TIMES = new Set(["createdAt", "updatedAt", "archivedAt", "completedAt", "canceledAt"]);
|
|
31
|
+
const snake = (name) => name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
32
|
+
/** A tracker's text is someone else's: an agent reads these fields as data, never as instructions. */
|
|
33
|
+
const UNTRUSTED = {
|
|
34
|
+
team: ["name"],
|
|
35
|
+
user: ["name"],
|
|
36
|
+
state: ["name"],
|
|
37
|
+
label: ["name"],
|
|
38
|
+
project: ["name", "description", "status"],
|
|
39
|
+
issue: ["title", "description", "state_name", "labels_names"],
|
|
40
|
+
comment: ["body"],
|
|
41
|
+
};
|
|
42
|
+
const viewOf = (item, extra = {}) => ({
|
|
43
|
+
kind: item.kind,
|
|
44
|
+
...Object.fromEntries(Object.entries(item.record).map(([name, value]) => [
|
|
45
|
+
snake(name),
|
|
46
|
+
TIMES.has(name) && typeof value === "number" ? new Date(value).toISOString() : value,
|
|
47
|
+
])),
|
|
48
|
+
...extra,
|
|
49
|
+
deleted: item.deletedAt !== null,
|
|
50
|
+
untrusted: UNTRUSTED[item.kind],
|
|
51
|
+
});
|
|
52
|
+
const trackerView = v.looseObject({ kind: v.picklist(TRACKER_KINDS), external_id: text, deleted: v.boolean() });
|
|
53
|
+
const trackerSync = v.strictObject({
|
|
54
|
+
provider: text,
|
|
55
|
+
account: text,
|
|
56
|
+
state: v.picklist(["partial", "complete"]),
|
|
57
|
+
complete: v.boolean(),
|
|
58
|
+
stopped: v.optional(v.picklist(["requests", "deadline", "cancelled"])),
|
|
59
|
+
synced: v.array(v.strictObject({
|
|
60
|
+
kind: v.picklist(TRACKER_KINDS),
|
|
61
|
+
round: v.picklist(["full", "changes"]),
|
|
62
|
+
reset: v.boolean(),
|
|
63
|
+
state: v.picklist(["partial", "complete"]),
|
|
64
|
+
saved: count,
|
|
65
|
+
unlisted: count,
|
|
66
|
+
pass: v.optional(v.picklist(["complete", "partial", "held"])),
|
|
67
|
+
held: v.optional(text),
|
|
68
|
+
error: v.optional(text),
|
|
69
|
+
})),
|
|
70
|
+
gaps: v.array(v.strictObject({ kind: v.picklist(TRACKER_KINDS), message: text, scope: v.optional(text) })),
|
|
71
|
+
progress: v.strictObject({ requests: count, saved: count, steps: count }),
|
|
72
|
+
});
|
|
73
|
+
const trackerTask = v.strictObject({ task_id: text, key: v.optional(text), issue: text, created: v.boolean() });
|
|
74
|
+
/** Each issue with its state's name and type, and its assignee's name and person, read from the same copy. */
|
|
75
|
+
const withNames = async (run, items) => {
|
|
76
|
+
const ids = (kind, pick) => [...new Set(items.map((one) => pick(one.record)).filter((one) => typeof one === "string"))].map(async (id) => [id, (await run.store.tracker.get(run.account, kind, id))?.record]);
|
|
77
|
+
const states = new Map(await Promise.all(ids("state", (issue) => issue.state)));
|
|
78
|
+
const users = new Map(await Promise.all(ids("user", (issue) => issue.assignee)));
|
|
79
|
+
const people = new Map((await run.store.tracker.people(run.account, [...users.keys()])).map((one) => [one.user, one.person]));
|
|
80
|
+
return items.map((item) => {
|
|
81
|
+
const state = item.record.state ? states.get(item.record.state) : undefined;
|
|
82
|
+
const assignee = item.record.assignee
|
|
83
|
+
? users.get(item.record.assignee)
|
|
84
|
+
: undefined;
|
|
85
|
+
return viewOf(item, {
|
|
86
|
+
...(state ? { state_name: state.name, state_type: state.type } : {}),
|
|
87
|
+
...(assignee ? { assignee_name: assignee.name } : {}),
|
|
88
|
+
...(item.record.assignee && people.has(item.record.assignee)
|
|
89
|
+
? { assignee_person: people.get(item.record.assignee) }
|
|
90
|
+
: {}),
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const issueOf = async (run, reference) => {
|
|
95
|
+
const found = (await run.store.tracker.get(run.account, "issue", reference)) ??
|
|
96
|
+
(await run.store.tracker.issueByKey(run.account, reference));
|
|
97
|
+
if (!found)
|
|
98
|
+
throw new InvalidArgumentError(`no issue ${reference} in the copy; run sync, then try again`);
|
|
99
|
+
return found;
|
|
100
|
+
};
|
|
101
|
+
const addTrackerCommandsDefinition = (program, options) => {
|
|
102
|
+
const now = () => options.now?.() ?? Date.now();
|
|
103
|
+
const within = (command, readOnly, work) => inCommandRun(command, async () => {
|
|
104
|
+
const run = await options.open(command, { readOnly });
|
|
105
|
+
let body;
|
|
106
|
+
try {
|
|
107
|
+
body = await work(run);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await run.close?.();
|
|
111
|
+
}
|
|
112
|
+
renderAnswer(command, outputFor(command), body);
|
|
113
|
+
});
|
|
114
|
+
const example = (command, ...lines) => annotate(command, { examples: lines.map((line) => `${options.app.command} work ${line}`) });
|
|
115
|
+
const paging = (command) => command
|
|
116
|
+
.option("--limit <n>", `rows per page, 1–${MOST}`, integer(MOST), 50)
|
|
117
|
+
.option("--page <n>", "which page, starting at 1", integer(1_000_000), 1);
|
|
118
|
+
example(answerEntity(annotate(program.command("sync"), { effects: FETCH, offline: false, cooperative: true, partial: true }), "tracker_sync", trackerSync).description("bring the tracker's copy in the local store up to date: teams, users, states, labels, projects, issues and " +
|
|
119
|
+
"comments that changed since the last sync, or everything with --rescan; once a day it also finds what the " +
|
|
120
|
+
"tracker deleted. A run stops before its deadline or --max-pages and the next one goes on from there"), "sync", "sync --rescan")
|
|
121
|
+
.option("--rescan", "list everything again, every id too, dropping a round in progress")
|
|
122
|
+
.option("--max-pages <pages>", "at most this many requests to the tracker in this run", integer(100_000))
|
|
123
|
+
.action(async (opts, command) => {
|
|
124
|
+
const { signal } = environmentOf(command);
|
|
125
|
+
await within(command, false, async (run) => {
|
|
126
|
+
const report = await syncTracker(run.source(), run.store, run.account, {
|
|
127
|
+
now: now(),
|
|
128
|
+
budget: runBudgetOf(command, opts.maxPages),
|
|
129
|
+
...(signal ? { signal } : {}),
|
|
130
|
+
...(opts.rescan ? { rescan: true } : {}),
|
|
131
|
+
});
|
|
132
|
+
const failed = report.synced.filter((one) => one.error !== undefined);
|
|
133
|
+
const next = report.state === "partial" && report.progress.steps > 0
|
|
134
|
+
? [
|
|
135
|
+
{
|
|
136
|
+
kind: "command",
|
|
137
|
+
step: "tracker.sync",
|
|
138
|
+
command: "sync",
|
|
139
|
+
args: opts.maxPages === undefined ? {} : { max_pages: opts.maxPages },
|
|
140
|
+
why: failed.length
|
|
141
|
+
? "a kind failed to sync; running sync again retries it"
|
|
142
|
+
: "the sync stopped before its end; running it again goes on from there",
|
|
143
|
+
safe_to_auto_execute: true,
|
|
144
|
+
},
|
|
145
|
+
]
|
|
146
|
+
: undefined;
|
|
147
|
+
const issues = [
|
|
148
|
+
...failed.map((one) => ({
|
|
149
|
+
code: "provider_error",
|
|
150
|
+
reason: "sync.partial",
|
|
151
|
+
source: `tracker:${one.kind}`,
|
|
152
|
+
})),
|
|
153
|
+
...report.synced
|
|
154
|
+
.filter((one) => one.pass === "held")
|
|
155
|
+
.map((one) => ({
|
|
156
|
+
code: "validation_error",
|
|
157
|
+
reason: "tracker.unlisted-held",
|
|
158
|
+
source: `tracker:${one.kind}`,
|
|
159
|
+
})),
|
|
160
|
+
];
|
|
161
|
+
return itemOf(report, {
|
|
162
|
+
...(report.state === "partial" || issues.length
|
|
163
|
+
? { meta: { complete: false, ...(issues.length ? { issues } : {}) } }
|
|
164
|
+
: {}),
|
|
165
|
+
...(next ? { next } : {}),
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
const issues = annotate(program.command("issues"), { effects: NO_EFFECTS }).description("the tracker's issues as last synced: state, team, project, assignee and labels");
|
|
170
|
+
example(paging(answerEntity(annotate(issues.command("list"), { effects: LOCAL_READ }), "tracker_issue", trackerView)
|
|
171
|
+
.description("issues copied from the tracker, newest change first; run sync to bring them up to date")
|
|
172
|
+
.option("--team <id>", "only this team's issues")
|
|
173
|
+
.option("--project <id>", "only this project's issues")
|
|
174
|
+
.option("--assignee <id>", "only issues assigned to this user; `none` for unassigned ones")
|
|
175
|
+
.option("--state <id>", "only issues in this state")
|
|
176
|
+
.option("--type <type>", `only issues whose state is of this type, repeatable: ${STATE_TYPES.join(", ")}`, stateTypes)
|
|
177
|
+
.option("--label <id>", "only issues with this label")
|
|
178
|
+
.option("--archived", "archived issues too")), "issues list --type started --type unstarted", "issues list --assignee none --json").action(async (opts, command) => {
|
|
179
|
+
await within(command, true, async (run) => {
|
|
180
|
+
const filter = {
|
|
181
|
+
...(opts.team ? { parent: opts.team } : {}),
|
|
182
|
+
...(opts.project ? { project: opts.project } : {}),
|
|
183
|
+
...(opts.assignee ? { assignee: opts.assignee === "none" ? null : opts.assignee } : {}),
|
|
184
|
+
...(opts.state ? { state: opts.state } : {}),
|
|
185
|
+
...(opts.type?.length ? { stateTypes: opts.type } : {}),
|
|
186
|
+
...(opts.label ? { label: opts.label } : {}),
|
|
187
|
+
...(opts.archived ? { archived: true } : {}),
|
|
188
|
+
limit: opts.limit,
|
|
189
|
+
offset: (opts.page - 1) * opts.limit,
|
|
190
|
+
};
|
|
191
|
+
const found = await run.store.tracker.list(run.account, "issue", filter);
|
|
192
|
+
return listOf("issues list", {
|
|
193
|
+
items: await withNames(run, found.items),
|
|
194
|
+
limit: opts.limit,
|
|
195
|
+
page: opts.page,
|
|
196
|
+
has_more: found.hasMore,
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
example(answerEntity(annotate(issues.command("show"), { effects: LOCAL_READ }), "tracker_issue_detail", trackerView)
|
|
201
|
+
.description("one issue with its state, assignee and comments")
|
|
202
|
+
.argument("<issue>", "the issue's key (ENG-12) or id"), "issues show ENG-12").action(async (reference, _opts, command) => {
|
|
203
|
+
await within(command, true, async (run) => {
|
|
204
|
+
const found = await issueOf(run, reference);
|
|
205
|
+
const [issue] = await withNames(run, [found]);
|
|
206
|
+
const comments = await run.store.tracker.list(run.account, "comment", {
|
|
207
|
+
parent: found.record.externalId,
|
|
208
|
+
limit: MOST,
|
|
209
|
+
});
|
|
210
|
+
return itemOf({ ...issue, comments: comments.items.map((one) => viewOf(one)) }, comments.hasMore ? { meta: { complete: false } } : {});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
example(paging(answerEntity(annotate(issues.command("search"), { effects: LOCAL_READ }), "tracker_hit", trackerView)
|
|
214
|
+
.description("find issues, projects and comments in the copy by their words")
|
|
215
|
+
.argument("<words...>", "every word must match; prefixes of three letters or more match too")
|
|
216
|
+
.option("--any", "any word may match")), 'issues search "invoice currency"').action(async (words, opts, command) => {
|
|
217
|
+
await within(command, true, async (run) => {
|
|
218
|
+
const found = await run.store.tracker.find({
|
|
219
|
+
words,
|
|
220
|
+
accounts: [run.account],
|
|
221
|
+
kinds: ["issue", "project", "comment"],
|
|
222
|
+
limit: opts.limit,
|
|
223
|
+
offset: (opts.page - 1) * opts.limit,
|
|
224
|
+
...(opts.any ? { anyWord: true } : {}),
|
|
225
|
+
});
|
|
226
|
+
return listOf("issues search", {
|
|
227
|
+
items: found.items.map((hit) => viewOf(hit.item, { excerpt: hit.excerpt })),
|
|
228
|
+
limit: opts.limit,
|
|
229
|
+
page: opts.page,
|
|
230
|
+
has_more: found.hasMore,
|
|
231
|
+
args: { words },
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
example(answerEntity(annotate(issues.command("task"), { effects: LOCAL_WRITE }), "tracker_issue_task", trackerTask)
|
|
236
|
+
.description("make an issue the owner's task: the task points at the issue and copies none of its text; the same issue " +
|
|
237
|
+
"again answers its existing task")
|
|
238
|
+
.argument("<issue>", "the issue's key (ENG-12) or id")
|
|
239
|
+
.option("--due <day>", "when it is due, YYYY-MM-DD", day), "issues task ENG-12 --due 2026-12-01").action(async (reference, opts, command) => {
|
|
240
|
+
await within(command, false, async (run) => {
|
|
241
|
+
const { task, created } = await trackerIssueTask(run.store, run.account, reference, {
|
|
242
|
+
now: now(),
|
|
243
|
+
...(opts.due ? { dueAt: new Date(`${opts.due}T00:00:00Z`) } : {}),
|
|
244
|
+
});
|
|
245
|
+
return itemOf({ task_id: task.id, ...(task.key ? { key: task.key } : {}), issue: task.source, created });
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
for (const [kind, plural, what] of [
|
|
249
|
+
["project", "projects", "the tracker's projects: status, lead, teams and target date"],
|
|
250
|
+
["team", "teams", "the tracker's teams"],
|
|
251
|
+
["user", "users", "the tracker's users, each with the person the store knows by the same e-mail"],
|
|
252
|
+
["state", "states", "each team's workflow states and their type"],
|
|
253
|
+
["label", "labels", "the tracker's labels"],
|
|
254
|
+
]) {
|
|
255
|
+
const group = annotate(program.command(plural), { effects: NO_EFFECTS }).description(what);
|
|
256
|
+
example(paging(answerEntity(annotate(group.command("list"), { effects: LOCAL_READ }), `tracker_${kind}`, trackerView)
|
|
257
|
+
.description(`${plural} copied from the tracker, newest change first`)
|
|
258
|
+
.option("--archived", `archived ${plural} too`)), `${plural} list`).action(async (opts, command) => {
|
|
259
|
+
await within(command, true, async (run) => {
|
|
260
|
+
const found = await run.store.tracker.list(run.account, kind, {
|
|
261
|
+
limit: opts.limit,
|
|
262
|
+
offset: (opts.page - 1) * opts.limit,
|
|
263
|
+
...(opts.archived ? { archived: true } : {}),
|
|
264
|
+
});
|
|
265
|
+
const people = kind === "user"
|
|
266
|
+
? new Map((await run.store.tracker.people(run.account, found.items.map((one) => one.record.externalId))).map((one) => [one.user, one.person]))
|
|
267
|
+
: new Map();
|
|
268
|
+
return listOf(`${plural} list`, {
|
|
269
|
+
items: found.items.map((one) => viewOf(one, people.has(one.record.externalId) ? { person: people.get(one.record.externalId) } : {})),
|
|
270
|
+
limit: opts.limit,
|
|
271
|
+
page: opts.page,
|
|
272
|
+
has_more: found.hasMore,
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
/** The tracker's commands: `sync`, `issues list|show|search|task`, and a `list` of each other kind. */
|
|
279
|
+
export const addTrackerCommands = honoursDryRun(sharedCommand(addTrackerCommandsDefinition));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { STATE_TYPES, type StateType, TRACKER_KINDS, type TrackerComment, type TrackerIssue, type TrackerKind, type TrackerLabel, type TrackerProject, type TrackerRecords, type TrackerState, type TrackerTeam, type TrackerUser, } from "../domain/tracker.js";
|
|
2
|
+
export { addTrackerCommands, type TrackerCommandOptions, type TrackerRun } from "./cli/index.js";
|
|
3
|
+
export { parseTrackerManifest, type TrackerAfterHook, type TrackerChangesCall, type TrackerManifest, type TrackerManifestEntity, type TrackerManifestHooks, type TrackerOperationCall, } from "./manifest/manifest.js";
|
|
4
|
+
export { TRACKER_FIELDS } from "./manifest/map.js";
|
|
5
|
+
export { type TrackerManifestSourceOptions, trackerSourceFromManifest, } from "./manifest/source.js";
|
|
6
|
+
export type { TrackerCallContext, TrackerChanges, TrackerGap, TrackerIdPage, TrackerPage, TrackerSource, TrackerSourceTraits, } from "./source.js";
|
|
7
|
+
export { syncTracker, type TrackerSyncOptions, type TrackerSyncReport, type TrackerSyncResult, trackerCursorName, trackerGapsOf, } from "./sync.js";
|
|
8
|
+
export { TRACKER_ISSUE_TASK, trackerIssueSource, trackerIssueTask } from "./tasks.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { STATE_TYPES, TRACKER_KINDS, } from "../domain/tracker.js";
|
|
2
|
+
export { addTrackerCommands } from "./cli/index.js";
|
|
3
|
+
export { parseTrackerManifest, } from "./manifest/manifest.js";
|
|
4
|
+
export { TRACKER_FIELDS } from "./manifest/map.js";
|
|
5
|
+
export { trackerSourceFromManifest, } from "./manifest/source.js";
|
|
6
|
+
export { syncTracker, trackerCursorName, trackerGapsOf, } from "./sync.js";
|
|
7
|
+
export { TRACKER_ISSUE_TASK, trackerIssueSource, trackerIssueTask } from "./tasks.js";
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type Selection } from "@wirecat/cli-base/codegen";
|
|
2
|
+
import type { ServiceApiCall } from "../../cli/service-api-call.js";
|
|
3
|
+
import type { ServiceApiManifest } from "../../cli/service-api-manifest.js";
|
|
4
|
+
import type { crmValues } from "../../crm/index.js";
|
|
5
|
+
import { type CrmRule } from "../../crm/manifest/manifest.js";
|
|
6
|
+
import { type TrackerKind, type TrackerRecords } from "../../domain/tracker.js";
|
|
7
|
+
import type { TrackerSource } from "../source.js";
|
|
8
|
+
/**
|
|
9
|
+
* One request: an operation of the generated API manifest by its id, with fixed variables. A string `"{since}"`
|
|
10
|
+
* anywhere in `variables` is filled in by the engine. `selection` replaces a GraphQL operation's default one: a
|
|
11
|
+
* tracker reads deeper than one level (`state { id }`, `labels { nodes { id } }`).
|
|
12
|
+
*/
|
|
13
|
+
export interface TrackerOperationCall {
|
|
14
|
+
operation: string;
|
|
15
|
+
variables?: Readonly<Record<string, unknown>>;
|
|
16
|
+
selection?: string;
|
|
17
|
+
/** Where the answer's rows are when the operation has no `pagination`; absent, the answer itself is the list. */
|
|
18
|
+
items?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TrackerChangesCall extends TrackerOperationCall {
|
|
21
|
+
/** How `{since}` is written: ISO, or epoch ms or seconds as digits. */
|
|
22
|
+
since: "iso" | "ms" | "seconds";
|
|
23
|
+
}
|
|
24
|
+
export interface TrackerManifestEntity<K extends TrackerKind = TrackerKind> {
|
|
25
|
+
/** Every row of the kind, archived ones too, page by page by the operation's own `pagination`. */
|
|
26
|
+
list: TrackerOperationCall;
|
|
27
|
+
/** Rows changed since `{since}`, the last cursor less the overlap; absent, every sync lists in full. */
|
|
28
|
+
changes?: TrackerChangesCall;
|
|
29
|
+
/** Every id, archived ones too, to find deletions; absent, `list`. Give one that selects only the id. */
|
|
30
|
+
ids?: TrackerOperationCall;
|
|
31
|
+
map: {
|
|
32
|
+
readonly [F in keyof TrackerRecords[K]]?: CrmRule;
|
|
33
|
+
};
|
|
34
|
+
/** A kind the plan or the sign-in may not have: its refusal is a gap with this text, and the others still sync. */
|
|
35
|
+
optional?: {
|
|
36
|
+
message: string;
|
|
37
|
+
scope?: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** A tracker account described as data: what to call for each kind and where each of our fields is in the answer. */
|
|
41
|
+
export interface TrackerManifest {
|
|
42
|
+
/** The registry name: `linear`. */
|
|
43
|
+
provider: string;
|
|
44
|
+
/** In `TRACKER_KINDS` order: teams and states before the issues on them. */
|
|
45
|
+
kinds: readonly TrackerKind[];
|
|
46
|
+
/** Re-read before the last cursor: rows saved while the round ran, and a clock running ahead. Default 10 min. */
|
|
47
|
+
overlapMs?: number;
|
|
48
|
+
entities: {
|
|
49
|
+
readonly [K in TrackerKind]?: TrackerManifestEntity<K>;
|
|
50
|
+
};
|
|
51
|
+
/** The sign-in's own user id: `viewer { id }`. */
|
|
52
|
+
self?: {
|
|
53
|
+
call: TrackerOperationCall;
|
|
54
|
+
path: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** Corrects one record after the map; `call` reads more from the service, spent from the run's budget. */
|
|
58
|
+
export type TrackerAfterHook<K extends TrackerKind> = (record: TrackerRecords[K], raw: crmValues.CrmRaw, service: {
|
|
59
|
+
call: ServiceApiCall;
|
|
60
|
+
}) => TrackerRecords[K] | Promise<TrackerRecords[K]>;
|
|
61
|
+
/** Code a tracker needs beyond what the manifest says. */
|
|
62
|
+
export interface TrackerManifestHooks {
|
|
63
|
+
after?: {
|
|
64
|
+
readonly [K in TrackerKind]?: TrackerAfterHook<K>;
|
|
65
|
+
};
|
|
66
|
+
/** Adds or replaces source methods; `base` is what the manifest built. */
|
|
67
|
+
extend?: (base: TrackerSource) => Partial<TrackerSource>;
|
|
68
|
+
}
|
|
69
|
+
/** The selection a call sends, as a tree: its own, else the operation's default; none for an operation over HTTP. */
|
|
70
|
+
export declare const selectionOf: (one: TrackerOperationCall, api: ServiceApiManifest) => Selection | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The manifest checked against its shape and the generated API: each operation exists and reads, a list pages or
|
|
73
|
+
* says where its rows are, a change call places `{since}`, and over GraphQL every path the map reads is selected, so
|
|
74
|
+
* a field is never left out of a request by mistake and read as "the tracker cleared it". Every error names where.
|
|
75
|
+
*/
|
|
76
|
+
export declare const parseTrackerManifest: (input: unknown, api: ServiceApiManifest) => TrackerManifest;
|