@stackone/core 1.22.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 +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/stepFunctions/groupData/groupDataStepFunction.d.ts +2 -0
- package/dist/types/stepFunctions/groupData/schemas.d.ts +18 -0
- package/dist/types/stepFunctions/request/requestStepFunction.d.ts +2 -0
- package/dist/types/stepFunctions/request/schemas.d.ts +100 -0
- package/dist/types/stepFunctions/stepFunctionsList.d.ts +104 -1
- package/package.json +2 -2
- package/dist/types/stepFunctions/request/types.d.ts +0 -11
package/dist/index.es.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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/
|
|
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()];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,3 +7,6 @@ export { Schema, SchemaField } from './schema/types';
|
|
|
7
7
|
export { Category } from './categories/types';
|
|
8
8
|
export { getCategoryDetails, isValidCategory } from './categories';
|
|
9
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';
|
|
@@ -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,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
|
+
}>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare enum StepFunctionName {
|
|
2
2
|
TYPECAST = "typecast",
|
|
3
|
-
MAP_FIELDS = "map_fields"
|
|
3
|
+
MAP_FIELDS = "map_fields",
|
|
4
|
+
GROUP_DATA = "group_data",
|
|
5
|
+
REQUEST = "request"
|
|
4
6
|
}
|
|
5
7
|
export declare const stepFunctions: {
|
|
6
8
|
typecast: {
|
|
@@ -98,4 +100,105 @@ export declare const stepFunctions: {
|
|
|
98
100
|
}>;
|
|
99
101
|
};
|
|
100
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
|
+
};
|
|
101
204
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.mjs",
|
|
@@ -24,7 +24,7 @@
|
|
|
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": "FORCE_COLOR=1 vitest run
|
|
27
|
+
"test": "FORCE_COLOR=1 vitest run",
|
|
28
28
|
"test:watch": "FORCE_COLOR=1 vitest watch --silent",
|
|
29
29
|
"publish-release": "npm publish --access=public"
|
|
30
30
|
},
|
|
@@ -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';
|