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