@chainfuse/helpers 4.0.2 → 4.0.3
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/discord.d.mts +1 -2
- package/dist/discord.mjs +17 -53
- package/dist/net.d.mts +13 -6
- package/dist/net.mjs +12 -34
- package/dist/uuid8.d.mts +1 -1
- package/dist/uuid8.mjs +1 -4
- package/package.json +2 -2
package/dist/discord.d.mts
CHANGED
|
@@ -17,12 +17,11 @@ export declare class DiscordHelpers {
|
|
|
17
17
|
* @link https://discord.com/developers/docs/reference#snowflakes-snowflake-id-format-structure-left-to-right
|
|
18
18
|
*/
|
|
19
19
|
static discordSnowflakeToDate(snowflakeRaw?: bigint | string): Date;
|
|
20
|
-
static customLogging: z.ZodMiniFunction<z.ZodMiniTuple<readonly [z.ZodMiniAny], z.ZodMiniAny>, z.ZodMiniUnion<readonly [z.ZodMiniPromise<z.ZodMiniVoid>, z.ZodMiniVoid]>>;
|
|
21
20
|
static disordRestLogging: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
22
21
|
level: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
23
22
|
error: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
24
23
|
color: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
25
|
-
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.
|
|
24
|
+
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnknown, z.ZodMiniTransform<(...args: any[]) => void | Promise<void>, unknown>>>;
|
|
26
25
|
}, z.core.$strip>>;
|
|
27
26
|
static discordRest(apiKey: string, _logging: z.input<typeof this.disordRestLogging>, cacheTtl?: number, forceCache?: boolean, executionContext?: ExecutionContext, restOptions?: Partial<Omit<RESTOptions, 'agent' | 'authPrefix' | 'makeRequest'>>): Promise<import("@discordjs/rest").REST>;
|
|
28
27
|
static userIcon(userId: bigint | string, userIconHash?: Parameters<CDN['avatar']>[1] | null, guildId?: bigint | string, memberIconHash?: Parameters<CDN['avatar']>[1] | null, options?: Parameters<CDN['avatar']>[2]): string;
|
package/dist/discord.mjs
CHANGED
|
@@ -31,17 +31,11 @@ export class DiscordHelpers {
|
|
|
31
31
|
const snowflake = BigInt(snowflakeRaw);
|
|
32
32
|
return new Date(Number((snowflake >> BigInt(22)) + this.discordEpoch));
|
|
33
33
|
}
|
|
34
|
-
static customLogging = z.function({
|
|
35
|
-
input: z.tuple([z.any()], z.any()),
|
|
36
|
-
output: z.union([z.promise(z.void()), z.void()]),
|
|
37
|
-
});
|
|
38
34
|
static disordRestLogging = z._default(z.object({
|
|
39
35
|
level: z._default(z.int().check(z.minimum(0), z.maximum(3)), 0),
|
|
40
36
|
error: z._default(z.int().check(z.minimum(0), z.maximum(3)), 1),
|
|
41
37
|
color: z._default(z.boolean(), true),
|
|
42
|
-
custom: z.optional(z.pipe(
|
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
z.transform((fn) => fn))),
|
|
38
|
+
custom: z.optional(z.pipe(z.unknown(), z.transform((fn) => fn))),
|
|
45
39
|
}), {
|
|
46
40
|
level: 0,
|
|
47
41
|
error: 1,
|
|
@@ -65,16 +59,12 @@ export class DiscordHelpers {
|
|
|
65
59
|
error: logging.error >= 2 ? logging.error - 1 : logging.error,
|
|
66
60
|
...('color' in logging && { color: logging.color }),
|
|
67
61
|
...((logging.level > 0 || logging.error > 0) && {
|
|
68
|
-
custom:
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
70
|
-
const args = [args_0, ...args_x];
|
|
62
|
+
custom: async (...args) => {
|
|
71
63
|
const [, id, , url] = args;
|
|
72
64
|
const customUrl = new URL(url);
|
|
73
65
|
if ('custom' in logging && logging.custom) {
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
75
|
-
const [argsFirst, ...argsRest] = args.slice(0, -1);
|
|
76
66
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
77
|
-
return logging.custom(
|
|
67
|
+
return logging.custom(...args.slice(0, -1));
|
|
78
68
|
}
|
|
79
69
|
else {
|
|
80
70
|
await Promise.all([
|
|
@@ -116,7 +106,7 @@ export class DiscordHelpers {
|
|
|
116
106
|
}
|
|
117
107
|
});
|
|
118
108
|
}
|
|
119
|
-
}
|
|
109
|
+
},
|
|
120
110
|
}),
|
|
121
111
|
},
|
|
122
112
|
};
|
|
@@ -144,10 +134,8 @@ export class DiscordHelpers {
|
|
|
144
134
|
});
|
|
145
135
|
}
|
|
146
136
|
if ('custom' in logging && logging.custom) {
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
148
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
149
137
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
150
|
-
await logging.custom(
|
|
138
|
+
await logging.custom(...loggingItems);
|
|
151
139
|
}
|
|
152
140
|
else {
|
|
153
141
|
console.info(
|
|
@@ -184,10 +172,8 @@ export class DiscordHelpers {
|
|
|
184
172
|
});
|
|
185
173
|
}
|
|
186
174
|
if ('custom' in logging && logging.custom) {
|
|
187
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
188
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
189
175
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
190
|
-
await logging.custom(
|
|
176
|
+
await logging.custom(...loggingItems);
|
|
191
177
|
}
|
|
192
178
|
else {
|
|
193
179
|
console.info(
|
|
@@ -224,10 +210,8 @@ export class DiscordHelpers {
|
|
|
224
210
|
});
|
|
225
211
|
}
|
|
226
212
|
if ('custom' in logging && logging.custom) {
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
228
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
229
213
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
230
|
-
await logging.custom(
|
|
214
|
+
await logging.custom(...loggingItems);
|
|
231
215
|
}
|
|
232
216
|
else {
|
|
233
217
|
console.info(
|
|
@@ -254,10 +238,8 @@ export class DiscordHelpers {
|
|
|
254
238
|
});
|
|
255
239
|
}
|
|
256
240
|
if ('custom' in logging && logging.custom) {
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
258
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
259
241
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
260
|
-
await logging.custom(
|
|
242
|
+
await logging.custom(...loggingItems);
|
|
261
243
|
}
|
|
262
244
|
else {
|
|
263
245
|
console.info(
|
|
@@ -288,10 +270,8 @@ export class DiscordHelpers {
|
|
|
288
270
|
});
|
|
289
271
|
}
|
|
290
272
|
if ('custom' in logging && logging.custom) {
|
|
291
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
292
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
293
273
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
294
|
-
await logging.custom(
|
|
274
|
+
await logging.custom(...loggingItems);
|
|
295
275
|
}
|
|
296
276
|
else {
|
|
297
277
|
console.info(
|
|
@@ -318,10 +298,8 @@ export class DiscordHelpers {
|
|
|
318
298
|
});
|
|
319
299
|
}
|
|
320
300
|
if ('custom' in logging && logging.custom) {
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
322
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
323
301
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
324
|
-
await logging.custom(
|
|
302
|
+
await logging.custom(...loggingItems);
|
|
325
303
|
}
|
|
326
304
|
else {
|
|
327
305
|
console.info(
|
|
@@ -354,10 +332,8 @@ export class DiscordHelpers {
|
|
|
354
332
|
});
|
|
355
333
|
}
|
|
356
334
|
if ('custom' in logging && logging.custom) {
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
358
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
359
335
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
360
|
-
await logging.custom(
|
|
336
|
+
await logging.custom(...loggingItems);
|
|
361
337
|
}
|
|
362
338
|
else {
|
|
363
339
|
console.info(
|
|
@@ -384,10 +360,8 @@ export class DiscordHelpers {
|
|
|
384
360
|
});
|
|
385
361
|
}
|
|
386
362
|
if ('custom' in logging && logging.custom) {
|
|
387
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
388
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
389
363
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
390
|
-
await logging.custom(
|
|
364
|
+
await logging.custom(...loggingItems);
|
|
391
365
|
}
|
|
392
366
|
else {
|
|
393
367
|
console.info(
|
|
@@ -418,10 +392,8 @@ export class DiscordHelpers {
|
|
|
418
392
|
});
|
|
419
393
|
}
|
|
420
394
|
if ('custom' in logging && logging.custom) {
|
|
421
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
422
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
423
395
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
424
|
-
await logging.custom(
|
|
396
|
+
await logging.custom(...loggingItems);
|
|
425
397
|
}
|
|
426
398
|
else {
|
|
427
399
|
console.info(
|
|
@@ -448,10 +420,8 @@ export class DiscordHelpers {
|
|
|
448
420
|
});
|
|
449
421
|
}
|
|
450
422
|
if ('custom' in logging && logging.custom) {
|
|
451
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
452
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
453
423
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
454
|
-
await logging.custom(
|
|
424
|
+
await logging.custom(...loggingItems);
|
|
455
425
|
}
|
|
456
426
|
else {
|
|
457
427
|
console.info(
|
|
@@ -485,10 +455,8 @@ export class DiscordHelpers {
|
|
|
485
455
|
});
|
|
486
456
|
}
|
|
487
457
|
if ('custom' in logging && logging.custom) {
|
|
488
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
489
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
490
458
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
491
|
-
await logging.custom(
|
|
459
|
+
await logging.custom(...loggingItems);
|
|
492
460
|
}
|
|
493
461
|
else {
|
|
494
462
|
console.info(
|
|
@@ -516,10 +484,8 @@ export class DiscordHelpers {
|
|
|
516
484
|
});
|
|
517
485
|
}
|
|
518
486
|
if ('custom' in logging && logging.custom) {
|
|
519
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
520
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
521
487
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
522
|
-
await logging.custom(
|
|
488
|
+
await logging.custom(...loggingItems);
|
|
523
489
|
}
|
|
524
490
|
else {
|
|
525
491
|
console.info(
|
|
@@ -548,10 +514,8 @@ export class DiscordHelpers {
|
|
|
548
514
|
});
|
|
549
515
|
}
|
|
550
516
|
if ('custom' in logging && logging.custom) {
|
|
551
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
552
|
-
const [loggingItemsFirst, ...loggingItemsRest] = loggingItems;
|
|
553
517
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
554
|
-
await logging.custom(
|
|
518
|
+
await logging.custom(...loggingItems);
|
|
555
519
|
}
|
|
556
520
|
else {
|
|
557
521
|
console.info(
|
package/dist/net.d.mts
CHANGED
|
@@ -17,13 +17,12 @@ export declare enum Methods {
|
|
|
17
17
|
'PATCH' = "PATCH"
|
|
18
18
|
}
|
|
19
19
|
export declare class NetHelpers {
|
|
20
|
-
static customLogging: z.ZodMiniFunction<z.ZodMiniTuple<readonly [z.ZodMiniAny], z.ZodMiniAny>, z.ZodMiniUnion<readonly [z.ZodMiniPromise<z.ZodMiniVoid>, z.ZodMiniVoid]>>;
|
|
21
20
|
static cfApiConfig: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
22
21
|
logging: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
23
22
|
level: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
24
23
|
error: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
25
24
|
color: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
26
|
-
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.
|
|
25
|
+
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnknown, z.ZodMiniTransform<(...args: any[]) => void | Promise<void>, unknown>>>;
|
|
27
26
|
}, z.core.$strip>>;
|
|
28
27
|
cf: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
29
28
|
/**
|
|
@@ -102,19 +101,23 @@ export declare class NetHelpers {
|
|
|
102
101
|
* - Formatting and coloring log output for better readability.
|
|
103
102
|
* - Stripping redundant parts of URLs and wrapping unique IDs in brackets with color coding.
|
|
104
103
|
*/
|
|
105
|
-
static cfApi(apiKey: string, config?: z.input<typeof NetHelpers.cfApiConfig>
|
|
104
|
+
static cfApi(apiKey: string, config?: z.input<typeof NetHelpers.cfApiConfig> & {
|
|
105
|
+
logging?: {
|
|
106
|
+
custom?: (...args: any[]) => void | Promise<void>;
|
|
107
|
+
};
|
|
108
|
+
}): Promise<import("cloudflare").Cloudflare>;
|
|
106
109
|
static loggingFetchInitLogging: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
107
110
|
level: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
108
111
|
error: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
109
112
|
color: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
110
|
-
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.
|
|
113
|
+
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnknown, z.ZodMiniTransform<(...args: any[]) => void | Promise<void>, unknown>>>;
|
|
111
114
|
}, z.core.$strip>>;
|
|
112
115
|
static loggingFetchInit: z.ZodMiniObject<{
|
|
113
116
|
logging: z.ZodMiniDefault<z.ZodMiniObject<{
|
|
114
117
|
level: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
115
118
|
error: z.ZodMiniDefault<z.ZodMiniNumberFormat>;
|
|
116
119
|
color: z.ZodMiniDefault<z.ZodMiniBoolean<boolean>>;
|
|
117
|
-
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.
|
|
120
|
+
custom: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnknown, z.ZodMiniTransform<(...args: any[]) => void | Promise<void>, unknown>>>;
|
|
118
121
|
}, z.core.$strip>>;
|
|
119
122
|
}, z.core.$strip>;
|
|
120
123
|
/**
|
|
@@ -151,7 +154,11 @@ export declare class NetHelpers {
|
|
|
151
154
|
* - Allows for colorized output using the `chalk` library.
|
|
152
155
|
* - Provides hooks for custom logging implementations.
|
|
153
156
|
*/
|
|
154
|
-
static loggingFetch<RI extends RequestInit = RequestInit>(info: Parameters<typeof fetch>[0],
|
|
157
|
+
static loggingFetch<RI extends RequestInit = RequestInit>(info: Parameters<typeof fetch>[0], _init?: LoggingFetchInitType<RI> & {
|
|
158
|
+
logging?: {
|
|
159
|
+
custom?: (...args: any[]) => void | Promise<void>;
|
|
160
|
+
};
|
|
161
|
+
}): Promise<Response>;
|
|
155
162
|
/**
|
|
156
163
|
* Removes sensitive headers from the provided `Headers` object. Specifically, it deletes the `Set-Cookie` and `Authorization` headers.
|
|
157
164
|
*
|
package/dist/net.mjs
CHANGED
|
@@ -17,18 +17,12 @@ export var Methods;
|
|
|
17
17
|
Methods["PATCH"] = "PATCH";
|
|
18
18
|
})(Methods || (Methods = {}));
|
|
19
19
|
export class NetHelpers {
|
|
20
|
-
static customLogging = z.function({
|
|
21
|
-
input: z.tuple([z.any()], z.any()),
|
|
22
|
-
output: z.union([z.promise(z.void()), z.void()]),
|
|
23
|
-
});
|
|
24
20
|
static cfApiConfig = z._default(z.object({
|
|
25
21
|
logging: z._default(z.object({
|
|
26
22
|
level: z._default(z.int().check(z.minimum(0), z.maximum(3)), 0),
|
|
27
23
|
error: z._default(z.int().check(z.minimum(0), z.maximum(3)), 1),
|
|
28
24
|
color: z._default(z.boolean(), true),
|
|
29
|
-
custom: z.optional(z.pipe(
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
z.transform((fn) => fn))),
|
|
25
|
+
custom: z.optional(z.pipe(z.unknown(), z.transform((fn) => fn))),
|
|
32
26
|
}), {
|
|
33
27
|
level: 0,
|
|
34
28
|
error: 1,
|
|
@@ -145,9 +139,7 @@ export class NetHelpers {
|
|
|
145
139
|
error: config.logging.error === 1 ? 2 : config.logging.error,
|
|
146
140
|
...('color' in config.logging && { color: config.logging.color }),
|
|
147
141
|
...((config.logging.level > 0 || config.logging.error > 0) && {
|
|
148
|
-
custom:
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
150
|
-
const args = [args_0, ...args_x];
|
|
142
|
+
custom: async (...args) => {
|
|
151
143
|
const [, id, , url, headers] = args;
|
|
152
144
|
const customUrl = new URL(url);
|
|
153
145
|
const customHeaders = new Headers(headers);
|
|
@@ -165,16 +157,12 @@ export class NetHelpers {
|
|
|
165
157
|
if ('custom' in config && config.logging.custom) {
|
|
166
158
|
// We faked level 1 as 2 to get headers for ray-id
|
|
167
159
|
if (config.logging.level === 1 || config.logging.error === 1) {
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
169
|
-
const [argsFirst, ...argsRest] = args.slice(0, -1);
|
|
170
160
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
171
|
-
return config.logging.custom(
|
|
161
|
+
return void config.logging.custom(...args.slice(0, -1));
|
|
172
162
|
}
|
|
173
163
|
else {
|
|
174
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
175
|
-
const [argsFirst, ...argsRest] = args;
|
|
176
164
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
177
|
-
return config.logging.custom(
|
|
165
|
+
return void config.logging.custom(...args);
|
|
178
166
|
}
|
|
179
167
|
}
|
|
180
168
|
else {
|
|
@@ -300,7 +288,7 @@ export class NetHelpers {
|
|
|
300
288
|
}
|
|
301
289
|
});
|
|
302
290
|
}
|
|
303
|
-
}
|
|
291
|
+
},
|
|
304
292
|
}),
|
|
305
293
|
},
|
|
306
294
|
}),
|
|
@@ -310,9 +298,7 @@ export class NetHelpers {
|
|
|
310
298
|
level: z._default(z.int().check(z.minimum(0), z.maximum(3)), 0),
|
|
311
299
|
error: z._default(z.int().check(z.minimum(0), z.maximum(3)), 1),
|
|
312
300
|
color: z._default(z.boolean(), true),
|
|
313
|
-
custom: z.optional(z.pipe(
|
|
314
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
315
|
-
z.transform((fn) => fn))),
|
|
301
|
+
custom: z.optional(z.pipe(z.unknown(), z.transform((fn) => fn))),
|
|
316
302
|
}), {
|
|
317
303
|
level: 0,
|
|
318
304
|
error: 1,
|
|
@@ -355,7 +341,7 @@ export class NetHelpers {
|
|
|
355
341
|
* - Allows for colorized output using the `chalk` library.
|
|
356
342
|
* - Provides hooks for custom logging implementations.
|
|
357
343
|
*/
|
|
358
|
-
static loggingFetch(info,
|
|
344
|
+
static loggingFetch(info, _init) {
|
|
359
345
|
return Promise.all([
|
|
360
346
|
z
|
|
361
347
|
.pipe(z._default(z.looseObject(this.loggingFetchInit.def.shape), {
|
|
@@ -365,7 +351,7 @@ export class NetHelpers {
|
|
|
365
351
|
color: true,
|
|
366
352
|
},
|
|
367
353
|
}), z.transform((parsed) => parsed))
|
|
368
|
-
.parseAsync(
|
|
354
|
+
.parseAsync(_init),
|
|
369
355
|
import("./crypto.mjs").then(({ CryptoHelpers }) => CryptoHelpers.base62secret(8)),
|
|
370
356
|
]).then(async ([init, id]) => {
|
|
371
357
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -421,10 +407,8 @@ export class NetHelpers {
|
|
|
421
407
|
]).catch(() => { });
|
|
422
408
|
}
|
|
423
409
|
if (init.logging.level > 0 && 'custom' in init.logging && init.logging.custom) {
|
|
424
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
425
|
-
const [requestLoggingItemsFirst, ...requestLoggingItemsRest] = requestLoggingItems;
|
|
426
410
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
427
|
-
await init.logging.custom(
|
|
411
|
+
await init.logging.custom(...requestLoggingItems);
|
|
428
412
|
}
|
|
429
413
|
else if (init.logging.level > 0) {
|
|
430
414
|
console.info(
|
|
@@ -489,21 +473,15 @@ export class NetHelpers {
|
|
|
489
473
|
.catch(() => { });
|
|
490
474
|
}
|
|
491
475
|
if (init.logging.level > 0 && 'custom' in init.logging && init.logging.custom) {
|
|
492
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
493
|
-
const [responseLoggingItemsFirst, ...responseLoggingItemsRest] = responseLoggingItems;
|
|
494
476
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
495
|
-
await init.logging.custom(
|
|
477
|
+
await init.logging.custom(...responseLoggingItems);
|
|
496
478
|
}
|
|
497
479
|
else if (init.logging.error > 0 && !response.ok && 'custom' in init.logging && init.logging.custom) {
|
|
498
480
|
// Send request errors too (since we barely now know if error or not)
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
500
|
-
const [requestErrorItemsFirst, ...requestErrorItemsRest] = requestErrorItems;
|
|
501
481
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
502
|
-
await init.logging.custom(
|
|
503
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
504
|
-
const [responseErrorItemsFirst, ...responseErrorItemsRest] = responseErrorItems;
|
|
482
|
+
await init.logging.custom(...requestErrorItems);
|
|
505
483
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
506
|
-
await init.logging.custom(
|
|
484
|
+
await init.logging.custom(...responseErrorItems);
|
|
507
485
|
}
|
|
508
486
|
else if (init.logging.level > 0) {
|
|
509
487
|
console.info(
|
package/dist/uuid8.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ export declare const v8Options: z.ZodMiniUnion<readonly [z.ZodMiniObject<{
|
|
|
14
14
|
location: z.ZodMiniUnion<readonly [z.ZodMiniDefault<z.ZodMiniCustomStringFormat<"hex">>, z.ZodMiniPipe<z.ZodMiniDefault<z.ZodMiniEnum<typeof DOCombinedLocations>>, z.ZodMiniTransform<string, DOCombinedLocations>>]>;
|
|
15
15
|
shardType: z.ZodMiniUnion<readonly [z.ZodMiniDefault<z.ZodMiniCustomStringFormat<"hex">>, z.ZodMiniPipe<z.ZodMiniDefault<z.ZodMiniEnum<typeof ShardType>>, z.ZodMiniTransform<string, ShardType>>]>;
|
|
16
16
|
suffix: z.ZodMiniUnion<readonly [z.ZodMiniDefault<z.ZodMiniCustomStringFormat<"hex">>, z.ZodMiniPipe<z.ZodMiniDefault<z.ZodMiniCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>>, z.ZodMiniTransform<string, Uint8Array<ArrayBuffer>>>]>;
|
|
17
|
-
rng: z.ZodMiniOptional<z.
|
|
17
|
+
rng: z.ZodMiniOptional<z.ZodMiniPipe<z.ZodMiniUnknown, z.ZodMiniTransform<() => Uint8Array, unknown>>>;
|
|
18
18
|
}, z.core.$strip>]>;
|
|
19
19
|
export type Version8Options = z.input<typeof v8Options>;
|
|
20
20
|
/**
|
package/dist/uuid8.mjs
CHANGED
|
@@ -43,10 +43,7 @@ export const v8Options = z.union([
|
|
|
43
43
|
/**
|
|
44
44
|
* Alternative to options.random, a Function that returns an Array of 16 random bytes (0-255)
|
|
45
45
|
*/
|
|
46
|
-
rng: z.optional(z.
|
|
47
|
-
input: [],
|
|
48
|
-
output: z.instanceof(Uint8Array).check(z.refine((arr) => arr.byteLength === 16, { message: '`random` must be a Uint8Array of 16 random bytes' })),
|
|
49
|
-
})),
|
|
46
|
+
rng: z.optional(z.pipe(z.unknown(), z.transform((fn) => fn))),
|
|
50
47
|
}),
|
|
51
48
|
]);
|
|
52
49
|
function replaceByIndex(input, start, end, replacement) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/helpers",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/helpers#readme",
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"@cloudflare/workers-types": "^4.20250910.0",
|
|
94
94
|
"@types/node": "^22.18.1"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "e75fc2917aab88ac2d51deb1a278a3ce0ec1e63b"
|
|
97
97
|
}
|