@mondaydotcomorg/atp-server 0.19.17 → 0.20.1

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/index.cjs CHANGED
@@ -6324,7 +6324,7 @@ function convertOperation(path, method, operation, spec, baseURL, options, auth)
6324
6324
  const inputSchema = buildInputSchema(operation, spec);
6325
6325
  const outputSchema = buildOutputSchema(operation, spec);
6326
6326
  extractAnnotations(operation, operationKey, options.annotations);
6327
- const handler = /* @__PURE__ */ __name(async (params) => {
6327
+ const handler = /* @__PURE__ */ __name(async (params, handlerContext) => {
6328
6328
  const input = params || {};
6329
6329
  let requestPath = path;
6330
6330
  const queryParams = {};
@@ -6332,7 +6332,18 @@ function convertOperation(path, method, operation, spec, baseURL, options, auth)
6332
6332
  const headers = {
6333
6333
  "Content-Type": "application/json"
6334
6334
  };
6335
- if (auth) {
6335
+ let context;
6336
+ if (options.contextProvider) {
6337
+ context = await options.contextProvider(handlerContext?.requestContext);
6338
+ }
6339
+ if (options.headerProvider) {
6340
+ const dynamicHeaders = await options.headerProvider(input, context);
6341
+ Object.assign(headers, dynamicHeaders);
6342
+ atpRuntime.log.debug("Added headers from headerProvider", {
6343
+ keys: Object.keys(dynamicHeaders)
6344
+ });
6345
+ }
6346
+ if (auth && !headers["Authorization"]) {
6336
6347
  if (auth.scheme === "bearer" && auth.envVar) {
6337
6348
  let token = null;
6338
6349
  if (options.authProvider) {
@@ -6431,10 +6442,28 @@ function convertOperation(path, method, operation, spec, baseURL, options, auth)
6431
6442
  url.searchParams.append(key, value);
6432
6443
  }
6433
6444
  try {
6434
- const response = await fetch(url.toString(), {
6435
- method: method.toUpperCase(),
6436
- headers,
6437
- body: body ? JSON.stringify(body) : void 0
6445
+ let finalUrl = url.toString();
6446
+ let finalMethod = method.toUpperCase();
6447
+ let finalHeaders = {
6448
+ ...headers
6449
+ };
6450
+ let finalBody = body ? JSON.stringify(body) : void 0;
6451
+ if (options.requestTransformer) {
6452
+ const transformed = await options.requestTransformer({
6453
+ url: finalUrl,
6454
+ method: finalMethod,
6455
+ headers: finalHeaders,
6456
+ body
6457
+ });
6458
+ if (transformed.url) finalUrl = transformed.url;
6459
+ if (transformed.method) finalMethod = transformed.method;
6460
+ if (transformed.headers) finalHeaders = transformed.headers;
6461
+ if (transformed.body !== void 0) finalBody = transformed.body;
6462
+ }
6463
+ const response = await fetch(finalUrl, {
6464
+ method: finalMethod,
6465
+ headers: finalHeaders,
6466
+ body: finalBody
6438
6467
  });
6439
6468
  if (!response.ok) {
6440
6469
  const errorText = await response.text();