@stackone/core 1.5.2 → 1.6.1

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{HttpClient as t}from"@stackone/transport";import e from"jsonpath";import*as r from"date-fns";const n=(t,e="")=>{if("object"===t.type&&t.properties){const r=""===e||e.endsWith(".")?e:`${e}.`;return Object.entries(t.properties).flatMap((([t,e])=>n(e,`${r}${t}`)))}return"array"===t.type&&t.items?n(t.items,`${e}[].`):[{name:e.endsWith(".")?e.slice(0,-1):e,type:t.type,description:t.description}]};class s{constructor({version:e="1",key:r,name:s,services:o={},httpOperations:a={},auth:i,proxy:c,httpClient:u=new t}){this.listOperations=()=>Object.keys(this.httpOperations||{}),this.getOperation=t=>{const e=this.httpOperations?.[t];if(!e)throw new Error(`Operation ${t} not found`);return e},this.getOperationResponseFieldsMetadata=t=>{const e=this.getOperation(t).responses;if(!e)return null;const r=(t=>{const e=Object.entries(t).find((([t])=>t.startsWith("2")));return e?e[1]:null})(e);return r&&r.content["application/json"]?.schema?n(r.content["application/json"]?.schema):null},this.callOperation=async({operationId:t,params:e,credentials:r})=>{const n=this.httpOperations?.[t];if(!n)throw new Error(`Operation ${t} not found`);const s=(({params:t,httpOperation:e})=>{const{url:r,method:n}=e;let s=r;const o=[],a=[],i={};let c;Object.entries(t||{}).forEach((([t,r])=>{const n=e.parameters?.[t];if(n)switch(n.in){case"path":s=s.replace(`{${t}}`,r).replace(`:${t}`,r);break;case"query":o.push(`${t}=${r}`);break;case"header":i[t]=r;break;case"cookie":a.push(`${t}=${r}; `);break;case"body":c=r}}));const u=o.length>0?`?${o.join("&")}`:"";return a.length>0&&(i.cookie=a.join("")),{url:`${s}${u}`,method:n,headers:Object.keys(i).length>0?i:void 0,body:c||void 0}})({params:e,httpOperation:n}),{method:o,url:a,headers:i,body:c}=s,{apiKey:u}=r;return{connector:this,input:{operationId:t,params:e},response:await this.httpClient.request({method:o,url:a,headers:{...i,authorization:u},payload:c}),credentials:r}},this.version=e,this.key=r,this.name=s,this.services=o,this.httpOperations=a,this.auth=i,this.proxy=c,this.httpClient=u}}const o="request_body";var a;!function(t){t.MAP="map",t.TYPECAST="typecast"}(a||(a={}));const i=async({blockFunctions:t,block:e})=>t.reduce((async(t,e)=>e({block:await t})),Promise.resolve(e)),c=async({block:t})=>{const e=t?.fieldConfigs;if(!e)return t;let r;const n=t.providerResponse;return r=Array.isArray(t.result)?t.result.map((r=>{const s=(n?.data?.[t.context.resource]).find((t=>t.id===r.id||t.id===r.remote_id));return u(r,e,s)})):u(t.result,e,n?.data),{...t,result:r}},u=(t,r,n)=>{if(!n)return t;const s={...t};return r.forEach((t=>{const{expression:r,targetFieldKey:o}=t,a=r&&e.query(n,r)[0];r&&a&&(s[o]=a)})),{...s}},l=t=>"string"==typeof t,p=t=>t instanceof Date,y="yyyy-MM-dd",d=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],h=({value:t})=>{const e=r.parseISO(t);if(r.isValid(e))return e;const n=new Date;for(const e of d){const s=r.parse(t,e,n);if(r.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},f=({value:t,format:e=y})=>{const n=(({value:t,format:e=y})=>{if(p(t))return t;if(!l(t))return null;try{const n=r.parse(t,e,new Date);return r.isValid(n)?n:h({value:t})}catch(t){return null}})({value:t,format:e});return n?n.toISOString():null};var m;!function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.DateTimeString="datetime_string"}(m||(m={}));const b=({value:t,type:e,format:r})=>{if(!t)return null;switch(e){case m.String:return(({value:t})=>l(t)?t:p(t)?t.toISOString():(t=>"object"==typeof t&&null!==t)(t)?JSON.stringify(t):String(t))({value:t});case m.Number:return(({value:t})=>{if((t=>"number"==typeof t)(t))return t;if(p(t))return null;const e=Number(t);return isNaN(e)?null:e})({value:t});case m.Boolean:return(({value:t})=>(t=>"boolean"==typeof t)(t)?t:"false"!==t&&"0"!==t&&0!==t&&Boolean(t))({value:t});case m.DateTimeString:return f({value:t,format:r});default:return t}},v=async({block:t})=>{const e=t?.fieldConfigs;if(!e)return t;let r;return r=Array.isArray(t.result)?t.result.map((t=>O(t,e))):O(t.result,e),{...t,result:r}},O=(t,e)=>{const r={...t};return e.forEach((e=>{const{targetFieldKey:n,type:s}=e;(t=>Object.values(m).includes(t))(s)&&t[n]&&(r[n]=b({value:t[n],type:s}))})),{...r}};class M{static build({type:t}){switch(t){case a.MAP:return c;case a.TYPECAST:return v;default:throw new Error(`Unknown block function: ${t}`)}}}const g=({fieldConfigs:t})=>{const e=[];return t&&e.push(M.build({type:a.MAP}),M.build({type:a.TYPECAST})),e};export{s as BaseConnector,a as BlockFunctionType,o as REQUEST_BODY_PARAM,i as blockPipe,g as getBlockPipeFunctionsFromConfigs};
1
+ import{HttpClient as t}from"@stackone/transport";import e from"jsonpath";import*as r from"date-fns";const n=(t,e="")=>{if("object"===t.type&&t.properties){const r=""===e||e.endsWith(".")?e:`${e}.`;return Object.entries(t.properties).flatMap((([t,e])=>n(e,`${r}${t}`)))}return"array"===t.type&&t.items?n(t.items,`${e}[].`):[{name:e.endsWith(".")?e.slice(0,-1):e,type:t.type,description:t.description}]};class s{constructor({version:e="1",key:r,name:s,services:o={},httpOperations:a={},auth:i,proxy:u,httpClient:c=new t}){this.listOperations=()=>Object.keys(this.httpOperations||{}),this.getOperation=t=>{const e=this.httpOperations?.[t];if(!e)throw new Error(`Operation ${t} not found`);return e},this.getOperationResponseFieldsMetadata=t=>{const e=this.getOperation(t).responses;if(!e)return null;const r=(t=>{const e=Object.entries(t).find((([t])=>t.startsWith("2")));return e?e[1]:null})(e);return r?.content["application/json"]?.schema?n(r.content["application/json"]?.schema):null},this.callOperation=async({operationId:t,params:e,credentials:r})=>{const n=this.httpOperations?.[t];if(!n)throw new Error(`Operation ${t} not found`);const s=(({params:t,httpOperation:e})=>{const{url:r,method:n}=e;let s=r;const o=[],a=[],i={};let u;Object.entries(t||{}).forEach((([t,r])=>{const n=e.parameters?.[t];if(n)switch(n.in){case"path":s=s.replace(`{${t}}`,r).replace(`:${t}`,r);break;case"query":o.push(`${t}=${r}`);break;case"header":i[t]=r;break;case"cookie":a.push(`${t}=${r}; `);break;case"body":u=r}}));const c=o.length>0?`?${o.join("&")}`:"";return a.length>0&&(i.cookie=a.join("")),{url:`${s}${c}`,method:n,headers:Object.keys(i).length>0?i:void 0,body:u||void 0}})({params:e,httpOperation:n}),{method:o,url:a,headers:i,body:u}=s,{apiKey:c}=r;return{connector:this,input:{operationId:t,params:e},response:await this.httpClient.request({method:o,url:a,headers:{...i,authorization:c},payload:u}),credentials:r}},this.version=e,this.key=r,this.name=s,this.services=o,this.httpOperations=a,this.auth=i,this.proxy=u,this.httpClient=c}}const o="request_body";var a;!function(t){t.MAP="map",t.TYPECAST="typecast"}(a||(a={}));const i=async({blockSteps:t,block:e})=>t.reduce((async(t,e)=>e({block:await t})),Promise.resolve(e)),u=async({block:t})=>{const e=t?.fieldConfigs;if(!e||"disabled"===t?.debug?.custom_mappings)return t;let r;const n=t.providerResponse;return r=Array.isArray(t.result)?t.result.map((r=>{const s=(n?.data?.[t.context.resource]).find((t=>t.id===r.id||t.id===r.remote_id));return c(r,e,s)})):c(t.result,e,n?.data),{...t,result:r}},c=(t,r,n)=>{if(!n)return t;const s={...t};return r.forEach((t=>{const{expression:r,targetFieldKey:o}=t,a=r&&e.query(n,r)[0];r&&a&&(s[o]=a)})),{...s}},l=t=>"string"==typeof t,p=t=>t instanceof Date,y="yyyy-MM-dd",d=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],h=({value:t})=>{const e=r.parseISO(t);if(r.isValid(e))return e;const n=new Date;for(const e of d){const s=r.parse(t,e,n);if(r.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},f=({value:t,format:e=y})=>{const n=(({value:t,format:e=y})=>{if(p(t))return t;if(!l(t))return null;try{const n=r.parse(t,e,new Date);return r.isValid(n)?n:h({value:t})}catch(t){return null}})({value:t,format:e});return n?n.toISOString():null};var m;!function(t){t.String="string",t.Number="number",t.Boolean="boolean",t.DateTimeString="datetime_string"}(m||(m={}));const b=({value:t,type:e,format:r})=>{if(!t)return null;switch(e){case m.String:return(({value:t})=>l(t)?t:p(t)?t.toISOString():(t=>"object"==typeof t&&null!==t)(t)?JSON.stringify(t):String(t))({value:t});case m.Number:return(({value:t})=>{if((t=>"number"==typeof t)(t))return t;if(p(t))return null;const e=Number(t);return isNaN(e)?null:e})({value:t});case m.Boolean:return(({value:t})=>(t=>"boolean"==typeof t)(t)?t:"false"!==t&&"0"!==t&&0!==t&&Boolean(t))({value:t});case m.DateTimeString:return f({value:t,format:r});default:return t}},g=async({block:t})=>{const e=t?.fieldConfigs;if(!e||"disabled"===t?.debug?.custom_mappings)return t;let r;return r=Array.isArray(t.result)?t.result.map((t=>v(t,e))):v(t.result,e),{...t,result:r}},v=(t,e)=>{const r={...t};return e.forEach((e=>{const{targetFieldKey:n,type:s}=e;(t=>Object.values(m).includes(t))(s)&&t[n]&&(r[n]=b({value:t[n],type:s}))})),{...r}},O={build({type:t}){switch(t){case a.MAP:return u;case a.TYPECAST:return g;default:throw new Error(`Unknown block step: ${t}`)}}},M=({fieldConfigs:t})=>{const e=[];return t&&e.push(O.build({type:a.MAP}),O.build({type:a.TYPECAST})),e};export{s as BaseConnector,a as BlockStepType,o as REQUEST_BODY_PARAM,i as blockPipe,M as getBlockPipeStepsFromConfigs};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@stackone/transport"),t=require("jsonpath");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(require("date-fns"));const o=(e,t="")=>{if("object"===e.type&&e.properties){const r=""===t||t.endsWith(".")?t:`${t}.`;return Object.entries(e.properties).flatMap((([e,t])=>o(t,`${r}${e}`)))}return"array"===e.type&&e.items?o(e.items,`${t}[].`):[{name:t.endsWith(".")?t.slice(0,-1):t,type:e.type,description:e.description}]};var s;exports.BlockFunctionType=void 0,(s=exports.BlockFunctionType||(exports.BlockFunctionType={})).MAP="map",s.TYPECAST="typecast";const i=async({block:e})=>{const t=e?.fieldConfigs;if(!t)return e;let r;const n=e.providerResponse;return r=Array.isArray(e.result)?e.result.map((r=>{const o=(n?.data?.[e.context.resource]).find((e=>e.id===r.id||e.id===r.remote_id));return a(r,t,o)})):a(e.result,t,n?.data),{...e,result:r}},a=(e,r,n)=>{if(!n)return e;const o={...e};return r.forEach((e=>{const{expression:r,targetFieldKey:s}=e,i=r&&t.query(n,r)[0];r&&i&&(o[s]=i)})),{...o}},c=e=>"string"==typeof e,u=e=>e instanceof Date,l="yyyy-MM-dd",p=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],y=({value:e})=>{const t=n.parseISO(e);if(n.isValid(t))return t;const r=new Date;for(const t of p){const o=n.parse(e,t,r);if(n.isValid(o))return o.setUTCHours(0,0,0,0),o}return null},d=({value:e,format:t=l})=>{const r=(({value:e,format:t=l})=>{if(u(e))return e;if(!c(e))return null;try{const r=n.parse(e,t,new Date);return n.isValid(r)?r:y({value:e})}catch(e){return null}})({value:e,format:t});return r?r.toISOString():null};var h;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(h||(h={}));const f=({value:e,type:t,format:r})=>{if(!e)return null;switch(t){case h.String:return(({value:e})=>c(e)?e:u(e)?e.toISOString():(e=>"object"==typeof e&&null!==e)(e)?JSON.stringify(e):String(e))({value:e});case h.Number:return(({value:e})=>{if((e=>"number"==typeof e)(e))return e;if(u(e))return null;const t=Number(e);return isNaN(t)?null:t})({value:e});case h.Boolean:return(({value:e})=>(e=>"boolean"==typeof e)(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case h.DateTimeString:return d({value:e,format:r});default:return e}},b=async({block:e})=>{const t=e?.fieldConfigs;if(!t)return e;let r;return r=Array.isArray(e.result)?e.result.map((e=>m(e,t))):m(e.result,t),{...e,result:r}},m=(e,t)=>{const r={...e};return t.forEach((t=>{const{targetFieldKey:n,type:o}=t;(e=>Object.values(h).includes(e))(o)&&e[n]&&(r[n]=f({value:e[n],type:o}))})),{...r}};class O{static build({type:e}){switch(e){case exports.BlockFunctionType.MAP:return i;case exports.BlockFunctionType.TYPECAST:return b;default:throw new Error(`Unknown block function: ${e}`)}}}exports.BaseConnector=class{constructor({version:t="1",key:r,name:n,services:s={},httpOperations:i={},auth:a,proxy:c,httpClient:u=new e.HttpClient}){this.listOperations=()=>Object.keys(this.httpOperations||{}),this.getOperation=e=>{const t=this.httpOperations?.[e];if(!t)throw new Error(`Operation ${e} not found`);return t},this.getOperationResponseFieldsMetadata=e=>{const t=this.getOperation(e).responses;if(!t)return null;const r=(e=>{const t=Object.entries(e).find((([e])=>e.startsWith("2")));return t?t[1]:null})(t);return r&&r.content["application/json"]?.schema?o(r.content["application/json"]?.schema):null},this.callOperation=async({operationId:e,params:t,credentials:r})=>{const n=this.httpOperations?.[e];if(!n)throw new Error(`Operation ${e} not found`);const o=(({params:e,httpOperation:t})=>{const{url:r,method:n}=t;let o=r;const s=[],i=[],a={};let c;Object.entries(e||{}).forEach((([e,r])=>{const n=t.parameters?.[e];if(n)switch(n.in){case"path":o=o.replace(`{${e}}`,r).replace(`:${e}`,r);break;case"query":s.push(`${e}=${r}`);break;case"header":a[e]=r;break;case"cookie":i.push(`${e}=${r}; `);break;case"body":c=r}}));const u=s.length>0?`?${s.join("&")}`:"";return i.length>0&&(a.cookie=i.join("")),{url:`${o}${u}`,method:n,headers:Object.keys(a).length>0?a:void 0,body:c||void 0}})({params:t,httpOperation:n}),{method:s,url:i,headers:a,body:c}=o,{apiKey:u}=r;return{connector:this,input:{operationId:e,params:t},response:await this.httpClient.request({method:s,url:i,headers:{...a,authorization:u},payload:c}),credentials:r}},this.version=t,this.key=r,this.name=n,this.services=s,this.httpOperations=i,this.auth=a,this.proxy=c,this.httpClient=u}},exports.REQUEST_BODY_PARAM="request_body",exports.blockPipe=async({blockFunctions:e,block:t})=>e.reduce((async(e,t)=>t({block:await e})),Promise.resolve(t)),exports.getBlockPipeFunctionsFromConfigs=({fieldConfigs:e})=>{const t=[];return e&&t.push(O.build({type:exports.BlockFunctionType.MAP}),O.build({type:exports.BlockFunctionType.TYPECAST})),t};
1
+ "use strict";var e=require("@stackone/transport"),t=require("jsonpath");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(require("date-fns"));const s=(e,t="")=>{if("object"===e.type&&e.properties){const r=""===t||t.endsWith(".")?t:`${t}.`;return Object.entries(e.properties).flatMap((([e,t])=>s(t,`${r}${e}`)))}return"array"===e.type&&e.items?s(e.items,`${t}[].`):[{name:t.endsWith(".")?t.slice(0,-1):t,type:e.type,description:e.description}]};var o;exports.BlockStepType=void 0,(o=exports.BlockStepType||(exports.BlockStepType={})).MAP="map",o.TYPECAST="typecast";const a=async({block:e})=>{const t=e?.fieldConfigs;if(!t||"disabled"===e?.debug?.custom_mappings)return e;let r;const n=e.providerResponse;return r=Array.isArray(e.result)?e.result.map((r=>{const s=(n?.data?.[e.context.resource]).find((e=>e.id===r.id||e.id===r.remote_id));return i(r,t,s)})):i(e.result,t,n?.data),{...e,result:r}},i=(e,r,n)=>{if(!n)return e;const s={...e};return r.forEach((e=>{const{expression:r,targetFieldKey:o}=e,a=r&&t.query(n,r)[0];r&&a&&(s[o]=a)})),{...s}},c=e=>"string"==typeof e,p=e=>e instanceof Date,u="yyyy-MM-dd",l=["yyyy-MM-dd","yyyy/MM/dd","dd/MM/yyyy","dd-MM-yyyy","yyyy-dd-MM","yyyy/dd/MM","MM/dd/yyyy","MM-dd-yyyy"],y=({value:e})=>{const t=n.parseISO(e);if(n.isValid(t))return t;const r=new Date;for(const t of l){const s=n.parse(e,t,r);if(n.isValid(s))return s.setUTCHours(0,0,0,0),s}return null},d=({value:e,format:t=u})=>{const r=(({value:e,format:t=u})=>{if(p(e))return e;if(!c(e))return null;try{const r=n.parse(e,t,new Date);return n.isValid(r)?r:y({value:e})}catch(e){return null}})({value:e,format:t});return r?r.toISOString():null};var h;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(h||(h={}));const f=({value:e,type:t,format:r})=>{if(!e)return null;switch(t){case h.String:return(({value:e})=>c(e)?e:p(e)?e.toISOString():(e=>"object"==typeof e&&null!==e)(e)?JSON.stringify(e):String(e))({value:e});case h.Number:return(({value:e})=>{if((e=>"number"==typeof e)(e))return e;if(p(e))return null;const t=Number(e);return isNaN(t)?null:t})({value:e});case h.Boolean:return(({value:e})=>(e=>"boolean"==typeof e)(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case h.DateTimeString:return d({value:e,format:r});default:return e}},b=async({block:e})=>{const t=e?.fieldConfigs;if(!t||"disabled"===e?.debug?.custom_mappings)return e;let r;return r=Array.isArray(e.result)?e.result.map((e=>m(e,t))):m(e.result,t),{...e,result:r}},m=(e,t)=>{const r={...e};return t.forEach((t=>{const{targetFieldKey:n,type:s}=t;(e=>Object.values(h).includes(e))(s)&&e[n]&&(r[n]=f({value:e[n],type:s}))})),{...r}},g={build({type:e}){switch(e){case exports.BlockStepType.MAP:return a;case exports.BlockStepType.TYPECAST:return b;default:throw new Error(`Unknown block step: ${e}`)}}};exports.BaseConnector=class{constructor({version:t="1",key:r,name:n,services:o={},httpOperations:a={},auth:i,proxy:c,httpClient:p=new e.HttpClient}){this.listOperations=()=>Object.keys(this.httpOperations||{}),this.getOperation=e=>{const t=this.httpOperations?.[e];if(!t)throw new Error(`Operation ${e} not found`);return t},this.getOperationResponseFieldsMetadata=e=>{const t=this.getOperation(e).responses;if(!t)return null;const r=(e=>{const t=Object.entries(e).find((([e])=>e.startsWith("2")));return t?t[1]:null})(t);return r?.content["application/json"]?.schema?s(r.content["application/json"]?.schema):null},this.callOperation=async({operationId:e,params:t,credentials:r})=>{const n=this.httpOperations?.[e];if(!n)throw new Error(`Operation ${e} not found`);const s=(({params:e,httpOperation:t})=>{const{url:r,method:n}=t;let s=r;const o=[],a=[],i={};let c;Object.entries(e||{}).forEach((([e,r])=>{const n=t.parameters?.[e];if(n)switch(n.in){case"path":s=s.replace(`{${e}}`,r).replace(`:${e}`,r);break;case"query":o.push(`${e}=${r}`);break;case"header":i[e]=r;break;case"cookie":a.push(`${e}=${r}; `);break;case"body":c=r}}));const p=o.length>0?`?${o.join("&")}`:"";return a.length>0&&(i.cookie=a.join("")),{url:`${s}${p}`,method:n,headers:Object.keys(i).length>0?i:void 0,body:c||void 0}})({params:t,httpOperation:n}),{method:o,url:a,headers:i,body:c}=s,{apiKey:p}=r;return{connector:this,input:{operationId:e,params:t},response:await this.httpClient.request({method:o,url:a,headers:{...i,authorization:p},payload:c}),credentials:r}},this.version=t,this.key=r,this.name=n,this.services=o,this.httpOperations=a,this.auth=i,this.proxy=c,this.httpClient=p}},exports.REQUEST_BODY_PARAM="request_body",exports.blockPipe=async({blockSteps:e,block:t})=>e.reduce((async(e,t)=>t({block:await e})),Promise.resolve(t)),exports.getBlockPipeStepsFromConfigs=({fieldConfigs:e})=>{const t=[];return e&&t.push(g.build({type:exports.BlockStepType.MAP}),g.build({type:exports.BlockStepType.TYPECAST})),t};
@@ -1,5 +1,5 @@
1
- import { Block, BlockFunction } from './types';
2
- export declare const blockPipe: ({ blockFunctions, block, }: {
3
- blockFunctions: BlockFunction[];
1
+ import type { Block, BlockStep } from './types';
2
+ export declare const blockPipe: ({ blockSteps, block, }: {
3
+ blockSteps: BlockStep[];
4
4
  block: Block;
5
5
  }) => Promise<Block>;
@@ -0,0 +1,4 @@
1
+ import type { BlockFieldConfig, BlockStep } from './types';
2
+ export declare const getBlockPipeStepsFromConfigs: ({ fieldConfigs, }: {
3
+ fieldConfigs?: BlockFieldConfig[] | undefined;
4
+ }) => BlockStep[];
@@ -0,0 +1,7 @@
1
+ import { BlockStepType } from './steps/stepsDirectoryTypes';
2
+ import type { BlockStep } from './types';
3
+ export declare const BlockStepsFactory: {
4
+ build({ type }: {
5
+ type: BlockStepType;
6
+ }): BlockStep;
7
+ };
@@ -0,0 +1,2 @@
1
+ import type { BlockStep } from '../../types';
2
+ export declare const mapBlockStep: BlockStep;
@@ -1,4 +1,4 @@
1
- export declare enum BlockFunctionType {
1
+ export declare enum BlockStepType {
2
2
  MAP = "map",
3
3
  TYPECAST = "typecast"
4
4
  }
@@ -2,5 +2,5 @@ export declare const typecast: ({ value, type, format, }: {
2
2
  value: unknown;
3
3
  type: string;
4
4
  format?: string | undefined;
5
- }) => unknown | null;
5
+ }) => unknown;
6
6
  export declare const isFieldSupportedType: (type: string) => boolean;
@@ -0,0 +1,2 @@
1
+ import type { BlockStep } from '../../types';
2
+ export declare const typecastBlockStep: BlockStep;
@@ -4,6 +4,7 @@ export type Block = {
4
4
  providerResponse?: HttpResponse;
5
5
  result?: BlockIndexedRecord[] | BlockIndexedRecord;
6
6
  context: BlockContext;
7
+ debug?: BlockDebugParams;
7
8
  };
8
9
  export type BlockContext = {
9
10
  projectSecureId: string;
@@ -22,6 +23,9 @@ export type BlockFieldConfig = {
22
23
  targetFieldKey: string;
23
24
  type: string;
24
25
  };
25
- export type BlockFunction = ({ block, }: {
26
+ export type BlockStep = ({ block, }: {
26
27
  block: Readonly<Block>;
27
28
  }) => Promise<Block>;
29
+ export type BlockDebugParams = {
30
+ custom_mappings?: 'disabled' | 'enabled';
31
+ };
@@ -1,7 +1,7 @@
1
1
  export { IConnector, HttpOperations, HttpParameter, HttpParameterLocation, HttpParameterType, } from './types';
2
2
  export { BaseConnector } from './baseConnector';
3
3
  export { REQUEST_BODY_PARAM } from './constants';
4
- export { Block, BlockFunction, BlockIndexedRecord, BlockContext, BlockFieldConfig, } from './blocks/types';
5
- export { BlockFunctionType } from './blocks/functions/functionsDirectoryTypes';
4
+ export { Block, BlockStep, BlockIndexedRecord, BlockContext, BlockFieldConfig, } from './blocks/types';
5
+ export { BlockStepType } from './blocks/steps/stepsDirectoryTypes';
6
6
  export { blockPipe } from './blocks/blockPipe';
7
- export { getBlockPipeFunctionsFromConfigs } from './blocks/blockFunctionsConfigs';
7
+ export { getBlockPipeStepsFromConfigs } from './blocks/blockStepsConfigs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "1.5.2",
3
+ "version": "1.6.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -1,4 +0,0 @@
1
- import { BlockFieldConfig, BlockFunction } from './types';
2
- export declare const getBlockPipeFunctionsFromConfigs: ({ fieldConfigs, }: {
3
- fieldConfigs?: BlockFieldConfig[] | undefined;
4
- }) => BlockFunction[];
@@ -1,7 +0,0 @@
1
- import { BlockFunctionType } from './functions/functionsDirectoryTypes';
2
- import { BlockFunction } from './types';
3
- export declare class BlockFunctionsFactory {
4
- static build({ type }: {
5
- type: BlockFunctionType;
6
- }): BlockFunction;
7
- }
@@ -1,2 +0,0 @@
1
- import { BlockFunction } from '../../types';
2
- export declare const mapBlockFunction: BlockFunction;
@@ -1,2 +0,0 @@
1
- import { BlockFunction } from '../../types';
2
- export declare const typecastBlockFunction: BlockFunction;