@fdcn/sourcefed 0.3.2 → 0.3.4
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 +2 -2
- package/dist/chunk-BNLZQKEB.js +962 -0
- package/dist/{chunk-QPDTUNFA.js → chunk-X3BZSHKZ.js} +55 -45
- package/dist/cli.js +104 -96
- package/dist/daemon.js +341 -1271
- package/dist/data/core/references/commands.md +1 -1
- package/dist/mcp.js +1 -1
- package/dist/opencode.js +124 -37
- package/dist/pi.js +5 -4
- package/dist.dts/adapters/opencode/bridge.d.ts +18 -2
- package/dist.dts/adapters/opencode/bridge.test.d.ts +1 -0
- package/dist.dts/packages/cli/src/utils/flags.d.ts +2 -0
- package/dist.dts/packages/cli/src/utils/flags.test.d.ts +1 -0
- package/dist.dts/packages/daemon/src/daemon.d.ts +5 -0
- package/dist.dts/packages/daemon/src/forward.test.d.ts +1 -0
- package/dist.dts/packages/daemon/src/gate.test.d.ts +1 -0
- package/dist.dts/packages/daemon/src/utils/forward.d.ts +32 -0
- package/dist.dts/packages/daemon/src/utils/gate.d.ts +33 -0
- package/dist.dts/providers/slack/src/poll/utils/slack-api.d.ts +12 -4
- package/dist.dts/providers/slack/src/poll/utils/slack-api.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -1,954 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JsonMonitorEventQueue,
|
|
3
|
+
JsonMonitorStore,
|
|
4
|
+
MonitorRuntime
|
|
5
|
+
} from "./chunk-BNLZQKEB.js";
|
|
1
6
|
import "./chunk-MLKGABMK.js";
|
|
2
7
|
|
|
3
|
-
// packages/core/dist/index.js
|
|
4
|
-
import { link, mkdir, open, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
5
|
-
import os from "node:os";
|
|
6
|
-
import path from "node:path";
|
|
7
|
-
var store$4;
|
|
8
|
-
var DEFAULT_CONFIG = {
|
|
9
|
-
lang: void 0,
|
|
10
|
-
message: void 0,
|
|
11
|
-
abortEarly: void 0,
|
|
12
|
-
abortPipeEarly: void 0
|
|
13
|
-
};
|
|
14
|
-
// @__NO_SIDE_EFFECTS__
|
|
15
|
-
function getGlobalConfig(config$1) {
|
|
16
|
-
if (!config$1 && !store$4) return DEFAULT_CONFIG;
|
|
17
|
-
return {
|
|
18
|
-
lang: config$1?.lang ?? store$4?.lang,
|
|
19
|
-
message: config$1?.message,
|
|
20
|
-
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
21
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
var store$3;
|
|
25
|
-
// @__NO_SIDE_EFFECTS__
|
|
26
|
-
function getGlobalMessage(lang) {
|
|
27
|
-
return store$3?.get(lang);
|
|
28
|
-
}
|
|
29
|
-
var store$2;
|
|
30
|
-
// @__NO_SIDE_EFFECTS__
|
|
31
|
-
function getSchemaMessage(lang) {
|
|
32
|
-
return store$2?.get(lang);
|
|
33
|
-
}
|
|
34
|
-
var store$1;
|
|
35
|
-
// @__NO_SIDE_EFFECTS__
|
|
36
|
-
function getSpecificMessage(reference, lang) {
|
|
37
|
-
return store$1?.get(reference)?.get(lang);
|
|
38
|
-
}
|
|
39
|
-
// @__NO_SIDE_EFFECTS__
|
|
40
|
-
function _stringify(input) {
|
|
41
|
-
const type = typeof input;
|
|
42
|
-
if (type === "string") return `"${input}"`;
|
|
43
|
-
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
44
|
-
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
45
|
-
return type;
|
|
46
|
-
}
|
|
47
|
-
function _addIssue(context, label, dataset, config$1, other) {
|
|
48
|
-
const input = other && "input" in other ? other.input : dataset.value;
|
|
49
|
-
const expected = other?.expected ?? context.expects ?? null;
|
|
50
|
-
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
51
|
-
const issue = {
|
|
52
|
-
kind: context.kind,
|
|
53
|
-
type: context.type,
|
|
54
|
-
input,
|
|
55
|
-
expected,
|
|
56
|
-
received,
|
|
57
|
-
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
|
|
58
|
-
requirement: context.requirement,
|
|
59
|
-
path: other?.path,
|
|
60
|
-
issues: other?.issues,
|
|
61
|
-
lang: config$1.lang,
|
|
62
|
-
abortEarly: config$1.abortEarly,
|
|
63
|
-
abortPipeEarly: config$1.abortPipeEarly
|
|
64
|
-
};
|
|
65
|
-
const isSchema = context.kind === "schema";
|
|
66
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
67
|
-
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
68
|
-
if (isSchema) dataset.typed = false;
|
|
69
|
-
if (dataset.issues) dataset.issues.push(issue);
|
|
70
|
-
else dataset.issues = [issue];
|
|
71
|
-
}
|
|
72
|
-
var _standardCache = /* @__PURE__ */ new WeakMap();
|
|
73
|
-
// @__NO_SIDE_EFFECTS__
|
|
74
|
-
function _getStandardProps(context) {
|
|
75
|
-
let cached = _standardCache.get(context);
|
|
76
|
-
if (!cached) {
|
|
77
|
-
cached = {
|
|
78
|
-
version: 1,
|
|
79
|
-
vendor: "valibot",
|
|
80
|
-
validate(value$1) {
|
|
81
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
_standardCache.set(context, cached);
|
|
85
|
-
}
|
|
86
|
-
return cached;
|
|
87
|
-
}
|
|
88
|
-
// @__NO_SIDE_EFFECTS__
|
|
89
|
-
function _isValidObjectKey(object$1, key) {
|
|
90
|
-
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
|
|
91
|
-
}
|
|
92
|
-
// @__NO_SIDE_EFFECTS__
|
|
93
|
-
function _joinExpects(values$1, separator) {
|
|
94
|
-
const list = [...new Set(values$1)];
|
|
95
|
-
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
|
|
96
|
-
return list[0] ?? "never";
|
|
97
|
-
}
|
|
98
|
-
var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
99
|
-
// @__NO_SIDE_EFFECTS__
|
|
100
|
-
function getFallback(schema, dataset, config$1) {
|
|
101
|
-
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
102
|
-
}
|
|
103
|
-
// @__NO_SIDE_EFFECTS__
|
|
104
|
-
function getDefault(schema, dataset, config$1) {
|
|
105
|
-
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
106
|
-
}
|
|
107
|
-
// @__NO_SIDE_EFFECTS__
|
|
108
|
-
function array(item, message$1) {
|
|
109
|
-
return {
|
|
110
|
-
kind: "schema",
|
|
111
|
-
type: "array",
|
|
112
|
-
reference: array,
|
|
113
|
-
expects: "Array",
|
|
114
|
-
async: false,
|
|
115
|
-
item,
|
|
116
|
-
message: message$1,
|
|
117
|
-
get "~standard"() {
|
|
118
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
119
|
-
},
|
|
120
|
-
"~run"(dataset, config$1) {
|
|
121
|
-
const input = dataset.value;
|
|
122
|
-
if (Array.isArray(input)) {
|
|
123
|
-
dataset.typed = true;
|
|
124
|
-
dataset.value = [];
|
|
125
|
-
for (let key = 0; key < input.length; key++) {
|
|
126
|
-
const value$1 = input[key];
|
|
127
|
-
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
|
|
128
|
-
if (itemDataset.issues) {
|
|
129
|
-
const pathItem = {
|
|
130
|
-
type: "array",
|
|
131
|
-
origin: "value",
|
|
132
|
-
input,
|
|
133
|
-
key,
|
|
134
|
-
value: value$1
|
|
135
|
-
};
|
|
136
|
-
for (const issue of itemDataset.issues) {
|
|
137
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
138
|
-
else issue.path = [pathItem];
|
|
139
|
-
dataset.issues?.push(issue);
|
|
140
|
-
}
|
|
141
|
-
if (!dataset.issues) dataset.issues = itemDataset.issues;
|
|
142
|
-
if (config$1.abortEarly) {
|
|
143
|
-
dataset.typed = false;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (!itemDataset.typed) dataset.typed = false;
|
|
148
|
-
dataset.value.push(itemDataset.value);
|
|
149
|
-
}
|
|
150
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
151
|
-
return dataset;
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
// @__NO_SIDE_EFFECTS__
|
|
156
|
-
function boolean(message$1) {
|
|
157
|
-
return {
|
|
158
|
-
kind: "schema",
|
|
159
|
-
type: "boolean",
|
|
160
|
-
reference: boolean,
|
|
161
|
-
expects: "boolean",
|
|
162
|
-
async: false,
|
|
163
|
-
message: message$1,
|
|
164
|
-
get "~standard"() {
|
|
165
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
166
|
-
},
|
|
167
|
-
"~run"(dataset, config$1) {
|
|
168
|
-
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
169
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
170
|
-
return dataset;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
// @__NO_SIDE_EFFECTS__
|
|
175
|
-
function _merge(value1, value2) {
|
|
176
|
-
if (typeof value1 === typeof value2) {
|
|
177
|
-
if (value1 === value2 || value1 instanceof Date && value2 instanceof Date && +value1 === +value2) return { value: value1 };
|
|
178
|
-
if (value1 && value2 && value1.constructor === Object && value2.constructor === Object) {
|
|
179
|
-
const nextValue = { ...value1 };
|
|
180
|
-
for (const key in value2) if (Object.prototype.hasOwnProperty.call(value1, key)) {
|
|
181
|
-
const dataset = /* @__PURE__ */ _merge(value1[key], value2[key]);
|
|
182
|
-
if (dataset.issue) return dataset;
|
|
183
|
-
nextValue[key] = dataset.value;
|
|
184
|
-
} else nextValue[key] = value2[key];
|
|
185
|
-
return { value: nextValue };
|
|
186
|
-
}
|
|
187
|
-
if (Array.isArray(value1) && Array.isArray(value2)) {
|
|
188
|
-
if (value1.length === value2.length) {
|
|
189
|
-
const nextValue = [...value1];
|
|
190
|
-
for (let index = 0; index < value1.length; index++) {
|
|
191
|
-
const dataset = /* @__PURE__ */ _merge(value1[index], value2[index]);
|
|
192
|
-
if (dataset.issue) return dataset;
|
|
193
|
-
nextValue[index] = dataset.value;
|
|
194
|
-
}
|
|
195
|
-
return { value: nextValue };
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return { issue: true };
|
|
200
|
-
}
|
|
201
|
-
// @__NO_SIDE_EFFECTS__
|
|
202
|
-
function intersect(options, message$1) {
|
|
203
|
-
return {
|
|
204
|
-
kind: "schema",
|
|
205
|
-
type: "intersect",
|
|
206
|
-
reference: intersect,
|
|
207
|
-
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "&"),
|
|
208
|
-
async: false,
|
|
209
|
-
options,
|
|
210
|
-
message: message$1,
|
|
211
|
-
get "~standard"() {
|
|
212
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
213
|
-
},
|
|
214
|
-
"~run"(dataset, config$1) {
|
|
215
|
-
if (this.options.length) {
|
|
216
|
-
const input = dataset.value;
|
|
217
|
-
let outputs;
|
|
218
|
-
dataset.typed = true;
|
|
219
|
-
for (const schema of this.options) {
|
|
220
|
-
const optionDataset = schema["~run"]({ value: input }, config$1);
|
|
221
|
-
if (optionDataset.issues) {
|
|
222
|
-
if (dataset.issues) for (const issue of optionDataset.issues) dataset.issues.push(issue);
|
|
223
|
-
else dataset.issues = optionDataset.issues;
|
|
224
|
-
if (config$1.abortEarly) {
|
|
225
|
-
dataset.typed = false;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (!optionDataset.typed) dataset.typed = false;
|
|
230
|
-
if (dataset.typed) if (outputs) outputs.push(optionDataset.value);
|
|
231
|
-
else outputs = [optionDataset.value];
|
|
232
|
-
}
|
|
233
|
-
if (dataset.typed) {
|
|
234
|
-
dataset.value = outputs[0];
|
|
235
|
-
for (let index = 1; index < outputs.length; index++) {
|
|
236
|
-
const mergeDataset = /* @__PURE__ */ _merge(dataset.value, outputs[index]);
|
|
237
|
-
if (mergeDataset.issue) {
|
|
238
|
-
_addIssue(this, "type", dataset, config$1, { received: "unknown" });
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
dataset.value = mergeDataset.value;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
245
|
-
return dataset;
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
// @__NO_SIDE_EFFECTS__
|
|
250
|
-
function number(message$1) {
|
|
251
|
-
return {
|
|
252
|
-
kind: "schema",
|
|
253
|
-
type: "number",
|
|
254
|
-
reference: number,
|
|
255
|
-
expects: "number",
|
|
256
|
-
async: false,
|
|
257
|
-
message: message$1,
|
|
258
|
-
get "~standard"() {
|
|
259
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
260
|
-
},
|
|
261
|
-
"~run"(dataset, config$1) {
|
|
262
|
-
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
263
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
264
|
-
return dataset;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
// @__NO_SIDE_EFFECTS__
|
|
269
|
-
function object(entries$1, message$1) {
|
|
270
|
-
return {
|
|
271
|
-
kind: "schema",
|
|
272
|
-
type: "object",
|
|
273
|
-
reference: object,
|
|
274
|
-
expects: "Object",
|
|
275
|
-
async: false,
|
|
276
|
-
entries: entries$1,
|
|
277
|
-
message: message$1,
|
|
278
|
-
get "~standard"() {
|
|
279
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
280
|
-
},
|
|
281
|
-
"~run"(dataset, config$1) {
|
|
282
|
-
const input = dataset.value;
|
|
283
|
-
if (input && typeof input === "object") {
|
|
284
|
-
dataset.typed = true;
|
|
285
|
-
dataset.value = {};
|
|
286
|
-
for (const key in this.entries) {
|
|
287
|
-
const valueSchema = this.entries[key];
|
|
288
|
-
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
289
|
-
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
290
|
-
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
291
|
-
if (valueDataset.issues) {
|
|
292
|
-
const pathItem = {
|
|
293
|
-
type: "object",
|
|
294
|
-
origin: "value",
|
|
295
|
-
input,
|
|
296
|
-
key,
|
|
297
|
-
value: value$1
|
|
298
|
-
};
|
|
299
|
-
for (const issue of valueDataset.issues) {
|
|
300
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
301
|
-
else issue.path = [pathItem];
|
|
302
|
-
dataset.issues?.push(issue);
|
|
303
|
-
}
|
|
304
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
305
|
-
if (config$1.abortEarly) {
|
|
306
|
-
dataset.typed = false;
|
|
307
|
-
break;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
if (!valueDataset.typed) dataset.typed = false;
|
|
311
|
-
dataset.value[key] = valueDataset.value;
|
|
312
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
313
|
-
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
314
|
-
_addIssue(this, "key", dataset, config$1, {
|
|
315
|
-
input: void 0,
|
|
316
|
-
expected: `"${key}"`,
|
|
317
|
-
path: [{
|
|
318
|
-
type: "object",
|
|
319
|
-
origin: "key",
|
|
320
|
-
input,
|
|
321
|
-
key,
|
|
322
|
-
value: input[key]
|
|
323
|
-
}]
|
|
324
|
-
});
|
|
325
|
-
if (config$1.abortEarly) break;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
329
|
-
return dataset;
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
// @__NO_SIDE_EFFECTS__
|
|
334
|
-
function picklist(options, message$1) {
|
|
335
|
-
return {
|
|
336
|
-
kind: "schema",
|
|
337
|
-
type: "picklist",
|
|
338
|
-
reference: picklist,
|
|
339
|
-
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
|
|
340
|
-
async: false,
|
|
341
|
-
options,
|
|
342
|
-
message: message$1,
|
|
343
|
-
get "~standard"() {
|
|
344
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
345
|
-
},
|
|
346
|
-
"~run"(dataset, config$1) {
|
|
347
|
-
if (this.options.includes(dataset.value)) dataset.typed = true;
|
|
348
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
349
|
-
return dataset;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
// @__NO_SIDE_EFFECTS__
|
|
354
|
-
function record(key, value$1, message$1) {
|
|
355
|
-
return {
|
|
356
|
-
kind: "schema",
|
|
357
|
-
type: "record",
|
|
358
|
-
reference: record,
|
|
359
|
-
expects: "Object",
|
|
360
|
-
async: false,
|
|
361
|
-
key,
|
|
362
|
-
value: value$1,
|
|
363
|
-
message: message$1,
|
|
364
|
-
get "~standard"() {
|
|
365
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
366
|
-
},
|
|
367
|
-
"~run"(dataset, config$1) {
|
|
368
|
-
const input = dataset.value;
|
|
369
|
-
if (input && typeof input === "object") {
|
|
370
|
-
dataset.typed = true;
|
|
371
|
-
dataset.value = {};
|
|
372
|
-
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
|
|
373
|
-
const entryValue = input[entryKey];
|
|
374
|
-
const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
|
|
375
|
-
if (keyDataset.issues) {
|
|
376
|
-
const pathItem = {
|
|
377
|
-
type: "object",
|
|
378
|
-
origin: "key",
|
|
379
|
-
input,
|
|
380
|
-
key: entryKey,
|
|
381
|
-
value: entryValue
|
|
382
|
-
};
|
|
383
|
-
for (const issue of keyDataset.issues) {
|
|
384
|
-
issue.path = [pathItem];
|
|
385
|
-
dataset.issues?.push(issue);
|
|
386
|
-
}
|
|
387
|
-
if (!dataset.issues) dataset.issues = keyDataset.issues;
|
|
388
|
-
if (config$1.abortEarly) {
|
|
389
|
-
dataset.typed = false;
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
|
|
394
|
-
if (valueDataset.issues) {
|
|
395
|
-
const pathItem = {
|
|
396
|
-
type: "object",
|
|
397
|
-
origin: "value",
|
|
398
|
-
input,
|
|
399
|
-
key: entryKey,
|
|
400
|
-
value: entryValue
|
|
401
|
-
};
|
|
402
|
-
for (const issue of valueDataset.issues) {
|
|
403
|
-
if (issue.path) issue.path.unshift(pathItem);
|
|
404
|
-
else issue.path = [pathItem];
|
|
405
|
-
dataset.issues?.push(issue);
|
|
406
|
-
}
|
|
407
|
-
if (!dataset.issues) dataset.issues = valueDataset.issues;
|
|
408
|
-
if (config$1.abortEarly) {
|
|
409
|
-
dataset.typed = false;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
|
|
414
|
-
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
|
|
415
|
-
}
|
|
416
|
-
} else _addIssue(this, "type", dataset, config$1);
|
|
417
|
-
return dataset;
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
// @__NO_SIDE_EFFECTS__
|
|
422
|
-
function string(message$1) {
|
|
423
|
-
return {
|
|
424
|
-
kind: "schema",
|
|
425
|
-
type: "string",
|
|
426
|
-
reference: string,
|
|
427
|
-
expects: "string",
|
|
428
|
-
async: false,
|
|
429
|
-
message: message$1,
|
|
430
|
-
get "~standard"() {
|
|
431
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
432
|
-
},
|
|
433
|
-
"~run"(dataset, config$1) {
|
|
434
|
-
if (typeof dataset.value === "string") dataset.typed = true;
|
|
435
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
436
|
-
return dataset;
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
// @__NO_SIDE_EFFECTS__
|
|
441
|
-
function unknown() {
|
|
442
|
-
return {
|
|
443
|
-
kind: "schema",
|
|
444
|
-
type: "unknown",
|
|
445
|
-
reference: unknown,
|
|
446
|
-
expects: "unknown",
|
|
447
|
-
async: false,
|
|
448
|
-
get "~standard"() {
|
|
449
|
-
return /* @__PURE__ */ _getStandardProps(this);
|
|
450
|
-
},
|
|
451
|
-
"~run"(dataset) {
|
|
452
|
-
dataset.typed = true;
|
|
453
|
-
return dataset;
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
// @__NO_SIDE_EFFECTS__
|
|
458
|
-
function safeParse(schema, input, config$1) {
|
|
459
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
460
|
-
return {
|
|
461
|
-
typed: dataset.typed,
|
|
462
|
-
success: !dataset.issues,
|
|
463
|
-
output: dataset.value,
|
|
464
|
-
issues: dataset.issues
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function monitorSourceIdentity(source) {
|
|
468
|
-
return JSON.stringify(stableValue(source));
|
|
469
|
-
}
|
|
470
|
-
function stableValue(value) {
|
|
471
|
-
if (Array.isArray(value)) return value.map(stableValue);
|
|
472
|
-
if (!value || typeof value !== "object") return value;
|
|
473
|
-
return Object.fromEntries(
|
|
474
|
-
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableValue(entry)])
|
|
475
|
-
);
|
|
476
|
-
}
|
|
477
|
-
function monitorIdentity(target, source) {
|
|
478
|
-
return JSON.stringify([target.kind, target.id, monitorSourceIdentity(source)]);
|
|
479
|
-
}
|
|
480
|
-
function dedupeActiveMonitors(monitors) {
|
|
481
|
-
const seen = /* @__PURE__ */ new Set();
|
|
482
|
-
const result = [];
|
|
483
|
-
for (const monitor of monitors) {
|
|
484
|
-
if (!monitor.enabled) {
|
|
485
|
-
result.push(monitor);
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
|
-
const identity = monitorIdentity(monitor.target, monitor.source);
|
|
489
|
-
if (seen.has(identity)) continue;
|
|
490
|
-
seen.add(identity);
|
|
491
|
-
result.push(monitor);
|
|
492
|
-
}
|
|
493
|
-
return result;
|
|
494
|
-
}
|
|
495
|
-
var MonitorService = class {
|
|
496
|
-
constructor(store) {
|
|
497
|
-
this.store = store;
|
|
498
|
-
}
|
|
499
|
-
registryQueue = Promise.resolve();
|
|
500
|
-
async list() {
|
|
501
|
-
return (await this.store.load()).monitors;
|
|
502
|
-
}
|
|
503
|
-
async get(id) {
|
|
504
|
-
return (await this.store.load()).monitors.find((monitor) => monitor.id === id);
|
|
505
|
-
}
|
|
506
|
-
async create(input) {
|
|
507
|
-
return this.transact((registry) => {
|
|
508
|
-
registry.monitors = dedupeActiveMonitors(registry.monitors);
|
|
509
|
-
const identity = monitorIdentity(input.target, input.source);
|
|
510
|
-
const existing = registry.monitors.find(
|
|
511
|
-
(monitor2) => monitor2.enabled && monitorIdentity(monitor2.target, monitor2.source) === identity
|
|
512
|
-
);
|
|
513
|
-
if (existing) return { monitor: existing, created: false };
|
|
514
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
515
|
-
const monitor = {
|
|
516
|
-
id: `m-${Date.now().toString(36)}-${crypto.randomUUID().slice(0, 6)}`,
|
|
517
|
-
name: input.name,
|
|
518
|
-
source: input.source,
|
|
519
|
-
delivery: input.delivery,
|
|
520
|
-
target: input.target,
|
|
521
|
-
pollIntervalSec: Math.max(15, input.pollIntervalSec ?? 60),
|
|
522
|
-
enabled: true,
|
|
523
|
-
createdAt: now,
|
|
524
|
-
updatedAt: now,
|
|
525
|
-
cursors: {}
|
|
526
|
-
};
|
|
527
|
-
registry.monitors.push(monitor);
|
|
528
|
-
return { monitor, created: true };
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
async stop(id) {
|
|
532
|
-
return this.transact((registry) => {
|
|
533
|
-
const monitor = registry.monitors.find((entry) => entry.id === id);
|
|
534
|
-
if (!monitor) return { error: `monitor ${id} was not found` };
|
|
535
|
-
monitor.enabled = false;
|
|
536
|
-
monitor.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
537
|
-
return monitor;
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
async start(id) {
|
|
541
|
-
return this.transact((registry) => {
|
|
542
|
-
const monitor = registry.monitors.find((entry) => entry.id === id);
|
|
543
|
-
if (!monitor) return { error: `monitor ${id} was not found` };
|
|
544
|
-
const identity = monitorIdentity(monitor.target, monitor.source);
|
|
545
|
-
const duplicate = registry.monitors.find(
|
|
546
|
-
(entry) => entry.id !== id && entry.enabled && monitorIdentity(entry.target, entry.source) === identity
|
|
547
|
-
);
|
|
548
|
-
if (duplicate) return { error: `monitor ${id} duplicates active monitor ${duplicate.id} for the same source` };
|
|
549
|
-
monitor.enabled = true;
|
|
550
|
-
monitor.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
551
|
-
return monitor;
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
async remove(id) {
|
|
555
|
-
await this.transact((registry) => {
|
|
556
|
-
registry.monitors = registry.monitors.filter((monitor) => monitor.id !== id);
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
async setDelivery(id, delivery) {
|
|
560
|
-
await this.updateMonitor(id, (monitor) => {
|
|
561
|
-
monitor.delivery = delivery;
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
async updateCursor(monitor, key, value) {
|
|
565
|
-
await this.updateMonitor(monitor.id, (current) => {
|
|
566
|
-
current.cursors[key] = value;
|
|
567
|
-
});
|
|
568
|
-
}
|
|
569
|
-
async updateCursorValue(monitor, key, update) {
|
|
570
|
-
await this.updateMonitor(monitor.id, (current) => {
|
|
571
|
-
current.cursors[key] = update(current.cursors[key]);
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
async dedupe() {
|
|
575
|
-
return this.transact((registry) => {
|
|
576
|
-
const deduped = dedupeActiveMonitors(registry.monitors);
|
|
577
|
-
const removed = registry.monitors.length - deduped.length;
|
|
578
|
-
registry.monitors = deduped;
|
|
579
|
-
return removed;
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
async updateMonitor(id, update) {
|
|
583
|
-
await this.transact((registry) => {
|
|
584
|
-
const monitor = registry.monitors.find((entry) => entry.id === id);
|
|
585
|
-
if (!monitor) return;
|
|
586
|
-
update(monitor);
|
|
587
|
-
monitor.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
transact(operation) {
|
|
591
|
-
const next = this.registryQueue.then(async () => {
|
|
592
|
-
const registry = await this.store.load();
|
|
593
|
-
const result = await operation(registry);
|
|
594
|
-
await this.store.save(registry);
|
|
595
|
-
return result;
|
|
596
|
-
});
|
|
597
|
-
this.registryQueue = next.then(() => void 0, () => void 0);
|
|
598
|
-
return next;
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
async function tick(context) {
|
|
602
|
-
const monitors = await context.service.list();
|
|
603
|
-
for (const record2 of monitors) {
|
|
604
|
-
if (!record2.enabled) continue;
|
|
605
|
-
const source = context.sources[record2.source.type];
|
|
606
|
-
if (!source) {
|
|
607
|
-
console.error(`[sourcefed] no monitor provider for source type ${record2.source.type}`);
|
|
608
|
-
continue;
|
|
609
|
-
}
|
|
610
|
-
try {
|
|
611
|
-
await source.tick(context, record2);
|
|
612
|
-
} catch (error) {
|
|
613
|
-
console.error(`[sourcefed] monitor ${record2.id} poll failed:`, error);
|
|
614
|
-
await context.service.updateCursor(record2, "__lastAttemptAt", Date.now()).catch((updateError) => {
|
|
615
|
-
console.error(`[sourcefed] monitor ${record2.id} poll timestamp update failed:`, updateError);
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
async function deliverWebhook(context, source, event, deliveryId) {
|
|
621
|
-
let delivered = 0;
|
|
622
|
-
const monitors = await context.service.list();
|
|
623
|
-
for (const monitor of monitors) {
|
|
624
|
-
const monitorSource = context.sources[monitor.source.type];
|
|
625
|
-
if (!monitorSource) continue;
|
|
626
|
-
if (monitorSource.type !== source.type) continue;
|
|
627
|
-
delivered += await monitorSource.deliver(context, monitor, event, deliveryId);
|
|
628
|
-
}
|
|
629
|
-
return delivered;
|
|
630
|
-
}
|
|
631
|
-
async function heartbeatWebhooks(context, source, eventSource) {
|
|
632
|
-
const sourceKey = source.key(source.validateSource(eventSource));
|
|
633
|
-
const monitors = await context.service.list();
|
|
634
|
-
for (const monitor of monitors) {
|
|
635
|
-
if (!monitor.enabled || monitor.source.type !== source.type) continue;
|
|
636
|
-
if (source.key(source.validateSource(monitor.source)) !== sourceKey) continue;
|
|
637
|
-
await context.service.updateCursor(monitor, "__webhookHeartbeatAt", Date.now());
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
var MAX_WEBHOOK_BODY_BYTES = 1024 * 1024;
|
|
641
|
-
async function handleWebhook(request, context) {
|
|
642
|
-
const source = context.sourceForWebhookPath(new URL(request.url).pathname);
|
|
643
|
-
if (!source || !source.webhook) return new Response("not found", { status: 404 });
|
|
644
|
-
const body = await readBody(request);
|
|
645
|
-
if (body === void 0) return new Response("payload too large", { status: 413 });
|
|
646
|
-
if (!source.webhook.verify(body, request)) return new Response("invalid signature", { status: 401 });
|
|
647
|
-
let payload;
|
|
648
|
-
try {
|
|
649
|
-
payload = JSON.parse(body);
|
|
650
|
-
} catch {
|
|
651
|
-
return new Response("invalid json", { status: 400 });
|
|
652
|
-
}
|
|
653
|
-
const challenge = source.webhook.challenge?.(payload);
|
|
654
|
-
if (challenge) return Response.json(challenge);
|
|
655
|
-
const deliveryId = source.webhook.deliveryId(request, payload);
|
|
656
|
-
if (!deliveryId) return new Response("missing delivery id", { status: 400 });
|
|
657
|
-
const eventName = source.webhook.eventName(request, payload);
|
|
658
|
-
const event = source.webhook.parse(payload, eventName, deliveryId);
|
|
659
|
-
if (!event) return new Response("ignored", { status: 202 });
|
|
660
|
-
void heartbeatWebhooks(context, source, event.source).catch((error) => console.error("[sourcefed] webhook heartbeat failed:", error));
|
|
661
|
-
if (source.webhook.acknowledgeBeforeDelivery) {
|
|
662
|
-
void deliverWebhook(context, source, event, deliveryId).catch((error) => console.error("[sourcefed] webhook delivery failed:", error));
|
|
663
|
-
return new Response("accepted", { status: 202 });
|
|
664
|
-
}
|
|
665
|
-
await deliverWebhook(context, source, event, deliveryId);
|
|
666
|
-
return new Response("ok");
|
|
667
|
-
}
|
|
668
|
-
async function readBody(request) {
|
|
669
|
-
const contentLength = Number(request.headers.get("content-length"));
|
|
670
|
-
if (Number.isFinite(contentLength) && contentLength > MAX_WEBHOOK_BODY_BYTES) return void 0;
|
|
671
|
-
const reader = request.body?.getReader();
|
|
672
|
-
if (!reader) return "";
|
|
673
|
-
const chunks = [];
|
|
674
|
-
let length = 0;
|
|
675
|
-
try {
|
|
676
|
-
while (true) {
|
|
677
|
-
const { done, value } = await reader.read();
|
|
678
|
-
if (done) break;
|
|
679
|
-
length += value.byteLength;
|
|
680
|
-
if (length > MAX_WEBHOOK_BODY_BYTES) {
|
|
681
|
-
await reader.cancel();
|
|
682
|
-
return void 0;
|
|
683
|
-
}
|
|
684
|
-
chunks.push(value);
|
|
685
|
-
}
|
|
686
|
-
} finally {
|
|
687
|
-
reader.releaseLock();
|
|
688
|
-
}
|
|
689
|
-
const bytes = new Uint8Array(length);
|
|
690
|
-
let offset = 0;
|
|
691
|
-
for (const chunk of chunks) {
|
|
692
|
-
bytes.set(chunk, offset);
|
|
693
|
-
offset += chunk.byteLength;
|
|
694
|
-
}
|
|
695
|
-
return new TextDecoder().decode(bytes);
|
|
696
|
-
}
|
|
697
|
-
var MonitorRuntime = class {
|
|
698
|
-
service;
|
|
699
|
-
context;
|
|
700
|
-
timer;
|
|
701
|
-
activeTicks = /* @__PURE__ */ new Set();
|
|
702
|
-
constructor(options) {
|
|
703
|
-
this.service = new MonitorService(options.store);
|
|
704
|
-
this.context = {
|
|
705
|
-
service: this.service,
|
|
706
|
-
sink: options.sink,
|
|
707
|
-
sources: options.sources,
|
|
708
|
-
sourceForWebhookPath: options.sourceForWebhookPath
|
|
709
|
-
};
|
|
710
|
-
this.pollLoopSec = Math.max(1, options.pollLoopSec ?? 5);
|
|
711
|
-
}
|
|
712
|
-
pollLoopSec;
|
|
713
|
-
async start() {
|
|
714
|
-
await this.service.dedupe();
|
|
715
|
-
if (this.timer) return;
|
|
716
|
-
this.timer = setInterval(() => {
|
|
717
|
-
const tick2 = this.tick().catch((error) => console.error("[sourcefed] monitor tick error:", error));
|
|
718
|
-
this.activeTicks.add(tick2);
|
|
719
|
-
void tick2.finally(() => this.activeTicks.delete(tick2));
|
|
720
|
-
}, this.pollLoopSec * 1e3);
|
|
721
|
-
const initial = this.tick().catch((error) => console.error("[sourcefed] monitor tick error:", error));
|
|
722
|
-
this.activeTicks.add(initial);
|
|
723
|
-
void initial.finally(() => this.activeTicks.delete(initial));
|
|
724
|
-
}
|
|
725
|
-
async tick() {
|
|
726
|
-
await tick(this.context);
|
|
727
|
-
}
|
|
728
|
-
async webhook(request) {
|
|
729
|
-
return handleWebhook(request, this.context);
|
|
730
|
-
}
|
|
731
|
-
async stop() {
|
|
732
|
-
if (this.timer) {
|
|
733
|
-
clearInterval(this.timer);
|
|
734
|
-
this.timer = void 0;
|
|
735
|
-
}
|
|
736
|
-
const ticks = [...this.activeTicks];
|
|
737
|
-
if (ticks.length === 0) return true;
|
|
738
|
-
let timer;
|
|
739
|
-
const settled = await Promise.race([
|
|
740
|
-
Promise.allSettled(ticks).then(() => true),
|
|
741
|
-
new Promise((resolve) => {
|
|
742
|
-
timer = setTimeout(() => {
|
|
743
|
-
console.warn("[sourcefed] stop waited 30s for in-flight monitor ticks; retaining state lock");
|
|
744
|
-
resolve(false);
|
|
745
|
-
}, 3e4);
|
|
746
|
-
})
|
|
747
|
-
]);
|
|
748
|
-
if (timer) clearTimeout(timer);
|
|
749
|
-
return settled;
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
function createQueuedMonitorEvent(monitor, event) {
|
|
753
|
-
return {
|
|
754
|
-
id: `${monitor.id}:${monitorEventID(event)}`,
|
|
755
|
-
monitorID: monitor.id,
|
|
756
|
-
target: monitor.target,
|
|
757
|
-
event,
|
|
758
|
-
queuedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
function monitorEventID(event) {
|
|
762
|
-
if (event.id) return event.id;
|
|
763
|
-
return `${event.kind}:${event.at}:${event.summary}`;
|
|
764
|
-
}
|
|
765
|
-
var MonitorSourceSchema = /* @__PURE__ */ intersect([
|
|
766
|
-
/* @__PURE__ */ object({ type: /* @__PURE__ */ string() }),
|
|
767
|
-
/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ unknown())
|
|
768
|
-
]);
|
|
769
|
-
var MonitorRecordSchema = /* @__PURE__ */ object({
|
|
770
|
-
id: /* @__PURE__ */ string(),
|
|
771
|
-
name: /* @__PURE__ */ string(),
|
|
772
|
-
source: MonitorSourceSchema,
|
|
773
|
-
delivery: /* @__PURE__ */ picklist(["poll", "webhook"]),
|
|
774
|
-
target: /* @__PURE__ */ object({
|
|
775
|
-
kind: /* @__PURE__ */ string(),
|
|
776
|
-
id: /* @__PURE__ */ string()
|
|
777
|
-
}),
|
|
778
|
-
pollIntervalSec: /* @__PURE__ */ number(),
|
|
779
|
-
enabled: /* @__PURE__ */ boolean(),
|
|
780
|
-
createdAt: /* @__PURE__ */ string(),
|
|
781
|
-
updatedAt: /* @__PURE__ */ string(),
|
|
782
|
-
cursors: /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ unknown())
|
|
783
|
-
});
|
|
784
|
-
var MonitorRegistrySchema = /* @__PURE__ */ object({
|
|
785
|
-
monitors: /* @__PURE__ */ array(MonitorRecordSchema)
|
|
786
|
-
});
|
|
787
|
-
var JsonMonitorStore = class {
|
|
788
|
-
stateDir;
|
|
789
|
-
stateFile;
|
|
790
|
-
constructor(options = {}) {
|
|
791
|
-
this.stateDir = options.stateDir ?? process.env.SOURCEFED_STATE_DIR ?? path.join(process.env.XDG_STATE_HOME ?? path.join(os.homedir(), ".local", "state"), "sourcefed");
|
|
792
|
-
this.stateFile = path.join(this.stateDir, "monitors.json");
|
|
793
|
-
}
|
|
794
|
-
async load() {
|
|
795
|
-
const raw = await this.readRaw(this.stateFile);
|
|
796
|
-
if (raw === void 0) return { monitors: [] };
|
|
797
|
-
const parsed = parseRegistry(raw);
|
|
798
|
-
if (!parsed) throw new Error(`invalid monitor state at ${this.stateFile}; refusing to overwrite`);
|
|
799
|
-
return parsed;
|
|
800
|
-
}
|
|
801
|
-
async acquireExclusive() {
|
|
802
|
-
const lockPath = path.join(this.stateDir, ".monitors.lock");
|
|
803
|
-
await mkdir(this.stateDir, { recursive: true });
|
|
804
|
-
const pid = String(process.pid);
|
|
805
|
-
for (let attempt = 0; attempt < 5; attempt++) {
|
|
806
|
-
try {
|
|
807
|
-
const handle2 = await open(lockPath, "wx");
|
|
808
|
-
await handle2.writeFile(pid);
|
|
809
|
-
let released = false;
|
|
810
|
-
return async () => {
|
|
811
|
-
if (released) return;
|
|
812
|
-
released = true;
|
|
813
|
-
await handle2.close();
|
|
814
|
-
const current = await readLockPid(lockPath);
|
|
815
|
-
if (current === process.pid) await rm(lockPath, { force: true });
|
|
816
|
-
};
|
|
817
|
-
} catch (error) {
|
|
818
|
-
const code = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
819
|
-
if (code !== "EEXIST") throw error;
|
|
820
|
-
const holder = await readLockPid(lockPath);
|
|
821
|
-
if (holder === void 0 || processAlive(holder)) {
|
|
822
|
-
throw new Error(`another sourcefed daemon (pid ${holder ?? "unknown"}) is using ${this.stateDir}; stop it or set SOURCEFED_STATE_DIR`);
|
|
823
|
-
}
|
|
824
|
-
const contender = `${lockPath}.${process.pid}.${Date.now().toString(36)}`;
|
|
825
|
-
try {
|
|
826
|
-
await rename(lockPath, contender);
|
|
827
|
-
} catch {
|
|
828
|
-
continue;
|
|
829
|
-
}
|
|
830
|
-
await writeFile(contender, pid);
|
|
831
|
-
try {
|
|
832
|
-
await link(contender, lockPath);
|
|
833
|
-
} catch {
|
|
834
|
-
await rm(contender, { force: true });
|
|
835
|
-
continue;
|
|
836
|
-
}
|
|
837
|
-
await rm(contender, { force: true });
|
|
838
|
-
let released = false;
|
|
839
|
-
return async () => {
|
|
840
|
-
if (released) return;
|
|
841
|
-
released = true;
|
|
842
|
-
const current = await readLockPid(lockPath);
|
|
843
|
-
if (current === process.pid) await rm(lockPath, { force: true });
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
throw new Error(`could not acquire the sourcefed state lock at ${lockPath}`);
|
|
848
|
-
}
|
|
849
|
-
async save(registry) {
|
|
850
|
-
await mkdir(this.stateDir, { recursive: true, mode: 448 });
|
|
851
|
-
const temporary = `${this.stateFile}.${process.pid}.tmp`;
|
|
852
|
-
await writeFile(temporary, `${JSON.stringify(registry, null, 2)}
|
|
853
|
-
`, { mode: 384 });
|
|
854
|
-
await rename(temporary, this.stateFile);
|
|
855
|
-
}
|
|
856
|
-
async readRaw(filePath) {
|
|
857
|
-
try {
|
|
858
|
-
const contents = await readFile(filePath, "utf8");
|
|
859
|
-
return JSON.parse(contents);
|
|
860
|
-
} catch (error) {
|
|
861
|
-
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return void 0;
|
|
862
|
-
throw error;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
};
|
|
866
|
-
async function readLockPid(lockPath) {
|
|
867
|
-
try {
|
|
868
|
-
const contents = await readFile(lockPath, "utf8");
|
|
869
|
-
const pid = Number(contents.trim());
|
|
870
|
-
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
871
|
-
} catch {
|
|
872
|
-
return void 0;
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
function processAlive(pid) {
|
|
876
|
-
try {
|
|
877
|
-
process.kill(pid, 0);
|
|
878
|
-
return true;
|
|
879
|
-
} catch (error) {
|
|
880
|
-
return Boolean(error && typeof error === "object" && "code" in error && error.code === "EPERM");
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
function parseRegistry(value) {
|
|
884
|
-
const result = /* @__PURE__ */ safeParse(MonitorRegistrySchema, value);
|
|
885
|
-
return result.success ? result.output : void 0;
|
|
886
|
-
}
|
|
887
|
-
var JsonMonitorEventQueue = class {
|
|
888
|
-
constructor(stateDir) {
|
|
889
|
-
this.stateDir = stateDir;
|
|
890
|
-
this.eventsFile = path.join(stateDir, "events.json");
|
|
891
|
-
}
|
|
892
|
-
eventsFile;
|
|
893
|
-
queue = Promise.resolve();
|
|
894
|
-
async enqueue(input) {
|
|
895
|
-
return this.transact((events) => {
|
|
896
|
-
const queued = createQueuedMonitorEvent(input.monitor, input.event);
|
|
897
|
-
const existing = events.find((event) => event.id === queued.id);
|
|
898
|
-
if (existing) return existing;
|
|
899
|
-
events.push(queued);
|
|
900
|
-
return queued;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
async read(target) {
|
|
904
|
-
const events = await this.loadEvents();
|
|
905
|
-
return events.filter((event) => sameTarget2(event.target, target));
|
|
906
|
-
}
|
|
907
|
-
async acknowledge(target, eventIDs) {
|
|
908
|
-
await this.transact((events) => {
|
|
909
|
-
const ids = new Set(eventIDs);
|
|
910
|
-
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
911
|
-
if (sameTarget2(events[index].target, target) && ids.has(events[index].id)) events.splice(index, 1);
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
async transact(operation) {
|
|
916
|
-
const next = this.queue.then(async () => {
|
|
917
|
-
const events = await this.loadEvents();
|
|
918
|
-
const result = await operation(events);
|
|
919
|
-
await this.saveEvents(events);
|
|
920
|
-
return result;
|
|
921
|
-
});
|
|
922
|
-
this.queue = next.then(() => void 0, () => void 0);
|
|
923
|
-
return next;
|
|
924
|
-
}
|
|
925
|
-
async loadEvents() {
|
|
926
|
-
try {
|
|
927
|
-
const contents = await readFile(this.eventsFile, "utf8");
|
|
928
|
-
const parsed = JSON.parse(contents);
|
|
929
|
-
if (!Array.isArray(parsed)) throw new Error(`invalid event queue at ${this.eventsFile}`);
|
|
930
|
-
return parsed;
|
|
931
|
-
} catch (error) {
|
|
932
|
-
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") return [];
|
|
933
|
-
throw error;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
async saveEvents(events) {
|
|
937
|
-
await mkdir(this.stateDir, { recursive: true, mode: 448 });
|
|
938
|
-
const temporary = `${this.eventsFile}.${process.pid}.tmp`;
|
|
939
|
-
await writeFile(temporary, `${JSON.stringify(events, null, 2)}
|
|
940
|
-
`, { mode: 384 });
|
|
941
|
-
await rename(temporary, this.eventsFile);
|
|
942
|
-
}
|
|
943
|
-
};
|
|
944
|
-
function sameTarget2(left, right) {
|
|
945
|
-
return left.kind === right.kind && left.id === right.id;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
8
|
// providers/github/dist/index.js
|
|
949
|
-
import { link
|
|
950
|
-
import
|
|
951
|
-
import
|
|
9
|
+
import { link, mkdir, open, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
10
|
+
import os from "node:os";
|
|
11
|
+
import path from "node:path";
|
|
952
12
|
import { inflateRawSync } from "node:zlib";
|
|
953
13
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
954
14
|
var __create = Object.create;
|
|
@@ -7845,50 +6905,50 @@ var require_dist2 = __commonJS({
|
|
|
7845
6905
|
} });
|
|
7846
6906
|
}
|
|
7847
6907
|
});
|
|
7848
|
-
var store$
|
|
7849
|
-
var
|
|
6908
|
+
var store$4;
|
|
6909
|
+
var DEFAULT_CONFIG = {
|
|
7850
6910
|
lang: void 0,
|
|
7851
6911
|
message: void 0,
|
|
7852
6912
|
abortEarly: void 0,
|
|
7853
6913
|
abortPipeEarly: void 0
|
|
7854
6914
|
};
|
|
7855
6915
|
// @__NO_SIDE_EFFECTS__
|
|
7856
|
-
function
|
|
7857
|
-
if (!config$1 && !store$
|
|
6916
|
+
function getGlobalConfig(config$1) {
|
|
6917
|
+
if (!config$1 && !store$4) return DEFAULT_CONFIG;
|
|
7858
6918
|
return {
|
|
7859
|
-
lang: config$1?.lang ?? store$
|
|
6919
|
+
lang: config$1?.lang ?? store$4?.lang,
|
|
7860
6920
|
message: config$1?.message,
|
|
7861
|
-
abortEarly: config$1?.abortEarly ?? store$
|
|
7862
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$
|
|
6921
|
+
abortEarly: config$1?.abortEarly ?? store$4?.abortEarly,
|
|
6922
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$4?.abortPipeEarly
|
|
7863
6923
|
};
|
|
7864
6924
|
}
|
|
7865
|
-
var store$
|
|
6925
|
+
var store$3;
|
|
7866
6926
|
// @__NO_SIDE_EFFECTS__
|
|
7867
|
-
function
|
|
7868
|
-
return store$
|
|
6927
|
+
function getGlobalMessage(lang) {
|
|
6928
|
+
return store$3?.get(lang);
|
|
7869
6929
|
}
|
|
7870
|
-
var store$
|
|
6930
|
+
var store$2;
|
|
7871
6931
|
// @__NO_SIDE_EFFECTS__
|
|
7872
|
-
function
|
|
7873
|
-
return store$
|
|
6932
|
+
function getSchemaMessage(lang) {
|
|
6933
|
+
return store$2?.get(lang);
|
|
7874
6934
|
}
|
|
7875
|
-
var store$
|
|
6935
|
+
var store$1;
|
|
7876
6936
|
// @__NO_SIDE_EFFECTS__
|
|
7877
|
-
function
|
|
7878
|
-
return store$
|
|
6937
|
+
function getSpecificMessage(reference, lang) {
|
|
6938
|
+
return store$1?.get(reference)?.get(lang);
|
|
7879
6939
|
}
|
|
7880
6940
|
// @__NO_SIDE_EFFECTS__
|
|
7881
|
-
function
|
|
6941
|
+
function _stringify(input) {
|
|
7882
6942
|
const type = typeof input;
|
|
7883
6943
|
if (type === "string") return `"${input}"`;
|
|
7884
6944
|
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
7885
6945
|
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
7886
6946
|
return type;
|
|
7887
6947
|
}
|
|
7888
|
-
function
|
|
6948
|
+
function _addIssue(context, label, dataset, config$1, other) {
|
|
7889
6949
|
const input = other && "input" in other ? other.input : dataset.value;
|
|
7890
6950
|
const expected = other?.expected ?? context.expects ?? null;
|
|
7891
|
-
const received = other?.received ?? /* @__PURE__ */
|
|
6951
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
|
|
7892
6952
|
const issue = {
|
|
7893
6953
|
kind: context.kind,
|
|
7894
6954
|
type: context.type,
|
|
@@ -7904,49 +6964,49 @@ function _addIssue2(context, label, dataset, config$1, other) {
|
|
|
7904
6964
|
abortPipeEarly: config$1.abortPipeEarly
|
|
7905
6965
|
};
|
|
7906
6966
|
const isSchema = context.kind === "schema";
|
|
7907
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */
|
|
6967
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
|
|
7908
6968
|
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
7909
6969
|
if (isSchema) dataset.typed = false;
|
|
7910
6970
|
if (dataset.issues) dataset.issues.push(issue);
|
|
7911
6971
|
else dataset.issues = [issue];
|
|
7912
6972
|
}
|
|
7913
|
-
var
|
|
6973
|
+
var _standardCache = /* @__PURE__ */ new WeakMap();
|
|
7914
6974
|
// @__NO_SIDE_EFFECTS__
|
|
7915
|
-
function
|
|
7916
|
-
let cached =
|
|
6975
|
+
function _getStandardProps(context) {
|
|
6976
|
+
let cached = _standardCache.get(context);
|
|
7917
6977
|
if (!cached) {
|
|
7918
6978
|
cached = {
|
|
7919
6979
|
version: 1,
|
|
7920
6980
|
vendor: "valibot",
|
|
7921
6981
|
validate(value$1) {
|
|
7922
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */
|
|
6982
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
|
|
7923
6983
|
}
|
|
7924
6984
|
};
|
|
7925
|
-
|
|
6985
|
+
_standardCache.set(context, cached);
|
|
7926
6986
|
}
|
|
7927
6987
|
return cached;
|
|
7928
6988
|
}
|
|
7929
|
-
var
|
|
6989
|
+
var EMOJI_REGEX = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
7930
6990
|
// @__NO_SIDE_EFFECTS__
|
|
7931
|
-
function
|
|
6991
|
+
function getFallback(schema, dataset, config$1) {
|
|
7932
6992
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
7933
6993
|
}
|
|
7934
6994
|
// @__NO_SIDE_EFFECTS__
|
|
7935
|
-
function
|
|
6995
|
+
function getDefault(schema, dataset, config$1) {
|
|
7936
6996
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
7937
6997
|
}
|
|
7938
6998
|
// @__NO_SIDE_EFFECTS__
|
|
7939
|
-
function
|
|
6999
|
+
function array(item, message$1) {
|
|
7940
7000
|
return {
|
|
7941
7001
|
kind: "schema",
|
|
7942
7002
|
type: "array",
|
|
7943
|
-
reference:
|
|
7003
|
+
reference: array,
|
|
7944
7004
|
expects: "Array",
|
|
7945
7005
|
async: false,
|
|
7946
7006
|
item,
|
|
7947
7007
|
message: message$1,
|
|
7948
7008
|
get "~standard"() {
|
|
7949
|
-
return /* @__PURE__ */
|
|
7009
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
7950
7010
|
},
|
|
7951
7011
|
"~run"(dataset, config$1) {
|
|
7952
7012
|
const input = dataset.value;
|
|
@@ -7978,42 +7038,42 @@ function array2(item, message$1) {
|
|
|
7978
7038
|
if (!itemDataset.typed) dataset.typed = false;
|
|
7979
7039
|
dataset.value.push(itemDataset.value);
|
|
7980
7040
|
}
|
|
7981
|
-
} else
|
|
7041
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
7982
7042
|
return dataset;
|
|
7983
7043
|
}
|
|
7984
7044
|
};
|
|
7985
7045
|
}
|
|
7986
7046
|
// @__NO_SIDE_EFFECTS__
|
|
7987
|
-
function
|
|
7047
|
+
function boolean(message$1) {
|
|
7988
7048
|
return {
|
|
7989
7049
|
kind: "schema",
|
|
7990
7050
|
type: "boolean",
|
|
7991
|
-
reference:
|
|
7051
|
+
reference: boolean,
|
|
7992
7052
|
expects: "boolean",
|
|
7993
7053
|
async: false,
|
|
7994
7054
|
message: message$1,
|
|
7995
7055
|
get "~standard"() {
|
|
7996
|
-
return /* @__PURE__ */
|
|
7056
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
7997
7057
|
},
|
|
7998
7058
|
"~run"(dataset, config$1) {
|
|
7999
7059
|
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
8000
|
-
else
|
|
7060
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
8001
7061
|
return dataset;
|
|
8002
7062
|
}
|
|
8003
7063
|
};
|
|
8004
7064
|
}
|
|
8005
7065
|
// @__NO_SIDE_EFFECTS__
|
|
8006
|
-
function
|
|
7066
|
+
function object(entries$1, message$1) {
|
|
8007
7067
|
return {
|
|
8008
7068
|
kind: "schema",
|
|
8009
7069
|
type: "object",
|
|
8010
|
-
reference:
|
|
7070
|
+
reference: object,
|
|
8011
7071
|
expects: "Object",
|
|
8012
7072
|
async: false,
|
|
8013
7073
|
entries: entries$1,
|
|
8014
7074
|
message: message$1,
|
|
8015
7075
|
get "~standard"() {
|
|
8016
|
-
return /* @__PURE__ */
|
|
7076
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
8017
7077
|
},
|
|
8018
7078
|
"~run"(dataset, config$1) {
|
|
8019
7079
|
const input = dataset.value;
|
|
@@ -8023,7 +7083,7 @@ function object2(entries$1, message$1) {
|
|
|
8023
7083
|
for (const key in this.entries) {
|
|
8024
7084
|
const valueSchema = this.entries[key];
|
|
8025
7085
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
8026
|
-
const value$1 = key in input ? input[key] : /* @__PURE__ */
|
|
7086
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
|
|
8027
7087
|
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
8028
7088
|
if (valueDataset.issues) {
|
|
8029
7089
|
const pathItem = {
|
|
@@ -8046,9 +7106,9 @@ function object2(entries$1, message$1) {
|
|
|
8046
7106
|
}
|
|
8047
7107
|
if (!valueDataset.typed) dataset.typed = false;
|
|
8048
7108
|
dataset.value[key] = valueDataset.value;
|
|
8049
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */
|
|
7109
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
|
|
8050
7110
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
8051
|
-
|
|
7111
|
+
_addIssue(this, "key", dataset, config$1, {
|
|
8052
7112
|
input: void 0,
|
|
8053
7113
|
expected: `"${key}"`,
|
|
8054
7114
|
path: [{
|
|
@@ -8062,7 +7122,7 @@ function object2(entries$1, message$1) {
|
|
|
8062
7122
|
if (config$1.abortEarly) break;
|
|
8063
7123
|
}
|
|
8064
7124
|
}
|
|
8065
|
-
} else
|
|
7125
|
+
} else _addIssue(this, "type", dataset, config$1);
|
|
8066
7126
|
return dataset;
|
|
8067
7127
|
}
|
|
8068
7128
|
};
|
|
@@ -8078,11 +7138,11 @@ function optional(wrapped, default_) {
|
|
|
8078
7138
|
wrapped,
|
|
8079
7139
|
default: default_,
|
|
8080
7140
|
get "~standard"() {
|
|
8081
|
-
return /* @__PURE__ */
|
|
7141
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
8082
7142
|
},
|
|
8083
7143
|
"~run"(dataset, config$1) {
|
|
8084
7144
|
if (dataset.value === void 0) {
|
|
8085
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */
|
|
7145
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
|
|
8086
7146
|
if (dataset.value === void 0) {
|
|
8087
7147
|
dataset.typed = true;
|
|
8088
7148
|
return dataset;
|
|
@@ -8093,34 +7153,34 @@ function optional(wrapped, default_) {
|
|
|
8093
7153
|
};
|
|
8094
7154
|
}
|
|
8095
7155
|
// @__NO_SIDE_EFFECTS__
|
|
8096
|
-
function
|
|
7156
|
+
function string(message$1) {
|
|
8097
7157
|
return {
|
|
8098
7158
|
kind: "schema",
|
|
8099
7159
|
type: "string",
|
|
8100
|
-
reference:
|
|
7160
|
+
reference: string,
|
|
8101
7161
|
expects: "string",
|
|
8102
7162
|
async: false,
|
|
8103
7163
|
message: message$1,
|
|
8104
7164
|
get "~standard"() {
|
|
8105
|
-
return /* @__PURE__ */
|
|
7165
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
8106
7166
|
},
|
|
8107
7167
|
"~run"(dataset, config$1) {
|
|
8108
7168
|
if (typeof dataset.value === "string") dataset.typed = true;
|
|
8109
|
-
else
|
|
7169
|
+
else _addIssue(this, "type", dataset, config$1);
|
|
8110
7170
|
return dataset;
|
|
8111
7171
|
}
|
|
8112
7172
|
};
|
|
8113
7173
|
}
|
|
8114
7174
|
// @__NO_SIDE_EFFECTS__
|
|
8115
|
-
function
|
|
7175
|
+
function unknown() {
|
|
8116
7176
|
return {
|
|
8117
7177
|
kind: "schema",
|
|
8118
7178
|
type: "unknown",
|
|
8119
|
-
reference:
|
|
7179
|
+
reference: unknown,
|
|
8120
7180
|
expects: "unknown",
|
|
8121
7181
|
async: false,
|
|
8122
7182
|
get "~standard"() {
|
|
8123
|
-
return /* @__PURE__ */
|
|
7183
|
+
return /* @__PURE__ */ _getStandardProps(this);
|
|
8124
7184
|
},
|
|
8125
7185
|
"~run"(dataset) {
|
|
8126
7186
|
dataset.typed = true;
|
|
@@ -8129,8 +7189,8 @@ function unknown2() {
|
|
|
8129
7189
|
};
|
|
8130
7190
|
}
|
|
8131
7191
|
// @__NO_SIDE_EFFECTS__
|
|
8132
|
-
function
|
|
8133
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */
|
|
7192
|
+
function safeParse(schema, input, config$1) {
|
|
7193
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
|
|
8134
7194
|
return {
|
|
8135
7195
|
typed: dataset.typed,
|
|
8136
7196
|
success: !dataset.issues,
|
|
@@ -8148,7 +7208,7 @@ var Monitor = class {
|
|
|
8148
7208
|
this.schema = options.schema;
|
|
8149
7209
|
}
|
|
8150
7210
|
validateSource(source) {
|
|
8151
|
-
const result = /* @__PURE__ */
|
|
7211
|
+
const result = /* @__PURE__ */ safeParse(this.schema, source);
|
|
8152
7212
|
if (result.success) return result.output;
|
|
8153
7213
|
throw new Error(`invalid ${this.type} monitor source`);
|
|
8154
7214
|
}
|
|
@@ -8205,7 +7265,7 @@ var Monitor = class {
|
|
|
8205
7265
|
return this.webhook.isUnresponsive(record2, now);
|
|
8206
7266
|
}
|
|
8207
7267
|
};
|
|
8208
|
-
var RoutedEventCursorSchema = /* @__PURE__ */
|
|
7268
|
+
var RoutedEventCursorSchema = /* @__PURE__ */ array(/* @__PURE__ */ string());
|
|
8209
7269
|
function eventDeliveryId(event) {
|
|
8210
7270
|
if (event.id) return event.id;
|
|
8211
7271
|
return `${event.kind}:${event.at}:${event.summary}`;
|
|
@@ -8226,7 +7286,7 @@ var PollMonitor = class {
|
|
|
8226
7286
|
const result = await this.options.run(sourceRecord, fresh.cursors[cursorKey]);
|
|
8227
7287
|
const current = await context.service.get(record2.id);
|
|
8228
7288
|
if (!current || !current.enabled) return 0;
|
|
8229
|
-
const parsedRoutedIds = /* @__PURE__ */
|
|
7289
|
+
const parsedRoutedIds = /* @__PURE__ */ safeParse(RoutedEventCursorSchema, fresh.cursors.__routedEventIds);
|
|
8230
7290
|
let routedIds = [];
|
|
8231
7291
|
if (parsedRoutedIds.success) routedIds = parsedRoutedIds.output;
|
|
8232
7292
|
let routeFailed = false;
|
|
@@ -8283,20 +7343,20 @@ function mergeCursors(current, result) {
|
|
|
8283
7343
|
}
|
|
8284
7344
|
var WEBHOOK_STALE_MS = 9e4;
|
|
8285
7345
|
var WEBHOOK_STARTUP_GRACE_MS = 12e4;
|
|
8286
|
-
var PendingWebhookEventSchema = /* @__PURE__ */
|
|
8287
|
-
deliveryId: /* @__PURE__ */
|
|
8288
|
-
event: /* @__PURE__ */
|
|
8289
|
-
source: /* @__PURE__ */
|
|
8290
|
-
kind: /* @__PURE__ */
|
|
8291
|
-
id: /* @__PURE__ */ optional(/* @__PURE__ */
|
|
8292
|
-
at: /* @__PURE__ */
|
|
8293
|
-
summary: /* @__PURE__ */
|
|
8294
|
-
body: /* @__PURE__ */ optional(/* @__PURE__ */
|
|
8295
|
-
actionable: /* @__PURE__ */
|
|
8296
|
-
terminal: /* @__PURE__ */ optional(/* @__PURE__ */
|
|
7346
|
+
var PendingWebhookEventSchema = /* @__PURE__ */ object({
|
|
7347
|
+
deliveryId: /* @__PURE__ */ string(),
|
|
7348
|
+
event: /* @__PURE__ */ object({
|
|
7349
|
+
source: /* @__PURE__ */ unknown(),
|
|
7350
|
+
kind: /* @__PURE__ */ string(),
|
|
7351
|
+
id: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
7352
|
+
at: /* @__PURE__ */ string(),
|
|
7353
|
+
summary: /* @__PURE__ */ string(),
|
|
7354
|
+
body: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
|
|
7355
|
+
actionable: /* @__PURE__ */ boolean(),
|
|
7356
|
+
terminal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
|
|
8297
7357
|
})
|
|
8298
7358
|
});
|
|
8299
|
-
var PendingWebhookEventsSchema = /* @__PURE__ */
|
|
7359
|
+
var PendingWebhookEventsSchema = /* @__PURE__ */ array(PendingWebhookEventSchema);
|
|
8300
7360
|
var pendingDeliveries = /* @__PURE__ */ new Set();
|
|
8301
7361
|
var PENDING_WEBHOOK_EVENTS = "__pendingWebhookEvents";
|
|
8302
7362
|
var WebhookMonitor = class {
|
|
@@ -8336,7 +7396,7 @@ var WebhookMonitor = class {
|
|
|
8336
7396
|
async retryPending(context, source, record2) {
|
|
8337
7397
|
const fresh = await context.service.get(record2.id);
|
|
8338
7398
|
if (!fresh || !fresh.enabled) return 0;
|
|
8339
|
-
const parsed = /* @__PURE__ */
|
|
7399
|
+
const parsed = /* @__PURE__ */ safeParse(PendingWebhookEventsSchema, fresh.cursors[PENDING_WEBHOOK_EVENTS]);
|
|
8340
7400
|
if (!parsed.success) return 0;
|
|
8341
7401
|
let delivered = 0;
|
|
8342
7402
|
for (const pending of parsed.output) {
|
|
@@ -8353,7 +7413,7 @@ var WebhookMonitor = class {
|
|
|
8353
7413
|
}
|
|
8354
7414
|
async addPending(context, monitor, deliveryId, event) {
|
|
8355
7415
|
await context.service.updateCursorValue(monitor, PENDING_WEBHOOK_EVENTS, (cursor) => {
|
|
8356
|
-
const parsed = /* @__PURE__ */
|
|
7416
|
+
const parsed = /* @__PURE__ */ safeParse(PendingWebhookEventsSchema, cursor);
|
|
8357
7417
|
let pending = [];
|
|
8358
7418
|
if (parsed.success) pending = parsed.output;
|
|
8359
7419
|
if (pending.some((entry) => entry.deliveryId === deliveryId)) return pending;
|
|
@@ -8363,7 +7423,7 @@ var WebhookMonitor = class {
|
|
|
8363
7423
|
}
|
|
8364
7424
|
async removePending(context, monitor, deliveryId) {
|
|
8365
7425
|
await context.service.updateCursorValue(monitor, PENDING_WEBHOOK_EVENTS, (cursor) => {
|
|
8366
|
-
const parsed = /* @__PURE__ */
|
|
7426
|
+
const parsed = /* @__PURE__ */ safeParse(PendingWebhookEventsSchema, cursor);
|
|
8367
7427
|
if (!parsed.success) return [];
|
|
8368
7428
|
return parsed.output.filter((entry) => entry.deliveryId !== deliveryId);
|
|
8369
7429
|
});
|
|
@@ -8404,7 +7464,7 @@ var WebhookMonitor = class {
|
|
|
8404
7464
|
}
|
|
8405
7465
|
}
|
|
8406
7466
|
};
|
|
8407
|
-
var
|
|
7467
|
+
var MAX_WEBHOOK_BODY_BYTES = 1024 * 1024;
|
|
8408
7468
|
function toMonitorEvent(event, source) {
|
|
8409
7469
|
return {
|
|
8410
7470
|
source,
|
|
@@ -8417,50 +7477,50 @@ function toMonitorEvent(event, source) {
|
|
|
8417
7477
|
terminal: event.terminal
|
|
8418
7478
|
};
|
|
8419
7479
|
}
|
|
8420
|
-
var store$
|
|
8421
|
-
var
|
|
7480
|
+
var store$42;
|
|
7481
|
+
var DEFAULT_CONFIG2 = {
|
|
8422
7482
|
lang: void 0,
|
|
8423
7483
|
message: void 0,
|
|
8424
7484
|
abortEarly: void 0,
|
|
8425
7485
|
abortPipeEarly: void 0
|
|
8426
7486
|
};
|
|
8427
7487
|
// @__NO_SIDE_EFFECTS__
|
|
8428
|
-
function
|
|
8429
|
-
if (!config$1 && !store$
|
|
7488
|
+
function getGlobalConfig2(config$1) {
|
|
7489
|
+
if (!config$1 && !store$42) return DEFAULT_CONFIG2;
|
|
8430
7490
|
return {
|
|
8431
|
-
lang: config$1?.lang ?? store$
|
|
7491
|
+
lang: config$1?.lang ?? store$42?.lang,
|
|
8432
7492
|
message: config$1?.message,
|
|
8433
|
-
abortEarly: config$1?.abortEarly ?? store$
|
|
8434
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$
|
|
7493
|
+
abortEarly: config$1?.abortEarly ?? store$42?.abortEarly,
|
|
7494
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$42?.abortPipeEarly
|
|
8435
7495
|
};
|
|
8436
7496
|
}
|
|
8437
|
-
var store$
|
|
7497
|
+
var store$32;
|
|
8438
7498
|
// @__NO_SIDE_EFFECTS__
|
|
8439
|
-
function
|
|
8440
|
-
return store$
|
|
7499
|
+
function getGlobalMessage2(lang) {
|
|
7500
|
+
return store$32?.get(lang);
|
|
8441
7501
|
}
|
|
8442
|
-
var store$
|
|
7502
|
+
var store$22;
|
|
8443
7503
|
// @__NO_SIDE_EFFECTS__
|
|
8444
|
-
function
|
|
8445
|
-
return store$
|
|
7504
|
+
function getSchemaMessage2(lang) {
|
|
7505
|
+
return store$22?.get(lang);
|
|
8446
7506
|
}
|
|
8447
|
-
var store$
|
|
7507
|
+
var store$12;
|
|
8448
7508
|
// @__NO_SIDE_EFFECTS__
|
|
8449
|
-
function
|
|
8450
|
-
return store$
|
|
7509
|
+
function getSpecificMessage2(reference, lang) {
|
|
7510
|
+
return store$12?.get(reference)?.get(lang);
|
|
8451
7511
|
}
|
|
8452
7512
|
// @__NO_SIDE_EFFECTS__
|
|
8453
|
-
function
|
|
7513
|
+
function _stringify2(input) {
|
|
8454
7514
|
const type = typeof input;
|
|
8455
7515
|
if (type === "string") return `"${input}"`;
|
|
8456
7516
|
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
8457
7517
|
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
8458
7518
|
return type;
|
|
8459
7519
|
}
|
|
8460
|
-
function
|
|
7520
|
+
function _addIssue2(context, label, dataset, config$1, other) {
|
|
8461
7521
|
const input = other && "input" in other ? other.input : dataset.value;
|
|
8462
7522
|
const expected = other?.expected ?? context.expects ?? null;
|
|
8463
|
-
const received = other?.received ?? /* @__PURE__ */
|
|
7523
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify2(input);
|
|
8464
7524
|
const issue = {
|
|
8465
7525
|
kind: context.kind,
|
|
8466
7526
|
type: context.type,
|
|
@@ -8476,49 +7536,49 @@ function _addIssue22(context, label, dataset, config$1, other) {
|
|
|
8476
7536
|
abortPipeEarly: config$1.abortPipeEarly
|
|
8477
7537
|
};
|
|
8478
7538
|
const isSchema = context.kind === "schema";
|
|
8479
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */
|
|
7539
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage2(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage2(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage2(issue.lang);
|
|
8480
7540
|
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
8481
7541
|
if (isSchema) dataset.typed = false;
|
|
8482
7542
|
if (dataset.issues) dataset.issues.push(issue);
|
|
8483
7543
|
else dataset.issues = [issue];
|
|
8484
7544
|
}
|
|
8485
|
-
var
|
|
8486
|
-
// @__NO_SIDE_EFFECTS__
|
|
8487
|
-
function
|
|
8488
|
-
let cached =
|
|
7545
|
+
var _standardCache2 = /* @__PURE__ */ new WeakMap();
|
|
7546
|
+
// @__NO_SIDE_EFFECTS__
|
|
7547
|
+
function _getStandardProps2(context) {
|
|
7548
|
+
let cached = _standardCache2.get(context);
|
|
8489
7549
|
if (!cached) {
|
|
8490
7550
|
cached = {
|
|
8491
7551
|
version: 1,
|
|
8492
7552
|
vendor: "valibot",
|
|
8493
7553
|
validate(value$1) {
|
|
8494
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */
|
|
7554
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig2());
|
|
8495
7555
|
}
|
|
8496
7556
|
};
|
|
8497
|
-
|
|
7557
|
+
_standardCache2.set(context, cached);
|
|
8498
7558
|
}
|
|
8499
7559
|
return cached;
|
|
8500
7560
|
}
|
|
8501
|
-
var
|
|
7561
|
+
var EMOJI_REGEX2 = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
8502
7562
|
// @__NO_SIDE_EFFECTS__
|
|
8503
|
-
function
|
|
7563
|
+
function getFallback2(schema, dataset, config$1) {
|
|
8504
7564
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
8505
7565
|
}
|
|
8506
7566
|
// @__NO_SIDE_EFFECTS__
|
|
8507
|
-
function
|
|
7567
|
+
function getDefault2(schema, dataset, config$1) {
|
|
8508
7568
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
8509
7569
|
}
|
|
8510
7570
|
// @__NO_SIDE_EFFECTS__
|
|
8511
|
-
function
|
|
7571
|
+
function array2(item, message$1) {
|
|
8512
7572
|
return {
|
|
8513
7573
|
kind: "schema",
|
|
8514
7574
|
type: "array",
|
|
8515
|
-
reference:
|
|
7575
|
+
reference: array2,
|
|
8516
7576
|
expects: "Array",
|
|
8517
7577
|
async: false,
|
|
8518
7578
|
item,
|
|
8519
7579
|
message: message$1,
|
|
8520
7580
|
get "~standard"() {
|
|
8521
|
-
return /* @__PURE__ */
|
|
7581
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8522
7582
|
},
|
|
8523
7583
|
"~run"(dataset, config$1) {
|
|
8524
7584
|
const input = dataset.value;
|
|
@@ -8550,26 +7610,26 @@ function array22(item, message$1) {
|
|
|
8550
7610
|
if (!itemDataset.typed) dataset.typed = false;
|
|
8551
7611
|
dataset.value.push(itemDataset.value);
|
|
8552
7612
|
}
|
|
8553
|
-
} else
|
|
7613
|
+
} else _addIssue2(this, "type", dataset, config$1);
|
|
8554
7614
|
return dataset;
|
|
8555
7615
|
}
|
|
8556
7616
|
};
|
|
8557
7617
|
}
|
|
8558
7618
|
// @__NO_SIDE_EFFECTS__
|
|
8559
|
-
function
|
|
7619
|
+
function boolean2(message$1) {
|
|
8560
7620
|
return {
|
|
8561
7621
|
kind: "schema",
|
|
8562
7622
|
type: "boolean",
|
|
8563
|
-
reference:
|
|
7623
|
+
reference: boolean2,
|
|
8564
7624
|
expects: "boolean",
|
|
8565
7625
|
async: false,
|
|
8566
7626
|
message: message$1,
|
|
8567
7627
|
get "~standard"() {
|
|
8568
|
-
return /* @__PURE__ */
|
|
7628
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8569
7629
|
},
|
|
8570
7630
|
"~run"(dataset, config$1) {
|
|
8571
7631
|
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
8572
|
-
else
|
|
7632
|
+
else _addIssue2(this, "type", dataset, config$1);
|
|
8573
7633
|
return dataset;
|
|
8574
7634
|
}
|
|
8575
7635
|
};
|
|
@@ -8580,51 +7640,51 @@ function literal(literal_, message$1) {
|
|
|
8580
7640
|
kind: "schema",
|
|
8581
7641
|
type: "literal",
|
|
8582
7642
|
reference: literal,
|
|
8583
|
-
expects: /* @__PURE__ */
|
|
7643
|
+
expects: /* @__PURE__ */ _stringify2(literal_),
|
|
8584
7644
|
async: false,
|
|
8585
7645
|
literal: literal_,
|
|
8586
7646
|
message: message$1,
|
|
8587
7647
|
get "~standard"() {
|
|
8588
|
-
return /* @__PURE__ */
|
|
7648
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8589
7649
|
},
|
|
8590
7650
|
"~run"(dataset, config$1) {
|
|
8591
7651
|
if (dataset.value === this.literal) dataset.typed = true;
|
|
8592
|
-
else
|
|
7652
|
+
else _addIssue2(this, "type", dataset, config$1);
|
|
8593
7653
|
return dataset;
|
|
8594
7654
|
}
|
|
8595
7655
|
};
|
|
8596
7656
|
}
|
|
8597
7657
|
// @__NO_SIDE_EFFECTS__
|
|
8598
|
-
function
|
|
7658
|
+
function number(message$1) {
|
|
8599
7659
|
return {
|
|
8600
7660
|
kind: "schema",
|
|
8601
7661
|
type: "number",
|
|
8602
|
-
reference:
|
|
7662
|
+
reference: number,
|
|
8603
7663
|
expects: "number",
|
|
8604
7664
|
async: false,
|
|
8605
7665
|
message: message$1,
|
|
8606
7666
|
get "~standard"() {
|
|
8607
|
-
return /* @__PURE__ */
|
|
7667
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8608
7668
|
},
|
|
8609
7669
|
"~run"(dataset, config$1) {
|
|
8610
7670
|
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
8611
|
-
else
|
|
7671
|
+
else _addIssue2(this, "type", dataset, config$1);
|
|
8612
7672
|
return dataset;
|
|
8613
7673
|
}
|
|
8614
7674
|
};
|
|
8615
7675
|
}
|
|
8616
7676
|
// @__NO_SIDE_EFFECTS__
|
|
8617
|
-
function
|
|
7677
|
+
function object2(entries$1, message$1) {
|
|
8618
7678
|
return {
|
|
8619
7679
|
kind: "schema",
|
|
8620
7680
|
type: "object",
|
|
8621
|
-
reference:
|
|
7681
|
+
reference: object2,
|
|
8622
7682
|
expects: "Object",
|
|
8623
7683
|
async: false,
|
|
8624
7684
|
entries: entries$1,
|
|
8625
7685
|
message: message$1,
|
|
8626
7686
|
get "~standard"() {
|
|
8627
|
-
return /* @__PURE__ */
|
|
7687
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8628
7688
|
},
|
|
8629
7689
|
"~run"(dataset, config$1) {
|
|
8630
7690
|
const input = dataset.value;
|
|
@@ -8634,7 +7694,7 @@ function object22(entries$1, message$1) {
|
|
|
8634
7694
|
for (const key in this.entries) {
|
|
8635
7695
|
const valueSchema = this.entries[key];
|
|
8636
7696
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
8637
|
-
const value$1 = key in input ? input[key] : /* @__PURE__ */
|
|
7697
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault2(valueSchema);
|
|
8638
7698
|
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
8639
7699
|
if (valueDataset.issues) {
|
|
8640
7700
|
const pathItem = {
|
|
@@ -8657,9 +7717,9 @@ function object22(entries$1, message$1) {
|
|
|
8657
7717
|
}
|
|
8658
7718
|
if (!valueDataset.typed) dataset.typed = false;
|
|
8659
7719
|
dataset.value[key] = valueDataset.value;
|
|
8660
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */
|
|
7720
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback2(valueSchema);
|
|
8661
7721
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
8662
|
-
|
|
7722
|
+
_addIssue2(this, "key", dataset, config$1, {
|
|
8663
7723
|
input: void 0,
|
|
8664
7724
|
expected: `"${key}"`,
|
|
8665
7725
|
path: [{
|
|
@@ -8673,7 +7733,7 @@ function object22(entries$1, message$1) {
|
|
|
8673
7733
|
if (config$1.abortEarly) break;
|
|
8674
7734
|
}
|
|
8675
7735
|
}
|
|
8676
|
-
} else
|
|
7736
|
+
} else _addIssue2(this, "type", dataset, config$1);
|
|
8677
7737
|
return dataset;
|
|
8678
7738
|
}
|
|
8679
7739
|
};
|
|
@@ -8689,11 +7749,11 @@ function optional2(wrapped, default_) {
|
|
|
8689
7749
|
wrapped,
|
|
8690
7750
|
default: default_,
|
|
8691
7751
|
get "~standard"() {
|
|
8692
|
-
return /* @__PURE__ */
|
|
7752
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8693
7753
|
},
|
|
8694
7754
|
"~run"(dataset, config$1) {
|
|
8695
7755
|
if (dataset.value === void 0) {
|
|
8696
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */
|
|
7756
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault2(this, dataset, config$1);
|
|
8697
7757
|
if (dataset.value === void 0) {
|
|
8698
7758
|
dataset.typed = true;
|
|
8699
7759
|
return dataset;
|
|
@@ -8704,27 +7764,27 @@ function optional2(wrapped, default_) {
|
|
|
8704
7764
|
};
|
|
8705
7765
|
}
|
|
8706
7766
|
// @__NO_SIDE_EFFECTS__
|
|
8707
|
-
function
|
|
7767
|
+
function string2(message$1) {
|
|
8708
7768
|
return {
|
|
8709
7769
|
kind: "schema",
|
|
8710
7770
|
type: "string",
|
|
8711
|
-
reference:
|
|
7771
|
+
reference: string2,
|
|
8712
7772
|
expects: "string",
|
|
8713
7773
|
async: false,
|
|
8714
7774
|
message: message$1,
|
|
8715
7775
|
get "~standard"() {
|
|
8716
|
-
return /* @__PURE__ */
|
|
7776
|
+
return /* @__PURE__ */ _getStandardProps2(this);
|
|
8717
7777
|
},
|
|
8718
7778
|
"~run"(dataset, config$1) {
|
|
8719
7779
|
if (typeof dataset.value === "string") dataset.typed = true;
|
|
8720
|
-
else
|
|
7780
|
+
else _addIssue2(this, "type", dataset, config$1);
|
|
8721
7781
|
return dataset;
|
|
8722
7782
|
}
|
|
8723
7783
|
};
|
|
8724
7784
|
}
|
|
8725
7785
|
// @__NO_SIDE_EFFECTS__
|
|
8726
|
-
function
|
|
8727
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */
|
|
7786
|
+
function safeParse2(schema, input, config$1) {
|
|
7787
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig2(config$1));
|
|
8728
7788
|
return {
|
|
8729
7789
|
typed: dataset.typed,
|
|
8730
7790
|
success: !dataset.issues,
|
|
@@ -8732,21 +7792,21 @@ function safeParse22(schema, input, config$1) {
|
|
|
8732
7792
|
issues: dataset.issues
|
|
8733
7793
|
};
|
|
8734
7794
|
}
|
|
8735
|
-
var GithubSourceSchema = /* @__PURE__ */
|
|
7795
|
+
var GithubSourceSchema = /* @__PURE__ */ object2({
|
|
8736
7796
|
type: /* @__PURE__ */ literal("github"),
|
|
8737
|
-
repo: /* @__PURE__ */
|
|
8738
|
-
prNumber: /* @__PURE__ */
|
|
7797
|
+
repo: /* @__PURE__ */ string2(),
|
|
7798
|
+
prNumber: /* @__PURE__ */ number()
|
|
8739
7799
|
});
|
|
8740
|
-
var GithubCursorSchema = /* @__PURE__ */
|
|
8741
|
-
reviewIds: /* @__PURE__ */
|
|
8742
|
-
commentIds: /* @__PURE__ */
|
|
8743
|
-
historyPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */
|
|
8744
|
-
lineCommentsPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */
|
|
8745
|
-
conversationCommentsPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */
|
|
8746
|
-
ciState: /* @__PURE__ */
|
|
8747
|
-
ciFailureState: /* @__PURE__ */ optional2(/* @__PURE__ */
|
|
8748
|
-
mergeable: /* @__PURE__ */
|
|
8749
|
-
prState: /* @__PURE__ */
|
|
7800
|
+
var GithubCursorSchema = /* @__PURE__ */ object2({
|
|
7801
|
+
reviewIds: /* @__PURE__ */ array2(/* @__PURE__ */ string2()),
|
|
7802
|
+
commentIds: /* @__PURE__ */ array2(/* @__PURE__ */ string2()),
|
|
7803
|
+
historyPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */ boolean2(), false),
|
|
7804
|
+
lineCommentsPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */ boolean2(), false),
|
|
7805
|
+
conversationCommentsPrimed: /* @__PURE__ */ optional2(/* @__PURE__ */ boolean2(), false),
|
|
7806
|
+
ciState: /* @__PURE__ */ string2(),
|
|
7807
|
+
ciFailureState: /* @__PURE__ */ optional2(/* @__PURE__ */ string2(), ""),
|
|
7808
|
+
mergeable: /* @__PURE__ */ string2(),
|
|
7809
|
+
prState: /* @__PURE__ */ string2()
|
|
8750
7810
|
});
|
|
8751
7811
|
var import_node_html_markdown = __toESM(require_dist2(), 1);
|
|
8752
7812
|
var HTML_TAG = /<(\/?)([a-z][a-z0-9]*)\b[^>]*>/i;
|
|
@@ -9154,7 +8214,7 @@ function emptyGithubCursor() {
|
|
|
9154
8214
|
}
|
|
9155
8215
|
var warnedMissingToken = false;
|
|
9156
8216
|
async function pollGithub(repo, prNumber, cursorRaw) {
|
|
9157
|
-
const parsedCursor = /* @__PURE__ */
|
|
8217
|
+
const parsedCursor = /* @__PURE__ */ safeParse2(GithubCursorSchema, cursorRaw);
|
|
9158
8218
|
let cursor = emptyGithubCursor();
|
|
9159
8219
|
if (parsedCursor.success) cursor = parsedCursor.output;
|
|
9160
8220
|
const events = [];
|
|
@@ -9230,7 +8290,7 @@ var githubPollMonitor = new PollMonitor({
|
|
|
9230
8290
|
mergeCursor: mergeCursors
|
|
9231
8291
|
});
|
|
9232
8292
|
function updateGithubCursor(event, cursorRaw) {
|
|
9233
|
-
const parsed = /* @__PURE__ */
|
|
8293
|
+
const parsed = /* @__PURE__ */ safeParse2(GithubCursorSchema, cursorRaw);
|
|
9234
8294
|
let cursor = emptyGithubCursor();
|
|
9235
8295
|
if (parsed.success) cursor = parsed.output;
|
|
9236
8296
|
if (event.id?.startsWith("review:")) {
|
|
@@ -9384,9 +8444,9 @@ var GithubMonitor = class extends Monitor {
|
|
|
9384
8444
|
};
|
|
9385
8445
|
|
|
9386
8446
|
// providers/jira/dist/index.js
|
|
9387
|
-
import { link as
|
|
9388
|
-
import
|
|
9389
|
-
import
|
|
8447
|
+
import { link as link2, mkdir as mkdir2, open as open2, readFile as readFile2, rename as rename2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
|
|
8448
|
+
import os2 from "node:os";
|
|
8449
|
+
import path2 from "node:path";
|
|
9390
8450
|
var store$43;
|
|
9391
8451
|
var DEFAULT_CONFIG3 = {
|
|
9392
8452
|
lang: void 0,
|
|
@@ -9672,7 +8732,7 @@ var PollMonitor2 = class {
|
|
|
9672
8732
|
return now - Date.parse(record2.createdAt) > intervalMs;
|
|
9673
8733
|
}
|
|
9674
8734
|
};
|
|
9675
|
-
var
|
|
8735
|
+
var MAX_WEBHOOK_BODY_BYTES2 = 1024 * 1024;
|
|
9676
8736
|
function toMonitorEvent2(event, source) {
|
|
9677
8737
|
return {
|
|
9678
8738
|
source,
|
|
@@ -9685,50 +8745,50 @@ function toMonitorEvent2(event, source) {
|
|
|
9685
8745
|
terminal: event.terminal
|
|
9686
8746
|
};
|
|
9687
8747
|
}
|
|
9688
|
-
var store$
|
|
9689
|
-
var
|
|
8748
|
+
var store$422;
|
|
8749
|
+
var DEFAULT_CONFIG22 = {
|
|
9690
8750
|
lang: void 0,
|
|
9691
8751
|
message: void 0,
|
|
9692
8752
|
abortEarly: void 0,
|
|
9693
8753
|
abortPipeEarly: void 0
|
|
9694
8754
|
};
|
|
9695
8755
|
// @__NO_SIDE_EFFECTS__
|
|
9696
|
-
function
|
|
9697
|
-
if (!config$1 && !store$
|
|
8756
|
+
function getGlobalConfig22(config$1) {
|
|
8757
|
+
if (!config$1 && !store$422) return DEFAULT_CONFIG22;
|
|
9698
8758
|
return {
|
|
9699
|
-
lang: config$1?.lang ?? store$
|
|
8759
|
+
lang: config$1?.lang ?? store$422?.lang,
|
|
9700
8760
|
message: config$1?.message,
|
|
9701
|
-
abortEarly: config$1?.abortEarly ?? store$
|
|
9702
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$
|
|
8761
|
+
abortEarly: config$1?.abortEarly ?? store$422?.abortEarly,
|
|
8762
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$422?.abortPipeEarly
|
|
9703
8763
|
};
|
|
9704
8764
|
}
|
|
9705
|
-
var store$
|
|
8765
|
+
var store$322;
|
|
9706
8766
|
// @__NO_SIDE_EFFECTS__
|
|
9707
|
-
function
|
|
9708
|
-
return store$
|
|
8767
|
+
function getGlobalMessage22(lang) {
|
|
8768
|
+
return store$322?.get(lang);
|
|
9709
8769
|
}
|
|
9710
|
-
var store$
|
|
8770
|
+
var store$222;
|
|
9711
8771
|
// @__NO_SIDE_EFFECTS__
|
|
9712
|
-
function
|
|
9713
|
-
return store$
|
|
8772
|
+
function getSchemaMessage22(lang) {
|
|
8773
|
+
return store$222?.get(lang);
|
|
9714
8774
|
}
|
|
9715
|
-
var store$
|
|
8775
|
+
var store$122;
|
|
9716
8776
|
// @__NO_SIDE_EFFECTS__
|
|
9717
|
-
function
|
|
9718
|
-
return store$
|
|
8777
|
+
function getSpecificMessage22(reference, lang) {
|
|
8778
|
+
return store$122?.get(reference)?.get(lang);
|
|
9719
8779
|
}
|
|
9720
8780
|
// @__NO_SIDE_EFFECTS__
|
|
9721
|
-
function
|
|
8781
|
+
function _stringify22(input) {
|
|
9722
8782
|
const type = typeof input;
|
|
9723
8783
|
if (type === "string") return `"${input}"`;
|
|
9724
8784
|
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
9725
8785
|
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
9726
8786
|
return type;
|
|
9727
8787
|
}
|
|
9728
|
-
function
|
|
8788
|
+
function _addIssue22(context, label, dataset, config$1, other) {
|
|
9729
8789
|
const input = other && "input" in other ? other.input : dataset.value;
|
|
9730
8790
|
const expected = other?.expected ?? context.expects ?? null;
|
|
9731
|
-
const received = other?.received ?? /* @__PURE__ */
|
|
8791
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify22(input);
|
|
9732
8792
|
const issue = {
|
|
9733
8793
|
kind: context.kind,
|
|
9734
8794
|
type: context.type,
|
|
@@ -9744,29 +8804,29 @@ function _addIssue23(context, label, dataset, config$1, other) {
|
|
|
9744
8804
|
abortPipeEarly: config$1.abortPipeEarly
|
|
9745
8805
|
};
|
|
9746
8806
|
const isSchema = context.kind === "schema";
|
|
9747
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */
|
|
8807
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage22(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage22(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage22(issue.lang);
|
|
9748
8808
|
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
9749
8809
|
if (isSchema) dataset.typed = false;
|
|
9750
8810
|
if (dataset.issues) dataset.issues.push(issue);
|
|
9751
8811
|
else dataset.issues = [issue];
|
|
9752
8812
|
}
|
|
9753
|
-
var
|
|
8813
|
+
var _standardCache22 = /* @__PURE__ */ new WeakMap();
|
|
9754
8814
|
// @__NO_SIDE_EFFECTS__
|
|
9755
|
-
function
|
|
9756
|
-
let cached =
|
|
8815
|
+
function _getStandardProps22(context) {
|
|
8816
|
+
let cached = _standardCache22.get(context);
|
|
9757
8817
|
if (!cached) {
|
|
9758
8818
|
cached = {
|
|
9759
8819
|
version: 1,
|
|
9760
8820
|
vendor: "valibot",
|
|
9761
8821
|
validate(value$1) {
|
|
9762
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */
|
|
8822
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig22());
|
|
9763
8823
|
}
|
|
9764
8824
|
};
|
|
9765
|
-
|
|
8825
|
+
_standardCache22.set(context, cached);
|
|
9766
8826
|
}
|
|
9767
8827
|
return cached;
|
|
9768
8828
|
}
|
|
9769
|
-
var
|
|
8829
|
+
var EMOJI_REGEX22 = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
9770
8830
|
// @__NO_SIDE_EFFECTS__
|
|
9771
8831
|
function getFallback3(schema, dataset, config$1) {
|
|
9772
8832
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
@@ -9776,17 +8836,17 @@ function getDefault3(schema, dataset, config$1) {
|
|
|
9776
8836
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
9777
8837
|
}
|
|
9778
8838
|
// @__NO_SIDE_EFFECTS__
|
|
9779
|
-
function
|
|
8839
|
+
function array22(item, message$1) {
|
|
9780
8840
|
return {
|
|
9781
8841
|
kind: "schema",
|
|
9782
8842
|
type: "array",
|
|
9783
|
-
reference:
|
|
8843
|
+
reference: array22,
|
|
9784
8844
|
expects: "Array",
|
|
9785
8845
|
async: false,
|
|
9786
8846
|
item,
|
|
9787
8847
|
message: message$1,
|
|
9788
8848
|
get "~standard"() {
|
|
9789
|
-
return /* @__PURE__ */
|
|
8849
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9790
8850
|
},
|
|
9791
8851
|
"~run"(dataset, config$1) {
|
|
9792
8852
|
const input = dataset.value;
|
|
@@ -9818,7 +8878,7 @@ function array23(item, message$1) {
|
|
|
9818
8878
|
if (!itemDataset.typed) dataset.typed = false;
|
|
9819
8879
|
dataset.value.push(itemDataset.value);
|
|
9820
8880
|
}
|
|
9821
|
-
} else
|
|
8881
|
+
} else _addIssue22(this, "type", dataset, config$1);
|
|
9822
8882
|
return dataset;
|
|
9823
8883
|
}
|
|
9824
8884
|
};
|
|
@@ -9829,35 +8889,35 @@ function literal2(literal_, message$1) {
|
|
|
9829
8889
|
kind: "schema",
|
|
9830
8890
|
type: "literal",
|
|
9831
8891
|
reference: literal2,
|
|
9832
|
-
expects: /* @__PURE__ */
|
|
8892
|
+
expects: /* @__PURE__ */ _stringify22(literal_),
|
|
9833
8893
|
async: false,
|
|
9834
8894
|
literal: literal_,
|
|
9835
8895
|
message: message$1,
|
|
9836
8896
|
get "~standard"() {
|
|
9837
|
-
return /* @__PURE__ */
|
|
8897
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9838
8898
|
},
|
|
9839
8899
|
"~run"(dataset, config$1) {
|
|
9840
8900
|
if (dataset.value === this.literal) dataset.typed = true;
|
|
9841
|
-
else
|
|
8901
|
+
else _addIssue22(this, "type", dataset, config$1);
|
|
9842
8902
|
return dataset;
|
|
9843
8903
|
}
|
|
9844
8904
|
};
|
|
9845
8905
|
}
|
|
9846
8906
|
// @__NO_SIDE_EFFECTS__
|
|
9847
|
-
function
|
|
8907
|
+
function number2(message$1) {
|
|
9848
8908
|
return {
|
|
9849
8909
|
kind: "schema",
|
|
9850
8910
|
type: "number",
|
|
9851
|
-
reference:
|
|
8911
|
+
reference: number2,
|
|
9852
8912
|
expects: "number",
|
|
9853
8913
|
async: false,
|
|
9854
8914
|
message: message$1,
|
|
9855
8915
|
get "~standard"() {
|
|
9856
|
-
return /* @__PURE__ */
|
|
8916
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9857
8917
|
},
|
|
9858
8918
|
"~run"(dataset, config$1) {
|
|
9859
8919
|
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
9860
|
-
else
|
|
8920
|
+
else _addIssue22(this, "type", dataset, config$1);
|
|
9861
8921
|
return dataset;
|
|
9862
8922
|
}
|
|
9863
8923
|
};
|
|
@@ -9873,7 +8933,7 @@ function object3(entries$1, message$1) {
|
|
|
9873
8933
|
entries: entries$1,
|
|
9874
8934
|
message: message$1,
|
|
9875
8935
|
get "~standard"() {
|
|
9876
|
-
return /* @__PURE__ */
|
|
8936
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9877
8937
|
},
|
|
9878
8938
|
"~run"(dataset, config$1) {
|
|
9879
8939
|
const input = dataset.value;
|
|
@@ -9908,7 +8968,7 @@ function object3(entries$1, message$1) {
|
|
|
9908
8968
|
dataset.value[key] = valueDataset.value;
|
|
9909
8969
|
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback3(valueSchema);
|
|
9910
8970
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
9911
|
-
|
|
8971
|
+
_addIssue22(this, "key", dataset, config$1, {
|
|
9912
8972
|
input: void 0,
|
|
9913
8973
|
expected: `"${key}"`,
|
|
9914
8974
|
path: [{
|
|
@@ -9922,7 +8982,7 @@ function object3(entries$1, message$1) {
|
|
|
9922
8982
|
if (config$1.abortEarly) break;
|
|
9923
8983
|
}
|
|
9924
8984
|
}
|
|
9925
|
-
} else
|
|
8985
|
+
} else _addIssue22(this, "type", dataset, config$1);
|
|
9926
8986
|
return dataset;
|
|
9927
8987
|
}
|
|
9928
8988
|
};
|
|
@@ -9938,7 +8998,7 @@ function optional3(wrapped, default_) {
|
|
|
9938
8998
|
wrapped,
|
|
9939
8999
|
default: default_,
|
|
9940
9000
|
get "~standard"() {
|
|
9941
|
-
return /* @__PURE__ */
|
|
9001
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9942
9002
|
},
|
|
9943
9003
|
"~run"(dataset, config$1) {
|
|
9944
9004
|
if (dataset.value === void 0) {
|
|
@@ -9953,27 +9013,27 @@ function optional3(wrapped, default_) {
|
|
|
9953
9013
|
};
|
|
9954
9014
|
}
|
|
9955
9015
|
// @__NO_SIDE_EFFECTS__
|
|
9956
|
-
function
|
|
9016
|
+
function string22(message$1) {
|
|
9957
9017
|
return {
|
|
9958
9018
|
kind: "schema",
|
|
9959
9019
|
type: "string",
|
|
9960
|
-
reference:
|
|
9020
|
+
reference: string22,
|
|
9961
9021
|
expects: "string",
|
|
9962
9022
|
async: false,
|
|
9963
9023
|
message: message$1,
|
|
9964
9024
|
get "~standard"() {
|
|
9965
|
-
return /* @__PURE__ */
|
|
9025
|
+
return /* @__PURE__ */ _getStandardProps22(this);
|
|
9966
9026
|
},
|
|
9967
9027
|
"~run"(dataset, config$1) {
|
|
9968
9028
|
if (typeof dataset.value === "string") dataset.typed = true;
|
|
9969
|
-
else
|
|
9029
|
+
else _addIssue22(this, "type", dataset, config$1);
|
|
9970
9030
|
return dataset;
|
|
9971
9031
|
}
|
|
9972
9032
|
};
|
|
9973
9033
|
}
|
|
9974
9034
|
// @__NO_SIDE_EFFECTS__
|
|
9975
|
-
function
|
|
9976
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */
|
|
9035
|
+
function safeParse22(schema, input, config$1) {
|
|
9036
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig22(config$1));
|
|
9977
9037
|
return {
|
|
9978
9038
|
typed: dataset.typed,
|
|
9979
9039
|
success: !dataset.issues,
|
|
@@ -9983,12 +9043,12 @@ function safeParse23(schema, input, config$1) {
|
|
|
9983
9043
|
}
|
|
9984
9044
|
var JiraSourceSchema = /* @__PURE__ */ object3({
|
|
9985
9045
|
type: /* @__PURE__ */ literal2("jira"),
|
|
9986
|
-
issueKey: /* @__PURE__ */
|
|
9046
|
+
issueKey: /* @__PURE__ */ string22()
|
|
9987
9047
|
});
|
|
9988
9048
|
var JiraCursorSchema = /* @__PURE__ */ object3({
|
|
9989
|
-
commentIds: /* @__PURE__ */
|
|
9990
|
-
descriptionVersion: /* @__PURE__ */ optional3(/* @__PURE__ */
|
|
9991
|
-
changelogIds: /* @__PURE__ */
|
|
9049
|
+
commentIds: /* @__PURE__ */ array22(/* @__PURE__ */ number2()),
|
|
9050
|
+
descriptionVersion: /* @__PURE__ */ optional3(/* @__PURE__ */ string22()),
|
|
9051
|
+
changelogIds: /* @__PURE__ */ array22(/* @__PURE__ */ string22())
|
|
9992
9052
|
});
|
|
9993
9053
|
function jiraChangeValue(item, side) {
|
|
9994
9054
|
let value = item.toString ?? item.to;
|
|
@@ -10111,7 +9171,7 @@ async function jiraFetch(path22) {
|
|
|
10111
9171
|
return response.json();
|
|
10112
9172
|
}
|
|
10113
9173
|
async function pollJira(issueKey, cursorRaw) {
|
|
10114
|
-
const parsedCursor = /* @__PURE__ */
|
|
9174
|
+
const parsedCursor = /* @__PURE__ */ safeParse22(JiraCursorSchema, cursorRaw);
|
|
10115
9175
|
let cursor = emptyJiraCursor();
|
|
10116
9176
|
if (parsedCursor.success) cursor = parsedCursor.output;
|
|
10117
9177
|
const events = [];
|
|
@@ -10151,9 +9211,9 @@ var JiraMonitor = class extends Monitor2 {
|
|
|
10151
9211
|
};
|
|
10152
9212
|
|
|
10153
9213
|
// providers/slack/dist/index.js
|
|
10154
|
-
import { link as
|
|
10155
|
-
import
|
|
10156
|
-
import
|
|
9214
|
+
import { link as link3, mkdir as mkdir3, open as open3, readFile as readFile3, rename as rename3, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
9215
|
+
import os3 from "node:os";
|
|
9216
|
+
import path3 from "node:path";
|
|
10157
9217
|
import { createHmac as createHmac2 } from "node:crypto";
|
|
10158
9218
|
import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
10159
9219
|
var store$44;
|
|
@@ -10423,11 +9483,11 @@ function string4(message$1) {
|
|
|
10423
9483
|
};
|
|
10424
9484
|
}
|
|
10425
9485
|
// @__NO_SIDE_EFFECTS__
|
|
10426
|
-
function
|
|
9486
|
+
function unknown2() {
|
|
10427
9487
|
return {
|
|
10428
9488
|
kind: "schema",
|
|
10429
9489
|
type: "unknown",
|
|
10430
|
-
reference:
|
|
9490
|
+
reference: unknown2,
|
|
10431
9491
|
expects: "unknown",
|
|
10432
9492
|
async: false,
|
|
10433
9493
|
get "~standard"() {
|
|
@@ -10580,7 +9640,7 @@ var WEBHOOK_STARTUP_GRACE_MS2 = 12e4;
|
|
|
10580
9640
|
var PendingWebhookEventSchema2 = /* @__PURE__ */ object4({
|
|
10581
9641
|
deliveryId: /* @__PURE__ */ string4(),
|
|
10582
9642
|
event: /* @__PURE__ */ object4({
|
|
10583
|
-
source: /* @__PURE__ */
|
|
9643
|
+
source: /* @__PURE__ */ unknown2(),
|
|
10584
9644
|
kind: /* @__PURE__ */ string4(),
|
|
10585
9645
|
id: /* @__PURE__ */ optional4(/* @__PURE__ */ string4()),
|
|
10586
9646
|
at: /* @__PURE__ */ string4(),
|
|
@@ -10698,7 +9758,7 @@ var WebhookMonitor2 = class {
|
|
|
10698
9758
|
}
|
|
10699
9759
|
}
|
|
10700
9760
|
};
|
|
10701
|
-
var
|
|
9761
|
+
var MAX_WEBHOOK_BODY_BYTES3 = 1024 * 1024;
|
|
10702
9762
|
function toMonitorEvent3(event, source) {
|
|
10703
9763
|
return {
|
|
10704
9764
|
source,
|
|
@@ -10711,50 +9771,50 @@ function toMonitorEvent3(event, source) {
|
|
|
10711
9771
|
terminal: event.terminal
|
|
10712
9772
|
};
|
|
10713
9773
|
}
|
|
10714
|
-
var store$
|
|
10715
|
-
var
|
|
9774
|
+
var store$423;
|
|
9775
|
+
var DEFAULT_CONFIG23 = {
|
|
10716
9776
|
lang: void 0,
|
|
10717
9777
|
message: void 0,
|
|
10718
9778
|
abortEarly: void 0,
|
|
10719
9779
|
abortPipeEarly: void 0
|
|
10720
9780
|
};
|
|
10721
9781
|
// @__NO_SIDE_EFFECTS__
|
|
10722
|
-
function
|
|
10723
|
-
if (!config$1 && !store$
|
|
9782
|
+
function getGlobalConfig23(config$1) {
|
|
9783
|
+
if (!config$1 && !store$423) return DEFAULT_CONFIG23;
|
|
10724
9784
|
return {
|
|
10725
|
-
lang: config$1?.lang ?? store$
|
|
9785
|
+
lang: config$1?.lang ?? store$423?.lang,
|
|
10726
9786
|
message: config$1?.message,
|
|
10727
|
-
abortEarly: config$1?.abortEarly ?? store$
|
|
10728
|
-
abortPipeEarly: config$1?.abortPipeEarly ?? store$
|
|
9787
|
+
abortEarly: config$1?.abortEarly ?? store$423?.abortEarly,
|
|
9788
|
+
abortPipeEarly: config$1?.abortPipeEarly ?? store$423?.abortPipeEarly
|
|
10729
9789
|
};
|
|
10730
9790
|
}
|
|
10731
|
-
var store$
|
|
9791
|
+
var store$323;
|
|
10732
9792
|
// @__NO_SIDE_EFFECTS__
|
|
10733
|
-
function
|
|
10734
|
-
return store$
|
|
9793
|
+
function getGlobalMessage23(lang) {
|
|
9794
|
+
return store$323?.get(lang);
|
|
10735
9795
|
}
|
|
10736
|
-
var store$
|
|
9796
|
+
var store$223;
|
|
10737
9797
|
// @__NO_SIDE_EFFECTS__
|
|
10738
|
-
function
|
|
10739
|
-
return store$
|
|
9798
|
+
function getSchemaMessage23(lang) {
|
|
9799
|
+
return store$223?.get(lang);
|
|
10740
9800
|
}
|
|
10741
|
-
var store$
|
|
9801
|
+
var store$123;
|
|
10742
9802
|
// @__NO_SIDE_EFFECTS__
|
|
10743
|
-
function
|
|
10744
|
-
return store$
|
|
9803
|
+
function getSpecificMessage23(reference, lang) {
|
|
9804
|
+
return store$123?.get(reference)?.get(lang);
|
|
10745
9805
|
}
|
|
10746
9806
|
// @__NO_SIDE_EFFECTS__
|
|
10747
|
-
function
|
|
9807
|
+
function _stringify23(input) {
|
|
10748
9808
|
const type = typeof input;
|
|
10749
9809
|
if (type === "string") return `"${input}"`;
|
|
10750
9810
|
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
|
|
10751
9811
|
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
|
|
10752
9812
|
return type;
|
|
10753
9813
|
}
|
|
10754
|
-
function
|
|
9814
|
+
function _addIssue23(context, label, dataset, config$1, other) {
|
|
10755
9815
|
const input = other && "input" in other ? other.input : dataset.value;
|
|
10756
9816
|
const expected = other?.expected ?? context.expects ?? null;
|
|
10757
|
-
const received = other?.received ?? /* @__PURE__ */
|
|
9817
|
+
const received = other?.received ?? /* @__PURE__ */ _stringify23(input);
|
|
10758
9818
|
const issue = {
|
|
10759
9819
|
kind: context.kind,
|
|
10760
9820
|
type: context.type,
|
|
@@ -10770,49 +9830,49 @@ function _addIssue24(context, label, dataset, config$1, other) {
|
|
|
10770
9830
|
abortPipeEarly: config$1.abortPipeEarly
|
|
10771
9831
|
};
|
|
10772
9832
|
const isSchema = context.kind === "schema";
|
|
10773
|
-
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */
|
|
9833
|
+
const message$1 = other?.message ?? context.message ?? /* @__PURE__ */ getSpecificMessage23(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage23(issue.lang) : null) ?? config$1.message ?? /* @__PURE__ */ getGlobalMessage23(issue.lang);
|
|
10774
9834
|
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
|
|
10775
9835
|
if (isSchema) dataset.typed = false;
|
|
10776
9836
|
if (dataset.issues) dataset.issues.push(issue);
|
|
10777
9837
|
else dataset.issues = [issue];
|
|
10778
9838
|
}
|
|
10779
|
-
var
|
|
9839
|
+
var _standardCache23 = /* @__PURE__ */ new WeakMap();
|
|
10780
9840
|
// @__NO_SIDE_EFFECTS__
|
|
10781
|
-
function
|
|
10782
|
-
let cached =
|
|
9841
|
+
function _getStandardProps23(context) {
|
|
9842
|
+
let cached = _standardCache23.get(context);
|
|
10783
9843
|
if (!cached) {
|
|
10784
9844
|
cached = {
|
|
10785
9845
|
version: 1,
|
|
10786
9846
|
vendor: "valibot",
|
|
10787
9847
|
validate(value$1) {
|
|
10788
|
-
return context["~run"]({ value: value$1 }, /* @__PURE__ */
|
|
9848
|
+
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig23());
|
|
10789
9849
|
}
|
|
10790
9850
|
};
|
|
10791
|
-
|
|
9851
|
+
_standardCache23.set(context, cached);
|
|
10792
9852
|
}
|
|
10793
9853
|
return cached;
|
|
10794
9854
|
}
|
|
10795
|
-
var
|
|
9855
|
+
var EMOJI_REGEX23 = new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$", "u");
|
|
10796
9856
|
// @__NO_SIDE_EFFECTS__
|
|
10797
|
-
function
|
|
9857
|
+
function getFallback22(schema, dataset, config$1) {
|
|
10798
9858
|
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
|
|
10799
9859
|
}
|
|
10800
9860
|
// @__NO_SIDE_EFFECTS__
|
|
10801
|
-
function
|
|
9861
|
+
function getDefault22(schema, dataset, config$1) {
|
|
10802
9862
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
10803
9863
|
}
|
|
10804
9864
|
// @__NO_SIDE_EFFECTS__
|
|
10805
|
-
function
|
|
9865
|
+
function array23(item, message$1) {
|
|
10806
9866
|
return {
|
|
10807
9867
|
kind: "schema",
|
|
10808
9868
|
type: "array",
|
|
10809
|
-
reference:
|
|
9869
|
+
reference: array23,
|
|
10810
9870
|
expects: "Array",
|
|
10811
9871
|
async: false,
|
|
10812
9872
|
item,
|
|
10813
9873
|
message: message$1,
|
|
10814
9874
|
get "~standard"() {
|
|
10815
|
-
return /* @__PURE__ */
|
|
9875
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10816
9876
|
},
|
|
10817
9877
|
"~run"(dataset, config$1) {
|
|
10818
9878
|
const input = dataset.value;
|
|
@@ -10844,26 +9904,26 @@ function array24(item, message$1) {
|
|
|
10844
9904
|
if (!itemDataset.typed) dataset.typed = false;
|
|
10845
9905
|
dataset.value.push(itemDataset.value);
|
|
10846
9906
|
}
|
|
10847
|
-
} else
|
|
9907
|
+
} else _addIssue23(this, "type", dataset, config$1);
|
|
10848
9908
|
return dataset;
|
|
10849
9909
|
}
|
|
10850
9910
|
};
|
|
10851
9911
|
}
|
|
10852
9912
|
// @__NO_SIDE_EFFECTS__
|
|
10853
|
-
function
|
|
9913
|
+
function boolean22(message$1) {
|
|
10854
9914
|
return {
|
|
10855
9915
|
kind: "schema",
|
|
10856
9916
|
type: "boolean",
|
|
10857
|
-
reference:
|
|
9917
|
+
reference: boolean22,
|
|
10858
9918
|
expects: "boolean",
|
|
10859
9919
|
async: false,
|
|
10860
9920
|
message: message$1,
|
|
10861
9921
|
get "~standard"() {
|
|
10862
|
-
return /* @__PURE__ */
|
|
9922
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10863
9923
|
},
|
|
10864
9924
|
"~run"(dataset, config$1) {
|
|
10865
9925
|
if (typeof dataset.value === "boolean") dataset.typed = true;
|
|
10866
|
-
else
|
|
9926
|
+
else _addIssue23(this, "type", dataset, config$1);
|
|
10867
9927
|
return dataset;
|
|
10868
9928
|
}
|
|
10869
9929
|
};
|
|
@@ -10874,32 +9934,32 @@ function literal3(literal_, message$1) {
|
|
|
10874
9934
|
kind: "schema",
|
|
10875
9935
|
type: "literal",
|
|
10876
9936
|
reference: literal3,
|
|
10877
|
-
expects: /* @__PURE__ */
|
|
9937
|
+
expects: /* @__PURE__ */ _stringify23(literal_),
|
|
10878
9938
|
async: false,
|
|
10879
9939
|
literal: literal_,
|
|
10880
9940
|
message: message$1,
|
|
10881
9941
|
get "~standard"() {
|
|
10882
|
-
return /* @__PURE__ */
|
|
9942
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10883
9943
|
},
|
|
10884
9944
|
"~run"(dataset, config$1) {
|
|
10885
9945
|
if (dataset.value === this.literal) dataset.typed = true;
|
|
10886
|
-
else
|
|
9946
|
+
else _addIssue23(this, "type", dataset, config$1);
|
|
10887
9947
|
return dataset;
|
|
10888
9948
|
}
|
|
10889
9949
|
};
|
|
10890
9950
|
}
|
|
10891
9951
|
// @__NO_SIDE_EFFECTS__
|
|
10892
|
-
function
|
|
9952
|
+
function object22(entries$1, message$1) {
|
|
10893
9953
|
return {
|
|
10894
9954
|
kind: "schema",
|
|
10895
9955
|
type: "object",
|
|
10896
|
-
reference:
|
|
9956
|
+
reference: object22,
|
|
10897
9957
|
expects: "Object",
|
|
10898
9958
|
async: false,
|
|
10899
9959
|
entries: entries$1,
|
|
10900
9960
|
message: message$1,
|
|
10901
9961
|
get "~standard"() {
|
|
10902
|
-
return /* @__PURE__ */
|
|
9962
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10903
9963
|
},
|
|
10904
9964
|
"~run"(dataset, config$1) {
|
|
10905
9965
|
const input = dataset.value;
|
|
@@ -10909,7 +9969,7 @@ function object23(entries$1, message$1) {
|
|
|
10909
9969
|
for (const key in this.entries) {
|
|
10910
9970
|
const valueSchema = this.entries[key];
|
|
10911
9971
|
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
|
|
10912
|
-
const value$1 = key in input ? input[key] : /* @__PURE__ */
|
|
9972
|
+
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault22(valueSchema);
|
|
10913
9973
|
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
|
|
10914
9974
|
if (valueDataset.issues) {
|
|
10915
9975
|
const pathItem = {
|
|
@@ -10932,9 +9992,9 @@ function object23(entries$1, message$1) {
|
|
|
10932
9992
|
}
|
|
10933
9993
|
if (!valueDataset.typed) dataset.typed = false;
|
|
10934
9994
|
dataset.value[key] = valueDataset.value;
|
|
10935
|
-
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */
|
|
9995
|
+
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback22(valueSchema);
|
|
10936
9996
|
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
|
|
10937
|
-
|
|
9997
|
+
_addIssue23(this, "key", dataset, config$1, {
|
|
10938
9998
|
input: void 0,
|
|
10939
9999
|
expected: `"${key}"`,
|
|
10940
10000
|
path: [{
|
|
@@ -10948,7 +10008,7 @@ function object23(entries$1, message$1) {
|
|
|
10948
10008
|
if (config$1.abortEarly) break;
|
|
10949
10009
|
}
|
|
10950
10010
|
}
|
|
10951
|
-
} else
|
|
10011
|
+
} else _addIssue23(this, "type", dataset, config$1);
|
|
10952
10012
|
return dataset;
|
|
10953
10013
|
}
|
|
10954
10014
|
};
|
|
@@ -10964,11 +10024,11 @@ function optional22(wrapped, default_) {
|
|
|
10964
10024
|
wrapped,
|
|
10965
10025
|
default: default_,
|
|
10966
10026
|
get "~standard"() {
|
|
10967
|
-
return /* @__PURE__ */
|
|
10027
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10968
10028
|
},
|
|
10969
10029
|
"~run"(dataset, config$1) {
|
|
10970
10030
|
if (dataset.value === void 0) {
|
|
10971
|
-
if (this.default !== void 0) dataset.value = /* @__PURE__ */
|
|
10031
|
+
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault22(this, dataset, config$1);
|
|
10972
10032
|
if (dataset.value === void 0) {
|
|
10973
10033
|
dataset.typed = true;
|
|
10974
10034
|
return dataset;
|
|
@@ -10979,27 +10039,27 @@ function optional22(wrapped, default_) {
|
|
|
10979
10039
|
};
|
|
10980
10040
|
}
|
|
10981
10041
|
// @__NO_SIDE_EFFECTS__
|
|
10982
|
-
function
|
|
10042
|
+
function string23(message$1) {
|
|
10983
10043
|
return {
|
|
10984
10044
|
kind: "schema",
|
|
10985
10045
|
type: "string",
|
|
10986
|
-
reference:
|
|
10046
|
+
reference: string23,
|
|
10987
10047
|
expects: "string",
|
|
10988
10048
|
async: false,
|
|
10989
10049
|
message: message$1,
|
|
10990
10050
|
get "~standard"() {
|
|
10991
|
-
return /* @__PURE__ */
|
|
10051
|
+
return /* @__PURE__ */ _getStandardProps23(this);
|
|
10992
10052
|
},
|
|
10993
10053
|
"~run"(dataset, config$1) {
|
|
10994
10054
|
if (typeof dataset.value === "string") dataset.typed = true;
|
|
10995
|
-
else
|
|
10055
|
+
else _addIssue23(this, "type", dataset, config$1);
|
|
10996
10056
|
return dataset;
|
|
10997
10057
|
}
|
|
10998
10058
|
};
|
|
10999
10059
|
}
|
|
11000
10060
|
// @__NO_SIDE_EFFECTS__
|
|
11001
|
-
function
|
|
11002
|
-
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */
|
|
10061
|
+
function safeParse23(schema, input, config$1) {
|
|
10062
|
+
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig23(config$1));
|
|
11003
10063
|
return {
|
|
11004
10064
|
typed: dataset.typed,
|
|
11005
10065
|
success: !dataset.issues,
|
|
@@ -11007,15 +10067,15 @@ function safeParse24(schema, input, config$1) {
|
|
|
11007
10067
|
issues: dataset.issues
|
|
11008
10068
|
};
|
|
11009
10069
|
}
|
|
11010
|
-
var SlackSourceSchema = /* @__PURE__ */
|
|
10070
|
+
var SlackSourceSchema = /* @__PURE__ */ object22({
|
|
11011
10071
|
type: /* @__PURE__ */ literal3("slack"),
|
|
11012
|
-
channelId: /* @__PURE__ */
|
|
11013
|
-
threadTs: /* @__PURE__ */ optional22(/* @__PURE__ */
|
|
10072
|
+
channelId: /* @__PURE__ */ string23(),
|
|
10073
|
+
threadTs: /* @__PURE__ */ optional22(/* @__PURE__ */ string23())
|
|
11014
10074
|
});
|
|
11015
|
-
var SlackCursorSchema = /* @__PURE__ */
|
|
11016
|
-
primed: /* @__PURE__ */
|
|
11017
|
-
messageIds: /* @__PURE__ */
|
|
11018
|
-
latestTs: /* @__PURE__ */ optional22(/* @__PURE__ */
|
|
10075
|
+
var SlackCursorSchema = /* @__PURE__ */ object22({
|
|
10076
|
+
primed: /* @__PURE__ */ boolean22(),
|
|
10077
|
+
messageIds: /* @__PURE__ */ array23(/* @__PURE__ */ string23()),
|
|
10078
|
+
latestTs: /* @__PURE__ */ optional22(/* @__PURE__ */ string23())
|
|
11019
10079
|
});
|
|
11020
10080
|
function messageTimestamp(ts) {
|
|
11021
10081
|
const value = Number(ts ?? 0);
|
|
@@ -11028,7 +10088,7 @@ function messageAt(ts) {
|
|
|
11028
10088
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
11029
10089
|
}
|
|
11030
10090
|
function parseSlackReadResult(result, cursorRaw, location = "thread") {
|
|
11031
|
-
const parsedCursor = /* @__PURE__ */
|
|
10091
|
+
const parsedCursor = /* @__PURE__ */ safeParse23(SlackCursorSchema, cursorRaw);
|
|
11032
10092
|
let previous = {};
|
|
11033
10093
|
if (parsedCursor.success) previous = parsedCursor.output;
|
|
11034
10094
|
const cursor = {
|
|
@@ -11036,7 +10096,7 @@ function parseSlackReadResult(result, cursorRaw, location = "thread") {
|
|
|
11036
10096
|
messageIds: previous.messageIds ?? [],
|
|
11037
10097
|
latestTs: previous.latestTs
|
|
11038
10098
|
};
|
|
11039
|
-
const
|
|
10099
|
+
const users2 = new Map((result.users ?? []).map((user) => [user.id, user.real_name ?? user.name ?? user.id ?? "someone"]));
|
|
11040
10100
|
const messages = (result.messages ?? []).filter((message) => message.ts);
|
|
11041
10101
|
const freshMessages = messages.filter((message) => {
|
|
11042
10102
|
if (cursor.messageIds.includes(message.ts)) return false;
|
|
@@ -11048,7 +10108,7 @@ function parseSlackReadResult(result, cursorRaw, location = "thread") {
|
|
|
11048
10108
|
events = freshMessages.map((message) => {
|
|
11049
10109
|
let text = "[message without text]";
|
|
11050
10110
|
if (message.text?.trim()) text = message.text.trim();
|
|
11051
|
-
let author =
|
|
10111
|
+
let author = users2.get(message.user);
|
|
11052
10112
|
if (!author) author = message.user;
|
|
11053
10113
|
if (!author) author = "someone";
|
|
11054
10114
|
return {
|
|
@@ -11071,10 +10131,9 @@ function parseSlackReadResult(result, cursorRaw, location = "thread") {
|
|
|
11071
10131
|
return { events, cursor };
|
|
11072
10132
|
}
|
|
11073
10133
|
var SLACK_API = "https://slack.com/api";
|
|
11074
|
-
var
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
}
|
|
10134
|
+
var USERS_TTL_MS = 60 * 60 * 1e3;
|
|
10135
|
+
var users;
|
|
10136
|
+
var refreshing;
|
|
11078
10137
|
async function fetchSlackThread(channelId, threadTs) {
|
|
11079
10138
|
return fetchSlackMessages("conversations.replies", { channel: channelId, ts: threadTs, inclusive: "false" });
|
|
11080
10139
|
}
|
|
@@ -11084,61 +10143,57 @@ async function fetchSlackDm(channelId) {
|
|
|
11084
10143
|
async function fetchSlackMessages(method, params) {
|
|
11085
10144
|
const messages = [];
|
|
11086
10145
|
let cursor = "";
|
|
11087
|
-
let received = false;
|
|
11088
10146
|
do {
|
|
11089
|
-
const page = await slackApi(method, {
|
|
11090
|
-
|
|
11091
|
-
|
|
11092
|
-
|
|
11093
|
-
}
|
|
11094
|
-
if (
|
|
11095
|
-
|
|
11096
|
-
if (Array.isArray(page.messages)) messages.push(...page.messages);
|
|
11097
|
-
cursor = page.response_metadata?.next_cursor ?? "";
|
|
10147
|
+
const page = await slackApi(method, { ...params, limit: "1000", ...cursor ? { cursor } : {} });
|
|
10148
|
+
if (!page.ok) {
|
|
10149
|
+
if (messages.length > 0) break;
|
|
10150
|
+
throw new Error(`slack ${method} failed: ${page.error}`);
|
|
10151
|
+
}
|
|
10152
|
+
if (Array.isArray(page.result.messages)) messages.push(...page.result.messages);
|
|
10153
|
+
cursor = page.result.response_metadata?.next_cursor ?? "";
|
|
11098
10154
|
if (messages.length >= 1e4) break;
|
|
11099
10155
|
} while (cursor);
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
10156
|
+
return { messages, users: await slackUsers() };
|
|
10157
|
+
}
|
|
10158
|
+
async function slackUsers() {
|
|
10159
|
+
if (users && Date.now() - users.fetchedAt < USERS_TTL_MS) return users.list;
|
|
10160
|
+
refreshing ??= refreshUsers().finally(() => {
|
|
10161
|
+
refreshing = void 0;
|
|
10162
|
+
});
|
|
10163
|
+
return refreshing;
|
|
10164
|
+
}
|
|
10165
|
+
async function refreshUsers() {
|
|
10166
|
+
const list = [];
|
|
10167
|
+
let cursor = "";
|
|
11103
10168
|
do {
|
|
11104
|
-
const page = await slackApi("users.list", { limit: "200", ...
|
|
11105
|
-
if (!page)
|
|
11106
|
-
if (Array.isArray(page.members)) {
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
|
|
11112
|
-
|
|
11113
|
-
usersCursor = page.response_metadata?.next_cursor ?? "";
|
|
11114
|
-
} while (usersCursor);
|
|
11115
|
-
return { messages, users };
|
|
10169
|
+
const page = await slackApi("users.list", { limit: "200", ...cursor ? { cursor } : {} });
|
|
10170
|
+
if (!page.ok) return users?.list ?? list;
|
|
10171
|
+
if (Array.isArray(page.result.members)) {
|
|
10172
|
+
list.push(...page.result.members.map((member) => ({ id: member.id, name: member.name, real_name: member.real_name })));
|
|
10173
|
+
}
|
|
10174
|
+
cursor = page.result.response_metadata?.next_cursor ?? "";
|
|
10175
|
+
} while (cursor);
|
|
10176
|
+
users = { list, fetchedAt: Date.now() };
|
|
10177
|
+
return list;
|
|
11116
10178
|
}
|
|
11117
10179
|
async function slackApi(method, params) {
|
|
11118
|
-
const token =
|
|
11119
|
-
if (!token) {
|
|
11120
|
-
if (!warnedMissingToken2) {
|
|
11121
|
-
warnedMissingToken2 = true;
|
|
11122
|
-
console.warn("[sourcefed] SOURCEFED_SLACK_TOKEN is not set; Slack monitors will not poll");
|
|
11123
|
-
}
|
|
11124
|
-
return void 0;
|
|
11125
|
-
}
|
|
10180
|
+
const token = process.env.SOURCEFED_SLACK_TOKEN;
|
|
10181
|
+
if (!token) return { ok: false, error: "SOURCEFED_SLACK_TOKEN is not set" };
|
|
11126
10182
|
try {
|
|
11127
10183
|
const response = await fetch(`${SLACK_API}/${method}`, {
|
|
11128
10184
|
method: "POST",
|
|
11129
10185
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/x-www-form-urlencoded" },
|
|
11130
10186
|
body: new URLSearchParams(params)
|
|
11131
10187
|
});
|
|
11132
|
-
const result = await response.json();
|
|
11133
|
-
if (
|
|
11134
|
-
return result;
|
|
11135
|
-
} catch {
|
|
11136
|
-
return
|
|
10188
|
+
const result = await response.json().catch(() => void 0);
|
|
10189
|
+
if (response.ok && result?.ok === true) return { ok: true, result };
|
|
10190
|
+
return { ok: false, error: result?.error ?? `HTTP ${response.status}` };
|
|
10191
|
+
} catch (error) {
|
|
10192
|
+
return { ok: false, error: error instanceof Error ? error.message : String(error) };
|
|
11137
10193
|
}
|
|
11138
10194
|
}
|
|
11139
10195
|
async function pollSlack(source, cursorRaw) {
|
|
11140
10196
|
const result = source.threadTs ? await fetchSlackThread(source.channelId, source.threadTs) : await fetchSlackDm(source.channelId);
|
|
11141
|
-
if (!result) throw new Error("slack API request failed; check SOURCEFED_SLACK_TOKEN");
|
|
11142
10197
|
const parsed = parseSlackReadResult(result, cursorRaw, source.threadTs ? "thread" : "DM");
|
|
11143
10198
|
return { ...parsed, terminal: false };
|
|
11144
10199
|
}
|
|
@@ -11194,7 +10249,7 @@ function validSlackSignature(body, request, secret = process.env.SOURCEFED_SLACK
|
|
|
11194
10249
|
return actual.length === wanted.length && timingSafeEqual2(actual, wanted);
|
|
11195
10250
|
}
|
|
11196
10251
|
function updateSlackCursor(event, cursorRaw) {
|
|
11197
|
-
const parsed = /* @__PURE__ */
|
|
10252
|
+
const parsed = /* @__PURE__ */ safeParse23(SlackCursorSchema, cursorRaw);
|
|
11198
10253
|
let cursor = { primed: false, messageIds: [], latestTs: void 0 };
|
|
11199
10254
|
if (parsed.success) cursor = parsed.output;
|
|
11200
10255
|
if (event.id?.startsWith("message:")) {
|
|
@@ -11277,8 +10332,8 @@ function sourceForWebhookPath(pathname) {
|
|
|
11277
10332
|
}
|
|
11278
10333
|
|
|
11279
10334
|
// packages/daemon/src/utils/env.ts
|
|
11280
|
-
import
|
|
11281
|
-
import
|
|
10335
|
+
import os4 from "node:os";
|
|
10336
|
+
import path4 from "node:path";
|
|
11282
10337
|
var DAEMON_ENVIRONMENT = [
|
|
11283
10338
|
"PATH",
|
|
11284
10339
|
"HOME",
|
|
@@ -11306,7 +10361,7 @@ function daemonEnvironment(host) {
|
|
|
11306
10361
|
const environment = Object.fromEntries(
|
|
11307
10362
|
DAEMON_ENVIRONMENT.flatMap((name) => process.env[name] === void 0 ? [] : [[name, process.env[name]]])
|
|
11308
10363
|
);
|
|
11309
|
-
if (host) environment.SOURCEFED_STATE_DIR ??=
|
|
10364
|
+
if (host) environment.SOURCEFED_STATE_DIR ??= path4.join(process.env.XDG_STATE_HOME ?? path4.join(os4.homedir(), ".local", "state"), "sourcefed", host);
|
|
11310
10365
|
return environment;
|
|
11311
10366
|
}
|
|
11312
10367
|
|
|
@@ -11432,7 +10487,7 @@ var RequestRouter = class {
|
|
|
11432
10487
|
|
|
11433
10488
|
// packages/daemon/src/utils/spawn.ts
|
|
11434
10489
|
import { spawn } from "node:child_process";
|
|
11435
|
-
import
|
|
10490
|
+
import path5 from "node:path";
|
|
11436
10491
|
var DEFAULT_DAEMON_URL = "http://127.0.0.1:18787";
|
|
11437
10492
|
function defaultDaemonUrl() {
|
|
11438
10493
|
const port = process.env.SOURCEFED_DAEMON_PORT ?? 18787;
|
|
@@ -11445,7 +10500,7 @@ function daemonCommand(cliEntryPath) {
|
|
|
11445
10500
|
};
|
|
11446
10501
|
}
|
|
11447
10502
|
function nodeExecutable() {
|
|
11448
|
-
const base =
|
|
10503
|
+
const base = path5.basename(process.execPath);
|
|
11449
10504
|
if (base.includes("node") || base.includes("bun")) return process.execPath;
|
|
11450
10505
|
return "node";
|
|
11451
10506
|
}
|
|
@@ -11620,6 +10675,18 @@ var SourcefedDaemon = class {
|
|
|
11620
10675
|
const monitors = (await this.service.list()).filter((monitor) => sameTarget(monitor.target, target));
|
|
11621
10676
|
return { ok: true, monitors: monitors.map(monitorView) };
|
|
11622
10677
|
}
|
|
10678
|
+
/**
|
|
10679
|
+
* Every target of `kind` with an enabled monitor, so a host that restarts can
|
|
10680
|
+
* resubscribe the sessions whose monitors outlived it.
|
|
10681
|
+
*/
|
|
10682
|
+
async listTargets(kind) {
|
|
10683
|
+
const targets = /* @__PURE__ */ new Map();
|
|
10684
|
+
for (const monitor of await this.service.list()) {
|
|
10685
|
+
if (!monitor.enabled || monitor.target.kind !== kind) continue;
|
|
10686
|
+
targets.set(targetKey(monitor.target), { kind: monitor.target.kind, id: monitor.target.id });
|
|
10687
|
+
}
|
|
10688
|
+
return [...targets.values()];
|
|
10689
|
+
}
|
|
11623
10690
|
async getMonitor(target, id) {
|
|
11624
10691
|
const monitor = await ownedMonitor(this.service, id, target);
|
|
11625
10692
|
if (!monitor) return { ok: false, error: `monitor ${id} was not found for this target` };
|
|
@@ -11992,6 +11059,9 @@ async function dispatchDaemonRequest(daemon, method, params) {
|
|
|
11992
11059
|
return daemon.createMonitor(createTarget(params), createCreateInput(params));
|
|
11993
11060
|
case "monitor.list":
|
|
11994
11061
|
return daemon.listMonitors(createTarget(params));
|
|
11062
|
+
case "monitor.targets":
|
|
11063
|
+
if (typeof params.kind !== "string" || !params.kind) throw new Error("monitor.targets requires params.kind");
|
|
11064
|
+
return { targets: await daemon.listTargets(params.kind) };
|
|
11995
11065
|
case "monitor.status":
|
|
11996
11066
|
return daemon.getMonitor(createTarget(params), String(params.id));
|
|
11997
11067
|
case "monitor.stop":
|