@hello-bill/node 2.1.2-beta.1 → 2.1.2

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.
@@ -1,4 +1,4 @@
1
- import { C as CreateHellobillHandlerOptions } from '../index-C_gIXrzG.cjs';
1
+ import { C as CreateHellobillHandlerOptions } from '../index-D5WlUYVZ.cjs';
2
2
  import '../webhooks-DePW-Bjp.cjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { C as CreateHellobillHandlerOptions } from '../index-DnEk4Y5R.js';
1
+ import { C as CreateHellobillHandlerOptions } from '../index-jK9cEnEY.js';
2
2
  import '../webhooks-DePW-Bjp.js';
3
3
 
4
4
  /**
@@ -135,10 +135,9 @@ function buildQueryString(query) {
135
135
  async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
136
136
  const base = apiBaseUrl.replace(/\/$/, "");
137
137
  const url = `${base}${opts.path}${buildQueryString(opts.query)}`;
138
- const m2mToken = await tokenManager.getAccessToken();
139
- const bearerToken = opts.sessionBearer ?? m2mToken;
138
+ const token = await tokenManager.getAccessToken();
140
139
  const headers = {
141
- Authorization: `Bearer ${bearerToken}`,
140
+ Authorization: `Bearer ${token}`,
142
141
  Accept: "application/json"
143
142
  };
144
143
  if (opts.body !== void 0) headers["Content-Type"] = "application/json";
@@ -148,15 +147,14 @@ async function callUpstream(apiBaseUrl, tokenManager, opts, fetchImpl) {
148
147
  headers
149
148
  };
150
149
  if (opts.body !== void 0) init.body = JSON.stringify(opts.body);
151
- const onTokenExpired = opts.sessionBearer ? void 0 : async () => {
152
- await tokenManager.invalidate();
153
- const fresh = await tokenManager.getAccessToken();
154
- headers.Authorization = `Bearer ${fresh}`;
155
- };
156
150
  const res = await retryFetch(url, init, {
157
151
  fetch: fetchImpl,
158
152
  timeoutMs: opts.timeoutMs,
159
- onTokenExpired
153
+ onTokenExpired: async () => {
154
+ await tokenManager.invalidate();
155
+ const fresh = await tokenManager.getAccessToken();
156
+ headers.Authorization = `Bearer ${fresh}`;
157
+ }
160
158
  });
161
159
  let body = null;
162
160
  const text = await res.text();
@@ -934,27 +932,6 @@ function createHellobillHandler(opts) {
934
932
  if (!result2) return;
935
933
  passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
936
934
  };
937
- const loaDocument = async (req, res) => {
938
- const rawLoa = req.query.loa_id ?? req.params?.id;
939
- const loaId = Array.isArray(rawLoa) ? rawLoa[0] : rawLoa;
940
- if (!loaId) {
941
- sendError(res, 400, "validation.missing_required_field", "loa_id query parameter required");
942
- return;
943
- }
944
- const sessionBearer = extractBearer(req);
945
- if (!sessionBearer) {
946
- sendError(res, 401, "auth.token_malformed", "Missing Authorization bearer token");
947
- return;
948
- }
949
- const result2 = await safeCallUpstream(res, {
950
- method: "GET",
951
- path: `/partner/loa/${encodeURIComponent(loaId)}/document`,
952
- sessionBearer,
953
- logger
954
- });
955
- if (!result2) return;
956
- passthroughUpstream(res, result2.status, result2.body, result2.requestId, result2.headers);
957
- };
958
935
  const webhookHandler = opts.webhook ? createWebhookHandler({ ...opts.webhook, logger: opts.webhook.logger ?? opts.logger }) : void 0;
959
936
  const result = {
960
937
  session,
@@ -966,8 +943,7 @@ function createHellobillHandler(opts) {
966
943
  property,
967
944
  sessions: { list: sessionsList, get: sessionsGet },
968
945
  savingsSummary,
969
- serviceSlots,
970
- loaDocument
946
+ serviceSlots
971
947
  };
972
948
  if (webhookHandler !== void 0) {
973
949
  result.webhook = webhookHandler;
@@ -1056,9 +1032,6 @@ function createHellobillRouter(opts) {
1056
1032
  router.get("/property", asyncWrap(handlers.property));
1057
1033
  router.get("/sessions", asyncWrap(handlers.sessions.list));
1058
1034
  router.get("/sessions/:id", asyncWrap(handlers.sessions.get));
1059
- router.get("/service-slots", asyncWrap(handlers.serviceSlots));
1060
- router.get("/savings-summary", asyncWrap(handlers.savingsSummary));
1061
- router.get("/loa-document", asyncWrap(handlers.loaDocument));
1062
1035
  router.use(
1063
1036
  (err, _req, res, _next) => {
1064
1037
  opts.logger?.error?.("hellobill.router_error", { message: err?.message });