@stackone/connect-sdk 1.19.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,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}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,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: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;
|
|
@@ -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:
|
|
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:
|
|
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.
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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;
|