@stackone/core 1.19.0 → 1.21.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 e from"jsonpath";import{safeEvaluate as r}from"@stackone/expressions";import{isDate as t,isString as s,isBoolean as n,isNumber as i,isObject as o,isMissing as u,notMissing as a}from"@stackone/utils";import*as l from"date-fns";var d;!function(e){e.MAP="map",e.TYPECAST="typecast",e.MAP_FIELDS="map_fields"}(d||(d={}));const c=async({stepFunctions:e,block:r})=>e.reduce((async(e,r)=>r({block:await e})),Promise.resolve(r)),y=async({block:e})=>{const r=e?.fieldConfigs,t=[];if(!r||"disabled"===e?.debug?.custom_mappings)return e;let s;const n=e.providerData,i=e.context.childResource??e.context.subResource??e.context.resource;if(Array.isArray(e.result))s=e.result.map((e=>{const s=n?.[i]?.items;if(!s)return e;const o=f(e.id,e.remote_id,n),u=p(e,r,o);return t.push(...u.errors||[]),u.record}));else{const i=p(e.result,r,n);s=i.record,t.push(...i.errors||[])}return{...e,result:s,customMappingErrors:Object.keys(t).length>0?t:void 0}},f=(e,r,t)=>t?Object.keys(t).reduce(((s,n)=>{const i=t[n];if(!i.items)return s;const o=i.items.find((t=>t.id===e||t.id===r));return o?{...s,[n]:o}:s}),{}):{},p=(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}=m(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}},m=(r,t,s)=>{const{expression:n,targetFieldKey:i}=s;if(!n)return{error:{message:"Expression is empty",id:t,targetField:i}};try{e.parse(n)}catch(e){return{error:{message:"Invalid JSON path expression",id:t,targetField:i}}}const o=n&&e.query(r,n)[0];return o?{value:o}:{error:{message:"Expression returned no value",id:t,targetField:i}}},g=async({block:e})=>{const r=e?.fieldConfigs,t=[],s=e.steps;if(!r||"disabled"===e?.debug?.custom_mappings||!s)return e;let n;if(Array.isArray(e.result)){const i=e.result.length;n=e.result.map(((e,n)=>{const o=v(s,i,n),u=b(e,r,o);return t.push(...u.errors||[]),u.record}))}else{const i=b(e.result,r,s);n=i.record,t.push(...i.errors||[])}return{...e,result:n,customMappingErrors:Object.keys(t).length>0?t:void 0}},v=(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}),{}),b=(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}=h(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}},h=(t,s,n)=>{const{expression:i,targetFieldKey:o}=n;if(!i)return{error:{message:"Expression is empty",id:s,targetField:o}};try{e.parse(i)}catch(e){const n=r(i,t);return null===n?{error:{message:"Invalid expression",id:s,targetField:o}}:{value:n}}const u=i&&e.query(t,i)[0];return void 0===u?{error:{message:"Expression returned no value",id:s,targetField:o}}:{value:u}},M="yyyy-MM-dd",_=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],S=({value:e})=>{const r=l.parseISO(e);if(l.isValid(r))return r;const t=new Date;for(const r of _){const s=l.parse(e,r,t);if(l.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},A=({value:e,format:r=M})=>{const n=(({value:e,format:r=M})=>{if(t(e))return e;if(!s(e))return null;try{const t=l.parse(e,r,new Date);return l.isValid(t)?t:S({value:e})}catch(e){return null}})({value:e,format:r});return n?n.toISOString():null};var F;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(F||(F={}));const k=({value:e,type:r,format:a})=>{if(u(e))return null;switch(r){case F.String:return(({value:e})=>s(e)?e:t(e)?e.toISOString():o(e)?JSON.stringify(e):String(e))({value:e});case F.Number:return(({value:e})=>{if(i(e))return e;if(t(e))return null;const r=Number(e);return isNaN(r)?null:r})({value:e});case F.Boolean:return(({value:e})=>n(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case F.DateTimeString:return A({value:e,format:a});default:return e}},x=async({block:e})=>{const r=e?.fieldConfigs;if(!r||"disabled"===e?.debug?.custom_mappings)return e;let t;return t=Array.isArray(e.result)?e.result.map((e=>E(e,r))):E(e.result,r),{...e,result:t}},E=(e,r)=>{const t={...e};return r.forEach((r=>{const{targetFieldKey:s,type:n}=r;(e=>Object.values(F).includes(e))(n)&&(r.isUnified&&a(t[s])?t[s]=k({value:e[s],type:n}):t.unified_custom_fields&&a(t.unified_custom_fields?.[s])&&(t.unified_custom_fields[s]=k({value:e.unified_custom_fields?.[s],type:n})))})),{...t}},O={build({functionName:e}){switch(e){case d.MAP:return y;case d.TYPECAST:return x;case d.MAP_FIELDS:return g;default:throw new Error(`Unknown step function: ${e}`)}}},j=({fieldConfigs:e})=>{const r=[];return e&&r.push(O.build({functionName:d.MAP}),O.build({functionName:d.TYPECAST})),r};export{d as StepFunctionName,O as StepFunctionsFactory,j as getFieldMappingStepFunctions,c as stepsBasicPipeRunner};
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};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("jsonpath"),r=require("@stackone/expressions"),t=require("@stackone/utils");function s(e){var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var n,i=s(require("date-fns"));exports.StepFunctionName=void 0,(n=exports.StepFunctionName||(exports.StepFunctionName={})).MAP="map",n.TYPECAST="typecast",n.MAP_FIELDS="map_fields";const o=async({block:e})=>{const r=e?.fieldConfigs,t=[];if(!r||"disabled"===e?.debug?.custom_mappings)return e;let s;const n=e.providerData,i=e.context.childResource??e.context.subResource??e.context.resource;if(Array.isArray(e.result))s=e.result.map((e=>{const s=n?.[i]?.items;if(!s)return e;const o=u(e.id,e.remote_id,n),c=a(e,r,o);return t.push(...c.errors||[]),c.record}));else{const i=a(e.result,r,n);s=i.record,t.push(...i.errors||[])}return{...e,result:s,customMappingErrors:Object.keys(t).length>0?t:void 0}},u=(e,r,t)=>t?Object.keys(t).reduce(((s,n)=>{const i=t[n];if(!i.items)return s;const o=i.items.find((t=>t.id===e||t.id===r));return o?{...s,[n]:o}:s}),{}):{},a=(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}=c(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}},c=(r,t,s)=>{const{expression:n,targetFieldKey:i}=s;if(!n)return{error:{message:"Expression is empty",id:t,targetField:i}};try{e.parse(n)}catch(e){return{error:{message:"Invalid JSON path expression",id:t,targetField:i}}}const o=n&&e.query(r,n)[0];return o?{value:o}:{error:{message:"Expression returned no value",id:t,targetField:i}}},l=async({block:e})=>{const r=e?.fieldConfigs,t=[],s=e.steps;if(!r||"disabled"===e?.debug?.custom_mappings||!s)return e;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=p(e,r,o);return t.push(...u.errors||[]),u.record}))}else{const i=p(e.result,r,s);n=i.record,t.push(...i.errors||[])}return{...e,result:n,customMappingErrors: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}),{}),p=(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}=y(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}},y=(t,s,n)=>{const{expression:i,targetFieldKey:o}=n;if(!i)return{error:{message:"Expression is empty",id:s,targetField:o}};try{e.parse(i)}catch(e){const n=r.safeEvaluate(i,t);return null===n?{error:{message:"Invalid expression",id:s,targetField:o}}:{value:n}}const u=i&&e.query(t,i)[0];return void 0===u?{error:{message:"Expression returned no value",id:s,targetField:o}}:{value:u}},f="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"],m=({value:e})=>{const r=i.parseISO(e);if(i.isValid(r))return r;const t=new Date;for(const r of g){const s=i.parse(e,r,t);if(i.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},v=({value:e,format:r=f})=>{const s=(({value:e,format:r=f})=>{if(t.isDate(e))return e;if(!t.isString(e))return null;try{const t=i.parse(e,r,new Date);return i.isValid(t)?t:m({value:e})}catch(e){return null}})({value:e,format:r});return s?s.toISOString():null};var b;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(b||(b={}));const M=({value:e,type:r,format:s})=>{if(t.isMissing(e))return null;switch(r){case b.String:return(({value:e})=>t.isString(e)?e:t.isDate(e)?e.toISOString():t.isObject(e)?JSON.stringify(e):String(e))({value:e});case b.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 b.Boolean:return(({value:e})=>t.isBoolean(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case b.DateTimeString:return v({value:e,format:s});default:return e}},S=async({block:e})=>{const r=e?.fieldConfigs;if(!r||"disabled"===e?.debug?.custom_mappings)return e;let t;return t=Array.isArray(e.result)?e.result.map((e=>F(e,r))):F(e.result,r),{...e,result:t}},F=(e,r)=>{const s={...e};return r.forEach((r=>{const{targetFieldKey:n,type:i}=r;(e=>Object.values(b).includes(e))(i)&&(r.isUnified&&t.notMissing(s[n])?s[n]=M({value:e[n],type:i}):s.unified_custom_fields&&t.notMissing(s.unified_custom_fields?.[n])&&(s.unified_custom_fields[n]=M({value:e.unified_custom_fields?.[n],type:i})))})),{...s}},h={build({functionName:e}){switch(e){case exports.StepFunctionName.MAP:return o;case exports.StepFunctionName.TYPECAST:return S;case exports.StepFunctionName.MAP_FIELDS:return l;default:throw new Error(`Unknown step function: ${e}`)}}};exports.StepFunctionsFactory=h,exports.getFieldMappingStepFunctions=({fieldConfigs:e})=>{const r=[];return e&&r.push(h.build({functionName:exports.StepFunctionName.MAP}),h.build({functionName:exports.StepFunctionName.TYPECAST})),r},exports.stepsBasicPipeRunner=async({stepFunctions:e,block:r})=>e.reduce((async(e,r)=>r({block:await e})),Promise.resolve(r));
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,23 +1,37 @@
1
- import type { HttpMethod } from '@stackone/transport';
1
+ import type { IHttpClient } from '@stackone/transport';
2
+ import { Category } from '../categories/types';
3
+ import { Connector, Operation, OperationType } from '../connector/types';
4
+ import { ILogger } from '../logger/types';
2
5
  import type { StepsSnapshots } from '../steps/types';
3
6
  export type Block = {
4
- fieldConfigs?: FieldConfig[];
5
- result?: BlockIndexedRecord[] | BlockIndexedRecord;
7
+ inputs?: {
8
+ [key: string]: unknown;
9
+ };
10
+ connector?: Connector;
6
11
  context: BlockContext;
7
12
  debug?: DebugParams;
8
13
  steps?: StepsSnapshots;
9
- customMappingErrors?: FieldMappingError[];
10
- providerData?: ProviderData;
14
+ httpClient?: IHttpClient;
15
+ logger?: ILogger;
16
+ operation?: Operation;
17
+ credentials?: Credentials;
18
+ outputs?: unknown;
19
+ fieldConfigs?: FieldConfig[];
20
+ result?: BlockIndexedRecord[] | BlockIndexedRecord;
11
21
  };
12
22
  export type BlockContext = {
13
23
  projectSecureId: string;
14
24
  accountSecureId: string;
15
25
  connector: string;
26
+ category: Category;
27
+ schema?: string;
28
+ operationType: OperationType;
29
+ authenticationType: string;
30
+ environment: string;
16
31
  service: string;
17
32
  resource: string;
18
33
  subResource?: string;
19
34
  childResource?: string;
20
- operationType: string;
21
35
  };
22
36
  export type BlockIndexedRecord = {
23
37
  id: string;
@@ -36,22 +50,4 @@ export type FieldConfig = {
36
50
  export type DebugParams = {
37
51
  custom_mappings?: 'disabled' | 'enabled';
38
52
  };
39
- export type ProviderData = {
40
- [key: string]: ProviderDataObject;
41
- };
42
- export type ProviderDataObject<T = unknown> = {
43
- [key: string]: T | ProviderDataRequestDetails;
44
- request_details: ProviderDataRequestDetails;
45
- };
46
- export type ProviderDataRequestDetails = {
47
- method: HttpMethod;
48
- url: string;
49
- body?: {
50
- [key: string]: string | number | boolean;
51
- };
52
- };
53
- export type FieldMappingError = {
54
- id?: string;
55
- message: string;
56
- targetField: string;
57
- };
53
+ export type Credentials = Record<string, unknown>;
@@ -0,0 +1,3 @@
1
+ import { CategoryDetails } from './types';
2
+ export declare const getCategoryDetails: (category: string) => CategoryDetails | null;
3
+ export declare const isValidCategory: (category: string) => boolean;
@@ -0,0 +1,6 @@
1
+ export type Category = 'hris' | 'crm' | 'ats' | 'lms' | 'marketing' | 'filestorage';
2
+ export type CategoryDetails = {
3
+ title: string;
4
+ key: Category;
5
+ description: string;
6
+ };
@@ -0,0 +1,53 @@
1
+ import { HttpMethod } from '@stackone/transport';
2
+ import { Category } from '../categories/types';
3
+ import { Schema } from '../schema/types';
4
+ import { Step } from '../steps/types';
5
+ export type Connector = {
6
+ title: string;
7
+ version: string;
8
+ key: string;
9
+ description?: string;
10
+ categories: Category[];
11
+ authentication?: Authentication;
12
+ operations?: {
13
+ [entrypointUrl: string]: Operation;
14
+ };
15
+ };
16
+ export type OperationType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom';
17
+ export type InputLocation = 'body' | 'query' | 'path' | 'headers';
18
+ export type Input = {
19
+ name: string;
20
+ type: string;
21
+ required: boolean;
22
+ description: string;
23
+ in: InputLocation;
24
+ };
25
+ export type Operation = {
26
+ id: string;
27
+ description: string;
28
+ schema?: Schema;
29
+ operationType: OperationType;
30
+ entrypointUrl: string;
31
+ entrypointHttpMethod: HttpMethod;
32
+ inputs?: Input[];
33
+ steps: {
34
+ [stepId: string]: Step;
35
+ };
36
+ result?: string;
37
+ };
38
+ export type AuthenticationConfig = {
39
+ envKey: string;
40
+ envName: string;
41
+ type: 'custom' | 'oauth2' | 'oidc';
42
+ label: string;
43
+ authorization: {
44
+ type: 'basic' | 'bearer';
45
+ [authParam: string]: unknown;
46
+ };
47
+ };
48
+ export type Authentication = {
49
+ [authType: string]: {
50
+ production: AuthenticationConfig;
51
+ [envKey: string]: AuthenticationConfig;
52
+ };
53
+ };
@@ -1,6 +1,8 @@
1
1
  export { Block, BlockIndexedRecord, BlockContext, FieldConfig, } from './blocks/types';
2
2
  export { StepFunction, StepFunctionParams, StepFunctionName } from './stepFunctions/types';
3
- export { StepsSnapshots } from './steps/types';
4
- export { stepsBasicPipeRunner } from './steps/stepsRunners';
5
- export { getFieldMappingStepFunctions } from './stepFunctions/getFieldMappingStepFunctions';
3
+ export { StepsSnapshots, Step } from './steps/types';
6
4
  export { StepFunctionsFactory } from './stepFunctions/factory';
5
+ export { Schema, SchemaField } from './schema/types';
6
+ export { Category } from './categories/types';
7
+ export { getCategoryDetails, isValidCategory } from './categories';
8
+ export { Connector, Operation, OperationType } from './connector/types';
@@ -0,0 +1,34 @@
1
+ export interface ILogger {
2
+ debug({ category, message, traceId, context, }: {
3
+ category?: string;
4
+ message: string;
5
+ traceId?: string;
6
+ context?: Record<string, unknown>;
7
+ }): void;
8
+ info({ category, message, traceId, context, }: {
9
+ category?: string;
10
+ message: string;
11
+ traceId?: string;
12
+ context?: Record<string, unknown>;
13
+ }): void;
14
+ warning({ category, message, traceId, context, }: {
15
+ category?: string;
16
+ message: string;
17
+ traceId?: string;
18
+ context?: Record<string, unknown>;
19
+ }): void;
20
+ error({ category, message, traceId, error, context, }: {
21
+ category?: string;
22
+ message: string;
23
+ traceId?: string;
24
+ error?: LogError;
25
+ context?: Record<string, unknown>;
26
+ }): void;
27
+ }
28
+ export type LogError = Error & {
29
+ response?: {
30
+ data?: unknown;
31
+ };
32
+ context?: Record<string, unknown>;
33
+ url?: string;
34
+ };
@@ -0,0 +1,17 @@
1
+ import { Category } from '../categories/types';
2
+ export type Schema = {
3
+ name: string;
4
+ key: string;
5
+ version: string;
6
+ description?: string;
7
+ category: Category;
8
+ fields: {
9
+ [name: string]: SchemaField;
10
+ };
11
+ };
12
+ export type SchemaField = {
13
+ name: string;
14
+ type: string;
15
+ required: boolean;
16
+ description?: string;
17
+ };
@@ -1,2 +1,2 @@
1
- import type { StepFunction } from '../types';
1
+ import { StepFunction } from '../types';
2
2
  export declare const mapFieldsStepFunction: StepFunction;
@@ -0,0 +1,11 @@
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';
@@ -1,13 +1,28 @@
1
1
  import type { Block } from '../blocks/types';
2
+ import { StepError } from '../steps/types';
2
3
  export declare enum StepFunctionName {
3
- MAP = "map",
4
4
  TYPECAST = "typecast",
5
- MAP_FIELDS = "map_fields"
5
+ MAP_FIELDS = "map_fields",
6
+ REQUEST = "request",
7
+ GROUP_RESULTS = "group_results"
6
8
  }
7
9
  export type StepFunction = ({ block, params, }: {
8
10
  block: Readonly<Block>;
9
11
  params?: StepFunctionParams;
10
- }) => Promise<Block>;
12
+ }) => Promise<StepFunctionOutput>;
11
13
  export type StepFunctionParams = {
12
14
  [key: string]: unknown;
13
15
  };
16
+ export type StepFunctionMeta = {
17
+ functionName: StepFunctionName;
18
+ params?: StepFunctionParams;
19
+ version?: string;
20
+ };
21
+ export type StepFunctionOutput = {
22
+ block: Block;
23
+ successfull: boolean;
24
+ errors?: StepError[];
25
+ output?: {
26
+ [name: string]: unknown;
27
+ };
28
+ };
@@ -1,13 +1,26 @@
1
+ import { StepFunctionMeta } from '../stepFunctions/types';
1
2
  export type StepSnapshot = {
2
- output: {
3
- data: unknown;
4
- matcher?: string;
3
+ output?: {
4
+ [name: string]: unknown;
5
5
  };
6
+ successfull: boolean;
6
7
  errors?: StepError[];
7
8
  };
8
9
  export type StepsSnapshots = {
9
- [key: string]: StepSnapshot;
10
+ [stepId: string]: StepSnapshot;
10
11
  };
11
12
  export type StepError = {
12
- message: string;
13
+ [key: string]: unknown;
14
+ };
15
+ export type StepOutput = {
16
+ name: string;
17
+ value: string;
18
+ };
19
+ export type Step = {
20
+ id: string;
21
+ description: string;
22
+ stepFunction: StepFunctionMeta;
23
+ ignoreErrors?: boolean;
24
+ async?: boolean;
25
+ successCriteria?: string;
13
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",
@@ -32,11 +32,10 @@
32
32
  "author": "StackOne",
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
+ "@stackone/expressions": "*",
35
36
  "@stackone/transport": "*",
36
37
  "@stackone/utils": "*",
37
- "@stackone/expressions": "*",
38
- "date-fns": "^3.4.0",
39
- "jsonpath": "^1.1.1"
38
+ "date-fns": "^3.4.0"
40
39
  },
41
40
  "devDependencies": {
42
41
  "@types/jsonpath": "^0.2.4"
@@ -1,5 +0,0 @@
1
- import type { FieldConfig } from '../blocks/types';
2
- import { type StepFunction } from './types';
3
- export declare const getFieldMappingStepFunctions: ({ fieldConfigs, }: {
4
- fieldConfigs?: FieldConfig[];
5
- }) => StepFunction[];
@@ -1,2 +0,0 @@
1
- import type { StepFunction } from '../types';
2
- export declare const mapStepFunction: StepFunction;
@@ -1,6 +0,0 @@
1
- import type { Block } from '../blocks/types';
2
- import type { StepFunction } from '../stepFunctions/types';
3
- export declare const stepsBasicPipeRunner: ({ stepFunctions, block, }: {
4
- stepFunctions: StepFunction[];
5
- block: Block;
6
- }) => Promise<Block>;