@hello-bill/node 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/express/index.d.cts +2 -2
- package/dist/express/index.d.ts +2 -2
- package/dist/express/index.js +41 -6
- package/dist/express/index.js.map +1 -1
- package/dist/express/index.mjs +41 -6
- package/dist/express/index.mjs.map +1 -1
- package/dist/hono/index.d.cts +2 -2
- package/dist/hono/index.d.ts +2 -2
- package/dist/hono/index.js +40 -15
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/index.mjs +40 -15
- package/dist/hono/index.mjs.map +1 -1
- package/dist/{index-BrfG82zs.d.cts → index-D81ftBQo.d.ts} +16 -4
- package/dist/{index-EXetQn1f.d.ts → index-lPvEf5hZ.d.cts} +16 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -6
- package/dist/index.mjs.map +1 -1
- package/dist/koa/index.d.cts +2 -2
- package/dist/koa/index.d.ts +2 -2
- package/dist/koa/index.js +40 -14
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/index.mjs +40 -14
- package/dist/koa/index.mjs.map +1 -1
- package/dist/next/index.d.cts +2 -2
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +31 -7
- package/dist/next/index.js.map +1 -1
- package/dist/next/index.mjs +31 -7
- package/dist/next/index.mjs.map +1 -1
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/webhook/index.d.cts +2 -2
- package/dist/webhook/index.d.ts +2 -2
- package/dist/webhook/index.js +14 -2
- package/dist/webhook/index.js.map +1 -1
- package/dist/webhook/index.mjs +14 -3
- package/dist/webhook/index.mjs.map +1 -1
- package/dist/{webhooks-DPpqf7d2.d.cts → webhooks-Cv4e8oXp.d.cts} +3 -2
- package/dist/{webhooks-DPpqf7d2.d.ts → webhooks-Cv4e8oXp.d.ts} +3 -2
- package/package.json +1 -1
package/dist/koa/index.js
CHANGED
|
@@ -392,8 +392,16 @@ var InMemoryWebhookDedupeStore = class {
|
|
|
392
392
|
};
|
|
393
393
|
|
|
394
394
|
// src/webhook/handler.ts
|
|
395
|
+
var UnknownWebhookEventError = class extends Error {
|
|
396
|
+
code = "webhook.unknown_event_type";
|
|
397
|
+
constructor(eventType) {
|
|
398
|
+
super(`Unhandled webhook event type: ${eventType}`);
|
|
399
|
+
this.name = "UnknownWebhookEventError";
|
|
400
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
395
403
|
function assertNever(x) {
|
|
396
|
-
throw new
|
|
404
|
+
throw new UnknownWebhookEventError(x.type ?? JSON.stringify(x));
|
|
397
405
|
}
|
|
398
406
|
var noopLogger = {
|
|
399
407
|
debug: () => {
|
|
@@ -558,7 +566,10 @@ function createWebhookHandler(opts) {
|
|
|
558
566
|
safeLogger.error("hellobill.webhook.handler_error", {
|
|
559
567
|
event_id: event.id,
|
|
560
568
|
event_type: event.type,
|
|
561
|
-
message: err.message
|
|
569
|
+
message: err.message,
|
|
570
|
+
// Include the typed error code when present so partners can identify
|
|
571
|
+
// known error classes (e.g. unknown event type) in log aggregation.
|
|
572
|
+
...err != null && typeof err === "object" && "code" in err ? { code: err.code } : {}
|
|
562
573
|
});
|
|
563
574
|
});
|
|
564
575
|
};
|
|
@@ -897,16 +908,25 @@ function createHellobillHandler(opts) {
|
|
|
897
908
|
if (!result2) return;
|
|
898
909
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
899
910
|
};
|
|
900
|
-
const
|
|
911
|
+
const serviceSlots = async (req, res) => {
|
|
901
912
|
const rawSession = req.query.session_id ?? req.params?.id;
|
|
902
913
|
const sessionId = Array.isArray(rawSession) ? rawSession[0] : rawSession;
|
|
903
914
|
if (!sessionId) {
|
|
904
915
|
sendError(res, 400, "validation.missing_required_field", "session_id query parameter required");
|
|
905
916
|
return;
|
|
906
917
|
}
|
|
918
|
+
const rawService = req.query.service;
|
|
919
|
+
const service = Array.isArray(rawService) ? rawService[0] : rawService;
|
|
920
|
+
if (!service) {
|
|
921
|
+
sendError(res, 400, "validation.missing_required_field", "service query parameter required");
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
const rawProvider = req.query.provider;
|
|
925
|
+
const providerRaw = Array.isArray(rawProvider) ? rawProvider[0] : rawProvider;
|
|
926
|
+
const provider = typeof providerRaw === "string" && providerRaw.trim().length > 0 ? providerRaw.trim() : "any_van";
|
|
907
927
|
const result2 = await safeCallUpstream(res, {
|
|
908
928
|
method: "GET",
|
|
909
|
-
path: `/partner/sessions/${encodeURIComponent(sessionId)}/
|
|
929
|
+
path: `/partner/sessions/${encodeURIComponent(sessionId)}/service-slots?service=${encodeURIComponent(service)}&provider=${encodeURIComponent(provider)}`,
|
|
910
930
|
logger
|
|
911
931
|
});
|
|
912
932
|
if (!result2) return;
|
|
@@ -923,13 +943,28 @@ function createHellobillHandler(opts) {
|
|
|
923
943
|
property,
|
|
924
944
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
925
945
|
savingsSummary,
|
|
926
|
-
|
|
946
|
+
serviceSlots
|
|
927
947
|
};
|
|
928
948
|
if (webhookHandler !== void 0) {
|
|
929
949
|
result.webhook = webhookHandler;
|
|
930
950
|
}
|
|
931
951
|
return result;
|
|
932
952
|
}
|
|
953
|
+
|
|
954
|
+
// src/_internal/normalise-headers.ts
|
|
955
|
+
function normaliseHeaders(raw) {
|
|
956
|
+
const out = { ...raw };
|
|
957
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
958
|
+
if (k.toLowerCase() === "hellobill-signature") {
|
|
959
|
+
if (out["x-hellobill-signature"] === void 0) {
|
|
960
|
+
out["x-hellobill-signature"] = v;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return out;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/koa/index.ts
|
|
933
968
|
function loadKoaRouter() {
|
|
934
969
|
try {
|
|
935
970
|
const req = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
@@ -946,15 +981,6 @@ function loadKoaRouter() {
|
|
|
946
981
|
);
|
|
947
982
|
}
|
|
948
983
|
}
|
|
949
|
-
function normaliseHeaders(raw) {
|
|
950
|
-
const out = { ...raw };
|
|
951
|
-
for (const [k, v] of Object.entries(raw)) {
|
|
952
|
-
if (k.toLowerCase() === "hellobill-signature") {
|
|
953
|
-
out["x-hellobill-signature"] = v;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
return out;
|
|
957
|
-
}
|
|
958
984
|
function toHellobillRequest(ctx) {
|
|
959
985
|
const rawHeaders = ctx.request.headers;
|
|
960
986
|
const headers = normaliseHeaders(rawHeaders);
|