@onlineapps/conn-orch-api-mapper 1.0.18 → 1.0.20

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/ApiMapper.js +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlineapps/conn-orch-api-mapper",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "API mapping connector for OA Drive - maps cookbook operations to HTTP endpoints",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/ApiMapper.js CHANGED
@@ -414,7 +414,7 @@ class ApiMapper {
414
414
  const handlerInput = await this._resolveContentDescriptors(resolvedInput, operation);
415
415
 
416
416
  // Build request
417
- const request = this._buildRequest(operation, handlerInput);
417
+ const request = this._buildRequest(operation, handlerInput, context);
418
418
 
419
419
  // Make the call
420
420
  let response;
@@ -664,9 +664,10 @@ class ApiMapper {
664
664
  * @private
665
665
  * @param {Object} operation - Operation definition
666
666
  * @param {Object} input - Resolved input
667
+ * @param {Object} context - Workflow context (may include _system.account_id)
667
668
  * @returns {Object} Request object
668
669
  */
669
- _buildRequest(operation, input) {
670
+ _buildRequest(operation, input, context = {}) {
670
671
  const request = {
671
672
  method: operation.method,
672
673
  url: this.serviceUrl + operation.path,
@@ -716,6 +717,19 @@ class ApiMapper {
716
717
  }
717
718
  }
718
719
 
720
+ // Multitenancy: propagate account context from workflow _system into HTTP header.
721
+ // This is the single source of truth for workflow-scoped tenant.
722
+ // NOTE: Gateway must set cookbook._system.account_id explicitly (no fallbacks).
723
+ const sys = context && typeof context === 'object' ? context._system : null;
724
+ if (sys && Object.prototype.hasOwnProperty.call(sys, 'account_id')) {
725
+ const accountId = Number.parseInt(String(sys.account_id), 10);
726
+ if (!Number.isInteger(accountId) || accountId <= 0) {
727
+ throw new Error(`[ApiMapper][AccountContext] Invalid account context - Expected context._system.account_id to be a positive integer, got: ${sys.account_id}`);
728
+ }
729
+ // Do not allow step input to override tenant header
730
+ request.headers['account-id'] = String(accountId);
731
+ }
732
+
719
733
  return request;
720
734
  }
721
735