@alistigo/claude-storage-plugin 0.2.16 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +311 -1003
- package/dist/index.js.map +1 -1
- package/package.json +5 -8
package/dist/index.js
CHANGED
|
@@ -1,804 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const De = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
12
|
-
function Ue(e) {
|
|
13
|
-
return typeof e == "string" && De.test(e);
|
|
14
|
-
}
|
|
15
|
-
var w = [];
|
|
16
|
-
for (var ne = 0; ne < 256; ++ne)
|
|
17
|
-
w.push((ne + 256).toString(16).slice(1));
|
|
18
|
-
function Ie(e, n = 0) {
|
|
19
|
-
return (w[e[n + 0]] + w[e[n + 1]] + w[e[n + 2]] + w[e[n + 3]] + "-" + w[e[n + 4]] + w[e[n + 5]] + "-" + w[e[n + 6]] + w[e[n + 7]] + "-" + w[e[n + 8]] + w[e[n + 9]] + "-" + w[e[n + 10]] + w[e[n + 11]] + w[e[n + 12]] + w[e[n + 13]] + w[e[n + 14]] + w[e[n + 15]]).toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
function Pe(e, n = 0) {
|
|
22
|
-
var t = Ie(e, n);
|
|
23
|
-
if (!Ue(t))
|
|
24
|
-
throw TypeError("Stringified UUID is invalid");
|
|
25
|
-
return t;
|
|
26
|
-
}
|
|
27
|
-
var G, $e = new Uint8Array(16);
|
|
28
|
-
function Fe() {
|
|
29
|
-
if (!G && (G = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !G))
|
|
30
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
31
|
-
return G($e);
|
|
32
|
-
}
|
|
33
|
-
var me = null, he = null, A = 0;
|
|
34
|
-
function Re(e, n, t) {
|
|
35
|
-
e = e || {};
|
|
36
|
-
var i = 0, c = n || new Uint8Array(16), m = e.random || (e.rng || Fe)(), _ = e.msecs !== void 0 ? e.msecs : Date.now(), I = e.seq !== void 0 ? e.seq : null, E = he, p = me;
|
|
37
|
-
return _ > A && e.msecs === void 0 && (A = _, I !== null && (E = null, p = null)), I !== null && (I > 2147483647 && (I = 2147483647), E = I >>> 19 & 4095, p = I & 524287), (E === null || p === null) && (E = m[6] & 127, E = E << 8 | m[7], p = m[8] & 63, p = p << 8 | m[9], p = p << 5 | m[10] >>> 3), _ + 1e4 > A && I === null ? ++p > 524287 && (p = 0, ++E > 4095 && (E = 0, A++)) : A = _, he = E, me = p, c[i++] = A / 1099511627776 & 255, c[i++] = A / 4294967296 & 255, c[i++] = A / 16777216 & 255, c[i++] = A / 65536 & 255, c[i++] = A / 256 & 255, c[i++] = A & 255, c[i++] = E >>> 4 & 15 | 112, c[i++] = E & 255, c[i++] = p >>> 13 & 63 | 128, c[i++] = p >>> 5 & 255, c[i++] = p << 3 & 255 | m[10] & 7, c[i++] = m[11], c[i++] = m[12], c[i++] = m[13], c[i++] = m[14], c[i++] = m[15], n || Ie(c);
|
|
38
|
-
}
|
|
39
|
-
function Ve(e) {
|
|
40
|
-
let n;
|
|
41
|
-
const t = new Uint8Array(16);
|
|
42
|
-
return t[0] = (n = parseInt(e.slice(0, 8), 16)) >>> 24, t[1] = n >>> 16 & 255, t[2] = n >>> 8 & 255, t[3] = n & 255, t[4] = (n = parseInt(e.slice(9, 13), 16)) >>> 8, t[5] = n & 255, t[6] = (n = parseInt(e.slice(14, 18), 16)) >>> 8, t[7] = n & 255, t[8] = (n = parseInt(e.slice(19, 23), 16)) >>> 8, t[9] = n & 255, t[10] = (n = parseInt(e.slice(24, 36), 16)) / 1099511627776 & 255, t[11] = n / 4294967296 & 255, t[12] = n >>> 24 & 255, t[13] = n >>> 16 & 255, t[14] = n >>> 8 & 255, t[15] = n & 255, t;
|
|
43
|
-
}
|
|
44
|
-
var h = "0123456789abcdefghjkmnpqrstvwxyz", s = new Uint8Array([
|
|
45
|
-
255,
|
|
46
|
-
255,
|
|
47
|
-
255,
|
|
48
|
-
255,
|
|
49
|
-
255,
|
|
50
|
-
255,
|
|
51
|
-
255,
|
|
52
|
-
255,
|
|
53
|
-
255,
|
|
54
|
-
255,
|
|
55
|
-
255,
|
|
56
|
-
255,
|
|
57
|
-
255,
|
|
58
|
-
255,
|
|
59
|
-
255,
|
|
60
|
-
255,
|
|
61
|
-
255,
|
|
62
|
-
255,
|
|
63
|
-
255,
|
|
64
|
-
255,
|
|
65
|
-
255,
|
|
66
|
-
255,
|
|
67
|
-
255,
|
|
68
|
-
255,
|
|
69
|
-
255,
|
|
70
|
-
255,
|
|
71
|
-
255,
|
|
72
|
-
255,
|
|
73
|
-
255,
|
|
74
|
-
255,
|
|
75
|
-
255,
|
|
76
|
-
255,
|
|
77
|
-
255,
|
|
78
|
-
255,
|
|
79
|
-
255,
|
|
80
|
-
255,
|
|
81
|
-
255,
|
|
82
|
-
255,
|
|
83
|
-
255,
|
|
84
|
-
255,
|
|
85
|
-
255,
|
|
86
|
-
255,
|
|
87
|
-
255,
|
|
88
|
-
255,
|
|
89
|
-
255,
|
|
90
|
-
255,
|
|
91
|
-
255,
|
|
92
|
-
255,
|
|
93
|
-
0,
|
|
94
|
-
1,
|
|
95
|
-
2,
|
|
96
|
-
3,
|
|
97
|
-
4,
|
|
98
|
-
5,
|
|
99
|
-
6,
|
|
100
|
-
7,
|
|
101
|
-
8,
|
|
102
|
-
9,
|
|
103
|
-
255,
|
|
104
|
-
255,
|
|
105
|
-
255,
|
|
106
|
-
255,
|
|
107
|
-
255,
|
|
108
|
-
255,
|
|
109
|
-
255,
|
|
110
|
-
255,
|
|
111
|
-
255,
|
|
112
|
-
255,
|
|
113
|
-
255,
|
|
114
|
-
255,
|
|
115
|
-
255,
|
|
116
|
-
255,
|
|
117
|
-
255,
|
|
118
|
-
255,
|
|
119
|
-
255,
|
|
120
|
-
255,
|
|
121
|
-
255,
|
|
122
|
-
255,
|
|
123
|
-
255,
|
|
124
|
-
255,
|
|
125
|
-
255,
|
|
126
|
-
255,
|
|
127
|
-
255,
|
|
128
|
-
255,
|
|
129
|
-
255,
|
|
130
|
-
255,
|
|
131
|
-
255,
|
|
132
|
-
255,
|
|
133
|
-
255,
|
|
134
|
-
255,
|
|
135
|
-
255,
|
|
136
|
-
255,
|
|
137
|
-
255,
|
|
138
|
-
255,
|
|
139
|
-
255,
|
|
140
|
-
255,
|
|
141
|
-
255,
|
|
142
|
-
10,
|
|
143
|
-
11,
|
|
144
|
-
12,
|
|
145
|
-
13,
|
|
146
|
-
14,
|
|
147
|
-
15,
|
|
148
|
-
16,
|
|
149
|
-
17,
|
|
150
|
-
255,
|
|
151
|
-
18,
|
|
152
|
-
19,
|
|
153
|
-
255,
|
|
154
|
-
20,
|
|
155
|
-
21,
|
|
156
|
-
255,
|
|
157
|
-
22,
|
|
158
|
-
23,
|
|
159
|
-
24,
|
|
160
|
-
25,
|
|
161
|
-
26,
|
|
162
|
-
255,
|
|
163
|
-
27,
|
|
164
|
-
28,
|
|
165
|
-
29,
|
|
166
|
-
30,
|
|
167
|
-
31,
|
|
168
|
-
255,
|
|
169
|
-
255,
|
|
170
|
-
255,
|
|
171
|
-
255,
|
|
172
|
-
255,
|
|
173
|
-
255,
|
|
174
|
-
255,
|
|
175
|
-
255,
|
|
176
|
-
255,
|
|
177
|
-
255,
|
|
178
|
-
255,
|
|
179
|
-
255,
|
|
180
|
-
255,
|
|
181
|
-
255,
|
|
182
|
-
255,
|
|
183
|
-
255,
|
|
184
|
-
255,
|
|
185
|
-
255,
|
|
186
|
-
255,
|
|
187
|
-
255,
|
|
188
|
-
255,
|
|
189
|
-
255,
|
|
190
|
-
255,
|
|
191
|
-
255,
|
|
192
|
-
255,
|
|
193
|
-
255,
|
|
194
|
-
255,
|
|
195
|
-
255,
|
|
196
|
-
255,
|
|
197
|
-
255,
|
|
198
|
-
255,
|
|
199
|
-
255,
|
|
200
|
-
255,
|
|
201
|
-
255,
|
|
202
|
-
255,
|
|
203
|
-
255,
|
|
204
|
-
255,
|
|
205
|
-
255,
|
|
206
|
-
255,
|
|
207
|
-
255,
|
|
208
|
-
255,
|
|
209
|
-
255,
|
|
210
|
-
255,
|
|
211
|
-
255,
|
|
212
|
-
255,
|
|
213
|
-
255,
|
|
214
|
-
255,
|
|
215
|
-
255,
|
|
216
|
-
255,
|
|
217
|
-
255,
|
|
218
|
-
255,
|
|
219
|
-
255,
|
|
220
|
-
255,
|
|
221
|
-
255,
|
|
222
|
-
255,
|
|
223
|
-
255,
|
|
224
|
-
255,
|
|
225
|
-
255,
|
|
226
|
-
255,
|
|
227
|
-
255,
|
|
228
|
-
255,
|
|
229
|
-
255,
|
|
230
|
-
255,
|
|
231
|
-
255,
|
|
232
|
-
255,
|
|
233
|
-
255,
|
|
234
|
-
255,
|
|
235
|
-
255,
|
|
236
|
-
255,
|
|
237
|
-
255,
|
|
238
|
-
255,
|
|
239
|
-
255,
|
|
240
|
-
255,
|
|
241
|
-
255,
|
|
242
|
-
255,
|
|
243
|
-
255,
|
|
244
|
-
255,
|
|
245
|
-
255,
|
|
246
|
-
255,
|
|
247
|
-
255,
|
|
248
|
-
255,
|
|
249
|
-
255,
|
|
250
|
-
255,
|
|
251
|
-
255,
|
|
252
|
-
255,
|
|
253
|
-
255,
|
|
254
|
-
255,
|
|
255
|
-
255,
|
|
256
|
-
255,
|
|
257
|
-
255,
|
|
258
|
-
255,
|
|
259
|
-
255,
|
|
260
|
-
255,
|
|
261
|
-
255,
|
|
262
|
-
255,
|
|
263
|
-
255,
|
|
264
|
-
255,
|
|
265
|
-
255,
|
|
266
|
-
255,
|
|
267
|
-
255,
|
|
268
|
-
255,
|
|
269
|
-
255,
|
|
270
|
-
255,
|
|
271
|
-
255,
|
|
272
|
-
255,
|
|
273
|
-
255,
|
|
274
|
-
255,
|
|
275
|
-
255,
|
|
276
|
-
255,
|
|
277
|
-
255,
|
|
278
|
-
255,
|
|
279
|
-
255,
|
|
280
|
-
255,
|
|
281
|
-
255,
|
|
282
|
-
255,
|
|
283
|
-
255,
|
|
284
|
-
255,
|
|
285
|
-
255,
|
|
286
|
-
255,
|
|
287
|
-
255,
|
|
288
|
-
255,
|
|
289
|
-
255,
|
|
290
|
-
255,
|
|
291
|
-
255,
|
|
292
|
-
255,
|
|
293
|
-
255,
|
|
294
|
-
255,
|
|
295
|
-
255,
|
|
296
|
-
255,
|
|
297
|
-
255,
|
|
298
|
-
255,
|
|
299
|
-
255,
|
|
300
|
-
255
|
|
301
|
-
]);
|
|
302
|
-
function ie(e) {
|
|
303
|
-
const n = new Array(26).fill("");
|
|
304
|
-
if (e.length !== 16)
|
|
305
|
-
throw new Error(
|
|
306
|
-
`Invalid length. Expected 16 bytes, got ${e.length}. Input: ${e}`
|
|
307
|
-
);
|
|
308
|
-
return n[0] = h[(e[0] & 224) >> 5], n[1] = h[e[0] & 31], n[2] = h[(e[1] & 248) >> 3], n[3] = h[(e[1] & 7) << 2 | (e[2] & 192) >> 6], n[4] = h[(e[2] & 62) >> 1], n[5] = h[(e[2] & 1) << 4 | (e[3] & 240) >> 4], n[6] = h[(e[3] & 15) << 1 | (e[4] & 128) >> 7], n[7] = h[(e[4] & 124) >> 2], n[8] = h[(e[4] & 3) << 3 | (e[5] & 224) >> 5], n[9] = h[e[5] & 31], n[10] = h[(e[6] & 248) >> 3], n[11] = h[(e[6] & 7) << 2 | (e[7] & 192) >> 6], n[12] = h[(e[7] & 62) >> 1], n[13] = h[(e[7] & 1) << 4 | (e[8] & 240) >> 4], n[14] = h[(e[8] & 15) << 1 | (e[9] & 128) >> 7], n[15] = h[(e[9] & 124) >> 2], n[16] = h[(e[9] & 3) << 3 | (e[10] & 224) >> 5], n[17] = h[e[10] & 31], n[18] = h[(e[11] & 248) >> 3], n[19] = h[(e[11] & 7) << 2 | (e[12] & 192) >> 6], n[20] = h[(e[12] & 62) >> 1], n[21] = h[(e[12] & 1) << 4 | (e[13] & 240) >> 4], n[22] = h[(e[13] & 15) << 1 | (e[14] & 128) >> 7], n[23] = h[(e[14] & 124) >> 2], n[24] = h[(e[14] & 3) << 3 | (e[15] & 224) >> 5], n[25] = h[e[15] & 31], n.join("");
|
|
309
|
-
}
|
|
310
|
-
function xe(e) {
|
|
311
|
-
if (e.length !== 26)
|
|
312
|
-
throw new Error(
|
|
313
|
-
`Invalid length. Expected 26 bytes, got ${e.length}. Input: ${e}`
|
|
314
|
-
);
|
|
315
|
-
const t = new TextEncoder().encode(e);
|
|
316
|
-
if (s[t[0]] === 255 || s[t[1]] === 255 || s[t[2]] === 255 || s[t[3]] === 255 || s[t[4]] === 255 || s[t[5]] === 255 || s[t[6]] === 255 || s[t[7]] === 255 || s[t[8]] === 255 || s[t[9]] === 255 || s[t[10]] === 255 || s[t[11]] === 255 || s[t[12]] === 255 || s[t[13]] === 255 || s[t[14]] === 255 || s[t[15]] === 255 || s[t[16]] === 255 || s[t[17]] === 255 || s[t[18]] === 255 || s[t[19]] === 255 || s[t[20]] === 255 || s[t[21]] === 255 || s[t[22]] === 255 || s[t[23]] === 255 || s[t[24]] === 255 || s[t[25]] === 255)
|
|
317
|
-
throw new Error("Invalid base32 character");
|
|
318
|
-
const i = new Uint8Array(16);
|
|
319
|
-
return i[0] = s[t[0]] << 5 | s[t[1]], i[1] = s[t[2]] << 3 | s[t[3]] >> 2, i[2] = (s[t[3]] & 3) << 6 | s[t[4]] << 1 | s[t[5]] >> 4, i[3] = (s[t[5]] & 15) << 4 | s[t[6]] >> 1, i[4] = (s[t[6]] & 1) << 7 | s[t[7]] << 2 | s[t[8]] >> 3, i[5] = (s[t[8]] & 7) << 5 | s[t[9]], i[6] = s[t[10]] << 3 | s[t[11]] >> 2, i[7] = (s[t[11]] & 3) << 6 | s[t[12]] << 1 | s[t[13]] >> 4, i[8] = (s[t[13]] & 15) << 4 | s[t[14]] >> 1, i[9] = (s[t[14]] & 1) << 7 | s[t[15]] << 2 | s[t[16]] >> 3, i[10] = (s[t[16]] & 7) << 5 | s[t[17]], i[11] = s[t[18]] << 3 | s[t[19]] >> 2, i[12] = (s[t[19]] & 3) << 6 | s[t[20]] << 1 | s[t[21]] >> 4, i[13] = (s[t[21]] & 15) << 4 | s[t[22]] >> 1, i[14] = (s[t[22]] & 1) << 7 | s[t[23]] << 2 | s[t[24]] >> 3, i[15] = (s[t[24]] & 7) << 5 | s[t[25]], i;
|
|
320
|
-
}
|
|
321
|
-
function qe(e) {
|
|
322
|
-
if (e.length > 63)
|
|
323
|
-
return !1;
|
|
324
|
-
let n, t, i;
|
|
325
|
-
for (t = 0, i = e.length; t < i; t += 1) {
|
|
326
|
-
n = e.charCodeAt(t);
|
|
327
|
-
const c = n > 96 && n < 123, m = n === 95;
|
|
328
|
-
if ((t === 0 || t === i - 1) && !c || !(c || m))
|
|
329
|
-
return !1;
|
|
330
|
-
}
|
|
331
|
-
return !0;
|
|
332
|
-
}
|
|
333
|
-
var Ne = class extends Error {
|
|
334
|
-
constructor(e) {
|
|
335
|
-
super(`Invalid prefix "${e}". Must be at most 63 ASCII letters [a-z_]`), this.name = "InvalidPrefixError";
|
|
336
|
-
}
|
|
337
|
-
}, Me = class extends Error {
|
|
338
|
-
constructor(e, n) {
|
|
339
|
-
super(`Invalid TypeId. Prefix mismatch. Expected ${e}, got ${n}`), this.name = "PrefixMismatchError";
|
|
340
|
-
}
|
|
341
|
-
}, Be = class extends Error {
|
|
342
|
-
constructor(e) {
|
|
343
|
-
super(`Invalid TypeId. Prefix cannot be empty when there's a separator: ${e}`), this.name = "EmptyPrefixError";
|
|
344
|
-
}
|
|
345
|
-
}, Le = class extends Error {
|
|
346
|
-
constructor(e) {
|
|
347
|
-
super(`Invalid length. Suffix should have 26 characters, got ${e}`), this.name = "InvalidSuffixLengthError";
|
|
348
|
-
}
|
|
349
|
-
}, He = class extends Error {
|
|
350
|
-
constructor(e) {
|
|
351
|
-
super(`Invalid suffix. First character "${e}" must be in the range [0-7]`), this.name = "InvalidSuffixCharacterError";
|
|
352
|
-
}
|
|
353
|
-
}, Ge = class extends Error {
|
|
354
|
-
constructor(e, n) {
|
|
355
|
-
super(`Cannot convert TypeID of type ${e} to type ${n}`), this.name = "TypeIDConversionError";
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
function Se(e = "", n = "") {
|
|
359
|
-
if (!qe(e))
|
|
360
|
-
throw new Ne(e);
|
|
361
|
-
let t;
|
|
362
|
-
if (n)
|
|
363
|
-
t = n;
|
|
364
|
-
else {
|
|
365
|
-
const i = new Uint8Array(16);
|
|
366
|
-
Re(void 0, i), t = ie(i);
|
|
367
|
-
}
|
|
368
|
-
if (t.length !== 26)
|
|
369
|
-
throw new Le(t.length);
|
|
370
|
-
if (t[0] > "7")
|
|
371
|
-
throw new He(t[0]);
|
|
372
|
-
return xe(t), e === "" ? t : `${e}_${t}`;
|
|
373
|
-
}
|
|
374
|
-
function Ke(e, n) {
|
|
375
|
-
let t, i;
|
|
376
|
-
const c = e.lastIndexOf("_");
|
|
377
|
-
if (c === -1)
|
|
378
|
-
t = "", i = e;
|
|
379
|
-
else if (t = e.substring(0, c), i = e.substring(c + 1), !t)
|
|
380
|
-
throw new Be(e);
|
|
381
|
-
if (!i)
|
|
382
|
-
throw new Le(0);
|
|
383
|
-
if (n && t !== n)
|
|
384
|
-
throw new Me(n, t);
|
|
385
|
-
return Se(t, i);
|
|
386
|
-
}
|
|
387
|
-
function ge(e) {
|
|
388
|
-
const n = e.lastIndexOf("_");
|
|
389
|
-
return n === -1 ? "" : e.substring(0, n);
|
|
390
|
-
}
|
|
391
|
-
function ve(e) {
|
|
392
|
-
const n = e.lastIndexOf("_");
|
|
393
|
-
return n === -1 ? e : e.substring(n + 1);
|
|
394
|
-
}
|
|
395
|
-
var D = class {
|
|
396
|
-
constructor(e, n = "") {
|
|
397
|
-
this.prefix = e, this.suffix = n;
|
|
398
|
-
const t = Se(e, n);
|
|
399
|
-
this.prefix = ge(t), this.suffix = ve(t);
|
|
400
|
-
}
|
|
401
|
-
getType() {
|
|
402
|
-
return this.prefix;
|
|
403
|
-
}
|
|
404
|
-
getSuffix() {
|
|
405
|
-
return this.suffix;
|
|
406
|
-
}
|
|
407
|
-
asType(e) {
|
|
408
|
-
const n = this;
|
|
409
|
-
if (n.prefix !== e)
|
|
410
|
-
throw new Ge(n.prefix, e);
|
|
411
|
-
return n;
|
|
412
|
-
}
|
|
413
|
-
toUUIDBytes() {
|
|
414
|
-
return xe(this.suffix);
|
|
415
|
-
}
|
|
416
|
-
toUUID() {
|
|
417
|
-
return Pe(this.toUUIDBytes());
|
|
418
|
-
}
|
|
419
|
-
toString() {
|
|
420
|
-
return this.prefix === "" ? this.suffix : `${this.prefix}_${this.suffix}`;
|
|
421
|
-
}
|
|
422
|
-
static fromString(e, n) {
|
|
423
|
-
const t = Ke(e, n);
|
|
424
|
-
return new D(ge(t), ve(t));
|
|
425
|
-
}
|
|
426
|
-
static fromUUIDBytes(e, n) {
|
|
427
|
-
const t = ie(n);
|
|
428
|
-
return new D(e, t);
|
|
429
|
-
}
|
|
430
|
-
static fromUUID(e, n) {
|
|
431
|
-
const t = ie(Ve(n));
|
|
432
|
-
return new D(e, t);
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
function se(e = "", n = "") {
|
|
436
|
-
return new D(e, n);
|
|
437
|
-
}
|
|
438
|
-
function Je() {
|
|
439
|
-
return se("lse");
|
|
440
|
-
}
|
|
441
|
-
function pe(e) {
|
|
442
|
-
return D.fromString(e, "lse");
|
|
443
|
-
}
|
|
444
|
-
function K() {
|
|
445
|
-
return se("lev");
|
|
446
|
-
}
|
|
447
|
-
function Xe(e) {
|
|
448
|
-
return D.fromString(e, "lev");
|
|
449
|
-
}
|
|
450
|
-
function Qe() {
|
|
451
|
-
return se("lst");
|
|
452
|
-
}
|
|
453
|
-
function Oe(e) {
|
|
454
|
-
return D.fromString(e, "lst");
|
|
455
|
-
}
|
|
456
|
-
function We(e) {
|
|
457
|
-
const n = new Date(e);
|
|
458
|
-
if (Number.isNaN(n.getTime()))
|
|
459
|
-
throw new Q(`Invalid Timestamp: "${e}" does not parse as a valid date`);
|
|
460
|
-
return e;
|
|
461
|
-
}
|
|
462
|
-
function J() {
|
|
463
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
464
|
-
}
|
|
465
|
-
class W {
|
|
466
|
-
#t;
|
|
467
|
-
#i;
|
|
468
|
-
#n;
|
|
469
|
-
#e;
|
|
470
|
-
constructor(n) {
|
|
471
|
-
this.#t = n, this.#i = void 0, this.#n = /* @__PURE__ */ new Map(), this.#e = [];
|
|
472
|
-
}
|
|
473
|
-
get id() {
|
|
474
|
-
return this.#t;
|
|
475
|
-
}
|
|
476
|
-
get title() {
|
|
477
|
-
return this.#i;
|
|
478
|
-
}
|
|
479
|
-
get elements() {
|
|
480
|
-
return [...this.#n.values()];
|
|
481
|
-
}
|
|
482
|
-
// ─────────────────────────────────────────────── Factory
|
|
483
|
-
/**
|
|
484
|
-
* Creates a new List aggregate and emits ListCreated.
|
|
485
|
-
* Generates a ListId if not provided in the command.
|
|
486
|
-
*/
|
|
487
|
-
static create(n) {
|
|
488
|
-
const t = n.listId ?? Qe(), i = new W(t), c = {
|
|
489
|
-
type: "ListCreated",
|
|
490
|
-
listEventId: K(),
|
|
491
|
-
listId: t,
|
|
492
|
-
actorId: n.actorId,
|
|
493
|
-
timestamp: J(),
|
|
494
|
-
...n.title !== void 0 ? { title: n.title } : {}
|
|
495
|
-
};
|
|
496
|
-
return i.#r(c), i.#e.push(c), { list: i, event: c };
|
|
497
|
-
}
|
|
498
|
-
// ─────────────────────────────────────────────── Rehydration
|
|
499
|
-
/**
|
|
500
|
-
* Reconstructs a List from its full event log.
|
|
501
|
-
* The resulting List has no uncommitted events.
|
|
502
|
-
*/
|
|
503
|
-
static rehydrate(n, t) {
|
|
504
|
-
const i = new W(n);
|
|
505
|
-
for (const c of t)
|
|
506
|
-
i.#r(c);
|
|
507
|
-
return i;
|
|
508
|
-
}
|
|
509
|
-
// ─────────────────────────────────────────────── Command Handlers
|
|
510
|
-
/**
|
|
511
|
-
* Appends a new ListElement to the List.
|
|
512
|
-
* Invariant: content must be non-empty after trimming (enforced at ListElementContent creation).
|
|
513
|
-
*/
|
|
514
|
-
addListElement(n) {
|
|
515
|
-
const t = Je(), i = {
|
|
516
|
-
type: "ListElementAdded",
|
|
517
|
-
listEventId: K(),
|
|
518
|
-
listId: this.#t,
|
|
519
|
-
actorId: n.actorId,
|
|
520
|
-
timestamp: J(),
|
|
521
|
-
listElementId: t,
|
|
522
|
-
content: n.content
|
|
523
|
-
};
|
|
524
|
-
return this.#r(i), this.#e.push(i), i;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Removes a ListElement from the List by its stable identity.
|
|
528
|
-
* Invariant: the ListElementId must exist in the current elements.
|
|
529
|
-
* Throws ListElementNotFoundError if not found.
|
|
530
|
-
*/
|
|
531
|
-
deleteListElement(n) {
|
|
532
|
-
const t = n.listElementId.toString();
|
|
533
|
-
if (!this.#n.has(t))
|
|
534
|
-
throw new ke(t);
|
|
535
|
-
const i = {
|
|
536
|
-
type: "ListElementDeleted",
|
|
537
|
-
listEventId: K(),
|
|
538
|
-
listId: this.#t,
|
|
539
|
-
actorId: n.actorId,
|
|
540
|
-
timestamp: J(),
|
|
541
|
-
listElementId: n.listElementId
|
|
542
|
-
};
|
|
543
|
-
return this.#r(i), this.#e.push(i), i;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Emits a ListExported audit event.
|
|
547
|
-
* Export is always valid — no invariants to check.
|
|
548
|
-
*/
|
|
549
|
-
exportListDocument(n) {
|
|
550
|
-
const t = {
|
|
551
|
-
type: "ListExported",
|
|
552
|
-
listEventId: K(),
|
|
553
|
-
listId: this.#t,
|
|
554
|
-
actorId: n.actorId,
|
|
555
|
-
timestamp: J(),
|
|
556
|
-
format: "json-ld"
|
|
557
|
-
};
|
|
558
|
-
return this.#r(t), this.#e.push(t), t;
|
|
559
|
-
}
|
|
560
|
-
// ─────────────────────────────────────────────── Uncommitted Events
|
|
561
|
-
/** Returns all events emitted since the last load/save. */
|
|
562
|
-
getUncommittedEvents() {
|
|
563
|
-
return [...this.#e];
|
|
564
|
-
}
|
|
565
|
-
/** Clears uncommitted events after they have been persisted. */
|
|
566
|
-
markEventsAsCommitted() {
|
|
567
|
-
this.#e.length = 0;
|
|
568
|
-
}
|
|
569
|
-
// ─────────────────────────────────────────────── Private State Mutation
|
|
570
|
-
/** Mutates state from a single event. Used by both command handlers and rehydration. */
|
|
571
|
-
#r(n) {
|
|
572
|
-
({
|
|
573
|
-
ListCreated: (i) => {
|
|
574
|
-
this.#i = i.title;
|
|
575
|
-
},
|
|
576
|
-
ListElementAdded: (i) => {
|
|
577
|
-
this.#n.set(i.listElementId.toString(), {
|
|
578
|
-
id: i.listElementId,
|
|
579
|
-
content: i.content,
|
|
580
|
-
addedAt: i.timestamp
|
|
581
|
-
});
|
|
582
|
-
},
|
|
583
|
-
ListElementDeleted: (i) => {
|
|
584
|
-
this.#n.delete(i.listElementId.toString());
|
|
585
|
-
},
|
|
586
|
-
// Audit-only event — no state change
|
|
587
|
-
ListExported: (i) => {
|
|
588
|
-
}
|
|
589
|
-
})[n.type](n);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function Ze(e) {
|
|
593
|
-
return D.fromString(e, "act");
|
|
594
|
-
}
|
|
595
|
-
const be = 2e3;
|
|
596
|
-
function Ye(e) {
|
|
597
|
-
const n = e.trim();
|
|
598
|
-
if (n.length === 0)
|
|
599
|
-
throw new Q("ListElementContent cannot be empty");
|
|
600
|
-
if (n.length > be)
|
|
601
|
-
throw new Q(`ListElementContent exceeds maximum length of ${be} characters`);
|
|
602
|
-
return n;
|
|
603
|
-
}
|
|
604
|
-
const et = {
|
|
605
|
-
"@vocab": "https://schema.org/",
|
|
606
|
-
alistigo: "https://alistigo.ai/vocab/"
|
|
607
|
-
}, tt = "1.0.0";
|
|
608
|
-
function nt(e) {
|
|
609
|
-
const n = {
|
|
610
|
-
"alistigo:listEventId": e.listEventId.toString(),
|
|
611
|
-
"alistigo:listId": e.listId.toString(),
|
|
612
|
-
"alistigo:actorId": e.actorId.toString(),
|
|
613
|
-
"alistigo:timestamp": e.timestamp
|
|
614
|
-
};
|
|
615
|
-
switch (e.type) {
|
|
616
|
-
case "ListCreated":
|
|
617
|
-
return {
|
|
618
|
-
...n,
|
|
619
|
-
"alistigo:eventType": "ListCreated",
|
|
620
|
-
...e.title !== void 0 ? { name: e.title } : {}
|
|
621
|
-
};
|
|
622
|
-
case "ListElementAdded":
|
|
623
|
-
return {
|
|
624
|
-
...n,
|
|
625
|
-
"alistigo:eventType": "ListElementAdded",
|
|
626
|
-
"alistigo:listElementId": e.listElementId.toString(),
|
|
627
|
-
name: e.content
|
|
628
|
-
};
|
|
629
|
-
case "ListElementDeleted":
|
|
630
|
-
return {
|
|
631
|
-
...n,
|
|
632
|
-
"alistigo:eventType": "ListElementDeleted",
|
|
633
|
-
"alistigo:listElementId": e.listElementId.toString()
|
|
634
|
-
};
|
|
635
|
-
case "ListExported":
|
|
636
|
-
return {
|
|
637
|
-
...n,
|
|
638
|
-
"alistigo:eventType": "ListExported"
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
function rt(e) {
|
|
643
|
-
const n = {
|
|
644
|
-
listEventId: Xe(e["alistigo:listEventId"]),
|
|
645
|
-
listId: Oe(e["alistigo:listId"]),
|
|
646
|
-
actorId: Ze(e["alistigo:actorId"]),
|
|
647
|
-
timestamp: We(e["alistigo:timestamp"])
|
|
648
|
-
};
|
|
649
|
-
switch (e["alistigo:eventType"]) {
|
|
650
|
-
case "ListCreated": {
|
|
651
|
-
const t = e;
|
|
652
|
-
return {
|
|
653
|
-
...n,
|
|
654
|
-
type: "ListCreated",
|
|
655
|
-
...t.name !== void 0 ? { title: t.name } : {}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
case "ListElementAdded": {
|
|
659
|
-
const t = e;
|
|
660
|
-
return {
|
|
661
|
-
...n,
|
|
662
|
-
type: "ListElementAdded",
|
|
663
|
-
listElementId: pe(t["alistigo:listElementId"]),
|
|
664
|
-
content: Ye(t.name)
|
|
665
|
-
};
|
|
666
|
-
}
|
|
667
|
-
case "ListElementDeleted":
|
|
668
|
-
return {
|
|
669
|
-
...n,
|
|
670
|
-
type: "ListElementDeleted",
|
|
671
|
-
listElementId: pe(e["alistigo:listElementId"])
|
|
672
|
-
};
|
|
673
|
-
case "ListExported":
|
|
674
|
-
return {
|
|
675
|
-
...n,
|
|
676
|
-
type: "ListExported",
|
|
677
|
-
format: "json-ld"
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
const ye = {
|
|
682
|
-
serialize(e, n) {
|
|
683
|
-
const t = n?.["alistigo:listEventLog"] ?? [], i = e.getUncommittedEvents().map(nt), c = e.elements.map((_, I) => ({
|
|
684
|
-
"@type": "ListItem",
|
|
685
|
-
"alistigo:listElementId": _.id.toString(),
|
|
686
|
-
position: I + 1,
|
|
687
|
-
name: _.content
|
|
688
|
-
})), m = {
|
|
689
|
-
"@context": et,
|
|
690
|
-
"@type": "ItemList",
|
|
691
|
-
"alistigo:listId": e.id.toString(),
|
|
692
|
-
"alistigo:schemaVersion": tt,
|
|
693
|
-
itemListElement: c,
|
|
694
|
-
"alistigo:listEventLog": [...t, ...i]
|
|
695
|
-
};
|
|
696
|
-
return e.title !== void 0 && (m.name = e.title), m;
|
|
697
|
-
},
|
|
698
|
-
deserialize(e) {
|
|
699
|
-
const n = Oe(e["alistigo:listId"]), t = e["alistigo:listEventLog"].map(rt);
|
|
700
|
-
return W.rehydrate(n, t);
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
function it(e) {
|
|
704
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
705
|
-
}
|
|
706
|
-
var F = { exports: {} }, re, Ee;
|
|
707
|
-
function st() {
|
|
708
|
-
if (Ee) return re;
|
|
709
|
-
Ee = 1;
|
|
710
|
-
function e(t) {
|
|
1
|
+
function le(d) {
|
|
2
|
+
return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
|
|
3
|
+
}
|
|
4
|
+
var V = { exports: {} }, U, Z;
|
|
5
|
+
function ce() {
|
|
6
|
+
if (Z) return U;
|
|
7
|
+
Z = 1;
|
|
8
|
+
function d(i) {
|
|
711
9
|
try {
|
|
712
|
-
return JSON.stringify(
|
|
10
|
+
return JSON.stringify(i);
|
|
713
11
|
} catch {
|
|
714
12
|
return '"[Circular]"';
|
|
715
13
|
}
|
|
716
14
|
}
|
|
717
|
-
|
|
718
|
-
function
|
|
719
|
-
var
|
|
720
|
-
if (typeof
|
|
721
|
-
var
|
|
722
|
-
if (
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
for (var
|
|
726
|
-
|
|
727
|
-
return
|
|
15
|
+
U = s;
|
|
16
|
+
function s(i, c, m) {
|
|
17
|
+
var E = m && m.stringify || d, q = 1;
|
|
18
|
+
if (typeof i == "object" && i !== null) {
|
|
19
|
+
var z = c.length + q;
|
|
20
|
+
if (z === 1) return i;
|
|
21
|
+
var C = new Array(z);
|
|
22
|
+
C[0] = E(i);
|
|
23
|
+
for (var k = 1; k < z; k++)
|
|
24
|
+
C[k] = E(c[k]);
|
|
25
|
+
return C.join(" ");
|
|
728
26
|
}
|
|
729
|
-
if (typeof
|
|
730
|
-
return
|
|
731
|
-
var
|
|
732
|
-
if (
|
|
733
|
-
for (var
|
|
734
|
-
if (
|
|
735
|
-
switch (
|
|
27
|
+
if (typeof i != "string")
|
|
28
|
+
return i;
|
|
29
|
+
var w = c.length;
|
|
30
|
+
if (w === 0) return i;
|
|
31
|
+
for (var v = "", h = 1 - q, u = -1, j = i && i.length || 0, l = 0; l < j; ) {
|
|
32
|
+
if (i.charCodeAt(l) === 37 && l + 1 < j) {
|
|
33
|
+
switch (u = u > -1 ? u : 0, i.charCodeAt(l + 1)) {
|
|
736
34
|
case 100:
|
|
737
35
|
// 'd'
|
|
738
36
|
case 102:
|
|
739
|
-
if (
|
|
740
|
-
|
|
37
|
+
if (h >= w || c[h] == null) break;
|
|
38
|
+
u < l && (v += i.slice(u, l)), v += Number(c[h]), u = l + 2, l++;
|
|
741
39
|
break;
|
|
742
40
|
case 105:
|
|
743
|
-
if (
|
|
744
|
-
|
|
41
|
+
if (h >= w || c[h] == null) break;
|
|
42
|
+
u < l && (v += i.slice(u, l)), v += Math.floor(Number(c[h])), u = l + 2, l++;
|
|
745
43
|
break;
|
|
746
44
|
case 79:
|
|
747
45
|
// 'O'
|
|
748
46
|
case 111:
|
|
749
47
|
// 'o'
|
|
750
48
|
case 106:
|
|
751
|
-
if (
|
|
752
|
-
|
|
753
|
-
var
|
|
754
|
-
if (
|
|
755
|
-
|
|
49
|
+
if (h >= w || c[h] === void 0) break;
|
|
50
|
+
u < l && (v += i.slice(u, l));
|
|
51
|
+
var M = typeof c[h];
|
|
52
|
+
if (M === "string") {
|
|
53
|
+
v += "'" + c[h] + "'", u = l + 2, l++;
|
|
756
54
|
break;
|
|
757
55
|
}
|
|
758
|
-
if (
|
|
759
|
-
|
|
56
|
+
if (M === "function") {
|
|
57
|
+
v += c[h].name || "<anonymous>", u = l + 2, l++;
|
|
760
58
|
break;
|
|
761
59
|
}
|
|
762
|
-
|
|
60
|
+
v += E(c[h]), u = l + 2, l++;
|
|
763
61
|
break;
|
|
764
62
|
case 115:
|
|
765
|
-
if (
|
|
63
|
+
if (h >= w)
|
|
766
64
|
break;
|
|
767
|
-
|
|
65
|
+
u < l && (v += i.slice(u, l)), v += String(c[h]), u = l + 2, l++;
|
|
768
66
|
break;
|
|
769
67
|
case 37:
|
|
770
|
-
|
|
68
|
+
u < l && (v += i.slice(u, l)), v += "%", u = l + 2, l++, h--;
|
|
771
69
|
break;
|
|
772
70
|
}
|
|
773
|
-
++
|
|
71
|
+
++h;
|
|
774
72
|
}
|
|
775
|
-
++
|
|
73
|
+
++l;
|
|
776
74
|
}
|
|
777
|
-
return
|
|
778
|
-
}
|
|
779
|
-
return
|
|
780
|
-
}
|
|
781
|
-
var
|
|
782
|
-
function
|
|
783
|
-
if (
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
mapHttpRequest:
|
|
789
|
-
mapHttpResponse:
|
|
790
|
-
wrapRequestSerializer:
|
|
791
|
-
wrapResponseSerializer:
|
|
792
|
-
wrapErrorSerializer:
|
|
793
|
-
req:
|
|
794
|
-
res:
|
|
795
|
-
err:
|
|
796
|
-
errWithCause:
|
|
75
|
+
return u === -1 ? i : (u < j && (v += i.slice(u)), v);
|
|
76
|
+
}
|
|
77
|
+
return U;
|
|
78
|
+
}
|
|
79
|
+
var ee;
|
|
80
|
+
function ue() {
|
|
81
|
+
if (ee) return V.exports;
|
|
82
|
+
ee = 1;
|
|
83
|
+
const d = ce();
|
|
84
|
+
V.exports = w;
|
|
85
|
+
const s = oe().console || {}, i = {
|
|
86
|
+
mapHttpRequest: R,
|
|
87
|
+
mapHttpResponse: R,
|
|
88
|
+
wrapRequestSerializer: D,
|
|
89
|
+
wrapResponseSerializer: D,
|
|
90
|
+
wrapErrorSerializer: D,
|
|
91
|
+
req: R,
|
|
92
|
+
res: R,
|
|
93
|
+
err: J,
|
|
94
|
+
errWithCause: J
|
|
797
95
|
};
|
|
798
|
-
function
|
|
799
|
-
return
|
|
96
|
+
function c(e, t) {
|
|
97
|
+
return e === "silent" ? 1 / 0 : t.levels.values[e];
|
|
800
98
|
}
|
|
801
|
-
const
|
|
99
|
+
const m = /* @__PURE__ */ Symbol("pino.logFuncs"), E = /* @__PURE__ */ Symbol("pino.hierarchy"), q = {
|
|
802
100
|
error: "log",
|
|
803
101
|
fatal: "error",
|
|
804
102
|
warn: "error",
|
|
@@ -806,110 +104,110 @@ function ot() {
|
|
|
806
104
|
debug: "log",
|
|
807
105
|
trace: "log"
|
|
808
106
|
};
|
|
809
|
-
function
|
|
810
|
-
const
|
|
811
|
-
logger:
|
|
812
|
-
parent:
|
|
107
|
+
function z(e, t) {
|
|
108
|
+
const n = {
|
|
109
|
+
logger: t,
|
|
110
|
+
parent: e[E]
|
|
813
111
|
};
|
|
814
|
-
|
|
815
|
-
}
|
|
816
|
-
function E(r, o, l) {
|
|
817
|
-
const u = {};
|
|
818
|
-
o.forEach((f) => {
|
|
819
|
-
u[f] = l[f] ? l[f] : n[f] || n[_[f] || "log"] || U;
|
|
820
|
-
}), r[c] = u;
|
|
112
|
+
t[E] = n;
|
|
821
113
|
}
|
|
822
|
-
function
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
114
|
+
function C(e, t, n) {
|
|
115
|
+
const a = {};
|
|
116
|
+
t.forEach((o) => {
|
|
117
|
+
a[o] = n[o] ? n[o] : s[o] || s[q[o] || "log"] || L;
|
|
118
|
+
}), e[m] = a;
|
|
119
|
+
}
|
|
120
|
+
function k(e, t) {
|
|
121
|
+
return Array.isArray(e) ? e.filter(function(a) {
|
|
122
|
+
return a !== "!stdSerializers.err";
|
|
123
|
+
}) : e === !0 ? Object.keys(t) : !1;
|
|
124
|
+
}
|
|
125
|
+
function w(e) {
|
|
126
|
+
e = e || {}, e.browser = e.browser || {};
|
|
127
|
+
const t = e.browser.transmit;
|
|
128
|
+
if (t && typeof t.send != "function")
|
|
831
129
|
throw Error("pino: transmit option must have a send function");
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
let
|
|
836
|
-
Array.isArray(
|
|
837
|
-
const
|
|
838
|
-
typeof
|
|
839
|
-
|
|
840
|
-
}), (
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
get:
|
|
844
|
-
}), Object.defineProperty(
|
|
845
|
-
get:
|
|
846
|
-
set:
|
|
130
|
+
const n = e.browser.write || s;
|
|
131
|
+
e.browser.write && (e.browser.asObject = !0);
|
|
132
|
+
const a = e.serializers || {}, o = k(e.browser.serialize, a);
|
|
133
|
+
let g = e.browser.serialize;
|
|
134
|
+
Array.isArray(e.browser.serialize) && e.browser.serialize.indexOf("!stdSerializers.err") > -1 && (g = !1);
|
|
135
|
+
const p = Object.keys(e.customLevels || {}), f = ["error", "fatal", "warn", "info", "debug", "trace"].concat(p);
|
|
136
|
+
typeof n == "function" && f.forEach(function(O) {
|
|
137
|
+
n[O] = n;
|
|
138
|
+
}), (e.enabled === !1 || e.browser.disabled) && (e.level = "silent");
|
|
139
|
+
const y = e.level || "info", r = Object.create(n);
|
|
140
|
+
r.log || (r.log = L), C(r, f, n), z({}, r), Object.defineProperty(r, "levelVal", {
|
|
141
|
+
get: S
|
|
142
|
+
}), Object.defineProperty(r, "level", {
|
|
143
|
+
get: G,
|
|
144
|
+
set: x
|
|
847
145
|
});
|
|
848
|
-
const
|
|
849
|
-
transmit:
|
|
850
|
-
serialize:
|
|
851
|
-
asObject:
|
|
852
|
-
asObjectBindingsOnly:
|
|
853
|
-
formatters:
|
|
854
|
-
levels:
|
|
855
|
-
timestamp:
|
|
856
|
-
messageKey:
|
|
857
|
-
onChild:
|
|
146
|
+
const b = {
|
|
147
|
+
transmit: t,
|
|
148
|
+
serialize: o,
|
|
149
|
+
asObject: e.browser.asObject,
|
|
150
|
+
asObjectBindingsOnly: e.browser.asObjectBindingsOnly,
|
|
151
|
+
formatters: e.browser.formatters,
|
|
152
|
+
levels: f,
|
|
153
|
+
timestamp: ie(e),
|
|
154
|
+
messageKey: e.messageKey || "msg",
|
|
155
|
+
onChild: e.onChild || L
|
|
858
156
|
};
|
|
859
|
-
|
|
860
|
-
return this.levels.values[
|
|
861
|
-
},
|
|
862
|
-
return
|
|
863
|
-
},
|
|
864
|
-
function
|
|
865
|
-
return
|
|
157
|
+
r.levels = v(e), r.level = y, r.isLevelEnabled = function(O) {
|
|
158
|
+
return this.levels.values[O] ? this.levels.values[O] >= this.levels.values[this.level] : !1;
|
|
159
|
+
}, r.setMaxListeners = r.getMaxListeners = r.emit = r.addListener = r.on = r.prependListener = r.once = r.prependOnceListener = r.removeListener = r.removeAllListeners = r.listeners = r.listenerCount = r.eventNames = r.write = r.flush = L, r.serializers = a, r._serialize = o, r._stdErrSerialize = g, r.child = function(...O) {
|
|
160
|
+
return Q.call(this, b, ...O);
|
|
161
|
+
}, t && (r._logEvent = N());
|
|
162
|
+
function S() {
|
|
163
|
+
return c(this.level, this);
|
|
866
164
|
}
|
|
867
|
-
function
|
|
165
|
+
function G() {
|
|
868
166
|
return this._level;
|
|
869
167
|
}
|
|
870
|
-
function
|
|
871
|
-
if (
|
|
872
|
-
throw Error("unknown level " +
|
|
873
|
-
this._level =
|
|
874
|
-
|
|
168
|
+
function x(O) {
|
|
169
|
+
if (O !== "silent" && !this.levels.values[O])
|
|
170
|
+
throw Error("unknown level " + O);
|
|
171
|
+
this._level = O, j(this, b, r, "error"), j(this, b, r, "fatal"), j(this, b, r, "warn"), j(this, b, r, "info"), j(this, b, r, "debug"), j(this, b, r, "trace"), p.forEach((_) => {
|
|
172
|
+
j(this, b, r, _);
|
|
875
173
|
});
|
|
876
174
|
}
|
|
877
|
-
function
|
|
878
|
-
if (!
|
|
175
|
+
function Q(O, _, A) {
|
|
176
|
+
if (!_)
|
|
879
177
|
throw new Error("missing bindings for child Pino");
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
if (
|
|
883
|
-
var B = Object.assign({},
|
|
884
|
-
delete
|
|
178
|
+
A = A || {}, o && _.serializers && (A.serializers = _.serializers);
|
|
179
|
+
const $ = A.serializers;
|
|
180
|
+
if (o && $) {
|
|
181
|
+
var B = Object.assign({}, a, $), X = e.browser.serialize === !0 ? Object.keys(B) : o;
|
|
182
|
+
delete _.serializers, K([_], X, B, this._stdErrSerialize);
|
|
885
183
|
}
|
|
886
|
-
function
|
|
887
|
-
this._childLevel = (
|
|
888
|
-
[].concat(
|
|
184
|
+
function Y(I) {
|
|
185
|
+
this._childLevel = (I._childLevel | 0) + 1, this.bindings = _, B && (this.serializers = B, this._serialize = X), t && (this._logEvent = N(
|
|
186
|
+
[].concat(I._logEvent.bindings, _)
|
|
889
187
|
));
|
|
890
188
|
}
|
|
891
|
-
|
|
892
|
-
const
|
|
893
|
-
return
|
|
894
|
-
return
|
|
895
|
-
},
|
|
189
|
+
Y.prototype = this;
|
|
190
|
+
const F = new Y(this);
|
|
191
|
+
return z(this, F), F.child = function(...I) {
|
|
192
|
+
return Q.call(this, O, ...I);
|
|
193
|
+
}, F.level = A.level || this.level, O.onChild(F), F;
|
|
896
194
|
}
|
|
897
|
-
return
|
|
195
|
+
return r;
|
|
898
196
|
}
|
|
899
|
-
function
|
|
900
|
-
const
|
|
197
|
+
function v(e) {
|
|
198
|
+
const t = e.customLevels || {}, n = Object.assign({}, w.levels.values, t), a = Object.assign({}, w.levels.labels, h(t));
|
|
901
199
|
return {
|
|
902
|
-
values:
|
|
903
|
-
labels:
|
|
200
|
+
values: n,
|
|
201
|
+
labels: a
|
|
904
202
|
};
|
|
905
203
|
}
|
|
906
|
-
function
|
|
907
|
-
const
|
|
908
|
-
return Object.keys(
|
|
909
|
-
|
|
910
|
-
}),
|
|
204
|
+
function h(e) {
|
|
205
|
+
const t = {};
|
|
206
|
+
return Object.keys(e).forEach(function(n) {
|
|
207
|
+
t[e[n]] = n;
|
|
208
|
+
}), t;
|
|
911
209
|
}
|
|
912
|
-
|
|
210
|
+
w.levels = {
|
|
913
211
|
values: {
|
|
914
212
|
fatal: 60,
|
|
915
213
|
error: 50,
|
|
@@ -926,146 +224,146 @@ function ot() {
|
|
|
926
224
|
50: "error",
|
|
927
225
|
60: "fatal"
|
|
928
226
|
}
|
|
929
|
-
},
|
|
930
|
-
function
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
let
|
|
934
|
-
for (;
|
|
935
|
-
|
|
936
|
-
return
|
|
937
|
-
}
|
|
938
|
-
function
|
|
939
|
-
if (Object.defineProperty(
|
|
940
|
-
value:
|
|
227
|
+
}, w.stdSerializers = i, w.stdTimeFunctions = Object.assign({}, { nullTime: W, epochTime: H, unixTime: se, isoTime: ae });
|
|
228
|
+
function u(e) {
|
|
229
|
+
const t = [];
|
|
230
|
+
e.bindings && t.push(e.bindings);
|
|
231
|
+
let n = e[E];
|
|
232
|
+
for (; n.parent; )
|
|
233
|
+
n = n.parent, n.logger.bindings && t.push(n.logger.bindings);
|
|
234
|
+
return t.reverse();
|
|
235
|
+
}
|
|
236
|
+
function j(e, t, n, a) {
|
|
237
|
+
if (Object.defineProperty(e, a, {
|
|
238
|
+
value: c(e.level, n) > c(a, n) ? L : n[m][a],
|
|
941
239
|
writable: !0,
|
|
942
240
|
enumerable: !0,
|
|
943
241
|
configurable: !0
|
|
944
|
-
}),
|
|
945
|
-
if (!
|
|
946
|
-
const
|
|
947
|
-
if (
|
|
242
|
+
}), e[a] === L) {
|
|
243
|
+
if (!t.transmit) return;
|
|
244
|
+
const g = t.transmit.level || e.level, p = c(g, n);
|
|
245
|
+
if (c(a, n) < p) return;
|
|
948
246
|
}
|
|
949
|
-
|
|
950
|
-
const
|
|
951
|
-
|
|
247
|
+
e[a] = M(e, t, n, a);
|
|
248
|
+
const o = u(e);
|
|
249
|
+
o.length !== 0 && (e[a] = l(o, e[a]));
|
|
952
250
|
}
|
|
953
|
-
function
|
|
251
|
+
function l(e, t) {
|
|
954
252
|
return function() {
|
|
955
|
-
return
|
|
253
|
+
return t.apply(this, [...e, ...arguments]);
|
|
956
254
|
};
|
|
957
255
|
}
|
|
958
|
-
function
|
|
959
|
-
return /* @__PURE__ */ (function(
|
|
256
|
+
function M(e, t, n, a) {
|
|
257
|
+
return /* @__PURE__ */ (function(o) {
|
|
960
258
|
return function() {
|
|
961
|
-
const
|
|
962
|
-
for (var
|
|
963
|
-
var
|
|
964
|
-
if (
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
|
|
968
|
-
ts:
|
|
969
|
-
methodLevel:
|
|
970
|
-
methodValue:
|
|
971
|
-
transmitValue:
|
|
972
|
-
send:
|
|
973
|
-
val:
|
|
974
|
-
},
|
|
259
|
+
const p = t.timestamp(), f = new Array(arguments.length), y = Object.getPrototypeOf && Object.getPrototypeOf(this) === s ? s : this;
|
|
260
|
+
for (var r = 0; r < f.length; r++) f[r] = arguments[r];
|
|
261
|
+
var b = !1;
|
|
262
|
+
if (t.serialize && (K(f, this._serialize, this.serializers, this._stdErrSerialize), b = !0), t.asObject || t.formatters ? o.call(y, ...re(this, a, f, p, t)) : o.apply(y, f), t.transmit) {
|
|
263
|
+
const S = t.transmit.level || e._level, G = c(S, n), x = c(a, n);
|
|
264
|
+
if (x < G) return;
|
|
265
|
+
ne(this, {
|
|
266
|
+
ts: p,
|
|
267
|
+
methodLevel: a,
|
|
268
|
+
methodValue: x,
|
|
269
|
+
transmitValue: n.levels.values[t.transmit.level || e._level],
|
|
270
|
+
send: t.transmit.send,
|
|
271
|
+
val: c(e._level, n)
|
|
272
|
+
}, f, b);
|
|
975
273
|
}
|
|
976
274
|
};
|
|
977
|
-
})(
|
|
275
|
+
})(e[m][a]);
|
|
978
276
|
}
|
|
979
|
-
function
|
|
277
|
+
function re(e, t, n, a, o) {
|
|
980
278
|
const {
|
|
981
|
-
level:
|
|
982
|
-
log:
|
|
983
|
-
} =
|
|
984
|
-
let
|
|
985
|
-
const
|
|
986
|
-
let
|
|
987
|
-
if (
|
|
988
|
-
const
|
|
989
|
-
Object.assign(
|
|
279
|
+
level: g,
|
|
280
|
+
log: p = (S) => S
|
|
281
|
+
} = o.formatters || {}, f = n.slice();
|
|
282
|
+
let y = f[0];
|
|
283
|
+
const r = {};
|
|
284
|
+
let b = (e._childLevel | 0) + 1;
|
|
285
|
+
if (b < 1 && (b = 1), a && (r.time = a), g) {
|
|
286
|
+
const S = g(t, e.levels.values[t]);
|
|
287
|
+
Object.assign(r, S);
|
|
990
288
|
} else
|
|
991
|
-
|
|
992
|
-
if (
|
|
993
|
-
if (
|
|
994
|
-
for (;
|
|
995
|
-
Object.assign(
|
|
996
|
-
return [
|
|
289
|
+
r.level = e.levels.values[t];
|
|
290
|
+
if (o.asObjectBindingsOnly) {
|
|
291
|
+
if (y !== null && typeof y == "object")
|
|
292
|
+
for (; b-- && typeof f[0] == "object"; )
|
|
293
|
+
Object.assign(r, f.shift());
|
|
294
|
+
return [p(r), ...f];
|
|
997
295
|
} else {
|
|
998
|
-
if (
|
|
999
|
-
for (;
|
|
1000
|
-
Object.assign(
|
|
1001
|
-
|
|
1002
|
-
} else typeof
|
|
1003
|
-
return
|
|
296
|
+
if (y !== null && typeof y == "object") {
|
|
297
|
+
for (; b-- && typeof f[0] == "object"; )
|
|
298
|
+
Object.assign(r, f.shift());
|
|
299
|
+
y = f.length ? d(f.shift(), f) : void 0;
|
|
300
|
+
} else typeof y == "string" && (y = d(f.shift(), f));
|
|
301
|
+
return y !== void 0 && (r[o.messageKey] = y), [p(r)];
|
|
1004
302
|
}
|
|
1005
303
|
}
|
|
1006
|
-
function
|
|
1007
|
-
for (const
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1010
|
-
else if (typeof
|
|
1011
|
-
for (const
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
function
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
),
|
|
1022
|
-
return
|
|
1023
|
-
}),
|
|
1024
|
-
}
|
|
1025
|
-
function
|
|
304
|
+
function K(e, t, n, a) {
|
|
305
|
+
for (const o in e)
|
|
306
|
+
if (a && e[o] instanceof Error)
|
|
307
|
+
e[o] = w.stdSerializers.err(e[o]);
|
|
308
|
+
else if (typeof e[o] == "object" && !Array.isArray(e[o]) && t)
|
|
309
|
+
for (const g in e[o])
|
|
310
|
+
t.indexOf(g) > -1 && g in n && (e[o][g] = n[g](e[o][g]));
|
|
311
|
+
}
|
|
312
|
+
function ne(e, t, n, a = !1) {
|
|
313
|
+
const o = t.send, g = t.ts, p = t.methodLevel, f = t.methodValue, y = t.val, r = e._logEvent.bindings;
|
|
314
|
+
a || K(
|
|
315
|
+
n,
|
|
316
|
+
e._serialize || Object.keys(e.serializers),
|
|
317
|
+
e.serializers,
|
|
318
|
+
e._stdErrSerialize === void 0 ? !0 : e._stdErrSerialize
|
|
319
|
+
), e._logEvent.ts = g, e._logEvent.messages = n.filter(function(b) {
|
|
320
|
+
return r.indexOf(b) === -1;
|
|
321
|
+
}), e._logEvent.level.label = p, e._logEvent.level.value = f, o(p, e._logEvent, y), e._logEvent = N(r);
|
|
322
|
+
}
|
|
323
|
+
function N(e) {
|
|
1026
324
|
return {
|
|
1027
325
|
ts: 0,
|
|
1028
326
|
messages: [],
|
|
1029
|
-
bindings:
|
|
327
|
+
bindings: e || [],
|
|
1030
328
|
level: { label: "", value: 0 }
|
|
1031
329
|
};
|
|
1032
330
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const
|
|
1035
|
-
type:
|
|
1036
|
-
msg:
|
|
1037
|
-
stack:
|
|
331
|
+
function J(e) {
|
|
332
|
+
const t = {
|
|
333
|
+
type: e.constructor.name,
|
|
334
|
+
msg: e.message,
|
|
335
|
+
stack: e.stack
|
|
1038
336
|
};
|
|
1039
|
-
for (const
|
|
1040
|
-
|
|
1041
|
-
return
|
|
337
|
+
for (const n in e)
|
|
338
|
+
t[n] === void 0 && (t[n] = e[n]);
|
|
339
|
+
return t;
|
|
1042
340
|
}
|
|
1043
|
-
function
|
|
1044
|
-
return typeof
|
|
341
|
+
function ie(e) {
|
|
342
|
+
return typeof e.timestamp == "function" ? e.timestamp : e.timestamp === !1 ? W : H;
|
|
1045
343
|
}
|
|
1046
|
-
function
|
|
344
|
+
function R() {
|
|
1047
345
|
return {};
|
|
1048
346
|
}
|
|
1049
|
-
function
|
|
1050
|
-
return
|
|
347
|
+
function D(e) {
|
|
348
|
+
return e;
|
|
1051
349
|
}
|
|
1052
|
-
function
|
|
350
|
+
function L() {
|
|
1053
351
|
}
|
|
1054
|
-
function
|
|
352
|
+
function W() {
|
|
1055
353
|
return !1;
|
|
1056
354
|
}
|
|
1057
|
-
function
|
|
355
|
+
function H() {
|
|
1058
356
|
return Date.now();
|
|
1059
357
|
}
|
|
1060
|
-
function
|
|
358
|
+
function se() {
|
|
1061
359
|
return Math.round(Date.now() / 1e3);
|
|
1062
360
|
}
|
|
1063
|
-
function
|
|
361
|
+
function ae() {
|
|
1064
362
|
return new Date(Date.now()).toISOString();
|
|
1065
363
|
}
|
|
1066
|
-
function
|
|
1067
|
-
function
|
|
1068
|
-
return typeof
|
|
364
|
+
function oe() {
|
|
365
|
+
function e(t) {
|
|
366
|
+
return typeof t < "u" && t;
|
|
1069
367
|
}
|
|
1070
368
|
try {
|
|
1071
369
|
return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", {
|
|
@@ -1075,89 +373,98 @@ function ot() {
|
|
|
1075
373
|
configurable: !0
|
|
1076
374
|
}), globalThis;
|
|
1077
375
|
} catch {
|
|
1078
|
-
return
|
|
376
|
+
return e(self) || e(window) || e(this) || {};
|
|
1079
377
|
}
|
|
1080
378
|
}
|
|
1081
|
-
return
|
|
379
|
+
return V.exports.default = w, V.exports.pino = w, V.exports;
|
|
1082
380
|
}
|
|
1083
|
-
var
|
|
1084
|
-
const
|
|
381
|
+
var fe = ue();
|
|
382
|
+
const de = /* @__PURE__ */ le(fe), he = de({
|
|
1085
383
|
level: "silent",
|
|
1086
384
|
browser: { asObject: !0 }
|
|
1087
|
-
}),
|
|
1088
|
-
function
|
|
385
|
+
}), te = (d, s) => he.child({ module: d, ...s }), be = te("alistigo:claude-storage:retry"), me = 1e3, ve = 3;
|
|
386
|
+
function ge(d, s) {
|
|
1089
387
|
return Promise.race([
|
|
1090
|
-
|
|
388
|
+
d().then((i) => ({ tag: "ok", value: i })).catch((i) => ({ tag: "error", err: i })),
|
|
1091
389
|
new Promise(
|
|
1092
|
-
(
|
|
390
|
+
(i) => setTimeout(() => i({ tag: "timeout" }), s)
|
|
1093
391
|
)
|
|
1094
392
|
]);
|
|
1095
393
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
394
|
+
async function T(d, s = me, i = ve) {
|
|
395
|
+
for (let c = 0; c <= i; c++) {
|
|
396
|
+
const m = await ge(d, s);
|
|
397
|
+
if (m.tag === "ok") return m.value;
|
|
398
|
+
if (m.tag === "error") throw m.err;
|
|
399
|
+
c < i && be.debug({ attempt: c }, "claude storage timed out, retrying");
|
|
400
|
+
}
|
|
401
|
+
throw new Error(`Claude storage timed out after ${i + 1} attempts`);
|
|
402
|
+
}
|
|
403
|
+
const P = te("alistigo:claude-storage");
|
|
404
|
+
class ye {
|
|
1098
405
|
get storage() {
|
|
1099
|
-
const
|
|
1100
|
-
if (!
|
|
406
|
+
const s = window.storage;
|
|
407
|
+
if (!s)
|
|
1101
408
|
throw new Error(
|
|
1102
|
-
"
|
|
409
|
+
"ClaudeKeyValueStore requires window.storage — check isClaudeArtifactContext() first"
|
|
1103
410
|
);
|
|
1104
|
-
return
|
|
411
|
+
return s;
|
|
1105
412
|
}
|
|
1106
|
-
async
|
|
413
|
+
async get(s) {
|
|
1107
414
|
try {
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1110
|
-
return
|
|
1111
|
-
} catch (
|
|
1112
|
-
|
|
415
|
+
P.debug({ key: s }, "get");
|
|
416
|
+
const i = await T(() => this.storage.get(s));
|
|
417
|
+
return JSON.parse(i.value);
|
|
418
|
+
} catch (i) {
|
|
419
|
+
P.debug({ key: s, err: i }, "get returned nothing (key may not exist)");
|
|
1113
420
|
return;
|
|
1114
421
|
}
|
|
1115
422
|
}
|
|
1116
|
-
async
|
|
1117
|
-
|
|
1118
|
-
await V(this.storage.set(R(n.id), JSON.stringify(i))), X.debug({ key: R(n.id) }, "saved to claude storage");
|
|
423
|
+
async set(s, i) {
|
|
424
|
+
P.debug({ key: s }, "set"), await T(() => this.storage.set(s, JSON.stringify(i)));
|
|
1119
425
|
}
|
|
1120
|
-
async
|
|
426
|
+
async del(s) {
|
|
427
|
+
P.debug({ key: s }, "del"), await T(() => this.storage.delete(s));
|
|
428
|
+
}
|
|
429
|
+
async list(s = "") {
|
|
1121
430
|
try {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
X.debug({ err: t }, "loadDocument from claude storage returned nothing (key may not exist)");
|
|
1126
|
-
return;
|
|
431
|
+
return P.debug({ prefix: s }, "list"), (await T(() => this.storage.list(s)))?.keys ?? [];
|
|
432
|
+
} catch {
|
|
433
|
+
return [];
|
|
1127
434
|
}
|
|
1128
435
|
}
|
|
1129
436
|
}
|
|
1130
|
-
function
|
|
437
|
+
function we() {
|
|
1131
438
|
return typeof window < "u" && typeof window.claude?.complete == "function";
|
|
1132
439
|
}
|
|
1133
|
-
const
|
|
1134
|
-
version:
|
|
1135
|
-
},
|
|
440
|
+
const Oe = "0.3.0", pe = {
|
|
441
|
+
version: Oe
|
|
442
|
+
}, je = {
|
|
1136
443
|
name: "@alistigo/claude-storage-plugin",
|
|
1137
|
-
version:
|
|
444
|
+
version: pe.version,
|
|
1138
445
|
type: "storage",
|
|
1139
446
|
storage: {
|
|
1140
447
|
isAvailable() {
|
|
1141
|
-
return
|
|
448
|
+
return we();
|
|
1142
449
|
},
|
|
1143
450
|
createStore() {
|
|
1144
|
-
return new
|
|
451
|
+
return new ye();
|
|
1145
452
|
},
|
|
1146
|
-
async listKeys(
|
|
1147
|
-
const
|
|
1148
|
-
if (!
|
|
453
|
+
async listKeys(d = "") {
|
|
454
|
+
const s = window.storage;
|
|
455
|
+
if (!s) return [];
|
|
1149
456
|
try {
|
|
1150
|
-
const
|
|
1151
|
-
return
|
|
1152
|
-
|
|
457
|
+
const i = await T(() => s.list(d));
|
|
458
|
+
return i ? (await Promise.all(
|
|
459
|
+
i.keys.map(async (m) => {
|
|
1153
460
|
try {
|
|
1154
|
-
const
|
|
1155
|
-
return { key:
|
|
461
|
+
const E = await T(() => s.get(m));
|
|
462
|
+
return { key: m, value: E.value };
|
|
1156
463
|
} catch {
|
|
1157
464
|
return null;
|
|
1158
465
|
}
|
|
1159
466
|
})
|
|
1160
|
-
)).filter((
|
|
467
|
+
)).filter((m) => m !== null) : [];
|
|
1161
468
|
} catch {
|
|
1162
469
|
return [];
|
|
1163
470
|
}
|
|
@@ -1165,8 +472,9 @@ const ht = "0.2.16", gt = {
|
|
|
1165
472
|
}
|
|
1166
473
|
};
|
|
1167
474
|
export {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
475
|
+
ye as ClaudeKeyValueStore,
|
|
476
|
+
je as default,
|
|
477
|
+
we as isClaudeArtifactContext,
|
|
478
|
+
T as withStorageRetry
|
|
1171
479
|
};
|
|
1172
480
|
//# sourceMappingURL=index.js.map
|