@stackone/connect-sdk 1.9.1 → 1.10.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{StepFunctionName as t,StepFunctionsFactory as e,AUTHENTICATION_SCHEMA as n}from"@stackone/core";import{safeEvaluate as o}from"@stackone/expressions";import{parse as r}from"yaml";import{z as i}from"zod";import{HttpClientManager as s}from"@stackone/transport";import{match as a}from"path-to-regexp";const p=async({block:n,stepFunctionName:o,params:r,buildStepFunction:i=e.build})=>{const s=i({functionName:o}).fn,a=await s({block:n,params:r}),p=o===t.MAP_FIELDS?{[t.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...p}}},c=async({block:t,buildStepFunction:n=e.build})=>{const r=t.operation?.steps||[];let i={...t};const s=Object.keys(r);for(const t of s){const e=r[t].stepFunction,o=n({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await o({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=t.operation?.result?o(t.operation.result,i):void 0;return{...i,outputs:a}},u=i.object({StackOne:i.string(),info:i.object({title:i.string(),version:i.string(),key:i.string(),description:i.string().optional(),categories:i.array(i.string())}),baseUrl:i.string(),authentication:i.record(i.string(),i.object({type:i.string(),label:i.string(),authorization:n,environments:i.record(i.string(),i.object({key:i.string(),name:i.string()})).array()})).array().optional(),operations:i.object({operationId:i.string(),operationType:i.string(),schema:i.string().optional(),entrypointUrl:i.string().optional(),entrypointHttpMethod:i.string().optional(),description:i.string(),inputs:i.object({name:i.string(),type:i.string(),required:i.boolean(),description:i.string(),in:i.string()}).array().optional(),fieldConfigs:i.object({targetFieldKey:i.string(),expression:i.string(),type:i.string(),isUnified:i.boolean()}).array(),steps:i.object({stepId:i.string(),description:i.string(),stepFunction:i.object({functionName:i.string(),version:i.string().optional(),parameters:i.record(i.string(),i.unknown())})}).array(),result:i.string()}).array()});function l(t){try{const e=r(t),n=u.parse(e),o={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description,categories:n.info.categories},i=d(n),s={baseUrl:n.baseUrl,authentication:i},a=y(n,s);return o.operations=a,o}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const d=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),o=n[t].environments.reduce(((e,o)=>{const[r]=Object.values(o),{environments:i,...s}=n[t];return e[r.key]={...s,envKey:r.key,envName:r.name},e}),{});e[t]=o}return e},y=(t,e)=>t.operations.reduce(((t,n)=>{const o=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),r=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[o??r]={id:n.operationId,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,o)=>(t[o.stepId]={id:o.stepId,description:o.description,stepFunction:{functionName:o.stepFunction.functionName,version:o.stepFunction.version,params:{..."request"===o.stepFunction.functionName?e:{},..."map_fields"===o.stepFunction.functionName||"typecast"===o.stepFunction.functionName?{fields:n.fieldConfigs}:{},...o.stepFunction.parameters}}},t)),{}),result:n.result},t}),{}),m=(t,e)=>{if(!t.inputs)return{};const n=f(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},g=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=i.string();break;case"number":n=i.number();break;case"boolean":n=i.boolean();break;default:n=i.any()}e[t.name]=t.required?n:n.optional()})),i.object(e)},f=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),r=t.filter((t=>"headers"===t.in));return i.object({path:g(e).optional(),query:g(n).optional(),body:g(o).optional(),headers:g(r).optional()})},b=async({inputs:t,category:e,providerKey:n,authConfigKey:o,environment:r="production",operation:i,accountSecureId:a,projectSecureId:p,credentials:c,logger:u,getHttpClient:l=async()=>s.getInstance()})=>{const d=await l();return{inputs:t,fieldConfigs:[],context:{projectSecureId:p,accountSecureId:a,connector:n,category:e,schema:i.schema?.key,service:"",resource:"",operationType:i.operationType,authenticationType:o,environment:r},operation:i,credentials:c,httpClient:d,logger:u}},h=(t,e,n)=>{const o=n.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=v(e,o,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},k=t=>t.replace(/^(\/+|\/+)$/g,""),v=(t,e,n)=>{const o=k(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),r=a(k(n))(k(o));if(!1!==r)return{path:t,params:r.params}}};export{b as createBlock,p as executeStepFunction,h as getOperationFromUrl,m as parseOperationInputs,l as parseYamlConnector,c as runStepOperation};
1
+ import{StepFunctionName as t,StepFunctionsFactory as e,AUTHENTICATION_SCHEMA as n}from"@stackone/core";import{safeEvaluate as o}from"@stackone/expressions";import{parse as r}from"yaml";import{z as i}from"zod";import{HttpClientManager as s}from"@stackone/transport";import{match as a}from"path-to-regexp";const c=async({block:n,stepFunctionName:o,params:r,buildStepFunction:i=e.build})=>{const s=i({functionName:o}).fn,a=await s({block:n,params:r}),c=o===t.MAP_FIELDS?{[t.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...c}}},p=async({block:t,buildStepFunction:n=e.build})=>{const r=t.operation?.steps||[];let i={...t};const s=Object.keys(r);for(const t of s){const e=r[t].stepFunction,o=n({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await o({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=t.operation?.result?o(t.operation.result,i):void 0;return{...i,outputs:a}},u=i.object({key:i.string(),label:i.string(),type:i.string(),required:i.boolean().optional(),secret:i.boolean().optional(),placeholder:i.string().optional(),description:i.string().optional(),tooltip:i.string().optional()}),l=i.object({StackOne:i.string(),info:i.object({title:i.string(),version:i.string(),key:i.string(),description:i.string().optional()}),baseUrl:i.string(),authentication:i.record(i.string(),i.object({type:i.string(),label:i.string(),authorization:n,environments:i.object({key:i.string(),name:i.string()}).array(),support:i.object({link:i.string(),description:i.string().optional()}),configFields:u.array().optional(),setupFields:u.array().optional()})).array().optional(),operations:i.object({operationId:i.string(),categories:i.string().array(),operationType:i.string(),schema:i.string().optional(),entrypointUrl:i.string().optional(),entrypointHttpMethod:i.string().optional(),description:i.string(),inputs:i.object({name:i.string(),type:i.string(),required:i.boolean(),description:i.string(),in:i.string()}).array().optional(),fieldConfigs:i.object({targetFieldKey:i.string(),expression:i.string(),type:i.string(),isUnified:i.boolean()}).array(),steps:i.object({stepId:i.string(),description:i.string(),stepFunction:i.object({functionName:i.string(),version:i.string().optional(),parameters:i.record(i.string(),i.unknown())})}).array(),result:i.string()}).array()});function d(t){try{const e=r(t),n=l.parse(e),o={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},i=f(n),s={baseUrl:n.baseUrl,authentication:g(i)},a=m(n,s);return o.operations=a,o.authentication=i,o.categories=y(Object.values(a)),o}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const g=t=>{const e={};for(const[n,o]of Object.entries(t))if(o&&"object"==typeof o){const{setupFields:t,configFields:r,support:i,...s}=o;e[n]=g(s)}else e[n]=o;return e},y=t=>{const e=t.reduce(((t,e)=>{for(const n of e.categories)t.add(n);return t}),new Set);return Array.from(e)},f=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),o=n[t].environments.reduce(((e,o)=>{const{key:r,name:i}=o,{environments:s,...a}=n[t];return e[r]={...a,envKey:r,envName:i},e}),{});e[t]=o}return e},m=(t,e)=>t.operations.reduce(((t,n)=>{const o=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),r=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[o??r]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,o)=>(t[o.stepId]={id:o.stepId,description:o.description,stepFunction:{functionName:o.stepFunction.functionName,version:o.stepFunction.version,params:{..."request"===o.stepFunction.functionName?e:{},..."map_fields"===o.stepFunction.functionName||"typecast"===o.stepFunction.functionName?{fields:n.fieldConfigs}:{},...o.stepFunction.parameters}}},t)),{}),result:n.result},t}),{}),b=(t,e)=>{if(!t.inputs)return{};const n=k(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},h=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=i.string();break;case"number":n=i.number();break;case"boolean":n=i.boolean();break;default:n=i.any()}e[t.name]=t.required?n:n.optional()})),i.object(e)},k=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),r=t.filter((t=>"headers"===t.in));return i.object({path:h(e).optional(),query:h(n).optional(),body:h(o).optional(),headers:h(r).optional()})},v=async({inputs:t,category:e,providerKey:n,authConfigKey:o,environment:r="production",operation:i,accountSecureId:a,projectSecureId:c,credentials:p,logger:u,getHttpClient:l=async()=>s.getInstance()})=>{const d=await l();return{inputs:t,fieldConfigs:[],context:{projectSecureId:c,accountSecureId:a,connector:n,category:e,schema:i.schema?.key,service:"",resource:"",operationType:i.operationType,authenticationType:o,environment:r},operation:i,credentials:p,httpClient:d,logger:u}},j=(t,e,n)=>{const o=n.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=I(e,o,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},F=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},I=(t,e,n)=>{const o=F(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),r=a(F(n))(F(o));if(!1!==r)return{path:t,params:r.params}}};export{v as createBlock,c as executeStepFunction,j as getOperationFromUrl,b as parseOperationInputs,d as parseYamlConnector,p as runStepOperation};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("@stackone/core"),e=require("@stackone/expressions"),n=require("yaml"),r=require("zod"),o=require("@stackone/transport"),i=require("path-to-regexp");const s=r.z.object({StackOne:r.z.string(),info:r.z.object({title:r.z.string(),version:r.z.string(),key:r.z.string(),description:r.z.string().optional(),categories:r.z.array(r.z.string())}),baseUrl:r.z.string(),authentication:r.z.record(r.z.string(),r.z.object({type:r.z.string(),label:r.z.string(),authorization:t.AUTHENTICATION_SCHEMA,environments:r.z.record(r.z.string(),r.z.object({key:r.z.string(),name:r.z.string()})).array()})).array().optional(),operations:r.z.object({operationId:r.z.string(),operationType:r.z.string(),schema:r.z.string().optional(),entrypointUrl:r.z.string().optional(),entrypointHttpMethod:r.z.string().optional(),description:r.z.string(),inputs:r.z.object({name:r.z.string(),type:r.z.string(),required:r.z.boolean(),description:r.z.string(),in:r.z.string()}).array().optional(),fieldConfigs:r.z.object({targetFieldKey:r.z.string(),expression:r.z.string(),type:r.z.string(),isUnified:r.z.boolean()}).array(),steps:r.z.object({stepId:r.z.string(),description:r.z.string(),stepFunction:r.z.object({functionName:r.z.string(),version:r.z.string().optional(),parameters:r.z.record(r.z.string(),r.z.unknown())})}).array(),result:r.z.string()}).array()});const a=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),r=n[t].environments.reduce(((e,r)=>{const[o]=Object.values(r),{environments:i,...s}=n[t];return e[o.key]={...s,envKey:o.key,envName:o.name},e}),{});e[t]=r}return e},p=(t,e)=>t.operations.reduce(((t,n)=>{const r=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),o=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[r??o]={id:n.operationId,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,r)=>(t[r.stepId]={id:r.stepId,description:r.description,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{..."request"===r.stepFunction.functionName?e:{},..."map_fields"===r.stepFunction.functionName||"typecast"===r.stepFunction.functionName?{fields:n.fieldConfigs}:{},...r.stepFunction.parameters}}},t)),{}),result:n.result},t}),{}),c=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=r.z.string();break;case"number":n=r.z.number();break;case"boolean":n=r.z.boolean();break;default:n=r.z.any()}e[t.name]=t.required?n:n.optional()})),r.z.object(e)},u=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),i=t.filter((t=>"headers"===t.in));return r.z.object({path:c(e).optional(),query:c(n).optional(),body:c(o).optional(),headers:c(i).optional()})},l=t=>t.replace(/^(\/+|\/+)$/g,""),d=(t,e,n)=>{const r=l(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),o=i.match(l(n))(l(r));if(!1!==o)return{path:t,params:o.params}}};exports.createBlock=async({inputs:t,category:e,providerKey:n,authConfigKey:r,environment:i="production",operation:s,accountSecureId:a,projectSecureId:p,credentials:c,logger:u,getHttpClient:l=async()=>o.HttpClientManager.getInstance()})=>{const d=await l();return{inputs:t,fieldConfigs:[],context:{projectSecureId:p,accountSecureId:a,connector:n,category:e,schema:s.schema?.key,service:"",resource:"",operationType:s.operationType,authenticationType:r,environment:i},operation:s,credentials:c,httpClient:d,logger:u}},exports.executeStepFunction=async({block:e,stepFunctionName:n,params:r,buildStepFunction:o=t.StepFunctionsFactory.build})=>{const i=o({functionName:n}).fn,s=await i({block:e,params:r}),a=n===t.StepFunctionName.MAP_FIELDS?{[t.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=(t,e,n)=>{const r=n.toUpperCase();if(!t.operations)return;const o=Object.keys(t.operations),i=d(e,r,o);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},exports.parseOperationInputs=(t,e)=>{if(!t.inputs)return{};const n=u(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},exports.parseYamlConnector=function(t){try{const e=n.parse(t),r=s.parse(e),o={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description,categories:r.info.categories},i=a(r),c={baseUrl:r.baseUrl,authentication:i},u=p(r,c);return o.operations=u,o}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}},exports.runStepOperation=async({block:n,buildStepFunction:r=t.StepFunctionsFactory.build})=>{const o=n.operation?.steps||[];let i={...n};const s=Object.keys(o);for(const t of s){const e=o[t].stepFunction,n=r({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await n({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=n.operation?.result?e.safeEvaluate(n.operation.result,i):void 0;return{...i,outputs:a}};
1
+ "use strict";var t=require("@stackone/core"),e=require("@stackone/expressions"),n=require("yaml"),r=require("zod"),o=require("@stackone/transport"),i=require("path-to-regexp");const s=r.z.object({key:r.z.string(),label:r.z.string(),type:r.z.string(),required:r.z.boolean().optional(),secret:r.z.boolean().optional(),placeholder:r.z.string().optional(),description:r.z.string().optional(),tooltip:r.z.string().optional()}),a=r.z.object({StackOne:r.z.string(),info:r.z.object({title:r.z.string(),version:r.z.string(),key:r.z.string(),description:r.z.string().optional()}),baseUrl:r.z.string(),authentication:r.z.record(r.z.string(),r.z.object({type:r.z.string(),label:r.z.string(),authorization:t.AUTHENTICATION_SCHEMA,environments:r.z.object({key:r.z.string(),name:r.z.string()}).array(),support:r.z.object({link:r.z.string(),description:r.z.string().optional()}),configFields:s.array().optional(),setupFields:s.array().optional()})).array().optional(),operations:r.z.object({operationId:r.z.string(),categories:r.z.string().array(),operationType:r.z.string(),schema:r.z.string().optional(),entrypointUrl:r.z.string().optional(),entrypointHttpMethod:r.z.string().optional(),description:r.z.string(),inputs:r.z.object({name:r.z.string(),type:r.z.string(),required:r.z.boolean(),description:r.z.string(),in:r.z.string()}).array().optional(),fieldConfigs:r.z.object({targetFieldKey:r.z.string(),expression:r.z.string(),type:r.z.string(),isUnified:r.z.boolean()}).array(),steps:r.z.object({stepId:r.z.string(),description:r.z.string(),stepFunction:r.z.object({functionName:r.z.string(),version:r.z.string().optional(),parameters:r.z.record(r.z.string(),r.z.unknown())})}).array(),result:r.z.string()}).array()});const c=t=>{const e={};for(const[n,r]of Object.entries(t))if(r&&"object"==typeof r){const{setupFields:t,configFields:o,support:i,...s}=r;e[n]=c(s)}else e[n]=r;return e},p=t=>{const e=t.reduce(((t,e)=>{for(const n of e.categories)t.add(n);return t}),new Set);return Array.from(e)},u=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),r=n[t].environments.reduce(((e,r)=>{const{key:o,name:i}=r,{environments:s,...a}=n[t];return e[o]={...a,envKey:o,envName:i},e}),{});e[t]=r}return e},l=(t,e)=>t.operations.reduce(((t,n)=>{const r=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),o=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[r??o]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,r)=>(t[r.stepId]={id:r.stepId,description:r.description,stepFunction:{functionName:r.stepFunction.functionName,version:r.stepFunction.version,params:{..."request"===r.stepFunction.functionName?e:{},..."map_fields"===r.stepFunction.functionName||"typecast"===r.stepFunction.functionName?{fields:n.fieldConfigs}:{},...r.stepFunction.parameters}}},t)),{}),result:n.result},t}),{}),d=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=r.z.string();break;case"number":n=r.z.number();break;case"boolean":n=r.z.boolean();break;default:n=r.z.any()}e[t.name]=t.required?n:n.optional()})),r.z.object(e)},g=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),i=t.filter((t=>"headers"===t.in));return r.z.object({path:d(e).optional(),query:d(n).optional(),body:d(o).optional(),headers:d(i).optional()})},y=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},z=(t,e,n)=>{const r=y(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),o=i.match(y(n))(y(r));if(!1!==o)return{path:t,params:o.params}}};exports.createBlock=async({inputs:t,category:e,providerKey:n,authConfigKey:r,environment:i="production",operation:s,accountSecureId:a,projectSecureId:c,credentials:p,logger:u,getHttpClient:l=async()=>o.HttpClientManager.getInstance()})=>{const d=await l();return{inputs:t,fieldConfigs:[],context:{projectSecureId:c,accountSecureId:a,connector:n,category:e,schema:s.schema?.key,service:"",resource:"",operationType:s.operationType,authenticationType:r,environment:i},operation:s,credentials:p,httpClient:d,logger:u}},exports.executeStepFunction=async({block:e,stepFunctionName:n,params:r,buildStepFunction:o=t.StepFunctionsFactory.build})=>{const i=o({functionName:n}).fn,s=await i({block:e,params:r}),a=n===t.StepFunctionName.MAP_FIELDS?{[t.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=(t,e,n)=>{const r=n.toUpperCase();if(!t.operations)return;const o=Object.keys(t.operations),i=z(e,r,o);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},exports.parseOperationInputs=(t,e)=>{if(!t.inputs)return{};const n=g(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},exports.parseYamlConnector=function(t){try{const e=n.parse(t),r=a.parse(e),o={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description},i=u(r),s={baseUrl:r.baseUrl,authentication:c(i)},d=l(r,s);return o.operations=d,o.authentication=i,o.categories=p(Object.values(d)),o}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}},exports.runStepOperation=async({block:n,buildStepFunction:r=t.StepFunctionsFactory.build})=>{const o=n.operation?.steps||[];let i={...n};const s=Object.keys(o);for(const t of s){const e=o[t].stepFunction,n=r({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await n({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=n.operation?.result?e.safeEvaluate(n.operation.result,i):void 0;return{...i,outputs:a}};
@@ -6,18 +6,15 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
6
6
  version: z.ZodString;
7
7
  key: z.ZodString;
8
8
  description: z.ZodOptional<z.ZodString>;
9
- categories: z.ZodArray<z.ZodString, "many">;
10
9
  }, "strip", z.ZodTypeAny, {
10
+ key: string;
11
11
  title: string;
12
12
  version: string;
13
- key: string;
14
- categories: string[];
15
13
  description?: string | undefined;
16
14
  }, {
15
+ key: string;
17
16
  title: string;
18
17
  version: string;
19
- key: string;
20
- categories: string[];
21
18
  description?: string | undefined;
22
19
  }>;
23
20
  baseUrl: z.ZodString;
@@ -49,7 +46,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
49
46
  type: "bearer";
50
47
  token: string;
51
48
  }>]>;
52
- environments: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodObject<{
49
+ environments: z.ZodArray<z.ZodObject<{
53
50
  key: z.ZodString;
54
51
  name: z.ZodString;
55
52
  }, "strip", z.ZodTypeAny, {
@@ -58,10 +55,76 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
58
55
  }, {
59
56
  key: string;
60
57
  name: string;
61
- }>>, "many">;
58
+ }>, "many">;
59
+ support: z.ZodObject<{
60
+ link: z.ZodString;
61
+ description: z.ZodOptional<z.ZodString>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ link: string;
64
+ description?: string | undefined;
65
+ }, {
66
+ link: string;
67
+ description?: string | undefined;
68
+ }>;
69
+ configFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
70
+ key: z.ZodString;
71
+ label: z.ZodString;
72
+ type: z.ZodString;
73
+ required: z.ZodOptional<z.ZodBoolean>;
74
+ secret: z.ZodOptional<z.ZodBoolean>;
75
+ placeholder: z.ZodOptional<z.ZodString>;
76
+ description: z.ZodOptional<z.ZodString>;
77
+ tooltip: z.ZodOptional<z.ZodString>;
78
+ }, "strip", z.ZodTypeAny, {
79
+ key: string;
80
+ label: string;
81
+ type: string;
82
+ required?: boolean | undefined;
83
+ secret?: boolean | undefined;
84
+ placeholder?: string | undefined;
85
+ description?: string | undefined;
86
+ tooltip?: string | undefined;
87
+ }, {
88
+ key: string;
89
+ label: string;
90
+ type: string;
91
+ required?: boolean | undefined;
92
+ secret?: boolean | undefined;
93
+ placeholder?: string | undefined;
94
+ description?: string | undefined;
95
+ tooltip?: string | undefined;
96
+ }>, "many">>;
97
+ setupFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
98
+ key: z.ZodString;
99
+ label: z.ZodString;
100
+ type: z.ZodString;
101
+ required: z.ZodOptional<z.ZodBoolean>;
102
+ secret: z.ZodOptional<z.ZodBoolean>;
103
+ placeholder: z.ZodOptional<z.ZodString>;
104
+ description: z.ZodOptional<z.ZodString>;
105
+ tooltip: z.ZodOptional<z.ZodString>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ key: string;
108
+ label: string;
109
+ type: string;
110
+ required?: boolean | undefined;
111
+ secret?: boolean | undefined;
112
+ placeholder?: string | undefined;
113
+ description?: string | undefined;
114
+ tooltip?: string | undefined;
115
+ }, {
116
+ key: string;
117
+ label: string;
118
+ type: string;
119
+ required?: boolean | undefined;
120
+ secret?: boolean | undefined;
121
+ placeholder?: string | undefined;
122
+ description?: string | undefined;
123
+ tooltip?: string | undefined;
124
+ }>, "many">>;
62
125
  }, "strip", z.ZodTypeAny, {
63
- type: string;
64
126
  label: string;
127
+ type: string;
65
128
  authorization: {
66
129
  type: "basic";
67
130
  username: string;
@@ -71,13 +134,37 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
71
134
  type: "bearer";
72
135
  token: string;
73
136
  };
74
- environments: Record<string, {
137
+ environments: {
75
138
  key: string;
76
139
  name: string;
77
- }>[];
140
+ }[];
141
+ support: {
142
+ link: string;
143
+ description?: string | undefined;
144
+ };
145
+ configFields?: {
146
+ key: string;
147
+ label: string;
148
+ type: string;
149
+ required?: boolean | undefined;
150
+ secret?: boolean | undefined;
151
+ placeholder?: string | undefined;
152
+ description?: string | undefined;
153
+ tooltip?: string | undefined;
154
+ }[] | undefined;
155
+ setupFields?: {
156
+ key: string;
157
+ label: string;
158
+ type: string;
159
+ required?: boolean | undefined;
160
+ secret?: boolean | undefined;
161
+ placeholder?: string | undefined;
162
+ description?: string | undefined;
163
+ tooltip?: string | undefined;
164
+ }[] | undefined;
78
165
  }, {
79
- type: string;
80
166
  label: string;
167
+ type: string;
81
168
  authorization: {
82
169
  type: "basic";
83
170
  username: string;
@@ -87,13 +174,38 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
87
174
  type: "bearer";
88
175
  token: string;
89
176
  };
90
- environments: Record<string, {
177
+ environments: {
91
178
  key: string;
92
179
  name: string;
93
- }>[];
180
+ }[];
181
+ support: {
182
+ link: string;
183
+ description?: string | undefined;
184
+ };
185
+ configFields?: {
186
+ key: string;
187
+ label: string;
188
+ type: string;
189
+ required?: boolean | undefined;
190
+ secret?: boolean | undefined;
191
+ placeholder?: string | undefined;
192
+ description?: string | undefined;
193
+ tooltip?: string | undefined;
194
+ }[] | undefined;
195
+ setupFields?: {
196
+ key: string;
197
+ label: string;
198
+ type: string;
199
+ required?: boolean | undefined;
200
+ secret?: boolean | undefined;
201
+ placeholder?: string | undefined;
202
+ description?: string | undefined;
203
+ tooltip?: string | undefined;
204
+ }[] | undefined;
94
205
  }>>, "many">>;
95
206
  operations: z.ZodArray<z.ZodObject<{
96
207
  operationId: z.ZodString;
208
+ categories: z.ZodArray<z.ZodString, "many">;
97
209
  operationType: z.ZodString;
98
210
  schema: z.ZodOptional<z.ZodString>;
99
211
  entrypointUrl: z.ZodOptional<z.ZodString>;
@@ -107,15 +219,15 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
107
219
  in: z.ZodString;
108
220
  }, "strip", z.ZodTypeAny, {
109
221
  type: string;
222
+ required: boolean;
110
223
  description: string;
111
224
  name: string;
112
- required: boolean;
113
225
  in: string;
114
226
  }, {
115
227
  type: string;
228
+ required: boolean;
116
229
  description: string;
117
230
  name: string;
118
- required: boolean;
119
231
  in: string;
120
232
  }>, "many">>;
121
233
  fieldConfigs: z.ZodArray<z.ZodObject<{
@@ -171,6 +283,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
171
283
  }, "strip", z.ZodTypeAny, {
172
284
  description: string;
173
285
  operationId: string;
286
+ categories: string[];
174
287
  operationType: string;
175
288
  fieldConfigs: {
176
289
  type: string;
@@ -193,14 +306,15 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
193
306
  entrypointHttpMethod?: string | undefined;
194
307
  inputs?: {
195
308
  type: string;
309
+ required: boolean;
196
310
  description: string;
197
311
  name: string;
198
- required: boolean;
199
312
  in: string;
200
313
  }[] | undefined;
201
314
  }, {
202
315
  description: string;
203
316
  operationId: string;
317
+ categories: string[];
204
318
  operationType: string;
205
319
  fieldConfigs: {
206
320
  type: string;
@@ -223,25 +337,25 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
223
337
  entrypointHttpMethod?: string | undefined;
224
338
  inputs?: {
225
339
  type: string;
340
+ required: boolean;
226
341
  description: string;
227
342
  name: string;
228
- required: boolean;
229
343
  in: string;
230
344
  }[] | undefined;
231
345
  }>, "many">;
232
346
  }, "strip", z.ZodTypeAny, {
233
347
  StackOne: string;
234
348
  info: {
349
+ key: string;
235
350
  title: string;
236
351
  version: string;
237
- key: string;
238
- categories: string[];
239
352
  description?: string | undefined;
240
353
  };
241
354
  baseUrl: string;
242
355
  operations: {
243
356
  description: string;
244
357
  operationId: string;
358
+ categories: string[];
245
359
  operationType: string;
246
360
  fieldConfigs: {
247
361
  type: string;
@@ -264,15 +378,15 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
264
378
  entrypointHttpMethod?: string | undefined;
265
379
  inputs?: {
266
380
  type: string;
381
+ required: boolean;
267
382
  description: string;
268
383
  name: string;
269
- required: boolean;
270
384
  in: string;
271
385
  }[] | undefined;
272
386
  }[];
273
387
  authentication?: Record<string, {
274
- type: string;
275
388
  label: string;
389
+ type: string;
276
390
  authorization: {
277
391
  type: "basic";
278
392
  username: string;
@@ -282,24 +396,48 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
282
396
  type: "bearer";
283
397
  token: string;
284
398
  };
285
- environments: Record<string, {
399
+ environments: {
286
400
  key: string;
287
401
  name: string;
288
- }>[];
402
+ }[];
403
+ support: {
404
+ link: string;
405
+ description?: string | undefined;
406
+ };
407
+ configFields?: {
408
+ key: string;
409
+ label: string;
410
+ type: string;
411
+ required?: boolean | undefined;
412
+ secret?: boolean | undefined;
413
+ placeholder?: string | undefined;
414
+ description?: string | undefined;
415
+ tooltip?: string | undefined;
416
+ }[] | undefined;
417
+ setupFields?: {
418
+ key: string;
419
+ label: string;
420
+ type: string;
421
+ required?: boolean | undefined;
422
+ secret?: boolean | undefined;
423
+ placeholder?: string | undefined;
424
+ description?: string | undefined;
425
+ tooltip?: string | undefined;
426
+ }[] | undefined;
289
427
  }>[] | undefined;
290
428
  }, {
291
429
  StackOne: string;
292
430
  info: {
431
+ key: string;
293
432
  title: string;
294
433
  version: string;
295
- key: string;
296
- categories: string[];
297
434
  description?: string | undefined;
298
435
  };
299
436
  baseUrl: string;
300
437
  operations: {
301
438
  description: string;
302
439
  operationId: string;
440
+ categories: string[];
303
441
  operationType: string;
304
442
  fieldConfigs: {
305
443
  type: string;
@@ -322,15 +460,15 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
322
460
  entrypointHttpMethod?: string | undefined;
323
461
  inputs?: {
324
462
  type: string;
463
+ required: boolean;
325
464
  description: string;
326
465
  name: string;
327
- required: boolean;
328
466
  in: string;
329
467
  }[] | undefined;
330
468
  }[];
331
469
  authentication?: Record<string, {
332
- type: string;
333
470
  label: string;
471
+ type: string;
334
472
  authorization: {
335
473
  type: "basic";
336
474
  username: string;
@@ -340,9 +478,33 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
340
478
  type: "bearer";
341
479
  token: string;
342
480
  };
343
- environments: Record<string, {
481
+ environments: {
344
482
  key: string;
345
483
  name: string;
346
- }>[];
484
+ }[];
485
+ support: {
486
+ link: string;
487
+ description?: string | undefined;
488
+ };
489
+ configFields?: {
490
+ key: string;
491
+ label: string;
492
+ type: string;
493
+ required?: boolean | undefined;
494
+ secret?: boolean | undefined;
495
+ placeholder?: string | undefined;
496
+ description?: string | undefined;
497
+ tooltip?: string | undefined;
498
+ }[] | undefined;
499
+ setupFields?: {
500
+ key: string;
501
+ label: string;
502
+ type: string;
503
+ required?: boolean | undefined;
504
+ secret?: boolean | undefined;
505
+ placeholder?: string | undefined;
506
+ description?: string | undefined;
507
+ tooltip?: string | undefined;
508
+ }[] | undefined;
347
509
  }>[] | undefined;
348
510
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/connect-sdk",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",