@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
@@ -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 Error(`Unhandled webhook variant: ${JSON.stringify(x)}`);
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 anyvanSlots = async (req, res) => {
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)}/anyvan-slots`,
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
- anyvanSlots
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/hono/index.ts
930
965
  function loadHono() {
931
966
  try {
932
967
  const req = createRequire(import.meta.url);
@@ -937,16 +972,6 @@ function loadHono() {
937
972
  );
938
973
  }
939
974
  }
940
- function normaliseHeaders(raw) {
941
- const out = {};
942
- for (const [k, v] of Object.entries(raw)) {
943
- out[k] = v;
944
- if (k.toLowerCase() === "hellobill-signature") {
945
- out["x-hellobill-signature"] = v;
946
- }
947
- }
948
- return out;
949
- }
950
975
  async function toHellobillRequest(c, isWebhook) {
951
976
  const url = new URL(c.req.url);
952
977
  const query = {};