@stackone/connect-sdk 1.18.0 → 1.20.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}from"@stackone/expressions";import{notMissing as r,isString as i,isMissing as s}from"@stackone/utils";import{HttpClientManager as a}from"@stackone/transport";import{match as c}from"path-to-regexp";import{parse as p}from"yaml";import{z as u}from"zod";const l=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}}},d=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=y({block:i,stepId:t,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){i=y({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=y({block:i,stepId:t,successful:!1,functionOutput:p});(e.ignoreError??!1)||(a=!0)}else i=y({block:p.block,stepId:t,functionOutput:p})}const c=e.operation?.result?n(e.operation.result,i):void 0;return{...i,outputs:c}},y=({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}}}),m=async({inputs:t,context:e,operation:o,credentials:n,logger:r,getHttpClient:i=async()=>a.getInstance()})=>({inputs:t,fieldConfigs:[],context:e,operation:o,credentials:n,httpClient:await i(),logger:r}),g=({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}),b=(t,e,o)=>{const n=o.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=_(e,n,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},h=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},_=(t,e,o)=>{const n=h(t);for(const t of o)if(t.startsWith(e)){const o=t.replace(`${e} `,"").trim(),r=c(h(o))(h(n));if(!1!==r)return{path:t,params:r.params}}},f=u.object({key:u.string(),label:u.string(),type:u.string(),required:u.boolean().optional(),secret:u.boolean().optional(),placeholder:u.string().optional(),description:u.string().optional(),tooltip:u.string().optional()}),k=u.object({operationId:u.string(),categories:u.string().array(),operationType:u.string(),schema:u.string().optional(),entrypointUrl:u.string().optional(),entrypointHttpMethod:u.string().optional(),description:u.string(),inputs:u.object({name:u.string(),type:u.string(),required:u.boolean(),description:u.string(),in:u.string()}).array().optional(),fieldConfigs:u.object({targetFieldKey:u.string(),expression:u.string(),type:u.enum(["string","number","boolean","datetime_string","enum"]),isUnified:u.boolean(),enumMapper:u.object({matcher:u.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(u.object({matchExpression:u.string(),value:u.string()}).array())}).optional()}).array().optional(),steps:u.object({stepId:u.string(),description:u.string(),stepFunction:u.object({functionName:u.string(),version:u.string().optional(),parameters:u.record(u.string(),u.unknown())}),condition:u.string().optional(),ignoreError:u.boolean().optional()}).array(),result:u.string()}),v=u.object({StackOne:u.string(),info:u.object({title:u.string(),version:u.string(),key:u.string(),description:u.string().optional()}),baseUrl:u.string(),authentication:u.record(u.string(),u.object({type:u.string(),label:u.string(),authorization:o,environments:u.object({key:u.string(),name:u.string()}).array(),support:u.object({link:u.string(),description:u.string().optional()}),configFields:f.array().optional(),setupFields:f.array().optional(),testOperationsIds:u.string().array().optional()})).array().optional(),operations:k.array().optional()});function I(t){try{const e=p(t),o=v.parse(e),n={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},i=j(o),s={baseUrl:o.baseUrl,authentication:E(i)},a=F(o,s);return n.operations=a,n.authentication=i,r(a)&&(n.categories=S(Object.values(a))),n}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const E=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]=E(a)}else e[o]=n;return e},S=t=>{const e=t.reduce(((t,e)=>{for(const o of e.categories)t.add(o);return t}),new Set);return Array.from(e)},j=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},F=(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},O=(t,e)=>{if(!t.inputs)return{};const o=T(t.inputs).parse(e);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},w=t=>{const e={};return t.forEach((t=>{let o;switch(t.type.toLowerCase()){case"string":o=u.string();break;case"number":o=u.number();break;case"boolean":o=u.boolean();break;default:o=u.any()}e[t.name]=t.required?o:o.optional()})),u.object(e)},T=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 u.object({path:w(e).optional(),query:w(o).optional(),body:w(n).optional(),headers:w(r).optional()})};class N extends Error{constructor(t,e,o){super(o),this.name="ConnectSDKError",this.errorType=t,this.context=e,Error.captureStackTrace&&Error.captureStackTrace(this,N)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class C extends N{constructor(t,e){super("CONNECTOR_PARSE_ERROR",t,e),this.name="ConnectorParseError"}}class x extends N{constructor(t,e){super("MISSING_OPERATION_ERROR",t,e),this.name="MissingOperationError"}}class R extends N{constructor(t,e){super("INVALID_OPERATION_INPUTS_ERROR",t,e),this.name="InvalidOperationInputsError"}}const U=async({account:t,connector:e,category:o,path:n,method:r="get",queryParams:a,body:c,headers:p,logger:u,parseConnector:l=I,getOperationFromUrlFn:y=b,parseOperationInputsFn:h=O,createBlockContextFn:_=g,createBlockFn:f=m,runStepOperationFn:k=d})=>{const v=t.authConfigKey,E=t.environment??"production",S=t.secureId,j=t.projectSecureId,F=t.credentials,w=_({category:o,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:v,environment:E,accountSecureId:S,projectSecureId:j});let T;try{T=i(e)?l(e):e}catch{throw new C(w,"Error while parsing connector")}const N=y(T,n,r);if(s(N))throw new x(w,"No matching operation found");let U;w.operationType=N.operation.operationType,w.schema=N.operation.schema?.key;try{U=h(N.operation,{query:a,body:c,headers:p,path:N.params})}catch{throw new R(w,"Error while parsing operation inputs")}const M=await f({inputs:U,context:w,operation:N.operation,credentials:F,logger:u});return await k({block:M})};export{N as ConnectSDKError,m as createBlock,l as executeStepFunction,b as getOperationFromUrl,O as parseOperationInputs,I as parseYamlConnector,U as runConnectorOperation,d as runStepOperation};
|
|
1
|
+
import{StepFunctionsFactory as e,StepFunctionName as t,AUTHENTICATION_SCHEMA as o}from"@stackone/core";import{safeEvaluate as r,safeEvaluateRecord as n}from"@stackone/expressions";import{isObject as s,notMissing as i,isString as c,isMissing as a}from"@stackone/utils";import{HttpClientManager as p,isSuccessStatusCode as u}from"@stackone/transport";import{match as d}from"path-to-regexp";import{parse as l}from"yaml";import{z as y}from"zod";const m=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})=>{const n=t.operation?.steps||[];let s={...t};const i=Object.keys(n);let c=!1,a=null;for(const e of i){const t=n[e],i=t.stepFunction,p=o({functionName:i.functionName,version:i.version,validateSchemas:!0}).fn;if(t.condition&&!r(t.condition,s)){s=b({block:s,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(c){s=b({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=b({block:s,stepId:e,successful:!1,functionOutput:u});(t.ignoreError??!1)||(c=!0,a??=u.output?.statusCode??500)}else s=b({block:u.block,stepId:e,functionOutput:u})}const p=t.operation?.result?h(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"}}},h=(e,t)=>s(e)?n(e,t):r(e,t),b=({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}}}),f=async({inputs:e,context:t,operation:o,credentials:r,logger:n,getHttpClient:s=async()=>p.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:r,httpClient:await s(),logger:n}),_=({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}),k=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=C(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},v=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},C=(e,t,o)=>{const r=v(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),n=d(v(o))(v(r));if(!1!==n)return{path:e,params:n.params}}},w=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}`)}},I=y.object({key:y.string(),label:y.string(),type:y.string(),required:y.boolean().optional(),secret:y.boolean().optional(),placeholder:y.string().optional(),description:y.string().optional(),tooltip:y.string().optional()}),E=y.object({operationId:y.string(),categories:y.string().array(),operationType:y.enum(["list","get","create","update","delete","custom","unknown"]),schema:y.string().optional(),entrypointUrl:y.string().optional(),entrypointHttpMethod:y.string().optional(),description:y.string(),responses:y.object({statusCode:y.number(),description:y.string()}).array().optional(),inputs:y.object({name:y.string(),type:y.string(),required:y.boolean(),description:y.string(),in:y.string()}).array().optional(),fieldConfigs:y.object({targetFieldKey:y.string(),expression:y.string(),type:y.enum(["string","number","boolean","datetime_string","enum"]),isUnified:y.boolean(),enumMapper:y.object({matcher:y.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(y.object({matchExpression:y.string(),value:y.string()}).array())}).optional()}).array().optional(),steps:y.object({stepId:y.string(),description:y.string(),stepFunction:y.object({functionName:y.string(),version:y.string().optional(),parameters:y.record(y.string(),y.unknown())}),condition:y.string().optional(),ignoreError:y.boolean().optional()}).array(),result:y.string().or(y.record(y.string(),y.unknown())).optional()}),S=y.object({StackOne:y.string(),info:y.object({title:y.string(),version:y.string(),key:y.string(),description:y.string().optional()}),baseUrl:y.string(),authentication:y.record(y.string(),y.object({type:y.string(),label:y.string(),authorization:o,environments:y.object({key:y.string(),name:y.string()}).array(),support:y.object({link:y.string(),description:y.string().optional()}),configFields:I.array().optional(),setupFields:I.array().optional(),testOperationsIds:y.string().array().optional()})).array().optional(),operations:E.array().optional()});function T(e){try{const t=l(e),o=S.parse(t),r={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},n=O(o),s={baseUrl:o.baseUrl,authentication:j(n)},c=N(o,s);return r.operations=c,r.authentication=n,i(c)&&(r.categories=F(Object.values(c))),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},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)},O=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},N=(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:w(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)=>(u(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},x=(e,t)=>{if(!e.inputs)return{};const o=R(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},U=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=y.string();break;case"number":o=y.number();break;case"boolean":o=y.boolean();break;default:o=y.any()}t[e.name]=e.required?o:o.optional()})),y.object(t)},R=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 y.object({path:U(t).optional(),query:U(o).optional(),body:U(r).optional(),headers:U(n).optional()})};class q extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,q)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class $ extends q{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class M extends q{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class K extends q{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}const A=async({account:e,connector:t,category:o,path:r,method:n="get",queryParams:s,body:i,headers:p,logger:u,parseConnector:d=T,getOperationFromUrlFn:l=k,parseOperationInputsFn:y=x,createBlockContextFn:m=_,createBlockFn:h=f,runStepOperationFn:b=g})=>{const v=e.authConfigKey,C=e.environment??"production",w=e.secureId,I=e.projectSecureId,E=e.credentials,S=m({category:o,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:v,environment:C,accountSecureId:w,projectSecureId:I});let j;try{j=c(t)?d(t):t}catch{throw new $(S,"Error while parsing connector")}const F=l(j,r,n);if(a(F))throw new M(S,"No matching operation found");let O;S.operationType=F.operation.operationType,S.schema=F.operation.schema?.key;try{O=y(F.operation,{query:s,body:i,headers:p,path:F.params})}catch{throw new K(S,"Error while parsing operation inputs")}const N=await h({inputs:O,context:S,operation:F.operation,credentials:E,logger:u});return await b({block:N})};export{q as ConnectSDKError,f as createBlock,m as executeStepFunction,k as getOperationFromUrl,x as parseOperationInputs,T as parseYamlConnector,A 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,p=n({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(o.condition&&!t.safeEvaluate(o.condition,i)){i=c({block:i,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){i=c({block:i,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=await p({block:i,params:s.params});if(!1===u.successful){i=c({block:i,stepId:e,successful:!1,functionOutput:u});(o.ignoreError??!1)||(a=!0)}else i=c({block:u.block,stepId:e,functionOutput:u})}const p=o.operation?.result?t.safeEvaluate(o.operation.result,i):void 0;return{...i,outputs:p}},c=({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}}}),p=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}),u=({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}),l=(e,t,o)=>{const n=o.toUpperCase();if(!e.operations)return;const r=Object.keys(e.operations),i=y(t,n,r);return i?{operation:e.operations?.[i.path],params:i.params}:void 0},d=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},y=(e,t,o)=>{const n=d(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),i=r.match(d(o))(d(n));if(!1!==i)return{path:e,params:i.params}}},g=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()}),b=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:g.array().optional(),setupFields:g.array().optional(),testOperationsIds:s.z.string().array().optional()})).array().optional(),operations:m.array().optional()});function h(e){try{const t=i.parse(e),n=b.parse(t),r={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},s=z(n),a={baseUrl:n.baseUrl,authentication:_(s)},c=k(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 _=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]=_(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)},z=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},k=(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},v=(e,t)=>{if(!e.inputs)return{};const o=S(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},I=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)},S=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:I(t).optional(),query:I(o).optional(),body:I(n).optional(),headers:I(r).optional()})};class E extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,E)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class F extends E{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class O extends E{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class j extends E{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}exports.ConnectSDKError=E,exports.createBlock=p,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=l,exports.parseOperationInputs=v,exports.parseYamlConnector=h,exports.runConnectorOperation=async({account:e,connector:t,category:n,path:r,method:i="get",queryParams:s,body:c,headers:d,logger:y,parseConnector:g=h,getOperationFromUrlFn:m=l,parseOperationInputsFn:b=v,createBlockContextFn:_=u,createBlockFn:f=p,runStepOperationFn:z=a})=>{const k=e.authConfigKey,I=e.environment??"production",S=e.secureId,E=e.projectSecureId,C=e.credentials,N=_({category:n,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:k,environment:I,accountSecureId:S,projectSecureId:E});let T;try{T=o.isString(t)?g(t):t}catch{throw new F(N,"Error while parsing connector")}const x=m(T,r,i);if(o.isMissing(x))throw new O(N,"No matching operation found");let w;N.operationType=x.operation.operationType,N.schema=x.operation.schema?.key;try{w=b(x.operation,{query:s,body:c,headers:d,path:x.params})}catch{throw new j(N,"Error while parsing operation inputs")}const q=await f({inputs:w,context:N,operation:x.operation,credentials:C,logger:y});return await z({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:o,buildStepFunction:r=e.StepFunctionsFactory.build})=>{const n=o.operation?.steps||[];let s={...o};const i=Object.keys(n);let a=!1,u=null;for(const e of i){const o=n[e],i=o.stepFunction,c=r({functionName:i.functionName,version:i.version,validateSchemas:!0}).fn;if(o.condition&&!t.safeEvaluate(o.condition,s)){s=p({block:s,stepId:e,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(a){s=p({block:s,stepId:e,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const d=await c({block:s,params:i.params});if(!1===d.successful){s=p({block:s,stepId:e,successful:!1,functionOutput:d});(o.ignoreError??!1)||(a=!0,u??=d.output?.statusCode??500)}else s=p({block:d.block,stepId:e,functionOutput:d})}const d=o.operation?.result?c(o.operation.result,s):void 0,l=!a,y=l?o.operation?.responses.success.statusCode??200:u??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"}}},c=(e,r)=>o.isObject(e)?t.safeEvaluateRecord(e,r):t.safeEvaluate(e,r),p=({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}}}),u=async({inputs:e,context:t,operation:o,credentials:n,logger:s,getHttpClient:i=async()=>r.HttpClientManager.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:n,httpClient:await i(),logger:s}),d=({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}),l=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=g(t,r,n);return s?{operation:e.operations?.[s.path],params:s.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 r=y(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),s=n.match(y(o))(y(r));if(!1!==s)return{path:e,params:s.params}}},h=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()}),b=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:b.array().optional()});function _(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=C(r),a={baseUrl:r.baseUrl,authentication:z(i)},c=v(r,a);return n.operations=c,n.authentication=i,o.notMissing(c)&&(n.categories=k(Object.values(c))),n}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const z=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]=z(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)},C=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},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),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:h(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},S=(e,t)=>{if(!e.inputs)return{};const o=w(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},I=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)},w=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:I(t).optional(),query:I(o).optional(),body:I(r).optional(),headers:I(n).optional()})};class E extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,E)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class F extends E{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class O extends E{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class T extends E{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}exports.ConnectSDKError=E,exports.createBlock=u,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=l,exports.parseOperationInputs=S,exports.parseYamlConnector=_,exports.runConnectorOperation=async({account:e,connector:t,category:r,path:n,method:s="get",queryParams:i,body:c,headers:p,logger:y,parseConnector:g=_,getOperationFromUrlFn:h=l,parseOperationInputsFn:m=S,createBlockContextFn:b=d,createBlockFn:f=u,runStepOperationFn:z=a})=>{const k=e.authConfigKey,C=e.environment??"production",v=e.secureId,I=e.projectSecureId,w=e.credentials,E=b({category:r,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:k,environment:C,accountSecureId:v,projectSecureId:I});let j;try{j=o.isString(t)?g(t):t}catch{throw new F(E,"Error while parsing connector")}const x=h(j,n,s);if(o.isMissing(x))throw new O(E,"No matching operation found");let N;E.operationType=x.operation.operationType,E.schema=x.operation.schema?.key;try{N=m(x.operation,{query:i,body:c,headers:p,path:x.params})}catch{throw new T(E,"Error while parsing operation inputs")}const q=await f({inputs:N,context:E,operation:x.operation,credentials:w,logger:y});return await z({block:q})},exports.runStepOperation=a;
|
|
@@ -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.
|
|
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;
|
|
@@ -115,12 +125,12 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
115
125
|
condition?: string | undefined;
|
|
116
126
|
ignoreError?: boolean | undefined;
|
|
117
127
|
}>, "many">;
|
|
118
|
-
result: z.ZodString
|
|
128
|
+
result: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
119
129
|
}, "strip", z.ZodTypeAny, {
|
|
120
130
|
description: string;
|
|
121
131
|
operationId: string;
|
|
122
132
|
categories: string[];
|
|
123
|
-
operationType:
|
|
133
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
124
134
|
steps: {
|
|
125
135
|
description: string;
|
|
126
136
|
stepId: string;
|
|
@@ -132,10 +142,13 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
132
142
|
condition?: string | undefined;
|
|
133
143
|
ignoreError?: boolean | undefined;
|
|
134
144
|
}[];
|
|
135
|
-
result: string;
|
|
136
145
|
schema?: string | undefined;
|
|
137
146
|
entrypointUrl?: string | undefined;
|
|
138
147
|
entrypointHttpMethod?: string | undefined;
|
|
148
|
+
responses?: {
|
|
149
|
+
description: string;
|
|
150
|
+
statusCode: number;
|
|
151
|
+
}[] | undefined;
|
|
139
152
|
inputs?: {
|
|
140
153
|
type: string;
|
|
141
154
|
required: boolean;
|
|
@@ -155,11 +168,12 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
155
168
|
}[];
|
|
156
169
|
} | undefined;
|
|
157
170
|
}[] | undefined;
|
|
171
|
+
result?: string | Record<string, unknown> | undefined;
|
|
158
172
|
}, {
|
|
159
173
|
description: string;
|
|
160
174
|
operationId: string;
|
|
161
175
|
categories: string[];
|
|
162
|
-
operationType:
|
|
176
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
163
177
|
steps: {
|
|
164
178
|
description: string;
|
|
165
179
|
stepId: string;
|
|
@@ -171,10 +185,13 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
171
185
|
condition?: string | undefined;
|
|
172
186
|
ignoreError?: boolean | undefined;
|
|
173
187
|
}[];
|
|
174
|
-
result: string;
|
|
175
188
|
schema?: string | undefined;
|
|
176
189
|
entrypointUrl?: string | undefined;
|
|
177
190
|
entrypointHttpMethod?: string | undefined;
|
|
191
|
+
responses?: {
|
|
192
|
+
description: string;
|
|
193
|
+
statusCode: number;
|
|
194
|
+
}[] | undefined;
|
|
178
195
|
inputs?: {
|
|
179
196
|
type: string;
|
|
180
197
|
required: boolean;
|
|
@@ -194,6 +211,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
194
211
|
}[];
|
|
195
212
|
} | undefined;
|
|
196
213
|
}[] | undefined;
|
|
214
|
+
result?: string | Record<string, unknown> | undefined;
|
|
197
215
|
}>;
|
|
198
216
|
export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
199
217
|
StackOne: z.ZodString;
|
|
@@ -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.
|
|
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;
|
|
@@ -518,12 +546,12 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
518
546
|
condition?: string | undefined;
|
|
519
547
|
ignoreError?: boolean | undefined;
|
|
520
548
|
}>, "many">;
|
|
521
|
-
result: z.ZodString
|
|
549
|
+
result: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
|
|
522
550
|
}, "strip", z.ZodTypeAny, {
|
|
523
551
|
description: string;
|
|
524
552
|
operationId: string;
|
|
525
553
|
categories: string[];
|
|
526
|
-
operationType:
|
|
554
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
527
555
|
steps: {
|
|
528
556
|
description: string;
|
|
529
557
|
stepId: string;
|
|
@@ -535,10 +563,13 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
535
563
|
condition?: string | undefined;
|
|
536
564
|
ignoreError?: boolean | undefined;
|
|
537
565
|
}[];
|
|
538
|
-
result: string;
|
|
539
566
|
schema?: string | undefined;
|
|
540
567
|
entrypointUrl?: string | undefined;
|
|
541
568
|
entrypointHttpMethod?: string | undefined;
|
|
569
|
+
responses?: {
|
|
570
|
+
description: string;
|
|
571
|
+
statusCode: number;
|
|
572
|
+
}[] | undefined;
|
|
542
573
|
inputs?: {
|
|
543
574
|
type: string;
|
|
544
575
|
required: boolean;
|
|
@@ -558,11 +589,12 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
558
589
|
}[];
|
|
559
590
|
} | undefined;
|
|
560
591
|
}[] | undefined;
|
|
592
|
+
result?: string | Record<string, unknown> | undefined;
|
|
561
593
|
}, {
|
|
562
594
|
description: string;
|
|
563
595
|
operationId: string;
|
|
564
596
|
categories: string[];
|
|
565
|
-
operationType:
|
|
597
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
566
598
|
steps: {
|
|
567
599
|
description: string;
|
|
568
600
|
stepId: string;
|
|
@@ -574,10 +606,13 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
574
606
|
condition?: string | undefined;
|
|
575
607
|
ignoreError?: boolean | undefined;
|
|
576
608
|
}[];
|
|
577
|
-
result: string;
|
|
578
609
|
schema?: string | undefined;
|
|
579
610
|
entrypointUrl?: string | undefined;
|
|
580
611
|
entrypointHttpMethod?: string | undefined;
|
|
612
|
+
responses?: {
|
|
613
|
+
description: string;
|
|
614
|
+
statusCode: number;
|
|
615
|
+
}[] | undefined;
|
|
581
616
|
inputs?: {
|
|
582
617
|
type: string;
|
|
583
618
|
required: boolean;
|
|
@@ -597,6 +632,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
597
632
|
}[];
|
|
598
633
|
} | undefined;
|
|
599
634
|
}[] | undefined;
|
|
635
|
+
result?: string | Record<string, unknown> | undefined;
|
|
600
636
|
}>, "many">>;
|
|
601
637
|
}, "strip", z.ZodTypeAny, {
|
|
602
638
|
StackOne: string;
|
|
@@ -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:
|
|
692
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
657
693
|
steps: {
|
|
658
694
|
description: string;
|
|
659
695
|
stepId: string;
|
|
@@ -665,10 +701,13 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
665
701
|
condition?: string | undefined;
|
|
666
702
|
ignoreError?: boolean | undefined;
|
|
667
703
|
}[];
|
|
668
|
-
result: string;
|
|
669
704
|
schema?: string | undefined;
|
|
670
705
|
entrypointUrl?: string | undefined;
|
|
671
706
|
entrypointHttpMethod?: string | undefined;
|
|
707
|
+
responses?: {
|
|
708
|
+
description: string;
|
|
709
|
+
statusCode: number;
|
|
710
|
+
}[] | undefined;
|
|
672
711
|
inputs?: {
|
|
673
712
|
type: string;
|
|
674
713
|
required: boolean;
|
|
@@ -688,6 +727,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
688
727
|
}[];
|
|
689
728
|
} | undefined;
|
|
690
729
|
}[] | undefined;
|
|
730
|
+
result?: string | Record<string, unknown> | undefined;
|
|
691
731
|
}[] | undefined;
|
|
692
732
|
}, {
|
|
693
733
|
StackOne: string;
|
|
@@ -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:
|
|
787
|
+
operationType: "custom" | "unknown" | "list" | "get" | "create" | "update" | "delete";
|
|
748
788
|
steps: {
|
|
749
789
|
description: string;
|
|
750
790
|
stepId: string;
|
|
@@ -756,10 +796,13 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
756
796
|
condition?: string | undefined;
|
|
757
797
|
ignoreError?: boolean | undefined;
|
|
758
798
|
}[];
|
|
759
|
-
result: string;
|
|
760
799
|
schema?: string | undefined;
|
|
761
800
|
entrypointUrl?: string | undefined;
|
|
762
801
|
entrypointHttpMethod?: string | undefined;
|
|
802
|
+
responses?: {
|
|
803
|
+
description: string;
|
|
804
|
+
statusCode: number;
|
|
805
|
+
}[] | undefined;
|
|
763
806
|
inputs?: {
|
|
764
807
|
type: string;
|
|
765
808
|
required: boolean;
|
|
@@ -779,5 +822,6 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
779
822
|
}[];
|
|
780
823
|
} | undefined;
|
|
781
824
|
}[] | undefined;
|
|
825
|
+
result?: string | Record<string, unknown> | undefined;
|
|
782
826
|
}[] | undefined;
|
|
783
827
|
}>;
|