autosync_backend2 1.2.17 → 1.2.19
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.d.ts +246 -8
- package/dist/index.js +540 -114
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -22792,8 +22792,8 @@ var require_caller = __commonJS((exports, module) => {
|
|
|
22792
22792
|
};
|
|
22793
22793
|
});
|
|
22794
22794
|
|
|
22795
|
-
// node_modules/
|
|
22796
|
-
var
|
|
22795
|
+
// node_modules/@pinojs/redact/index.js
|
|
22796
|
+
var require_redact = __commonJS((exports, module) => {
|
|
22797
22797
|
function deepClone2(obj2) {
|
|
22798
22798
|
if (obj2 === null || typeof obj2 !== "object") {
|
|
22799
22799
|
return obj2;
|
|
@@ -23296,7 +23296,7 @@ var require_symbols = __commonJS((exports, module) => {
|
|
|
23296
23296
|
|
|
23297
23297
|
// node_modules/pino/lib/redaction.js
|
|
23298
23298
|
var require_redaction = __commonJS((exports, module) => {
|
|
23299
|
-
var
|
|
23299
|
+
var Redact = require_redact();
|
|
23300
23300
|
var { redactFmtSym, wildcardFirstSym } = require_symbols();
|
|
23301
23301
|
var rx = /[^.[\]]+|\[([^[\]]*?)\]/g;
|
|
23302
23302
|
var CENSOR = "[Redacted]";
|
|
@@ -23335,7 +23335,7 @@ var require_redaction = __commonJS((exports, module) => {
|
|
|
23335
23335
|
return o;
|
|
23336
23336
|
}, {});
|
|
23337
23337
|
const result = {
|
|
23338
|
-
[redactFmtSym]:
|
|
23338
|
+
[redactFmtSym]: Redact({ paths: paths2, censor, serialize, strict, remove })
|
|
23339
23339
|
};
|
|
23340
23340
|
const topCensor = (...args) => {
|
|
23341
23341
|
return typeof censor === "function" ? serialize(censor(...args)) : serialize(censor);
|
|
@@ -23347,7 +23347,7 @@ var require_redaction = __commonJS((exports, module) => {
|
|
|
23347
23347
|
const wrappedCensor = typeof censor === "function" ? (value, path) => {
|
|
23348
23348
|
return censor(value, [k2, ...path]);
|
|
23349
23349
|
} : censor;
|
|
23350
|
-
o[k2] =
|
|
23350
|
+
o[k2] = Redact({
|
|
23351
23351
|
paths: shape[k2],
|
|
23352
23352
|
censor: wrappedCensor,
|
|
23353
23353
|
serialize,
|
|
@@ -25420,7 +25420,7 @@ var require_levels = __commonJS((exports, module) => {
|
|
|
25420
25420
|
|
|
25421
25421
|
// node_modules/pino/lib/meta.js
|
|
25422
25422
|
var require_meta = __commonJS((exports, module) => {
|
|
25423
|
-
module.exports = { version: "9.
|
|
25423
|
+
module.exports = { version: "9.14.0" };
|
|
25424
25424
|
});
|
|
25425
25425
|
|
|
25426
25426
|
// node_modules/pino/lib/proto.js
|
|
@@ -25524,6 +25524,7 @@ var require_proto = __commonJS((exports, module) => {
|
|
|
25524
25524
|
instance[formattersSym] = buildFormatters(formatters.level, resetChildingsFormatter, formatters.log);
|
|
25525
25525
|
}
|
|
25526
25526
|
instance[chindingsSym] = asChindings(instance, bindings2);
|
|
25527
|
+
instance[setLevelSym](this.level);
|
|
25527
25528
|
if (this.onChild !== noop2) {
|
|
25528
25529
|
this.onChild(instance);
|
|
25529
25530
|
}
|
|
@@ -25572,10 +25573,8 @@ var require_proto = __commonJS((exports, module) => {
|
|
|
25572
25573
|
instance[msgPrefixSym] = (this[msgPrefixSym] || "") + options.msgPrefix;
|
|
25573
25574
|
}
|
|
25574
25575
|
instance[chindingsSym] = asChindings(instance, bindings2);
|
|
25575
|
-
|
|
25576
|
-
|
|
25577
|
-
instance[setLevelSym](childLevel);
|
|
25578
|
-
}
|
|
25576
|
+
const childLevel = options.level || this.level;
|
|
25577
|
+
instance[setLevelSym](childLevel);
|
|
25579
25578
|
this.onChild(instance);
|
|
25580
25579
|
return instance;
|
|
25581
25580
|
}
|
|
@@ -136200,7 +136199,7 @@ class WithSubquery extends Subquery {
|
|
|
136200
136199
|
}
|
|
136201
136200
|
|
|
136202
136201
|
// node_modules/drizzle-orm/version.js
|
|
136203
|
-
var version4 = "0.44.
|
|
136202
|
+
var version4 = "0.44.7";
|
|
136204
136203
|
|
|
136205
136204
|
// node_modules/drizzle-orm/tracing.js
|
|
136206
136205
|
var otel;
|
|
@@ -142404,6 +142403,18 @@ __export(exports_schema, {
|
|
|
142404
142403
|
permissionTable: () => permissionTable,
|
|
142405
142404
|
permissionGroupTable: () => permissionGroupTable,
|
|
142406
142405
|
logTable: () => logTable,
|
|
142406
|
+
inspectionTemplateTable: () => inspectionTemplateTable,
|
|
142407
|
+
inspectionTemplateMachineKindTable: () => inspectionTemplateMachineKindTable,
|
|
142408
|
+
inspectionTemplateFieldTable: () => inspectionTemplateFieldTable,
|
|
142409
|
+
inspectionTable: () => inspectionTable,
|
|
142410
|
+
inspectionStateResultEnum: () => inspectionStateResultEnum,
|
|
142411
|
+
inspectionStateEnum: () => inspectionStateEnum,
|
|
142412
|
+
inspectionSchema: () => inspectionSchema,
|
|
142413
|
+
inspectionScheduleTable: () => inspectionScheduleTable,
|
|
142414
|
+
inspectionFieldTypeEnum: () => inspectionFieldTypeEnum,
|
|
142415
|
+
inspectionFieldTable: () => inspectionFieldTable,
|
|
142416
|
+
inspectionFieldResult: () => inspectionFieldResult,
|
|
142417
|
+
inspectionFieldGroupTable: () => inspectionFieldGroupTable,
|
|
142407
142418
|
dataStoreTable: () => dataStoreTable,
|
|
142408
142419
|
crmVehicleTable: () => crmVehicleTable,
|
|
142409
142420
|
crmVehicleRelations: () => crmVehicleRelations,
|
|
@@ -142926,6 +142937,99 @@ var crmInspectionTable = crmSchema.table("inspections", {
|
|
|
142926
142937
|
description: text(),
|
|
142927
142938
|
status: crmInspectionStatusEnum("status").notNull().default("CREATED")
|
|
142928
142939
|
});
|
|
142940
|
+
// src/lib/db/schema/fleet.schema.ts
|
|
142941
|
+
var inspectionSchema = pgSchema("inspection");
|
|
142942
|
+
var inspectionFieldGroupTable = inspectionSchema.table("field_group", {
|
|
142943
|
+
...base_schema_helper_default,
|
|
142944
|
+
code: varchar(),
|
|
142945
|
+
name: varchar().notNull(),
|
|
142946
|
+
description: text()
|
|
142947
|
+
});
|
|
142948
|
+
var inspectionFieldTypeEnum = inspectionSchema.enum("field_type_enum", ["BOOLEAN", "NUMERIC", "TEXT", "DATE", "RATE", "MULTI_CHOICE"]);
|
|
142949
|
+
var inspectionFieldTable = inspectionSchema.table("field", {
|
|
142950
|
+
...base_schema_helper_default,
|
|
142951
|
+
groupId: uuid5().notNull(),
|
|
142952
|
+
code: varchar(),
|
|
142953
|
+
description: text(),
|
|
142954
|
+
version: varchar(),
|
|
142955
|
+
isActive: boolean4().notNull().default(true),
|
|
142956
|
+
metadata: jsonb(),
|
|
142957
|
+
required: boolean4().notNull().default(false),
|
|
142958
|
+
fieldGroup: varchar(),
|
|
142959
|
+
sortIndex: integer2()
|
|
142960
|
+
});
|
|
142961
|
+
var inspectionTemplateTable = inspectionSchema.table("template", {
|
|
142962
|
+
...base_schema_helper_default,
|
|
142963
|
+
companyId: uuid5(),
|
|
142964
|
+
name: varchar().notNull(),
|
|
142965
|
+
description: text(),
|
|
142966
|
+
version: varchar(),
|
|
142967
|
+
isActive: boolean4().notNull().default(true)
|
|
142968
|
+
});
|
|
142969
|
+
var inspectionTemplateFieldTable = inspectionSchema.table("template_field", {
|
|
142970
|
+
...base_schema_helper_default,
|
|
142971
|
+
templateId: uuid5().notNull(),
|
|
142972
|
+
fieldGroupId: uuid5(),
|
|
142973
|
+
fieldGroup: varchar(),
|
|
142974
|
+
fieldId: uuid5().notNull(),
|
|
142975
|
+
code: varchar(),
|
|
142976
|
+
description: text(),
|
|
142977
|
+
fieldType: inspectionFieldTypeEnum().notNull(),
|
|
142978
|
+
required: boolean4().notNull().default(false),
|
|
142979
|
+
metadata: jsonb(),
|
|
142980
|
+
sortIndex: integer2()
|
|
142981
|
+
});
|
|
142982
|
+
var inspectionTemplateMachineKindTable = inspectionSchema.table("template_machine_kind", {
|
|
142983
|
+
templateId: uuid5().notNull(),
|
|
142984
|
+
machineKindId: uuid5().notNull()
|
|
142985
|
+
});
|
|
142986
|
+
var inspectionStateEnum = inspectionSchema.enum("state", [
|
|
142987
|
+
"CREATED",
|
|
142988
|
+
"SCHEDULED",
|
|
142989
|
+
"IN_PROGRESS",
|
|
142990
|
+
"COMPLETED"
|
|
142991
|
+
]);
|
|
142992
|
+
var inspectionStateResultEnum = inspectionSchema.enum("state_result", [
|
|
142993
|
+
"NOT_INSPECTED",
|
|
142994
|
+
"PASSED",
|
|
142995
|
+
"FAILED",
|
|
142996
|
+
"RETURNED",
|
|
142997
|
+
"WAIVED"
|
|
142998
|
+
]);
|
|
142999
|
+
var inspectionTable = inspectionSchema.table("inspection", {
|
|
143000
|
+
...base_schema_helper_default,
|
|
143001
|
+
machineId: uuid5().notNull(),
|
|
143002
|
+
templateId: uuid5().notNull(),
|
|
143003
|
+
employeeInspectedId: uuid5().notNull(),
|
|
143004
|
+
userInspectedId: uuid5().notNull(),
|
|
143005
|
+
hours: numeric({ mode: "number" }),
|
|
143006
|
+
mileageKm: numeric({ mode: "number" }),
|
|
143007
|
+
state: inspectionStateEnum().notNull().default("CREATED"),
|
|
143008
|
+
stateResult: inspectionStateResultEnum(),
|
|
143009
|
+
timeScheduled: timestamp({
|
|
143010
|
+
withTimezone: true
|
|
143011
|
+
}).notNull(),
|
|
143012
|
+
timeStarted: timestamp({ withTimezone: true }).notNull(),
|
|
143013
|
+
timeCompleted: timestamp({ withTimezone: true }).notNull(),
|
|
143014
|
+
note: text()
|
|
143015
|
+
});
|
|
143016
|
+
var inspectionFieldResult = inspectionSchema.table("field_result", {
|
|
143017
|
+
...base_schema_helper_default,
|
|
143018
|
+
inspectionId: uuid5().notNull(),
|
|
143019
|
+
templateFieldId: uuid5().notNull(),
|
|
143020
|
+
result: varchar(),
|
|
143021
|
+
numeric: numeric({ mode: "number" }),
|
|
143022
|
+
comment: varchar(),
|
|
143023
|
+
severityLevel: integer2()
|
|
143024
|
+
});
|
|
143025
|
+
var inspectionScheduleTable = inspectionSchema.table("schedule", {
|
|
143026
|
+
...base_schema_helper_default,
|
|
143027
|
+
machineId: uuid5().notNull(),
|
|
143028
|
+
templateId: uuid5().notNull(),
|
|
143029
|
+
daysInterval: integer2(),
|
|
143030
|
+
timeNextDue: timestamp({ withTimezone: true }),
|
|
143031
|
+
isActive: boolean4().notNull().default(true)
|
|
143032
|
+
});
|
|
142929
143033
|
// src/lib/db/schema/techdoc.schema.ts
|
|
142930
143034
|
var techdocSchema = pgSchema("techdoc");
|
|
142931
143035
|
var techdocVehicleKindEnum = pgEnum("vehicle_kind_enum", [
|
|
@@ -142976,7 +143080,8 @@ var warehouseProductTable = warehouseSchema.table("product", {
|
|
|
142976
143080
|
partNumber: varchar().notNull(),
|
|
142977
143081
|
alias: varchar(),
|
|
142978
143082
|
companyId: uuid5().notNull(),
|
|
142979
|
-
type: warehouseProductTypeEnum().notNull().default("\u0421\u044D\u043B\u0431\u044D\u0433")
|
|
143083
|
+
type: warehouseProductTypeEnum().notNull().default("\u0421\u044D\u043B\u0431\u044D\u0433"),
|
|
143084
|
+
quantityUnit: integer2().notNull().default(1)
|
|
142980
143085
|
});
|
|
142981
143086
|
var warehouseWarehouseTable = warehouseSchema.table("warehouse", {
|
|
142982
143087
|
...base_schema_helper_default,
|
|
@@ -142990,7 +143095,6 @@ var warehouseItemTable = warehouseSchema.table("item", {
|
|
|
142990
143095
|
warehouseId: uuid5().notNull(),
|
|
142991
143096
|
productId: uuid5().notNull(),
|
|
142992
143097
|
quantity: numeric({ mode: "number" }).notNull().default(0),
|
|
142993
|
-
quantityUnit: integer2().notNull().default(1),
|
|
142994
143098
|
safetyStock: numeric({ mode: "number" }).notNull(),
|
|
142995
143099
|
shelfNumber: varchar(),
|
|
142996
143100
|
description: text(),
|
|
@@ -143042,7 +143146,7 @@ var db_default = db;
|
|
|
143042
143146
|
var webCrypto = globalThis.crypto;
|
|
143043
143147
|
var subtle = webCrypto.subtle;
|
|
143044
143148
|
|
|
143045
|
-
// node_modules/@upstash/redis/chunk-
|
|
143149
|
+
// node_modules/@upstash/redis/chunk-TAJI6TAE.mjs
|
|
143046
143150
|
var __defProp6 = Object.defineProperty;
|
|
143047
143151
|
var __export4 = (target, all) => {
|
|
143048
143152
|
for (var name in all)
|
|
@@ -143051,11 +143155,12 @@ var __export4 = (target, all) => {
|
|
|
143051
143155
|
var error_exports = {};
|
|
143052
143156
|
__export4(error_exports, {
|
|
143053
143157
|
UpstashError: () => UpstashError,
|
|
143158
|
+
UpstashJSONParseError: () => UpstashJSONParseError,
|
|
143054
143159
|
UrlError: () => UrlError
|
|
143055
143160
|
});
|
|
143056
143161
|
var UpstashError = class extends Error {
|
|
143057
|
-
constructor(message2) {
|
|
143058
|
-
super(message2);
|
|
143162
|
+
constructor(message2, options) {
|
|
143163
|
+
super(message2, options);
|
|
143059
143164
|
this.name = "UpstashError";
|
|
143060
143165
|
}
|
|
143061
143166
|
};
|
|
@@ -143065,6 +143170,13 @@ var UrlError = class extends Error {
|
|
|
143065
143170
|
this.name = "UrlError";
|
|
143066
143171
|
}
|
|
143067
143172
|
};
|
|
143173
|
+
var UpstashJSONParseError = class extends UpstashError {
|
|
143174
|
+
constructor(body, options) {
|
|
143175
|
+
const truncatedBody = body.length > 200 ? body.slice(0, 200) + "..." : body;
|
|
143176
|
+
super(`Unable to parse response body: ${truncatedBody}`, options);
|
|
143177
|
+
this.name = "UpstashJSONParseError";
|
|
143178
|
+
}
|
|
143179
|
+
};
|
|
143068
143180
|
function parseRecursive(obj2) {
|
|
143069
143181
|
const parsed = Array.isArray(obj2) ? obj2.map((o) => {
|
|
143070
143182
|
try {
|
|
@@ -143207,7 +143319,13 @@ var HttpClient = class {
|
|
|
143207
143319
|
throw error3 ?? new Error("Exhausted all retries");
|
|
143208
143320
|
}
|
|
143209
143321
|
if (!res.ok) {
|
|
143210
|
-
|
|
143322
|
+
let body2;
|
|
143323
|
+
const rawBody2 = await res.text();
|
|
143324
|
+
try {
|
|
143325
|
+
body2 = JSON.parse(rawBody2);
|
|
143326
|
+
} catch (error22) {
|
|
143327
|
+
throw new UpstashJSONParseError(rawBody2, { cause: error22 });
|
|
143328
|
+
}
|
|
143211
143329
|
throw new UpstashError(`${body2.error}, command was: ${JSON.stringify(req.body)}`);
|
|
143212
143330
|
}
|
|
143213
143331
|
if (this.readYourWrites) {
|
|
@@ -143245,7 +143363,13 @@ var HttpClient = class {
|
|
|
143245
143363
|
})();
|
|
143246
143364
|
return { result: 1 };
|
|
143247
143365
|
}
|
|
143248
|
-
|
|
143366
|
+
let body;
|
|
143367
|
+
const rawBody = await res.text();
|
|
143368
|
+
try {
|
|
143369
|
+
body = JSON.parse(rawBody);
|
|
143370
|
+
} catch (error22) {
|
|
143371
|
+
throw new UpstashJSONParseError(rawBody, { cause: error22 });
|
|
143372
|
+
}
|
|
143249
143373
|
if (this.readYourWrites) {
|
|
143250
143374
|
const headers = res.headers;
|
|
143251
143375
|
this.upstashSyncToken = headers.get("upstash-sync-token") ?? "";
|
|
@@ -145829,7 +145953,7 @@ var Redis = class {
|
|
|
145829
145953
|
zunion = (...args) => new ZUnionCommand(args, this.opts).exec(this.client);
|
|
145830
145954
|
zunionstore = (...args) => new ZUnionStoreCommand(args, this.opts).exec(this.client);
|
|
145831
145955
|
};
|
|
145832
|
-
var VERSION = "v1.35.
|
|
145956
|
+
var VERSION = "v1.35.6";
|
|
145833
145957
|
|
|
145834
145958
|
// node_modules/@upstash/redis/nodejs.mjs
|
|
145835
145959
|
if (typeof atob === "undefined") {
|
|
@@ -149093,13 +149217,21 @@ class HTTPError extends Error {
|
|
|
149093
149217
|
}
|
|
149094
149218
|
}
|
|
149095
149219
|
|
|
149096
|
-
// node_modules/ky/distribution/errors/
|
|
149097
|
-
class
|
|
149098
|
-
|
|
149099
|
-
|
|
149100
|
-
|
|
149101
|
-
|
|
149102
|
-
|
|
149220
|
+
// node_modules/ky/distribution/errors/NonError.js
|
|
149221
|
+
class NonError extends Error {
|
|
149222
|
+
name = "NonError";
|
|
149223
|
+
value;
|
|
149224
|
+
constructor(value) {
|
|
149225
|
+
let message2 = "Non-error value was thrown";
|
|
149226
|
+
try {
|
|
149227
|
+
if (typeof value === "string") {
|
|
149228
|
+
message2 = value;
|
|
149229
|
+
} else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
|
|
149230
|
+
message2 = value.message;
|
|
149231
|
+
}
|
|
149232
|
+
} catch {}
|
|
149233
|
+
super(message2);
|
|
149234
|
+
this.value = value;
|
|
149103
149235
|
}
|
|
149104
149236
|
}
|
|
149105
149237
|
|
|
@@ -149160,7 +149292,11 @@ var kyOptionKeys = {
|
|
|
149160
149292
|
throwHttpErrors: true,
|
|
149161
149293
|
onDownloadProgress: true,
|
|
149162
149294
|
onUploadProgress: true,
|
|
149163
|
-
fetch: true
|
|
149295
|
+
fetch: true,
|
|
149296
|
+
context: true
|
|
149297
|
+
};
|
|
149298
|
+
var vendorSpecificOptions = {
|
|
149299
|
+
next: true
|
|
149164
149300
|
};
|
|
149165
149301
|
var requestOptionsRegistry = {
|
|
149166
149302
|
method: true,
|
|
@@ -149176,9 +149312,7 @@ var requestOptionsRegistry = {
|
|
|
149176
149312
|
keepalive: true,
|
|
149177
149313
|
signal: true,
|
|
149178
149314
|
window: true,
|
|
149179
|
-
|
|
149180
|
-
duplex: true,
|
|
149181
|
-
priority: true
|
|
149315
|
+
duplex: true
|
|
149182
149316
|
};
|
|
149183
149317
|
|
|
149184
149318
|
// node_modules/ky/distribution/utils/body.js
|
|
@@ -149255,7 +149389,7 @@ var streamResponse2 = (response, onDownloadProgress) => {
|
|
|
149255
149389
|
headers: response.headers
|
|
149256
149390
|
});
|
|
149257
149391
|
}
|
|
149258
|
-
const totalBytes = Number(response.headers.get("content-length")) || 0;
|
|
149392
|
+
const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
|
|
149259
149393
|
return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
|
|
149260
149394
|
status: response.status,
|
|
149261
149395
|
statusText: response.statusText,
|
|
@@ -149307,10 +149441,44 @@ var mergeHooks = (original = {}, incoming = {}) => ({
|
|
|
149307
149441
|
afterResponse: newHookValue(original, incoming, "afterResponse"),
|
|
149308
149442
|
beforeError: newHookValue(original, incoming, "beforeError")
|
|
149309
149443
|
});
|
|
149444
|
+
var appendSearchParameters = (target, source) => {
|
|
149445
|
+
const result = new URLSearchParams;
|
|
149446
|
+
for (const input of [target, source]) {
|
|
149447
|
+
if (input === undefined) {
|
|
149448
|
+
continue;
|
|
149449
|
+
}
|
|
149450
|
+
if (input instanceof URLSearchParams) {
|
|
149451
|
+
for (const [key, value] of input.entries()) {
|
|
149452
|
+
result.append(key, value);
|
|
149453
|
+
}
|
|
149454
|
+
} else if (Array.isArray(input)) {
|
|
149455
|
+
for (const pair of input) {
|
|
149456
|
+
if (!Array.isArray(pair) || pair.length !== 2) {
|
|
149457
|
+
throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
|
|
149458
|
+
}
|
|
149459
|
+
result.append(String(pair[0]), String(pair[1]));
|
|
149460
|
+
}
|
|
149461
|
+
} else if (isObject6(input)) {
|
|
149462
|
+
for (const [key, value] of Object.entries(input)) {
|
|
149463
|
+
if (value !== undefined) {
|
|
149464
|
+
result.append(key, String(value));
|
|
149465
|
+
}
|
|
149466
|
+
}
|
|
149467
|
+
} else {
|
|
149468
|
+
const parameters = new URLSearchParams(input);
|
|
149469
|
+
for (const [key, value] of parameters.entries()) {
|
|
149470
|
+
result.append(key, value);
|
|
149471
|
+
}
|
|
149472
|
+
}
|
|
149473
|
+
}
|
|
149474
|
+
return result;
|
|
149475
|
+
};
|
|
149310
149476
|
var deepMerge = (...sources) => {
|
|
149311
149477
|
let returnValue = {};
|
|
149312
149478
|
let headers = {};
|
|
149313
149479
|
let hooks = {};
|
|
149480
|
+
let searchParameters;
|
|
149481
|
+
const signals = [];
|
|
149314
149482
|
for (const source of sources) {
|
|
149315
149483
|
if (Array.isArray(source)) {
|
|
149316
149484
|
if (!Array.isArray(returnValue)) {
|
|
@@ -149319,6 +149487,28 @@ var deepMerge = (...sources) => {
|
|
|
149319
149487
|
returnValue = [...returnValue, ...source];
|
|
149320
149488
|
} else if (isObject6(source)) {
|
|
149321
149489
|
for (let [key, value] of Object.entries(source)) {
|
|
149490
|
+
if (key === "signal" && value instanceof globalThis.AbortSignal) {
|
|
149491
|
+
signals.push(value);
|
|
149492
|
+
continue;
|
|
149493
|
+
}
|
|
149494
|
+
if (key === "context") {
|
|
149495
|
+
if (value !== undefined && value !== null && (!isObject6(value) || Array.isArray(value))) {
|
|
149496
|
+
throw new TypeError("The `context` option must be an object");
|
|
149497
|
+
}
|
|
149498
|
+
returnValue = {
|
|
149499
|
+
...returnValue,
|
|
149500
|
+
context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
|
|
149501
|
+
};
|
|
149502
|
+
continue;
|
|
149503
|
+
}
|
|
149504
|
+
if (key === "searchParams") {
|
|
149505
|
+
if (value === undefined || value === null) {
|
|
149506
|
+
searchParameters = undefined;
|
|
149507
|
+
} else {
|
|
149508
|
+
searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
|
|
149509
|
+
}
|
|
149510
|
+
continue;
|
|
149511
|
+
}
|
|
149322
149512
|
if (isObject6(value) && key in returnValue) {
|
|
149323
149513
|
value = deepMerge(returnValue[key], value);
|
|
149324
149514
|
}
|
|
@@ -149334,6 +149524,21 @@ var deepMerge = (...sources) => {
|
|
|
149334
149524
|
}
|
|
149335
149525
|
}
|
|
149336
149526
|
}
|
|
149527
|
+
if (searchParameters !== undefined) {
|
|
149528
|
+
returnValue.searchParams = searchParameters;
|
|
149529
|
+
}
|
|
149530
|
+
if (signals.length > 0) {
|
|
149531
|
+
if (signals.length === 1) {
|
|
149532
|
+
returnValue.signal = signals[0];
|
|
149533
|
+
} else if (supportsAbortSignal) {
|
|
149534
|
+
returnValue.signal = AbortSignal.any(signals);
|
|
149535
|
+
} else {
|
|
149536
|
+
returnValue.signal = signals.at(-1);
|
|
149537
|
+
}
|
|
149538
|
+
}
|
|
149539
|
+
if (returnValue.context === undefined) {
|
|
149540
|
+
returnValue.context = {};
|
|
149541
|
+
}
|
|
149337
149542
|
return returnValue;
|
|
149338
149543
|
};
|
|
149339
149544
|
|
|
@@ -149349,7 +149554,9 @@ var defaultRetryOptions = {
|
|
|
149349
149554
|
afterStatusCodes: retryAfterStatusCodes,
|
|
149350
149555
|
maxRetryAfter: Number.POSITIVE_INFINITY,
|
|
149351
149556
|
backoffLimit: Number.POSITIVE_INFINITY,
|
|
149352
|
-
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000
|
|
149557
|
+
delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
|
|
149558
|
+
jitter: undefined,
|
|
149559
|
+
retryOnTimeout: false
|
|
149353
149560
|
};
|
|
149354
149561
|
var normalizeRetryOptions = (retry = {}) => {
|
|
149355
149562
|
if (typeof retry === "number") {
|
|
@@ -149370,6 +149577,16 @@ var normalizeRetryOptions = (retry = {}) => {
|
|
|
149370
149577
|
};
|
|
149371
149578
|
};
|
|
149372
149579
|
|
|
149580
|
+
// node_modules/ky/distribution/errors/TimeoutError.js
|
|
149581
|
+
class TimeoutError extends Error {
|
|
149582
|
+
request;
|
|
149583
|
+
constructor(request) {
|
|
149584
|
+
super(`Request timed out: ${request.method} ${request.url}`);
|
|
149585
|
+
this.name = "TimeoutError";
|
|
149586
|
+
this.request = request;
|
|
149587
|
+
}
|
|
149588
|
+
}
|
|
149589
|
+
|
|
149373
149590
|
// node_modules/ky/distribution/utils/timeout.js
|
|
149374
149591
|
async function timeout(request, init2, abortController, options) {
|
|
149375
149592
|
return new Promise((resolve, reject) => {
|
|
@@ -149407,7 +149624,10 @@ async function delay(ms2, { signal }) {
|
|
|
149407
149624
|
var findUnknownOptions = (request, options) => {
|
|
149408
149625
|
const unknownOptions = {};
|
|
149409
149626
|
for (const key in options) {
|
|
149410
|
-
if (!(
|
|
149627
|
+
if (!Object.hasOwn(options, key)) {
|
|
149628
|
+
continue;
|
|
149629
|
+
}
|
|
149630
|
+
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
|
|
149411
149631
|
unknownOptions[key] = options[key];
|
|
149412
149632
|
}
|
|
149413
149633
|
}
|
|
@@ -149432,44 +149652,52 @@ var hasSearchParameters = (search) => {
|
|
|
149432
149652
|
return Boolean(search);
|
|
149433
149653
|
};
|
|
149434
149654
|
|
|
149655
|
+
// node_modules/ky/distribution/utils/type-guards.js
|
|
149656
|
+
function isHTTPError(error3) {
|
|
149657
|
+
return error3 instanceof HTTPError || error3?.name === HTTPError.name;
|
|
149658
|
+
}
|
|
149659
|
+
function isTimeoutError(error3) {
|
|
149660
|
+
return error3 instanceof TimeoutError || error3?.name === TimeoutError.name;
|
|
149661
|
+
}
|
|
149662
|
+
|
|
149435
149663
|
// node_modules/ky/distribution/core/Ky.js
|
|
149436
149664
|
class Ky {
|
|
149437
149665
|
static create(input, options) {
|
|
149438
149666
|
const ky = new Ky(input, options);
|
|
149439
149667
|
const function_ = async () => {
|
|
149440
|
-
if (typeof ky.
|
|
149668
|
+
if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
|
|
149441
149669
|
throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
|
|
149442
149670
|
}
|
|
149443
149671
|
await Promise.resolve();
|
|
149444
|
-
let response = await ky
|
|
149445
|
-
for (const hook of ky.
|
|
149446
|
-
const modifiedResponse = await hook(ky.request, ky
|
|
149672
|
+
let response = await ky.#fetch();
|
|
149673
|
+
for (const hook of ky.#options.hooks.afterResponse) {
|
|
149674
|
+
const modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), ky.#decorateResponse(response.clone()), { retryCount: ky.#retryCount });
|
|
149447
149675
|
if (modifiedResponse instanceof globalThis.Response) {
|
|
149448
149676
|
response = modifiedResponse;
|
|
149449
149677
|
}
|
|
149450
149678
|
}
|
|
149451
|
-
ky
|
|
149452
|
-
if (!response.ok && ky.
|
|
149453
|
-
let error3 = new HTTPError(response, ky.request, ky
|
|
149454
|
-
for (const hook of ky.
|
|
149455
|
-
error3 = await hook(error3);
|
|
149679
|
+
ky.#decorateResponse(response);
|
|
149680
|
+
if (!response.ok && ky.#options.throwHttpErrors) {
|
|
149681
|
+
let error3 = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
|
|
149682
|
+
for (const hook of ky.#options.hooks.beforeError) {
|
|
149683
|
+
error3 = await hook(error3, { retryCount: ky.#retryCount });
|
|
149456
149684
|
}
|
|
149457
149685
|
throw error3;
|
|
149458
149686
|
}
|
|
149459
|
-
if (ky.
|
|
149460
|
-
if (typeof ky.
|
|
149687
|
+
if (ky.#options.onDownloadProgress) {
|
|
149688
|
+
if (typeof ky.#options.onDownloadProgress !== "function") {
|
|
149461
149689
|
throw new TypeError("The `onDownloadProgress` option must be a function");
|
|
149462
149690
|
}
|
|
149463
149691
|
if (!supportsResponseStreams) {
|
|
149464
149692
|
throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
|
|
149465
149693
|
}
|
|
149466
|
-
return streamResponse2(response.clone(), ky.
|
|
149694
|
+
return streamResponse2(response.clone(), ky.#options.onDownloadProgress);
|
|
149467
149695
|
}
|
|
149468
149696
|
return response;
|
|
149469
149697
|
};
|
|
149470
|
-
const isRetriableMethod = ky.
|
|
149471
|
-
const result = (isRetriableMethod ? ky
|
|
149472
|
-
const originalRequest = ky
|
|
149698
|
+
const isRetriableMethod = ky.#options.retry.methods.includes(ky.request.method.toLowerCase());
|
|
149699
|
+
const result = (isRetriableMethod ? ky.#retry(function_) : function_()).finally(async () => {
|
|
149700
|
+
const originalRequest = ky.#originalRequest;
|
|
149473
149701
|
const cleanupPromises = [];
|
|
149474
149702
|
if (originalRequest && !originalRequest.bodyUsed) {
|
|
149475
149703
|
cleanupPromises.push(originalRequest.body?.cancel());
|
|
@@ -149511,65 +149739,69 @@ class Ky {
|
|
|
149511
149739
|
return searchParams;
|
|
149512
149740
|
}
|
|
149513
149741
|
request;
|
|
149514
|
-
abortController;
|
|
149515
|
-
|
|
149516
|
-
|
|
149517
|
-
|
|
149518
|
-
|
|
149742
|
+
#abortController;
|
|
149743
|
+
#retryCount = 0;
|
|
149744
|
+
#input;
|
|
149745
|
+
#options;
|
|
149746
|
+
#originalRequest;
|
|
149747
|
+
#userProvidedAbortSignal;
|
|
149748
|
+
#cachedNormalizedOptions;
|
|
149519
149749
|
constructor(input, options = {}) {
|
|
149520
|
-
this
|
|
149521
|
-
this
|
|
149750
|
+
this.#input = input;
|
|
149751
|
+
this.#options = {
|
|
149522
149752
|
...options,
|
|
149523
|
-
headers: mergeHeaders2(this.
|
|
149753
|
+
headers: mergeHeaders2(this.#input.headers, options.headers),
|
|
149524
149754
|
hooks: mergeHooks({
|
|
149525
149755
|
beforeRequest: [],
|
|
149526
149756
|
beforeRetry: [],
|
|
149527
149757
|
beforeError: [],
|
|
149528
149758
|
afterResponse: []
|
|
149529
149759
|
}, options.hooks),
|
|
149530
|
-
method: normalizeRequestMethod(options.method ?? this.
|
|
149760
|
+
method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
|
|
149531
149761
|
prefixUrl: String(options.prefixUrl || ""),
|
|
149532
149762
|
retry: normalizeRetryOptions(options.retry),
|
|
149533
149763
|
throwHttpErrors: options.throwHttpErrors !== false,
|
|
149534
149764
|
timeout: options.timeout ?? 1e4,
|
|
149535
|
-
fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
|
|
149765
|
+
fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
|
|
149766
|
+
context: options.context ?? {}
|
|
149536
149767
|
};
|
|
149537
|
-
if (typeof this
|
|
149768
|
+
if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
|
|
149538
149769
|
throw new TypeError("`input` must be a string, URL, or Request");
|
|
149539
149770
|
}
|
|
149540
|
-
if (this.
|
|
149541
|
-
if (this.
|
|
149771
|
+
if (this.#options.prefixUrl && typeof this.#input === "string") {
|
|
149772
|
+
if (this.#input.startsWith("/")) {
|
|
149542
149773
|
throw new Error("`input` must not begin with a slash when using `prefixUrl`");
|
|
149543
149774
|
}
|
|
149544
|
-
if (!this.
|
|
149545
|
-
this.
|
|
149775
|
+
if (!this.#options.prefixUrl.endsWith("/")) {
|
|
149776
|
+
this.#options.prefixUrl += "/";
|
|
149546
149777
|
}
|
|
149547
|
-
this
|
|
149778
|
+
this.#input = this.#options.prefixUrl + this.#input;
|
|
149548
149779
|
}
|
|
149549
149780
|
if (supportsAbortController && supportsAbortSignal) {
|
|
149550
|
-
|
|
149551
|
-
this
|
|
149552
|
-
this.
|
|
149781
|
+
this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
|
|
149782
|
+
this.#abortController = new globalThis.AbortController;
|
|
149783
|
+
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
149553
149784
|
}
|
|
149554
149785
|
if (supportsRequestStreams) {
|
|
149555
|
-
this.
|
|
149786
|
+
this.#options.duplex = "half";
|
|
149556
149787
|
}
|
|
149557
|
-
if (this.
|
|
149558
|
-
this.
|
|
149559
|
-
this.
|
|
149788
|
+
if (this.#options.json !== undefined) {
|
|
149789
|
+
this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
|
|
149790
|
+
this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
|
|
149560
149791
|
}
|
|
149561
|
-
|
|
149562
|
-
if (
|
|
149563
|
-
|
|
149792
|
+
const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
|
|
149793
|
+
if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
|
|
149794
|
+
this.#options.headers.delete("content-type");
|
|
149795
|
+
}
|
|
149796
|
+
this.request = new globalThis.Request(this.#input, this.#options);
|
|
149797
|
+
if (hasSearchParameters(this.#options.searchParams)) {
|
|
149798
|
+
const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
|
|
149564
149799
|
const searchParams = "?" + textSearchParams;
|
|
149565
149800
|
const url2 = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
|
|
149566
|
-
|
|
149567
|
-
this.request.headers.delete("content-type");
|
|
149568
|
-
}
|
|
149569
|
-
this.request = new globalThis.Request(new globalThis.Request(url2, { ...this.request }), this._options);
|
|
149801
|
+
this.request = new globalThis.Request(new globalThis.Request(url2, { ...this.request }), this.#options);
|
|
149570
149802
|
}
|
|
149571
|
-
if (this.
|
|
149572
|
-
if (typeof this.
|
|
149803
|
+
if (this.#options.onUploadProgress) {
|
|
149804
|
+
if (typeof this.#options.onUploadProgress !== "function") {
|
|
149573
149805
|
throw new TypeError("The `onUploadProgress` option must be a function");
|
|
149574
149806
|
}
|
|
149575
149807
|
if (!supportsRequestStreams) {
|
|
@@ -149577,69 +149809,106 @@ class Ky {
|
|
|
149577
149809
|
}
|
|
149578
149810
|
const originalBody = this.request.body;
|
|
149579
149811
|
if (originalBody) {
|
|
149580
|
-
this.request = streamRequest(this.request, this.
|
|
149812
|
+
this.request = streamRequest(this.request, this.#options.onUploadProgress, this.#options.body);
|
|
149813
|
+
}
|
|
149814
|
+
}
|
|
149815
|
+
}
|
|
149816
|
+
#calculateDelay() {
|
|
149817
|
+
const retryDelay = this.#options.retry.delay(this.#retryCount);
|
|
149818
|
+
let jitteredDelay = retryDelay;
|
|
149819
|
+
if (this.#options.retry.jitter === true) {
|
|
149820
|
+
jitteredDelay = Math.random() * retryDelay;
|
|
149821
|
+
} else if (typeof this.#options.retry.jitter === "function") {
|
|
149822
|
+
jitteredDelay = this.#options.retry.jitter(retryDelay);
|
|
149823
|
+
if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
|
|
149824
|
+
jitteredDelay = retryDelay;
|
|
149581
149825
|
}
|
|
149582
149826
|
}
|
|
149827
|
+
return Math.min(this.#options.retry.backoffLimit, jitteredDelay);
|
|
149583
149828
|
}
|
|
149584
|
-
|
|
149585
|
-
this
|
|
149586
|
-
if (this
|
|
149829
|
+
async#calculateRetryDelay(error3) {
|
|
149830
|
+
this.#retryCount++;
|
|
149831
|
+
if (this.#retryCount > this.#options.retry.limit) {
|
|
149832
|
+
throw error3;
|
|
149833
|
+
}
|
|
149834
|
+
const errorObject = error3 instanceof Error ? error3 : new NonError(error3);
|
|
149835
|
+
if (this.#options.retry.shouldRetry !== undefined) {
|
|
149836
|
+
const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
|
|
149837
|
+
if (result === false) {
|
|
149838
|
+
throw error3;
|
|
149839
|
+
}
|
|
149840
|
+
if (result === true) {
|
|
149841
|
+
return this.#calculateDelay();
|
|
149842
|
+
}
|
|
149843
|
+
}
|
|
149844
|
+
if (isTimeoutError(error3) && !this.#options.retry.retryOnTimeout) {
|
|
149587
149845
|
throw error3;
|
|
149588
149846
|
}
|
|
149589
|
-
if (error3
|
|
149590
|
-
if (!this.
|
|
149847
|
+
if (isHTTPError(error3)) {
|
|
149848
|
+
if (!this.#options.retry.statusCodes.includes(error3.response.status)) {
|
|
149591
149849
|
throw error3;
|
|
149592
149850
|
}
|
|
149593
|
-
const retryAfter = error3.response.headers.get("Retry-After") ?? error3.response.headers.get("RateLimit-Reset") ?? error3.response.headers.get("X-RateLimit-Reset") ?? error3.response.headers.get("X-Rate-Limit-Reset");
|
|
149594
|
-
if (retryAfter && this.
|
|
149851
|
+
const retryAfter = error3.response.headers.get("Retry-After") ?? error3.response.headers.get("RateLimit-Reset") ?? error3.response.headers.get("X-RateLimit-Retry-After") ?? error3.response.headers.get("X-RateLimit-Reset") ?? error3.response.headers.get("X-Rate-Limit-Reset");
|
|
149852
|
+
if (retryAfter && this.#options.retry.afterStatusCodes.includes(error3.response.status)) {
|
|
149595
149853
|
let after = Number(retryAfter) * 1000;
|
|
149596
149854
|
if (Number.isNaN(after)) {
|
|
149597
149855
|
after = Date.parse(retryAfter) - Date.now();
|
|
149598
149856
|
} else if (after >= Date.parse("2024-01-01")) {
|
|
149599
149857
|
after -= Date.now();
|
|
149600
149858
|
}
|
|
149601
|
-
const max2 = this.
|
|
149859
|
+
const max2 = this.#options.retry.maxRetryAfter ?? after;
|
|
149602
149860
|
return after < max2 ? after : max2;
|
|
149603
149861
|
}
|
|
149604
149862
|
if (error3.response.status === 413) {
|
|
149605
149863
|
throw error3;
|
|
149606
149864
|
}
|
|
149607
149865
|
}
|
|
149608
|
-
|
|
149609
|
-
return Math.min(this._options.retry.backoffLimit, retryDelay);
|
|
149866
|
+
return this.#calculateDelay();
|
|
149610
149867
|
}
|
|
149611
|
-
|
|
149612
|
-
if (this.
|
|
149613
|
-
response.json = async () => this.
|
|
149868
|
+
#decorateResponse(response) {
|
|
149869
|
+
if (this.#options.parseJson) {
|
|
149870
|
+
response.json = async () => this.#options.parseJson(await response.text());
|
|
149614
149871
|
}
|
|
149615
149872
|
return response;
|
|
149616
149873
|
}
|
|
149617
|
-
async
|
|
149874
|
+
async#retry(function_) {
|
|
149618
149875
|
try {
|
|
149619
149876
|
return await function_();
|
|
149620
149877
|
} catch (error3) {
|
|
149621
|
-
const ms2 = Math.min(this
|
|
149622
|
-
if (this
|
|
149878
|
+
const ms2 = Math.min(await this.#calculateRetryDelay(error3), maxSafeTimeout);
|
|
149879
|
+
if (this.#retryCount < 1) {
|
|
149623
149880
|
throw error3;
|
|
149624
149881
|
}
|
|
149625
|
-
await delay(ms2, { signal: this
|
|
149626
|
-
for (const hook of this.
|
|
149882
|
+
await delay(ms2, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
|
|
149883
|
+
for (const hook of this.#options.hooks.beforeRetry) {
|
|
149627
149884
|
const hookResult = await hook({
|
|
149628
149885
|
request: this.request,
|
|
149629
|
-
options: this
|
|
149886
|
+
options: this.#getNormalizedOptions(),
|
|
149630
149887
|
error: error3,
|
|
149631
|
-
retryCount: this
|
|
149888
|
+
retryCount: this.#retryCount
|
|
149632
149889
|
});
|
|
149890
|
+
if (hookResult instanceof globalThis.Request) {
|
|
149891
|
+
this.request = hookResult;
|
|
149892
|
+
break;
|
|
149893
|
+
}
|
|
149894
|
+
if (hookResult instanceof globalThis.Response) {
|
|
149895
|
+
return hookResult;
|
|
149896
|
+
}
|
|
149633
149897
|
if (hookResult === stop) {
|
|
149634
149898
|
return;
|
|
149635
149899
|
}
|
|
149636
149900
|
}
|
|
149637
|
-
return this
|
|
149901
|
+
return this.#retry(function_);
|
|
149638
149902
|
}
|
|
149639
149903
|
}
|
|
149640
|
-
async
|
|
149641
|
-
|
|
149642
|
-
|
|
149904
|
+
async#fetch() {
|
|
149905
|
+
if (this.#abortController?.signal.aborted) {
|
|
149906
|
+
this.#abortController = new globalThis.AbortController;
|
|
149907
|
+
this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
|
|
149908
|
+
this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
|
|
149909
|
+
}
|
|
149910
|
+
for (const hook of this.#options.hooks.beforeRequest) {
|
|
149911
|
+
const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
|
|
149643
149912
|
if (result instanceof Request) {
|
|
149644
149913
|
this.request = result;
|
|
149645
149914
|
break;
|
|
@@ -149648,13 +149917,20 @@ class Ky {
|
|
|
149648
149917
|
return result;
|
|
149649
149918
|
}
|
|
149650
149919
|
}
|
|
149651
|
-
const nonRequestOptions = findUnknownOptions(this.request, this
|
|
149652
|
-
this
|
|
149653
|
-
this.request = this.
|
|
149654
|
-
if (this.
|
|
149655
|
-
return this.
|
|
149920
|
+
const nonRequestOptions = findUnknownOptions(this.request, this.#options);
|
|
149921
|
+
this.#originalRequest = this.request;
|
|
149922
|
+
this.request = this.#originalRequest.clone();
|
|
149923
|
+
if (this.#options.timeout === false) {
|
|
149924
|
+
return this.#options.fetch(this.#originalRequest, nonRequestOptions);
|
|
149656
149925
|
}
|
|
149657
|
-
return timeout(this
|
|
149926
|
+
return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
|
|
149927
|
+
}
|
|
149928
|
+
#getNormalizedOptions() {
|
|
149929
|
+
if (!this.#cachedNormalizedOptions) {
|
|
149930
|
+
const { hooks, ...normalizedOptions } = this.#options;
|
|
149931
|
+
this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
|
|
149932
|
+
}
|
|
149933
|
+
return this.#cachedNormalizedOptions;
|
|
149658
149934
|
}
|
|
149659
149935
|
}
|
|
149660
149936
|
|
|
@@ -149834,7 +150110,12 @@ var CrmVehicleLogic;
|
|
|
149834
150110
|
yearImport: new Date(atutData.imported_date).getFullYear(),
|
|
149835
150111
|
engineCode: atutData.engine_model_name
|
|
149836
150112
|
};
|
|
149837
|
-
const [result] = await tdb.insert(crmVehicleTable).values(insertData).
|
|
150113
|
+
const [result] = await tdb.insert(crmVehicleTable).values(insertData).onConflictDoUpdate({
|
|
150114
|
+
target: crmVehicleTable.vin,
|
|
150115
|
+
set: {
|
|
150116
|
+
licensePlate: insertData.licensePlate
|
|
150117
|
+
}
|
|
150118
|
+
}).returning();
|
|
149838
150119
|
return result;
|
|
149839
150120
|
};
|
|
149840
150121
|
CrmVehicleLogic.select = async (query, user2) => {
|
|
@@ -151329,7 +151610,8 @@ var CrmCpOrderModel;
|
|
|
151329
151610
|
type: t.UnionEnum(crmCpOrderTypeEnum.enumValues, {
|
|
151330
151611
|
default: "Service"
|
|
151331
151612
|
}),
|
|
151332
|
-
oldId: t.Number()
|
|
151613
|
+
oldId: t.Number(),
|
|
151614
|
+
isPaid: t.Boolean()
|
|
151333
151615
|
}))
|
|
151334
151616
|
]);
|
|
151335
151617
|
CrmCpOrderModel.complete = t.Object({
|
|
@@ -151861,6 +152143,41 @@ var CrmInspectionLogic;
|
|
|
151861
152143
|
}).from(crmInspectionTable).where(eq(crmInspectionTable.licensePlate, licensePlate)).leftJoin(companyCompanyTable, eq(companyCompanyTable.id, crmInspectionTable.companyId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmInspectionTable.vehicleId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmInspectionTable.employeeId)).orderBy(desc(crmInspectionTable.createdAt));
|
|
151862
152144
|
return inspections;
|
|
151863
152145
|
};
|
|
152146
|
+
CrmInspectionLogic.selectAdmin = async (query) => {
|
|
152147
|
+
const baseQuery = db_default.select({
|
|
152148
|
+
company: {
|
|
152149
|
+
id: companyCompanyTable.id,
|
|
152150
|
+
name: companyCompanyTable.name,
|
|
152151
|
+
serviceName: companyCompanyTable.serviceName,
|
|
152152
|
+
logoUrl: companyCompanyTable.logoUrl
|
|
152153
|
+
},
|
|
152154
|
+
vehicle: {
|
|
152155
|
+
licensePlate: crmVehicleTable.licensePlate,
|
|
152156
|
+
vin: crmVehicleTable.vin,
|
|
152157
|
+
model: techdocVehicleKindTable.name
|
|
152158
|
+
},
|
|
152159
|
+
employee: {
|
|
152160
|
+
firstname: companyEmployeeTable.firstname,
|
|
152161
|
+
lastname: companyEmployeeTable.lastname
|
|
152162
|
+
},
|
|
152163
|
+
inspection: {
|
|
152164
|
+
inspection: crmInspectionTable.inspection,
|
|
152165
|
+
createdAt: crmInspectionTable.createdAt,
|
|
152166
|
+
expireAt: crmInspectionTable.expireAt,
|
|
152167
|
+
status: crmInspectionTable.status
|
|
152168
|
+
},
|
|
152169
|
+
totalCount: totalCountSql
|
|
152170
|
+
}).from(crmInspectionTable).where(eq(crmInspectionTable.companyId, query.companyId).if(query.companyId)).leftJoin(companyCompanyTable, eq(companyCompanyTable.id, crmInspectionTable.companyId)).leftJoin(crmVehicleTable, eq(crmVehicleTable.id, crmInspectionTable.vehicleId)).leftJoin(techdocVehicleKindTable, eq(techdocVehicleKindTable.id, crmVehicleTable.vehicleKindId)).leftJoin(companyEmployeeTable, eq(companyEmployeeTable.id, crmInspectionTable.employeeId)).orderBy(desc(crmInspectionTable.createdAt)).$dynamic();
|
|
152171
|
+
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
152172
|
+
const content = {
|
|
152173
|
+
totalCount: result[0]?.totalCount ?? 0,
|
|
152174
|
+
totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
|
|
152175
|
+
};
|
|
152176
|
+
return {
|
|
152177
|
+
result,
|
|
152178
|
+
...content
|
|
152179
|
+
};
|
|
152180
|
+
};
|
|
151864
152181
|
})(CrmInspectionLogic ||= {});
|
|
151865
152182
|
var logic_default17 = CrmInspectionLogic;
|
|
151866
152183
|
|
|
@@ -151893,6 +152210,12 @@ var CrmInspectionModel;
|
|
|
151893
152210
|
CrmInspectionModel.selectUbCab = t.Object({
|
|
151894
152211
|
licensePlate: t.String()
|
|
151895
152212
|
});
|
|
152213
|
+
CrmInspectionModel.selectAdmin = t.Composite([
|
|
152214
|
+
t.Partial(t.Object({
|
|
152215
|
+
companyId: t.String({ format: "uuid" })
|
|
152216
|
+
})),
|
|
152217
|
+
PaginationSchema
|
|
152218
|
+
]);
|
|
151896
152219
|
})(CrmInspectionModel ||= {});
|
|
151897
152220
|
var model_default13 = CrmInspectionModel;
|
|
151898
152221
|
|
|
@@ -151907,6 +152230,9 @@ var inspectionRoutes = new Elysia({
|
|
|
151907
152230
|
query: model_default13.select
|
|
151908
152231
|
}).post("/", async ({ body, user: user2 }) => logic_default17.create(body, user2), {
|
|
151909
152232
|
body: model_default13.create
|
|
152233
|
+
}).get("/admin", async ({ query }) => logic_default17.selectAdmin(query), {
|
|
152234
|
+
query: model_default13.selectAdmin,
|
|
152235
|
+
userKind: "ADMIN"
|
|
151910
152236
|
}).guard({
|
|
151911
152237
|
params: IdSchema
|
|
151912
152238
|
}).get("/:id", async ({ params: { id }, user: user2 }) => logic_default17.getById(id, user2)).post("/:id", async ({ params: { id }, user: user2 }) => logic_default17.approve(id, user2)).put("/:id", async ({ params: { id }, user: user2 }) => logic_default17.cancel(id, user2)).post("/:id/service-order", async ({ params: { id }, user: user2 }) => logic_default17.createCpOrder(id, user2));
|
|
@@ -153555,10 +153881,110 @@ var warehouseSchemaRoutes = new Elysia({
|
|
|
153555
153881
|
}).use(product_default3).use(warehouse_default).use(item_default3);
|
|
153556
153882
|
var warehouse_default2 = warehouseSchemaRoutes;
|
|
153557
153883
|
|
|
153884
|
+
// src/routes/fleet/inspection/field/logic.ts
|
|
153885
|
+
var InspectionFieldLogic;
|
|
153886
|
+
((InspectionFieldLogic) => {
|
|
153887
|
+
InspectionFieldLogic.select = async (groupId) => {
|
|
153888
|
+
const result = await db_default.select().from(inspectionFieldTable).where(eq(inspectionFieldTable.groupId, groupId));
|
|
153889
|
+
return result;
|
|
153890
|
+
};
|
|
153891
|
+
InspectionFieldLogic.create = async (body) => {
|
|
153892
|
+
await db_default.insert(inspectionFieldTable).values(body);
|
|
153893
|
+
};
|
|
153894
|
+
InspectionFieldLogic.update = async (id, body) => {
|
|
153895
|
+
await db_default.update(inspectionFieldTable).set(body).where(eq(inspectionFieldTable.id, id));
|
|
153896
|
+
};
|
|
153897
|
+
InspectionFieldLogic.remove = async (id) => {
|
|
153898
|
+
await db_default.update(inspectionFieldTable).set({
|
|
153899
|
+
deletedAt: sql3`now()`
|
|
153900
|
+
}).where(eq(inspectionFieldTable.id, id));
|
|
153901
|
+
};
|
|
153902
|
+
})(InspectionFieldLogic ||= {});
|
|
153903
|
+
var logic_default25 = InspectionFieldLogic;
|
|
153904
|
+
|
|
153905
|
+
// src/routes/fleet/inspection/fieldGroup/logic.ts
|
|
153906
|
+
var InspectionFieldGroupLogic;
|
|
153907
|
+
((InspectionFieldGroupLogic) => {
|
|
153908
|
+
InspectionFieldGroupLogic.select = async (query) => {
|
|
153909
|
+
const filter = and(softDeletedFilter(inspectionFieldGroupTable), ilike(inspectionFieldGroupTable.name, `%${query.name}%`).if(query.name), ilike(inspectionFieldGroupTable.code, `%${query.code}%`).if(query.code));
|
|
153910
|
+
const columns = getTableColumns(inspectionFieldGroupTable);
|
|
153911
|
+
const baseQuery = db_default.select({
|
|
153912
|
+
...columns,
|
|
153913
|
+
totalCount: totalCountSql
|
|
153914
|
+
}).from(inspectionFieldGroupTable).where(filter).$dynamic();
|
|
153915
|
+
const result = await pagination_helper_default(baseQuery, query.pagination);
|
|
153916
|
+
const content = {
|
|
153917
|
+
totalCount: result[0]?.totalCount ?? 0,
|
|
153918
|
+
totalPage: result.length === 0 ? 0 : Math.ceil(result[0].totalCount / query.pagination.size)
|
|
153919
|
+
};
|
|
153920
|
+
return {
|
|
153921
|
+
result,
|
|
153922
|
+
...content
|
|
153923
|
+
};
|
|
153924
|
+
};
|
|
153925
|
+
InspectionFieldGroupLogic.create = async (body) => {
|
|
153926
|
+
await db_default.insert(inspectionFieldGroupTable).values(body);
|
|
153927
|
+
};
|
|
153928
|
+
InspectionFieldGroupLogic.update = async (id, body) => {
|
|
153929
|
+
await db_default.update(inspectionFieldGroupTable).set(body).where(eq(inspectionFieldGroupTable.id, id));
|
|
153930
|
+
};
|
|
153931
|
+
InspectionFieldGroupLogic.remove = async (id) => {
|
|
153932
|
+
await db_default.update(inspectionFieldGroupTable).set({
|
|
153933
|
+
deletedAt: sql3`now`
|
|
153934
|
+
}).where(eq(inspectionFieldGroupTable.id, id));
|
|
153935
|
+
};
|
|
153936
|
+
})(InspectionFieldGroupLogic ||= {});
|
|
153937
|
+
var logic_default26 = InspectionFieldGroupLogic;
|
|
153938
|
+
|
|
153939
|
+
// src/routes/fleet/inspection/fieldGroup/model.ts
|
|
153940
|
+
var InspectionFieldGroupModel;
|
|
153941
|
+
((InspectionFieldGroupModel) => {
|
|
153942
|
+
const createSchema = createInsertSchema(inspectionFieldGroupTable);
|
|
153943
|
+
const updateSchema = createUpdateSchema(inspectionFieldGroupTable);
|
|
153944
|
+
InspectionFieldGroupModel.create = OmitBaseSchema(createSchema);
|
|
153945
|
+
InspectionFieldGroupModel.update = OmitBaseSchema(updateSchema);
|
|
153946
|
+
InspectionFieldGroupModel.select = t.Composite([
|
|
153947
|
+
t.Partial(t.Object({
|
|
153948
|
+
name: t.String(),
|
|
153949
|
+
code: t.String()
|
|
153950
|
+
})),
|
|
153951
|
+
PaginationSchema
|
|
153952
|
+
]);
|
|
153953
|
+
})(InspectionFieldGroupModel ||= {});
|
|
153954
|
+
var model_default25 = InspectionFieldGroupModel;
|
|
153955
|
+
|
|
153956
|
+
// src/routes/fleet/inspection/fieldGroup/index.ts
|
|
153957
|
+
var fieldGroupRoutes = new Elysia({
|
|
153958
|
+
prefix: "/field-group"
|
|
153959
|
+
}).use(better_auth_default).guard({
|
|
153960
|
+
userKind: "ADMIN"
|
|
153961
|
+
}).get("/", async ({ query }) => logic_default26.select(query), {
|
|
153962
|
+
query: model_default25.select,
|
|
153963
|
+
userKind: undefined,
|
|
153964
|
+
auth: true
|
|
153965
|
+
}).post("/", async ({ body }) => logic_default26.create(body), {
|
|
153966
|
+
body: model_default25.create
|
|
153967
|
+
}).guard({
|
|
153968
|
+
params: IdSchema
|
|
153969
|
+
}).put("/:id", async ({ body, params: { id } }) => logic_default26.update(id, body), {
|
|
153970
|
+
body: model_default25.update
|
|
153971
|
+
}).delete("/:id", async ({ params: { id } }) => logic_default26.remove(id)).get("/:id/field", async ({ params: { id } }) => logic_default25.select(id));
|
|
153972
|
+
var fieldGroup_default = fieldGroupRoutes;
|
|
153973
|
+
|
|
153974
|
+
// src/routes/fleet/inspection/index.ts
|
|
153975
|
+
var inspectionRoutes2 = new Elysia({
|
|
153976
|
+
prefix: "/inspection"
|
|
153977
|
+
}).use(fieldGroup_default);
|
|
153978
|
+
var inspection_default2 = inspectionRoutes2;
|
|
153979
|
+
|
|
153980
|
+
// src/routes/fleet/index.ts
|
|
153981
|
+
var fleetRoutes = new Elysia({ prefix: "/fleet" }).use(inspection_default2);
|
|
153982
|
+
var fleet_default = fleetRoutes;
|
|
153983
|
+
|
|
153558
153984
|
// src/routes/index.ts
|
|
153559
153985
|
var router2 = new Elysia({
|
|
153560
153986
|
prefix: "/api"
|
|
153561
|
-
}).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default);
|
|
153987
|
+
}).use(imageRoutes).use(warehouse_default2).use(company_default2).use(permission_default2).use(user_default2).use(crm_default).use(techdoc_default).use(fleet_default);
|
|
153562
153988
|
var routes_default = router2;
|
|
153563
153989
|
|
|
153564
153990
|
// src/index.ts
|