@stackone/core 1.20.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{evaluate as e}from"@stackone/expressions";import{isDate as r,isString as t,isBoolean as n,isNumber as s,isObject as u,isMissing as i,notMissing as o}from"@stackone/utils";import*as a from"date-fns";var l;!function(e){e.TYPECAST="typecast",e.MAP_FIELDS="map_fields"}(l||(l={}));const d=async({block:e})=>{const r=e?.fieldConfigs,t=[],n=e.steps;if(!r||"disabled"===e?.debug?.custom_mappings||!n)return e;let s;if(Array.isArray(e.result)){const u=e.result.length;s=e.result.map(((e,s)=>{const i=c(n,u,s),o=y(e,r,i);return t.push(...o.errors||[]),o.record}))}else{const u=y(e.result,r,n);s=u.record,t.push(...u.errors||[])}const u={output:{data:s},errors:Object.keys(t).length>0?t:void 0};return{...e,result:s,steps:{...n,[l.MAP_FIELDS.toString()]:u}}},c=(e,r,t)=>Object.entries(e).reduce(((e,[n,s])=>{const u=s?.output?.data;return Array.isArray(u)&&u.length===r?e[n]={output:{data:u[t]}}:e[n]=s,e}),{}),y=(e,r,t)=>{if(!e||!t)return{record:e};const n={unified:{...e},..."object"==typeof t?t:{}},s={},u=[],i={...e};for(const t of r){const{error:r,value:o}=f(n,e.id,t);r?u.push(r):t.isUnified?i[t.targetFieldKey]=o:s[t.targetFieldKey]=o}return{record:{...i,unified_custom_fields:Object.keys(s).length>0?s:void 0},errors:u.length>0?u:void 0}},f=(r,t,n)=>{const{expression:s,targetFieldKey:u}=n;if(!s)return{error:{message:"Expression is empty",id:t,targetField:u}};let i;try{i=e(s,r)}catch(e){return{error:{message:"Invalid expression",id:t,targetField:u}}}return void 0===i?{error:{message:"Expression returned no value",id:t,targetField:u}}:{value:i}},m="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"],g=({value:e})=>{const r=a.parseISO(e);if(a.isValid(r))return r;const t=new Date;for(const r of p){const n=a.parse(e,r,t);if(a.isValid(n))return n.setUTCHours(0,0,0,0),n}return null},v=({value:e,format:n=m})=>{const s=(({value:e,format:n=m})=>{if(r(e))return e;if(!t(e))return null;try{const r=a.parse(e,n,new Date);return a.isValid(r)?r:g({value:e})}catch(e){return null}})({value:e,format:n});return s?s.toISOString():null};var M;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(M||(M={}));const b=({value:e,type:o,format:a})=>{if(i(e))return null;switch(o){case M.String:return(({value:e})=>t(e)?e:r(e)?e.toISOString():u(e)?JSON.stringify(e):String(e))({value:e});case M.Number:return(({value:e})=>{if(s(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})=>n(e)?e:"false"!==e&&"0"!==e&&0!==e&&Boolean(e))({value:e});case M.DateTimeString:return v({value:e,format:a});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=>_(e,r))):_(e.result,r),{...e,result:t}},_=(e,r)=>{const t={...e};return r.forEach((r=>{const{targetFieldKey:n,type:s}=r;(e=>Object.values(M).includes(e))(s)&&(r.isUnified&&o(t[n])?t[n]=b({value:e[n],type:s}):t.unified_custom_fields&&o(t.unified_custom_fields?.[n])&&(t.unified_custom_fields[n]=b({value:e.unified_custom_fields?.[n],type:s})))})),{...t}},h={build({functionName:e}){switch(e){case l.TYPECAST:return S;case l.MAP_FIELDS:return d;default:throw new Error(`Unknown step function: ${e}`)}}};export{l as StepFunctionName,h as StepFunctionsFactory};
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("@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 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,s=r(require("date-fns"));exports.StepFunctionName=void 0,(n=exports.StepFunctionName||(exports.StepFunctionName={})).TYPECAST="typecast",n.MAP_FIELDS="map_fields";const i=async({block:e})=>{const t=e?.fieldConfigs,r=[],n=e.steps;if(!t||"disabled"===e?.debug?.custom_mappings||!n)return e;let s;if(Array.isArray(e.result)){const i=e.result.length;s=e.result.map(((e,s)=>{const a=u(n,i,s),l=o(e,t,a);return r.push(...l.errors||[]),l.record}))}else{const i=o(e.result,t,n);s=i.record,r.push(...i.errors||[])}const i={output:{data:s},errors:Object.keys(r).length>0?r:void 0};return{...e,result:s,steps:{...n,[exports.StepFunctionName.MAP_FIELDS.toString()]:i}}},u=(e,t,r)=>Object.entries(e).reduce(((e,[n,s])=>{const i=s?.output?.data;return Array.isArray(i)&&i.length===t?e[n]={output:{data:i[r]}}:e[n]=s,e}),{}),o=(e,t,r)=>{if(!e||!r)return{record:e};const n={unified:{...e},..."object"==typeof r?r:{}},s={},i=[],u={...e};for(const r of t){const{error:t,value:o}=a(n,e.id,r);t?i.push(t):r.isUnified?u[r.targetFieldKey]=o:s[r.targetFieldKey]=o}return{record:{...u,unified_custom_fields:Object.keys(s).length>0?s:void 0},errors:i.length>0?i:void 0}},a=(t,r,n)=>{const{expression:s,targetFieldKey:i}=n;if(!s)return{error:{message:"Expression is empty",id:r,targetField:i}};let u;try{u=e.evaluate(s,t)}catch(e){return{error:{message:"Invalid expression",id:r,targetField:i}}}return void 0===u?{error:{message:"Expression returned no value",id:r,targetField:i}}:{value:u}},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=s.parseISO(e);if(s.isValid(t))return t;const r=new Date;for(const t of c){const n=s.parse(e,t,r);if(s.isValid(n))return n.setUTCHours(0,0,0,0),n}return null},y=({value:e,format:r=l})=>{const n=(({value:e,format:r=l})=>{if(t.isDate(e))return e;if(!t.isString(e))return null;try{const t=s.parse(e,r,new Date);return s.isValid(t)?t:d({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 p=({value:e,type:r,format:n})=>{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:n});default:return e}},g=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,r)=>{const n={...e};return r.forEach((r=>{const{targetFieldKey:s,type:i}=r;(e=>Object.values(f).includes(e))(i)&&(r.isUnified&&t.notMissing(n[s])?n[s]=p({value:e[s],type:i}):n.unified_custom_fields&&t.notMissing(n.unified_custom_fields?.[s])&&(n.unified_custom_fields[s]=p({value:e.unified_custom_fields?.[s],type:i})))})),{...n}},v={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}`)}}};exports.StepFunctionsFactory=v;
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,20 +1,37 @@
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';
1
5
  import type { StepsSnapshots } from '../steps/types';
2
6
  export type Block = {
3
- fieldConfigs?: FieldConfig[];
4
- result?: BlockIndexedRecord[] | BlockIndexedRecord;
7
+ inputs?: {
8
+ [key: string]: unknown;
9
+ };
10
+ connector?: Connector;
5
11
  context: BlockContext;
6
12
  debug?: DebugParams;
7
13
  steps?: StepsSnapshots;
14
+ httpClient?: IHttpClient;
15
+ logger?: ILogger;
16
+ operation?: Operation;
17
+ credentials?: Credentials;
18
+ outputs?: unknown;
19
+ fieldConfigs?: FieldConfig[];
20
+ result?: BlockIndexedRecord[] | BlockIndexedRecord;
8
21
  };
9
22
  export type BlockContext = {
10
23
  projectSecureId: string;
11
24
  accountSecureId: string;
12
25
  connector: string;
26
+ category: Category;
27
+ schema?: string;
28
+ operationType: OperationType;
29
+ authenticationType: string;
30
+ environment: string;
13
31
  service: string;
14
32
  resource: string;
15
33
  subResource?: string;
16
34
  childResource?: string;
17
- operationType: string;
18
35
  };
19
36
  export type BlockIndexedRecord = {
20
37
  id: string;
@@ -33,3 +50,4 @@ export type FieldConfig = {
33
50
  export type DebugParams = {
34
51
  custom_mappings?: 'disabled' | 'enabled';
35
52
  };
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,4 +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';
3
+ export { StepsSnapshots, Step } from './steps/types';
4
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
+ };
@@ -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,12 +1,28 @@
1
1
  import type { Block } from '../blocks/types';
2
+ import { StepError } from '../steps/types';
2
3
  export declare enum StepFunctionName {
3
4
  TYPECAST = "typecast",
4
- MAP_FIELDS = "map_fields"
5
+ MAP_FIELDS = "map_fields",
6
+ REQUEST = "request",
7
+ GROUP_RESULTS = "group_results"
5
8
  }
6
9
  export type StepFunction = ({ block, params, }: {
7
10
  block: Readonly<Block>;
8
11
  params?: StepFunctionParams;
9
- }) => Promise<Block>;
12
+ }) => Promise<StepFunctionOutput>;
10
13
  export type StepFunctionParams = {
11
14
  [key: string]: unknown;
12
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,12 +1,26 @@
1
+ import { StepFunctionMeta } from '../stepFunctions/types';
1
2
  export type StepSnapshot = {
2
3
  output?: {
3
- data: unknown;
4
+ [name: string]: unknown;
4
5
  };
6
+ successfull: boolean;
5
7
  errors?: StepError[];
6
8
  };
7
9
  export type StepsSnapshots = {
8
- [key: string]: StepSnapshot;
10
+ [stepId: string]: StepSnapshot;
9
11
  };
10
12
  export type StepError = {
11
13
  [key: string]: unknown;
12
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;
26
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",