cliodot 1.2.3 → 1.2.4

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 (135) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +2 -0
  3. package/dist/AuthAppClient.d.ts +1 -0
  4. package/dist/AuthAppClient.d.ts.map +1 -1
  5. package/dist/AuthAppClient.js +199 -1
  6. package/dist/CommercialAppClient.d.ts +50 -9
  7. package/dist/CommercialAppClient.d.ts.map +1 -1
  8. package/dist/CommercialAppClient.js +576 -1
  9. package/dist/ConnectorBuilder.js +104 -1
  10. package/dist/Events.d.ts +2 -0
  11. package/dist/Events.d.ts.map +1 -1
  12. package/dist/Events.js +325 -1
  13. package/dist/Flosync.js +296 -1
  14. package/dist/FlosyncClient.js +429 -1
  15. package/dist/FunctionBuilder.js +65 -1
  16. package/dist/IdentityAppClient.d.ts +1 -0
  17. package/dist/IdentityAppClient.d.ts.map +1 -1
  18. package/dist/IdentityAppClient.js +197 -1
  19. package/dist/MemoryAppClient.d.ts +1 -0
  20. package/dist/MemoryAppClient.d.ts.map +1 -1
  21. package/dist/MemoryAppClient.js +149 -1
  22. package/dist/MemoryClient.js +20 -1
  23. package/dist/OAuthAppClient.d.ts +1 -0
  24. package/dist/OAuthAppClient.d.ts.map +1 -1
  25. package/dist/OAuthAppClient.js +269 -1
  26. package/dist/ProviderServicesClient.d.ts +24 -0
  27. package/dist/ProviderServicesClient.d.ts.map +1 -0
  28. package/dist/ProviderServicesClient.js +158 -0
  29. package/dist/Surface.d.ts +2 -0
  30. package/dist/Surface.d.ts.map +1 -1
  31. package/dist/Surface.js +255 -1
  32. package/dist/ValidatorBuilder.js +24 -1
  33. package/dist/Webhooks.js +61 -1
  34. package/dist/WorkflowBuilder.js +279 -1
  35. package/dist/__tests__/CommercialAppClient.test.d.ts +2 -0
  36. package/dist/__tests__/CommercialAppClient.test.d.ts.map +1 -0
  37. package/dist/__tests__/CommercialAppClient.test.js +217 -0
  38. package/dist/__tests__/Events.test.js +191 -1
  39. package/dist/__tests__/IdentityAppClient.test.js +232 -1
  40. package/dist/__tests__/OAuthAppClient.test.js +300 -1
  41. package/dist/__tests__/ProviderServicesClient.test.d.ts +2 -0
  42. package/dist/__tests__/ProviderServicesClient.test.d.ts.map +1 -0
  43. package/dist/__tests__/ProviderServicesClient.test.js +131 -0
  44. package/dist/__tests__/Surface.test.js +150 -1
  45. package/dist/__tests__/errors.test.js +54 -1
  46. package/dist/__tests__/function.test.js +58 -1
  47. package/dist/__tests__/helpers.d.ts +5 -0
  48. package/dist/__tests__/helpers.d.ts.map +1 -0
  49. package/dist/__tests__/helpers.js +10 -0
  50. package/dist/__tests__/localhost-lookup.test.d.ts +2 -0
  51. package/dist/__tests__/localhost-lookup.test.d.ts.map +1 -0
  52. package/dist/__tests__/localhost-lookup.test.js +26 -0
  53. package/dist/__tests__/parse-api-error.test.js +26 -1
  54. package/dist/__tests__/runner.test.js +156 -1
  55. package/dist/connectors/builtin.js +354 -1
  56. package/dist/connectors/registry.js +300 -1
  57. package/dist/decorators/build.js +105 -1
  58. package/dist/decorators/connector.js +56 -1
  59. package/dist/decorators/index.js +34 -1
  60. package/dist/decorators/metadata.js +338 -1
  61. package/dist/decorators/steps.js +220 -1
  62. package/dist/decorators/workflow.js +52 -1
  63. package/dist/errors.js +76 -1
  64. package/dist/http/__tests__/cliodot-request.environment.test.d.ts +2 -0
  65. package/dist/http/__tests__/cliodot-request.environment.test.d.ts.map +1 -0
  66. package/dist/http/__tests__/cliodot-request.environment.test.js +37 -0
  67. package/dist/http/__tests__/cliodot-result.test.d.ts +2 -0
  68. package/dist/http/__tests__/cliodot-result.test.d.ts.map +1 -0
  69. package/dist/http/__tests__/cliodot-result.test.js +57 -0
  70. package/dist/http/__tests__/events-instance-id.test.d.ts +2 -0
  71. package/dist/http/__tests__/events-instance-id.test.d.ts.map +1 -0
  72. package/dist/http/__tests__/events-instance-id.test.js +45 -0
  73. package/dist/http/cliodot-request.d.ts +35 -0
  74. package/dist/http/cliodot-request.d.ts.map +1 -0
  75. package/dist/http/cliodot-request.js +105 -0
  76. package/dist/http/cliodot-result.d.ts +40 -0
  77. package/dist/http/cliodot-result.d.ts.map +1 -0
  78. package/dist/http/cliodot-result.js +139 -0
  79. package/dist/http/create-client.d.ts +3 -0
  80. package/dist/http/create-client.d.ts.map +1 -0
  81. package/dist/http/create-client.js +14 -0
  82. package/dist/http/events-instance-id.d.ts +11 -0
  83. package/dist/http/events-instance-id.d.ts.map +1 -0
  84. package/dist/http/events-instance-id.js +86 -0
  85. package/dist/http/localhost-lookup.d.ts +12 -0
  86. package/dist/http/localhost-lookup.d.ts.map +1 -0
  87. package/dist/http/localhost-lookup.js +67 -0
  88. package/dist/http/parse-api-error.js +56 -1
  89. package/dist/http/sanitize-execution-headers.js +79 -1
  90. package/dist/identity-offline-verify.js +174 -1
  91. package/dist/identity-token-cache.js +51 -1
  92. package/dist/index.d.ts +1 -1
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +108 -1
  95. package/dist/runner/ProcessorEngine.js +1311 -1
  96. package/dist/runner/connector.executor.js +1786 -1
  97. package/dist/runner/utilities/math.executor.js +153 -1
  98. package/dist/runner/utilities/random.executor.js +151 -1
  99. package/dist/runner/utilities/string.executor.js +825 -1
  100. package/dist/template.js +127 -1
  101. package/dist/transformers/StepsToNodesTransformer.js +214 -1
  102. package/dist/transformers/WorkflowTransformer.js +189 -1
  103. package/dist/types/auth-app.api.d.ts +2 -0
  104. package/dist/types/auth-app.api.d.ts.map +1 -1
  105. package/dist/types/auth-app.api.js +2 -1
  106. package/dist/types/builtin.js +2 -1
  107. package/dist/types/client.api.js +2 -1
  108. package/dist/types/commercial-app.api.d.ts +407 -11
  109. package/dist/types/commercial-app.api.d.ts.map +1 -1
  110. package/dist/types/commercial-app.api.js +2 -1
  111. package/dist/types/connector.js +2 -1
  112. package/dist/types/context.js +2 -1
  113. package/dist/types/event-app.api.d.ts +8 -0
  114. package/dist/types/event-app.api.d.ts.map +1 -1
  115. package/dist/types/event-app.api.js +2 -1
  116. package/dist/types/function.js +2 -1
  117. package/dist/types/identity-app.api.d.ts +2 -0
  118. package/dist/types/identity-app.api.d.ts.map +1 -1
  119. package/dist/types/identity-app.api.js +2 -1
  120. package/dist/types/index.js +23 -1
  121. package/dist/types/memory-app.api.d.ts +2 -0
  122. package/dist/types/memory-app.api.d.ts.map +1 -1
  123. package/dist/types/memory-app.api.js +2 -1
  124. package/dist/types/oauth-app.api.d.ts +2 -0
  125. package/dist/types/oauth-app.api.d.ts.map +1 -1
  126. package/dist/types/oauth-app.api.js +105 -1
  127. package/dist/types/provider-services.api.d.ts +98 -0
  128. package/dist/types/provider-services.api.d.ts.map +1 -0
  129. package/dist/types/provider-services.api.js +2 -0
  130. package/dist/types/validator.js +2 -1
  131. package/dist/types/webhook-app.api.js +2 -1
  132. package/dist/types/workflow.js +33 -1
  133. package/dist/validators/validators.js +478 -1
  134. package/dist/variable.js +37 -1
  135. package/package.json +3 -2
@@ -1 +1,269 @@
1
- 'use strict';const _0x20773f=_0x2020;(function(_0x42e1a8,_0x7241e0){const _0x5df7dd=_0x2020,_0x3edda7=_0x42e1a8();while(!![]){try{const _0x1e188e=-parseInt(_0x5df7dd(0xe6))/0x1*(parseInt(_0x5df7dd(0x10b))/0x2)+-parseInt(_0x5df7dd(0x12e))/0x3+parseInt(_0x5df7dd(0xec))/0x4*(-parseInt(_0x5df7dd(0xe7))/0x5)+-parseInt(_0x5df7dd(0x130))/0x6+-parseInt(_0x5df7dd(0x129))/0x7+-parseInt(_0x5df7dd(0xf6))/0x8*(-parseInt(_0x5df7dd(0x116))/0x9)+parseInt(_0x5df7dd(0xed))/0xa;if(_0x1e188e===_0x7241e0)break;else _0x3edda7['push'](_0x3edda7['shift']());}catch(_0x4c4a19){_0x3edda7['push'](_0x3edda7['shift']());}}}(_0x3218,0x6aa9f));function _0x3218(){const _0x30ba5e=['C2v0','yxv0Aa','mtaXodmYAwDpALj2','lI90ExbLCY9Vyxv0Ac1HChaUyxbP','zMLSDgvY','DMfSAwrHDgvszxnWB25Zzq','A2v5CW','l3jLDM9Rzq','x19LC01VzhvSzq','C2vHCMnOugfYyw1Z','l3jLzNjLC2G','ywn0B3jFDg9Rzw5FDhLWzq','CMvKAxjLy3rFDxjP','ovjuqMjPBW','y29UBMvJDgLVBL9ZDg9YywDL','zw50CMLLCW','ywn0B3jFDg9Rzw4','l2nVBM5Ly3q','yMfZzvvYBa','t0f1DgHbChbdBgLLBNqGCMvXDwLYzxmGyxbWswq','yNvPBgrtmLnizwfKzxjZ','t0f1DgGGyxbWignYzwrLBNrPywXZihjLCxvPCMvKicHHChbbCgLlzxKGB3iGyxbWu2vJCMv0kq','yxbWqxbPs2v5','yxbWu2vJCMv0','C2nVCgu','l3rVA2vUl2v4y2HHBMDL','zgvMyxvSDa','ue9tva','lI9LCNjVCNm','yxnZAwDU','zxHJAgfUz2u','zxH0zxjUywXFDxnLCL9Pza','ode4nJK5Cgrfyu5l','uMvXDwvZDcbMywLSzwq6ia','t0f1DgHbChbdBgLLBNqGCMvXDwLYzxmGyMfZzvvYBa','yxbWswq','yM9KEq','nZK4nJa2yvHRueLu','Cg9SBcbYzxf1AxjLCYbWB2XSx3n0yxrL','ndeYnZGZohniu053yW','l3rVA2vU','y29UBMvJDcbYzxf1AxjLCYbYzwrPCMvJDf91CMK','yxvKAwvUy2u','C3nVx2jPBMrPBMC','CgfYC2vbCgLfCNjVCK1LC3nHz2u','l29HDxrO','y29Kzq','yxnZzxj0Aw9U','C3vIAMvJDf90B2TLBL90ExbL','l2fWChmV','yxHPB3m','Cg9SBeLUDgvYDMfStxm','qMvHCMvYia','Cg9ZDa','z2v0vg9Rzw4','BgvUz3rO','nfLwAxbmqW','ntu1nxvmrK1Juq','CgfYC2vbCgLfCNjVCKnVzgu','AxnezxzPy2vbDxrOB3jPEMf0Aw9UugvUzgLUz0vYCM9Y','zgvMAw5LuhjVCgvYDhK','rgv2AwnLigf1DgHVCML6yxrPB24GCg9SBcb0Aw1LzcbVDxq','mJm2nezTEKTytW','mJe2mdKXmtbXCMrdtKm','CMvSyxLFC3rHDgu','yxv0Ag9YAxPHDgLVBL91CMW','ChjVDMLKzxi','yxbWBgLJyxrPB24VANnVBG','revmrvrf','DhjPBq','l2nVBM5Ly3rPB25ZlW','C2fTBf9Yzxf1zxn0','mty1ota0ofHRuLfkCq','y3jLyxrL','t0f1DgHbChbdBgLLBNq','CMvXDwvZDgvKx3rVA2vUx3r5Cgu','zgvIDwC','CMvXDwvZDa','y29UBMvJDgLVBKLKigLZihjLCxvPCMvK','l29HDxrOl2fWChmV','AM9PBG','C2nVCgvZ','x19PBxbVCNrezwzHDwX0','C3rHDgu','C3vIAMvJDf90B2TLBG','y29UBMvJDgLVBL9Pza','y29UBMvJDgLVBNm','Cg9SBf9ZDgf0zq','r0vu','CMvZB2X2zufWCeLK','q2XPB2rVDefWAuvYCM9Y'];_0x3218=function(){return _0x30ba5e;};return _0x3218();}var __importDefault=this&&this[_0x20773f(0x100)]||function(_0xd79192){return _0xd79192&&_0xd79192['__esModule']?_0xd79192:{'default':_0xd79192};};Object[_0x20773f(0xea)](exports,_0x20773f(0x111),{'value':!![]}),exports[_0x20773f(0xf8)]=void 0x0;const axios_1=__importDefault(require(_0x20773f(0xe0))),errors_1=require(_0x20773f(0x125)),parse_api_error_1=require('./http/parse-api-error'),oauth_app_api_1=require(_0x20773f(0x10c));function trimBaseUrl(_0x1ed7f0){const _0x326182=_0x20773f;return _0x1ed7f0[_0x326182(0xf3)]()['replace'](/\/+$/,'');}function resolveScope(_0x59d880){const _0x1c00d3=_0x20773f;if(_0x59d880[_0x1c00d3(0x121)]?.[_0x1c00d3(0xf3)]())return _0x59d880[_0x1c00d3(0x121)][_0x1c00d3(0xf3)]();if(_0x59d880['scopes']?.[_0x1c00d3(0xe5)])return _0x59d880[_0x1c00d3(0xff)][_0x1c00d3(0x10d)](Boolean)[_0x1c00d3(0xfe)]('\x20');return undefined;}function buildConnectQuery(_0x2452bb){const _0x439cdd=_0x20773f,_0x213b14={'provider':_0x2452bb['provider']['trim'](),'redirect_uri':_0x2452bb[_0x439cdd(0x115)][_0x439cdd(0xf3)]()},_0x5099f0=resolveScope(_0x2452bb);if(_0x5099f0)_0x213b14['scope']=_0x5099f0;if(_0x2452bb[_0x439cdd(0x101)])_0x213b14[_0x439cdd(0x101)]=_0x2452bb[_0x439cdd(0x101)];if(_0x2452bb[_0x439cdd(0x128)])_0x213b14['external_user_id']=_0x2452bb['external_user_id'];if(_0x2452bb[_0x439cdd(0x117)])_0x213b14[_0x439cdd(0x117)]=_0x2452bb['connection_storage'];return _0x213b14;}function buildConnectBody(_0x35799e){const _0x1b0b91=_0x20773f,_0x50082={'provider':_0x35799e[_0x1b0b91(0xf0)]['trim'](),'redirect_uri':_0x35799e[_0x1b0b91(0x115)]['trim']()},_0x521e28=resolveScope(_0x35799e);if(_0x521e28)_0x50082[_0x1b0b91(0x121)]=_0x521e28;if(_0x35799e[_0x1b0b91(0xff)]?.[_0x1b0b91(0xe5)])_0x50082[_0x1b0b91(0xff)]=_0x35799e[_0x1b0b91(0xff)];if(_0x35799e[_0x1b0b91(0x101)])_0x50082[_0x1b0b91(0x101)]=_0x35799e['state'];if(_0x35799e[_0x1b0b91(0x128)])_0x50082['external_user_id']=_0x35799e[_0x1b0b91(0x128)];if(_0x35799e[_0x1b0b91(0x117)])_0x50082['connection_storage']=_0x35799e[_0x1b0b91(0x117)];if(_0x35799e[_0x1b0b91(0xdd)])_0x50082[_0x1b0b91(0xdd)]=_0x35799e['assertion'];if(_0x35799e[_0x1b0b91(0x102)])_0x50082['subject_token']=_0x35799e[_0x1b0b91(0x102)];if(_0x35799e[_0x1b0b91(0xde)])_0x50082[_0x1b0b91(0xde)]=_0x35799e[_0x1b0b91(0xde)];if(_0x35799e[_0x1b0b91(0xf9)])_0x50082['requested_token_type']=_0x35799e[_0x1b0b91(0xf9)];if(_0x35799e[_0x1b0b91(0x119)])_0x50082['actor_token']=_0x35799e[_0x1b0b91(0x119)];if(_0x35799e[_0x1b0b91(0x114)])_0x50082['actor_token_type']=_0x35799e[_0x1b0b91(0x114)];if(_0x35799e[_0x1b0b91(0x133)])_0x50082[_0x1b0b91(0x133)]=_0x35799e[_0x1b0b91(0x133)];return _0x50082;}function assertConnectInput(_0x483dfc){const _0x4969b6=_0x20773f;if(!_0x483dfc[_0x4969b6(0xf0)]?.['trim']())throw new errors_1[(_0x4969b6(0x108))]('connect\x20requires\x20provider');if(!_0x483dfc[_0x4969b6(0x115)]?.[_0x4969b6(0xf3)]())throw new errors_1[(_0x4969b6(0x108))](_0x4969b6(0x132));}function assertPollInput(_0x5decb7){const _0x56bfba=_0x20773f;if(!_0x5decb7[_0x56bfba(0xf0)]?.[_0x56bfba(0xf3)]())throw new errors_1[(_0x56bfba(0x108))]('poll\x20requires\x20provider');if(!_0x5decb7[_0x56bfba(0x105)]?.[_0x56bfba(0xf3)]())throw new errors_1['CliodotApiError'](_0x56bfba(0x12f));}function _0x2020(_0x592e59,_0x21d2de){_0x592e59=_0x592e59-0xdb;const _0x32184f=_0x3218();let _0x20209a=_0x32184f[_0x592e59];if(_0x2020['SSYcPf']===undefined){var _0x1db1c7=function(_0x3f3ca7){const _0x377fa9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xd79192='',_0x1ed7f0='';for(let _0x59d880=0x0,_0x2452bb,_0x213b14,_0x5099f0=0x0;_0x213b14=_0x3f3ca7['charAt'](_0x5099f0++);~_0x213b14&&(_0x2452bb=_0x59d880%0x4?_0x2452bb*0x40+_0x213b14:_0x213b14,_0x59d880++%0x4)?_0xd79192+=String['fromCharCode'](0xff&_0x2452bb>>(-0x2*_0x59d880&0x6)):0x0){_0x213b14=_0x377fa9['indexOf'](_0x213b14);}for(let _0x35799e=0x0,_0x50082=_0xd79192['length'];_0x35799e<_0x50082;_0x35799e++){_0x1ed7f0+='%'+('00'+_0xd79192['charCodeAt'](_0x35799e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1ed7f0);};_0x2020['GeaGyV']=_0x1db1c7,_0x2020['bWbhaK']={},_0x2020['SSYcPf']=!![];}const _0x201b40=_0x32184f[0x0],_0x10cf1f=_0x592e59+_0x201b40,_0x19c8d8=_0x2020['bWbhaK'][_0x10cf1f];return!_0x19c8d8?(_0x20209a=_0x2020['GeaGyV'](_0x20209a),_0x2020['bWbhaK'][_0x10cf1f]=_0x20209a):_0x20209a=_0x19c8d8,_0x20209a;}function assertExchangeInput(_0x41afe6){const _0x4a0901=_0x20773f;if(!_0x41afe6[_0x4a0901(0xdc)]?.[_0x4a0901(0xf3)]())throw new errors_1['CliodotApiError']('exchange\x20requires\x20code');if(!_0x41afe6[_0x4a0901(0x103)]?.['trim']())throw new errors_1[(_0x4a0901(0x108))]('exchange\x20requires\x20connection_id');}function assertConnectionId(_0x67b116){const _0x62b4bd=_0x20773f;if(!_0x67b116?.[_0x62b4bd(0xf3)]())throw new errors_1['CliodotApiError'](_0x62b4bd(0xfc));}function sleep(_0x5016f5){return new Promise(_0x537959=>setTimeout(_0x537959,_0x5016f5));}class OAuthAppClient{constructor(_0x532d18){const _0x115d1f=_0x20773f;this['connect']={'start':async _0x2b3f64=>{const _0x2e3874=_0x2020;assertConnectInput(_0x2b3f64);const _0x2c7d13=this[_0x2e3874(0x107)](_0x2b3f64[_0x2e3874(0x12c)]);return this[_0x2e3874(0xfb)](_0x2e3874(0x124),_0x2e3874(0xdf)+encodeURIComponent(_0x2c7d13)+_0x2e3874(0x11a),{'body':buildConnectBody(_0x2b3f64),'auth':![]});},'poll':async _0x68faa6=>{const _0x4c27bd=_0x2020;assertPollInput(_0x68faa6);const _0x5d2722=this[_0x4c27bd(0x107)](_0x68faa6['appId']),_0x5a1dc4=_0x68faa6[_0x4c27bd(0xe1)]??0x1388,_0x3630f8=_0x68faa6['maxAttempts']??0x78;for(let _0x409065=0x0;_0x409065<_0x3630f8;_0x409065+=0x1){try{return await this['request'](_0x4c27bd(0x124),_0x4c27bd(0xdf)+encodeURIComponent(_0x5d2722)+'/connect/poll',{'body':{'provider':_0x68faa6['provider'][_0x4c27bd(0xf3)](),'poll_state':_0x68faa6[_0x4c27bd(0x105)][_0x4c27bd(0xf3)]()},'auth':![]});}catch(_0x292524){if(!(0x0,oauth_app_api_1[_0x4c27bd(0xe9)])(_0x292524)||_0x409065===_0x3630f8-0x1)throw _0x292524;await sleep(_0x5a1dc4);}}throw new errors_1[(_0x4c27bd(0x108))](_0x4c27bd(0xeb));},'buildUrl':_0x29e3c2=>{const _0x1efaf0=_0x2020;assertConnectInput(_0x29e3c2);const _0x6766a0=this['resolveAppId'](_0x29e3c2[_0x1efaf0(0x12c)]),_0x2cf4fa=new URL(this[_0x1efaf0(0x11b)]+_0x1efaf0(0xfd)+encodeURIComponent(_0x6766a0)+_0x1efaf0(0x11a)),_0x2c1c7e=buildConnectQuery(_0x29e3c2);for(const [_0x32f871,value]of Object[_0x1efaf0(0x118)](_0x2c1c7e)){_0x2cf4fa[_0x1efaf0(0x112)][_0x1efaf0(0x109)](_0x32f871,value);}return _0x2cf4fa['toString']();},'isSamlPostBinding':_0x3aa4e7=>{const _0x18e839=_0x2020;return _0x3aa4e7['sso_binding']===_0x18e839(0xe3)&&!!_0x3aa4e7[_0x18e839(0xf5)]&&!!_0x3aa4e7['relay_state'];},'buildSamlPostForm':_0x51f976=>{const _0x58adcb=_0x2020;if(!_0x51f976['saml_request']||!_0x51f976[_0x58adcb(0xee)]||!_0x51f976[_0x58adcb(0xef)])return null;if(_0x51f976[_0x58adcb(0x134)]&&_0x51f976[_0x58adcb(0x134)]!==_0x58adcb(0xe3))return null;return{'action':_0x51f976[_0x58adcb(0xef)],'samlRequest':_0x51f976[_0x58adcb(0xf5)],'relayState':_0x51f976[_0x58adcb(0xee)]};}},this[_0x115d1f(0x104)]={'get':async _0x24f541=>{const _0x16295b=_0x115d1f;return assertConnectionId(_0x24f541),this[_0x16295b(0xfb)]('GET',_0x16295b(0xf4)+encodeURIComponent(_0x24f541[_0x16295b(0xf3)]()));},'getToken':async _0x297fd2=>{const _0x5b6472=_0x115d1f;return assertConnectionId(_0x297fd2),this[_0x5b6472(0xfb)](_0x5b6472(0x106),_0x5b6472(0xf4)+encodeURIComponent(_0x297fd2[_0x5b6472(0xf3)]())+_0x5b6472(0x131));},'sync':async _0x2f7cd9=>{const _0x32b09e=_0x115d1f;return this[_0x32b09e(0x104)][_0x32b09e(0xe4)](_0x2f7cd9);},'refresh':async _0x62859=>{const _0x22cd63=_0x115d1f;return assertConnectionId(_0x62859),this[_0x22cd63(0xfb)](_0x22cd63(0x124),_0x22cd63(0xf4)+encodeURIComponent(_0x62859[_0x22cd63(0xf3)]())+_0x22cd63(0x113));},'revoke':async(_0x4ac101,_0x5f1b18)=>{const _0x1895f0=_0x115d1f;assertConnectionId(_0x4ac101);const _0x2eb8b6={};return _0x5f1b18?.['reason']?.[_0x1895f0(0xf3)]()&&(_0x2eb8b6['reason']=_0x5f1b18['reason']['trim']()),this[_0x1895f0(0xfb)]('POST',_0x1895f0(0xf4)+encodeURIComponent(_0x4ac101[_0x1895f0(0xf3)]())+_0x1895f0(0x110),{'body':Object[_0x1895f0(0x10f)](_0x2eb8b6)[_0x1895f0(0xe5)]?_0x2eb8b6:undefined});},'delete':async _0x415a14=>{const _0x1134c7=_0x115d1f;return assertConnectionId(_0x415a14),this[_0x1134c7(0xfb)](_0x1134c7(0xf2),_0x1134c7(0xf4)+encodeURIComponent(_0x415a14['trim']()));}};if(!_0x532d18[_0x115d1f(0x11b)]?.[_0x115d1f(0xf3)]())throw new errors_1['CliodotApiError'](_0x115d1f(0x12b));if(!_0x532d18[_0x115d1f(0x12c)]?.[_0x115d1f(0xf3)]())throw new errors_1[(_0x115d1f(0x108))](_0x115d1f(0x11c));this['baseUrl']=trimBaseUrl(_0x532d18[_0x115d1f(0x11b)]),this[_0x115d1f(0x12c)]=_0x532d18['appId'][_0x115d1f(0xf3)](),this[_0x115d1f(0x11f)]=_0x532d18[_0x115d1f(0x11f)]?.[_0x115d1f(0xf3)]()||undefined,this[_0x115d1f(0x120)]=_0x532d18[_0x115d1f(0x120)]?.[_0x115d1f(0xf3)]()||undefined,this[_0x115d1f(0xfa)]=_0x532d18[_0x115d1f(0xfa)]??![],this[_0x115d1f(0xe0)]=axios_1[_0x115d1f(0x123)][_0x115d1f(0xf7)]({'baseURL':this['baseUrl']+_0x115d1f(0xdb),'timeout':0x7530,'headers':{'Content-Type':_0x115d1f(0xf1)}});}['resolveAppId'](_0x19224e){const _0x14a756=_0x20773f;return(_0x19224e?.['trim']()||this[_0x14a756(0x12c)])[_0x14a756(0xf3)]();}[_0x20773f(0x11d)](){const _0x368085=_0x20773f;if(this[_0x368085(0x11f)])return{'Authorization':_0x368085(0xe2)+this['appApiKey']};if(this['appSecret'])return{'X-Cliodot-App-Id':this[_0x368085(0x12c)],'X-Cliodot-App-Secret':this['appSecret']};throw new errors_1[(_0x368085(0x108))](_0x368085(0x11e));}async[_0x20773f(0xfb)](_0x3a371d,_0x30b51e,_0x425565){const _0x5de59b=_0x20773f,_0x21d1c2={};_0x425565?.[_0x5de59b(0x10a)]!==![]&&Object[_0x5de59b(0x126)](_0x21d1c2,this[_0x5de59b(0x11d)]());try{const {data:_0x513df9}=await this[_0x5de59b(0xe0)]({'method':_0x3a371d,'url':_0x30b51e,'headers':_0x21d1c2,'data':_0x425565?.[_0x5de59b(0x12d)],'params':_0x425565?.['params'],'validateStatus':_0x425565?.[_0x5de59b(0x10e)]===![]?_0x4bce6f=>_0x4bce6f<0x1f4:undefined});if(_0x513df9?.['ok']===![]){const _0x2a50b5=_0x513df9['statusCode'];throw new errors_1[(_0x5de59b(0x108))]((0x0,parse_api_error_1[_0x5de59b(0x135)])(_0x513df9)||'OAuth\x20request\x20failed',{'data':_0x513df9,'code':(0x0,parse_api_error_1[_0x5de59b(0xe8)])(_0x513df9),'status':_0x2a50b5===0x1ac?0x1ac:undefined});}return _0x513df9;}catch(_0x37859a){if(_0x37859a instanceof errors_1[_0x5de59b(0x108)])throw _0x37859a;const _0x1f3613=(0x0,errors_1['cliodotApiErrorFromAxios'])(_0x37859a,_0x5de59b(0x12a)+_0x3a371d+'\x20'+_0x30b51e);throw _0x1f3613;}}async[_0x20773f(0x127)](_0x1d7b59){const _0x813f0d=_0x20773f;return assertExchangeInput(_0x1d7b59),this[_0x813f0d(0xfb)](_0x813f0d(0x124),_0x813f0d(0x122),{'body':{'code':_0x1d7b59[_0x813f0d(0xdc)]['trim'](),'connection_id':_0x1d7b59[_0x813f0d(0x103)]['trim']()}});}}exports[_0x20773f(0xf8)]=OAuthAppClient;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OAuthAppClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const errors_1 = require("./errors");
9
+ const parse_api_error_1 = require("./http/parse-api-error");
10
+ const cliodot_request_1 = require("./http/cliodot-request");
11
+ const oauth_app_api_1 = require("./types/oauth-app.api");
12
+ function trimBaseUrl(url) {
13
+ return url.trim().replace(/\/+$/, "");
14
+ }
15
+ function resolveScope(input) {
16
+ if (input.scope?.trim()) {
17
+ return input.scope.trim();
18
+ }
19
+ if (input.scopes?.length) {
20
+ return input.scopes.filter(Boolean).join(" ");
21
+ }
22
+ return undefined;
23
+ }
24
+ function buildConnectQuery(input) {
25
+ const query = {
26
+ provider: input.provider.trim(),
27
+ redirect_uri: input.redirect_uri.trim(),
28
+ };
29
+ const scope = resolveScope(input);
30
+ if (scope)
31
+ query.scope = scope;
32
+ if (input.state)
33
+ query.state = input.state;
34
+ if (input.external_user_id)
35
+ query.external_user_id = input.external_user_id;
36
+ if (input.connection_storage)
37
+ query.connection_storage = input.connection_storage;
38
+ return query;
39
+ }
40
+ function buildConnectBody(input) {
41
+ const body = {
42
+ provider: input.provider.trim(),
43
+ redirect_uri: input.redirect_uri.trim(),
44
+ };
45
+ const scope = resolveScope(input);
46
+ if (scope)
47
+ body.scope = scope;
48
+ if (input.scopes?.length)
49
+ body.scopes = input.scopes;
50
+ if (input.state)
51
+ body.state = input.state;
52
+ if (input.external_user_id)
53
+ body.external_user_id = input.external_user_id;
54
+ if (input.connection_storage)
55
+ body.connection_storage = input.connection_storage;
56
+ if (input.assertion)
57
+ body.assertion = input.assertion;
58
+ if (input.subject_token)
59
+ body.subject_token = input.subject_token;
60
+ if (input.subject_token_type)
61
+ body.subject_token_type = input.subject_token_type;
62
+ if (input.requested_token_type)
63
+ body.requested_token_type = input.requested_token_type;
64
+ if (input.actor_token)
65
+ body.actor_token = input.actor_token;
66
+ if (input.actor_token_type)
67
+ body.actor_token_type = input.actor_token_type;
68
+ if (input.audience)
69
+ body.audience = input.audience;
70
+ return body;
71
+ }
72
+ function assertConnectInput(input) {
73
+ if (!input.provider?.trim()) {
74
+ throw new errors_1.CliodotApiError("connect requires provider");
75
+ }
76
+ if (!input.redirect_uri?.trim()) {
77
+ throw new errors_1.CliodotApiError("connect requires redirect_uri");
78
+ }
79
+ }
80
+ function assertPollInput(input) {
81
+ if (!input.provider?.trim()) {
82
+ throw new errors_1.CliodotApiError("poll requires provider");
83
+ }
84
+ if (!input.poll_state?.trim()) {
85
+ throw new errors_1.CliodotApiError("poll requires poll_state");
86
+ }
87
+ }
88
+ function assertExchangeInput(input) {
89
+ if (!input.code?.trim()) {
90
+ throw new errors_1.CliodotApiError("exchange requires code");
91
+ }
92
+ if (!input.connection_id?.trim()) {
93
+ throw new errors_1.CliodotApiError("exchange requires connection_id");
94
+ }
95
+ }
96
+ function assertConnectionId(connectionId) {
97
+ if (!connectionId?.trim()) {
98
+ throw new errors_1.CliodotApiError("connectionId is required");
99
+ }
100
+ }
101
+ function sleep(ms) {
102
+ return new Promise((resolve) => setTimeout(resolve, ms));
103
+ }
104
+ class OAuthAppClient {
105
+ constructor(config) {
106
+ this.connect = {
107
+ start: async (input) => {
108
+ assertConnectInput(input);
109
+ const appId = this.resolveAppId(input.appId);
110
+ return this.request("POST", `/apps/${encodeURIComponent(appId)}/connect`, { body: buildConnectBody(input), auth: false });
111
+ },
112
+ poll: async (input) => {
113
+ assertPollInput(input);
114
+ const appId = this.resolveAppId(input.appId);
115
+ const intervalMs = input.pollIntervalMs ?? 5000;
116
+ const maxAttempts = input.maxAttempts ?? 120;
117
+ for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
118
+ try {
119
+ return await this.request("POST", `/apps/${encodeURIComponent(appId)}/connect/poll`, {
120
+ body: {
121
+ provider: input.provider.trim(),
122
+ poll_state: input.poll_state.trim(),
123
+ },
124
+ auth: false,
125
+ });
126
+ }
127
+ catch (err) {
128
+ if (!(0, oauth_app_api_1.isDeviceAuthorizationPendingError)(err) || attempt === maxAttempts - 1) {
129
+ throw err;
130
+ }
131
+ await sleep(intervalMs);
132
+ }
133
+ }
134
+ throw new errors_1.CliodotApiError("Device authorization poll timed out");
135
+ },
136
+ buildUrl: (input) => {
137
+ assertConnectInput(input);
138
+ const appId = this.resolveAppId(input.appId);
139
+ const url = new URL(`${this.baseUrl}/oauth/apps/${encodeURIComponent(appId)}/connect`);
140
+ const query = buildConnectQuery(input);
141
+ for (const [key, value] of Object.entries(query)) {
142
+ url.searchParams.set(key, value);
143
+ }
144
+ return url.toString();
145
+ },
146
+ isSamlPostBinding: (response) => {
147
+ return response.sso_binding === "post" && !!response.saml_request && !!response.relay_state;
148
+ },
149
+ buildSamlPostForm: (response) => {
150
+ if (!response.saml_request || !response.relay_state || !response.authorization_url) {
151
+ return null;
152
+ }
153
+ if (response.sso_binding && response.sso_binding !== "post") {
154
+ return null;
155
+ }
156
+ return {
157
+ action: response.authorization_url,
158
+ samlRequest: response.saml_request,
159
+ relayState: response.relay_state,
160
+ };
161
+ },
162
+ };
163
+ this.connections = {
164
+ get: async (connectionId) => {
165
+ assertConnectionId(connectionId);
166
+ return this.request("GET", `/connections/${encodeURIComponent(connectionId.trim())}`);
167
+ },
168
+ getToken: async (connectionId) => {
169
+ assertConnectionId(connectionId);
170
+ return this.request("GET", `/connections/${encodeURIComponent(connectionId.trim())}/token`);
171
+ },
172
+ sync: async (connectionId) => {
173
+ return this.connections.getToken(connectionId);
174
+ },
175
+ refresh: async (connectionId) => {
176
+ assertConnectionId(connectionId);
177
+ return this.request("POST", `/connections/${encodeURIComponent(connectionId.trim())}/refresh`);
178
+ },
179
+ revoke: async (connectionId, input) => {
180
+ assertConnectionId(connectionId);
181
+ const body = {};
182
+ if (input?.reason?.trim()) {
183
+ body.reason = input.reason.trim();
184
+ }
185
+ return this.request("POST", `/connections/${encodeURIComponent(connectionId.trim())}/revoke`, { body: Object.keys(body).length ? body : undefined });
186
+ },
187
+ delete: async (connectionId) => {
188
+ assertConnectionId(connectionId);
189
+ return this.request("DELETE", `/connections/${encodeURIComponent(connectionId.trim())}`);
190
+ },
191
+ };
192
+ if (!config.baseUrl?.trim()) {
193
+ throw new errors_1.CliodotApiError("OAuthAppClient requires baseUrl");
194
+ }
195
+ if (!config.appId?.trim()) {
196
+ throw new errors_1.CliodotApiError("OAuthAppClient requires appId");
197
+ }
198
+ this.baseUrl = trimBaseUrl(config.baseUrl);
199
+ this.appId = config.appId.trim();
200
+ this.appApiKey = config.appApiKey?.trim() || undefined;
201
+ this.appSecret = config.appSecret?.trim() || undefined;
202
+ this.environment = config.environment;
203
+ this.debug = config.debug ?? false;
204
+ this.axios = axios_1.default.create({
205
+ baseURL: `${this.baseUrl}/oauth`,
206
+ timeout: 30000,
207
+ headers: { "Content-Type": "application/json" },
208
+ });
209
+ }
210
+ resolveAppId(appId) {
211
+ return (appId?.trim() || this.appId).trim();
212
+ }
213
+ buildS2SHeaders() {
214
+ if (this.appApiKey) {
215
+ return (0, cliodot_request_1.applyEnvironmentHeader)({ Authorization: `Bearer ${this.appApiKey}` }, this.environment);
216
+ }
217
+ if (this.appSecret) {
218
+ return (0, cliodot_request_1.applyEnvironmentHeader)({
219
+ "X-Cliodot-App-Id": this.appId,
220
+ "X-Cliodot-App-Secret": this.appSecret,
221
+ }, this.environment);
222
+ }
223
+ throw new errors_1.CliodotApiError("OAuth app credentials required (appApiKey or appSecret)");
224
+ }
225
+ async request(method, path, options) {
226
+ const headers = {};
227
+ if (options?.auth !== false) {
228
+ Object.assign(headers, this.buildS2SHeaders());
229
+ }
230
+ try {
231
+ const { data } = await this.axios({
232
+ method,
233
+ url: path,
234
+ headers,
235
+ data: options?.body,
236
+ params: options?.params,
237
+ validateStatus: options?.validateResponse === false
238
+ ? (status) => status < 500
239
+ : undefined,
240
+ });
241
+ if (data?.ok === false) {
242
+ const status = data.statusCode;
243
+ throw new errors_1.CliodotApiError((0, parse_api_error_1.parseApiErrorMessage)(data) || "OAuth request failed", {
244
+ data,
245
+ code: (0, parse_api_error_1.parseApiErrorCode)(data),
246
+ status: status === 428 ? 428 : undefined,
247
+ });
248
+ }
249
+ return data;
250
+ }
251
+ catch (err) {
252
+ if (err instanceof errors_1.CliodotApiError) {
253
+ throw err;
254
+ }
255
+ const apiErr = (0, errors_1.cliodotApiErrorFromAxios)(err, `Request failed: ${method} ${path}`);
256
+ throw apiErr;
257
+ }
258
+ }
259
+ async exchange(input) {
260
+ assertExchangeInput(input);
261
+ return this.request("POST", "/token/exchange", {
262
+ body: {
263
+ code: input.code.trim(),
264
+ connection_id: input.connection_id.trim(),
265
+ },
266
+ });
267
+ }
268
+ }
269
+ exports.OAuthAppClient = OAuthAppClient;
@@ -0,0 +1,24 @@
1
+ import { type CliodotFail, type CliodotMethodResult } from "./http/cliodot-result";
2
+ import type { ProviderCatalogResponse, ProviderExecuteInput, ProviderExecuteResult, ProviderSdkTypesArtifact, ProviderServicesClientConfig } from "./types/provider-services.api";
3
+ export declare class ProviderServicesClient<TCatalog = any> {
4
+ private readonly baseUrl;
5
+ private readonly appId;
6
+ private readonly apiKey?;
7
+ private readonly appSecret?;
8
+ private readonly environment?;
9
+ private readonly axios;
10
+ private readonly configError;
11
+ readonly debug: boolean;
12
+ readonly api: TCatalog;
13
+ constructor(config: ProviderServicesClientConfig);
14
+ /**
15
+ * Execute a catalog operation. Pass `provider` to pin a binding when routing allows it.
16
+ */
17
+ execute<TResult = Record<string, unknown>>(input: ProviderExecuteInput): Promise<ProviderExecuteResult<TResult> | CliodotFail>;
18
+ catalog(): Promise<CliodotMethodResult<ProviderCatalogResponse>>;
19
+ downloadTypes(): Promise<CliodotMethodResult<ProviderSdkTypesArtifact>>;
20
+ private asProxy;
21
+ private buildAuthHeaders;
22
+ private request;
23
+ }
24
+ //# sourceMappingURL=ProviderServicesClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderServicesClient.d.ts","sourceRoot":"","sources":["../src/ProviderServicesClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,mBAAmB,EAGzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EAEpB,qBAAqB,EACrB,wBAAwB,EAExB,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAsCvC,qBAAa,sBAAsB,CAAC,QAAQ,GAAG,GAAG;IAChD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgC;IAC5D,SAAgB,KAAK,EAAE,OAAO,CAAC;IAC/B,SAAgB,GAAG,EAAE,QAAQ,CAAC;gBAElB,MAAM,EAAE,4BAA4B;IA2BhD;;OAEG;IACH,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC;IAmBxD,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;IAI1D,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IAW7E,OAAO,CAAC,OAAO;IAoCf,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,OAAO;CAiBhB"}
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProviderServicesClient = void 0;
4
+ const create_client_1 = require("./http/create-client");
5
+ const cliodot_request_1 = require("./http/cliodot-request");
6
+ const cliodot_result_1 = require("./http/cliodot-result");
7
+ function trimBaseUrl(url) {
8
+ return url.trim().replace(/\/+$/, "");
9
+ }
10
+ function isExecuteResult(value) {
11
+ if (!value || typeof value !== "object")
12
+ return false;
13
+ const obj = value;
14
+ return (typeof obj.service === "string" &&
15
+ typeof obj.operation === "string" &&
16
+ Array.isArray(obj.attempts));
17
+ }
18
+ function normalizeExecuteResult(data, status) {
19
+ if (!isExecuteResult(data))
20
+ return null;
21
+ if (status === 502 || data.ok === false) {
22
+ const error = data.error;
23
+ return {
24
+ ...data,
25
+ ok: false,
26
+ error: {
27
+ code: error?.code || cliodot_result_1.SDK_ERROR.REQUEST_FAILED,
28
+ message: error?.message || "Provider execute failed",
29
+ },
30
+ };
31
+ }
32
+ if (data.ok === true) {
33
+ return data;
34
+ }
35
+ return { ...data, ok: true };
36
+ }
37
+ class ProviderServicesClient {
38
+ constructor(config) {
39
+ this.configError = (0, cliodot_result_1.resolveConfigError)([
40
+ {
41
+ valid: !!config.baseUrl?.trim(),
42
+ message: "ProviderServicesClient requires baseUrl",
43
+ },
44
+ {
45
+ valid: !!config.appId?.trim(),
46
+ message: "ProviderServicesClient requires appId",
47
+ },
48
+ ]);
49
+ this.baseUrl = trimBaseUrl(config.baseUrl || "");
50
+ this.appId = config.appId?.trim() || "";
51
+ this.apiKey =
52
+ config.apiKey?.trim() || config.appApiKey?.trim() || undefined;
53
+ this.appSecret = config.appSecret?.trim() || undefined;
54
+ this.environment = config.environment;
55
+ this.debug = config.debug ?? false;
56
+ this.axios = (0, create_client_1.createCliodotAxios)({
57
+ baseURL: `${this.baseUrl}/provider`,
58
+ timeout: config.timeoutMs ?? 60000,
59
+ headers: { "Content-Type": "application/json" },
60
+ validateStatus: (status) => status === 200 || status === 502,
61
+ });
62
+ this.api = this.asProxy();
63
+ }
64
+ /**
65
+ * Execute a catalog operation. Pass `provider` to pin a binding when routing allows it.
66
+ */
67
+ execute(input) {
68
+ const serviceError = (0, cliodot_result_1.resolveRequiredString)(input?.service, "service");
69
+ if (serviceError)
70
+ return Promise.resolve(serviceError);
71
+ const operationError = (0, cliodot_result_1.resolveRequiredString)(input?.operation, "operation");
72
+ if (operationError)
73
+ return Promise.resolve(operationError);
74
+ const body = {
75
+ service: input.service.trim(),
76
+ operation: input.operation.trim(),
77
+ input: input.input ?? {},
78
+ };
79
+ if (input.version?.trim())
80
+ body.version = input.version.trim();
81
+ if (input.provider?.trim())
82
+ body.provider = input.provider.trim();
83
+ if (input.idempotency_key?.trim()) {
84
+ body.idempotency_key = input.idempotency_key.trim();
85
+ }
86
+ return this.request("POST", "/v1/execute", body);
87
+ }
88
+ catalog() {
89
+ return this.request("GET", "/v1/catalog");
90
+ }
91
+ async downloadTypes() {
92
+ const result = await this.request("GET", "/v1/types");
93
+ if ((0, cliodot_result_1.isCliodotFail)(result))
94
+ return result;
95
+ return {
96
+ ok: true,
97
+ typescript: result.typescript,
98
+ filename: result.filename,
99
+ export_name: result.export_name,
100
+ };
101
+ }
102
+ asProxy(path = []) {
103
+ const client = this;
104
+ const callable = (...args) => {
105
+ if (path.length !== 2) {
106
+ return Promise.resolve((0, cliodot_result_1.cliodotValidationFail)("Provider fluent calls are service.operation(input, opts?)"));
107
+ }
108
+ const [service, operation] = path;
109
+ const input = args[0] ?? {};
110
+ const opts = args[1] || {};
111
+ return client.execute({
112
+ service,
113
+ operation,
114
+ input,
115
+ version: opts.version,
116
+ provider: opts.provider,
117
+ idempotency_key: opts.idempotency_key,
118
+ });
119
+ };
120
+ return new Proxy(callable, {
121
+ get(_target, prop) {
122
+ if (typeof prop === "symbol")
123
+ return undefined;
124
+ if (prop === "then")
125
+ return undefined;
126
+ if (prop === "toString")
127
+ return () => "[ProviderServicesClient.api]";
128
+ return client.asProxy([...path, String(prop)]);
129
+ },
130
+ apply(_target, _thisArg, argArray) {
131
+ return callable(...(argArray || []));
132
+ },
133
+ });
134
+ }
135
+ buildAuthHeaders() {
136
+ return (0, cliodot_request_1.resolveBearerAuthHeaders)({
137
+ appId: this.appId,
138
+ apiKey: this.apiKey,
139
+ appSecret: this.appSecret,
140
+ environment: this.environment,
141
+ missingMessage: "Provider app credentials required (apiKey/appApiKey or appSecret)",
142
+ });
143
+ }
144
+ request(method, path, body) {
145
+ return (0, cliodot_request_1.executeCliodotRequest)({
146
+ configError: this.configError,
147
+ authHeaders: this.buildAuthHeaders(),
148
+ axios: this.axios,
149
+ method,
150
+ path,
151
+ body,
152
+ validateStatus: (status) => status === 200 || status === 502,
153
+ passThrough: (data, status) => normalizeExecuteResult(data, status),
154
+ fallbackMessage: `Request failed: ${method} ${path}`,
155
+ });
156
+ }
157
+ }
158
+ exports.ProviderServicesClient = ProviderServicesClient;
package/dist/Surface.d.ts CHANGED
@@ -6,6 +6,8 @@ export interface SurfaceConfig {
6
6
  apiKeyHeader?: string;
7
7
  fetchSurface?: boolean;
8
8
  version?: string;
9
+ /** Pin project env bag for connector auth templates. Omit to follow the project switch. */
10
+ environment?: "dev" | "prod" | "development" | "production";
9
11
  }
10
12
  export interface SurfaceOp {
11
13
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Surface.d.ts","sourceRoot":"","sources":["../src/Surface.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,aA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