@stackone/core 1.21.0 → 1.23.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{evaluate as e}from"@stackone/expressions";import{isDate as r,isString as t,isBoolean as s,isNumber as n,isObject as i,isMissing as o,notMissing as u}from"@stackone/utils";import*as l from"date-fns";var a;!function(e){e.TYPECAST="typecast",e.MAP_FIELDS="map_fields",e.REQUEST="request",e.GROUP_RESULTS="group_results"}(a||(a={}));const c=async({block:e})=>{const r=e?.fieldConfigs,t=[],s=e.steps;if(!r||"disabled"===e?.debug?.custom_mappings||!s)return{block:e,successfull:!0};let n;if(Array.isArray(e.result)){const i=e.result.length;n=e.result.map(((e,n)=>{const o=d(s,i,n),u=y(e,r,o);return t.push(...u.errors||[]),u.record}))}else{const i=y(e.result,r,s);n=i.record,t.push(...i.errors||[])}return{block:{...e,result:n},successfull:!0,errors:Object.keys(t).length>0?t:void 0}},d=(e,r,t)=>Object.entries(e).reduce(((e,[s,n])=>{const i=n?.output?.data;return Array.isArray(i)&&i.length===r?e[s]={output:{data:i[t]}}:e[s]=n,e}),{}),y=(e,r,t)=>{if(!e||!t)return{record:e};const s={unified:{...e},..."object"==typeof t?t:{}},n={},i=[],o={...e};for(const t of r){const{error:r,value:u}=f(s,e.id,t);r?i.push(r):t.isUnified?o[t.targetFieldKey]=u:n[t.targetFieldKey]=u}return{record:{...o,unified_custom_fields:Object.keys(n).length>0?n:void 0},errors:i.length>0?i:void 0}},f=(r,t,s)=>{const{expression:n,targetFieldKey:i}=s;if(!n)return{error:{message:"Expression is empty",id:t,targetField:i}};let o;try{o=e(n,r)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:i}}}return void 0===o?{error:{message:"Expression returned no value",id:t,targetField:i}}:{value:o}},m="yyyy-MM-dd",g=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],p=({value:e})=>{const r=l.parseISO(e);if(l.isValid(r))return r;const t=new Date;for(const r of g){const s=l.parse(e,r,t);if(l.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},v=({value:e,format:s=m})=>{const n=(({value:e,format:s=m})=>{if(r(e))return e;if(!t(e))return null;try{const r=l.parse(e,s,new Date);return l.isValid(r)?r:p({value:e})}catch(e){return null}})({value:e,format:s});return n?n.toISOString():null};var M;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(M||(M={}));const S=({value:e,type:u,format:l})=>{if(o(e))return null;switch(u){case M.String:return(({value:e})=>t(e)?e:r(e)?e.toISOString():i(e)?JSON.stringify(e):String(e))({value:e});case M.Number:return(({value:e})=>{if(n(e))return e;if(r(e))return null;const t=Number(e);return isNaN(t)?null:t})({value:e});case M.Boolean:return(({value:e})=>s(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case M.DateTimeString:return v({value:e,format:l});default:return e}},k=async({block:e})=>{const r=e?.fieldConfigs;if(!r||"disabled"===e?.debug?.custom_mappings)return{block:e,successfull:!0};let t;return t=Array.isArray(e.result)?e.result.map((e=>b(e,r))):b(e.result,r),{block:{...e,result:t},successfull:!0}},b=(e,r)=>{const t={...e};return r.forEach((r=>{const{targetFieldKey:s,type:n}=r;(e=>Object.values(M).includes(e))(n)&&(r.isUnified&&u(t[s])?t[s]=S({value:e[s],type:n}):t.unified_custom_fields&&u(t.unified_custom_fields?.[s])&&(t.unified_custom_fields[s]=S({value:e.unified_custom_fields?.[s],type:n})))})),{...t}},_={build({functionName:e}){switch(e){case a.TYPECAST:return k;case a.MAP_FIELDS:return c;default:throw new Error(`Unknown step function: ${e}`)}}},h={hris:{title:"HRIS",key:"hris",description:"Human Resource Information System"},crm:{title:"CRM",key:"crm",description:"Customer Relationship Management"},ats:{title:"ATS",key:"ats",description:"Applicant Tracking System"},lms:{title:"LMS",key:"lms",description:"Learning Management System"},marketing:{title:"Marketing",key:"marketing",description:"Marketing"},filestorage:{title:"File Storage",key:"filestorage",description:"File Storage"}},A=e=>h[e.toLowerCase()]??null,E=e=>!!h[e.toLowerCase()];export{a as StepFunctionName,_ as StepFunctionsFactory,A as getCategoryDetails,E as isValidCategory};
1
+ import{notMissing as e,isDate as t,isString as r,isBoolean as s,isNumber as n,isObject as o,isMissing as i}from"@stackone/utils";import{z as a}from"zod";import{evaluate as u,safeEvaluateRecord as c}from"@stackone/expressions";import{RequestParameterLocations as l,HttpMethods as d,RequestClientFactory as p,parseRequestParameters as y,createAuthorizationHeaders as f}from"@stackone/transport";import*as m from"date-fns";const g=a.object({stepsDataToGroup:a.array(a.string()),isSingleRecord:a.boolean().optional()}),b=a.object({data:a.unknown()}),h=(e,t,r)=>Object.entries(e).reduce(((e,[s,n])=>{const o=n?.output?.data;return Array.isArray(o)&&o.length===t?e[s]={output:{data:o[r]}}:e[s]=n,e}),{}),v=(e,t,r)=>{if(!e||!r)return{record:e};const s={unified:{...e},..."object"==typeof r?r:{}},n={},o=[],i={...e};for(const r of t){const{error:t,value:a}=k(s,e.id,r);t?o.push(t):r.isUnified?i[r.targetFieldKey]=a:n[r.targetFieldKey]=a}return{record:{...i,unified_custom_fields:Object.keys(n).length>0?n:void 0},errors:o.length>0?o:void 0}},k=(e,t,r)=>{const{expression:s,targetFieldKey:n}=r;if(!s)return{error:{message:"Expression is empty",id:t,targetField:n}};let o;try{o=u(s,e)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:n}}}return void 0===o?{error:{message:"Expression returned no value",id:t,targetField:n}}:{value:o}},S=a.object({fields:a.object({expression:a.string(),targetFieldKey:a.string(),type:a.string(),isUnified:a.boolean().optional()}).array(),dataSource:a.string()}),_=a.object({data:a.unknown()}),F=(e,t)=>{if(!t)return;const r={},s=[],n={};for(const o of e){const{error:e,value:i}=M(t,t?.id,o);e?s.push(e):o.isUnified?n[o.targetFieldKey]=i:r[o.targetFieldKey]=i}return{record:{...n,unified_custom_fields:Object.keys(r).length>0?r:void 0},errors:s.length>0?s:void 0}},M=(e,t,r)=>{const{expression:s,targetFieldKey:n}=r;if(!s)return{error:{message:"Expression is empty",id:t,targetField:n}};let o;try{o=u(s,e)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:n}}}return void 0===o?{error:{message:"Expression returned no value",id:t,targetField:n}}:{value:o}},j=a.object({type:a.literal("basic"),username:a.string(),password:a.string(),encoding:a.string().optional()}),A=a.object({type:a.literal("bearer"),token:a.string()}),w=a.discriminatedUnion("type",[j,A]),x=a.object({baseUrl:a.string(),url:a.string(),method:a.enum(d),response:a.object({collection:a.boolean().optional(),indexField:a.string().optional(),dataKey:a.string().optional()}).optional(),args:a.object({name:a.string(),value:a.unknown(),in:a.enum(l),condition:a.boolean().optional()}).array().optional()}),T=a.object({data:a.unknown(),raw:a.unknown().optional()}),E=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce(((e,r)=>{const s=t.indexField;return s&&r[s]&&(e[r[s]]=r),e}),{});if(!t?.collection&&t?.indexField){const r=t.indexField;return r&&e[r]?{[e[r]]:e}:e}return e},O=a.object({fields:a.object({targetFieldKey:a.string(),type:a.string(),isUnified:a.boolean().optional()}).array().optional(),dataSource:a.string()}),U=a.object({data:a.unknown()}),K="yyyy-MM-dd",C=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],R=({value:e})=>{const t=m.parseISO(e);if(m.isValid(t))return t;const r=new Date;for(const t of C){const s=m.parse(e,t,r);if(m.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},D=({value:e,format:s=K})=>{const n=(({value:e,format:s=K})=>{if(t(e))return e;if(!r(e))return null;try{const t=m.parse(e,s,new Date);return m.isValid(t)?t:R({value:e})}catch(e){return null}})({value:e,format:s});return n?n.toISOString():null};var I;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(I||(I={}));const P=({value:e,type:a,format:u})=>{if(i(e))return null;switch(a){case I.String:return(({value:e})=>r(e)?e:t(e)?e.toISOString():o(e)?JSON.stringify(e):String(e))({value:e});case I.Number:return(({value:e})=>{if(n(e))return e;if(t(e))return null;const r=Number(e);return isNaN(r)?null:r})({value:e});case I.Boolean:return(({value:e})=>s(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case I.DateTimeString:return D({value:e,format:u});default:return e}},L=e=>Object.values(I).includes(e),N=(t,r)=>{const s={...t};return r.forEach((r=>{const{targetFieldKey:n,type:o}=r;L(o)&&(r.isUnified&&e(s[n])?s[n]=P({value:t[n],type:o}):s.unified_custom_fields&&e(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=P({value:t.unified_custom_fields?.[n],type:o})))})),{...s}},$=(t,r)=>{const s={...t};return r.forEach((r=>{const{targetFieldKey:n,type:o}=r;L(o)&&(r.isUnified&&e(s[n])?s[n]=P({value:t[n],type:o}):s.unified_custom_fields&&e(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=P({value:t.unified_custom_fields?.[n],type:o})))})),{...s}};var q;!function(e){e.TYPECAST="typecast",e.MAP_FIELDS="map_fields",e.GROUP_DATA="group_data",e.REQUEST="request"}(q||(q={}));const G={[q.TYPECAST]:{v1:{fn:async({block:e})=>{const t=e?.fieldConfigs;if(!t||"disabled"===e?.debug?.custom_mappings)return{block:e,successful:!0};let r;return r=Array.isArray(e.result)?e.result.map((e=>N(e,t))):N(e.result,t),{block:{...e,result:r},successful:!0}}},v2:{fn:async({block:e,params:t})=>{const{fields:r,dataSource:s}=O.parse(t),n=u(s,e);if(!r||"disabled"===e?.debug?.custom_mappings)return{block:e,successful:!0};let o;return o=Array.isArray(n)?n.map((e=>$(e,r))):$(n,r),{block:{...e},successful:!0,output:{data:o}}},inputSchema:O,outputSchema:U}},[q.MAP_FIELDS]:{v1:{fn:async({block:e})=>{const t=e?.fieldConfigs,r=[],s=e.steps;if(!t||"disabled"===e?.debug?.custom_mappings||!s)return{block:e,successful:!0};let n;if(Array.isArray(e.result)){const o=e.result.length;n=e.result.map(((e,n)=>{const i=h(s,o,n),a=v(e,t,i);return r.push(...a.errors||[]),a.record}))}else{const o=v(e.result,t,s);n=o.record,r.push(...o.errors||[])}return{block:{...e,result:n},successful:!0,errors:Object.keys(r).length>0?r:void 0}}},v2:{fn:async({block:e,params:t})=>{const r=[],{fields:s,dataSource:n}=S.parse(t),o=u(n,e);if(!s||!n||"disabled"===e?.debug?.custom_mappings||!o)return{block:e,successful:!0};let i;if(Array.isArray(o))i=o.map((e=>{const t=F(s,e);return r.push(...t?.errors||[]),t?.record}));else{const e=F(s,o);i=e?.record,r.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:i},errors:Object.keys(r).length>0?r:void 0}},inputSchema:S,outputSchema:_}},[q.REQUEST]:{v1:{fn:async({block:e,params:t})=>{const r=p.build();if(!e.httpClient)throw new Error("HTTP client is not configured");const{args:s}=t,n=s?s.filter((t=>!t.condition||!0===u(t.condition,e))):void 0,o=t?c({...t,args:n},e):{},{baseUrl:i,url:a,method:l,response:d,args:m}=x.parse(o),g=o?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,b=w.parse(g),h=m?y(m):{query:{},body:{},headers:{}},v=f(b),k={...h?.headers??{},...v};let S;try{S=await r.performRequest({httpClient:e.httpClient,url:`${i}${a}`,queryParams:h?.query,method:l,headers:k,body:h?.body})}catch(t){return{block:e,successful:!1,errors:[t]}}const _=d?.dataKey?S.data[d?.dataKey]:S.data,F=E(_,d);return{block:e,successful:!0,output:{data:F,raw:S}}},inputSchema:x,outputSchema:T}},[q.GROUP_DATA]:{v1:{fn:async({block:t,params:r})=>{const{stepsDataToGroup:s,isSingleRecord:n}=g.parse(r),o=s.reduce(((r,s)=>{const o=t.steps?.[s]?.output?.data;return o?n?{...r,[s]:{...o}}:(Object.keys(o).forEach((t=>{const n=e(r[t])?r[t]:{};r[t]={...n,[s]:{...o[t]}}})),r):r}),{});return{block:{...t},successful:!0,output:{data:n?o:Object.values(o)}}},inputSchema:g,outputSchema:b}}},H=(e,t)=>async({block:r,params:s})=>{try{e.inputSchema&&e.inputSchema.parse(s)}catch(e){return{block:r,successful:!1,errors:[{message:`Input parameters for ${t} are invalid`}]}}const n=await e.fn({block:r,params:s});try{e.outputSchema&&e.outputSchema.parse(n.output)}catch(e){return{block:r,successful:!1,errors:[{message:`Output data of ${t} has unexpected format`}]}}return n},B={build({functionName:e,version:t="1",validateSchemas:r=!1,stepFunctionsList:s=G}){const n=s?.[e]?.[`v${t}`];if(!n)throw new Error(`Unknown step function: ${e} v${t}`);return r?{...n,fn:H(n,e)}:n}},V={hris:{title:"HRIS",key:"hris",description:"Human Resource Information System"},crm:{title:"CRM",key:"crm",description:"Customer Relationship Management"},ats:{title:"ATS",key:"ats",description:"Applicant Tracking System"},lms:{title:"LMS",key:"lms",description:"Learning Management System"},marketing:{title:"Marketing",key:"marketing",description:"Marketing"},filestorage:{title:"File Storage",key:"filestorage",description:"File Storage"}},z=e=>V[e.toLowerCase()]??null,Q=e=>!!V[e.toLowerCase()];export{w as AUTHENTICATION_SCHEMA,q as StepFunctionName,B as StepFunctionsFactory,z as getCategoryDetails,Q as isValidCategory};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@stackone/expressions"),t=require("@stackone/utils");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var s,n=r(require("date-fns"));exports.StepFunctionName=void 0,(s=exports.StepFunctionName||(exports.StepFunctionName={})).TYPECAST="typecast",s.MAP_FIELDS="map_fields",s.REQUEST="request",s.GROUP_RESULTS="group_results";const i=async({block:e})=>{const t=e?.fieldConfigs,r=[],s=e.steps;if(!t||"disabled"===e?.debug?.custom_mappings||!s)return{block:e,successfull:!0};let n;if(Array.isArray(e.result)){const i=e.result.length;n=e.result.map(((e,n)=>{const a=o(s,i,n),l=u(e,t,a);return r.push(...l.errors||[]),l.record}))}else{const i=u(e.result,t,s);n=i.record,r.push(...i.errors||[])}return{block:{...e,result:n},successfull:!0,errors:Object.keys(r).length>0?r:void 0}},o=(e,t,r)=>Object.entries(e).reduce(((e,[s,n])=>{const i=n?.output?.data;return Array.isArray(i)&&i.length===t?e[s]={output:{data:i[r]}}:e[s]=n,e}),{}),u=(e,t,r)=>{if(!e||!r)return{record:e};const s={unified:{...e},..."object"==typeof r?r:{}},n={},i=[],o={...e};for(const r of t){const{error:t,value:u}=a(s,e.id,r);t?i.push(t):r.isUnified?o[r.targetFieldKey]=u:n[r.targetFieldKey]=u}return{record:{...o,unified_custom_fields:Object.keys(n).length>0?n:void 0},errors:i.length>0?i:void 0}},a=(t,r,s)=>{const{expression:n,targetFieldKey:i}=s;if(!n)return{error:{message:"Expression is empty",id:r,targetField:i}};let o;try{o=e.evaluate(n,t)}catch(e){return{error:{message:"Invalid expression",id:r,targetField:i}}}return void 0===o?{error:{message:"Expression returned no value",id:r,targetField:i}}:{value:o}},l="yyyy-MM-dd",c=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],d=({value:e})=>{const t=n.parseISO(e);if(n.isValid(t))return t;const r=new Date;for(const t of c){const s=n.parse(e,t,r);if(n.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},y=({value:e,format:r=l})=>{const s=(({value:e,format:r=l})=>{if(t.isDate(e))return e;if(!t.isString(e))return null;try{const t=n.parse(e,r,new Date);return n.isValid(t)?t:d({value:e})}catch(e){return null}})({value:e,format:r});return s?s.toISOString():null};var f;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(f||(f={}));const p=({value:e,type:r,format:s})=>{if(t.isMissing(e))return null;switch(r){case f.String:return(({value:e})=>t.isString(e)?e:t.isDate(e)?e.toISOString():t.isObject(e)?JSON.stringify(e):String(e))({value:e});case f.Number:return(({value:e})=>{if(t.isNumber(e))return e;if(t.isDate(e))return null;const r=Number(e);return isNaN(r)?null:r})({value:e});case f.Boolean:return(({value:e})=>t.isBoolean(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case f.DateTimeString:return y({value:e,format:s});default:return e}},g=async({block:e})=>{const t=e?.fieldConfigs;if(!t||"disabled"===e?.debug?.custom_mappings)return{block:e,successfull:!0};let r;return r=Array.isArray(e.result)?e.result.map((e=>m(e,t))):m(e.result,t),{block:{...e,result:r},successfull:!0}},m=(e,r)=>{const s={...e};return r.forEach((r=>{const{targetFieldKey:n,type:i}=r;(e=>Object.values(f).includes(e))(i)&&(r.isUnified&&t.notMissing(s[n])?s[n]=p({value:e[n],type:i}):s.unified_custom_fields&&t.notMissing(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=p({value:e.unified_custom_fields?.[n],type:i})))})),{...s}},S={build({functionName:e}){switch(e){case exports.StepFunctionName.TYPECAST:return g;case exports.StepFunctionName.MAP_FIELDS:return i;default:throw new Error(`Unknown step function: ${e}`)}}},v={hris:{title:"HRIS",key:"hris",description:"Human Resource Information System"},crm:{title:"CRM",key:"crm",description:"Customer Relationship Management"},ats:{title:"ATS",key:"ats",description:"Applicant Tracking System"},lms:{title:"LMS",key:"lms",description:"Learning Management System"},marketing:{title:"Marketing",key:"marketing",description:"Marketing"},filestorage:{title:"File Storage",key:"filestorage",description:"File Storage"}};exports.StepFunctionsFactory=S,exports.getCategoryDetails=e=>v[e.toLowerCase()]??null,exports.isValidCategory=e=>!!v[e.toLowerCase()];
1
+ "use strict";var e=require("@stackone/utils"),t=require("zod"),r=require("@stackone/expressions"),s=require("@stackone/transport");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=n(require("date-fns"));const i=t.z.object({stepsDataToGroup:t.z.array(t.z.string()),isSingleRecord:t.z.boolean().optional()}),a=t.z.object({data:t.z.unknown()}),u=(e,t,r)=>Object.entries(e).reduce(((e,[s,n])=>{const o=n?.output?.data;return Array.isArray(o)&&o.length===t?e[s]={output:{data:o[r]}}:e[s]=n,e}),{}),c=(e,t,r)=>{if(!e||!r)return{record:e};const s={unified:{...e},..."object"==typeof r?r:{}},n={},o=[],i={...e};for(const r of t){const{error:t,value:a}=l(s,e.id,r);t?o.push(t):r.isUnified?i[r.targetFieldKey]=a:n[r.targetFieldKey]=a}return{record:{...i,unified_custom_fields:Object.keys(n).length>0?n:void 0},errors:o.length>0?o:void 0}},l=(e,t,s)=>{const{expression:n,targetFieldKey:o}=s;if(!n)return{error:{message:"Expression is empty",id:t,targetField:o}};let i;try{i=r.evaluate(n,e)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:o}}}return void 0===i?{error:{message:"Expression returned no value",id:t,targetField:o}}:{value:i}},d=t.z.object({fields:t.z.object({expression:t.z.string(),targetFieldKey:t.z.string(),type:t.z.string(),isUnified:t.z.boolean().optional()}).array(),dataSource:t.z.string()}),p=t.z.object({data:t.z.unknown()}),y=(e,t)=>{if(!t)return;const r={},s=[],n={};for(const o of e){const{error:e,value:i}=f(t,t?.id,o);e?s.push(e):o.isUnified?n[o.targetFieldKey]=i:r[o.targetFieldKey]=i}return{record:{...n,unified_custom_fields:Object.keys(r).length>0?r:void 0},errors:s.length>0?s:void 0}},f=(e,t,s)=>{const{expression:n,targetFieldKey:o}=s;if(!n)return{error:{message:"Expression is empty",id:t,targetField:o}};let i;try{i=r.evaluate(n,e)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:o}}}return void 0===i?{error:{message:"Expression returned no value",id:t,targetField:o}}:{value:i}},g=t.z.object({type:t.z.literal("basic"),username:t.z.string(),password:t.z.string(),encoding:t.z.string().optional()}),m=t.z.object({type:t.z.literal("bearer"),token:t.z.string()}),b=t.z.discriminatedUnion("type",[g,m]),v=t.z.object({baseUrl:t.z.string(),url:t.z.string(),method:t.z.enum(s.HttpMethods),response:t.z.object({collection:t.z.boolean().optional(),indexField:t.z.string().optional(),dataKey:t.z.string().optional()}).optional(),args:t.z.object({name:t.z.string(),value:t.z.unknown(),in:t.z.enum(s.RequestParameterLocations),condition:t.z.boolean().optional()}).array().optional()}),h=t.z.object({data:t.z.unknown(),raw:t.z.unknown().optional()}),S=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce(((e,r)=>{const s=t.indexField;return s&&r[s]&&(e[r[s]]=r),e}),{});if(!t?.collection&&t?.indexField){const r=t.indexField;return r&&e[r]?{[e[r]]:e}:e}return e},z=t.z.object({fields:t.z.object({targetFieldKey:t.z.string(),type:t.z.string(),isUnified:t.z.boolean().optional()}).array().optional(),dataSource:t.z.string()}),k=t.z.object({data:t.z.unknown()}),F="yyyy-MM-dd",M=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],_=({value:e})=>{const t=o.parseISO(e);if(o.isValid(t))return t;const r=new Date;for(const t of M){const s=o.parse(e,t,r);if(o.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},j=({value:t,format:r=F})=>{const s=(({value:t,format:r=F})=>{if(e.isDate(t))return t;if(!e.isString(t))return null;try{const e=o.parse(t,r,new Date);return o.isValid(e)?e:_({value:t})}catch(e){return null}})({value:t,format:r});return s?s.toISOString():null};var x;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(x||(x={}));const A=({value:t,type:r,format:s})=>{if(e.isMissing(t))return null;switch(r){case x.String:return(({value:t})=>e.isString(t)?t:e.isDate(t)?t.toISOString():e.isObject(t)?JSON.stringify(t):String(t))({value:t});case x.Number:return(({value:t})=>{if(e.isNumber(t))return t;if(e.isDate(t))return null;const r=Number(t);return isNaN(r)?null:r})({value:t});case x.Boolean:return(({value:t})=>e.isBoolean(t)?t:"false"!==t&&"0"!==t&&0!==t&&Boolean(t))({value:t});case x.DateTimeString:return j({value:t,format:s});default:return t}},O=e=>Object.values(x).includes(e),w=(t,r)=>{const s={...t};return r.forEach((r=>{const{targetFieldKey:n,type:o}=r;O(o)&&(r.isUnified&&e.notMissing(s[n])?s[n]=A({value:t[n],type:o}):s.unified_custom_fields&&e.notMissing(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=A({value:t.unified_custom_fields?.[n],type:o})))})),{...s}},E=(t,r)=>{const s={...t};return r.forEach((r=>{const{targetFieldKey:n,type:o}=r;O(o)&&(r.isUnified&&e.notMissing(s[n])?s[n]=A({value:t[n],type:o}):s.unified_custom_fields&&e.notMissing(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=A({value:t.unified_custom_fields?.[n],type:o})))})),{...s}};var T;exports.StepFunctionName=void 0,(T=exports.StepFunctionName||(exports.StepFunctionName={})).TYPECAST="typecast",T.MAP_FIELDS="map_fields",T.GROUP_DATA="group_data",T.REQUEST="request";const C={[exports.StepFunctionName.TYPECAST]:{v1:{fn:async({block:e})=>{const t=e?.fieldConfigs;if(!t||"disabled"===e?.debug?.custom_mappings)return{block:e,successful:!0};let r;return r=Array.isArray(e.result)?e.result.map((e=>w(e,t))):w(e.result,t),{block:{...e,result:r},successful:!0}}},v2:{fn:async({block:e,params:t})=>{const{fields:s,dataSource:n}=z.parse(t),o=r.evaluate(n,e);if(!s||"disabled"===e?.debug?.custom_mappings)return{block:e,successful:!0};let i;return i=Array.isArray(o)?o.map((e=>E(e,s))):E(o,s),{block:{...e},successful:!0,output:{data:i}}},inputSchema:z,outputSchema:k}},[exports.StepFunctionName.MAP_FIELDS]:{v1:{fn:async({block:e})=>{const t=e?.fieldConfigs,r=[],s=e.steps;if(!t||"disabled"===e?.debug?.custom_mappings||!s)return{block:e,successful:!0};let n;if(Array.isArray(e.result)){const o=e.result.length;n=e.result.map(((e,n)=>{const i=u(s,o,n),a=c(e,t,i);return r.push(...a.errors||[]),a.record}))}else{const o=c(e.result,t,s);n=o.record,r.push(...o.errors||[])}return{block:{...e,result:n},successful:!0,errors:Object.keys(r).length>0?r:void 0}}},v2:{fn:async({block:e,params:t})=>{const s=[],{fields:n,dataSource:o}=d.parse(t),i=r.evaluate(o,e);if(!n||!o||"disabled"===e?.debug?.custom_mappings||!i)return{block:e,successful:!0};let a;if(Array.isArray(i))a=i.map((e=>{const t=y(n,e);return s.push(...t?.errors||[]),t?.record}));else{const e=y(n,i);a=e?.record,s.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:a},errors:Object.keys(s).length>0?s:void 0}},inputSchema:d,outputSchema:p}},[exports.StepFunctionName.REQUEST]:{v1:{fn:async({block:e,params:t})=>{const n=s.RequestClientFactory.build();if(!e.httpClient)throw new Error("HTTP client is not configured");const{args:o}=t,i=o?o.filter((t=>!t.condition||!0===r.evaluate(t.condition,e))):void 0,a=t?r.safeEvaluateRecord({...t,args:i},e):{},{baseUrl:u,url:c,method:l,response:d,args:p}=v.parse(a),y=a?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,f=b.parse(y),g=p?s.parseRequestParameters(p):{query:{},body:{},headers:{}},m=s.createAuthorizationHeaders(f),h={...g?.headers??{},...m};let z;try{z=await n.performRequest({httpClient:e.httpClient,url:`${u}${c}`,queryParams:g?.query,method:l,headers:h,body:g?.body})}catch(t){return{block:e,successful:!1,errors:[t]}}const k=d?.dataKey?z.data[d?.dataKey]:z.data,F=S(k,d);return{block:e,successful:!0,output:{data:F,raw:z}}},inputSchema:v,outputSchema:h}},[exports.StepFunctionName.GROUP_DATA]:{v1:{fn:async({block:t,params:r})=>{const{stepsDataToGroup:s,isSingleRecord:n}=i.parse(r),o=s.reduce(((r,s)=>{const o=t.steps?.[s]?.output?.data;return o?n?{...r,[s]:{...o}}:(Object.keys(o).forEach((t=>{const n=e.notMissing(r[t])?r[t]:{};r[t]={...n,[s]:{...o[t]}}})),r):r}),{});return{block:{...t},successful:!0,output:{data:n?o:Object.values(o)}}},inputSchema:i,outputSchema:a}}},N=(e,t)=>async({block:r,params:s})=>{try{e.inputSchema&&e.inputSchema.parse(s)}catch(e){return{block:r,successful:!1,errors:[{message:`Input parameters for ${t} are invalid`}]}}const n=await e.fn({block:r,params:s});try{e.outputSchema&&e.outputSchema.parse(n.output)}catch(e){return{block:r,successful:!1,errors:[{message:`Output data of ${t} has unexpected format`}]}}return n},U={build({functionName:e,version:t="1",validateSchemas:r=!1,stepFunctionsList:s=C}){const n=s?.[e]?.[`v${t}`];if(!n)throw new Error(`Unknown step function: ${e} v${t}`);return r?{...n,fn:N(n,e)}:n}},D={hris:{title:"HRIS",key:"hris",description:"Human Resource Information System"},crm:{title:"CRM",key:"crm",description:"Customer Relationship Management"},ats:{title:"ATS",key:"ats",description:"Applicant Tracking System"},lms:{title:"LMS",key:"lms",description:"Learning Management System"},marketing:{title:"Marketing",key:"marketing",description:"Marketing"},filestorage:{title:"File Storage",key:"filestorage",description:"File Storage"}};exports.AUTHENTICATION_SCHEMA=b,exports.StepFunctionsFactory=U,exports.getCategoryDetails=e=>D[e.toLowerCase()]??null,exports.isValidCategory=e=>!!D[e.toLowerCase()];
@@ -1,8 +1,12 @@
1
1
  export { Block, BlockIndexedRecord, BlockContext, FieldConfig, } from './blocks/types';
2
- export { StepFunction, StepFunctionParams, StepFunctionName } from './stepFunctions/types';
2
+ export { StepFunction, StepFunctionParams } from './stepFunctions/types';
3
+ export { StepFunctionName } from './stepFunctions/stepFunctionsList';
3
4
  export { StepsSnapshots, Step } from './steps/types';
4
5
  export { StepFunctionsFactory } from './stepFunctions/factory';
5
6
  export { Schema, SchemaField } from './schema/types';
6
7
  export { Category } from './categories/types';
7
8
  export { getCategoryDetails, isValidCategory } from './categories';
8
9
  export { Connector, Operation, OperationType } from './connector/types';
10
+ export { AUTHENTICATION_SCHEMA } from './stepFunctions/request/schemas';
11
+ export { Input } from './connector/types';
12
+ export { ILogger } from './logger/types';
@@ -1,7 +1,10 @@
1
- import { StepFunctionName } from './types';
2
- import type { StepFunction } from './types';
1
+ import { StepFunctionName } from './stepFunctionsList';
2
+ import type { StepFunctionInstance } from './types';
3
3
  export declare const StepFunctionsFactory: {
4
- build({ functionName }: {
4
+ build({ functionName, version, validateSchemas, stepFunctionsList, }: {
5
5
  functionName: StepFunctionName;
6
- }): StepFunction;
6
+ version?: string;
7
+ validateSchemas?: boolean;
8
+ stepFunctionsList?: Record<string, Record<string, StepFunctionInstance>>;
9
+ }): StepFunctionInstance;
7
10
  };
@@ -0,0 +1,2 @@
1
+ import type { StepFunction } from '../types';
2
+ export declare const groupDataStepFunction: StepFunction;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const GROUP_DATA_INPUT_PARAMS: z.ZodObject<{
3
+ stepsDataToGroup: z.ZodArray<z.ZodString, "many">;
4
+ isSingleRecord: z.ZodOptional<z.ZodBoolean>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ stepsDataToGroup: string[];
7
+ isSingleRecord?: boolean | undefined;
8
+ }, {
9
+ stepsDataToGroup: string[];
10
+ isSingleRecord?: boolean | undefined;
11
+ }>;
12
+ export declare const GROUP_DATA_OUTPUT: z.ZodObject<{
13
+ data: z.ZodUnknown;
14
+ }, "strip", z.ZodTypeAny, {
15
+ data?: unknown;
16
+ }, {
17
+ data?: unknown;
18
+ }>;
@@ -0,0 +1,2 @@
1
+ import type { StepFunction } from '../types';
2
+ export declare const mapFieldsStepFunction: StepFunction;
@@ -0,0 +1,43 @@
1
+ import { z } from 'zod';
2
+ export declare const MAP_FIELDS_INPUT_PARAMS: z.ZodObject<{
3
+ fields: z.ZodArray<z.ZodObject<{
4
+ expression: z.ZodString;
5
+ targetFieldKey: z.ZodString;
6
+ type: z.ZodString;
7
+ isUnified: z.ZodOptional<z.ZodBoolean>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ expression: string;
10
+ targetFieldKey: string;
11
+ type: string;
12
+ isUnified?: boolean | undefined;
13
+ }, {
14
+ expression: string;
15
+ targetFieldKey: string;
16
+ type: string;
17
+ isUnified?: boolean | undefined;
18
+ }>, "many">;
19
+ dataSource: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ fields: {
22
+ expression: string;
23
+ targetFieldKey: string;
24
+ type: string;
25
+ isUnified?: boolean | undefined;
26
+ }[];
27
+ dataSource: string;
28
+ }, {
29
+ fields: {
30
+ expression: string;
31
+ targetFieldKey: string;
32
+ type: string;
33
+ isUnified?: boolean | undefined;
34
+ }[];
35
+ dataSource: string;
36
+ }>;
37
+ export declare const MAP_FIELDS_OUTPUT: z.ZodObject<{
38
+ data: z.ZodUnknown;
39
+ }, "strip", z.ZodTypeAny, {
40
+ data?: unknown;
41
+ }, {
42
+ data?: unknown;
43
+ }>;
@@ -0,0 +1,2 @@
1
+ import type { StepFunction } from '../types';
2
+ export declare const requestStepFunction: StepFunction;
@@ -0,0 +1,100 @@
1
+ import { z } from 'zod';
2
+ export declare const AUTHENTICATION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
+ type: z.ZodLiteral<"basic">;
4
+ username: z.ZodString;
5
+ password: z.ZodString;
6
+ encoding: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ type: "basic";
9
+ username: string;
10
+ password: string;
11
+ encoding?: string | undefined;
12
+ }, {
13
+ type: "basic";
14
+ username: string;
15
+ password: string;
16
+ encoding?: string | undefined;
17
+ }>, z.ZodObject<{
18
+ type: z.ZodLiteral<"bearer">;
19
+ token: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: "bearer";
22
+ token: string;
23
+ }, {
24
+ type: "bearer";
25
+ token: string;
26
+ }>]>;
27
+ export declare const REQUEST_INPUT_PARAMS: z.ZodObject<{
28
+ baseUrl: z.ZodString;
29
+ url: z.ZodString;
30
+ method: z.ZodEnum<["get", "post", "put", "delete", "patch"]>;
31
+ response: z.ZodOptional<z.ZodObject<{
32
+ collection: z.ZodOptional<z.ZodBoolean>;
33
+ indexField: z.ZodOptional<z.ZodString>;
34
+ dataKey: z.ZodOptional<z.ZodString>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ collection?: boolean | undefined;
37
+ indexField?: string | undefined;
38
+ dataKey?: string | undefined;
39
+ }, {
40
+ collection?: boolean | undefined;
41
+ indexField?: string | undefined;
42
+ dataKey?: string | undefined;
43
+ }>>;
44
+ args: z.ZodOptional<z.ZodArray<z.ZodObject<{
45
+ name: z.ZodString;
46
+ value: z.ZodUnknown;
47
+ in: z.ZodEnum<["query", "body", "headers"]>;
48
+ condition: z.ZodOptional<z.ZodBoolean>;
49
+ }, "strip", z.ZodTypeAny, {
50
+ name: string;
51
+ in: "query" | "body" | "headers";
52
+ value?: unknown;
53
+ condition?: boolean | undefined;
54
+ }, {
55
+ name: string;
56
+ in: "query" | "body" | "headers";
57
+ value?: unknown;
58
+ condition?: boolean | undefined;
59
+ }>, "many">>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ baseUrl: string;
62
+ url: string;
63
+ method: "get" | "post" | "put" | "delete" | "patch";
64
+ response?: {
65
+ collection?: boolean | undefined;
66
+ indexField?: string | undefined;
67
+ dataKey?: string | undefined;
68
+ } | undefined;
69
+ args?: {
70
+ name: string;
71
+ in: "query" | "body" | "headers";
72
+ value?: unknown;
73
+ condition?: boolean | undefined;
74
+ }[] | undefined;
75
+ }, {
76
+ baseUrl: string;
77
+ url: string;
78
+ method: "get" | "post" | "put" | "delete" | "patch";
79
+ response?: {
80
+ collection?: boolean | undefined;
81
+ indexField?: string | undefined;
82
+ dataKey?: string | undefined;
83
+ } | undefined;
84
+ args?: {
85
+ name: string;
86
+ in: "query" | "body" | "headers";
87
+ value?: unknown;
88
+ condition?: boolean | undefined;
89
+ }[] | undefined;
90
+ }>;
91
+ export declare const REQUEST_OUTPUT: z.ZodObject<{
92
+ data: z.ZodUnknown;
93
+ raw: z.ZodOptional<z.ZodUnknown>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ data?: unknown;
96
+ raw?: unknown;
97
+ }, {
98
+ data?: unknown;
99
+ raw?: unknown;
100
+ }>;
@@ -0,0 +1,204 @@
1
+ export declare enum StepFunctionName {
2
+ TYPECAST = "typecast",
3
+ MAP_FIELDS = "map_fields",
4
+ GROUP_DATA = "group_data",
5
+ REQUEST = "request"
6
+ }
7
+ export declare const stepFunctions: {
8
+ typecast: {
9
+ v1: {
10
+ fn: import("./types").StepFunction;
11
+ };
12
+ v2: {
13
+ fn: import("./types").StepFunction;
14
+ inputSchema: import("zod").ZodObject<{
15
+ fields: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
16
+ targetFieldKey: import("zod").ZodString;
17
+ type: import("zod").ZodString;
18
+ isUnified: import("zod").ZodOptional<import("zod").ZodBoolean>;
19
+ }, "strip", import("zod").ZodTypeAny, {
20
+ targetFieldKey: string;
21
+ type: string;
22
+ isUnified?: boolean | undefined;
23
+ }, {
24
+ targetFieldKey: string;
25
+ type: string;
26
+ isUnified?: boolean | undefined;
27
+ }>, "many">>;
28
+ dataSource: import("zod").ZodString;
29
+ }, "strip", import("zod").ZodTypeAny, {
30
+ dataSource: string;
31
+ fields?: {
32
+ targetFieldKey: string;
33
+ type: string;
34
+ isUnified?: boolean | undefined;
35
+ }[] | undefined;
36
+ }, {
37
+ dataSource: string;
38
+ fields?: {
39
+ targetFieldKey: string;
40
+ type: string;
41
+ isUnified?: boolean | undefined;
42
+ }[] | undefined;
43
+ }>;
44
+ outputSchema: import("zod").ZodObject<{
45
+ data: import("zod").ZodUnknown;
46
+ }, "strip", import("zod").ZodTypeAny, {
47
+ data?: unknown;
48
+ }, {
49
+ data?: unknown;
50
+ }>;
51
+ };
52
+ };
53
+ map_fields: {
54
+ v1: {
55
+ fn: import("./types").StepFunction;
56
+ };
57
+ v2: {
58
+ fn: import("./types").StepFunction;
59
+ inputSchema: import("zod").ZodObject<{
60
+ fields: import("zod").ZodArray<import("zod").ZodObject<{
61
+ expression: import("zod").ZodString;
62
+ targetFieldKey: import("zod").ZodString;
63
+ type: import("zod").ZodString;
64
+ isUnified: import("zod").ZodOptional<import("zod").ZodBoolean>;
65
+ }, "strip", import("zod").ZodTypeAny, {
66
+ targetFieldKey: string;
67
+ type: string;
68
+ expression: string;
69
+ isUnified?: boolean | undefined;
70
+ }, {
71
+ targetFieldKey: string;
72
+ type: string;
73
+ expression: string;
74
+ isUnified?: boolean | undefined;
75
+ }>, "many">;
76
+ dataSource: import("zod").ZodString;
77
+ }, "strip", import("zod").ZodTypeAny, {
78
+ fields: {
79
+ targetFieldKey: string;
80
+ type: string;
81
+ expression: string;
82
+ isUnified?: boolean | undefined;
83
+ }[];
84
+ dataSource: string;
85
+ }, {
86
+ fields: {
87
+ targetFieldKey: string;
88
+ type: string;
89
+ expression: string;
90
+ isUnified?: boolean | undefined;
91
+ }[];
92
+ dataSource: string;
93
+ }>;
94
+ outputSchema: import("zod").ZodObject<{
95
+ data: import("zod").ZodUnknown;
96
+ }, "strip", import("zod").ZodTypeAny, {
97
+ data?: unknown;
98
+ }, {
99
+ data?: unknown;
100
+ }>;
101
+ };
102
+ };
103
+ request: {
104
+ v1: {
105
+ fn: import("./types").StepFunction;
106
+ inputSchema: import("zod").ZodObject<{
107
+ baseUrl: import("zod").ZodString;
108
+ url: import("zod").ZodString;
109
+ method: import("zod").ZodEnum<["get", "post", "put", "delete", "patch"]>;
110
+ response: import("zod").ZodOptional<import("zod").ZodObject<{
111
+ collection: import("zod").ZodOptional<import("zod").ZodBoolean>;
112
+ indexField: import("zod").ZodOptional<import("zod").ZodString>;
113
+ dataKey: import("zod").ZodOptional<import("zod").ZodString>;
114
+ }, "strip", import("zod").ZodTypeAny, {
115
+ collection?: boolean | undefined;
116
+ indexField?: string | undefined;
117
+ dataKey?: string | undefined;
118
+ }, {
119
+ collection?: boolean | undefined;
120
+ indexField?: string | undefined;
121
+ dataKey?: string | undefined;
122
+ }>>;
123
+ args: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
124
+ name: import("zod").ZodString;
125
+ value: import("zod").ZodUnknown;
126
+ in: import("zod").ZodEnum<["query", "body", "headers"]>;
127
+ condition: import("zod").ZodOptional<import("zod").ZodBoolean>;
128
+ }, "strip", import("zod").ZodTypeAny, {
129
+ name: string;
130
+ in: "query" | "body" | "headers";
131
+ value?: unknown;
132
+ condition?: boolean | undefined;
133
+ }, {
134
+ name: string;
135
+ in: "query" | "body" | "headers";
136
+ value?: unknown;
137
+ condition?: boolean | undefined;
138
+ }>, "many">>;
139
+ }, "strip", import("zod").ZodTypeAny, {
140
+ baseUrl: string;
141
+ url: string;
142
+ method: "get" | "post" | "put" | "delete" | "patch";
143
+ response?: {
144
+ collection?: boolean | undefined;
145
+ indexField?: string | undefined;
146
+ dataKey?: string | undefined;
147
+ } | undefined;
148
+ args?: {
149
+ name: string;
150
+ in: "query" | "body" | "headers";
151
+ value?: unknown;
152
+ condition?: boolean | undefined;
153
+ }[] | undefined;
154
+ }, {
155
+ baseUrl: string;
156
+ url: string;
157
+ method: "get" | "post" | "put" | "delete" | "patch";
158
+ response?: {
159
+ collection?: boolean | undefined;
160
+ indexField?: string | undefined;
161
+ dataKey?: string | undefined;
162
+ } | undefined;
163
+ args?: {
164
+ name: string;
165
+ in: "query" | "body" | "headers";
166
+ value?: unknown;
167
+ condition?: boolean | undefined;
168
+ }[] | undefined;
169
+ }>;
170
+ outputSchema: import("zod").ZodObject<{
171
+ data: import("zod").ZodUnknown;
172
+ raw: import("zod").ZodOptional<import("zod").ZodUnknown>;
173
+ }, "strip", import("zod").ZodTypeAny, {
174
+ data?: unknown;
175
+ raw?: unknown;
176
+ }, {
177
+ data?: unknown;
178
+ raw?: unknown;
179
+ }>;
180
+ };
181
+ };
182
+ group_data: {
183
+ v1: {
184
+ fn: import("./types").StepFunction;
185
+ inputSchema: import("zod").ZodObject<{
186
+ stepsDataToGroup: import("zod").ZodArray<import("zod").ZodString, "many">;
187
+ isSingleRecord: import("zod").ZodOptional<import("zod").ZodBoolean>;
188
+ }, "strip", import("zod").ZodTypeAny, {
189
+ stepsDataToGroup: string[];
190
+ isSingleRecord?: boolean | undefined;
191
+ }, {
192
+ stepsDataToGroup: string[];
193
+ isSingleRecord?: boolean | undefined;
194
+ }>;
195
+ outputSchema: import("zod").ZodObject<{
196
+ data: import("zod").ZodUnknown;
197
+ }, "strip", import("zod").ZodTypeAny, {
198
+ data?: unknown;
199
+ }, {
200
+ data?: unknown;
201
+ }>;
202
+ };
203
+ };
204
+ };
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ export declare const TYPECAST_INPUT_PARAMS: z.ZodObject<{
3
+ fields: z.ZodOptional<z.ZodArray<z.ZodObject<{
4
+ targetFieldKey: z.ZodString;
5
+ type: z.ZodString;
6
+ isUnified: z.ZodOptional<z.ZodBoolean>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ targetFieldKey: string;
9
+ type: string;
10
+ isUnified?: boolean | undefined;
11
+ }, {
12
+ targetFieldKey: string;
13
+ type: string;
14
+ isUnified?: boolean | undefined;
15
+ }>, "many">>;
16
+ dataSource: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ dataSource: string;
19
+ fields?: {
20
+ targetFieldKey: string;
21
+ type: string;
22
+ isUnified?: boolean | undefined;
23
+ }[] | undefined;
24
+ }, {
25
+ dataSource: string;
26
+ fields?: {
27
+ targetFieldKey: string;
28
+ type: string;
29
+ isUnified?: boolean | undefined;
30
+ }[] | undefined;
31
+ }>;
32
+ export declare const TYPECAST_OUTPUT: z.ZodObject<{
33
+ data: z.ZodUnknown;
34
+ }, "strip", z.ZodTypeAny, {
35
+ data?: unknown;
36
+ }, {
37
+ data?: unknown;
38
+ }>;
@@ -0,0 +1,2 @@
1
+ import type { StepFunction } from '../types';
2
+ export declare const typecastStepFunction: StepFunction;
@@ -1,11 +1,7 @@
1
+ import { ZodTypeAny } from 'zod';
1
2
  import type { Block } from '../blocks/types';
2
3
  import { StepError } from '../steps/types';
3
- export declare enum StepFunctionName {
4
- TYPECAST = "typecast",
5
- MAP_FIELDS = "map_fields",
6
- REQUEST = "request",
7
- GROUP_RESULTS = "group_results"
8
- }
4
+ import { StepFunctionName } from './stepFunctionsList';
9
5
  export type StepFunction = ({ block, params, }: {
10
6
  block: Readonly<Block>;
11
7
  params?: StepFunctionParams;
@@ -18,9 +14,14 @@ export type StepFunctionMeta = {
18
14
  params?: StepFunctionParams;
19
15
  version?: string;
20
16
  };
17
+ export type StepFunctionInstance = {
18
+ fn: StepFunction;
19
+ inputSchema?: ZodTypeAny;
20
+ outputSchema?: ZodTypeAny;
21
+ };
21
22
  export type StepFunctionOutput = {
22
23
  block: Block;
23
- successfull: boolean;
24
+ successful: boolean;
24
25
  errors?: StepError[];
25
26
  output?: {
26
27
  [name: string]: unknown;
@@ -3,7 +3,7 @@ export type StepSnapshot = {
3
3
  output?: {
4
4
  [name: string]: unknown;
5
5
  };
6
- successfull: boolean;
6
+ successful: boolean;
7
7
  errors?: StepError[];
8
8
  };
9
9
  export type StepsSnapshots = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",
@@ -24,8 +24,8 @@
24
24
  "code:check:fix": "biome check --write ./src ./*.mjs",
25
25
  "lint": "npm run code:check",
26
26
  "lint:fix": "npm run code:check:fix",
27
- "test": "vitest run --silent",
28
- "test:watch": "vitest watch --silent",
27
+ "test": "FORCE_COLOR=1 vitest run",
28
+ "test:watch": "FORCE_COLOR=1 vitest watch --silent",
29
29
  "publish-release": "npm publish --access=public"
30
30
  },
31
31
  "keywords": [],
@@ -36,8 +36,5 @@
36
36
  "@stackone/transport": "*",
37
37
  "@stackone/utils": "*",
38
38
  "date-fns": "^3.4.0"
39
- },
40
- "devDependencies": {
41
- "@types/jsonpath": "^0.2.4"
42
39
  }
43
40
  }
@@ -1,11 +0,0 @@
1
- import { HttpMethod, HttpResponse, IHttpClient } from '@stackone/transport';
2
- export interface IRequestClient {
3
- performRequest: ({ httpClient, url, method, headers, body, }: {
4
- httpClient: IHttpClient;
5
- url: string;
6
- method: HttpMethod;
7
- headers: Record<string, string>;
8
- body: unknown;
9
- }) => Promise<HttpResponse>;
10
- }
11
- export type RequestClientType = 'rest' | 'soap';