@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.mjs
CHANGED
|
@@ -389,8 +389,16 @@ var InMemoryWebhookDedupeStore = class {
|
|
|
389
389
|
};
|
|
390
390
|
|
|
391
391
|
// src/webhook/handler.ts
|
|
392
|
+
var UnknownWebhookEventError = class extends Error {
|
|
393
|
+
code = "webhook.unknown_event_type";
|
|
394
|
+
constructor(eventType) {
|
|
395
|
+
super(`Unhandled webhook event type: ${eventType}`);
|
|
396
|
+
this.name = "UnknownWebhookEventError";
|
|
397
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
392
400
|
function assertNever(x) {
|
|
393
|
-
throw new
|
|
401
|
+
throw new UnknownWebhookEventError(x.type ?? JSON.stringify(x));
|
|
394
402
|
}
|
|
395
403
|
var noopLogger = {
|
|
396
404
|
debug: () => {
|
|
@@ -555,7 +563,10 @@ function createWebhookHandler(opts) {
|
|
|
555
563
|
safeLogger.error("hellobill.webhook.handler_error", {
|
|
556
564
|
event_id: event.id,
|
|
557
565
|
event_type: event.type,
|
|
558
|
-
message: err.message
|
|
566
|
+
message: err.message,
|
|
567
|
+
// Include the typed error code when present so partners can identify
|
|
568
|
+
// known error classes (e.g. unknown event type) in log aggregation.
|
|
569
|
+
...err != null && typeof err === "object" && "code" in err ? { code: err.code } : {}
|
|
559
570
|
});
|
|
560
571
|
});
|
|
561
572
|
};
|
|
@@ -894,16 +905,25 @@ function createHellobillHandler(opts) {
|
|
|
894
905
|
if (!result2) return;
|
|
895
906
|
passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
|
|
896
907
|
};
|
|
897
|
-
const
|
|
908
|
+
const serviceSlots = async (req, res) => {
|
|
898
909
|
const rawSession = req.query.session_id ?? req.params?.id;
|
|
899
910
|
const sessionId = Array.isArray(rawSession) ? rawSession[0] : rawSession;
|
|
900
911
|
if (!sessionId) {
|
|
901
912
|
sendError(res, 400, "validation.missing_required_field", "session_id query parameter required");
|
|
902
913
|
return;
|
|
903
914
|
}
|
|
915
|
+
const rawService = req.query.service;
|
|
916
|
+
const service = Array.isArray(rawService) ? rawService[0] : rawService;
|
|
917
|
+
if (!service) {
|
|
918
|
+
sendError(res, 400, "validation.missing_required_field", "service query parameter required");
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const rawProvider = req.query.provider;
|
|
922
|
+
const providerRaw = Array.isArray(rawProvider) ? rawProvider[0] : rawProvider;
|
|
923
|
+
const provider = typeof providerRaw === "string" && providerRaw.trim().length > 0 ? providerRaw.trim() : "any_van";
|
|
904
924
|
const result2 = await safeCallUpstream(res, {
|
|
905
925
|
method: "GET",
|
|
906
|
-
path: `/partner/sessions/${encodeURIComponent(sessionId)}/
|
|
926
|
+
path: `/partner/sessions/${encodeURIComponent(sessionId)}/service-slots?service=${encodeURIComponent(service)}&provider=${encodeURIComponent(provider)}`,
|
|
907
927
|
logger
|
|
908
928
|
});
|
|
909
929
|
if (!result2) return;
|
|
@@ -920,13 +940,28 @@ function createHellobillHandler(opts) {
|
|
|
920
940
|
property,
|
|
921
941
|
sessions: { list: sessionsList, get: sessionsGet },
|
|
922
942
|
savingsSummary,
|
|
923
|
-
|
|
943
|
+
serviceSlots
|
|
924
944
|
};
|
|
925
945
|
if (webhookHandler !== void 0) {
|
|
926
946
|
result.webhook = webhookHandler;
|
|
927
947
|
}
|
|
928
948
|
return result;
|
|
929
949
|
}
|
|
950
|
+
|
|
951
|
+
// src/_internal/normalise-headers.ts
|
|
952
|
+
function normaliseHeaders(raw) {
|
|
953
|
+
const out = { ...raw };
|
|
954
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
955
|
+
if (k.toLowerCase() === "hellobill-signature") {
|
|
956
|
+
if (out["x-hellobill-signature"] === void 0) {
|
|
957
|
+
out["x-hellobill-signature"] = v;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return out;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// src/koa/index.ts
|
|
930
965
|
function loadKoaRouter() {
|
|
931
966
|
try {
|
|
932
967
|
const req = createRequire(import.meta.url);
|
|
@@ -943,15 +978,6 @@ function loadKoaRouter() {
|
|
|
943
978
|
);
|
|
944
979
|
}
|
|
945
980
|
}
|
|
946
|
-
function normaliseHeaders(raw) {
|
|
947
|
-
const out = { ...raw };
|
|
948
|
-
for (const [k, v] of Object.entries(raw)) {
|
|
949
|
-
if (k.toLowerCase() === "hellobill-signature") {
|
|
950
|
-
out["x-hellobill-signature"] = v;
|
|
951
|
-
}
|
|
952
|
-
}
|
|
953
|
-
return out;
|
|
954
|
-
}
|
|
955
981
|
function toHellobillRequest(ctx) {
|
|
956
982
|
const rawHeaders = ctx.request.headers;
|
|
957
983
|
const headers = normaliseHeaders(rawHeaders);
|