@vite-hub/webhooks 0.4.1 → 0.5.1
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/README.md +36 -6
- package/dist/database-C5cwO1an.d.ts +1517 -0
- package/dist/database.d.ts +2 -2
- package/dist/database.js +196 -14
- package/dist/{errors-1y5fWGlX.js → errors-DT8uyCh7.js} +39 -4
- package/dist/index.d.ts +128 -4
- package/dist/index.js +246 -4
- package/dist/members-BjDcAAhY.d.ts +343 -0
- package/dist/members-Cr_Nlyg4.js +308 -0
- package/dist/object-CAK6UYR5.js +10 -0
- package/dist/{operations-7ycAhDCw.d.ts → operations-8hqTi0DH.d.ts} +8 -4
- package/dist/operations.d.ts +13 -4
- package/dist/operations.js +189 -99
- package/dist/{queue-name-CGeTSHId.d.ts → queue-name-CLdaJFPZ.d.ts} +0 -2
- package/dist/{queue-name-RURp9SQf.js → queue-name-jmgeppja.js} +1 -2
- package/dist/runtime-BFiCJOMB.js +914 -0
- package/dist/{runtime-mqwMGfyX.d.ts → runtime-BdILDcW1.d.ts} +94 -17
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +3 -3
- package/dist/table-names-DAUip4v2.js +12 -0
- package/dist/vite.d.ts +91 -16
- package/dist/vite.js +192 -55
- package/package.json +9 -9
- package/dist/database-COdjz9Vi.d.ts +0 -608
- package/dist/object-BJb1W_q5.js +0 -7
- package/dist/runtime-DVBMk9vu.js +0 -486
- package/dist/table-names-DVvicXhh.js +0 -8
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { t as webhooksErrors } from "./errors-DT8uyCh7.js";
|
|
2
|
+
import { A as sealedMemberBodyPrefix, D as memberBodyLabel, E as outsideHosts, O as sealEndpoint, T as checkWebhookUrl, _ as requireMemberEndpoints, j as unsealEndpoint, k as sealWebhooksText, n as createDeliveryId, r as deliverMemberClaim, s as inspectDelivery } from "./runtime-BFiCJOMB.js";
|
|
3
|
+
// \0rolldown/runtime.js
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __exportAll = (all, no_symbols) => {
|
|
6
|
+
let target = {};
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
11
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
// src/members.ts
|
|
15
|
+
var members_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
createMemberEndpoint: () => createMemberEndpoint,
|
|
17
|
+
disableMemberEndpoint: () => disableMemberEndpoint,
|
|
18
|
+
enableMemberEndpoint: () => enableMemberEndpoint,
|
|
19
|
+
getMemberDeliveryState: () => getMemberDeliveryState,
|
|
20
|
+
getMemberEndpoint: () => getMemberEndpoint,
|
|
21
|
+
listMemberDeliveries: () => listMemberDeliveries,
|
|
22
|
+
listMemberEndpoints: () => listMemberEndpoints,
|
|
23
|
+
memberEndpointHosts: () => memberEndpointHosts,
|
|
24
|
+
removeMemberEndpoint: () => removeMemberEndpoint,
|
|
25
|
+
removeMemberEndpoints: () => removeMemberEndpoints,
|
|
26
|
+
sendToMemberEndpoint: () => sendToMemberEndpoint
|
|
27
|
+
});
|
|
28
|
+
/** The hosts that a member endpoint URL may use when `createMemberEndpoint()` gets no `hosts`: the T3 Code relay. */
|
|
29
|
+
const memberEndpointHosts = ["relay.t3.codes"];
|
|
30
|
+
const limits = {
|
|
31
|
+
owner: 256,
|
|
32
|
+
name: 120,
|
|
33
|
+
agent: 64,
|
|
34
|
+
email: 320,
|
|
35
|
+
secret: 1024,
|
|
36
|
+
url: 2048,
|
|
37
|
+
address: 512
|
|
38
|
+
};
|
|
39
|
+
function toMemberEndpoint({ sealed: _sealed, address, ...endpoint }) {
|
|
40
|
+
return {
|
|
41
|
+
...endpoint,
|
|
42
|
+
address: address || null
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function storeError(error) {
|
|
46
|
+
if (webhooksErrors.WEBHOOKS_STORE_FAILED.is(error) || webhooksErrors.WEBHOOKS_DATABASE_MISSING.is(error)) return error;
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
function text(value, field, max) {
|
|
50
|
+
if (typeof value !== "string" || !value.trim()) return `\`${field}\` must be non-empty text`;
|
|
51
|
+
if (value.length > max) return `\`${field}\` must be at most ${max} characters`;
|
|
52
|
+
}
|
|
53
|
+
function invalid(problem) {
|
|
54
|
+
return [webhooksErrors.WEBHOOKS_ENDPOINT_INVALID({ problem }), void 0];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates the endpoint of a member, so `sendToMemberEndpoint(owner, ...)` reaches their own agent, and returns
|
|
58
|
+
* `[error, endpoint]`. A `"url"` endpoint must pass `checkWebhookUrl()` with `hosts`, which defaults to the T3 Code
|
|
59
|
+
* relay. Webhooks seals the URL and secret with `VITEHUB_WEBHOOKS_KEY` before it stores them, and returns only the host.
|
|
60
|
+
* A member has one endpoint per `address`: a new one replaces the one with the same address, and its id changes.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { createMemberEndpoint } from "@vite-hub/webhooks"
|
|
64
|
+
*
|
|
65
|
+
* const [error, endpoint] = await createMemberEndpoint({
|
|
66
|
+
* owner: "user_ana",
|
|
67
|
+
* name: "Launch plan thread",
|
|
68
|
+
* agent: "t3",
|
|
69
|
+
* kind: "url",
|
|
70
|
+
* url: "https://relay.t3.codes/hooks/abc123",
|
|
71
|
+
* secret: "whsec_9f2c",
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
async function createMemberEndpoint(options) {
|
|
76
|
+
const { endpoints, developmentKey } = requireMemberEndpoints();
|
|
77
|
+
const problem = text(options?.owner, "owner", limits.owner) ?? text(options.name, "name", limits.name) ?? (options.agent === void 0 ? void 0 : text(options.agent, "agent", limits.agent)) ?? (options.ownerName === void 0 ? void 0 : text(options.ownerName, "ownerName", limits.name)) ?? (options.ownerEmail === void 0 ? void 0 : text(options.ownerEmail, "ownerEmail", limits.email)) ?? (options.address === void 0 ? void 0 : text(options.address, "address", limits.address));
|
|
78
|
+
if (problem) return invalid(problem);
|
|
79
|
+
const kind = options.kind;
|
|
80
|
+
if (kind !== "url" && kind !== "inbox") return invalid(`\`kind\` must be "url" or "inbox", not ${JSON.stringify(kind)}`);
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
const endpoint = {
|
|
83
|
+
id: `whe_${crypto.randomUUID()}`,
|
|
84
|
+
owner: options.owner,
|
|
85
|
+
ownerName: options.ownerName?.trim() ?? null,
|
|
86
|
+
ownerEmail: options.ownerEmail?.trim().toLowerCase() ?? null,
|
|
87
|
+
name: options.name.trim(),
|
|
88
|
+
address: options.address?.trim() ?? "",
|
|
89
|
+
kind: options.kind,
|
|
90
|
+
agent: options.agent?.trim() ?? null,
|
|
91
|
+
host: null,
|
|
92
|
+
sealed: null,
|
|
93
|
+
disabledAt: null,
|
|
94
|
+
disabledBy: null,
|
|
95
|
+
createdAt: now,
|
|
96
|
+
updatedAt: now
|
|
97
|
+
};
|
|
98
|
+
if (options.kind === "url") {
|
|
99
|
+
const urlProblem = text(options.url, "url", limits.url) ?? text(options.secret, "secret", limits.secret);
|
|
100
|
+
if (urlProblem) return invalid(urlProblem);
|
|
101
|
+
const [refused, url] = await checkWebhookUrl(options.url, { hosts: options.hosts ?? memberEndpointHosts });
|
|
102
|
+
if (refused) return [refused, void 0];
|
|
103
|
+
const [keyError, sealed] = await sealEndpoint(endpoint, {
|
|
104
|
+
url: url.href,
|
|
105
|
+
secret: options.secret
|
|
106
|
+
}, developmentKey);
|
|
107
|
+
if (keyError) return [keyError, void 0];
|
|
108
|
+
endpoint.host = url.host;
|
|
109
|
+
endpoint.sealed = sealed;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await endpoints.put(endpoint);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return [storeError(error), void 0];
|
|
115
|
+
}
|
|
116
|
+
return [void 0, toMemberEndpoint(endpoint)];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The endpoint that a send to a member reaches, or `null` when they have none, as `[error, endpoint]`: the one with
|
|
120
|
+
* `endpointId` or `address`, else their newest. It never holds the URL or the secret.
|
|
121
|
+
*/
|
|
122
|
+
async function getMemberEndpoint(owner, options = {}) {
|
|
123
|
+
const { endpoints } = requireMemberEndpoints();
|
|
124
|
+
try {
|
|
125
|
+
const endpoint = await selectEndpoint(endpoints, owner, options);
|
|
126
|
+
return [void 0, endpoint ? toMemberEndpoint(endpoint) : null];
|
|
127
|
+
} catch (error) {
|
|
128
|
+
return [storeError(error), void 0];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Removes the endpoint `id` of a member. Another member's endpoint gives `WEBHOOKS_ENDPOINT_NOT_FOUND`. */
|
|
132
|
+
async function removeMemberEndpoint(owner, id) {
|
|
133
|
+
const { endpoints } = requireMemberEndpoints();
|
|
134
|
+
try {
|
|
135
|
+
const endpoint = await endpoints.remove(owner, id);
|
|
136
|
+
return endpoint ? [void 0, toMemberEndpoint(endpoint)] : [webhooksErrors.WEBHOOKS_ENDPOINT_NOT_FOUND({ match: `the id ${JSON.stringify(id)} and the owner ${JSON.stringify(owner)}` }), void 0];
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return [storeError(error), void 0];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Removes every endpoint of a member, such as when they disconnect their agents, and returns `[error, removed]`. A member
|
|
143
|
+
* with no endpoint gets an empty list.
|
|
144
|
+
*/
|
|
145
|
+
async function removeMemberEndpoints(owner) {
|
|
146
|
+
const { endpoints } = requireMemberEndpoints();
|
|
147
|
+
try {
|
|
148
|
+
return [void 0, (await endpoints.removeAll(owner)).map(toMemberEndpoint)];
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return [storeError(error), void 0];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A page of member endpoints, the oldest first, with the newest delivery to each, as `[error, endpoints]`. The rows never
|
|
155
|
+
* hold the URL or the secret. Check that the caller may read them, such as an admin, before you call it.
|
|
156
|
+
*/
|
|
157
|
+
async function listMemberEndpoints(options = {}) {
|
|
158
|
+
const { endpoints, store } = requireMemberEndpoints();
|
|
159
|
+
try {
|
|
160
|
+
const rows = await endpoints.list(options);
|
|
161
|
+
const results = await store.memberResults(rows.map((row) => `@${row.id}`));
|
|
162
|
+
return [void 0, rows.map((row) => ({
|
|
163
|
+
...toMemberEndpoint(row),
|
|
164
|
+
last: results.get(`@${row.id}`) ?? null
|
|
165
|
+
}))];
|
|
166
|
+
} catch (error) {
|
|
167
|
+
return [storeError(error), void 0];
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Disables a member endpoint, so it gets no more sends, without the owner. `by` names who did it, such as the admin,
|
|
172
|
+
* for the Console. Check that the caller may do this before you call it. `enableMemberEndpoint()` undoes it, and so
|
|
173
|
+
* does the member when they connect their agent again.
|
|
174
|
+
*/
|
|
175
|
+
async function disableMemberEndpoint(id, options = {}) {
|
|
176
|
+
const { endpoints } = requireMemberEndpoints();
|
|
177
|
+
try {
|
|
178
|
+
const endpoint = await endpoints.disable(id, Date.now(), options.by?.trim() || null);
|
|
179
|
+
return endpoint ? [void 0, toMemberEndpoint(endpoint)] : [webhooksErrors.WEBHOOKS_ENDPOINT_NOT_FOUND({ match: `the id ${JSON.stringify(id)}` }), void 0];
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return [storeError(error), void 0];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Enables a member endpoint that an admin disabled, so it gets sends again. Check that the caller may do this first. */
|
|
185
|
+
async function enableMemberEndpoint(id) {
|
|
186
|
+
const { endpoints } = requireMemberEndpoints();
|
|
187
|
+
try {
|
|
188
|
+
const endpoint = await endpoints.enable(id, Date.now());
|
|
189
|
+
return endpoint ? [void 0, toMemberEndpoint(endpoint)] : [webhooksErrors.WEBHOOKS_ENDPOINT_NOT_FOUND({ match: `the id ${JSON.stringify(id)}` }), void 0];
|
|
190
|
+
} catch (error) {
|
|
191
|
+
return [storeError(error), void 0];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Sends `body` as JSON to the endpoint of a member and returns `[error, { id, status }]`. It posts in the request,
|
|
196
|
+
* with a 10 second timeout and the same headers and signature as `sendWebhook()`, so it needs no Queue. When the app
|
|
197
|
+
* has Queue, a failed post is tried again through it, and `status` is `"pending"`. Without Queue, it is `"failed"`.
|
|
198
|
+
*
|
|
199
|
+
* A send with the `key` of a pending, sending, or sent delivery returns that delivery and posts nothing.
|
|
200
|
+
*
|
|
201
|
+
* ```ts
|
|
202
|
+
* import { sendToMemberEndpoint } from "@vite-hub/webhooks"
|
|
203
|
+
*
|
|
204
|
+
* const [error, sent] = await sendToMemberEndpoint("user_ana", { threads: ["thr_1", "thr_2"] }, {
|
|
205
|
+
* event: "comments.send",
|
|
206
|
+
* key: "thr_1:msg_8,thr_2:msg_3",
|
|
207
|
+
* })
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
async function sendToMemberEndpoint(owner, body, options) {
|
|
211
|
+
const installed = requireMemberEndpoints();
|
|
212
|
+
const { store } = installed;
|
|
213
|
+
let json;
|
|
214
|
+
try {
|
|
215
|
+
json = JSON.stringify(body);
|
|
216
|
+
} catch {
|
|
217
|
+
json = void 0;
|
|
218
|
+
}
|
|
219
|
+
if (json === void 0) return [webhooksErrors.WEBHOOKS_BODY_INVALID({ webhook: `of the member ${JSON.stringify(owner)}` }), void 0];
|
|
220
|
+
try {
|
|
221
|
+
const endpoint = await selectEndpoint(installed.endpoints, owner, options);
|
|
222
|
+
if (!endpoint) return [webhooksErrors.WEBHOOKS_ENDPOINT_NOT_FOUND({ match: options.endpointId === void 0 ? `the owner ${JSON.stringify(owner)}` : JSON.stringify(options.endpointId) }), void 0];
|
|
223
|
+
if (endpoint.disabledAt !== null) return [webhooksErrors.WEBHOOKS_ENDPOINT_DISABLED({ id: endpoint.id }), void 0];
|
|
224
|
+
let target;
|
|
225
|
+
if (endpoint.sealed !== null) {
|
|
226
|
+
const [keyError, opened] = await unsealEndpoint({
|
|
227
|
+
...endpoint,
|
|
228
|
+
sealed: endpoint.sealed
|
|
229
|
+
}, installed.developmentKey);
|
|
230
|
+
if (keyError) return [keyError, void 0];
|
|
231
|
+
const outside = options.hosts && outsideHosts(new URL(opened.url), options.hosts);
|
|
232
|
+
if (outside) return [webhooksErrors.WEBHOOKS_URL_REFUSED({ reason: outside }), void 0];
|
|
233
|
+
target = opened;
|
|
234
|
+
}
|
|
235
|
+
const webhook = `@${endpoint.id}`;
|
|
236
|
+
if (options.sealBody) {
|
|
237
|
+
const [error, sealed] = await sealWebhooksText(memberBodyLabel(webhook, options.event), json, installed.developmentKey);
|
|
238
|
+
if (error) return [error, void 0];
|
|
239
|
+
json = JSON.stringify(`${sealedMemberBodyPrefix}${sealed}`);
|
|
240
|
+
}
|
|
241
|
+
const now = Date.now();
|
|
242
|
+
const recorded = await store.recordOnce({
|
|
243
|
+
id: options.deliveryId ?? createDeliveryId(),
|
|
244
|
+
webhook,
|
|
245
|
+
owner: endpoint.owner,
|
|
246
|
+
key: options.key,
|
|
247
|
+
event: options.event,
|
|
248
|
+
body: json,
|
|
249
|
+
dueAt: now,
|
|
250
|
+
now
|
|
251
|
+
});
|
|
252
|
+
const done = target ? "sent" : "inbox";
|
|
253
|
+
if (!recorded.created) return [void 0, {
|
|
254
|
+
id: recorded.id,
|
|
255
|
+
status: recorded.state === "sent" ? done : "pending"
|
|
256
|
+
}];
|
|
257
|
+
const claim = await store.claim(recorded.id, recorded.revision, now, 0);
|
|
258
|
+
if (!claim) return [void 0, {
|
|
259
|
+
id: recorded.id,
|
|
260
|
+
status: "pending"
|
|
261
|
+
}];
|
|
262
|
+
return await deliverMemberClaim(installed, claim, target);
|
|
263
|
+
} catch (error) {
|
|
264
|
+
return [storeError(error), void 0];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async function selectEndpoint(endpoints, owner, options) {
|
|
268
|
+
if (options.endpointId === void 0) return endpoints.get(owner, options.address);
|
|
269
|
+
const endpoint = await endpoints.find(options.endpointId);
|
|
270
|
+
return endpoint?.owner === owner ? endpoint : void 0;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The deliveries to the endpoint that a send to the member with `address` reaches, the newest first, as
|
|
274
|
+
* `[error, { endpoint, deliveries }]`, or `null` when the member has no endpoint. An agent that pairs as an inbox reads
|
|
275
|
+
* its sends here: pass its `endpointId` for an exact lookup with no fallback, and the last delivery as `before` for
|
|
276
|
+
* the next page. An empty `address` prefers the unaddressed endpoint. Check that the caller acts as `owner` first.
|
|
277
|
+
* Sealed bodies are omitted, as in the delivery log.
|
|
278
|
+
*
|
|
279
|
+
* ```ts
|
|
280
|
+
* import { listMemberDeliveries } from "@vite-hub/webhooks"
|
|
281
|
+
*
|
|
282
|
+
* const [error, inbox] = await listMemberDeliveries("user_ana", { limit: 20 })
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
async function listMemberDeliveries(owner, options = {}) {
|
|
286
|
+
const { endpoints, store } = requireMemberEndpoints();
|
|
287
|
+
try {
|
|
288
|
+
const endpoint = await selectEndpoint(endpoints, owner, options);
|
|
289
|
+
if (!endpoint) return [void 0, null];
|
|
290
|
+
const deliveries = await store.list({
|
|
291
|
+
webhook: `@${endpoint.id}`,
|
|
292
|
+
limit: options.limit,
|
|
293
|
+
before: options.before
|
|
294
|
+
});
|
|
295
|
+
return [void 0, {
|
|
296
|
+
endpoint: toMemberEndpoint(endpoint),
|
|
297
|
+
deliveries: deliveries.map(inspectDelivery)
|
|
298
|
+
}];
|
|
299
|
+
} catch (error) {
|
|
300
|
+
return [storeError(error), void 0];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/** Reads only the state of a known member delivery, never its body. */
|
|
304
|
+
async function getMemberDeliveryState(id) {
|
|
305
|
+
const row = await requireMemberEndpoints().store.get(id);
|
|
306
|
+
return row?.webhook.startsWith("@") ? row.state : void 0;
|
|
307
|
+
}
|
|
308
|
+
export { getMemberEndpoint as a, memberEndpointHosts as c, removeMemberEndpoints as d, sendToMemberEndpoint as f, getMemberDeliveryState as i, members_exports as l, disableMemberEndpoint as n, listMemberDeliveries as o, enableMemberEndpoint as r, listMemberEndpoints as s, createMemberEndpoint as t, removeMemberEndpoint as u };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// ../internal/src/object.ts
|
|
2
|
+
/** A non-null object that is not an array. Functions do not pass. */
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
/** A non-null object or a function that is not an array. */
|
|
7
|
+
function isRecordOrFunction(value) {
|
|
8
|
+
return Object(value) === value && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
export { isRecordOrFunction as n, isRecord as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
//#region ../internal/src/operation-definition.d.ts
|
|
3
2
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
4
3
|
type OperationKind = "read" | "write" | "destructive";
|
|
5
4
|
/** The signed-in user of a call. */
|
|
@@ -28,6 +27,11 @@ interface OperationAccess {
|
|
|
28
27
|
*/
|
|
29
28
|
readonly sections: "all" | readonly string[];
|
|
30
29
|
readonly user?: OperationUser;
|
|
30
|
+
/**
|
|
31
|
+
* Who signed the call: `"console"` when the ViteHub Console signed it for a person, whose `user` is then a Console
|
|
32
|
+
* account and not an app user, or `"cli"` for a key. Not set for other calls.
|
|
33
|
+
*/
|
|
34
|
+
readonly via?: "console" | "cli";
|
|
31
35
|
}
|
|
32
36
|
interface OperationContext {
|
|
33
37
|
/** The checked Console access of the call. */
|
|
@@ -90,7 +94,8 @@ interface OperationDefinition<Input, Output> {
|
|
|
90
94
|
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
91
95
|
input: StandardSchemaV1<unknown, Input>;
|
|
92
96
|
output?: StandardSchemaV1<unknown, Output>;
|
|
93
|
-
|
|
97
|
+
/** `false`: no `vitehub` command. The Console and MCP still call the operation. */
|
|
98
|
+
cli?: false | {
|
|
94
99
|
/** Defaults: namespace = section, command = verb. */
|
|
95
100
|
namespace?: string;
|
|
96
101
|
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
@@ -131,7 +136,7 @@ interface OperationDefinition<Input, Output> {
|
|
|
131
136
|
/** An operation of any input and output, as a registry holds it. */
|
|
132
137
|
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
|
|
133
138
|
readOnlyWhen?: (input: never) => boolean;
|
|
134
|
-
cli?: {
|
|
139
|
+
cli?: false | {
|
|
135
140
|
namespace?: string;
|
|
136
141
|
command?: string;
|
|
137
142
|
default?: boolean;
|
|
@@ -161,5 +166,4 @@ interface OperationContributionEntry {
|
|
|
161
166
|
}
|
|
162
167
|
/** The contribution of a plugin: a list, or a function that returns it, for a plugin that reads the project first. */
|
|
163
168
|
type OperationContributions = readonly OperationContributionEntry[] | (() => readonly OperationContributionEntry[] | Promise<readonly OperationContributionEntry[]>);
|
|
164
|
-
//#endregion
|
|
165
169
|
export { OperationContributions as n, AnyOperation as t };
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { t as AnyOperation } from "./operations-
|
|
2
|
-
|
|
1
|
+
import { t as AnyOperation } from "./operations-8hqTi0DH.js";
|
|
2
|
+
import { r as MemberEndpoint } from "./database-C5cwO1an.js";
|
|
3
|
+
import { r as MemberEndpointWithLastDelivery } from "./members-BjDcAAhY.js";
|
|
4
|
+
/**
|
|
5
|
+
* One member endpoint, as `webhooks.endpoints` lists it for admins: no URL, no secret, and no email. `mine` is true
|
|
6
|
+
* when the caller owns it, so the Console shows Redeliver only on the caller's own deliveries.
|
|
7
|
+
*/
|
|
8
|
+
export type MemberEndpointRow = Omit<MemberEndpointWithLastDelivery, "ownerEmail"> & {
|
|
9
|
+
mine: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** What the Disable and Enable operations return. */
|
|
12
|
+
export type MemberEndpointChange = Pick<MemberEndpoint, "id" | "owner" | "disabledAt" | "disabledBy">;
|
|
3
13
|
/**
|
|
4
14
|
* The `webhooks.*` operations. The Console, `vitehub webhooks`, and MCP run them on the app's operation RPC, `POST
|
|
5
15
|
* /_vitehub/rpc`.
|
|
6
16
|
*/
|
|
7
|
-
export declare const webhooksOperations: readonly AnyOperation[];
|
|
8
|
-
//#endregion
|
|
17
|
+
export declare const webhooksOperations: readonly AnyOperation[];
|