@stackone/connect-sdk 1.33.0 → 1.34.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.d.mts +143 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +4652 -1
- package/dist/index.mjs +4622 -0
- package/package.json +22 -5
- package/dist/index.es.mjs +0 -1
- package/dist/types/blocks/createBlock.d.ts +0 -12
- package/dist/types/blocks/createBlockContext.d.ts +0 -11
- package/dist/types/compositeIds/inputs.d.ts +0 -2
- package/dist/types/compositeIds/outputs.d.ts +0 -2
- package/dist/types/connectors/constants.d.ts +0 -1
- package/dist/types/connectors/operations.d.ts +0 -6
- package/dist/types/connectors/parsers.d.ts +0 -3
- package/dist/types/connectors/responses.d.ts +0 -3
- package/dist/types/connectors/schemas.d.ts +0 -1457
- package/dist/types/connectors/specs/examples/testConnector.d.ts +0 -2
- package/dist/types/connectors/specs/examples/testConnectorWithoutOperations.d.ts +0 -2
- package/dist/types/errors/connectSDKErrors.d.ts +0 -20
- package/dist/types/errors/types.d.ts +0 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/pagination/utils.d.ts +0 -2
- package/dist/types/pagination/virtualPagination.d.ts +0 -7
- package/dist/types/runners/executeStepFunctions.d.ts +0 -7
- package/dist/types/runners/runConnectorOperation.d.ts +0 -25
- package/dist/types/runners/runStepOperation.d.ts +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/connect-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.mjs",
|
|
@@ -10,12 +10,20 @@
|
|
|
10
10
|
"package.json",
|
|
11
11
|
"README.md"
|
|
12
12
|
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
16
|
+
"import": "./dist/index.es.mjs",
|
|
17
|
+
"require": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
13
21
|
"scripts": {
|
|
14
22
|
"clean": "rimraf dist",
|
|
15
23
|
"prebuild": "npm run clean",
|
|
16
|
-
"build": "
|
|
24
|
+
"build": "tsdown --env.NODE_ENV=production",
|
|
17
25
|
"prebuild:dev": "npm run clean",
|
|
18
|
-
"build:dev": "
|
|
26
|
+
"build:dev": "tsdown --env.NODE_ENV=development",
|
|
19
27
|
"code:format": "biome format ./src ./*.mjs",
|
|
20
28
|
"code:format:fix": "biome format --write ./src ./*.mjs",
|
|
21
29
|
"code:lint": "biome lint --error-on-warnings ./src ./*.mjs",
|
|
@@ -35,10 +43,19 @@
|
|
|
35
43
|
"@stackone/core": "*",
|
|
36
44
|
"@stackone/expressions": "*",
|
|
37
45
|
"@stackone/logger": "*",
|
|
38
|
-
"@stackone/open-api": "*",
|
|
39
46
|
"@stackone/transport": "*",
|
|
40
47
|
"@stackone/utils": "*",
|
|
41
48
|
"path-to-regexp": "8.2.0",
|
|
42
49
|
"yaml": "2.7.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"tsdown": "^0.12.9"
|
|
53
|
+
},
|
|
54
|
+
"tsdown": {
|
|
55
|
+
"dts": true,
|
|
56
|
+
"format": [
|
|
57
|
+
"esm",
|
|
58
|
+
"cjs"
|
|
59
|
+
]
|
|
43
60
|
}
|
|
44
|
-
}
|
|
61
|
+
}
|
package/dist/index.es.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{HttpClientManager as e,isSuccessStatusCode as t,HttpErrorMessages as o}from"@stackone/transport";import{match as r}from"path-to-regexp";import{AUTHENTICATION_SCHEMA as n,COMPOSITE_ID_LATEST_VERSION as s,StepFunctionsFactory as i,StepFunctionName as a,decodeCompositeId as c,CoreError as p,encodeCompositeId as u,isCompositeId as d,isCursorEmpty as l,minifyCursor as y,updateCursor as m,expandCursor as g}from"@stackone/core";import{notMissing as f,isMissing as b,isObject as h,isString as _,isNumber as v}from"@stackone/utils";import{parse as I}from"yaml";import{z as C}from"zod";import{safeEvaluateRecord as k,safeEvaluate as F}from"@stackone/expressions";const E=async({inputs:t,context:o,operation:r,credentials:n,nextCursor:s,logger:i,getHttpClient:a=async()=>e.getInstance()})=>({inputs:t,fieldConfigs:[],context:o,operation:r,credentials:n,nextCursor:s,httpClient:await a(),logger:i}),S=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=j(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},w=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},j=(e,t,o)=>{const n=w(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),s=r(w(o))(w(n));if(!1!==s)return{path:e,params:s.params}}},O=e=>{switch(e){case"list":return{statusCode:200,description:"The list of records was retrieved."};case"get":return{statusCode:200,description:"The record with the given identifier was retrieved."};case"create":return{statusCode:201,description:"The record was created successfully."};case"update":return{statusCode:200,description:"The record was updated successfully."};case"delete":return{statusCode:204,description:"The record was deleted successfully."};case"custom":return{statusCode:200,description:"The operation was executed successfully."};case"unknown":return{statusCode:200};default:throw new Error(`Unknown operation type: ${e}`)}},x={key:C.string(),label:C.string(),required:C.boolean().optional().default(!1),secret:C.boolean().optional().default(!1),readOnly:C.boolean().optional().default(!1),placeholder:C.string().optional(),description:C.string().optional(),tooltip:C.string().optional()},R=C.discriminatedUnion("type",[C.object({...x,type:C.enum(["text","password"])}),C.object({...x,type:C.literal("select"),options:C.object({value:C.string(),label:C.string()}).array()})]),T=C.object({operationId:C.string(),categories:C.string().array(),operationType:C.enum(["list","get","create","update","delete","custom","unknown"]),schema:C.string().optional(),entrypointUrl:C.string().optional(),entrypointHttpMethod:C.string().optional(),description:C.string(),responses:C.object({statusCode:C.number(),description:C.string()}).array().optional(),inputs:C.object({name:C.string(),type:C.string(),required:C.boolean(),description:C.string(),in:C.string()}).array().optional(),cursor:C.object({enabled:C.boolean(),pageSize:C.number()}).optional(),compositeIdentifiers:C.object({enabled:C.boolean(),version:C.number().optional(),fields:C.object({targetFieldKey:C.string(),remote:C.string().optional(),components:C.string().array()}).array().optional()}).optional(),scheduledJobs:C.object({enabled:C.boolean(),type:C.enum(["data_sync"]),schedule:C.string(),description:C.string(),requestParams:C.object({fields:C.string().array().optional(),expand:C.string().array().optional(),filter:C.record(C.string(),C.string()).optional()}).optional(),syncFilter:C.object({name:C.enum(["updated_after","created_after"]),initialLoopbackPeriod:C.string(),incrementalLoopbackPeriod:C.string()}).optional()}).array().optional(),fieldConfigs:C.object({targetFieldKey:C.string(),alias:C.string().optional(),expression:C.string(),type:C.enum(["string","number","boolean","datetime_string","enum"]),custom:C.boolean().default(!1),hidden:C.boolean().default(!1),enumMapper:C.object({matcher:C.enum(["country_alpha2code_by_alpha2code","country_alpha3code_by_alpha3code","country_code_by_country_code","country_name_by_country_name","country_name_by_alpha3code","country_name_by_alpha2code","country_name_by_country_code","country_alpha3code_by_alpha2code","country_alpha3code_by_country_name","country_alpha3code_by_country_code","country_alpha2code_by_alpha3code","country_alpha2code_by_country_name","country_alpha2code_by_country_code","country_code_by_alpha2code","country_code_by_alpha3code","country_code_by_country_name","country_subdivisions_by_alpha2code","country_subdivision_code_by_subdivision_name","country_alpha2code_by_citizenship","country_subdivision_name_by_subdivision_code"]).or(C.object({matchExpression:C.string(),value:C.string()}).array())}).optional()}).array().optional(),steps:C.object({stepId:C.string(),description:C.string(),stepFunction:C.object({functionName:C.string(),version:C.string().optional(),parameters:C.record(C.string(),C.unknown())}),condition:C.string().optional(),ignoreError:C.boolean().optional()}).array(),result:C.string().or(C.record(C.string(),C.unknown())).optional()}),N=C.object({StackOne:C.string(),info:C.object({title:C.string(),version:C.string(),key:C.string(),description:C.string().optional()}),baseUrl:C.string(),authentication:C.record(C.string(),C.object({type:C.string(),label:C.string(),authorization:n,environments:C.object({key:C.string(),name:C.string()}).array(),support:C.object({link:C.string(),description:C.string().optional()}),configFields:R.array().optional(),setupFields:R.array().optional(),testOperationsIds:C.string().array().optional()})).array().optional(),operations:T.array().optional()});function A(e){try{const t=I(e),o=N.parse(t),r={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},n=P(o),s={baseUrl:o.baseUrl,authentication:$(n)},i=q(o,s);return r.operations=i,r.authentication=n,f(i)&&(r.categories=K(Object.values(i))),r}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const $=e=>{const t={};for(const[o,r]of Object.entries(e))if(r&&"object"==typeof r){const{setupFields:e,configFields:n,support:s,testOperationsIds:i,...a}=r;t[o]=$(a)}else t[o]=r;return t},K=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},P=e=>{const t={};for(const o of e.authentication??[]){const[e]=Object.keys(o),r=o[e].environments.reduce(((t,r)=>{const{key:n,name:s}=r,{environments:i,...a}=o[e];return t[n]={...a,envKey:n,envName:s},t}),{});t[e]=r}return t},q=(e,o)=>{const r=e.operations?.reduce(((e,r)=>{const n=(e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0)(r),s=(e=>"list"===e.operationType?`GET /${e.schema}`:`GET /${e.schema}/:id`)(r),i=(e=>"list"===e.operationType?`/${e.schema}`:`/${e.schema}/:id`)(r),a=(e=>{const o={success:O(e.operationType),errors:{400:{statusCode:400,description:"Invalid request."},401:{statusCode:401,description:"Unauthorized access."},403:{statusCode:403,description:"Forbidden."},404:{statusCode:404,description:"Resource not found."},500:{statusCode:500,description:"Server error while executing the request."}}},r=e.responses?.reduce(((e,o)=>(t(o.statusCode)?e.success={statusCode:o.statusCode,description:o.description}:e.errors[o.statusCode]={statusCode:o.statusCode,description:o.description},e)),o);return r??o})(r),c=D(r),p=r.inputs||[];return c.enabled&&p?.push({type:"string",name:"page_size",in:"query",required:!1,description:"Number of items to return per page"}),e[n??s]={id:r.operationId,categories:r.categories,description:r.description,operationType:r.operationType,entrypointUrl:r.entrypointUrl??i,entrypointHttpMethod:r.entrypointHttpMethod??"get",responses:a,cursor:c,compositeIdentifiers:L(r),scheduledJobs:H(r),inputs:p,steps:r.steps.reduce(((e,t)=>(e[t.stepId]={id:t.stepId,description:t.description,condition:t.condition,ignoreError:t.ignoreError,stepFunction:{functionName:t.stepFunction.functionName,version:t.stepFunction.version,params:{...t.stepFunction.parameters,...V(t.stepFunction.functionName,o,t.stepFunction.parameters),..."map_fields"===t.stepFunction.functionName||"typecast"===t.stepFunction.functionName?{fields:r.fieldConfigs}:{}}}},e)),{}),result:r.result},e}),{});return r},U=(e,t)=>{if(!e.inputs)return{};const o=z(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},M=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=C.string();break;case"number":o=C.number();break;case"boolean":o=C.boolean();break;default:o=C.any()}t[e.name]=e.required?o:o.optional()})),C.object(t)},z=e=>{const t=e.filter((e=>"path"===e.in)),o=e.filter((e=>"query"===e.in)),r=e.filter((e=>"body"===e.in)),n=e.filter((e=>"headers"===e.in));return C.object({path:M(t).optional(),query:M(o).optional(),body:M(r).optional(),headers:M(n).optional()})},D=e=>{const t="list"===e.operationType,o=e.cursor??{enabled:t,pageSize:25};return{enabled:o.enabled&&t,pageSize:o.pageSize}},L=e=>{if(b(e.compositeIdentifiers)){const t=e.fieldConfigs?.find((e=>"id"===e.targetFieldKey)),o=f(t)?[{targetFieldKey:t.targetFieldKey,remote:"id",components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:s,fields:o}}const t=[];for(const o of e.compositeIdentifiers?.fields??[]){const r=o.components.map((t=>{const o=e.fieldConfigs?.find((e=>e.targetFieldKey===t));return{name:t,alias:o?.alias}}));t.push({targetFieldKey:o.targetFieldKey,remote:o.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}},H=e=>{if(!b(e.scheduledJobs))return e.scheduledJobs},V=(e,t,o={})=>{if("request"===e||"paginated_request"===e){const e=[{receivedStatus:500,targetStatus:502}];return{...t,customErrors:[...o.customErrors&&Array.isArray(o.customErrors)?o.customErrors:[],...e]}}return{}};class G extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,G)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class J extends G{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class W extends G{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class B extends G{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class Y extends G{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const Q=async({block:e,stepFunctionName:t,params:o,buildStepFunction:r=i.build})=>{const n=r({functionName:t}).fn,s=await n({block:e,params:o}),c=t===a.MAP_FIELDS?{[a.MAP_FIELDS.toString()]:{output:{data:s.block.result},errors:s.errors,successful:s.successful}}:{};return{...s.block,steps:{...s?.block?.steps??{},...c}}},X=({category:e,connectorKey:t,connectorVersion:o,authConfigKey:r,environment:n="production",operation:s,accountSecureId:i,projectSecureId:a})=>({projectSecureId:a,accountSecureId:i,connectorKey:t,connectorVersion:o,category:e,service:"",resource:"",schema:s?.schema?.key,operationType:s?.operationType??"unknown",authenticationType:r,environment:n}),Z=e=>{const t=e.operation?.compositeIdentifiers,o={...e.inputs??{}};if(!t?.enabled||b(o))return e;const r=t.fields?.reduce(((e,t)=>(t.components.forEach((t=>{t.alias&&(e[t.name]=t.alias)})),e)),{}),n={version:t.version??s,aliases:r};return ee(o,n,e.logger),{...e,inputs:o}},ee=(e,t,o)=>{for(const r in e){const n=e[r];if("string"==typeof n||Array.isArray(n)&&n.every((e=>"string"==typeof e)))oe(n,r,e,t,o);else if(Array.isArray(n))for(const e of n)ee(e,t,o);else"object"==typeof n&&null!==n&&ee(n,t,o)}},te=e=>{const t=Object.values(e);return 1===t.length&&("string"==typeof t[0]||"number"==typeof t[0])},oe=(e,t,o,r,n)=>{try{const s=Array.isArray(e),i=s?e:[e];if(0===i.length)return;const{compositeIdComponents:a,nonCompositeIds:p}=((e,t,o,r)=>{const n=[],s=[];for(const i of e)try{const e=c(i,o);n.push(e)}catch(e){r?.debug({message:`Received ${t} with invalid composite ID, assuming it is not a composite ID`,category:"processCompositeId",context:{key:t,inputElement:i,compositeIdentifierConfig:o,error:e}}),s.push(i)}return{compositeIdComponents:n,nonCompositeIds:s}})(i,t,r,n);((e,t,o,r)=>{const n=o.filter((e=>Object.keys(e).length>1));n.length>0&&(e.decoded_ids={...e.decoded_ids??{},[t]:r?n:n[0]})})(o,t,a,s),((e,t,o,r,n)=>{o.every(te)&&(n?e[t]=[...o.map((e=>Object.values(e)[0])),...r]:o.length>0&&(e[t]=Object.values(o[0])[0]))})(o,t,a,p,s)}catch(e){((e,t,o)=>{e instanceof p&&"COMPOSITE_ID_MISSING_HEADER_ERROR"===e.type?o?.debug({message:`Received ${t} with no composite ID header, assuming it is not a composite ID`}):o?.warning({message:`Error processing composite ID for ${t}, ignoring it`,error:e})})(e,t,n)}},re="remote_",ne=e=>{const t=e.operation?.compositeIdentifiers;if(!t?.enabled)return e;const o="data",r=e.outputs?.[o];if(b(r))return e;const n=Array.isArray(r)?r.map((e=>se(e,t))):se(r,t);return{...e,outputs:{...e.outputs??{},[o]:n}}},se=(e,t)=>{const o=ie(e,t),r=de(o);return{...e,...h(r)?r:{}}},ie=(e,t)=>{const o=t.version??s,r={};return t.fields?.forEach((t=>{const n={},s=[];t.components.forEach((t=>{t.alias&&(n[t.name]=t.alias),s.push({key:t.name,value:e[t.name]})}));const i=1===s.length?s[0]:{identifiers:s},a={version:o,aliases:Object.keys(n).length>0?n:void 0},c=u(i,a);r[t.targetFieldKey]=c,t.remote&&(r[`${re}${t.remote}`]=e[t.remote])})),{...e,...r}},ae=e=>"id"===e||/.+_id(s)?$/.test(e),ce=(e,t,o)=>{const r=t.map((t=>_(t)&&t.length>0&&!d(t)?((e,t)=>{try{return u({key:e,value:t},{version:s})}catch{return t}})(e,t):t));o[e]=r,o[`${re}${e}`]=t},pe=(e,t,o)=>{if(((e,t)=>d(e)||t.startsWith(re))(t,e))return;const r=u({key:e,value:t},{version:s});o[e]=r,o[`remote_${e}`]=t},ue=(e,t,o)=>{(e=>Array.isArray(e)&&e.every((e=>_(e)&&e.length>0)))(t)?ce(e,t,o):_(t)&&t.length>0&&pe(e,t,o)},de=e=>{if(Array.isArray(e))return e.map((e=>de(e)));if(!h(e))return e;const t={...e};for(const[o,r]of Object.entries(e))(h(r)||Array.isArray(r)&&r.length>0&&h(r[0]))&&(t[o]=de(r)),ae(o)&&ue(o,r,t);return t},le=(e,t,o,r)=>{const n=b(e)?void 0:e.data,s=Object.keys(o).length+1,i=l({cursor:r,ignoreStepIndex:s});if(!h(e)||b(n)||(n?.length??0)<=t)return{result:e,next:f(r)&&!i?y(r):null};const a=r?.remote?.[s]?.pageNumber??1,c=(a-1)*t,p=c+t,u=n.slice(c,p),d=n.length>p||!i,g=m({cursor:r,stepIndex:s,pageNumber:a+1});return{result:{...e,data:u},next:d?y(g):null}},ye=async({block:e,buildStepFunction:t=i.build,virtualPaginateResultFn:o=le,encodeResultCompositeIds:r=ne,decodeInputCompositeIds:n=Z})=>{const s=n(e);return r(await ge({block:s,buildStepFunction:t,virtualPaginateResultFn:o}))},me=async(e,t,o,r,n,s)=>{const i=o[e],a=i.stepFunction,c=s.buildStepFunction({functionName:a.functionName,version:a.version,validateSchemas:!0}).fn;if(((e,t)=>!!e.condition&&!F(e.condition,t))(i,r))return be({block:r,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});if(n.hasFatalError)return be({block:r,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});const p=((e,t,o)=>{const r=e.stepFunction;return t.operation?.cursor.enabled?{...r.params??{},cursor:{token:t.nextCursor?.remote?.[o]?.providerPageCursor,position:t.nextCursor?.remote?.[o]?.position}}:r.params??{}})(i,r,t),u=await c({block:r,params:p});if(!1===u.successful)return((e,t,o,r,n)=>{const s=be({block:e,stepId:t,successful:!1,functionOutput:o});return(r.ignoreError??!1)||(n.hasFatalError=!0,n.errorStatusCode??=o.output?.statusCode??500),s})(r,e,u,i,n);const d=r.operation?.cursor.enabled?m({cursor:r.nextCursor,stepIndex:t,providerPageCursor:u.output?.next,position:u.output?.position}):void 0;return be({block:{...u.block,nextCursor:d},stepId:e,functionOutput:u})},ge=async({block:e,buildStepFunction:t=i.build,virtualPaginateResultFn:r=le})=>{const n=e.operation?.steps||{};let s={...e};const a=Object.keys(n),c=((e,t)=>{const o=Number(e.inputs?.page_size);return f(e.inputs?.page_size)&&v(o)&&!Number.isNaN(o)?o:e.operation?.cursor?.pageSize??t})(e,25),p={hasFatalError:!1,errorStatusCode:null},u={block:e,buildStepFunction:t,virtualPaginateResultFn:r};for(const[e,t]of a.entries())s=await me(t,e,n,s,p,u);const d=e.operation?.result?fe(e.operation.result,s):void 0;return((e,t,r,n,s)=>{const i=!r.hasFatalError,a=i?e.operation?.responses.success.statusCode??200:r.errorStatusCode??500;return{...t,outputs:f(s)&&h(s.result)?{next:s.next,...s.result}:n,response:{successful:i,statusCode:a,message:i?void 0:e.operation?.responses?.errors?.[a]?.description??o?.[a]??"Error while processing the request"}}})(e,s,p,d,e.operation?.cursor.enabled?r(d,c,n,s.nextCursor):void 0)},fe=(e,t)=>h(e)?k(e,t):F(e,t),be=({block:e,stepId:t,successful:o,functionOutput:r,skipped:n,message:s})=>({...e,steps:{...e.steps,[t]:{successful:o??r?.successful??!1,errors:r?.errors,output:r?.output,skipped:n,message:s}}}),he=async({account:e,connector:t,category:o,path:r,method:n="get",queryParams:s,body:i,headers:a,logger:c,parseConnector:p=A,getOperationFromUrlFn:u=S,parseOperationInputsFn:d=U,createBlockContextFn:l=X,createBlockFn:y=E,runStepOperationFn:m=ye})=>{const g=e.authConfigKey,f=e.environment??"production",h=e.secureId,v=e.projectSecureId,I=e.credentials,C=l({category:o,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:g,environment:f,accountSecureId:h,projectSecureId:v});let k;try{k=_(t)?p(t):t}catch{throw new J(C,"Error while parsing connector")}const F=u(k,r,n);if(b(F))throw new W(C,"No matching operation found");C.operationType=F.operation.operationType,C.schema=F.operation.schema?.key;const w=_e(s,C);let j;try{j=d(F.operation,{query:s,body:i,headers:a,path:F.params})}catch{throw new B(C,"Error while parsing operation inputs")}const O=await y({inputs:j,context:C,operation:F.operation,credentials:I,nextCursor:w,logger:c});return await m({block:O})},_e=(e,t)=>{const o=e?.next,r=f(o)&&"list"===t.operationType?g(o):void 0;if(null===r)throw new Y(t,"Invalid cursor.");return r};export{G as ConnectSDKError,E as createBlock,Q as executeStepFunction,S as getOperationFromUrl,U as parseOperationInputs,A as parseYamlConnector,he as runConnectorOperation,ye as runStepOperation};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Block, BlockContext, Cursor, Operation } from '@stackone/core';
|
|
2
|
-
import { ILogger } from '@stackone/logger';
|
|
3
|
-
import { IHttpClient } from '@stackone/transport';
|
|
4
|
-
export declare const createBlock: ({ inputs, context, operation, credentials, nextCursor, logger, getHttpClient, }: {
|
|
5
|
-
inputs?: Record<string, unknown>;
|
|
6
|
-
context: BlockContext;
|
|
7
|
-
operation: Operation;
|
|
8
|
-
credentials?: Record<string, unknown>;
|
|
9
|
-
nextCursor?: Cursor;
|
|
10
|
-
logger?: ILogger;
|
|
11
|
-
getHttpClient?: () => Promise<IHttpClient>;
|
|
12
|
-
}) => Promise<Block>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BlockContext, Category, Operation } from '@stackone/core';
|
|
2
|
-
export declare const createBlockContext: ({ category, connectorKey, connectorVersion, authConfigKey, environment, operation, accountSecureId, projectSecureId, }: {
|
|
3
|
-
category: Category;
|
|
4
|
-
connectorKey: string;
|
|
5
|
-
connectorVersion: string;
|
|
6
|
-
authConfigKey: string;
|
|
7
|
-
environment?: string;
|
|
8
|
-
operation?: Operation;
|
|
9
|
-
accountSecureId: string;
|
|
10
|
-
projectSecureId: string;
|
|
11
|
-
}) => BlockContext;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_PAGE_SIZE = 25;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Connector, Operation } from '@stackone/core';
|
|
2
|
-
import { HttpMethod } from '@stackone/transport';
|
|
3
|
-
export declare const getOperationFromUrl: (connector: Connector, url: string, method: HttpMethod) => {
|
|
4
|
-
operation: Operation;
|
|
5
|
-
params: Partial<Record<string, string | string[]>>;
|
|
6
|
-
} | undefined;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { OperationResponse, OperationType } from '@stackone/core';
|
|
2
|
-
export declare const getDefaultSuccessOperationResponse: (operationType: OperationType) => OperationResponse;
|
|
3
|
-
export declare const getDefaultErrorOperationResponses: () => Record<number, OperationResponse>;
|