@timeback/core 0.1.3 → 0.1.5
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/client.d.ts +8 -4
- package/dist/client.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/errors.js +463 -47
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3825 -1042
- package/dist/types.js +1 -17
- package/dist/utils.js +656 -202
- package/package.json +9 -7
package/dist/errors.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
1
|
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
2
|
var __export = (target, all) => {
|
|
19
3
|
for (var name in all)
|
|
20
4
|
__defProp(target, name, {
|
|
@@ -24,7 +8,417 @@ var __export = (target, all) => {
|
|
|
24
8
|
set: (newValue) => all[name] = () => newValue
|
|
25
9
|
});
|
|
26
10
|
};
|
|
27
|
-
var
|
|
11
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
12
|
+
|
|
13
|
+
// node:util
|
|
14
|
+
var exports_util = {};
|
|
15
|
+
__export(exports_util, {
|
|
16
|
+
types: () => types,
|
|
17
|
+
promisify: () => promisify,
|
|
18
|
+
log: () => log,
|
|
19
|
+
isUndefined: () => isUndefined,
|
|
20
|
+
isSymbol: () => isSymbol,
|
|
21
|
+
isString: () => isString,
|
|
22
|
+
isRegExp: () => isRegExp,
|
|
23
|
+
isPrimitive: () => isPrimitive,
|
|
24
|
+
isObject: () => isObject,
|
|
25
|
+
isNumber: () => isNumber,
|
|
26
|
+
isNullOrUndefined: () => isNullOrUndefined,
|
|
27
|
+
isNull: () => isNull,
|
|
28
|
+
isFunction: () => isFunction,
|
|
29
|
+
isError: () => isError,
|
|
30
|
+
isDate: () => isDate,
|
|
31
|
+
isBuffer: () => isBuffer,
|
|
32
|
+
isBoolean: () => isBoolean,
|
|
33
|
+
isArray: () => isArray,
|
|
34
|
+
inspect: () => inspect,
|
|
35
|
+
inherits: () => inherits,
|
|
36
|
+
format: () => format,
|
|
37
|
+
deprecate: () => deprecate,
|
|
38
|
+
default: () => util_default,
|
|
39
|
+
debuglog: () => debuglog,
|
|
40
|
+
callbackifyOnRejected: () => callbackifyOnRejected,
|
|
41
|
+
callbackify: () => callbackify,
|
|
42
|
+
_extend: () => _extend,
|
|
43
|
+
TextEncoder: () => TextEncoder,
|
|
44
|
+
TextDecoder: () => TextDecoder
|
|
45
|
+
});
|
|
46
|
+
function format(f, ...args) {
|
|
47
|
+
if (!isString(f)) {
|
|
48
|
+
var objects = [f];
|
|
49
|
+
for (var i = 0;i < args.length; i++)
|
|
50
|
+
objects.push(inspect(args[i]));
|
|
51
|
+
return objects.join(" ");
|
|
52
|
+
}
|
|
53
|
+
var i = 0, len = args.length, str = String(f).replace(formatRegExp, function(x2) {
|
|
54
|
+
if (x2 === "%%")
|
|
55
|
+
return "%";
|
|
56
|
+
if (i >= len)
|
|
57
|
+
return x2;
|
|
58
|
+
switch (x2) {
|
|
59
|
+
case "%s":
|
|
60
|
+
return String(args[i++]);
|
|
61
|
+
case "%d":
|
|
62
|
+
return Number(args[i++]);
|
|
63
|
+
case "%j":
|
|
64
|
+
try {
|
|
65
|
+
return JSON.stringify(args[i++]);
|
|
66
|
+
} catch (_) {
|
|
67
|
+
return "[Circular]";
|
|
68
|
+
}
|
|
69
|
+
default:
|
|
70
|
+
return x2;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
for (var x = args[i];i < len; x = args[++i])
|
|
74
|
+
if (isNull(x) || !isObject(x))
|
|
75
|
+
str += " " + x;
|
|
76
|
+
else
|
|
77
|
+
str += " " + inspect(x);
|
|
78
|
+
return str;
|
|
79
|
+
}
|
|
80
|
+
function deprecate(fn, msg) {
|
|
81
|
+
if (typeof process > "u" || process?.noDeprecation === true)
|
|
82
|
+
return fn;
|
|
83
|
+
var warned = false;
|
|
84
|
+
function deprecated(...args) {
|
|
85
|
+
if (!warned) {
|
|
86
|
+
if (process.throwDeprecation)
|
|
87
|
+
throw Error(msg);
|
|
88
|
+
else if (process.traceDeprecation)
|
|
89
|
+
console.trace(msg);
|
|
90
|
+
else
|
|
91
|
+
console.error(msg);
|
|
92
|
+
warned = true;
|
|
93
|
+
}
|
|
94
|
+
return fn.apply(this, ...args);
|
|
95
|
+
}
|
|
96
|
+
return deprecated;
|
|
97
|
+
}
|
|
98
|
+
function stylizeWithColor(str, styleType) {
|
|
99
|
+
var style = inspect.styles[styleType];
|
|
100
|
+
if (style)
|
|
101
|
+
return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
|
|
102
|
+
else
|
|
103
|
+
return str;
|
|
104
|
+
}
|
|
105
|
+
function stylizeNoColor(str, styleType) {
|
|
106
|
+
return str;
|
|
107
|
+
}
|
|
108
|
+
function arrayToHash(array) {
|
|
109
|
+
var hash = {};
|
|
110
|
+
return array.forEach(function(val, idx) {
|
|
111
|
+
hash[val] = true;
|
|
112
|
+
}), hash;
|
|
113
|
+
}
|
|
114
|
+
function formatValue(ctx, value, recurseTimes) {
|
|
115
|
+
if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
|
|
116
|
+
var ret = value.inspect(recurseTimes, ctx);
|
|
117
|
+
if (!isString(ret))
|
|
118
|
+
ret = formatValue(ctx, ret, recurseTimes);
|
|
119
|
+
return ret;
|
|
120
|
+
}
|
|
121
|
+
var primitive = formatPrimitive(ctx, value);
|
|
122
|
+
if (primitive)
|
|
123
|
+
return primitive;
|
|
124
|
+
var keys = Object.keys(value), visibleKeys = arrayToHash(keys);
|
|
125
|
+
if (ctx.showHidden)
|
|
126
|
+
keys = Object.getOwnPropertyNames(value);
|
|
127
|
+
if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0))
|
|
128
|
+
return formatError(value);
|
|
129
|
+
if (keys.length === 0) {
|
|
130
|
+
if (isFunction(value)) {
|
|
131
|
+
var name = value.name ? ": " + value.name : "";
|
|
132
|
+
return ctx.stylize("[Function" + name + "]", "special");
|
|
133
|
+
}
|
|
134
|
+
if (isRegExp(value))
|
|
135
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
136
|
+
if (isDate(value))
|
|
137
|
+
return ctx.stylize(Date.prototype.toString.call(value), "date");
|
|
138
|
+
if (isError(value))
|
|
139
|
+
return formatError(value);
|
|
140
|
+
}
|
|
141
|
+
var base = "", array = false, braces = ["{", "}"];
|
|
142
|
+
if (isArray(value))
|
|
143
|
+
array = true, braces = ["[", "]"];
|
|
144
|
+
if (isFunction(value)) {
|
|
145
|
+
var n = value.name ? ": " + value.name : "";
|
|
146
|
+
base = " [Function" + n + "]";
|
|
147
|
+
}
|
|
148
|
+
if (isRegExp(value))
|
|
149
|
+
base = " " + RegExp.prototype.toString.call(value);
|
|
150
|
+
if (isDate(value))
|
|
151
|
+
base = " " + Date.prototype.toUTCString.call(value);
|
|
152
|
+
if (isError(value))
|
|
153
|
+
base = " " + formatError(value);
|
|
154
|
+
if (keys.length === 0 && (!array || value.length == 0))
|
|
155
|
+
return braces[0] + base + braces[1];
|
|
156
|
+
if (recurseTimes < 0)
|
|
157
|
+
if (isRegExp(value))
|
|
158
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
|
|
159
|
+
else
|
|
160
|
+
return ctx.stylize("[Object]", "special");
|
|
161
|
+
ctx.seen.push(value);
|
|
162
|
+
var output;
|
|
163
|
+
if (array)
|
|
164
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
165
|
+
else
|
|
166
|
+
output = keys.map(function(key) {
|
|
167
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
168
|
+
});
|
|
169
|
+
return ctx.seen.pop(), reduceToSingleString(output, base, braces);
|
|
170
|
+
}
|
|
171
|
+
function formatPrimitive(ctx, value) {
|
|
172
|
+
if (isUndefined(value))
|
|
173
|
+
return ctx.stylize("undefined", "undefined");
|
|
174
|
+
if (isString(value)) {
|
|
175
|
+
var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, '"') + "'";
|
|
176
|
+
return ctx.stylize(simple, "string");
|
|
177
|
+
}
|
|
178
|
+
if (isNumber(value))
|
|
179
|
+
return ctx.stylize("" + value, "number");
|
|
180
|
+
if (isBoolean(value))
|
|
181
|
+
return ctx.stylize("" + value, "boolean");
|
|
182
|
+
if (isNull(value))
|
|
183
|
+
return ctx.stylize("null", "null");
|
|
184
|
+
}
|
|
185
|
+
function formatError(value) {
|
|
186
|
+
return "[" + Error.prototype.toString.call(value) + "]";
|
|
187
|
+
}
|
|
188
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
189
|
+
var output = [];
|
|
190
|
+
for (var i = 0, l = value.length;i < l; ++i)
|
|
191
|
+
if (hasOwnProperty(value, String(i)))
|
|
192
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
|
|
193
|
+
else
|
|
194
|
+
output.push("");
|
|
195
|
+
return keys.forEach(function(key) {
|
|
196
|
+
if (!key.match(/^\d+$/))
|
|
197
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
|
|
198
|
+
}), output;
|
|
199
|
+
}
|
|
200
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
201
|
+
var name, str, desc;
|
|
202
|
+
if (desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }, desc.get)
|
|
203
|
+
if (desc.set)
|
|
204
|
+
str = ctx.stylize("[Getter/Setter]", "special");
|
|
205
|
+
else
|
|
206
|
+
str = ctx.stylize("[Getter]", "special");
|
|
207
|
+
else if (desc.set)
|
|
208
|
+
str = ctx.stylize("[Setter]", "special");
|
|
209
|
+
if (!hasOwnProperty(visibleKeys, key))
|
|
210
|
+
name = "[" + key + "]";
|
|
211
|
+
if (!str)
|
|
212
|
+
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
213
|
+
if (isNull(recurseTimes))
|
|
214
|
+
str = formatValue(ctx, desc.value, null);
|
|
215
|
+
else
|
|
216
|
+
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
217
|
+
if (str.indexOf(`
|
|
218
|
+
`) > -1)
|
|
219
|
+
if (array)
|
|
220
|
+
str = str.split(`
|
|
221
|
+
`).map(function(line) {
|
|
222
|
+
return " " + line;
|
|
223
|
+
}).join(`
|
|
224
|
+
`).slice(2);
|
|
225
|
+
else
|
|
226
|
+
str = `
|
|
227
|
+
` + str.split(`
|
|
228
|
+
`).map(function(line) {
|
|
229
|
+
return " " + line;
|
|
230
|
+
}).join(`
|
|
231
|
+
`);
|
|
232
|
+
} else
|
|
233
|
+
str = ctx.stylize("[Circular]", "special");
|
|
234
|
+
if (isUndefined(name)) {
|
|
235
|
+
if (array && key.match(/^\d+$/))
|
|
236
|
+
return str;
|
|
237
|
+
if (name = JSON.stringify("" + key), name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/))
|
|
238
|
+
name = name.slice(1, -1), name = ctx.stylize(name, "name");
|
|
239
|
+
else
|
|
240
|
+
name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"), name = ctx.stylize(name, "string");
|
|
241
|
+
}
|
|
242
|
+
return name + ": " + str;
|
|
243
|
+
}
|
|
244
|
+
function reduceToSingleString(output, base, braces) {
|
|
245
|
+
var numLinesEst = 0, length = output.reduce(function(prev, cur) {
|
|
246
|
+
if (numLinesEst++, cur.indexOf(`
|
|
247
|
+
`) >= 0)
|
|
248
|
+
numLinesEst++;
|
|
249
|
+
return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
|
|
250
|
+
}, 0);
|
|
251
|
+
if (length > 60)
|
|
252
|
+
return braces[0] + (base === "" ? "" : base + `
|
|
253
|
+
`) + " " + output.join(`,
|
|
254
|
+
`) + " " + braces[1];
|
|
255
|
+
return braces[0] + base + " " + output.join(", ") + " " + braces[1];
|
|
256
|
+
}
|
|
257
|
+
function isArray(ar) {
|
|
258
|
+
return Array.isArray(ar);
|
|
259
|
+
}
|
|
260
|
+
function isBoolean(arg) {
|
|
261
|
+
return typeof arg === "boolean";
|
|
262
|
+
}
|
|
263
|
+
function isNull(arg) {
|
|
264
|
+
return arg === null;
|
|
265
|
+
}
|
|
266
|
+
function isNullOrUndefined(arg) {
|
|
267
|
+
return arg == null;
|
|
268
|
+
}
|
|
269
|
+
function isNumber(arg) {
|
|
270
|
+
return typeof arg === "number";
|
|
271
|
+
}
|
|
272
|
+
function isString(arg) {
|
|
273
|
+
return typeof arg === "string";
|
|
274
|
+
}
|
|
275
|
+
function isSymbol(arg) {
|
|
276
|
+
return typeof arg === "symbol";
|
|
277
|
+
}
|
|
278
|
+
function isUndefined(arg) {
|
|
279
|
+
return arg === undefined;
|
|
280
|
+
}
|
|
281
|
+
function isRegExp(re) {
|
|
282
|
+
return isObject(re) && objectToString(re) === "[object RegExp]";
|
|
283
|
+
}
|
|
284
|
+
function isObject(arg) {
|
|
285
|
+
return typeof arg === "object" && arg !== null;
|
|
286
|
+
}
|
|
287
|
+
function isDate(d) {
|
|
288
|
+
return isObject(d) && objectToString(d) === "[object Date]";
|
|
289
|
+
}
|
|
290
|
+
function isError(e) {
|
|
291
|
+
return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
|
|
292
|
+
}
|
|
293
|
+
function isFunction(arg) {
|
|
294
|
+
return typeof arg === "function";
|
|
295
|
+
}
|
|
296
|
+
function isPrimitive(arg) {
|
|
297
|
+
return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || typeof arg > "u";
|
|
298
|
+
}
|
|
299
|
+
function isBuffer(arg) {
|
|
300
|
+
return arg instanceof Buffer;
|
|
301
|
+
}
|
|
302
|
+
function objectToString(o) {
|
|
303
|
+
return Object.prototype.toString.call(o);
|
|
304
|
+
}
|
|
305
|
+
function pad(n) {
|
|
306
|
+
return n < 10 ? "0" + n.toString(10) : n.toString(10);
|
|
307
|
+
}
|
|
308
|
+
function timestamp() {
|
|
309
|
+
var d = new Date, time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(":");
|
|
310
|
+
return [d.getDate(), months[d.getMonth()], time].join(" ");
|
|
311
|
+
}
|
|
312
|
+
function log(...args) {
|
|
313
|
+
console.log("%s - %s", timestamp(), format.apply(null, args));
|
|
314
|
+
}
|
|
315
|
+
function inherits(ctor, superCtor) {
|
|
316
|
+
if (superCtor)
|
|
317
|
+
ctor.super_ = superCtor, ctor.prototype = Object.create(superCtor.prototype, { constructor: { value: ctor, enumerable: false, writable: true, configurable: true } });
|
|
318
|
+
}
|
|
319
|
+
function _extend(origin, add) {
|
|
320
|
+
if (!add || !isObject(add))
|
|
321
|
+
return origin;
|
|
322
|
+
var keys = Object.keys(add), i = keys.length;
|
|
323
|
+
while (i--)
|
|
324
|
+
origin[keys[i]] = add[keys[i]];
|
|
325
|
+
return origin;
|
|
326
|
+
}
|
|
327
|
+
function hasOwnProperty(obj, prop) {
|
|
328
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
329
|
+
}
|
|
330
|
+
function callbackifyOnRejected(reason, cb) {
|
|
331
|
+
if (!reason) {
|
|
332
|
+
var newReason = Error("Promise was rejected with a falsy value");
|
|
333
|
+
newReason.reason = reason, reason = newReason;
|
|
334
|
+
}
|
|
335
|
+
return cb(reason);
|
|
336
|
+
}
|
|
337
|
+
function callbackify(original) {
|
|
338
|
+
if (typeof original !== "function")
|
|
339
|
+
throw TypeError('The "original" argument must be of type Function');
|
|
340
|
+
function callbackified(...args) {
|
|
341
|
+
var maybeCb = args.pop();
|
|
342
|
+
if (typeof maybeCb !== "function")
|
|
343
|
+
throw TypeError("The last argument must be of type Function");
|
|
344
|
+
var self = this, cb = function(...args2) {
|
|
345
|
+
return maybeCb.apply(self, ...args2);
|
|
346
|
+
};
|
|
347
|
+
original.apply(this, args).then(function(ret) {
|
|
348
|
+
process.nextTick(cb.bind(null, null, ret));
|
|
349
|
+
}, function(rej) {
|
|
350
|
+
process.nextTick(callbackifyOnRejected.bind(null, rej, cb));
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
return Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)), Object.defineProperties(callbackified, Object.getOwnPropertyDescriptors(original)), callbackified;
|
|
354
|
+
}
|
|
355
|
+
var formatRegExp, debuglog, inspect, types = () => {}, months, promisify, TextEncoder, TextDecoder, util_default;
|
|
356
|
+
var init_util = __esm(() => {
|
|
357
|
+
formatRegExp = /%[sdj%]/g;
|
|
358
|
+
debuglog = ((debugs = {}, debugEnvRegex = {}, debugEnv) => ((debugEnv = typeof process < "u" && false) && (debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*").replace(/,/g, "$|^").toUpperCase()), debugEnvRegex = new RegExp("^" + debugEnv + "$", "i"), (set) => {
|
|
359
|
+
if (set = set.toUpperCase(), !debugs[set])
|
|
360
|
+
if (debugEnvRegex.test(set))
|
|
361
|
+
debugs[set] = function(...args) {
|
|
362
|
+
console.error("%s: %s", set, pid, format.apply(null, ...args));
|
|
363
|
+
};
|
|
364
|
+
else
|
|
365
|
+
debugs[set] = function() {};
|
|
366
|
+
return debugs[set];
|
|
367
|
+
}))();
|
|
368
|
+
inspect = ((i) => (i.colors = { bold: [1, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], white: [37, 39], grey: [90, 39], black: [30, 39], blue: [34, 39], cyan: [36, 39], green: [32, 39], magenta: [35, 39], red: [31, 39], yellow: [33, 39] }, i.styles = { special: "cyan", number: "yellow", boolean: "yellow", undefined: "grey", null: "bold", string: "green", date: "magenta", regexp: "red" }, i.custom = Symbol.for("nodejs.util.inspect.custom"), i))(function(obj, opts, ...rest) {
|
|
369
|
+
var ctx = { seen: [], stylize: stylizeNoColor };
|
|
370
|
+
if (rest.length >= 1)
|
|
371
|
+
ctx.depth = rest[0];
|
|
372
|
+
if (rest.length >= 2)
|
|
373
|
+
ctx.colors = rest[1];
|
|
374
|
+
if (isBoolean(opts))
|
|
375
|
+
ctx.showHidden = opts;
|
|
376
|
+
else if (opts)
|
|
377
|
+
_extend(ctx, opts);
|
|
378
|
+
if (isUndefined(ctx.showHidden))
|
|
379
|
+
ctx.showHidden = false;
|
|
380
|
+
if (isUndefined(ctx.depth))
|
|
381
|
+
ctx.depth = 2;
|
|
382
|
+
if (isUndefined(ctx.colors))
|
|
383
|
+
ctx.colors = false;
|
|
384
|
+
if (ctx.colors)
|
|
385
|
+
ctx.stylize = stylizeWithColor;
|
|
386
|
+
return formatValue(ctx, obj, ctx.depth);
|
|
387
|
+
});
|
|
388
|
+
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
389
|
+
promisify = ((x) => (x.custom = Symbol.for("nodejs.util.promisify.custom"), x))(function(original) {
|
|
390
|
+
if (typeof original !== "function")
|
|
391
|
+
throw TypeError('The "original" argument must be of type Function');
|
|
392
|
+
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
|
|
393
|
+
var fn = original[kCustomPromisifiedSymbol];
|
|
394
|
+
if (typeof fn !== "function")
|
|
395
|
+
throw TypeError('The "nodejs.util.promisify.custom" argument must be of type Function');
|
|
396
|
+
return Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }), fn;
|
|
397
|
+
}
|
|
398
|
+
function fn(...args) {
|
|
399
|
+
var promiseResolve, promiseReject, promise = new Promise(function(resolve, reject) {
|
|
400
|
+
promiseResolve = resolve, promiseReject = reject;
|
|
401
|
+
});
|
|
402
|
+
args.push(function(err, value) {
|
|
403
|
+
if (err)
|
|
404
|
+
promiseReject(err);
|
|
405
|
+
else
|
|
406
|
+
promiseResolve(value);
|
|
407
|
+
});
|
|
408
|
+
try {
|
|
409
|
+
original.apply(this, args);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
promiseReject(err);
|
|
412
|
+
}
|
|
413
|
+
return promise;
|
|
414
|
+
}
|
|
415
|
+
if (Object.setPrototypeOf(fn, Object.getPrototypeOf(original)), kCustomPromisifiedSymbol)
|
|
416
|
+
Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true });
|
|
417
|
+
return Object.defineProperties(fn, Object.getOwnPropertyDescriptors(original));
|
|
418
|
+
});
|
|
419
|
+
({ TextEncoder, TextDecoder } = globalThis);
|
|
420
|
+
util_default = { TextEncoder, TextDecoder, promisify, log, inherits, _extend, callbackifyOnRejected, callbackify };
|
|
421
|
+
});
|
|
28
422
|
|
|
29
423
|
// ../../internal/constants/src/endpoints.ts
|
|
30
424
|
var DEFAULT_PLATFORM = "BEYOND_AI";
|
|
@@ -180,7 +574,7 @@ function detectEnvironment() {
|
|
|
180
574
|
var nodeInspect;
|
|
181
575
|
if (!isBrowser()) {
|
|
182
576
|
try {
|
|
183
|
-
const util = await
|
|
577
|
+
const util = await Promise.resolve().then(() => (init_util(), exports_util));
|
|
184
578
|
nodeInspect = util.inspect;
|
|
185
579
|
} catch {}
|
|
186
580
|
}
|
|
@@ -233,10 +627,10 @@ var terminalFormatter = (entry) => {
|
|
|
233
627
|
const consoleMethod = getConsoleMethod(entry.level);
|
|
234
628
|
const levelUpper = entry.level.toUpperCase().padEnd(5);
|
|
235
629
|
const isoString = entry.timestamp.toISOString().replace(/\.\d{3}Z$/, "");
|
|
236
|
-
const
|
|
630
|
+
const timestamp2 = `${colors.dim}[${isoString}]${colors.reset}`;
|
|
237
631
|
const level = `${levelColor}${levelUpper}${colors.reset}`;
|
|
238
632
|
const scope = entry.scope ? `${colors.bold}[${entry.scope}]${colors.reset} ` : "";
|
|
239
|
-
const prefix = `${
|
|
633
|
+
const prefix = `${timestamp2} ${level} ${scope}${entry.message}`;
|
|
240
634
|
if (entry.context && Object.keys(entry.context).length > 0) {
|
|
241
635
|
consoleMethod(prefix, formatContext(entry.context));
|
|
242
636
|
} else {
|
|
@@ -251,9 +645,9 @@ var LEVEL_PREFIX = {
|
|
|
251
645
|
error: "[ERROR]"
|
|
252
646
|
};
|
|
253
647
|
function formatContext2(context) {
|
|
254
|
-
return Object.entries(context).map(([key, value]) => `${key}=${
|
|
648
|
+
return Object.entries(context).map(([key, value]) => `${key}=${formatValue2(value)}`).join(" ");
|
|
255
649
|
}
|
|
256
|
-
function
|
|
650
|
+
function formatValue2(value) {
|
|
257
651
|
if (typeof value === "string")
|
|
258
652
|
return value;
|
|
259
653
|
if (typeof value === "number")
|
|
@@ -413,7 +807,7 @@ function isDebug() {
|
|
|
413
807
|
return false;
|
|
414
808
|
}
|
|
415
809
|
}
|
|
416
|
-
var
|
|
810
|
+
var log2 = createLogger({ scope: "auth", minLevel: isDebug() ? "debug" : "warn" });
|
|
417
811
|
|
|
418
812
|
class TokenManager {
|
|
419
813
|
config;
|
|
@@ -427,11 +821,11 @@ class TokenManager {
|
|
|
427
821
|
}
|
|
428
822
|
async getToken() {
|
|
429
823
|
if (this.accessToken && Date.now() < this.tokenExpiry) {
|
|
430
|
-
|
|
824
|
+
log2.debug("Using cached token");
|
|
431
825
|
return this.accessToken;
|
|
432
826
|
}
|
|
433
827
|
if (this.pendingRequest) {
|
|
434
|
-
|
|
828
|
+
log2.debug("Waiting for in-flight token request");
|
|
435
829
|
return this.pendingRequest;
|
|
436
830
|
}
|
|
437
831
|
this.pendingRequest = this.fetchToken();
|
|
@@ -442,7 +836,7 @@ class TokenManager {
|
|
|
442
836
|
}
|
|
443
837
|
}
|
|
444
838
|
async fetchToken() {
|
|
445
|
-
|
|
839
|
+
log2.debug("Fetching new access token...");
|
|
446
840
|
const { clientId, clientSecret } = this.config.credentials;
|
|
447
841
|
const credentials = btoa(`${clientId}:${clientSecret}`);
|
|
448
842
|
const start = performance.now();
|
|
@@ -456,17 +850,17 @@ class TokenManager {
|
|
|
456
850
|
});
|
|
457
851
|
const duration = Math.round(performance.now() - start);
|
|
458
852
|
if (!response.ok) {
|
|
459
|
-
|
|
853
|
+
log2.error(`Token request failed: ${response.status} ${response.statusText}`);
|
|
460
854
|
throw new Error(`Failed to obtain access token: ${response.status} ${response.statusText}`);
|
|
461
855
|
}
|
|
462
856
|
const data = await response.json();
|
|
463
857
|
this.accessToken = data.access_token;
|
|
464
858
|
this.tokenExpiry = Date.now() + (data.expires_in - 60) * 1000;
|
|
465
|
-
|
|
859
|
+
log2.debug(`Token acquired (${duration}ms, expires in ${data.expires_in}s)`);
|
|
466
860
|
return this.accessToken;
|
|
467
861
|
}
|
|
468
862
|
invalidate() {
|
|
469
|
-
|
|
863
|
+
log2.debug("Token invalidated");
|
|
470
864
|
this.accessToken = null;
|
|
471
865
|
this.tokenExpiry = 0;
|
|
472
866
|
}
|
|
@@ -704,7 +1098,17 @@ class TimebackProvider {
|
|
|
704
1098
|
// ../../internal/client-infra/src/utils/utils.ts
|
|
705
1099
|
function getEnv(key) {
|
|
706
1100
|
try {
|
|
707
|
-
|
|
1101
|
+
if (typeof process === "undefined")
|
|
1102
|
+
return;
|
|
1103
|
+
if (typeof key === "string") {
|
|
1104
|
+
return process.env[key];
|
|
1105
|
+
}
|
|
1106
|
+
for (const k of key) {
|
|
1107
|
+
const value = process.env[k];
|
|
1108
|
+
if (value !== undefined)
|
|
1109
|
+
return value;
|
|
1110
|
+
}
|
|
1111
|
+
return;
|
|
708
1112
|
} catch {
|
|
709
1113
|
return;
|
|
710
1114
|
}
|
|
@@ -725,6 +1129,18 @@ var DEFAULT_PROVIDER_REGISTRY = {
|
|
|
725
1129
|
};
|
|
726
1130
|
|
|
727
1131
|
// ../../internal/client-infra/src/config/resolve.ts
|
|
1132
|
+
function primaryEnvVar(key) {
|
|
1133
|
+
if (typeof key === "string") {
|
|
1134
|
+
return key;
|
|
1135
|
+
}
|
|
1136
|
+
if (key.length === 0) {
|
|
1137
|
+
throw new Error(`Missing env var key: ${key}`);
|
|
1138
|
+
}
|
|
1139
|
+
return key[0];
|
|
1140
|
+
}
|
|
1141
|
+
function formatEnvVarKey(key) {
|
|
1142
|
+
return primaryEnvVar(key);
|
|
1143
|
+
}
|
|
728
1144
|
function validateEnv(env) {
|
|
729
1145
|
if (env !== "staging" && env !== "production") {
|
|
730
1146
|
throw new Error(`Invalid env "${env}": must be "staging" or "production"`);
|
|
@@ -735,10 +1151,10 @@ function validateAuth(auth, envVars) {
|
|
|
735
1151
|
const clientId = auth?.clientId ?? getEnv(envVars.clientId);
|
|
736
1152
|
const clientSecret = auth?.clientSecret ?? getEnv(envVars.clientSecret);
|
|
737
1153
|
if (!clientId) {
|
|
738
|
-
throw new Error(`Missing clientId: provide in config or set ${envVars.clientId}`);
|
|
1154
|
+
throw new Error(`Missing clientId: provide in config or set ${formatEnvVarKey(envVars.clientId)}`);
|
|
739
1155
|
}
|
|
740
1156
|
if (!clientSecret) {
|
|
741
|
-
throw new Error(`Missing clientSecret: provide in config or set ${envVars.clientSecret}`);
|
|
1157
|
+
throw new Error(`Missing clientSecret: provide in config or set ${formatEnvVarKey(envVars.clientSecret)}`);
|
|
742
1158
|
}
|
|
743
1159
|
return { clientId, clientSecret };
|
|
744
1160
|
}
|
|
@@ -754,21 +1170,21 @@ function buildMissingEnvError(envVars) {
|
|
|
754
1170
|
const clientId = getEnv(envVars.clientId);
|
|
755
1171
|
const clientSecret = getEnv(envVars.clientSecret);
|
|
756
1172
|
if (baseUrl === undefined && clientId === undefined) {
|
|
757
|
-
const hint = envVars.env ?? envVars.baseUrl;
|
|
1173
|
+
const hint = formatEnvVarKey(envVars.env ?? envVars.baseUrl);
|
|
758
1174
|
return `Missing env: provide in config or set ${hint}`;
|
|
759
1175
|
}
|
|
760
1176
|
const missing = [];
|
|
761
1177
|
if (baseUrl === undefined) {
|
|
762
|
-
missing.push(envVars.env ?? envVars.baseUrl);
|
|
1178
|
+
missing.push(formatEnvVarKey(envVars.env ?? envVars.baseUrl));
|
|
763
1179
|
}
|
|
764
1180
|
if (baseUrl !== undefined && authUrl === undefined) {
|
|
765
|
-
missing.push(envVars.authUrl);
|
|
1181
|
+
missing.push(formatEnvVarKey(envVars.authUrl));
|
|
766
1182
|
}
|
|
767
1183
|
if (clientId === undefined) {
|
|
768
|
-
missing.push(envVars.clientId);
|
|
1184
|
+
missing.push(formatEnvVarKey(envVars.clientId));
|
|
769
1185
|
}
|
|
770
1186
|
if (clientSecret === undefined) {
|
|
771
|
-
missing.push(envVars.clientSecret);
|
|
1187
|
+
missing.push(formatEnvVarKey(envVars.clientSecret));
|
|
772
1188
|
}
|
|
773
1189
|
return `Missing environment variables: ${missing.join(", ")}`;
|
|
774
1190
|
}
|
|
@@ -998,43 +1414,43 @@ function escapeValue(value) {
|
|
|
998
1414
|
}
|
|
999
1415
|
return value.replaceAll("'", "''");
|
|
1000
1416
|
}
|
|
1001
|
-
function
|
|
1417
|
+
function formatValue3(value) {
|
|
1002
1418
|
const escaped = escapeValue(value);
|
|
1003
1419
|
const needsQuotes = typeof value === "string" || value instanceof Date;
|
|
1004
1420
|
return needsQuotes ? `'${escaped}'` : escaped;
|
|
1005
1421
|
}
|
|
1006
1422
|
function fieldToConditions(field, condition) {
|
|
1007
1423
|
if (typeof condition === "string" || typeof condition === "number" || typeof condition === "boolean" || condition instanceof Date) {
|
|
1008
|
-
return [`${field}=${
|
|
1424
|
+
return [`${field}=${formatValue3(condition)}`];
|
|
1009
1425
|
}
|
|
1010
1426
|
if (typeof condition === "object" && condition !== null) {
|
|
1011
1427
|
const ops = condition;
|
|
1012
1428
|
const conditions = [];
|
|
1013
1429
|
if (ops.ne !== undefined) {
|
|
1014
|
-
conditions.push(`${field}!=${
|
|
1430
|
+
conditions.push(`${field}!=${formatValue3(ops.ne)}`);
|
|
1015
1431
|
}
|
|
1016
1432
|
if (ops.gt !== undefined) {
|
|
1017
|
-
conditions.push(`${field}>${
|
|
1433
|
+
conditions.push(`${field}>${formatValue3(ops.gt)}`);
|
|
1018
1434
|
}
|
|
1019
1435
|
if (ops.gte !== undefined) {
|
|
1020
|
-
conditions.push(`${field}>=${
|
|
1436
|
+
conditions.push(`${field}>=${formatValue3(ops.gte)}`);
|
|
1021
1437
|
}
|
|
1022
1438
|
if (ops.lt !== undefined) {
|
|
1023
|
-
conditions.push(`${field}<${
|
|
1439
|
+
conditions.push(`${field}<${formatValue3(ops.lt)}`);
|
|
1024
1440
|
}
|
|
1025
1441
|
if (ops.lte !== undefined) {
|
|
1026
|
-
conditions.push(`${field}<=${
|
|
1442
|
+
conditions.push(`${field}<=${formatValue3(ops.lte)}`);
|
|
1027
1443
|
}
|
|
1028
1444
|
if (ops.contains !== undefined) {
|
|
1029
|
-
conditions.push(`${field}~${
|
|
1445
|
+
conditions.push(`${field}~${formatValue3(ops.contains)}`);
|
|
1030
1446
|
}
|
|
1031
1447
|
if (ops.in !== undefined && ops.in.length > 0) {
|
|
1032
|
-
const inConditions = ops.in.map((v) => `${field}=${
|
|
1448
|
+
const inConditions = ops.in.map((v) => `${field}=${formatValue3(v)}`);
|
|
1033
1449
|
const joined = inConditions.join(" OR ");
|
|
1034
1450
|
conditions.push(inConditions.length > 1 ? `(${joined})` : joined);
|
|
1035
1451
|
}
|
|
1036
1452
|
if (ops.notIn !== undefined && ops.notIn.length > 0) {
|
|
1037
|
-
const notInConditions = ops.notIn.map((v) => `${field}!=${
|
|
1453
|
+
const notInConditions = ops.notIn.map((v) => `${field}!=${formatValue3(v)}`);
|
|
1038
1454
|
conditions.push(notInConditions.join(" AND "));
|
|
1039
1455
|
}
|
|
1040
1456
|
return conditions;
|
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export type { BroadcastResult, BroadcastResultMethods, BroadcastResults } from '
|
|
|
24
24
|
export { ApiError, ForbiddenError, isApiError, NotFoundError, UnauthorizedError, ValidationError, } from '@timeback/internal-client-infra';
|
|
25
25
|
export { whereToFilter } from '@timeback/internal-client-infra';
|
|
26
26
|
export type { FieldCondition, FieldOperators, FilterValue, OrCondition, WhereClause, } from '@timeback/internal-client-infra';
|
|
27
|
-
export
|
|
27
|
+
export { getServiceUrlsForEnv } from './constants';
|
|
28
|
+
export type { Environment, EnvServiceUrls, TimebackClientConfig } from './types/index';
|
|
28
29
|
export type { AuthCheckResult } from '@timeback/internal-client-infra';
|
|
29
30
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAM9F,OAAO,EACN,QAAQ,EACR,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,MAAM,iCAAiC,CAAA;AAMxC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,YAAY,EACX,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,GACX,MAAM,iCAAiC,CAAA;AAMxC,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAM9F,OAAO,EACN,QAAQ,EACR,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,GACf,MAAM,iCAAiC,CAAA;AAMxC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAE/D,YAAY,EACX,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,GACX,MAAM,iCAAiC,CAAA;AAMxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMlD,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAEtF,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA"}
|