@wirecat/cli-core 0.708.0 → 0.710.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 +48 -0
- package/dist/cli/bot/api-http.js +23 -2
- package/dist/cli/messenger/conversation-answers.d.ts +4 -0
- package/dist/cli/messenger/message-answers.d.ts +4 -0
- package/dist/cli/messenger/message-writes.d.ts +8 -0
- package/dist/content/manifest/manifest.d.ts +10 -3
- package/dist/content/manifest/manifest.js +8 -0
- package/dist/content/manifest/source.js +32 -17
- package/dist/content/sync.js +11 -2
- package/dist/content/testing/manifest-fake.d.ts +9 -0
- package/dist/content/testing/manifest-fake.js +24 -6
- package/dist/entities/contact-context.d.ts +8 -0
- package/dist/entities/conversation-results.d.ts +8 -0
- package/dist/entities/evidence.d.ts +32 -0
- package/dist/entities/index.d.ts +73 -88
- package/dist/entities/index.js +1 -0
- package/dist/entities/listener.d.ts +16 -0
- package/dist/entities/message-change.d.ts +4 -0
- package/dist/entities/message-context.d.ts +12 -0
- package/dist/entities/message-write.d.ts +16 -0
- package/dist/entities/message.d.ts +5 -0
- package/dist/entities/message.js +2 -0
- package/dist/entities/store-records.d.ts +4 -0
- package/dist/errors/reasons.js +2 -0
- package/dist/mail/cli/inbox.d.ts +15 -0
- package/dist/mail/cli/inbox.js +208 -0
- package/dist/mail/cli/index.d.ts +1 -0
- package/dist/mail/cli/index.js +1 -0
- package/dist/mail/cli/review.js +12 -8
- package/dist/mail/inbox.d.ts +108 -0
- package/dist/mail/inbox.js +215 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.js +1 -0
- package/dist/ports/wirecat-tools.js +7 -0
- package/package.json +1 -1
- package/parity.json +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,54 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.710.0 — 19.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **A refusal keeps the status its details name, as `inner_status`.** A read refused with an answer that names
|
|
13
|
+
another status under `details` (WordPress's 400 with 403 inside) keeps that number in the error's details; the
|
|
14
|
+
service's text stays out.
|
|
15
|
+
- **`contentManifestFake` takes `lacks` and `denied`:** the rights a sign-in lacks (its rights reads answer false,
|
|
16
|
+
and a call whose `needs` is lacked is refused as WordPress refuses it) and the operations refused with 403.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- **A content kind read by several calls syncs for a role refused one of them.** A WordPress author or
|
|
21
|
+
contributor may not list pages with a private status: WordPress answers HTTP 400 with 403 in its details, and the
|
|
22
|
+
whole `post` kind failed, so even their own posts stopped syncing. A call's `optional.needs` names a rights read
|
|
23
|
+
and a `check`; unless it is true the call is never sent, and the sync reports a gap with its own text. The kind's
|
|
24
|
+
other calls sync as before, and the gap holds deletions, so no stored row is marked deleted for a skipped call.
|
|
25
|
+
Each rights read is sent once per source, whatever it checks. A content source takes a 400 with 403 inside as a
|
|
26
|
+
refusal, so `optional` reports a gap for it.
|
|
27
|
+
- **A scheduled post the sign-in may not read is a gap, not a failed sync.** Past its time, such a post (a page an
|
|
28
|
+
editor's sign-in stored, read later by an author) is read again; a refusal failed the whole `post` kind on every
|
|
29
|
+
run. It now stays as it was, and the gap holds deletions.
|
|
30
|
+
|
|
31
|
+
## 0.709.0 — 19.11.2026
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **`mailInboxCommand`: a mail CLI's `inbox` sorts new mail with the shared AI model.** The threads that changed since
|
|
36
|
+
its last run go to the model chosen with `models ai` (Anthropic, OpenAI or a local Ollama), with no agent. It puts
|
|
37
|
+
each one under needs an answer, to read or can wait, with a one-line reason, then lists every sorted thread, those
|
|
38
|
+
that need an answer first. It sends each thread's subject, senders and its 3 newest emails without quoted mail or
|
|
39
|
+
the signature, at most 1500 characters each. Mail sent to many is not sent. `--max-messages` (40 by default) and
|
|
40
|
+
`--max-tokens` (60000) limit a run, and the threads left wait for the next. A model outside this computer follows
|
|
41
|
+
local only and `models chats`: under ask it needs `--yes`. An agent is refused (`mail.inbox-agent`), and
|
|
42
|
+
`--offline` lists without calling the model. A thread the owner answered leaves the list on the next run. The
|
|
43
|
+
verdicts are kept in the store, so a schedule can run it.
|
|
44
|
+
- **Mail `review` shows how `inbox` sorted each thread**, as `email.inbox` (`bucket` and `reason`, the reason marked
|
|
45
|
+
untrusted).
|
|
46
|
+
- **wordpress joins `WIRECAT_TOOLS`.** WordPress (`wordpress`, `@wirecat/wordpress-cli`) is on npm since 0.1.0, so
|
|
47
|
+
every CLI's first screen ("Works with") and first-run list of other WireCat tools now name it, and an upload refuses
|
|
48
|
+
a file from its folders (`wordpress-cli`, `WCWP_`) as it does for the other tools.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- **`parity.json` has rows for `messages scheduled cancel`, `edit` and `send`** (max and tg; WhatsApp has no scheduled
|
|
53
|
+
messages). 0.706.0 added the commands without rows, so the parity manifest check failed for max-cli and tg-cli,
|
|
54
|
+
hidden only because both were listed as known broken.
|
|
55
|
+
|
|
8
56
|
## 0.708.0 — 19.11.2026
|
|
9
57
|
|
|
10
58
|
### Fixed
|
package/dist/cli/bot/api-http.js
CHANGED
|
@@ -171,7 +171,8 @@ export const httpApiExchange = (options) => async (command, operation, request)
|
|
|
171
171
|
if (!response.ok) {
|
|
172
172
|
const failed = status >= 500 && writes
|
|
173
173
|
? refusal(options.service, operation, response, writes)
|
|
174
|
-
: (options.failure?.(status, answer, operation) ??
|
|
174
|
+
: (options.failure?.(status, answer, operation) ??
|
|
175
|
+
refusal(options.service, operation, response, writes, innerStatus(answer)));
|
|
175
176
|
end({ status, error: failed });
|
|
176
177
|
throw failed;
|
|
177
178
|
}
|
|
@@ -224,7 +225,26 @@ const unreadable = (service, writes, status) => writes
|
|
|
224
225
|
retryable: false,
|
|
225
226
|
})
|
|
226
227
|
: new CliError("invalid_response", `${service} sent an answer that could not be read`, { status, retryable: true });
|
|
227
|
-
|
|
228
|
+
/**
|
|
229
|
+
* The status a refusal's `details` name, as WordPress answers a role a status it may not read: HTTP 400 with 403 in
|
|
230
|
+
* `data.details`. Only the number is kept, never the service's text (WC-SECR-6).
|
|
231
|
+
*/
|
|
232
|
+
const innerStatus = (answer) => {
|
|
233
|
+
const find = (value, depth, inDetails) => {
|
|
234
|
+
if (depth > 5 || typeof value !== "object" || value === null || Array.isArray(value))
|
|
235
|
+
return undefined;
|
|
236
|
+
for (const [key, one] of Object.entries(value)) {
|
|
237
|
+
if (inDetails && key === "status" && typeof one === "number" && one >= 400 && one < 600)
|
|
238
|
+
return one;
|
|
239
|
+
const found = find(one, depth + 1, inDetails || key === "details");
|
|
240
|
+
if (found !== undefined)
|
|
241
|
+
return found;
|
|
242
|
+
}
|
|
243
|
+
return undefined;
|
|
244
|
+
};
|
|
245
|
+
return find(answer, 0, false);
|
|
246
|
+
};
|
|
247
|
+
const refusal = (service, operation, response, writes, inner) => {
|
|
228
248
|
const { status } = response;
|
|
229
249
|
if (status === 429) {
|
|
230
250
|
const wait = providerWaitMs(response.headers, wallClock);
|
|
@@ -262,5 +282,6 @@ const refusal = (service, operation, response, writes) => {
|
|
|
262
282
|
return new CliError(statusToCode(status), `${service} refused ${operation.command} (HTTP ${status})`, {
|
|
263
283
|
status,
|
|
264
284
|
retryable: status >= 500,
|
|
285
|
+
...(inner === undefined || inner === status ? {} : { inner_status: inner }),
|
|
265
286
|
});
|
|
266
287
|
};
|
|
@@ -254,6 +254,10 @@ export declare const conversationShown: (account: AccountKey, { summary, message
|
|
|
254
254
|
fingerprint?: string | undefined;
|
|
255
255
|
new_sender?: boolean | undefined;
|
|
256
256
|
sender_identities?: number | undefined;
|
|
257
|
+
inbox?: {
|
|
258
|
+
bucket: "answer" | "later" | "read";
|
|
259
|
+
reason: string;
|
|
260
|
+
} | undefined;
|
|
257
261
|
} | undefined;
|
|
258
262
|
provider_metadata?: {
|
|
259
263
|
[x: string]: unknown;
|
|
@@ -231,6 +231,10 @@ export declare const threadAnswer: ({ items, ...thread }: ThreadContext, reader:
|
|
|
231
231
|
fingerprint?: string | undefined;
|
|
232
232
|
new_sender?: boolean | undefined;
|
|
233
233
|
sender_identities?: number | undefined;
|
|
234
|
+
inbox?: {
|
|
235
|
+
bucket: "answer" | "later" | "read";
|
|
236
|
+
reason: string;
|
|
237
|
+
} | undefined;
|
|
234
238
|
} | undefined;
|
|
235
239
|
provider_metadata?: {
|
|
236
240
|
[x: string]: unknown;
|
|
@@ -235,6 +235,10 @@ export declare const writtenAnswer: ({ operationId, sendId, message, messages, s
|
|
|
235
235
|
fingerprint?: string | undefined;
|
|
236
236
|
new_sender?: boolean | undefined;
|
|
237
237
|
sender_identities?: number | undefined;
|
|
238
|
+
inbox?: {
|
|
239
|
+
bucket: "answer" | "later" | "read";
|
|
240
|
+
reason: string;
|
|
241
|
+
} | undefined;
|
|
238
242
|
} | undefined;
|
|
239
243
|
provider_metadata?: {
|
|
240
244
|
[x: string]: unknown;
|
|
@@ -460,6 +464,10 @@ export declare const writtenAnswer: ({ operationId, sendId, message, messages, s
|
|
|
460
464
|
fingerprint?: string | undefined;
|
|
461
465
|
new_sender?: boolean | undefined;
|
|
462
466
|
sender_identities?: number | undefined;
|
|
467
|
+
inbox?: {
|
|
468
|
+
bucket: "answer" | "later" | "read";
|
|
469
|
+
reason: string;
|
|
470
|
+
} | undefined;
|
|
463
471
|
} | undefined;
|
|
464
472
|
provider_metadata?: {
|
|
465
473
|
[x: string]: unknown;
|
|
@@ -39,16 +39,23 @@ export interface ContentManifestEntity {
|
|
|
39
39
|
/**
|
|
40
40
|
* The sign-in may be refused this call (a role without the right): a gap with this text, and the rest syncs. A
|
|
41
41
|
* source that leaves rows out without an error names `requires`: a read whose value at `check` is true when the
|
|
42
|
-
* sign-in sees every row; false or missing is the same gap.
|
|
42
|
+
* sign-in sees every row; false or missing is the same gap. A source that refuses the call outright to a role names
|
|
43
|
+
* `needs`: unless its `check` is true the call is never sent, and the gap says its own `message`.
|
|
43
44
|
*/
|
|
44
45
|
optional?: {
|
|
45
46
|
message: string;
|
|
46
47
|
scope?: string;
|
|
47
|
-
requires?:
|
|
48
|
-
|
|
48
|
+
requires?: ContentRightsCall;
|
|
49
|
+
needs?: ContentRightsCall & {
|
|
50
|
+
message: string;
|
|
51
|
+
scope?: string;
|
|
49
52
|
};
|
|
50
53
|
};
|
|
51
54
|
}
|
|
55
|
+
/** A read of the sign-in's rights, true at `check` when it has the right (WordPress: `users/me`'s capabilities). */
|
|
56
|
+
export type ContentRightsCall = CrmOperationCall & {
|
|
57
|
+
check: string;
|
|
58
|
+
};
|
|
52
59
|
/** A post's writes, as calls and values over the update call. `"{id}"` and `"{at}"` are filled by the engine. */
|
|
53
60
|
export interface ContentManifestWrites {
|
|
54
61
|
create: CrmOperationCall;
|
|
@@ -30,6 +30,12 @@ const entity = v.strictObject({
|
|
|
30
30
|
message: v.pipe(v.string(), v.minLength(1)),
|
|
31
31
|
scope: v.optional(v.string()),
|
|
32
32
|
requires: v.optional(v.strictObject({ ...call.entries, check: path })),
|
|
33
|
+
needs: v.optional(v.strictObject({
|
|
34
|
+
...call.entries,
|
|
35
|
+
check: path,
|
|
36
|
+
message: v.pipe(v.string(), v.minLength(1)),
|
|
37
|
+
scope: v.optional(v.string()),
|
|
38
|
+
})),
|
|
33
39
|
})),
|
|
34
40
|
});
|
|
35
41
|
const schema = v.strictObject({
|
|
@@ -101,6 +107,8 @@ export const parseContentManifest = (input, api) => {
|
|
|
101
107
|
checkCall(`${where}.ids`, one.ids, true);
|
|
102
108
|
if (one.optional?.requires)
|
|
103
109
|
checkCall(`${where}.optional.requires`, one.optional.requires, true);
|
|
110
|
+
if (one.optional?.needs)
|
|
111
|
+
checkCall(`${where}.optional.needs`, one.optional.needs, true);
|
|
104
112
|
if (one.get) {
|
|
105
113
|
checkCall(`${where}.get`, one.get, true);
|
|
106
114
|
if (!holds([one.get.path, one.get.query], "{id}"))
|
|
@@ -3,7 +3,7 @@ import { nextPage, parameterValue, withValue } from "../../cli/service-api-manif
|
|
|
3
3
|
import { crmValues } from "../../crm/index.js";
|
|
4
4
|
import { at, evaluate, MISSING } from "../../crm/manifest/map.js";
|
|
5
5
|
import { GET_UNSUPPORTED, } from "../source.js";
|
|
6
|
-
import { parseContentManifest } from "./manifest.js";
|
|
6
|
+
import { parseContentManifest, } from "./manifest.js";
|
|
7
7
|
import { mapContentRecord, postBodyOf, utcEpoch } from "./map.js";
|
|
8
8
|
/**
|
|
9
9
|
* The one channel's id, the same whatever the site's address: a profile pointed at another address is then a moved
|
|
@@ -66,7 +66,9 @@ const pageOf = (page, now) => {
|
|
|
66
66
|
return Number.isSafeInteger(call) && call >= 0 ? { call, token, started } : { call: -1, token: undefined, started };
|
|
67
67
|
};
|
|
68
68
|
const gone = (error) => isCliError(error) && error.code === "not_found";
|
|
69
|
-
|
|
69
|
+
// A service may refuse a role with a 400 whose details say 403 (WordPress, for a status the role may not read).
|
|
70
|
+
const refused = (error) => isCliError(error) &&
|
|
71
|
+
(error.code === "permission_error" || error.code === "not_found" || error.details.inner_status === 403);
|
|
70
72
|
/**
|
|
71
73
|
* A `ContentSource` read from a manifest: each kind by the calls it names, paged by each operation's own
|
|
72
74
|
* `pagination`, each row mapped onto the content domain, a post's text turned into Markdown.
|
|
@@ -136,23 +138,35 @@ export const contentSourceFromManifest = (input, options) => {
|
|
|
136
138
|
return records;
|
|
137
139
|
};
|
|
138
140
|
const rights = new Map();
|
|
139
|
-
/** Whether the sign-in
|
|
141
|
+
/** Whether the sign-in has the right `check` names; each rights read is sent once per source, whatever it checks. */
|
|
142
|
+
const has = async (read, send) => {
|
|
143
|
+
const request = inputOf(read, {});
|
|
144
|
+
const key = JSON.stringify([read.operation, request]);
|
|
145
|
+
let answer = rights.get(key);
|
|
146
|
+
if (answer === undefined) {
|
|
147
|
+
answer = send(read.operation, request);
|
|
148
|
+
rights.set(key, answer);
|
|
149
|
+
answer.catch(() => rights.delete(key));
|
|
150
|
+
}
|
|
151
|
+
return at(await answer, read.check) === true;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Whether the call may be sent: a role its `needs` read refuses is a gap, and the call is skipped. Else a sign-in
|
|
155
|
+
* its `requires` read says sees only part is a gap, and the call is sent.
|
|
156
|
+
*/
|
|
140
157
|
const checkRights = async (kind, entity, send, context) => {
|
|
141
|
-
const requires = entity.optional
|
|
142
|
-
if (!
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
let seen = rights.get(key);
|
|
146
|
-
if (seen === undefined) {
|
|
147
|
-
seen = at(await send(requires.operation, inputOf(requires, {})), requires.check) === true;
|
|
148
|
-
rights.set(key, seen);
|
|
158
|
+
const { needs, requires } = entity.optional ?? {};
|
|
159
|
+
if (needs && !(await has(needs, send))) {
|
|
160
|
+
context?.gap({ kind, message: needs.message, ...(needs.scope ? { scope: needs.scope } : {}) });
|
|
161
|
+
return false;
|
|
149
162
|
}
|
|
150
|
-
if (!
|
|
163
|
+
if (requires && !(await has(requires, send)))
|
|
151
164
|
context?.gap({
|
|
152
165
|
kind,
|
|
153
166
|
message: entity.optional?.message ?? "",
|
|
154
167
|
...(entity.optional?.scope ? { scope: entity.optional.scope } : {}),
|
|
155
168
|
});
|
|
169
|
+
return true;
|
|
156
170
|
};
|
|
157
171
|
const gapOf = (kind, entity, error, context) => {
|
|
158
172
|
if (!entity.optional || !refused(error))
|
|
@@ -189,9 +203,9 @@ export const contentSourceFromManifest = (input, options) => {
|
|
|
189
203
|
const changes = since === null ? undefined : entity.changes;
|
|
190
204
|
let read;
|
|
191
205
|
try {
|
|
192
|
-
await checkRights(kind, entity, send, context)
|
|
193
|
-
|
|
194
|
-
changes?.keyset && since !== null
|
|
206
|
+
read = !(await checkRights(kind, entity, send, context))
|
|
207
|
+
? { rows: [], next: undefined }
|
|
208
|
+
: changes?.keyset && since !== null
|
|
195
209
|
? await keysetPage({ ...changes, keyset: changes.keyset }, spot.token === undefined ? since - overlap : Number(spot.token), send)
|
|
196
210
|
: await readPage(changes ?? entity.list, changes && since !== null ? { since: SINCE[changes.since](since - overlap) } : {}, spot.token, send);
|
|
197
211
|
}
|
|
@@ -218,8 +232,9 @@ export const contentSourceFromManifest = (input, options) => {
|
|
|
218
232
|
let read;
|
|
219
233
|
const send = metered(context);
|
|
220
234
|
try {
|
|
221
|
-
await checkRights(kind, entity, send, context)
|
|
222
|
-
|
|
235
|
+
read = (await checkRights(kind, entity, send, context))
|
|
236
|
+
? await readPage(entity.ids ?? entity.list, {}, spot.token, send)
|
|
237
|
+
: { rows: [], next: undefined };
|
|
223
238
|
}
|
|
224
239
|
catch (error) {
|
|
225
240
|
// Refused, the ids read so far would mark every unread row deleted: the gap holds the pass.
|
package/dist/content/sync.js
CHANGED
|
@@ -8,6 +8,8 @@ const MOST_UNLISTED = 0.5;
|
|
|
8
8
|
const GUARDED_FROM = 10;
|
|
9
9
|
/** Scheduled posts past their time read one by one per run; more wait for the next. */
|
|
10
10
|
const MOST_DUE = 50;
|
|
11
|
+
/** The sign-in may not read it, which proves nothing about the row; WordPress also refuses with 400 and 403 inside. */
|
|
12
|
+
const refusedRead = (error) => isCliError(error) && (error.code === "permission_error" || error.details.inner_status === 403);
|
|
11
13
|
const fresh = () => ({ v: 1, token: null, round: null, passAt: 0 });
|
|
12
14
|
const parsed = (value) => {
|
|
13
15
|
try {
|
|
@@ -170,7 +172,14 @@ const readDue = async (run, result) => {
|
|
|
170
172
|
catch (error) {
|
|
171
173
|
if (isCliError(error) && error.details.reason === GET_UNSUPPORTED)
|
|
172
174
|
return null;
|
|
173
|
-
|
|
175
|
+
// An author's scheduled page, stored by an editor's sign-in: a refusal holds it, and the other posts go on.
|
|
176
|
+
if (!refusedRead(error))
|
|
177
|
+
throw error;
|
|
178
|
+
run.context.gap({
|
|
179
|
+
kind: "post",
|
|
180
|
+
message: `${source.provider} would not give this sign-in every post: ${error.message}`,
|
|
181
|
+
});
|
|
182
|
+
continue;
|
|
174
183
|
}
|
|
175
184
|
if (post)
|
|
176
185
|
result.saved += await store.content.save(account, "post", [post], run.now);
|
|
@@ -213,7 +222,7 @@ const confirmGone = async (run, kind, missing, result) => {
|
|
|
213
222
|
catch (error) {
|
|
214
223
|
// WordPress leaves others' drafts out of a contributor's list and refuses to read them, and a row of a status we
|
|
215
224
|
// do not know reads as nothing: neither proves it gone.
|
|
216
|
-
if (
|
|
225
|
+
if (refusedRead(error) || (isCliError(error) && error.code === "invalid_response")) {
|
|
217
226
|
run.context.gap({
|
|
218
227
|
kind,
|
|
219
228
|
message: `${source.provider} would not give this sign-in every ${kind}: ${error.message}`,
|
|
@@ -12,6 +12,15 @@ export interface ContentManifestFakeOptions {
|
|
|
12
12
|
pageSize?: number;
|
|
13
13
|
/** The service's clock, for the change time a write stamps. */
|
|
14
14
|
clock?: () => number;
|
|
15
|
+
/**
|
|
16
|
+
* The rights the sign-in lacks, as the `check` paths of the manifest's `requires` and `needs` reads
|
|
17
|
+
* (`capabilities.edit_pages`): they answer false. A call whose `needs` is lacked is refused, as WordPress refuses an
|
|
18
|
+
* author pages with a private status: a list with HTTP 400 and 403 in its details, one row with 403. It lands in
|
|
19
|
+
* `refusals`.
|
|
20
|
+
*/
|
|
21
|
+
lacks?: readonly string[];
|
|
22
|
+
/** Operations refused with 403 to this sign-in, as WordPress refuses an author the users list. */
|
|
23
|
+
denied?: readonly string[];
|
|
15
24
|
}
|
|
16
25
|
export interface ContentManifestFake {
|
|
17
26
|
/** Reads as `serviceApiCall` sends them, with the answer's headers through `withHeaders`. */
|
|
@@ -169,10 +169,10 @@ export const contentManifestFake = (input, options) => {
|
|
|
169
169
|
...(entity.get ? [{ kind, index, role: "get", call: entity.get }] : []),
|
|
170
170
|
{ kind, index, role: "list", call: entity.list },
|
|
171
171
|
...(entity.ids ? [{ kind, index, role: "list", call: entity.ids }] : []),
|
|
172
|
-
...
|
|
173
|
-
? [{ kind, index, role: "requires", call: entity.optional.requires }]
|
|
174
|
-
: []),
|
|
172
|
+
...[entity.optional?.requires, entity.optional?.needs].flatMap((call) => call ? [{ kind, index, role: "rights", call }] : []),
|
|
175
173
|
]));
|
|
174
|
+
const lacks = new Set(options.lacks ?? []);
|
|
175
|
+
const checks = manifest.kinds.flatMap((kind) => entities(kind).flatMap((entity) => [entity.optional?.requires, entity.optional?.needs].flatMap((call) => (call ? [call] : []))));
|
|
176
176
|
const carries = (route, request) => {
|
|
177
177
|
const fixed = fixedOf({ path: route.call.path ?? {}, query: route.call.query ?? {} });
|
|
178
178
|
const own = { path: request.path, query: request.query };
|
|
@@ -241,13 +241,28 @@ export const contentManifestFake = (input, options) => {
|
|
|
241
241
|
refusals.push(operation);
|
|
242
242
|
throw new CliError("configuration_error", `the content fake answers no ${operation} call like this`);
|
|
243
243
|
}
|
|
244
|
+
if (options.denied?.includes(operation))
|
|
245
|
+
throw new CliError("permission_error", `the content fake denies ${operation} to this sign-in`);
|
|
244
246
|
const entity = entities(route.kind)[route.index];
|
|
245
247
|
const held = rows[route.kind]?.[route.index] ?? [];
|
|
246
|
-
|
|
248
|
+
// One rights read answers every right the manifest checks with it.
|
|
249
|
+
if (route.role === "rights") {
|
|
247
250
|
const body = {};
|
|
248
|
-
|
|
251
|
+
for (const one of checks)
|
|
252
|
+
if (one.operation === operation && carries({ ...route, call: one }, request))
|
|
253
|
+
put(body, one.check, !lacks.has(one.check));
|
|
249
254
|
return { body, headers: new Headers() };
|
|
250
255
|
}
|
|
256
|
+
const needs = entity.optional?.needs;
|
|
257
|
+
if (needs && lacks.has(needs.check)) {
|
|
258
|
+
refusals.push(operation);
|
|
259
|
+
if (route.role === "get")
|
|
260
|
+
throw new CliError("permission_error", `the content fake denies ${operation} to this sign-in`);
|
|
261
|
+
throw new CliError("validation_error", `the content fake refuses ${operation} to this sign-in`, {
|
|
262
|
+
status: 400,
|
|
263
|
+
inner_status: 403,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
251
266
|
if (route.role === "get") {
|
|
252
267
|
const place = placeOf(route.call, "{id}");
|
|
253
268
|
const id = place ? request[place.in][place.name] : undefined;
|
|
@@ -375,7 +390,10 @@ export const contentManifestFake = (input, options) => {
|
|
|
375
390
|
catch (error) {
|
|
376
391
|
if (!(error instanceof CliError) || error.code === "outcome_unknown")
|
|
377
392
|
throw error;
|
|
378
|
-
|
|
393
|
+
const inner = error.details.inner_status;
|
|
394
|
+
return Response.json(inner === undefined
|
|
395
|
+
? { message: error.message }
|
|
396
|
+
: { message: error.message, data: { status: 400, details: { status: { data: { status: inner } } } } }, { status: statusOf(error) });
|
|
379
397
|
}
|
|
380
398
|
};
|
|
381
399
|
const call = Object.assign(async (operation, request) => (await read(operation, request)).body, {
|
|
@@ -512,6 +512,10 @@ export declare const contactMessages: v.StrictObjectSchema<{
|
|
|
512
512
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
513
513
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
514
514
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
515
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
516
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
517
|
+
readonly reason: v.StringSchema<undefined>;
|
|
518
|
+
}, undefined>, undefined>;
|
|
515
519
|
readonly reply_to: v.ArraySchema<v.StrictObjectSchema<{
|
|
516
520
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
517
521
|
readonly address: v.StringSchema<undefined>;
|
|
@@ -1308,6 +1312,10 @@ export declare const contactContext: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1308
1312
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
1309
1313
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1310
1314
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
1315
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1316
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
1317
|
+
readonly reason: v.StringSchema<undefined>;
|
|
1318
|
+
}, undefined>, undefined>;
|
|
1311
1319
|
readonly reply_to: v.ArraySchema<v.StrictObjectSchema<{
|
|
1312
1320
|
readonly name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
1313
1321
|
readonly address: v.StringSchema<undefined>;
|
|
@@ -230,6 +230,10 @@ export declare const conversationDetails: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
230
230
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
231
231
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
232
232
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
233
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
234
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
235
|
+
readonly reason: v.StringSchema<undefined>;
|
|
236
|
+
}, undefined>, undefined>;
|
|
233
237
|
}, undefined>, undefined>;
|
|
234
238
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
235
239
|
}, undefined>, undefined>;
|
|
@@ -453,6 +457,10 @@ export declare const conversationDetails: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
453
457
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
454
458
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
455
459
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
460
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
461
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
462
|
+
readonly reason: v.StringSchema<undefined>;
|
|
463
|
+
}, undefined>, undefined>;
|
|
456
464
|
}, undefined>, undefined>;
|
|
457
465
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
458
466
|
}, undefined>], undefined>;
|
|
@@ -221,6 +221,10 @@ export declare const contribution: v.StrictObjectSchema<{
|
|
|
221
221
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
222
222
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
223
223
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
224
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
225
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
226
|
+
readonly reason: v.StringSchema<undefined>;
|
|
227
|
+
}, undefined>, undefined>;
|
|
224
228
|
}, undefined>, undefined>;
|
|
225
229
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
226
230
|
}, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
|
|
@@ -444,6 +448,10 @@ export declare const contribution: v.StrictObjectSchema<{
|
|
|
444
448
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
445
449
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
446
450
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
451
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
452
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
453
|
+
readonly reason: v.StringSchema<undefined>;
|
|
454
|
+
}, undefined>, undefined>;
|
|
447
455
|
}, undefined>, undefined>;
|
|
448
456
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
449
457
|
}, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
|
|
@@ -705,6 +713,10 @@ export declare const contribution: v.StrictObjectSchema<{
|
|
|
705
713
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
706
714
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
707
715
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
716
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
717
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
718
|
+
readonly reason: v.StringSchema<undefined>;
|
|
719
|
+
}, undefined>, undefined>;
|
|
708
720
|
}, undefined>, undefined>;
|
|
709
721
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
710
722
|
}, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
|
|
@@ -928,6 +940,10 @@ export declare const contribution: v.StrictObjectSchema<{
|
|
|
928
940
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
929
941
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
930
942
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
943
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
944
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
945
|
+
readonly reason: v.StringSchema<undefined>;
|
|
946
|
+
}, undefined>, undefined>;
|
|
931
947
|
}, undefined>, undefined>;
|
|
932
948
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
933
949
|
}, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
|
|
@@ -1225,6 +1241,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1225
1241
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
1226
1242
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1227
1243
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
1244
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1245
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
1246
|
+
readonly reason: v.StringSchema<undefined>;
|
|
1247
|
+
}, undefined>, undefined>;
|
|
1228
1248
|
}, undefined>, undefined>;
|
|
1229
1249
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
1230
1250
|
}, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
|
|
@@ -1448,6 +1468,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1448
1468
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
1449
1469
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1450
1470
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
1471
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1472
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
1473
|
+
readonly reason: v.StringSchema<undefined>;
|
|
1474
|
+
}, undefined>, undefined>;
|
|
1451
1475
|
}, undefined>, undefined>;
|
|
1452
1476
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
1453
1477
|
}, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
|
|
@@ -1709,6 +1733,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1709
1733
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
1710
1734
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1711
1735
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
1736
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1737
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
1738
|
+
readonly reason: v.StringSchema<undefined>;
|
|
1739
|
+
}, undefined>, undefined>;
|
|
1712
1740
|
}, undefined>, undefined>;
|
|
1713
1741
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
1714
1742
|
}, undefined>, "entries" | "~run" | "~standard" | "~types"> & {
|
|
@@ -1932,6 +1960,10 @@ export declare const evidence: v.UnionSchema<[v.StrictObjectSchema<{
|
|
|
1932
1960
|
readonly fingerprint: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>, undefined>;
|
|
1933
1961
|
readonly new_sender: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
1934
1962
|
readonly sender_identities: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
1963
|
+
readonly inbox: v.OptionalSchema<v.StrictObjectSchema<{
|
|
1964
|
+
readonly bucket: v.PicklistSchema<["answer", "read", "later"], undefined>;
|
|
1965
|
+
readonly reason: v.StringSchema<undefined>;
|
|
1966
|
+
}, undefined>, undefined>;
|
|
1935
1967
|
}, undefined>, undefined>;
|
|
1936
1968
|
readonly provider_metadata: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
1937
1969
|
}, "chat_title" | "ref" | "sender_name" | "text" | "timestamp">;
|