@stackone/connect-sdk 1.16.0 → 1.17.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}}},
|
|
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);for(const t of s){const e=r[t],s=e.stepFunction,a=o({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(e.condition&&!n(e.condition,i)){i={...i,steps:{...i.steps,[t]:{successful:!0,skipped:!0}}};continue}const c=await a({block:i,params:s.params});i={...c.block,steps:{...c.block.steps,[t]:{successful:c.successful,errors:c.errors,output:c.output}}}}const a=e.operation?.result?n(e.operation.result,i):void 0;return{...i,outputs:a}},y=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}),m=({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}),g=(t,e,o)=>{const n=o.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=b(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},b=(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}}},_=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()}),f=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()}).array(),result:u.string()}),k=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:_.array().optional(),setupFields:_.array().optional(),testOperationsIds:u.string().array().optional()})).array().optional(),operations:f.array().optional()});function v(t){try{const e=p(t),o=k.parse(e),n={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},i=F(o),s={baseUrl:o.baseUrl,authentication:I(i)},a=E(o,s);return n.operations=a,n.authentication=i,r(a)&&(n.categories=j(Object.values(a))),n}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const I=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]=I(a)}else e[o]=n;return e},j=t=>{const e=t.reduce(((t,e)=>{for(const o of e.categories)t.add(o);return t}),new Set);return Array.from(e)},F=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},E=(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,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},S=(t,e)=>{if(!t.inputs)return{};const o=w(t.inputs).parse(e);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},O=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)},w=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:O(e).optional(),query:O(o).optional(),body:O(n).optional(),headers:O(r).optional()})};class T extends Error{constructor(t,e,o){super(o),this.name="ConnectSDKError",this.errorType=t,this.context=e,Error.captureStackTrace&&Error.captureStackTrace(this,T)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class N extends T{constructor(t,e){super("CONNECTOR_PARSE_ERROR",t,e),this.name="ConnectorParseError"}}class C extends T{constructor(t,e){super("MISSING_OPERATION_ERROR",t,e),this.name="MissingOperationError"}}class x extends T{constructor(t,e){super("INVALID_OPERATION_INPUTS_ERROR",t,e),this.name="InvalidOperationInputsError"}}const R=async({account:t,connector:e,category:o,path:n,method:r="get",queryParams:a,body:c,headers:p,logger:u,parseConnector:l=v,getOperationFromUrlFn:h=g,parseOperationInputsFn:b=S,createBlockContextFn:_=m,createBlockFn:f=y,runStepOperationFn:k=d})=>{const I=t.authConfigKey,j=t.environment??"production",F=t.secureId,E=t.projectSecureId,O=t.credentials,w=_({category:o,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:I,environment:j,accountSecureId:F,projectSecureId:E});let T;try{T=i(e)?l(e):e}catch{throw new N(w,"Error while parsing connector")}const R=h(T,n,r);if(s(R))throw new C(w,"No matching operation found");let U;w.operationType=R.operation.operationType,w.schema=R.operation.schema?.key;try{U=b(R.operation,{query:a,body:c,headers:p,path:R.params})}catch{throw new x(w,"Error while parsing operation inputs")}const M=await f({inputs:U,context:w,operation:R.operation,credentials:O,logger:u});return await k({block:M})};export{T as ConnectSDKError,y as createBlock,l as executeStepFunction,g as getOperationFromUrl,S as parseOperationInputs,v as parseYamlConnector,R as runConnectorOperation,d as runStepOperation};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var t=require("@stackone/core"),e=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=t.StepFunctionsFactory.build})=>{const r=o.operation?.steps||[];let i={...o};const s=Object.keys(r);for(const t of s){const o=r[t],s=o.stepFunction,a=n({functionName:s.functionName,version:s.version,validateSchemas:!0}).fn;if(o.condition&&!e.safeEvaluate(o.condition,i)){i={...i,steps:{...i.steps,[t]:{successful:!0,skipped:!0}}};continue}const c=await a({block:i,params:s.params});i={...c.block,steps:{...c.block.steps,[t]:{successful:c.successful,errors:c.errors,output:c.output}}}}const a=o.operation?.result?e.safeEvaluate(o.operation.result,i):void 0;return{...i,outputs:a}},c=async({inputs:t,context:e,operation:o,credentials:r,logger:i,getHttpClient:s=async()=>n.HttpClientManager.getInstance()})=>({inputs:t,fieldConfigs:[],context:e,operation:o,credentials:r,httpClient:await s(),logger:i}),p=({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}),u=(t,e,o)=>{const n=o.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=d(e,n,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},l=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},d=(t,e,o)=>{const n=l(t);for(const t of o)if(t.startsWith(e)){const o=t.replace(`${e} `,"").trim(),i=r.match(l(o))(l(n));if(!1!==i)return{path:t,params:i.params}}},y=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()}),g=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()}).array(),result:s.z.string()}),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:t.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:y.array().optional(),setupFields:y.array().optional(),testOperationsIds:s.z.string().array().optional()})).array().optional(),operations:g.array().optional()});function m(t){try{const e=i.parse(t),n=h.parse(e),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=f(n,a);return r.operations=c,r.authentication=s,o.notMissing(c)&&(r.categories=b(Object.values(c))),r}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const _=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]=_(a)}else e[o]=n;return e},b=t=>{const e=t.reduce(((t,e)=>{for(const o of e.categories)t.add(o);return t}),new Set);return Array.from(e)},z=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,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},k=(t,e)=>{if(!t.inputs)return{};const o=F(t.inputs).parse(e);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},v=t=>{const e={};return t.forEach((t=>{let o;switch(t.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()}e[t.name]=t.required?o:o.optional()})),s.z.object(e)},F=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 s.z.object({path:v(e).optional(),query:v(o).optional(),body:v(n).optional(),headers:v(r).optional()})};class S extends Error{constructor(t,e,o){super(o),this.name="ConnectSDKError",this.errorType=t,this.context=e,Error.captureStackTrace&&Error.captureStackTrace(this,S)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class I extends S{constructor(t,e){super("CONNECTOR_PARSE_ERROR",t,e),this.name="ConnectorParseError"}}class E extends S{constructor(t,e){super("MISSING_OPERATION_ERROR",t,e),this.name="MissingOperationError"}}class O extends S{constructor(t,e){super("INVALID_OPERATION_INPUTS_ERROR",t,e),this.name="InvalidOperationInputsError"}}exports.ConnectSDKError=S,exports.createBlock=c,exports.executeStepFunction=async({block:e,stepFunctionName:o,params:n,buildStepFunction:r=t.StepFunctionsFactory.build})=>{const i=r({functionName:o}).fn,s=await i({block:e,params:n}),a=o===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=u,exports.parseOperationInputs=k,exports.parseYamlConnector=m,exports.runConnectorOperation=async({account:t,connector:e,category:n,path:r,method:i="get",queryParams:s,body:l,headers:d,logger:y,parseConnector:g=m,getOperationFromUrlFn:h=u,parseOperationInputsFn:_=k,createBlockContextFn:b=p,createBlockFn:z=c,runStepOperationFn:f=a})=>{const v=t.authConfigKey,F=t.environment??"production",S=t.secureId,j=t.projectSecureId,C=t.credentials,N=b({category:n,connectorKey:t.providerKey,connectorVersion:t.providerVersion,authConfigKey:v,environment:F,accountSecureId:S,projectSecureId:j});let T;try{T=o.isString(e)?g(e):e}catch{throw new I(N,"Error while parsing connector")}const x=h(T,r,i);if(o.isMissing(x))throw new E(N,"No matching operation found");let w;N.operationType=x.operation.operationType,N.schema=x.operation.schema?.key;try{w=_(x.operation,{query:s,body:l,headers:d,path:x.params})}catch{throw new O(N,"Error while parsing operation inputs")}const q=await z({inputs:w,context:N,operation:x.operation,credentials:C,logger:y});return await f({block:q})},exports.runStepOperation=a;
|
|
@@ -26,7 +26,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
26
26
|
name: string;
|
|
27
27
|
in: string;
|
|
28
28
|
}>, "many">>;
|
|
29
|
-
fieldConfigs: z.ZodArray<z.ZodObject<{
|
|
29
|
+
fieldConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
30
30
|
targetFieldKey: z.ZodString;
|
|
31
31
|
expression: z.ZodString;
|
|
32
32
|
type: z.ZodEnum<["string", "number", "boolean", "datetime_string", "enum"]>;
|
|
@@ -75,7 +75,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
75
75
|
matchExpression: string;
|
|
76
76
|
}[];
|
|
77
77
|
} | undefined;
|
|
78
|
-
}>, "many"
|
|
78
|
+
}>, "many">>;
|
|
79
79
|
steps: z.ZodArray<z.ZodObject<{
|
|
80
80
|
stepId: z.ZodString;
|
|
81
81
|
description: z.ZodString;
|
|
@@ -92,6 +92,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
92
92
|
parameters: Record<string, unknown>;
|
|
93
93
|
version?: string | undefined;
|
|
94
94
|
}>;
|
|
95
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
95
96
|
}, "strip", z.ZodTypeAny, {
|
|
96
97
|
description: string;
|
|
97
98
|
stepId: string;
|
|
@@ -100,6 +101,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
100
101
|
parameters: Record<string, unknown>;
|
|
101
102
|
version?: string | undefined;
|
|
102
103
|
};
|
|
104
|
+
condition?: string | undefined;
|
|
103
105
|
}, {
|
|
104
106
|
description: string;
|
|
105
107
|
stepId: string;
|
|
@@ -108,6 +110,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
108
110
|
parameters: Record<string, unknown>;
|
|
109
111
|
version?: string | undefined;
|
|
110
112
|
};
|
|
113
|
+
condition?: string | undefined;
|
|
111
114
|
}>, "many">;
|
|
112
115
|
result: z.ZodString;
|
|
113
116
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -115,18 +118,6 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
115
118
|
operationId: string;
|
|
116
119
|
categories: string[];
|
|
117
120
|
operationType: string;
|
|
118
|
-
fieldConfigs: {
|
|
119
|
-
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
120
|
-
targetFieldKey: string;
|
|
121
|
-
expression: string;
|
|
122
|
-
isUnified: boolean;
|
|
123
|
-
enumMapper?: {
|
|
124
|
-
matcher: "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" | {
|
|
125
|
-
value: string;
|
|
126
|
-
matchExpression: string;
|
|
127
|
-
}[];
|
|
128
|
-
} | undefined;
|
|
129
|
-
}[];
|
|
130
121
|
steps: {
|
|
131
122
|
description: string;
|
|
132
123
|
stepId: string;
|
|
@@ -135,6 +126,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
135
126
|
parameters: Record<string, unknown>;
|
|
136
127
|
version?: string | undefined;
|
|
137
128
|
};
|
|
129
|
+
condition?: string | undefined;
|
|
138
130
|
}[];
|
|
139
131
|
result: string;
|
|
140
132
|
schema?: string | undefined;
|
|
@@ -147,12 +139,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
147
139
|
name: string;
|
|
148
140
|
in: string;
|
|
149
141
|
}[] | undefined;
|
|
150
|
-
|
|
151
|
-
description: string;
|
|
152
|
-
operationId: string;
|
|
153
|
-
categories: string[];
|
|
154
|
-
operationType: string;
|
|
155
|
-
fieldConfigs: {
|
|
142
|
+
fieldConfigs?: {
|
|
156
143
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
157
144
|
targetFieldKey: string;
|
|
158
145
|
expression: string;
|
|
@@ -163,7 +150,12 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
163
150
|
matchExpression: string;
|
|
164
151
|
}[];
|
|
165
152
|
} | undefined;
|
|
166
|
-
}[];
|
|
153
|
+
}[] | undefined;
|
|
154
|
+
}, {
|
|
155
|
+
description: string;
|
|
156
|
+
operationId: string;
|
|
157
|
+
categories: string[];
|
|
158
|
+
operationType: string;
|
|
167
159
|
steps: {
|
|
168
160
|
description: string;
|
|
169
161
|
stepId: string;
|
|
@@ -172,6 +164,7 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
172
164
|
parameters: Record<string, unknown>;
|
|
173
165
|
version?: string | undefined;
|
|
174
166
|
};
|
|
167
|
+
condition?: string | undefined;
|
|
175
168
|
}[];
|
|
176
169
|
result: string;
|
|
177
170
|
schema?: string | undefined;
|
|
@@ -184,6 +177,18 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
184
177
|
name: string;
|
|
185
178
|
in: string;
|
|
186
179
|
}[] | undefined;
|
|
180
|
+
fieldConfigs?: {
|
|
181
|
+
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
182
|
+
targetFieldKey: string;
|
|
183
|
+
expression: string;
|
|
184
|
+
isUnified: boolean;
|
|
185
|
+
enumMapper?: {
|
|
186
|
+
matcher: "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" | {
|
|
187
|
+
value: string;
|
|
188
|
+
matchExpression: string;
|
|
189
|
+
}[];
|
|
190
|
+
} | undefined;
|
|
191
|
+
}[] | undefined;
|
|
187
192
|
}>;
|
|
188
193
|
export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
189
194
|
StackOne: z.ZodString;
|
|
@@ -419,7 +424,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
419
424
|
name: string;
|
|
420
425
|
in: string;
|
|
421
426
|
}>, "many">>;
|
|
422
|
-
fieldConfigs: z.ZodArray<z.ZodObject<{
|
|
427
|
+
fieldConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
423
428
|
targetFieldKey: z.ZodString;
|
|
424
429
|
expression: z.ZodString;
|
|
425
430
|
type: z.ZodEnum<["string", "number", "boolean", "datetime_string", "enum"]>;
|
|
@@ -468,7 +473,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
468
473
|
matchExpression: string;
|
|
469
474
|
}[];
|
|
470
475
|
} | undefined;
|
|
471
|
-
}>, "many"
|
|
476
|
+
}>, "many">>;
|
|
472
477
|
steps: z.ZodArray<z.ZodObject<{
|
|
473
478
|
stepId: z.ZodString;
|
|
474
479
|
description: z.ZodString;
|
|
@@ -485,6 +490,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
485
490
|
parameters: Record<string, unknown>;
|
|
486
491
|
version?: string | undefined;
|
|
487
492
|
}>;
|
|
493
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
488
494
|
}, "strip", z.ZodTypeAny, {
|
|
489
495
|
description: string;
|
|
490
496
|
stepId: string;
|
|
@@ -493,6 +499,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
493
499
|
parameters: Record<string, unknown>;
|
|
494
500
|
version?: string | undefined;
|
|
495
501
|
};
|
|
502
|
+
condition?: string | undefined;
|
|
496
503
|
}, {
|
|
497
504
|
description: string;
|
|
498
505
|
stepId: string;
|
|
@@ -501,6 +508,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
501
508
|
parameters: Record<string, unknown>;
|
|
502
509
|
version?: string | undefined;
|
|
503
510
|
};
|
|
511
|
+
condition?: string | undefined;
|
|
504
512
|
}>, "many">;
|
|
505
513
|
result: z.ZodString;
|
|
506
514
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -508,18 +516,6 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
508
516
|
operationId: string;
|
|
509
517
|
categories: string[];
|
|
510
518
|
operationType: string;
|
|
511
|
-
fieldConfigs: {
|
|
512
|
-
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
513
|
-
targetFieldKey: string;
|
|
514
|
-
expression: string;
|
|
515
|
-
isUnified: boolean;
|
|
516
|
-
enumMapper?: {
|
|
517
|
-
matcher: "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" | {
|
|
518
|
-
value: string;
|
|
519
|
-
matchExpression: string;
|
|
520
|
-
}[];
|
|
521
|
-
} | undefined;
|
|
522
|
-
}[];
|
|
523
519
|
steps: {
|
|
524
520
|
description: string;
|
|
525
521
|
stepId: string;
|
|
@@ -528,6 +524,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
528
524
|
parameters: Record<string, unknown>;
|
|
529
525
|
version?: string | undefined;
|
|
530
526
|
};
|
|
527
|
+
condition?: string | undefined;
|
|
531
528
|
}[];
|
|
532
529
|
result: string;
|
|
533
530
|
schema?: string | undefined;
|
|
@@ -540,12 +537,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
540
537
|
name: string;
|
|
541
538
|
in: string;
|
|
542
539
|
}[] | undefined;
|
|
543
|
-
|
|
544
|
-
description: string;
|
|
545
|
-
operationId: string;
|
|
546
|
-
categories: string[];
|
|
547
|
-
operationType: string;
|
|
548
|
-
fieldConfigs: {
|
|
540
|
+
fieldConfigs?: {
|
|
549
541
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
550
542
|
targetFieldKey: string;
|
|
551
543
|
expression: string;
|
|
@@ -556,7 +548,12 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
556
548
|
matchExpression: string;
|
|
557
549
|
}[];
|
|
558
550
|
} | undefined;
|
|
559
|
-
}[];
|
|
551
|
+
}[] | undefined;
|
|
552
|
+
}, {
|
|
553
|
+
description: string;
|
|
554
|
+
operationId: string;
|
|
555
|
+
categories: string[];
|
|
556
|
+
operationType: string;
|
|
560
557
|
steps: {
|
|
561
558
|
description: string;
|
|
562
559
|
stepId: string;
|
|
@@ -565,6 +562,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
565
562
|
parameters: Record<string, unknown>;
|
|
566
563
|
version?: string | undefined;
|
|
567
564
|
};
|
|
565
|
+
condition?: string | undefined;
|
|
568
566
|
}[];
|
|
569
567
|
result: string;
|
|
570
568
|
schema?: string | undefined;
|
|
@@ -577,6 +575,18 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
577
575
|
name: string;
|
|
578
576
|
in: string;
|
|
579
577
|
}[] | undefined;
|
|
578
|
+
fieldConfigs?: {
|
|
579
|
+
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
580
|
+
targetFieldKey: string;
|
|
581
|
+
expression: string;
|
|
582
|
+
isUnified: boolean;
|
|
583
|
+
enumMapper?: {
|
|
584
|
+
matcher: "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" | {
|
|
585
|
+
value: string;
|
|
586
|
+
matchExpression: string;
|
|
587
|
+
}[];
|
|
588
|
+
} | undefined;
|
|
589
|
+
}[] | undefined;
|
|
580
590
|
}>, "many">>;
|
|
581
591
|
}, "strip", z.ZodTypeAny, {
|
|
582
592
|
StackOne: string;
|
|
@@ -634,18 +644,6 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
634
644
|
operationId: string;
|
|
635
645
|
categories: string[];
|
|
636
646
|
operationType: string;
|
|
637
|
-
fieldConfigs: {
|
|
638
|
-
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
639
|
-
targetFieldKey: string;
|
|
640
|
-
expression: string;
|
|
641
|
-
isUnified: boolean;
|
|
642
|
-
enumMapper?: {
|
|
643
|
-
matcher: "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" | {
|
|
644
|
-
value: string;
|
|
645
|
-
matchExpression: string;
|
|
646
|
-
}[];
|
|
647
|
-
} | undefined;
|
|
648
|
-
}[];
|
|
649
647
|
steps: {
|
|
650
648
|
description: string;
|
|
651
649
|
stepId: string;
|
|
@@ -654,6 +652,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
654
652
|
parameters: Record<string, unknown>;
|
|
655
653
|
version?: string | undefined;
|
|
656
654
|
};
|
|
655
|
+
condition?: string | undefined;
|
|
657
656
|
}[];
|
|
658
657
|
result: string;
|
|
659
658
|
schema?: string | undefined;
|
|
@@ -666,6 +665,18 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
666
665
|
name: string;
|
|
667
666
|
in: string;
|
|
668
667
|
}[] | undefined;
|
|
668
|
+
fieldConfigs?: {
|
|
669
|
+
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
670
|
+
targetFieldKey: string;
|
|
671
|
+
expression: string;
|
|
672
|
+
isUnified: boolean;
|
|
673
|
+
enumMapper?: {
|
|
674
|
+
matcher: "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" | {
|
|
675
|
+
value: string;
|
|
676
|
+
matchExpression: string;
|
|
677
|
+
}[];
|
|
678
|
+
} | undefined;
|
|
679
|
+
}[] | undefined;
|
|
669
680
|
}[] | undefined;
|
|
670
681
|
}, {
|
|
671
682
|
StackOne: string;
|
|
@@ -723,18 +734,6 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
723
734
|
operationId: string;
|
|
724
735
|
categories: string[];
|
|
725
736
|
operationType: string;
|
|
726
|
-
fieldConfigs: {
|
|
727
|
-
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
728
|
-
targetFieldKey: string;
|
|
729
|
-
expression: string;
|
|
730
|
-
isUnified: boolean;
|
|
731
|
-
enumMapper?: {
|
|
732
|
-
matcher: "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" | {
|
|
733
|
-
value: string;
|
|
734
|
-
matchExpression: string;
|
|
735
|
-
}[];
|
|
736
|
-
} | undefined;
|
|
737
|
-
}[];
|
|
738
737
|
steps: {
|
|
739
738
|
description: string;
|
|
740
739
|
stepId: string;
|
|
@@ -743,6 +742,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
743
742
|
parameters: Record<string, unknown>;
|
|
744
743
|
version?: string | undefined;
|
|
745
744
|
};
|
|
745
|
+
condition?: string | undefined;
|
|
746
746
|
}[];
|
|
747
747
|
result: string;
|
|
748
748
|
schema?: string | undefined;
|
|
@@ -755,5 +755,17 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
755
755
|
name: string;
|
|
756
756
|
in: string;
|
|
757
757
|
}[] | undefined;
|
|
758
|
+
fieldConfigs?: {
|
|
759
|
+
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
760
|
+
targetFieldKey: string;
|
|
761
|
+
expression: string;
|
|
762
|
+
isUnified: boolean;
|
|
763
|
+
enumMapper?: {
|
|
764
|
+
matcher: "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" | {
|
|
765
|
+
value: string;
|
|
766
|
+
matchExpression: string;
|
|
767
|
+
}[];
|
|
768
|
+
} | undefined;
|
|
769
|
+
}[] | undefined;
|
|
758
770
|
}[] | undefined;
|
|
759
771
|
}>;
|
|
@@ -5,13 +5,15 @@ import { createBlockContext } from '../blocks/createBlockContext';
|
|
|
5
5
|
import { getOperationFromUrl } from '../connectors/operations';
|
|
6
6
|
import { parseOperationInputs, parseYamlConnector } from '../connectors/parsers';
|
|
7
7
|
import { runStepOperation } from './runStepOperation';
|
|
8
|
-
export declare const runConnectorOperation: ({ account, connector, category, path, method, queryParams, logger, parseConnector, getOperationFromUrlFn, parseOperationInputsFn, createBlockContextFn, createBlockFn, runStepOperationFn, }: {
|
|
8
|
+
export declare const runConnectorOperation: ({ account, connector, category, path, method, queryParams, body, headers, logger, parseConnector, getOperationFromUrlFn, parseOperationInputsFn, createBlockContextFn, createBlockFn, runStepOperationFn, }: {
|
|
9
9
|
account: Account;
|
|
10
10
|
connector: Connector | string;
|
|
11
11
|
category: Category;
|
|
12
12
|
path: string;
|
|
13
13
|
method?: HttpMethod;
|
|
14
14
|
queryParams: unknown;
|
|
15
|
+
body?: unknown;
|
|
16
|
+
headers?: Record<string, string>;
|
|
15
17
|
logger?: ILogger;
|
|
16
18
|
parseConnector?: typeof parseYamlConnector;
|
|
17
19
|
getOperationFromUrlFn?: typeof getOperationFromUrl;
|