@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.
Files changed (45) hide show
  1. package/dist/express/index.d.cts +2 -2
  2. package/dist/express/index.d.ts +2 -2
  3. package/dist/express/index.js +41 -6
  4. package/dist/express/index.js.map +1 -1
  5. package/dist/express/index.mjs +41 -6
  6. package/dist/express/index.mjs.map +1 -1
  7. package/dist/hono/index.d.cts +2 -2
  8. package/dist/hono/index.d.ts +2 -2
  9. package/dist/hono/index.js +40 -15
  10. package/dist/hono/index.js.map +1 -1
  11. package/dist/hono/index.mjs +40 -15
  12. package/dist/hono/index.mjs.map +1 -1
  13. package/dist/{index-BrfG82zs.d.cts → index-D81ftBQo.d.ts} +16 -4
  14. package/dist/{index-EXetQn1f.d.ts → index-lPvEf5hZ.d.cts} +16 -4
  15. package/dist/index.d.cts +4 -4
  16. package/dist/index.d.ts +4 -4
  17. package/dist/index.js +26 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +26 -6
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/koa/index.d.cts +2 -2
  22. package/dist/koa/index.d.ts +2 -2
  23. package/dist/koa/index.js +40 -14
  24. package/dist/koa/index.js.map +1 -1
  25. package/dist/koa/index.mjs +40 -14
  26. package/dist/koa/index.mjs.map +1 -1
  27. package/dist/next/index.d.cts +2 -2
  28. package/dist/next/index.d.ts +2 -2
  29. package/dist/next/index.js +31 -7
  30. package/dist/next/index.js.map +1 -1
  31. package/dist/next/index.mjs +31 -7
  32. package/dist/next/index.mjs.map +1 -1
  33. package/dist/types/index.d.cts +3 -3
  34. package/dist/types/index.d.ts +3 -3
  35. package/dist/types/index.js.map +1 -1
  36. package/dist/types/index.mjs.map +1 -1
  37. package/dist/webhook/index.d.cts +2 -2
  38. package/dist/webhook/index.d.ts +2 -2
  39. package/dist/webhook/index.js +14 -2
  40. package/dist/webhook/index.js.map +1 -1
  41. package/dist/webhook/index.mjs +14 -3
  42. package/dist/webhook/index.mjs.map +1 -1
  43. package/dist/{webhooks-DPpqf7d2.d.cts → webhooks-Cv4e8oXp.d.cts} +3 -2
  44. package/dist/{webhooks-DPpqf7d2.d.ts → webhooks-Cv4e8oXp.d.ts} +3 -2
  45. package/package.json +1 -1
@@ -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 Error(`Unhandled webhook variant: ${JSON.stringify(x)}`);
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 anyvanSlots = async (req, res) => {
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)}/anyvan-slots`,
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
- anyvanSlots
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/next/index.ts
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"] = v;
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 = {};