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