@stackone/connect-sdk 1.25.0 → 1.27.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/types/connectors/schemas.d.ts +156 -12
- package/package.json +1 -1
package/dist/index.es.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{StepFunctionsFactory as e,StepFunctionName as t,isCursorEmpty as o,minifyCursor as r,updateCursor as n,AUTHENTICATION_SCHEMA as s,COMPOSITE_ID_LATEST_VERSION as i,expandCursor as a}from"@stackone/core";import{safeEvaluate as c,safeEvaluateRecord as p}from"@stackone/expressions";import{notMissing as u,isNumber as d,isMissing as l,isObject as y,isString as g}from"@stackone/utils";import{HttpClientManager as m,isSuccessStatusCode as b}from"@stackone/transport";import{match as h}from"path-to-regexp";import{parse as f}from"yaml";import{z as _}from"zod";const k=async({block:o,stepFunctionName:r,params:n,buildStepFunction:s=e.build})=>{const i=s({functionName:r}).fn,a=await i({block:o,params:n}),c=r===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}}},v=(e,t,s,i)=>{const a=l(e)?void 0:e.data,c=Object.keys(s).length+1,p=o({cursor:i,ignoreStepIndex:c});if(!y(e)||l(a)||(a?.length??0)<=t)return{result:e,next:u(i)&&!p?r(i):null};const d=i?.remote?.[c]?.pageNumber??1,g=(d-1)*t,m=g+t,b=a.slice(g,m),h=a.length>m||!p,f=n({cursor:i,stepIndex:c,pageNumber:d+1});return{result:{...e,data:b},next:h?r(f):null}},C=async({block:t,buildStepFunction:o=e.build,virtualPaginateResultFn:r=v})=>await I({block:t,buildStepFunction:o,virtualPaginateResultFn:r}),I=async({block:t,buildStepFunction:o=e.build,virtualPaginateResultFn:r=v})=>{const s=t.operation?.steps||{};let i={...t};const a=Object.keys(s),p=((e,t)=>{const o=Number(e.inputs?.page_size);return u(e.inputs?.page_size)&&d(o)&&!Number.isNaN(o)?o:e.operation?.cursor?.pageSize??t})(t,25);let l=!1,g=null;for(const[e,t]of a.entries()){const r=s[t],a=r.stepFunction,p=o({functionName:a.functionName,version:a.version,validateSchemas:!0}).fn;if(r.condition&&!c(r.condition,i)){i=S({block:i,stepId:t,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(l){i=S({block:i,stepId:t,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=i.operation?.cursor.enabled?{...a.params,cursor:{token:i.nextCursor?.remote?.[e]?.providerPageCursor,position:i.nextCursor?.remote?.[e]?.position}}:a.params,d=await p({block:i,params:u});if(!1===d.successful){i=S({block:i,stepId:t,successful:!1,functionOutput:d});(r.ignoreError??!1)||(l=!0,g??=d.output?.statusCode??500)}else{const o=i.operation?.cursor.enabled?n({cursor:i.nextCursor,stepIndex:e,providerPageCursor:d.output?.next,position:d.output?.position}):void 0;i=S({block:{...d.block,nextCursor:o},stepId:t,functionOutput:d})}}const m=t.operation?.result?w(t.operation.result,i):void 0,b=t.operation?.cursor.enabled?r(m,p,s,i.nextCursor):void 0,h=!l,f=h?t.operation?.responses.success.statusCode??200:g??500,_=u(b)&&y(b.result)?{next:b.next,...b.result}:m;return{...i,outputs:_,response:{successful:h,statusCode:f,message:h?void 0:t.operation?.responses?.errors?.[f]?.description??"Error while processing the request"}}},w=(e,t)=>y(e)?p(e,t):c(e,t),S=({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}}}),x=async({inputs:e,context:t,operation:o,credentials:r,nextCursor:n,logger:s,getHttpClient:i=async()=>m.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:r,nextCursor:n,httpClient:await i(),logger:s}),E=({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}),F=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=O(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},j=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},O=(e,t,o)=>{const r=j(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),n=h(j(o))(j(r));if(!1!==n)return{path:e,params:n.params}}},T=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}`)}},N={key:_.string(),label:_.string(),required:_.boolean().optional().default(!1),secret:_.boolean().optional().default(!1),readOnly:_.boolean().optional().default(!1),placeholder:_.string().optional(),description:_.string().optional(),tooltip:_.string().optional()},R=_.discriminatedUnion("type",[_.object({...N,type:_.enum(["text","password"])}),_.object({...N,type:_.literal("select"),options:_.object({value:_.string(),label:_.string()}).array()})]),U=_.object({operationId:_.string(),categories:_.string().array(),operationType:_.enum(["list","get","create","update","delete","custom","unknown"]),schema:_.string().optional(),entrypointUrl:_.string().optional(),entrypointHttpMethod:_.string().optional(),description:_.string(),responses:_.object({statusCode:_.number(),description:_.string()}).array().optional(),inputs:_.object({name:_.string(),type:_.string(),required:_.boolean(),description:_.string(),in:_.string()}).array().optional(),cursor:_.object({enabled:_.boolean(),pageSize:_.number()}).optional(),fieldConfigs:_.object({targetFieldKey:_.string(),expression:_.string(),type:_.enum(["string","number","boolean","datetime_string","enum"]),isUnified:_.boolean(),enumMapper:_.object({matcher:_.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(_.object({matchExpression:_.string(),value:_.string()}).array())}).optional()}).array().optional(),steps:_.object({stepId:_.string(),description:_.string(),stepFunction:_.object({functionName:_.string(),version:_.string().optional(),parameters:_.record(_.string(),_.unknown())}),condition:_.string().optional(),ignoreError:_.boolean().optional()}).array(),result:_.string().or(_.record(_.string(),_.unknown())).optional()}),q=_.object({StackOne:_.string(),info:_.object({title:_.string(),version:_.string(),key:_.string(),description:_.string().optional()}),baseUrl:_.string(),authentication:_.record(_.string(),_.object({type:_.string(),label:_.string(),authorization:s,environments:_.object({key:_.string(),name:_.string()}).array(),support:_.object({link:_.string(),description:_.string().optional()}),configFields:R.array().optional(),setupFields:R.array().optional(),testOperationsIds:_.string().array().optional()})).array().optional(),operations:U.array().optional()});function P(e){try{const t=f(e),o=q.parse(t),r={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},n=M(o),s={baseUrl:o.baseUrl,authentication:z(n)},i=K(o,s);return r.operations=i,r.authentication=n,u(i)&&(r.categories=$(Object.values(i))),r}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},$=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},M=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},K=(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),a=(e=>{const t={success:T(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)=>(b(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),c=V(o),p=o.inputs||[];return c.enabled&&p?.push({type:"string",name:"page_size",in:"query",required:!1,description:"Number of items to return per page"}),e[r??n]={id:o.operationId,categories:o.categories,description:o.description,operationType:o.operationType,entrypointUrl:o.entrypointUrl??s,entrypointHttpMethod:o.entrypointHttpMethod??"get",responses:a,cursor:c,compositeIdentifiers:{enabled:!1,version:i},inputs:p,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||"paginated_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},A=(e,t)=>{if(!e.inputs)return{};const o=L(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},H=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=_.string();break;case"number":o=_.number();break;case"boolean":o=_.boolean();break;default:o=_.any()}t[e.name]=e.required?o:o.optional()})),_.object(t)},L=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 _.object({path:H(t).optional(),query:H(o).optional(),body:H(r).optional(),headers:H(n).optional()})},V=e=>{const t="list"===e.operationType,o=e.cursor??{enabled:t,pageSize:25};return{enabled:o.enabled&&t,pageSize:o.pageSize}};class D extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,D)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class G extends D{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class W extends D{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class B extends D{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class Y extends D{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const J=async({account:e,connector:t,category:o,path:r,method:n="get",queryParams:s,body:i,headers:a,logger:c,parseConnector:p=P,getOperationFromUrlFn:u=F,parseOperationInputsFn:d=A,createBlockContextFn:y=E,createBlockFn:m=x,runStepOperationFn:b=C})=>{const h=e.authConfigKey,f=e.environment??"production",_=e.secureId,k=e.projectSecureId,v=e.credentials,I=y({category:o,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:h,environment:f,accountSecureId:_,projectSecureId:k});let w;try{w=g(t)?p(t):t}catch{throw new G(I,"Error while parsing connector")}const S=u(w,r,n);if(l(S))throw new W(I,"No matching operation found");I.operationType=S.operation.operationType,I.schema=S.operation.schema?.key;const j=Q(s,I);let O;try{O=d(S.operation,{query:s,body:i,headers:a,path:S.params})}catch{throw new B(I,"Error while parsing operation inputs")}const T=await m({inputs:O,context:I,operation:S.operation,credentials:v,nextCursor:j,logger:c});return await b({block:T})},Q=(e,t)=>{const o=e?.next,r=u(o)&&"list"===t.operationType?a(o):void 0;if(null===r)throw new Y(t,"Invalid cursor.");return r};export{D as ConnectSDKError,x as createBlock,k as executeStepFunction,F as getOperationFromUrl,A as parseOperationInputs,P as parseYamlConnector,J as runConnectorOperation,C as runStepOperation};
|
|
1
|
+
import{StepFunctionsFactory as e,StepFunctionName as t,isCursorEmpty as o,minifyCursor as r,updateCursor as n,AUTHENTICATION_SCHEMA as s,COMPOSITE_ID_LATEST_VERSION as i,expandCursor as a}from"@stackone/core";import{safeEvaluate as c,safeEvaluateRecord as p}from"@stackone/expressions";import{notMissing as u,isNumber as d,isMissing as l,isObject as y,isString as g}from"@stackone/utils";import{HttpClientManager as m,isSuccessStatusCode as b}from"@stackone/transport";import{match as f}from"path-to-regexp";import{parse as h}from"yaml";import{z as _}from"zod";const v=async({block:o,stepFunctionName:r,params:n,buildStepFunction:s=e.build})=>{const i=s({functionName:r}).fn,a=await i({block:o,params:n}),c=r===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}}},k=(e,t,s,i)=>{const a=l(e)?void 0:e.data,c=Object.keys(s).length+1,p=o({cursor:i,ignoreStepIndex:c});if(!y(e)||l(a)||(a?.length??0)<=t)return{result:e,next:u(i)&&!p?r(i):null};const d=i?.remote?.[c]?.pageNumber??1,g=(d-1)*t,m=g+t,b=a.slice(g,m),f=a.length>m||!p,h=n({cursor:i,stepIndex:c,pageNumber:d+1});return{result:{...e,data:b},next:f?r(h):null}},C=async({block:t,buildStepFunction:o=e.build,virtualPaginateResultFn:r=k})=>await I({block:t,buildStepFunction:o,virtualPaginateResultFn:r}),I=async({block:t,buildStepFunction:o=e.build,virtualPaginateResultFn:r=k})=>{const s=t.operation?.steps||{};let i={...t};const a=Object.keys(s),p=((e,t)=>{const o=Number(e.inputs?.page_size);return u(e.inputs?.page_size)&&d(o)&&!Number.isNaN(o)?o:e.operation?.cursor?.pageSize??t})(t,25);let l=!1,g=null;for(const[e,t]of a.entries()){const r=s[t],a=r.stepFunction,p=o({functionName:a.functionName,version:a.version,validateSchemas:!0}).fn;if(r.condition&&!c(r.condition,i)){i=F({block:i,stepId:t,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(l){i=F({block:i,stepId:t,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=i.operation?.cursor.enabled?{...a.params,cursor:{token:i.nextCursor?.remote?.[e]?.providerPageCursor,position:i.nextCursor?.remote?.[e]?.position}}:a.params,d=await p({block:i,params:u});if(!1===d.successful){i=F({block:i,stepId:t,successful:!1,functionOutput:d});(r.ignoreError??!1)||(l=!0,g??=d.output?.statusCode??500)}else{const o=i.operation?.cursor.enabled?n({cursor:i.nextCursor,stepIndex:e,providerPageCursor:d.output?.next,position:d.output?.position}):void 0;i=F({block:{...d.block,nextCursor:o},stepId:t,functionOutput:d})}}const m=t.operation?.result?w(t.operation.result,i):void 0,b=t.operation?.cursor.enabled?r(m,p,s,i.nextCursor):void 0,f=!l,h=f?t.operation?.responses.success.statusCode??200:g??500,_=u(b)&&y(b.result)?{next:b.next,...b.result}:m;return{...i,outputs:_,response:{successful:f,statusCode:h,message:f?void 0:t.operation?.responses?.errors?.[h]?.description??"Error while processing the request"}}},w=(e,t)=>y(e)?p(e,t):c(e,t),F=({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}}}),S=async({inputs:e,context:t,operation:o,credentials:r,nextCursor:n,logger:s,getHttpClient:i=async()=>m.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:r,nextCursor:n,httpClient:await i(),logger:s}),x=({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}),j=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=O(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},E=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},O=(e,t,o)=>{const r=E(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),n=f(E(o))(E(r));if(!1!==n)return{path:e,params:n.params}}},T=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}`)}},N={key:_.string(),label:_.string(),required:_.boolean().optional().default(!1),secret:_.boolean().optional().default(!1),readOnly:_.boolean().optional().default(!1),placeholder:_.string().optional(),description:_.string().optional(),tooltip:_.string().optional()},R=_.discriminatedUnion("type",[_.object({...N,type:_.enum(["text","password"])}),_.object({...N,type:_.literal("select"),options:_.object({value:_.string(),label:_.string()}).array()})]),K=_.object({operationId:_.string(),categories:_.string().array(),operationType:_.enum(["list","get","create","update","delete","custom","unknown"]),schema:_.string().optional(),entrypointUrl:_.string().optional(),entrypointHttpMethod:_.string().optional(),description:_.string(),responses:_.object({statusCode:_.number(),description:_.string()}).array().optional(),inputs:_.object({name:_.string(),type:_.string(),required:_.boolean(),description:_.string(),in:_.string()}).array().optional(),cursor:_.object({enabled:_.boolean(),pageSize:_.number()}).optional(),compositeIdentifiers:_.object({enabled:_.boolean(),version:_.number().optional(),fields:_.object({targetFieldKey:_.string(),remote:_.string().optional(),components:_.string().array()}).array().optional()}).optional(),fieldConfigs:_.object({targetFieldKey:_.string(),alias:_.string().optional(),expression:_.string(),type:_.enum(["string","number","boolean","datetime_string","enum"]),custom:_.boolean().default(!1),hidden:_.boolean().default(!1),enumMapper:_.object({matcher:_.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(_.object({matchExpression:_.string(),value:_.string()}).array())}).optional()}).array().optional(),steps:_.object({stepId:_.string(),description:_.string(),stepFunction:_.object({functionName:_.string(),version:_.string().optional(),parameters:_.record(_.string(),_.unknown())}),condition:_.string().optional(),ignoreError:_.boolean().optional()}).array(),result:_.string().or(_.record(_.string(),_.unknown())).optional()}),U=_.object({StackOne:_.string(),info:_.object({title:_.string(),version:_.string(),key:_.string(),description:_.string().optional()}),baseUrl:_.string(),authentication:_.record(_.string(),_.object({type:_.string(),label:_.string(),authorization:s,environments:_.object({key:_.string(),name:_.string()}).array(),support:_.object({link:_.string(),description:_.string().optional()}),configFields:R.array().optional(),setupFields:R.array().optional(),testOperationsIds:_.string().array().optional()})).array().optional(),operations:K.array().optional()});function q(e){try{const t=h(e),o=U.parse(t),r={title:o.info.title,version:o.info.version,key:o.info.key,description:o.info.description},n=$(o),s={baseUrl:o.baseUrl,authentication:P(n)},i=M(o,s);return r.operations=i,r.authentication=n,u(i)&&(r.categories=z(Object.values(i))),r}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const P=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]=P(a)}else t[o]=r;return t},z=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},$=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},M=(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:T(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)=>(b(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),a=V(o),c=o.inputs||[];return a.enabled&&c?.push({type:"string",name:"page_size",in:"query",required:!1,description:"Number of items to return per page"}),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,cursor:a,compositeIdentifiers:D(o),inputs:c,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||"paginated_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},A=(e,t)=>{if(!e.inputs)return{};const o=L(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},H=e=>{const t={};return e.forEach((e=>{let o;switch(e.type.toLowerCase()){case"string":o=_.string();break;case"number":o=_.number();break;case"boolean":o=_.boolean();break;default:o=_.any()}t[e.name]=e.required?o:o.optional()})),_.object(t)},L=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 _.object({path:H(t).optional(),query:H(o).optional(),body:H(r).optional(),headers:H(n).optional()})},V=e=>{const t="list"===e.operationType,o=e.cursor??{enabled:t,pageSize:25};return{enabled:o.enabled&&t,pageSize:o.pageSize}},D=e=>{if(l(e.compositeIdentifiers)){const t=e.fieldConfigs?.find((e=>"id"===e.targetFieldKey)),o=u(t)?[{targetFieldKey:t.targetFieldKey,remote:"id",components:[{name:t.targetFieldKey,alias:t.alias}]}]:void 0;return{enabled:!0,version:i,fields:o}}const t=[];for(const o of e.compositeIdentifiers?.fields??[]){const r=o.components.map((t=>{const o=e.fieldConfigs?.find((e=>e.targetFieldKey===t));return{name:t,alias:o?.alias}}));t.push({targetFieldKey:o.targetFieldKey,remote:o.remote,components:r})}return{enabled:e.compositeIdentifiers.enabled,version:e.compositeIdentifiers.version,fields:t.length>0?t:void 0}};class G extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,G)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class W extends G{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class B extends G{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class Y extends G{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class J extends G{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const Q=async({account:e,connector:t,category:o,path:r,method:n="get",queryParams:s,body:i,headers:a,logger:c,parseConnector:p=q,getOperationFromUrlFn:u=j,parseOperationInputsFn:d=A,createBlockContextFn:y=x,createBlockFn:m=S,runStepOperationFn:b=C})=>{const f=e.authConfigKey,h=e.environment??"production",_=e.secureId,v=e.projectSecureId,k=e.credentials,I=y({category:o,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:f,environment:h,accountSecureId:_,projectSecureId:v});let w;try{w=g(t)?p(t):t}catch{throw new W(I,"Error while parsing connector")}const F=u(w,r,n);if(l(F))throw new B(I,"No matching operation found");I.operationType=F.operation.operationType,I.schema=F.operation.schema?.key;const E=X(s,I);let O;try{O=d(F.operation,{query:s,body:i,headers:a,path:F.params})}catch{throw new Y(I,"Error while parsing operation inputs")}const T=await m({inputs:O,context:I,operation:F.operation,credentials:k,nextCursor:E,logger:c});return await b({block:T})},X=(e,t)=>{const o=e?.next,r=u(o)&&"list"===t.operationType?a(o):void 0;if(null===r)throw new J(t,"Invalid cursor.");return r};export{G as ConnectSDKError,S as createBlock,v as executeStepFunction,j as getOperationFromUrl,A as parseOperationInputs,q as parseYamlConnector,Q as runConnectorOperation,C 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"),r=require("@stackone/transport"),n=require("path-to-regexp"),s=require("yaml"),i=require("zod");const a=(t,r,n,s)=>{const i=o.isMissing(t)?void 0:t.data,a=Object.keys(n).length+1,c=e.isCursorEmpty({cursor:s,ignoreStepIndex:a});if(!o.isObject(t)||o.isMissing(i)||(i?.length??0)<=r)return{result:t,next:o.notMissing(s)&&!c?e.minifyCursor(s):null};const u=s?.remote?.[a]?.pageNumber??1,p=(u-1)*r,d=p+r,l=i.slice(p,d),y=i.length>d||!c,g=e.updateCursor({cursor:s,stepIndex:a,pageNumber:u+1});return{result:{...t,data:l},next:y?e.minifyCursor(g):null}},c=async({block:t,buildStepFunction:o=e.StepFunctionsFactory.build,virtualPaginateResultFn:r=a})=>await u({block:t,buildStepFunction:o,virtualPaginateResultFn:r}),u=async({block:r,buildStepFunction:n=e.StepFunctionsFactory.build,virtualPaginateResultFn:s=a})=>{const i=r.operation?.steps||{};let c={...r};const u=Object.keys(i),l=((e,t)=>{const r=Number(e.inputs?.page_size);return o.notMissing(e.inputs?.page_size)&&o.isNumber(r)&&!Number.isNaN(r)?r:e.operation?.cursor?.pageSize??t})(r,25);let y=!1,g=null;for(const[o,r]of u.entries()){const s=i[r],a=s.stepFunction,u=n({functionName:a.functionName,version:a.version,validateSchemas:!0}).fn;if(s.condition&&!t.safeEvaluate(s.condition,c)){c=d({block:c,stepId:r,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(y){c=d({block:c,stepId:r,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const p=c.operation?.cursor.enabled?{...a.params,cursor:{token:c.nextCursor?.remote?.[o]?.providerPageCursor,position:c.nextCursor?.remote?.[o]?.position}}:a.params,l=await u({block:c,params:p});if(!1===l.successful){c=d({block:c,stepId:r,successful:!1,functionOutput:l});(s.ignoreError??!1)||(y=!0,g??=l.output?.statusCode??500)}else{const t=c.operation?.cursor.enabled?e.updateCursor({cursor:c.nextCursor,stepIndex:o,providerPageCursor:l.output?.next,position:l.output?.position}):void 0;c=d({block:{...l.block,nextCursor:t},stepId:r,functionOutput:l})}}const b=r.operation?.result?p(r.operation.result,c):void 0,m=r.operation?.cursor.enabled?s(b,l,i,c.nextCursor):void 0,h=!y,z=h?r.operation?.responses.success.statusCode??200:g??500,f=o.notMissing(m)&&o.isObject(m.result)?{next:m.next,...m.result}:b;return{...c,outputs:f,response:{successful:h,statusCode:z,message:h?void 0:r.operation?.responses?.errors?.[z]?.description??"Error while processing the request"}}},p=(e,r)=>o.isObject(e)?t.safeEvaluateRecord(e,r):t.safeEvaluate(e,r),d=({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}}}),l=async({inputs:e,context:t,operation:o,credentials:n,nextCursor:s,logger:i,getHttpClient:a=async()=>r.HttpClientManager.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:n,nextCursor:s,httpClient:await a(),logger:i}),y=({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}),g=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=m(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},b=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},m=(e,t,o)=>{const r=b(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),s=n.match(b(o))(b(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}`)}},z={key:i.z.string(),label:i.z.string(),required:i.z.boolean().optional().default(!1),secret:i.z.boolean().optional().default(!1),readOnly:i.z.boolean().optional().default(!1),placeholder:i.z.string().optional(),description:i.z.string().optional(),tooltip:i.z.string().optional()},f=i.z.discriminatedUnion("type",[i.z.object({...z,type:i.z.enum(["text","password"])}),i.z.object({...z,type:i.z.literal("select"),options:i.z.object({value:i.z.string(),label:i.z.string()}).array()})]),_=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(),cursor:i.z.object({enabled:i.z.boolean(),pageSize:i.z.number()}).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()}),C=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:f.array().optional(),setupFields:f.array().optional(),testOperationsIds:i.z.string().array().optional()})).array().optional(),operations:_.array().optional()});function v(e){try{const t=s.parse(e),r=C.parse(t),n={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description},i=I(r),a={baseUrl:r.baseUrl,authentication:k(i)},c=x(r,a);return n.operations=c,n.authentication=i,o.notMissing(c)&&(n.categories=S(Object.values(c))),n}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const k=e=>{const t={};for(const[o,r]of Object.entries(e))if(r&&"object"==typeof r){const{setupFields:e,configFields:n,support:s,testOperationsIds:i,...a}=r;t[o]=k(a)}else t[o]=r;return t},S=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},I=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},x=(t,o)=>{const n=t.operations?.reduce(((t,n)=>{const s=(e=>e.entrypointUrl&&e.entrypointHttpMethod?`${e.entrypointHttpMethod.toUpperCase()} ${e.entrypointUrl}`:void 0)(n),i=(e=>"list"===e.operationType?`GET /${e.schema}`:`GET /${e.schema}/:id`)(n),a=(e=>"list"===e.operationType?`/${e.schema}`:`/${e.schema}/:id`)(n),c=(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})(n),u=O(n),p=n.inputs||[];return u.enabled&&p?.push({type:"string",name:"page_size",in:"query",required:!1,description:"Number of items to return per page"}),t[s??i]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??a,entrypointHttpMethod:n.entrypointHttpMethod??"get",responses:c,cursor:u,compositeIdentifiers:{enabled:!1,version:e.COMPOSITE_ID_LATEST_VERSION},inputs:p,steps:n.steps.reduce(((e,t)=>(e[t.stepId]={id:t.stepId,description:t.description,condition:t.condition,ignoreError:t.ignoreError,stepFunction:{functionName:t.stepFunction.functionName,version:t.stepFunction.version,params:{..."request"===t.stepFunction.functionName||"paginated_request"===t.stepFunction.functionName?o:{},..."map_fields"===t.stepFunction.functionName||"typecast"===t.stepFunction.functionName?{fields:n.fieldConfigs}:{},...t.stepFunction.parameters}}},e)),{}),result:n.result},t}),{});return n},E=(e,t)=>{if(!e.inputs)return{};const o=w(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},F=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:F(t).optional(),query:F(o).optional(),body:F(r).optional(),headers:F(n).optional()})},O=e=>{const t="list"===e.operationType,o=e.cursor??{enabled:t,pageSize:25};return{enabled:o.enabled&&t,pageSize:o.pageSize}};class T extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,T)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class N extends T{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class j extends T{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class R extends T{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class q extends T{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const M=(t,r)=>{const n=t?.next,s=o.notMissing(n)&&"list"===r.operationType?e.expandCursor(n):void 0;if(null===s)throw new q(r,"Invalid cursor.");return s};exports.ConnectSDKError=T,exports.createBlock=l,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=g,exports.parseOperationInputs=E,exports.parseYamlConnector=v,exports.runConnectorOperation=async({account:e,connector:t,category:r,path:n,method:s="get",queryParams:i,body:a,headers:u,logger:p,parseConnector:d=v,getOperationFromUrlFn:b=g,parseOperationInputsFn:m=E,createBlockContextFn:h=y,createBlockFn:z=l,runStepOperationFn:f=c})=>{const _=e.authConfigKey,C=e.environment??"production",k=e.secureId,S=e.projectSecureId,I=e.credentials,x=h({category:r,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:_,environment:C,accountSecureId:k,projectSecureId:S});let F;try{F=o.isString(t)?d(t):t}catch{throw new N(x,"Error while parsing connector")}const w=b(F,n,s);if(o.isMissing(w))throw new j(x,"No matching operation found");x.operationType=w.operation.operationType,x.schema=w.operation.schema?.key;const O=M(i,x);let T;try{T=m(w.operation,{query:i,body:a,headers:u,path:w.params})}catch{throw new R(x,"Error while parsing operation inputs")}const q=await z({inputs:T,context:x,operation:w.operation,credentials:I,nextCursor:O,logger:p});return await f({block:q})},exports.runStepOperation=c;
|
|
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=(t,r,n,s)=>{const i=o.isMissing(t)?void 0:t.data,a=Object.keys(n).length+1,c=e.isCursorEmpty({cursor:s,ignoreStepIndex:a});if(!o.isObject(t)||o.isMissing(i)||(i?.length??0)<=r)return{result:t,next:o.notMissing(s)&&!c?e.minifyCursor(s):null};const p=s?.remote?.[a]?.pageNumber??1,u=(p-1)*r,d=u+r,l=i.slice(u,d),y=i.length>d||!c,g=e.updateCursor({cursor:s,stepIndex:a,pageNumber:p+1});return{result:{...t,data:l},next:y?e.minifyCursor(g):null}},c=async({block:t,buildStepFunction:o=e.StepFunctionsFactory.build,virtualPaginateResultFn:r=a})=>await p({block:t,buildStepFunction:o,virtualPaginateResultFn:r}),p=async({block:r,buildStepFunction:n=e.StepFunctionsFactory.build,virtualPaginateResultFn:s=a})=>{const i=r.operation?.steps||{};let c={...r};const p=Object.keys(i),l=((e,t)=>{const r=Number(e.inputs?.page_size);return o.notMissing(e.inputs?.page_size)&&o.isNumber(r)&&!Number.isNaN(r)?r:e.operation?.cursor?.pageSize??t})(r,25);let y=!1,g=null;for(const[o,r]of p.entries()){const s=i[r],a=s.stepFunction,p=n({functionName:a.functionName,version:a.version,validateSchemas:!0}).fn;if(s.condition&&!t.safeEvaluate(s.condition,c)){c=d({block:c,stepId:r,successful:!0,skipped:!0,message:"Step skipped due to condition not met."});continue}if(y){c=d({block:c,stepId:r,successful:!1,skipped:!0,message:"Step skipped due to previous error."});continue}const u=c.operation?.cursor.enabled?{...a.params,cursor:{token:c.nextCursor?.remote?.[o]?.providerPageCursor,position:c.nextCursor?.remote?.[o]?.position}}:a.params,l=await p({block:c,params:u});if(!1===l.successful){c=d({block:c,stepId:r,successful:!1,functionOutput:l});(s.ignoreError??!1)||(y=!0,g??=l.output?.statusCode??500)}else{const t=c.operation?.cursor.enabled?e.updateCursor({cursor:c.nextCursor,stepIndex:o,providerPageCursor:l.output?.next,position:l.output?.position}):void 0;c=d({block:{...l.block,nextCursor:t},stepId:r,functionOutput:l})}}const m=r.operation?.result?u(r.operation.result,c):void 0,b=r.operation?.cursor.enabled?s(m,l,i,c.nextCursor):void 0,f=!y,h=f?r.operation?.responses.success.statusCode??200:g??500,z=o.notMissing(b)&&o.isObject(b.result)?{next:b.next,...b.result}:m;return{...c,outputs:z,response:{successful:f,statusCode:h,message:f?void 0:r.operation?.responses?.errors?.[h]?.description??"Error while processing the request"}}},u=(e,r)=>o.isObject(e)?t.safeEvaluateRecord(e,r):t.safeEvaluate(e,r),d=({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}}}),l=async({inputs:e,context:t,operation:o,credentials:n,nextCursor:s,logger:i,getHttpClient:a=async()=>r.HttpClientManager.getInstance()})=>({inputs:e,fieldConfigs:[],context:t,operation:o,credentials:n,nextCursor:s,httpClient:await a(),logger:i}),y=({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}),g=(e,t,o)=>{const r=o.toUpperCase();if(!e.operations)return;const n=Object.keys(e.operations),s=b(t,r,n);return s?{operation:e.operations?.[s.path],params:s.params}:void 0},m=e=>{const t=e.startsWith("/")?e.slice(1):e;return t.endsWith("/")?t.slice(0,-1):t},b=(e,t,o)=>{const r=m(e);for(const e of o)if(e.startsWith(t)){const o=e.replace(`${t} `,"").trim(),s=n.match(m(o))(m(r));if(!1!==s)return{path:e,params:s.params}}},f=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}`)}},h={key:i.z.string(),label:i.z.string(),required:i.z.boolean().optional().default(!1),secret:i.z.boolean().optional().default(!1),readOnly:i.z.boolean().optional().default(!1),placeholder:i.z.string().optional(),description:i.z.string().optional(),tooltip:i.z.string().optional()},z=i.z.discriminatedUnion("type",[i.z.object({...h,type:i.z.enum(["text","password"])}),i.z.object({...h,type:i.z.literal("select"),options:i.z.object({value:i.z.string(),label:i.z.string()}).array()})]),_=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(),cursor:i.z.object({enabled:i.z.boolean(),pageSize:i.z.number()}).optional(),compositeIdentifiers:i.z.object({enabled:i.z.boolean(),version:i.z.number().optional(),fields:i.z.object({targetFieldKey:i.z.string(),remote:i.z.string().optional(),components:i.z.string().array()}).array().optional()}).optional(),fieldConfigs:i.z.object({targetFieldKey:i.z.string(),alias:i.z.string().optional(),expression:i.z.string(),type:i.z.enum(["string","number","boolean","datetime_string","enum"]),custom:i.z.boolean().default(!1),hidden:i.z.boolean().default(!1),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()}),C=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:z.array().optional(),setupFields:z.array().optional(),testOperationsIds:i.z.string().array().optional()})).array().optional(),operations:_.array().optional()});function v(e){try{const t=s.parse(e),r=C.parse(t),n={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description},i=S(r),a={baseUrl:r.baseUrl,authentication:k(i)},c=F(r,a);return n.operations=c,n.authentication=i,o.notMissing(c)&&(n.categories=I(Object.values(c))),n}catch(e){throw new Error(`Error parsing YAML file: ${e.message}`)}}const k=e=>{const t={};for(const[o,r]of Object.entries(e))if(r&&"object"==typeof r){const{setupFields:e,configFields:n,support:s,testOperationsIds:i,...a}=r;t[o]=k(a)}else t[o]=r;return t},I=e=>{const t=e.reduce(((e,t)=>{for(const o of t.categories)e.add(o);return e}),new Set);return Array.from(t)},S=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},F=(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:f(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),c=O(o),p=o.inputs||[];return c.enabled&&p?.push({type:"string",name:"page_size",in:"query",required:!1,description:"Number of items to return per page"}),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,cursor:c,compositeIdentifiers:j(o),inputs:p,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||"paginated_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=w(e.inputs).parse(t);return{...o.headers??{},...o.query??{},...o.path??{},...o.body??{}}},E=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:E(t).optional(),query:E(o).optional(),body:E(r).optional(),headers:E(n).optional()})},O=e=>{const t="list"===e.operationType,o=e.cursor??{enabled:t,pageSize:25};return{enabled:o.enabled&&t,pageSize:o.pageSize}},j=t=>{if(o.isMissing(t.compositeIdentifiers)){const r=t.fieldConfigs?.find((e=>"id"===e.targetFieldKey)),n=o.notMissing(r)?[{targetFieldKey:r.targetFieldKey,remote:"id",components:[{name:r.targetFieldKey,alias:r.alias}]}]:void 0;return{enabled:!0,version:e.COMPOSITE_ID_LATEST_VERSION,fields:n}}const r=[];for(const e of t.compositeIdentifiers?.fields??[]){const o=e.components.map((e=>{const o=t.fieldConfigs?.find((t=>t.targetFieldKey===e));return{name:e,alias:o?.alias}}));r.push({targetFieldKey:e.targetFieldKey,remote:e.remote,components:o})}return{enabled:t.compositeIdentifiers.enabled,version:t.compositeIdentifiers.version,fields:r.length>0?r:void 0}};class T extends Error{constructor(e,t,o){super(o),this.name="ConnectSDKError",this.errorType=e,this.context=t,Error.captureStackTrace&&Error.captureStackTrace(this,T)}toString(){return`${this.name} [${this.errorType}]: ${this.message}`}}class N extends T{constructor(e,t){super("CONNECTOR_PARSE_ERROR",e,t),this.name="ConnectorParseError"}}class M extends T{constructor(e,t){super("MISSING_OPERATION_ERROR",e,t),this.name="MissingOperationError"}}class R extends T{constructor(e,t){super("INVALID_OPERATION_INPUTS_ERROR",e,t),this.name="InvalidOperationInputsError"}}class q extends T{constructor(e,t){super("INVALID_CURSOR_ERROR",e,t),this.name="InvalidCursorError"}}const K=(t,r)=>{const n=t?.next,s=o.notMissing(n)&&"list"===r.operationType?e.expandCursor(n):void 0;if(null===s)throw new q(r,"Invalid cursor.");return s};exports.ConnectSDKError=T,exports.createBlock=l,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=g,exports.parseOperationInputs=x,exports.parseYamlConnector=v,exports.runConnectorOperation=async({account:e,connector:t,category:r,path:n,method:s="get",queryParams:i,body:a,headers:p,logger:u,parseConnector:d=v,getOperationFromUrlFn:m=g,parseOperationInputsFn:b=x,createBlockContextFn:f=y,createBlockFn:h=l,runStepOperationFn:z=c})=>{const _=e.authConfigKey,C=e.environment??"production",k=e.secureId,I=e.projectSecureId,S=e.credentials,F=f({category:r,connectorKey:e.providerKey,connectorVersion:e.providerVersion,authConfigKey:_,environment:C,accountSecureId:k,projectSecureId:I});let E;try{E=o.isString(t)?d(t):t}catch{throw new N(F,"Error while parsing connector")}const w=m(E,n,s);if(o.isMissing(w))throw new M(F,"No matching operation found");F.operationType=w.operation.operationType,F.schema=w.operation.schema?.key;const O=K(i,F);let j;try{j=b(w.operation,{query:i,body:a,headers:p,path:w.params})}catch{throw new R(F,"Error while parsing operation inputs")}const T=await h({inputs:j,context:F,operation:w.operation,credentials:S,nextCursor:O,logger:u});return await z({block:T})},exports.runStepOperation=c;
|
|
@@ -46,11 +46,46 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
46
46
|
enabled: boolean;
|
|
47
47
|
pageSize: number;
|
|
48
48
|
}>>;
|
|
49
|
+
compositeIdentifiers: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
enabled: z.ZodBoolean;
|
|
51
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
53
|
+
targetFieldKey: z.ZodString;
|
|
54
|
+
remote: z.ZodOptional<z.ZodString>;
|
|
55
|
+
components: z.ZodArray<z.ZodString, "many">;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
targetFieldKey: string;
|
|
58
|
+
components: string[];
|
|
59
|
+
remote?: string | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
targetFieldKey: string;
|
|
62
|
+
components: string[];
|
|
63
|
+
remote?: string | undefined;
|
|
64
|
+
}>, "many">>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
version?: number | undefined;
|
|
68
|
+
fields?: {
|
|
69
|
+
targetFieldKey: string;
|
|
70
|
+
components: string[];
|
|
71
|
+
remote?: string | undefined;
|
|
72
|
+
}[] | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
version?: number | undefined;
|
|
76
|
+
fields?: {
|
|
77
|
+
targetFieldKey: string;
|
|
78
|
+
components: string[];
|
|
79
|
+
remote?: string | undefined;
|
|
80
|
+
}[] | undefined;
|
|
81
|
+
}>>;
|
|
49
82
|
fieldConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
50
83
|
targetFieldKey: z.ZodString;
|
|
84
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
51
85
|
expression: z.ZodString;
|
|
52
86
|
type: z.ZodEnum<["string", "number", "boolean", "datetime_string", "enum"]>;
|
|
53
|
-
|
|
87
|
+
custom: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
+
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
54
89
|
enumMapper: z.ZodOptional<z.ZodObject<{
|
|
55
90
|
matcher: z.ZodUnion<[z.ZodEnum<["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"]>, z.ZodArray<z.ZodObject<{
|
|
56
91
|
matchExpression: z.ZodString;
|
|
@@ -75,9 +110,11 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
75
110
|
}>>;
|
|
76
111
|
}, "strip", z.ZodTypeAny, {
|
|
77
112
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
113
|
+
custom: boolean;
|
|
78
114
|
targetFieldKey: string;
|
|
79
115
|
expression: string;
|
|
80
|
-
|
|
116
|
+
hidden: boolean;
|
|
117
|
+
alias?: string | undefined;
|
|
81
118
|
enumMapper?: {
|
|
82
119
|
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" | {
|
|
83
120
|
value: string;
|
|
@@ -88,7 +125,9 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
88
125
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
89
126
|
targetFieldKey: string;
|
|
90
127
|
expression: string;
|
|
91
|
-
|
|
128
|
+
custom?: boolean | undefined;
|
|
129
|
+
alias?: string | undefined;
|
|
130
|
+
hidden?: boolean | undefined;
|
|
92
131
|
enumMapper?: {
|
|
93
132
|
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" | {
|
|
94
133
|
value: string;
|
|
@@ -170,11 +209,22 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
170
209
|
enabled: boolean;
|
|
171
210
|
pageSize: number;
|
|
172
211
|
} | undefined;
|
|
212
|
+
compositeIdentifiers?: {
|
|
213
|
+
enabled: boolean;
|
|
214
|
+
version?: number | undefined;
|
|
215
|
+
fields?: {
|
|
216
|
+
targetFieldKey: string;
|
|
217
|
+
components: string[];
|
|
218
|
+
remote?: string | undefined;
|
|
219
|
+
}[] | undefined;
|
|
220
|
+
} | undefined;
|
|
173
221
|
fieldConfigs?: {
|
|
174
222
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
223
|
+
custom: boolean;
|
|
175
224
|
targetFieldKey: string;
|
|
176
225
|
expression: string;
|
|
177
|
-
|
|
226
|
+
hidden: boolean;
|
|
227
|
+
alias?: string | undefined;
|
|
178
228
|
enumMapper?: {
|
|
179
229
|
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" | {
|
|
180
230
|
value: string;
|
|
@@ -217,11 +267,22 @@ export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
|
217
267
|
enabled: boolean;
|
|
218
268
|
pageSize: number;
|
|
219
269
|
} | undefined;
|
|
270
|
+
compositeIdentifiers?: {
|
|
271
|
+
enabled: boolean;
|
|
272
|
+
version?: number | undefined;
|
|
273
|
+
fields?: {
|
|
274
|
+
targetFieldKey: string;
|
|
275
|
+
components: string[];
|
|
276
|
+
remote?: string | undefined;
|
|
277
|
+
}[] | undefined;
|
|
278
|
+
} | undefined;
|
|
220
279
|
fieldConfigs?: {
|
|
221
280
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
222
281
|
targetFieldKey: string;
|
|
223
282
|
expression: string;
|
|
224
|
-
|
|
283
|
+
custom?: boolean | undefined;
|
|
284
|
+
alias?: string | undefined;
|
|
285
|
+
hidden?: boolean | undefined;
|
|
225
286
|
enumMapper?: {
|
|
226
287
|
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" | {
|
|
227
288
|
value: string;
|
|
@@ -647,11 +708,46 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
647
708
|
enabled: boolean;
|
|
648
709
|
pageSize: number;
|
|
649
710
|
}>>;
|
|
711
|
+
compositeIdentifiers: z.ZodOptional<z.ZodObject<{
|
|
712
|
+
enabled: z.ZodBoolean;
|
|
713
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
714
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
715
|
+
targetFieldKey: z.ZodString;
|
|
716
|
+
remote: z.ZodOptional<z.ZodString>;
|
|
717
|
+
components: z.ZodArray<z.ZodString, "many">;
|
|
718
|
+
}, "strip", z.ZodTypeAny, {
|
|
719
|
+
targetFieldKey: string;
|
|
720
|
+
components: string[];
|
|
721
|
+
remote?: string | undefined;
|
|
722
|
+
}, {
|
|
723
|
+
targetFieldKey: string;
|
|
724
|
+
components: string[];
|
|
725
|
+
remote?: string | undefined;
|
|
726
|
+
}>, "many">>;
|
|
727
|
+
}, "strip", z.ZodTypeAny, {
|
|
728
|
+
enabled: boolean;
|
|
729
|
+
version?: number | undefined;
|
|
730
|
+
fields?: {
|
|
731
|
+
targetFieldKey: string;
|
|
732
|
+
components: string[];
|
|
733
|
+
remote?: string | undefined;
|
|
734
|
+
}[] | undefined;
|
|
735
|
+
}, {
|
|
736
|
+
enabled: boolean;
|
|
737
|
+
version?: number | undefined;
|
|
738
|
+
fields?: {
|
|
739
|
+
targetFieldKey: string;
|
|
740
|
+
components: string[];
|
|
741
|
+
remote?: string | undefined;
|
|
742
|
+
}[] | undefined;
|
|
743
|
+
}>>;
|
|
650
744
|
fieldConfigs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
651
745
|
targetFieldKey: z.ZodString;
|
|
746
|
+
alias: z.ZodOptional<z.ZodString>;
|
|
652
747
|
expression: z.ZodString;
|
|
653
748
|
type: z.ZodEnum<["string", "number", "boolean", "datetime_string", "enum"]>;
|
|
654
|
-
|
|
749
|
+
custom: z.ZodDefault<z.ZodBoolean>;
|
|
750
|
+
hidden: z.ZodDefault<z.ZodBoolean>;
|
|
655
751
|
enumMapper: z.ZodOptional<z.ZodObject<{
|
|
656
752
|
matcher: z.ZodUnion<[z.ZodEnum<["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"]>, z.ZodArray<z.ZodObject<{
|
|
657
753
|
matchExpression: z.ZodString;
|
|
@@ -676,9 +772,11 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
676
772
|
}>>;
|
|
677
773
|
}, "strip", z.ZodTypeAny, {
|
|
678
774
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
775
|
+
custom: boolean;
|
|
679
776
|
targetFieldKey: string;
|
|
680
777
|
expression: string;
|
|
681
|
-
|
|
778
|
+
hidden: boolean;
|
|
779
|
+
alias?: string | undefined;
|
|
682
780
|
enumMapper?: {
|
|
683
781
|
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" | {
|
|
684
782
|
value: string;
|
|
@@ -689,7 +787,9 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
689
787
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
690
788
|
targetFieldKey: string;
|
|
691
789
|
expression: string;
|
|
692
|
-
|
|
790
|
+
custom?: boolean | undefined;
|
|
791
|
+
alias?: string | undefined;
|
|
792
|
+
hidden?: boolean | undefined;
|
|
693
793
|
enumMapper?: {
|
|
694
794
|
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" | {
|
|
695
795
|
value: string;
|
|
@@ -771,11 +871,22 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
771
871
|
enabled: boolean;
|
|
772
872
|
pageSize: number;
|
|
773
873
|
} | undefined;
|
|
874
|
+
compositeIdentifiers?: {
|
|
875
|
+
enabled: boolean;
|
|
876
|
+
version?: number | undefined;
|
|
877
|
+
fields?: {
|
|
878
|
+
targetFieldKey: string;
|
|
879
|
+
components: string[];
|
|
880
|
+
remote?: string | undefined;
|
|
881
|
+
}[] | undefined;
|
|
882
|
+
} | undefined;
|
|
774
883
|
fieldConfigs?: {
|
|
775
884
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
885
|
+
custom: boolean;
|
|
776
886
|
targetFieldKey: string;
|
|
777
887
|
expression: string;
|
|
778
|
-
|
|
888
|
+
hidden: boolean;
|
|
889
|
+
alias?: string | undefined;
|
|
779
890
|
enumMapper?: {
|
|
780
891
|
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" | {
|
|
781
892
|
value: string;
|
|
@@ -818,11 +929,22 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
818
929
|
enabled: boolean;
|
|
819
930
|
pageSize: number;
|
|
820
931
|
} | undefined;
|
|
932
|
+
compositeIdentifiers?: {
|
|
933
|
+
enabled: boolean;
|
|
934
|
+
version?: number | undefined;
|
|
935
|
+
fields?: {
|
|
936
|
+
targetFieldKey: string;
|
|
937
|
+
components: string[];
|
|
938
|
+
remote?: string | undefined;
|
|
939
|
+
}[] | undefined;
|
|
940
|
+
} | undefined;
|
|
821
941
|
fieldConfigs?: {
|
|
822
942
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
823
943
|
targetFieldKey: string;
|
|
824
944
|
expression: string;
|
|
825
|
-
|
|
945
|
+
custom?: boolean | undefined;
|
|
946
|
+
alias?: string | undefined;
|
|
947
|
+
hidden?: boolean | undefined;
|
|
826
948
|
enumMapper?: {
|
|
827
949
|
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" | {
|
|
828
950
|
value: string;
|
|
@@ -947,11 +1069,22 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
947
1069
|
enabled: boolean;
|
|
948
1070
|
pageSize: number;
|
|
949
1071
|
} | undefined;
|
|
1072
|
+
compositeIdentifiers?: {
|
|
1073
|
+
enabled: boolean;
|
|
1074
|
+
version?: number | undefined;
|
|
1075
|
+
fields?: {
|
|
1076
|
+
targetFieldKey: string;
|
|
1077
|
+
components: string[];
|
|
1078
|
+
remote?: string | undefined;
|
|
1079
|
+
}[] | undefined;
|
|
1080
|
+
} | undefined;
|
|
950
1081
|
fieldConfigs?: {
|
|
951
1082
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
1083
|
+
custom: boolean;
|
|
952
1084
|
targetFieldKey: string;
|
|
953
1085
|
expression: string;
|
|
954
|
-
|
|
1086
|
+
hidden: boolean;
|
|
1087
|
+
alias?: string | undefined;
|
|
955
1088
|
enumMapper?: {
|
|
956
1089
|
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" | {
|
|
957
1090
|
value: string;
|
|
@@ -1076,11 +1209,22 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
1076
1209
|
enabled: boolean;
|
|
1077
1210
|
pageSize: number;
|
|
1078
1211
|
} | undefined;
|
|
1212
|
+
compositeIdentifiers?: {
|
|
1213
|
+
enabled: boolean;
|
|
1214
|
+
version?: number | undefined;
|
|
1215
|
+
fields?: {
|
|
1216
|
+
targetFieldKey: string;
|
|
1217
|
+
components: string[];
|
|
1218
|
+
remote?: string | undefined;
|
|
1219
|
+
}[] | undefined;
|
|
1220
|
+
} | undefined;
|
|
1079
1221
|
fieldConfigs?: {
|
|
1080
1222
|
type: "string" | "number" | "boolean" | "datetime_string" | "enum";
|
|
1081
1223
|
targetFieldKey: string;
|
|
1082
1224
|
expression: string;
|
|
1083
|
-
|
|
1225
|
+
custom?: boolean | undefined;
|
|
1226
|
+
alias?: string | undefined;
|
|
1227
|
+
hidden?: boolean | undefined;
|
|
1084
1228
|
enumMapper?: {
|
|
1085
1229
|
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" | {
|
|
1086
1230
|
value: string;
|