@stackone/connect-sdk 1.19.0 → 1.21.0

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.es.mjs CHANGED
@@ -1 +1 @@
1
- import{StepFunctionsFactory as t,StepFunctionName as e,AUTHENTICATION_SCHEMA as o}from"@stackone/core";import{safeEvaluate as n,safeEvaluateRecord as r}from"@stackone/expressions";import{isObject as i,notMissing as s,isString as a,isMissing as c}from"@stackone/utils";import{HttpClientManager as p}from"@stackone/transport";import{match as u}from"path-to-regexp";import{parse as l}from"yaml";import{z as d}from"zod";const y=async({block:o,stepFunctionName:n,params:r,buildStepFunction:i=t.build})=>{const s=i({functionName:n}).fn,a=await s({block:o,params:r}),c=n===e.MAP_FIELDS?{[e.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...c}}},m=async({block:e,buildStepFunction:o=t.build})=>{const r=e.operation?.steps||[];let i={...e};const s=Object.keys(r);let a=!1;for(const t of s){const e=r[t],s=e.stepFunction,c=o({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(e.condition&&!n(e.condition,i)){i=b({block:i,stepId:t,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){i=b({block:i,stepId:t,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const p=await c({block:i,params:s.params});if(!1===p.successful){i=b({block:i,stepId:t,successful:!1,functionOutput:p});(e.ignoreError??!1)||(a=!0)}else i=b({block:p.block,stepId:t,functionOutput:p})}const c=e.operation?.result?g(e.operation.result,i):void 0;return{...i,outputs:c}},g=(t,e)=>i(t)?r(t,e):n(t,e),b=({block:t,stepId:e,successful:o,functionOutput:n,skipped:r,message:i})=>({...t,steps:{...t.steps,[e]:{successful:o??n?.successful??!1,errors:n?.errors,output:n?.output,skipped:r,message:i}}}),h=async({inputs:t,context:e,operation:o,credentials:n,logger:r,getHttpClient:i=async()=>p.getInstance()})=>({inputs:t,fieldConfigs:[],context:e,operation:o,credentials:n,httpClient:await i(),logger:r}),_=({category:t,connectorKey:e,connectorVersion:o,authConfigKey:n,environment:r="production",operation:i,accountSecureId:s,projectSecureId:a})=>({projectSecureId:a,accountSecureId:s,connectorKey:e,connectorVersion:o,category:t,service:"",resource:"",schema:i?.schema?.key,operationType:i?.operationType??"unknown",authenticationType:n,environment:r}),f=(t,e,o)=>{const n=o.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=v(e,n,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},k=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},v=(t,e,o)=>{const n=k(t);for(const t of o)if(t.startsWith(e)){const o=t.replace(`${e} `,"").trim(),r=u(k(o))(k(n));if(!1!==r)return{path:t,params:r.params}}},I=d.object({key:d.string(),label:d.string(),type:d.string(),required:d.boolean().optional(),secret:d.boolean().optional(),placeholder:d.string().optional(),description:d.string().optional(),tooltip:d.string().optional()}),E=d.object({operationId:d.string(),categories:d.string().array(),operationType:d.string(),schema:d.string().optional(),entrypointUrl:d.string().optional(),entrypointHttpMethod:d.string().optional(),description:d.string(),inputs:d.object({name:d.string(),type:d.string(),required:d.boolean(),description:d.string(),in:d.string()}).array().optional(),fieldConfigs:d.object({targetFieldKey:d.string(),expression:d.string(),type:d.enum(["string","number","boolean","datetime_string","enum"]),isUnified:d.boolean(),enumMapper:d.object({matcher:d.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(d.object({matchExpression:d.string(),value:d.string()}).array())}).optional()}).array().optional(),steps:d.object({stepId:d.string(),description:d.string(),stepFunction:d.object({functionName:d.string(),version:d.string().optional(),parameters:d.record(d.string(),d.unknown())}),condition:d.string().optional(),ignoreError:d.boolean().optional()}).array(),result:d.string().or(d.record(d.string(),d.unknown())).optional()}),S=d.object({StackOne:d.string(),info:d.object({title:d.string(),version:d.string(),key:d.string(),description:d.string().optional()}),baseUrl:d.string(),authentication:d.record(d.string(),d.object({type:d.string(),label:d.string(),authorization:o,environments:d.object({key:d.string(),name:d.string()}).array(),support:d.object({link:d.string(),description:d.string().optional()}),configFields:I.array().optional(),setupFields:I.array().optional(),testOperationsIds:d.string().array().optional()})).array().optional(),operations:E.array().optional()});function j(t){try{const e=l(t),o=S.parse(e),n={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},r=w(o),i={baseUrl:o.baseUrl,authentication:F(r)},a=T(o,i);return n.operations=a,n.authentication=r,s(a)&&(n.categories=O(Object.values(a))),n}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const F=t=>{const e={};for(const[o,n]of Object.entries(t))if(n&&"object"==typeof n){const{setupFields:t,configFields:r,support:i,testOperationsIds:s,...a}=n;e[o]=F(a)}else e[o]=n;return e},O=t=>{const e=t.reduce(((t,e)=>{for(const o of e.categories)t.add(o);return t}),new Set);return Array.from(e)},w=t=>{const e={};for(const o of t.authentication??[]){const[t]=Object.keys(o),n=o[t].environments.reduce(((e,n)=>{const{key:r,name:i}=n,{environments:s,...a}=o[t];return e[r]={...a,envKey:r,envName:i},e}),{});e[t]=n}return e},T=(t,e)=>{const o=t.operations?.reduce(((t,o)=>{const n=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(o),r=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(o),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(o);return t[n??r]={id:o.operationId,categories:o.categories,description:o.description,operationType:o.operationType,entrypointUrl:o.entrypointUrl??i,entrypointHttpMethod:o.entrypointHttpMethod??"get",inputs:o.inputs,steps:o.steps.reduce(((t,n)=>(t[n.stepId]={id:n.stepId,description:n.description,condition:n.condition,ignoreError:n.ignoreError,stepFunction:{functionName:n.stepFunction.functionName,version:n.stepFunction.version,params:{..."request"===n.stepFunction.functionName?e:{},..."map_fields"===n.stepFunction.functionName||"typecast"===n.stepFunction.functionName?{fields:o.fieldConfigs}:{},...n.stepFunction.parameters}}},t)),{}),result:o.result},t}),{});return o},N=(t,e)=>{if(!t.inputs)return{};const o=x(t.inputs).parse(e);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},C=t=>{const e={};return t.forEach((t=>{let o;switch(t.type.toLowerCase()){case"string":o=d.string();break;case"number":o=d.number();break;case"boolean":o=d.boolean();break;default:o=d.any()}e[t.name]=t.required?o:o.optional()})),d.object(e)},x=t=>{const e=t.filter((t=>"path"===t.in)),o=t.filter((t=>"query"===t.in)),n=t.filter((t=>"body"===t.in)),r=t.filter((t=>"headers"===t.in));return d.object({path:C(e).optional(),query:C(o).optional(),body:C(n).optional(),headers:C(r).optional()})};class R extends Error{constructor(t,e,o){super(o),this.name="ConnectSDKError",this.errorType=t,this.context=e,Error.captureStackTrace&&Error.captureStackTrace(this,R)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class U extends R{constructor(t,e){super("CONNECTOR_PARSE_ERROR",t,e),this.name="ConnectorParseError"}}class M extends R{constructor(t,e){super("MISSING_OPERATION_ERROR",t,e),this.name="MissingOperationError"}}class $ extends R{constructor(t,e){super("INVALID_OPERATION_INPUTS_ERROR",t,e),this.name="InvalidOperationInputsError"}}const K=async({account:t,connector:e,category:o,path:n,method:r="get",queryParams:i,body:s,headers:p,logger:u,parseConnector:l=j,getOperationFromUrlFn:d=f,parseOperationInputsFn:y=N,createBlockContextFn:g=_,createBlockFn:b=h,runStepOperationFn:k=m})=>{const v=t.authConfigKey,I=t.environment??"production",E=t.secureId,S=t.projectSecureId,F=t.credentials,O=g({category:o,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:v,environment:I,accountSecureId:E,projectSecureId:S});let w;try{w=a(e)?l(e):e}catch{throw new U(O,"Error while parsing connector")}const T=d(w,n,r);if(c(T))throw new M(O,"No matching operation found");let C;O.operationType=T.operation.operationType,O.schema=T.operation.schema?.key;try{C=y(T.operation,{query:i,body:s,headers:p,path:T.params})}catch{throw new $(O,"Error while parsing operation inputs")}const x=await b({inputs:C,context:O,operation:T.operation,credentials:F,logger:u});return await k({block:x})};export{R as ConnectSDKError,h as createBlock,y as executeStepFunction,f as getOperationFromUrl,N as parseOperationInputs,j as parseYamlConnector,K as runConnectorOperation,m as runStepOperation};
1
+ import{StepFunctionsFactory as e,StepFunctionName as t,AUTHENTICATION_SCHEMA as o,expandCursor as r}from"@stackone/core";import{safeEvaluate as n,safeEvaluateRecord as s}from"@stackone/expressions";import{isObject as i,notMissing as c,isString as a,isMissing as p}from"@stackone/utils";import{HttpClientManager as u,isSuccessStatusCode as d}from"@stackone/transport";import{match as l}from"path-to-regexp";import{parse as y}from"yaml";import{z as m}from"zod";const h=async({block:o,stepFunctionName:r,params:n,buildStepFunction:s=e.build})=>{const i=s({functionName:r}).fn,c=await i({block:o,params:n}),a=r===t.MAP_FIELDS?{[t.MAP_FIELDS.toString()]:{output:{data:c.block.result},errors:c.errors,successful:c.successful}}:{};return{...c.block,steps:{...c?.block?.steps??{},...a}}},g=async({block:t,buildStepFunction:o=e.build})=>await b({block:t,buildStepFunction:o}),b=async({block:t,buildStepFunction:o=e.build})=>{const r=t.operation?.steps||[];let s={...t};const i=Object.keys(r);let c=!1,a=null;for(const e of i){const t=r[e],i=t.stepFunction,p=o({functionName:i.functionName,version:i.version,validateSchemas:!0}).fn;if(t.condition&&!n(t.condition,s)){s=_({block:s,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(c){s=_({block:s,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=await p({block:s,params:i.params});if(!1===u.successful){s=_({block:s,stepId:e,successful:!1,functionOutput:u});(t.ignoreError??!1)||(c=!0,a??=u.output?.statusCode??500)}else s=_({block:u.block,stepId:e,functionOutput:u})}const p=t.operation?.result?f(t.operation.result,s):void 0,u=!c,d=u?t.operation?.responses.success.statusCode??200:a??500;return{...s,outputs:p,response:{successful:u,statusCode:d,message:u?void 0:t.operation?.responses?.errors?.[d]?.description??"Error while processing the request"}}},f=(e,t)=>i(e)?s(e,t):n(e,t),_=({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}}}),k=async({inputs:e,context:t,operation:o,credentials:r,nextCursor:n,logger:s,getHttpClient:i=async()=>u.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:r,nextCursor:n,httpClient:await i(),logger:s}),C=({category:e,connectorKey:t,connectorVersion:o,authConfigKey:r,environment:n="production",operation:s,accountSecureId:i,projectSecureId:c})=>({projectSecureId:c,accountSecureId:i,connectorKey:t,connectorVersion:o,category:e,service:"",resource:"",schema:s?.schema?.key,operationType:s?.operationType??"unknown",authenticationType:r,environment:n}),v=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=I(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},I=(e,t,o)=>{const r=w(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),n=l(w(o))(w(r));if(!1!==n)return{path:e,params:n.params}}},E=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}`)}},S=m.object({key:m.string(),label:m.string(),type:m.string(),required:m.boolean().optional(),secret:m.boolean().optional(),placeholder:m.string().optional(),description:m.string().optional(),tooltip:m.string().optional()}),F=m.object({operationId:m.string(),categories:m.string().array(),operationType:m.enum(["list","get","create","update","delete","custom","unknown"]),schema:m.string().optional(),entrypointUrl:m.string().optional(),entrypointHttpMethod:m.string().optional(),description:m.string(),responses:m.object({statusCode:m.number(),description:m.string()}).array().optional(),inputs:m.object({name:m.string(),type:m.string(),required:m.boolean(),description:m.string(),in:m.string()}).array().optional(),fieldConfigs:m.object({targetFieldKey:m.string(),expression:m.string(),type:m.enum(["string","number","boolean","datetime_string","enum"]),isUnified:m.boolean(),enumMapper:m.object({matcher:m.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(m.object({matchExpression:m.string(),value:m.string()}).array())}).optional()}).array().optional(),steps:m.object({stepId:m.string(),description:m.string(),stepFunction:m.object({functionName:m.string(),version:m.string().optional(),parameters:m.record(m.string(),m.unknown())}),condition:m.string().optional(),ignoreError:m.boolean().optional()}).array(),result:m.string().or(m.record(m.string(),m.unknown())).optional()}),T=m.object({StackOne:m.string(),info:m.object({title:m.string(),version:m.string(),key:m.string(),description:m.string().optional()}),baseUrl:m.string(),authentication:m.record(m.string(),m.object({type:m.string(),label:m.string(),authorization:o,environments:m.object({key:m.string(),name:m.string()}).array(),support:m.object({link:m.string(),description:m.string().optional()}),configFields:S.array().optional(),setupFields:S.array().optional(),testOperationsIds:m.string().array().optional()})).array().optional(),operations:F.array().optional()});function O(e){try{const t=y(e),o=T.parse(t),r={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},n=N(o),s={baseUrl:o.baseUrl,authentication:j(n)},i=R(o,s);return r.operations=i,r.authentication=n,c(i)&&(r.categories=x(Object.values(i))),r}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const j=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,...c}=r;t[o]=j(c)}else t[o]=r;return t},x=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},N=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,...c}=o[e];return t[n]={...c,envKey:n,envName:s},t}),{});t[e]=r}return t},R=(e,t)=>{const o=e.operations?.reduce(((e,o)=>{const r=(e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0)(o),n=(e=>"list"===e.operationType?`GET /${e.schema}`:`GET /${e.schema}/:id`)(o),s=(e=>"list"===e.operationType?`/${e.schema}`:`/${e.schema}/:id`)(o),i=(e=>{const t={success:E(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."}}},o=e.responses?.reduce(((e,t)=>(d(t.statusCode)?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e)),t);return o??t})(o);return e[r??n]={id:o.operationId,categories:o.categories,description:o.description,operationType:o.operationType,entrypointUrl:o.entrypointUrl??s,entrypointHttpMethod:o.entrypointHttpMethod??"get",responses:i,inputs:o.inputs,steps:o.steps.reduce(((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{..."request"===r.stepFunction.functionName?t:{},..."map_fields"===r.stepFunction.functionName||"typecast"===r.stepFunction.functionName?{fields:o.fieldConfigs}:{},...r.stepFunction.parameters}}},e)),{}),result:o.result},e}),{});return o},U=(e,t)=>{if(!e.inputs)return{};const o=$(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},q=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=m.string();break;case"number":o=m.number();break;case"boolean":o=m.boolean();break;default:o=m.any()}t[e.name]=e.required?o:o.optional()})),m.object(t)},$=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 m.object({path:q(t).optional(),query:q(o).optional(),body:q(r).optional(),headers:q(n).optional()})};class M extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,M)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class K extends M{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class A extends M{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class P extends M{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class H extends M{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const L=async({account:e,connector:t,category:o,path:r,method:n="get",queryParams:s,body:i,headers:c,logger:u,parseConnector:d=O,getOperationFromUrlFn:l=v,parseOperationInputsFn:y=U,createBlockContextFn:m=C,createBlockFn:h=k,runStepOperationFn:b=g})=>{const f=e.authConfigKey,_=e.environment??"production",w=e.secureId,I=e.projectSecureId,E=e.credentials,S=m({category:o,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:f,environment:_,accountSecureId:w,projectSecureId:I});let F;try{F=a(t)?d(t):t}catch{throw new K(S,"Error while parsing connector")}const T=l(F,r,n);if(p(T))throw new A(S,"No matching operation found");S.operationType=T.operation.operationType,S.schema=T.operation.schema?.key;const j=V(s,S);let x;try{x=y(T.operation,{query:s,body:i,headers:c,path:T.params})}catch{throw new P(S,"Error while parsing operation inputs")}const N=await h({inputs:x,context:S,operation:T.operation,credentials:E,nextCursor:j,logger:u});return await b({block:N})},V=(e,t)=>{const o=e?.next,n=c(o)&&"list"===t.operationType?r(o):void 0;if(null===n)throw new H(t,"Invalid cursor.");return n};export{M as ConnectSDKError,k as createBlock,h as executeStepFunction,v as getOperationFromUrl,U as parseOperationInputs,O as parseYamlConnector,L as runConnectorOperation,g as runStepOperation};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@stackone/core"),t=require("@stackone/expressions"),o=require("@stackone/utils"),n=require("@stackone/transport"),r=require("path-to-regexp"),i=require("yaml"),s=require("zod");const a=async({block:o,buildStepFunction:n=e.StepFunctionsFactory.build})=>{const r=o.operation?.steps||[];let i={...o};const s=Object.keys(r);let a=!1;for(const e of s){const o=r[e],s=o.stepFunction,c=n({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(o.condition&&!t.safeEvaluate(o.condition,i)){i=p({block:i,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){i=p({block:i,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=await c({block:i,params:s.params});if(!1===u.successful){i=p({block:i,stepId:e,successful:!1,functionOutput:u});(o.ignoreError??!1)||(a=!0)}else i=p({block:u.block,stepId:e,functionOutput:u})}const u=o.operation?.result?c(o.operation.result,i):void 0;return{...i,outputs:u}},c=(e,n)=>o.isObject(e)?t.safeEvaluateRecord(e,n):t.safeEvaluate(e,n),p=({block:e,stepId:t,successful:o,functionOutput:n,skipped:r,message:i})=>({...e,steps:{...e.steps,[t]:{successful:o??n?.successful??!1,errors:n?.errors,output:n?.output,skipped:r,message:i}}}),u=async({inputs:e,context:t,operation:o,credentials:r,logger:i,getHttpClient:s=async()=>n.HttpClientManager.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:r,httpClient:await s(),logger:i}),l=({category:e,connectorKey:t,connectorVersion:o,authConfigKey:n,environment:r="production",operation:i,accountSecureId:s,projectSecureId:a})=>({projectSecureId:a,accountSecureId:s,connectorKey:t,connectorVersion:o,category:e,service:"",resource:"",schema:i?.schema?.key,operationType:i?.operationType??"unknown",authenticationType:n,environment:r}),d=(e,t,o)=>{const n=o.toUpperCase();if(!e.operations)return;const r=Object.keys(e.operations),i=g(t,n,r);return i?{operation:e.operations?.[i.path],params:i.params}:void 0},y=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},g=(e,t,o)=>{const n=y(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),i=r.match(y(o))(y(n));if(!1!==i)return{path:e,params:i.params}}},b=s.z.object({key:s.z.string(),label:s.z.string(),type:s.z.string(),required:s.z.boolean().optional(),secret:s.z.boolean().optional(),placeholder:s.z.string().optional(),description:s.z.string().optional(),tooltip:s.z.string().optional()}),m=s.z.object({operationId:s.z.string(),categories:s.z.string().array(),operationType:s.z.string(),schema:s.z.string().optional(),entrypointUrl:s.z.string().optional(),entrypointHttpMethod:s.z.string().optional(),description:s.z.string(),inputs:s.z.object({name:s.z.string(),type:s.z.string(),required:s.z.boolean(),description:s.z.string(),in:s.z.string()}).array().optional(),fieldConfigs:s.z.object({targetFieldKey:s.z.string(),expression:s.z.string(),type:s.z.enum(["string","number","boolean","datetime_string","enum"]),isUnified:s.z.boolean(),enumMapper:s.z.object({matcher:s.z.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(s.z.object({matchExpression:s.z.string(),value:s.z.string()}).array())}).optional()}).array().optional(),steps:s.z.object({stepId:s.z.string(),description:s.z.string(),stepFunction:s.z.object({functionName:s.z.string(),version:s.z.string().optional(),parameters:s.z.record(s.z.string(),s.z.unknown())}),condition:s.z.string().optional(),ignoreError:s.z.boolean().optional()}).array(),result:s.z.string().or(s.z.record(s.z.string(),s.z.unknown())).optional()}),h=s.z.object({StackOne:s.z.string(),info:s.z.object({title:s.z.string(),version:s.z.string(),key:s.z.string(),description:s.z.string().optional()}),baseUrl:s.z.string(),authentication:s.z.record(s.z.string(),s.z.object({type:s.z.string(),label:s.z.string(),authorization:e.AUTHENTICATION_SCHEMA,environments:s.z.object({key:s.z.string(),name:s.z.string()}).array(),support:s.z.object({link:s.z.string(),description:s.z.string().optional()}),configFields:b.array().optional(),setupFields:b.array().optional(),testOperationsIds:s.z.string().array().optional()})).array().optional(),operations:m.array().optional()});function _(e){try{const t=i.parse(e),n=h.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},s=k(n),a={baseUrl:n.baseUrl,authentication:z(s)},c=v(n,a);return r.operations=c,r.authentication=s,o.notMissing(c)&&(r.categories=f(Object.values(c))),r}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const z=e=>{const t={};for(const[o,n]of Object.entries(e))if(n&&"object"==typeof n){const{setupFields:e,configFields:r,support:i,testOperationsIds:s,...a}=n;t[o]=z(a)}else t[o]=n;return t},f=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},k=e=>{const t={};for(const o of e.authentication??[]){const[e]=Object.keys(o),n=o[e].environments.reduce(((t,n)=>{const{key:r,name:i}=n,{environments:s,...a}=o[e];return t[r]={...a,envKey:r,envName:i},t}),{});t[e]=n}return t},v=(e,t)=>{const o=e.operations?.reduce(((e,o)=>{const n=(e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0)(o),r=(e=>"list"===e.operationType?`GET /${e.schema}`:`GET /${e.schema}/:id`)(o),i=(e=>"list"===e.operationType?`/${e.schema}`:`/${e.schema}/:id`)(o);return e[n??r]={id:o.operationId,categories:o.categories,description:o.description,operationType:o.operationType,entrypointUrl:o.entrypointUrl??i,entrypointHttpMethod:o.entrypointHttpMethod??"get",inputs:o.inputs,steps:o.steps.reduce(((e,n)=>(e[n.stepId]={id:n.stepId,description:n.description,condition:n.condition,ignoreError:n.ignoreError,stepFunction:{functionName:n.stepFunction.functionName,version:n.stepFunction.version,params:{..."request"===n.stepFunction.functionName?t:{},..."map_fields"===n.stepFunction.functionName||"typecast"===n.stepFunction.functionName?{fields:o.fieldConfigs}:{},...n.stepFunction.parameters}}},e)),{}),result:o.result},e}),{});return o},I=(e,t)=>{if(!e.inputs)return{};const o=E(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},S=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=s.z.string();break;case"number":o=s.z.number();break;case"boolean":o=s.z.boolean();break;default:o=s.z.any()}t[e.name]=e.required?o:o.optional()})),s.z.object(t)},E=e=>{const t=e.filter((e=>"path"===e.in)),o=e.filter((e=>"query"===e.in)),n=e.filter((e=>"body"===e.in)),r=e.filter((e=>"headers"===e.in));return s.z.object({path:S(t).optional(),query:S(o).optional(),body:S(n).optional(),headers:S(r).optional()})};class F extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,F)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class O extends F{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class j extends F{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class C extends F{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}exports.ConnectSDKError=F,exports.createBlock=u,exports.executeStepFunction=async({block:t,stepFunctionName:o,params:n,buildStepFunction:r=e.StepFunctionsFactory.build})=>{const i=r({functionName:o}).fn,s=await i({block:t,params:n}),a=o===e.StepFunctionName.MAP_FIELDS?{[e.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:s.block.result},errors:s.errors,successful:s.successful}}:{};return{...s.block,steps:{...s?.block?.steps??{},...a}}},exports.getOperationFromUrl=d,exports.parseOperationInputs=I,exports.parseYamlConnector=_,exports.runConnectorOperation=async({account:e,connector:t,category:n,path:r,method:i="get",queryParams:s,body:c,headers:p,logger:y,parseConnector:g=_,getOperationFromUrlFn:b=d,parseOperationInputsFn:m=I,createBlockContextFn:h=l,createBlockFn:z=u,runStepOperationFn:f=a})=>{const k=e.authConfigKey,v=e.environment??"production",S=e.secureId,E=e.projectSecureId,F=e.credentials,N=h({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:k,environment:v,accountSecureId:S,projectSecureId:E});let T;try{T=o.isString(t)?g(t):t}catch{throw new O(N,"Error while parsing connector")}const x=b(T,r,i);if(o.isMissing(x))throw new j(N,"No matching operation found");let w;N.operationType=x.operation.operationType,N.schema=x.operation.schema?.key;try{w=m(x.operation,{query:s,body:c,headers:p,path:x.params})}catch{throw new C(N,"Error while parsing operation inputs")}const q=await z({inputs:w,context:N,operation:x.operation,credentials:F,logger:y});return await f({block:q})},exports.runStepOperation=a;
1
+ "use strict";var e=require("@stackone/core"),t=require("@stackone/expressions"),o=require("@stackone/utils"),r=require("@stackone/transport"),n=require("path-to-regexp"),s=require("yaml"),i=require("zod");const a=async({block:t,buildStepFunction:o=e.StepFunctionsFactory.build})=>await c({block:t,buildStepFunction:o}),c=async({block:o,buildStepFunction:r=e.StepFunctionsFactory.build})=>{const n=o.operation?.steps||[];let s={...o};const i=Object.keys(n);let a=!1,c=null;for(const e of i){const o=n[e],i=o.stepFunction,p=r({functionName:i.functionName,version:i.version,validateSchemas:!0}).fn;if(o.condition&&!t.safeEvaluate(o.condition,s)){s=u({block:s,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){s=u({block:s,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const d=await p({block:s,params:i.params});if(!1===d.successful){s=u({block:s,stepId:e,successful:!1,functionOutput:d});(o.ignoreError??!1)||(a=!0,c??=d.output?.statusCode??500)}else s=u({block:d.block,stepId:e,functionOutput:d})}const d=o.operation?.result?p(o.operation.result,s):void 0,l=!a,y=l?o.operation?.responses.success.statusCode??200:c??500;return{...s,outputs:d,response:{successful:l,statusCode:y,message:l?void 0:o.operation?.responses?.errors?.[y]?.description??"Error while processing the request"}}},p=(e,r)=>o.isObject(e)?t.safeEvaluateRecord(e,r):t.safeEvaluate(e,r),u=({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}}}),d=async({inputs:e,context:t,operation:o,credentials:n,nextCursor:s,logger:i,getHttpClient:a=async()=>r.HttpClientManager.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:n,nextCursor:s,httpClient:await a(),logger:i}),l=({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}),y=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=h(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},g=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},h=(e,t,o)=>{const r=g(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),s=n.match(g(o))(g(r));if(!1!==s)return{path:e,params:s.params}}},b=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}`)}},m=i.z.object({key:i.z.string(),label:i.z.string(),type:i.z.string(),required:i.z.boolean().optional(),secret:i.z.boolean().optional(),placeholder:i.z.string().optional(),description:i.z.string().optional(),tooltip:i.z.string().optional()}),_=i.z.object({operationId:i.z.string(),categories:i.z.string().array(),operationType:i.z.enum(["list","get","create","update","delete","custom","unknown"]),schema:i.z.string().optional(),entrypointUrl:i.z.string().optional(),entrypointHttpMethod:i.z.string().optional(),description:i.z.string(),responses:i.z.object({statusCode:i.z.number(),description:i.z.string()}).array().optional(),inputs:i.z.object({name:i.z.string(),type:i.z.string(),required:i.z.boolean(),description:i.z.string(),in:i.z.string()}).array().optional(),fieldConfigs:i.z.object({targetFieldKey:i.z.string(),expression:i.z.string(),type:i.z.enum(["string","number","boolean","datetime_string","enum"]),isUnified:i.z.boolean(),enumMapper:i.z.object({matcher:i.z.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(i.z.object({matchExpression:i.z.string(),value:i.z.string()}).array())}).optional()}).array().optional(),steps:i.z.object({stepId:i.z.string(),description:i.z.string(),stepFunction:i.z.object({functionName:i.z.string(),version:i.z.string().optional(),parameters:i.z.record(i.z.string(),i.z.unknown())}),condition:i.z.string().optional(),ignoreError:i.z.boolean().optional()}).array(),result:i.z.string().or(i.z.record(i.z.string(),i.z.unknown())).optional()}),f=i.z.object({StackOne:i.z.string(),info:i.z.object({title:i.z.string(),version:i.z.string(),key:i.z.string(),description:i.z.string().optional()}),baseUrl:i.z.string(),authentication:i.z.record(i.z.string(),i.z.object({type:i.z.string(),label:i.z.string(),authorization:e.AUTHENTICATION_SCHEMA,environments:i.z.object({key:i.z.string(),name:i.z.string()}).array(),support:i.z.object({link:i.z.string(),description:i.z.string().optional()}),configFields:m.array().optional(),setupFields:m.array().optional(),testOperationsIds:i.z.string().array().optional()})).array().optional(),operations:_.array().optional()});function z(e){try{const t=s.parse(e),r=f.parse(t),n={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description},i=v(r),a={baseUrl:r.baseUrl,authentication:k(i)},c=S(r,a);return n.operations=c,n.authentication=i,o.notMissing(c)&&(n.categories=C(Object.values(c))),n}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const k=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]=k(a)}else t[o]=r;return t},C=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},v=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},S=(e,t)=>{const o=e.operations?.reduce(((e,o)=>{const n=(e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0)(o),s=(e=>"list"===e.operationType?`GET /${e.schema}`:`GET /${e.schema}/:id`)(o),i=(e=>"list"===e.operationType?`/${e.schema}`:`/${e.schema}/:id`)(o),a=(e=>{const t={success:b(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."}}},o=e.responses?.reduce(((e,t)=>(r.isSuccessStatusCode(t.statusCode)?e.success={statusCode:t.statusCode,description:t.description}:e.errors[t.statusCode]={statusCode:t.statusCode,description:t.description},e)),t);return o??t})(o);return e[n??s]={id:o.operationId,categories:o.categories,description:o.description,operationType:o.operationType,entrypointUrl:o.entrypointUrl??i,entrypointHttpMethod:o.entrypointHttpMethod??"get",responses:a,inputs:o.inputs,steps:o.steps.reduce(((e,r)=>(e[r.stepId]={id:r.stepId,description:r.description,condition:r.condition,ignoreError:r.ignoreError,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{..."request"===r.stepFunction.functionName?t:{},..."map_fields"===r.stepFunction.functionName||"typecast"===r.stepFunction.functionName?{fields:o.fieldConfigs}:{},...r.stepFunction.parameters}}},e)),{}),result:o.result},e}),{});return o},I=(e,t)=>{if(!e.inputs)return{};const o=E(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},w=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=i.z.string();break;case"number":o=i.z.number();break;case"boolean":o=i.z.boolean();break;default:o=i.z.any()}t[e.name]=e.required?o:o.optional()})),i.z.object(t)},E=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 i.z.object({path:w(t).optional(),query:w(o).optional(),body:w(r).optional(),headers:w(n).optional()})};class F extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,F)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class O extends F{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class T extends F{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class x extends F{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class j extends F{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const N=(t,r)=>{const n=t?.next,s=o.notMissing(n)&&"list"===r.operationType?e.expandCursor(n):void 0;if(null===s)throw new j(r,"Invalid cursor.");return s};exports.ConnectSDKError=F,exports.createBlock=d,exports.executeStepFunction=async({block:t,stepFunctionName:o,params:r,buildStepFunction:n=e.StepFunctionsFactory.build})=>{const s=n({functionName:o}).fn,i=await s({block:t,params:r}),a=o===e.StepFunctionName.MAP_FIELDS?{[e.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:i.block.result},errors:i.errors,successful:i.successful}}:{};return{...i.block,steps:{...i?.block?.steps??{},...a}}},exports.getOperationFromUrl=y,exports.parseOperationInputs=I,exports.parseYamlConnector=z,exports.runConnectorOperation=async({account:e,connector:t,category:r,path:n,method:s="get",queryParams:i,body:c,headers:p,logger:u,parseConnector:g=z,getOperationFromUrlFn:h=y,parseOperationInputsFn:b=I,createBlockContextFn:m=l,createBlockFn:_=d,runStepOperationFn:f=a})=>{const k=e.authConfigKey,C=e.environment??"production",v=e.secureId,S=e.projectSecureId,w=e.credentials,E=m({category:r,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:k,environment:C,accountSecureId:v,projectSecureId:S});let F;try{F=o.isString(t)?g(t):t}catch{throw new O(E,"Error while parsing connector")}const j=h(F,n,s);if(o.isMissing(j))throw new T(E,"No matching operation found");E.operationType=j.operation.operationType,E.schema=j.operation.schema?.key;const R=N(i,E);let q;try{q=b(j.operation,{query:i,body:c,headers:p,path:j.params})}catch{throw new x(E,"Error while parsing operation inputs")}const U=await _({inputs:q,context:E,operation:j.operation,credentials:w,nextCursor:R,logger:u});return await f({block:U})},exports.runStepOperation=a;
@@ -1,10 +1,11 @@
1
- import { Block, BlockContext, ILogger, Operation } from '@stackone/core';
1
+ import { Block, BlockContext, Cursor, ILogger, Operation } from '@stackone/core';
2
2
  import { IHttpClient } from '@stackone/transport';
3
- export declare const createBlock: ({ inputs, context, operation, credentials, logger, getHttpClient, }: {
3
+ export declare const createBlock: ({ inputs, context, operation, credentials, nextCursor, logger, getHttpClient, }: {
4
4
  inputs?: Record<string, unknown>;
5
5
  context: BlockContext;
6
6
  operation: Operation;
7
7
  credentials?: Record<string, unknown>;
8
+ nextCursor?: Cursor;
8
9
  logger?: ILogger;
9
10
  getHttpClient?: () => Promise<IHttpClient>;
10
11
  }) => Promise<Block>;
@@ -0,0 +1,3 @@
1
+ import { OperationResponse, OperationType } from '@stackone/core';
2
+ export declare const getDefaultSuccessOperationResponse: (operationType: OperationType) => OperationResponse;
3
+ export declare const getDefaultErrorOperationResponses: () => Record<number, OperationResponse>;
@@ -2,11 +2,21 @@ import { z } from 'zod';
2
2
  export declare const OPERATION_SCHEMA: z.ZodObject<{
3
3
  operationId: z.ZodString;
4
4
  categories: z.ZodArray<z.ZodString, "many">;
5
- operationType: z.ZodString;
5
+ operationType: z.ZodEnum<["list", "get", "create", "update", "delete", "custom", "unknown"]>;
6
6
  schema: z.ZodOptional<z.ZodString>;
7
7
  entrypointUrl: z.ZodOptional<z.ZodString>;
8
8
  entrypointHttpMethod: z.ZodOptional<z.ZodString>;
9
9
  description: z.ZodString;
10
+ responses: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ statusCode: z.ZodNumber;
12
+ description: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ description: string;
15
+ statusCode: number;
16
+ }, {
17
+ description: string;
18
+ statusCode: number;
19
+ }>, "many">>;
10
20
  inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
21
  name: z.ZodString;
12
22
  type: z.ZodString;
@@ -120,7 +130,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
120
130
  description: string;
121
131
  operationId: string;
122
132
  categories: string[];
123
- operationType: string;
133
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
124
134
  steps: {
125
135
  description: string;
126
136
  stepId: string;
@@ -135,6 +145,10 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
135
145
  schema?: string | undefined;
136
146
  entrypointUrl?: string | undefined;
137
147
  entrypointHttpMethod?: string | undefined;
148
+ responses?: {
149
+ description: string;
150
+ statusCode: number;
151
+ }[] | undefined;
138
152
  inputs?: {
139
153
  type: string;
140
154
  required: boolean;
@@ -159,7 +173,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
159
173
  description: string;
160
174
  operationId: string;
161
175
  categories: string[];
162
- operationType: string;
176
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
163
177
  steps: {
164
178
  description: string;
165
179
  stepId: string;
@@ -174,6 +188,10 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
174
188
  schema?: string | undefined;
175
189
  entrypointUrl?: string | undefined;
176
190
  entrypointHttpMethod?: string | undefined;
191
+ responses?: {
192
+ description: string;
193
+ statusCode: number;
194
+ }[] | undefined;
177
195
  inputs?: {
178
196
  type: string;
179
197
  required: boolean;
@@ -405,11 +423,21 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
405
423
  operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
406
424
  operationId: z.ZodString;
407
425
  categories: z.ZodArray<z.ZodString, "many">;
408
- operationType: z.ZodString;
426
+ operationType: z.ZodEnum<["list", "get", "create", "update", "delete", "custom", "unknown"]>;
409
427
  schema: z.ZodOptional<z.ZodString>;
410
428
  entrypointUrl: z.ZodOptional<z.ZodString>;
411
429
  entrypointHttpMethod: z.ZodOptional<z.ZodString>;
412
430
  description: z.ZodString;
431
+ responses: z.ZodOptional<z.ZodArray<z.ZodObject<{
432
+ statusCode: z.ZodNumber;
433
+ description: z.ZodString;
434
+ }, "strip", z.ZodTypeAny, {
435
+ description: string;
436
+ statusCode: number;
437
+ }, {
438
+ description: string;
439
+ statusCode: number;
440
+ }>, "many">>;
413
441
  inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
414
442
  name: z.ZodString;
415
443
  type: z.ZodString;
@@ -523,7 +551,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
523
551
  description: string;
524
552
  operationId: string;
525
553
  categories: string[];
526
- operationType: string;
554
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
527
555
  steps: {
528
556
  description: string;
529
557
  stepId: string;
@@ -538,6 +566,10 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
538
566
  schema?: string | undefined;
539
567
  entrypointUrl?: string | undefined;
540
568
  entrypointHttpMethod?: string | undefined;
569
+ responses?: {
570
+ description: string;
571
+ statusCode: number;
572
+ }[] | undefined;
541
573
  inputs?: {
542
574
  type: string;
543
575
  required: boolean;
@@ -562,7 +594,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
562
594
  description: string;
563
595
  operationId: string;
564
596
  categories: string[];
565
- operationType: string;
597
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
566
598
  steps: {
567
599
  description: string;
568
600
  stepId: string;
@@ -577,6 +609,10 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
577
609
  schema?: string | undefined;
578
610
  entrypointUrl?: string | undefined;
579
611
  entrypointHttpMethod?: string | undefined;
612
+ responses?: {
613
+ description: string;
614
+ statusCode: number;
615
+ }[] | undefined;
580
616
  inputs?: {
581
617
  type: string;
582
618
  required: boolean;
@@ -653,7 +689,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
653
689
  description: string;
654
690
  operationId: string;
655
691
  categories: string[];
656
- operationType: string;
692
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
657
693
  steps: {
658
694
  description: string;
659
695
  stepId: string;
@@ -668,6 +704,10 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
668
704
  schema?: string | undefined;
669
705
  entrypointUrl?: string | undefined;
670
706
  entrypointHttpMethod?: string | undefined;
707
+ responses?: {
708
+ description: string;
709
+ statusCode: number;
710
+ }[] | undefined;
671
711
  inputs?: {
672
712
  type: string;
673
713
  required: boolean;
@@ -744,7 +784,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
744
784
  description: string;
745
785
  operationId: string;
746
786
  categories: string[];
747
- operationType: string;
787
+ operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
748
788
  steps: {
749
789
  description: string;
750
790
  stepId: string;
@@ -759,6 +799,10 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
759
799
  schema?: string | undefined;
760
800
  entrypointUrl?: string | undefined;
761
801
  entrypointHttpMethod?: string | undefined;
802
+ responses?: {
803
+ description: string;
804
+ statusCode: number;
805
+ }[] | undefined;
762
806
  inputs?: {
763
807
  type: string;
764
808
  required: boolean;
@@ -15,3 +15,6 @@ export declare class MissingOperationError extends ConnectSDKError {
15
15
  export declare class InvalidOperationInputsError extends ConnectSDKError {
16
16
  constructor(context: BlockContext, message?: string);
17
17
  }
18
+ export declare class InvalidCursorError extends ConnectSDKError {
19
+ constructor(context: BlockContext, message?: string);
20
+ }
@@ -1 +1 @@
1
- export type ErrorType = 'CONNECTOR_PARSE_ERROR' | 'MISSING_OPERATION_ERROR' | 'INVALID_OPERATION_INPUTS_ERROR';
1
+ export type ErrorType = 'CONNECTOR_PARSE_ERROR' | 'MISSING_OPERATION_ERROR' | 'INVALID_OPERATION_INPUTS_ERROR' | 'INVALID_CURSOR_ERROR';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/connect-sdk",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",