@stackone/core 1.52.4 → 1.52.5

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.
Files changed (42) hide show
  1. package/dist/index.d.mts +426 -0
  2. package/dist/index.d.ts +426 -0
  3. package/dist/index.js +4794 -1
  4. package/dist/index.mjs +4756 -0
  5. package/package.json +22 -4
  6. package/dist/index.es.mjs +0 -1
  7. package/dist/types/accounts/types.d.ts +0 -10
  8. package/dist/types/blocks/types.d.ts +0 -70
  9. package/dist/types/categories/index.d.ts +0 -3
  10. package/dist/types/categories/types.d.ts +0 -6
  11. package/dist/types/compositeIds/constants.d.ts +0 -8
  12. package/dist/types/compositeIds/errors.d.ts +0 -18
  13. package/dist/types/compositeIds/index.d.ts +0 -4
  14. package/dist/types/compositeIds/typeguards.d.ts +0 -3
  15. package/dist/types/compositeIds/types.d.ts +0 -28
  16. package/dist/types/connector/types.d.ts +0 -113
  17. package/dist/types/cursor/index.d.ts +0 -15
  18. package/dist/types/cursor/schemas.d.ts +0 -67
  19. package/dist/types/cursor/types.d.ts +0 -21
  20. package/dist/types/errors/coreError.d.ts +0 -14
  21. package/dist/types/errors/typeguards.d.ts +0 -2
  22. package/dist/types/index.d.ts +0 -18
  23. package/dist/types/schema/types.d.ts +0 -17
  24. package/dist/types/stepFunctions/factory.d.ts +0 -10
  25. package/dist/types/stepFunctions/groupData/groupDataStepFunction.d.ts +0 -2
  26. package/dist/types/stepFunctions/groupData/schemas.d.ts +0 -18
  27. package/dist/types/stepFunctions/mapFields/getEnumMatcher.d.ts +0 -1
  28. package/dist/types/stepFunctions/mapFields/mapFieldsStepFunction.d.ts +0 -2
  29. package/dist/types/stepFunctions/mapFields/mapFieldsStepFunction.v2.d.ts +0 -2
  30. package/dist/types/stepFunctions/mapFields/schemas.d.ts +0 -99
  31. package/dist/types/stepFunctions/paginatedRequest/paginatedRequestStepFunction.d.ts +0 -2
  32. package/dist/types/stepFunctions/paginatedRequest/schemas.d.ts +0 -176
  33. package/dist/types/stepFunctions/request/requestStepFunction.d.ts +0 -2
  34. package/dist/types/stepFunctions/request/schemas.d.ts +0 -134
  35. package/dist/types/stepFunctions/stepFunctionsList.d.ts +0 -460
  36. package/dist/types/stepFunctions/typecast/schemas.d.ts +0 -48
  37. package/dist/types/stepFunctions/typecast/typecast.d.ts +0 -6
  38. package/dist/types/stepFunctions/typecast/typecastStepFunction.d.ts +0 -2
  39. package/dist/types/stepFunctions/typecast/typecastStepFunction.v2.d.ts +0 -2
  40. package/dist/types/stepFunctions/typecast/types.d.ts +0 -6
  41. package/dist/types/stepFunctions/types.d.ts +0 -29
  42. package/dist/types/steps/types.d.ts +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackone/core",
3
- "version": "1.52.4",
3
+ "version": "1.52.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.mjs",
@@ -10,12 +10,20 @@
10
10
  "package.json",
11
11
  "README.md"
12
12
  ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/types/index.d.ts",
16
+ "import": "./dist/index.es.mjs",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
13
21
  "scripts": {
14
22
  "clean": "rimraf dist",
15
23
  "prebuild": "npm run clean",
16
- "build": "rollup -c --environment NODE_ENV:production",
24
+ "build": "tsdown --env.NODE_ENV=production",
17
25
  "prebuild:dev": "npm run clean",
18
- "build:dev": "rollup -c --environment NODE_ENV:development",
26
+ "build:dev": "tsdown --env.NODE_ENV=development",
19
27
  "code:format": "biome format ./src ./*.mjs",
20
28
  "code:format:fix": "biome format --write ./src ./*.mjs",
21
29
  "code:lint": "biome lint --error-on-warnings ./src ./*.mjs",
@@ -35,5 +43,15 @@
35
43
  "@stackone/expressions": "*",
36
44
  "@stackone/transport": "*",
37
45
  "@stackone/utils": "*"
46
+ },
47
+ "devDependencies": {
48
+ "tsdown": "^0.12.9"
49
+ },
50
+ "tsdown": {
51
+ "dts": true,
52
+ "format": [
53
+ "esm",
54
+ "cjs"
55
+ ]
38
56
  }
39
- }
57
+ }
package/dist/index.es.mjs DELETED
@@ -1 +0,0 @@
1
- import{encodeToBase64 as e,isMissing as t,decodeFromBase64 as r,getContentHash as o,isString as n,notMissing as s,getCountrySubDivisionNameBySubDivisionCode as a,getCountryAlpha2CodeByCitizenship as i,getCountrySubDivisionCodeBySubDivisionName as u,getCountrySubDivisionsByAlpha2Code as c,getCountryCodeByCountryName as l,getCountryCodeByAlpha3Code as d,getCountryCodeByAlpha2Code as p,getCountryAlpha2CodeByCountryCode as m,getCountryAlpha2CodeByCountryName as g,getCountryAlpha2CodeByAlpha3Code as y,getCountryAlpha3CodeByCountryCode as b,getCountryAlpha3CodeByCountryName as f,getCountryAlpha3CodeByAlpha2Code as h,getCountryNameByCountryCode as _,getCountryNameByAlpha2Code as v,getCountryNameByAlpha3Code as S,getCountryNameByCountryName as k,getCountryCodeByCountryCode as E,getCountryAlpha3CodeByAlpha3Code as I,getCountryAlpha2CodeByAlpha2Code as w,safeParseToDateTimeString as x,safeParseToBoolean as C,safeParseToNumber as j,safeParseToString as F}from"@stackone/utils";import{z as T}from"zod";import{evaluate as A,safeEvaluateRecord as O}from"@stackone/expressions";import{CUSTOM_ERROR_CONFIG_SCHEMA as P,RequestParameterLocations as R,HttpMethods as D,RequestClientFactory as K,parseRequestParameters as N,createAuthorizationHeaders as M}from"@stackone/transport";const $={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"}},U=e=>$[e.toLowerCase()]??null,q=e=>!!$[e.toLowerCase()],L=e("so1!"),z=":",H=",",G=new RegExp(`(?<!\\\\)${z}`,"g"),B=new RegExp(`(?<!\\\\)${H}`,"g"),Q=1;class W extends Error{constructor({category:e,name:t,type:r,context:o,message:n}){super(n),this.name=t??"CoreError",this.type=r,this.category=e,this.context=o,Error.captureStackTrace&&Error.captureStackTrace(this,W)}toString(){const e=this.message?`: ${this.message}`:"";return`${this.category}-${this.name} [${this.type}]${e}`}}class Y extends W{constructor(e,t,r){super({category:"CompositeId",name:t??"BaseCompositeIdError",type:e,message:r})}}class J extends Y{constructor(e){super("COMPOSITE_ID_MISSING_HEADER_ERROR","CompositeIdMissingHeaderError",e??"Invalid compositeId, missing header")}}class V extends Y{constructor(e){super("COMPOSITE_ID_MISSING_BODY_ERROR","CompositeIdMissingBodyError",e??"Invalid compositeId, missing body")}}class X extends Y{constructor(e){super("COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR","CompositeIdUnknownIdentifierError",e??"Invalid compositeId, unknown identifier")}}class Z extends Y{constructor(e){super("COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR","CompositeIdUnsupportedVersionError",e??"Invalid compositeId, unsupported version")}}const ee=(e,t={version:1})=>{if(1===t.version)return ae(re(e,t.aliases));throw new Z(`Cannot generate ID, unsupported version number: ${t.version}`)},te=(e,t={version:1})=>{const r=se(e,t),o={};return r?(r.split(B).forEach((e=>{const[r,n]=e.split(G),s=ne(r,t.aliases??{});o[s]=ce(n)})),o):o},re=(e,r={})=>{if((e=>!t(e)&&"value"in e&&void 0!==e.value)(e))return oe({identifier:e,compositeIdAliases:r,isSoleIdentifier:!0});if((e=>!t(e)&&"identifiers"in e&&void 0!==e.identifiers)(e))return e.identifiers.map((e=>oe({identifier:e,compositeIdAliases:r,isSoleIdentifier:!1}))).join(H);throw new X},oe=({identifier:e,compositeIdAliases:t,isSoleIdentifier:r})=>[r?"id":t[e.key]||e.key,ue(e.value)].filter(Boolean).join(z),ne=(e,t)=>Object.keys(t).find((r=>t[r]===e))??e,se=(e,t)=>{if(1===t.version)return ie(e);throw new Z(`Cannot decode ID, unsupported version number: ${t.version}`)},ae=t=>`${L}${e(t)}`,ie=e=>{if(!e.startsWith(L))throw new J(`Trying to decode an ID without the header: ${e}`);const t=e.split(L)[1];if(!t)throw new V(`Trying to decode an ID without a body: ${e}`);return r(t)},ue=e=>[H,z].reduce(((e,t)=>e.replace(t,"\\"+t)),e),ce=e=>[H,z].reduce(((e,t)=>{const r="\\"+t;return e.replace(new RegExp("\\\\"+r,"g"),t)}),e),le=e=>!t(e)&&e.startsWith(L),de=T.object({r:T.record(T.string(),T.object({n:T.number().optional().nullable(),c:T.string().optional().nullable(),p:T.number().optional().nullable()})),v:T.number(),t:T.number()}),pe=T.object({remote:T.record(T.string(),T.object({pageNumber:T.number().optional(),providerPageCursor:T.string().optional(),position:T.number().optional()})),version:T.number(),timestamp:T.number()}),me=t=>e(JSON.stringify(ge(t))),ge=e=>{const{remote:t,version:r,timestamp:o}=e;return{r:Object.fromEntries(Object.entries(t).map((([e,{pageNumber:t,providerPageCursor:r,position:o}])=>[e,{n:t,c:r,p:o}]))),v:r,t:o}},ye=e=>{try{if(n(e)){const t=r(e),o=JSON.parse(t),n=de.parse(o);return be(n)}return pe.parse(e),e}catch{return null}},be=e=>{const{r:t,v:r,t:o}=e;return{remote:Object.fromEntries(Object.entries(t).map((([e,{n:t,c:r,p:o}])=>[e,{pageNumber:t,providerPageCursor:r,position:o}]))),version:r,timestamp:o}},fe=(e,t)=>{const r="string"==typeof e?ye(e):e,n="string"==typeof t?ye(t):t;if(null===r||null===n)return r===n;const{timestamp:s,...a}=r,{timestamp:i,...u}=n;return o(a)===o(u)},he=({cursor:e,ignoreStepIndex:r})=>!!t(e)||Object.keys(e?.remote??{}).reduce(((o,n)=>{const s=e?.remote?.[n];return(t(r)||n!==r.toString())&&(o=o&&t(s.pageNumber)&&t(s.position)&&t(s.providerPageCursor)),o}),!0),_e=({cursor:e,stepIndex:r,pageNumber:o,providerPageCursor:n,position:s})=>{const a={pageNumber:o??void 0,providerPageCursor:n??void 0,position:s??void 0},i=t(o)&&t(n)&&t(s);return t(e)?{remote:i?{}:{[r]:a},version:2,timestamp:Date.now()}:i?(delete e.remote[r],e):{...e,remote:{...e.remote,[r]:a}}},ve=e=>e instanceof W,Se=T.object({stepsDataToGroup:T.array(T.string()),isSingleRecord:T.boolean().optional()}),ke=T.object({data:T.unknown()}),Ee=(e,t,r)=>Object.entries(e).reduce(((e,[o,n])=>{const s=n?.output?.data;return Array.isArray(s)&&s.length===t?e[o]={output:{data:s[r]}}:e[o]=n,e}),{}),Ie=(e,t,r)=>{if(!e||!r)return{record:e};const o={unified:{...e},..."object"==typeof r?r:{}},n={},s=[],a={...e};for(const r of t){const{error:t,value:i}=we(o,e.id,r);t?s.push(t):r.custom?n[r.targetFieldKey]=i:a[r.targetFieldKey]=i}return{record:{...a,unified_custom_fields:Object.keys(n).length>0?n:void 0},errors:s.length>0?s:void 0}},we=(e,t,r)=>{const{expression:o,targetFieldKey:n}=r;if(!o)return{error:{message:"Expression is empty",id:t,targetField:n}};let s;try{s=A(o,e)}catch{return{error:{message:"Invalid expression",id:t,targetField:n}}}return void 0===s?{error:{message:"Expression returned no value",id:t,targetField:n}}:{value:s}},xe=T.object({fields:T.object({targetFieldKey:T.string(),alias:T.string().optional(),expression:T.string(),type:T.enum(["string","number","boolean","datetime_string","enum"]),custom:T.boolean().default(!1),hidden:T.boolean().default(!1),enumMapper:T.object({matcher:T.string().or(T.object({matchExpression:T.string(),value:T.string()}).array())}).optional()}).array(),dataSource:T.string()}),Ce=T.object({data:T.unknown()}),je=(e,t)=>{if(!t)return;const r={},o=[],n={};for(const s of e){const{error:e,value:a}=Fe(t,t?.id,s);e?o.push(e):s.custom?r[s.targetFieldKey]=a:n[s.targetFieldKey]=a}return{record:{...n,unified_custom_fields:Object.keys(r).length>0?r:void 0},errors:o.length>0?o:void 0}},Fe=(e,t,r)=>{switch(r.type){case"string":case"number":case"boolean":case"datetime_string":return Te(r,t,e);case"enum":return Ae(r,t,e);default:return{error:{message:"Invalid type",id:t,targetField:r.targetFieldKey}}}},Te=(e,t,r)=>{if(!e.expression)return{error:{message:"Expression is empty",id:t,targetField:e.targetFieldKey}};let o;try{o=A(e.expression,r)}catch{return{error:{message:"Invalid expression",id:t,targetField:e.targetFieldKey}}}return void 0===o?{error:{message:"Expression returned no value",id:t,targetField:e.targetFieldKey}}:{value:o}},Ae=(e,t,r)=>{const o=Te(e,t,r),x=s(o.value)?o.value:null;if(void 0===e.enumMapper)return{error:{message:"Enum mapper was not defined",id:t,targetField:e.targetFieldKey}};const C=e.enumMapper.matcher;if(n(C)){const r=(e=>{switch(e){case"country_alpha2code_by_alpha2code":return w;case"country_alpha3code_by_alpha3code":return I;case"country_code_by_country_code":return E;case"country_name_by_country_name":return k;case"country_name_by_alpha3code":return S;case"country_name_by_alpha2code":return v;case"country_name_by_country_code":return _;case"country_alpha3code_by_alpha2code":return h;case"country_alpha3code_by_country_name":return f;case"country_alpha3code_by_country_code":return b;case"country_alpha2code_by_alpha3code":return y;case"country_alpha2code_by_country_name":return g;case"country_alpha2code_by_country_code":return m;case"country_code_by_alpha2code":return p;case"country_code_by_alpha3code":return d;case"country_code_by_country_name":return l;case"country_subdivisions_by_alpha2code":return c;case"country_subdivision_code_by_subdivision_name":return u;case"country_alpha2code_by_citizenship":return i;case"country_subdivision_name_by_subdivision_code":return a;default:return}})(C);if(s(r)){return{value:{value:(s(x)?r(x):null)??"unmapped_value",source_value:x}}}return{error:{message:`The built-in matcher "${C}" is not supported`,id:t,targetField:e.targetFieldKey}}}for(const e of C){const{matchExpression:t,value:o}=e;if(!0===A(t,r))return{value:{value:o,source_value:x}}}return{value:{value:"unmapped_value",source_value:x}}},Oe=T.object({type:T.literal("basic"),username:T.string().optional(),password:T.string().optional(),encoding:T.string().optional()}),Pe=T.object({type:T.literal("bearer"),token:T.string()}),Re=T.discriminatedUnion("type",[Oe,Pe]),De=T.object({baseUrl:T.string(),url:T.string(),method:T.enum(D),response:T.object({indexField:T.string().optional(),dataKey:T.string().optional(),nextKey:T.string().optional()}).optional(),iterator:T.object({key:T.string(),in:T.enum(R)}),cursor:T.object({token:T.string().optional().nullable(),position:T.number().optional().nullable()}).optional(),customErrors:P.array().optional(),args:T.object({name:T.string(),value:T.unknown(),in:T.enum(R),condition:T.string().optional()}).array().optional()}),Ke=T.object({data:T.unknown().optional(),raw:T.unknown().optional(),statusCode:T.number(),message:T.string().optional(),next:T.string().optional().nullable(),position:T.number().optional()}).optional(),Ne=(e,t)=>{const r=De.parse(e),o=e?.authentication?.[t.context.authenticationType]?.[t.context.environment]?.authorization,n=Re.parse(o),s=r.args?N(r.args):{query:{},body:{},headers:{}},a=M(n),i={...s?.headers??{},...a},u=(e=>{const t=Number(e.inputs?.page_size);return Number.isNaN(t)?25:t})(t);return{requestConfig:r,preparedRequest:{parsedArgs:s,requestHeaders:i,pageSize:u}}},Me=async(e,t,r,o)=>{if(!t.httpClient)throw new Error("HTTP client is not configured");try{return await e.performRequest({httpClient:t.httpClient,url:`${r.baseUrl}${r.url}`,queryParams:o.parsedArgs?.query,method:r.method,headers:o.requestHeaders,body:o.parsedArgs?.body,customErrorConfigs:r.customErrors})}catch(e){const r=e;return{block:t,successful:!1,errors:[e],output:{statusCode:r?.response?.status??500,message:r?.response?.message}}}},$e=(e,t,r)=>{const o=t?.dataKey?e.data[t?.dataKey]:e.data,n=o?.slice(r.pagePosition,r.recordsLeft)??[];return r.recordsLeft=r.recordsLeft-n.length,r.pagePosition=r.pagePosition+n.length,r.raw.push(e),r.data=r.data.concat(n),r.lastStatusCode=e?.status,{resultData:o,slicedData:n}},Ue=(e,r,o,n,s,a)=>{const i=r?.nextKey?e.data[r?.nextKey]:void 0;o.nextIterator="string"==typeof i||"number"==typeof i?i:null,n.length===s.length&&0===o.recordsLeft&&(o.pagePosition=0,o.lastUsedIterator=o.nextIterator),o.noMoreData=t(o.nextIterator)&&o.data.length<a},qe=(e,t,r)=>s(e.nextIterator)&&e.data.length<t&&r?.length>0,Le=(e,t)=>{if(t?.indexField&&Array.isArray(e))return e.reduce(((e,r)=>{const o=t.indexField;return o&&r[o]&&(e[r[o]]=r),e}),{});if(t?.indexField){const r=t.indexField;return r&&e[r]?{[e[r]]:e}:e}return e},ze=T.object({type:T.literal("basic"),username:T.string().optional(),password:T.string().optional(),encoding:T.string().optional()}),He=T.object({type:T.literal("bearer"),token:T.string()}),Ge=T.discriminatedUnion("type",[ze,He]),Be=T.object({baseUrl:T.string(),url:T.string(),method:T.enum(D),response:T.object({collection:T.boolean().optional(),indexField:T.string().optional(),dataKey:T.string().optional()}).optional(),customErrors:P.array().optional(),args:T.object({name:T.string(),value:T.unknown(),in:T.enum(R),condition:T.string().optional()}).array().optional()}),Qe=T.object({data:T.unknown().optional(),raw:T.unknown().optional(),statusCode:T.number(),message:T.string().optional()}).optional(),We=(e,t)=>{if(t?.collection&&t?.indexField&&Array.isArray(e))return e.reduce(((e,r)=>{const o=t.indexField;return o&&r[o]&&(e[r[o]]=r),e}),{});if(!t?.collection&&t?.indexField){const r=t.indexField;return r&&e[r]?{[e[r]]:e}:e}return e},Ye=T.object({fields:T.object({targetFieldKey:T.string(),alias:T.string().optional(),type:T.string(),custom:T.boolean().default(!1),hidden:T.boolean().default(!1)}).array().optional(),dataSource:T.string()}),Je=T.object({data:T.unknown()});var Ve;!function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.DateTimeString="datetime_string"}(Ve||(Ve={}));const Xe=({value:e,type:r,format:o})=>{if(t(e))return null;switch(r){case Ve.String:return F({value:e});case Ve.Number:return j({value:e});case Ve.Boolean:return C({value:e});case Ve.DateTimeString:return x({value:e,format:o});default:return e}},Ze=e=>Object.values(Ve).includes(e),et=(e,t)=>{const r={...e};return t.forEach((t=>{const{targetFieldKey:o,type:n}=t;Ze(n)&&(!t.custom&&s(r[o])?r[o]=Xe({value:e[o],type:n}):r.unified_custom_fields&&s(r.unified_custom_fields?.[o])&&(r.unified_custom_fields[o]=Xe({value:e.unified_custom_fields?.[o],type:n})))})),{...r}},tt=(e,t)=>{const r={...e};return t.forEach((t=>{const{targetFieldKey:o,type:n}=t;Ze(n)&&(!t.custom&&s(r[o])?r[o]=Xe({value:e[o],type:n}):r.unified_custom_fields&&s(r.unified_custom_fields?.[o])&&(r.unified_custom_fields[o]=Xe({value:e.unified_custom_fields?.[o],type:n})))})),{...r}};var rt;!function(e){e.TYPECAST="typecast",e.MAP_FIELDS="map_fields",e.GROUP_DATA="group_data",e.REQUEST="request",e.PAGINATED_REQUEST="paginated_request"}(rt||(rt={}));const ot={[rt.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=>et(e,t))):et(e.result,t),{block:{...e,result:r},successful:!0}}},v2:{fn:async({block:e,params:t})=>{const{fields:r,dataSource:o}=Ye.parse(t),n=A(o,e);if(!r||"disabled"===e?.debug?.custom_mappings)return{block:e,successful:!0};let s;return s=Array.isArray(n)?n.map((e=>tt(e,r))):tt(n,r),{block:{...e},successful:!0,output:{data:s}}},inputSchema:Ye,outputSchema:Je}},[rt.MAP_FIELDS]:{v1:{fn:async({block:e})=>{const t=e?.fieldConfigs,r=[],o=e.steps;if(!t||"disabled"===e?.debug?.custom_mappings||!o)return{block:e,successful:!0};let n;if(Array.isArray(e.result)){const s=e.result.length;n=e.result.map(((e,n)=>{const a=Ee(o,s,n),i=Ie(e,t,a);return r.push(...i.errors||[]),i.record}))}else{const s=Ie(e.result,t,o);n=s.record,r.push(...s.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:o,dataSource:n}=xe.parse(t),s=A(n,e);if(!o||!n||"disabled"===e?.debug?.custom_mappings||!s)return{block:e,successful:!0};let a;if(Array.isArray(s))a=s.map((e=>{const t=je(o,e);return r.push(...t?.errors||[]),t?.record}));else{const e=je(o,s);a=e?.record,r.push(...e?.errors||[])}return{block:{...e},successful:!0,output:{data:a},errors:Object.keys(r).length>0?r:void 0}},inputSchema:xe,outputSchema:Ce}},[rt.REQUEST]:{v1:{fn:async({block:e,params:t})=>{const r=K.build();if(!e.httpClient)throw new Error("HTTP client is not configured");const{args:o}=t,n=o?o.filter((t=>!t.condition||!0===A(t.condition,e))).map((e=>({...e,condition:void 0}))):void 0,s=t?O({...t,args:n},e):{},a={...s,customErrors:t?.customErrors},{baseUrl:i,url:u,method:c,response:l,customErrors:d,args:p}=Be.parse(a),m=s?.authentication?.[e.context.authenticationType]?.[e.context.environment]?.authorization,g=Ge.parse(m),y=p?N(p):{query:{},body:{},headers:{}},b=M(g),f={...y?.headers??{},...b};let h;try{h=await r.performRequest({httpClient:e.httpClient,url:`${i}${u}`,queryParams:y?.query,method:c,headers:f,body:y?.body,customErrorConfigs:d})}catch(t){const r=t;return{block:e,successful:!1,errors:[t],output:{statusCode:r?.response?.status??500,message:r?.response?.message}}}const _=l?.dataKey?h.data[l?.dataKey]:h.data,v=We(_,l);return{block:e,successful:!0,output:{data:v,raw:h,statusCode:h?.status,message:h?.message}}},inputSchema:Be,outputSchema:Qe}},[rt.GROUP_DATA]:{v1:{fn:async({block:e,params:t})=>{const{stepsDataToGroup:r,isSingleRecord:o}=Se.parse(t),n=r.reduce(((t,r)=>{const n=e.steps?.[r]?.output?.data;return n?o?{...t,[r]:{...n}}:(Object.keys(n).forEach((e=>{const o=s(t[e])?t[e]:{};t[e]={...o,[r]:{...n[e]}}})),t):t}),{});return{block:{...e},successful:!0,output:{data:o?n:Object.values(n)}}},inputSchema:Se,outputSchema:ke}},[rt.PAGINATED_REQUEST]:{v1:{fn:async({block:e,params:t})=>{const r=K.build();if(!e.httpClient)throw new Error("HTTP client is not configured");const o=((e,t)=>{const{args:r}=e,o=r?r.filter((e=>!e.condition||!0===A(e.condition,t))).map((e=>({...e,condition:void 0}))):void 0;return{...e?O({...e,args:o},t):{},customErrors:e?.customErrors}})(t??{},e),{requestConfig:n,preparedRequest:s}=Ne(o,e),a=(i=n.cursor,u=s.pageSize,{nextIterator:i?.token??null,lastUsedIterator:null,lastStatusCode:null,data:[],raw:[],recordsLeft:u,pagePosition:i?.position??0,firstPage:!0,noMoreData:!0});var i,u,c,l,d;do{a.firstPage?a.firstPage=!1:a.pagePosition=0,c=s.parsedArgs,l=n.iterator,null!==(d=a.nextIterator)&&("query"===l.in?c.query[l.key]=d.toString():"body"===l.in&&(c.body[l.key]=d));const t=await Me(r,e,n,s);if("successful"in t&&!1===t.successful)return t;const o=t;a.lastUsedIterator=a.nextIterator;const{resultData:i,slicedData:u}=$e(o,n.response,a);Ue(o,n.response,a,u,i,s.pageSize)}while(qe(a,s.pageSize,a.data));return((e,t,r)=>({block:e,successful:!0,output:{data:Le(t.data,r),raw:t.raw,statusCode:t.lastStatusCode,next:t.noMoreData?void 0:t.lastUsedIterator,position:t.noMoreData?void 0:t.pagePosition}}))(e,a,n.response)},inputSchema:De,outputSchema:Ke}}},nt=(e,t)=>async({block:r,params:o})=>{try{e.inputSchema&&e.inputSchema.parse(o)}catch{return{block:r,successful:!1,errors:[{message:`Input parameters for ${t} are invalid`}]}}const n=await e.fn({block:r,params:o});try{e.outputSchema&&e.outputSchema.parse(n.output)}catch{return{block:r,successful:!1,errors:[{message:`Output data of ${t} has unexpected format`}]}}return n},st={build({functionName:e,version:t="1",validateSchemas:r=!1,stepFunctionsList:o=ot}){const n=o?.[e]?.[`v${t}`];if(!n)throw new Error(`Unknown step function: ${e} v${t}`);return r?{...n,fn:nt(n,e)}:n}};export{Ge as AUTHENTICATION_SCHEMA,Q as COMPOSITE_ID_LATEST_VERSION,W as CoreError,rt as StepFunctionName,st as StepFunctionsFactory,fe as areCursorsEqual,te as decodeCompositeId,ee as encodeCompositeId,ye as expandCursor,U as getCategoryDetails,le as isCompositeId,ve as isCoreError,he as isCursorEmpty,q as isValidCategory,me as minifyCursor,_e as updateCursor};
@@ -1,10 +0,0 @@
1
- export type Account = {
2
- providerKey: string;
3
- providerVersion: string;
4
- authConfigKey: string;
5
- environment: string;
6
- organizationId: number;
7
- secureId: string;
8
- credentials?: Record<string, unknown>;
9
- projectSecureId: string;
10
- };
@@ -1,70 +0,0 @@
1
- import { ILogger } from '@stackone/logger';
2
- import type { IHttpClient } from '@stackone/transport';
3
- import { Category } from '../categories/types';
4
- import { Connector, Operation, OperationType } from '../connector/types';
5
- import { Cursor } from '../cursor/types';
6
- import type { StepsSnapshots } from '../steps/types';
7
- export type Block = {
8
- inputs?: {
9
- [key: string]: unknown;
10
- };
11
- connector?: Connector;
12
- context: BlockContext;
13
- debug?: DebugParams;
14
- steps?: StepsSnapshots;
15
- httpClient?: IHttpClient;
16
- logger?: ILogger;
17
- operation?: Operation;
18
- credentials?: Credentials;
19
- outputs?: unknown;
20
- nextCursor?: Cursor | null;
21
- response?: {
22
- statusCode: number;
23
- successful: boolean;
24
- message?: string;
25
- };
26
- fieldConfigs?: FieldConfig[];
27
- result?: BlockIndexedRecord[] | BlockIndexedRecord;
28
- };
29
- export type BlockContext = {
30
- projectSecureId: string;
31
- accountSecureId: string;
32
- connectorKey: string;
33
- connectorVersion: string;
34
- category: Category;
35
- schema?: string;
36
- operationType: OperationType;
37
- authenticationType: string;
38
- environment: string;
39
- service: string;
40
- resource: string;
41
- subResource?: string;
42
- childResource?: string;
43
- };
44
- export type BlockIndexedRecord = {
45
- id: string;
46
- remote_id?: string;
47
- [key: string]: unknown;
48
- unified_custom_fields?: {
49
- [key: string]: unknown;
50
- };
51
- };
52
- export type EnumMatcherExpression = {
53
- matchExpression: string;
54
- value: string;
55
- };
56
- export type FieldConfig = {
57
- expression?: string;
58
- targetFieldKey: string;
59
- alias?: string;
60
- type: string;
61
- custom: boolean;
62
- hidden: boolean;
63
- enumMapper?: {
64
- matcher: string | EnumMatcherExpression[];
65
- };
66
- };
67
- export type DebugParams = {
68
- custom_mappings?: 'disabled' | 'enabled';
69
- };
70
- export type Credentials = Record<string, unknown>;
@@ -1,3 +0,0 @@
1
- import { CategoryDetails } from './types';
2
- export declare const getCategoryDetails: (category: string) => CategoryDetails | null;
3
- export declare const isValidCategory: (category: string) => boolean;
@@ -1,6 +0,0 @@
1
- export type Category = 'hris' | 'crm' | 'ats' | 'lms' | 'marketing' | 'filestorage';
2
- export type CategoryDetails = {
3
- title: string;
4
- key: Category;
5
- description: string;
6
- };
@@ -1,8 +0,0 @@
1
- export declare const COMPOSITE_ID_HEADER_V1 = "so1!";
2
- export declare const ENCODED_COMPOSITE_ID_HEADER_V1: string;
3
- export declare const COMPOSITE_ID_FIELD_SEPARATOR = ":";
4
- export declare const COMPOSITE_ID_COMPOSED_SEPARATOR = ",";
5
- export declare const COMPOSITE_ID_FIELD_SEPARATOR_REGEX: RegExp;
6
- export declare const COMPOSITE_ID_COMPOSED_SEPARATOR_REGEX: RegExp;
7
- export declare const COMPOSITE_ID_LATEST_VERSION = 1;
8
- export declare const IDENTIFIER_REGEX: RegExp;
@@ -1,18 +0,0 @@
1
- import { CoreError } from '../errors/coreError';
2
- import { CompositeIdError } from './types';
3
- declare class BaseCompositeIdError extends CoreError {
4
- constructor(type: CompositeIdError, name: string, message?: string);
5
- }
6
- export declare class CompositeIdMissingHeaderError extends BaseCompositeIdError {
7
- constructor(message?: string);
8
- }
9
- export declare class CompositeIdMissingBodyError extends BaseCompositeIdError {
10
- constructor(message?: string);
11
- }
12
- export declare class CompositeIdUnknownIdentifierError extends BaseCompositeIdError {
13
- constructor(message?: string);
14
- }
15
- export declare class CompositeIdUnsupportedVersionError extends BaseCompositeIdError {
16
- constructor(message?: string);
17
- }
18
- export {};
@@ -1,4 +0,0 @@
1
- import { CompositeIdentifier, CompositeIdentifierConfig } from './types';
2
- export declare const encodeCompositeId: (identifier: CompositeIdentifier, compositeIdConfig?: CompositeIdentifierConfig) => string;
3
- export declare const decodeCompositeId: (compositeId: string, compositeIdConfig?: CompositeIdentifierConfig) => Record<string, string>;
4
- export declare const isCompositeId: (value?: string | null) => boolean;
@@ -1,3 +0,0 @@
1
- import { CompositeIdentifier, MultipleIdentifier, SingleIdentifier } from './types';
2
- export declare const isSingleIdentifier: (identifier?: CompositeIdentifier) => identifier is SingleIdentifier;
3
- export declare const isMultipleIdentifier: (identifier?: CompositeIdentifier) => identifier is MultipleIdentifier;
@@ -1,28 +0,0 @@
1
- export type SingleIdentifier = {
2
- value: string;
3
- key: string;
4
- };
5
- export type MultipleIdentifier = {
6
- identifiers: Array<SingleIdentifier>;
7
- };
8
- export type CompositeIdentifier = MultipleIdentifier | SingleIdentifier;
9
- export type CompositeIdentifierConfig = {
10
- version: number;
11
- aliases?: Record<string, string>;
12
- };
13
- export type CompositeIdError = 'COMPOSITE_ID_MISSING_HEADER_ERROR' | 'COMPOSITE_ID_MISSING_BODY_ERROR' | 'COMPOSITE_ID_UNKNOWN_IDENTIFIER_ERROR' | 'COMPOSITE_ID_UNSUPPORTED_VERSION_ERROR';
14
- type ComponentConfig = {
15
- name: string;
16
- alias?: string;
17
- };
18
- type ComponentFieldConfig = {
19
- targetFieldKey: string;
20
- remote?: string;
21
- components: ComponentConfig[];
22
- };
23
- export type CompositeIdentifierConnectorConfig = {
24
- enabled: boolean;
25
- version?: number;
26
- fields?: ComponentFieldConfig[];
27
- };
28
- export {};
@@ -1,113 +0,0 @@
1
- import { HttpMethod } from '@stackone/transport';
2
- import { Category } from '../categories/types';
3
- import { CompositeIdentifierConnectorConfig } from '../compositeIds/types';
4
- import { Schema } from '../schema/types';
5
- import { Step } from '../steps/types';
6
- export type Connector = {
7
- title: string;
8
- version: string;
9
- key: string;
10
- description?: string;
11
- categories?: Category[];
12
- authentication?: Authentication;
13
- operations?: {
14
- [entrypointUrl: string]: Operation;
15
- };
16
- };
17
- export type OperationType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom' | 'unknown';
18
- export type InputLocation = 'body' | 'query' | 'path' | 'headers';
19
- export type Input = {
20
- name: string;
21
- type: string;
22
- required: boolean;
23
- description: string;
24
- in: InputLocation;
25
- };
26
- export type Operation = {
27
- id: string;
28
- categories: Category[];
29
- description: string;
30
- schema?: Schema;
31
- operationType: OperationType;
32
- entrypointUrl: string;
33
- entrypointHttpMethod: HttpMethod;
34
- inputs?: Input[];
35
- steps: {
36
- [stepId: string]: Step;
37
- };
38
- result?: string | Record<string, unknown>;
39
- responses: {
40
- success: OperationResponse;
41
- errors: Record<number, OperationResponse>;
42
- };
43
- cursor: {
44
- enabled: boolean;
45
- pageSize: number;
46
- };
47
- compositeIdentifiers: CompositeIdentifierConnectorConfig;
48
- scheduledJobs?: ScheduledJobConfig[];
49
- };
50
- type ScheduledJobConfig = {
51
- enabled: boolean;
52
- type: ScheduledJobType;
53
- schedule: string;
54
- description: string;
55
- requestParams?: ScheduledJobRequestParams;
56
- syncFilter?: SyncFilterConfig;
57
- };
58
- type ScheduledJobRequestParams = {
59
- fields?: string[];
60
- expand?: string[];
61
- filter?: Record<string, string>;
62
- };
63
- type ScheduledJobType = 'data_sync';
64
- type SyncFilterName = 'updated_after' | 'created_after';
65
- type SyncFilterConfig = {
66
- name: SyncFilterName;
67
- initialLoopbackPeriod: string;
68
- incrementalLoopbackPeriod: string;
69
- };
70
- export type OperationResponse = {
71
- statusCode: number;
72
- description?: string;
73
- };
74
- export type AuthenticationField = {
75
- key: string;
76
- label: string;
77
- type: 'text' | 'password' | 'select';
78
- options?: {
79
- value: string;
80
- label: string;
81
- }[];
82
- required: boolean;
83
- secret: boolean;
84
- readOnly: boolean;
85
- placeholder?: string;
86
- description?: string;
87
- tooltip?: string;
88
- };
89
- export type SupportConfig = {
90
- link: string;
91
- description?: string;
92
- };
93
- export type AuthenticationConfig = {
94
- envKey: string;
95
- envName: string;
96
- type: 'custom' | 'oauth2' | 'oidc';
97
- label: string;
98
- authorization: {
99
- type: 'basic' | 'bearer';
100
- [authParam: string]: unknown;
101
- };
102
- support?: SupportConfig;
103
- configFields?: AuthenticationField[];
104
- setupFields?: AuthenticationField[];
105
- testOperationsIds?: string[];
106
- };
107
- export type Authentication = {
108
- [authType: string]: {
109
- production: AuthenticationConfig;
110
- [envKey: string]: AuthenticationConfig;
111
- };
112
- };
113
- export {};
@@ -1,15 +0,0 @@
1
- import { Cursor } from './types';
2
- export declare const minifyCursor: (cursor: Cursor) => string;
3
- export declare const expandCursor: (minifiedCursor: unknown) => Cursor | null;
4
- export declare const areCursorsEqual: (first: string | Cursor, second: string | Cursor) => boolean;
5
- export declare const isCursorEmpty: ({ cursor, ignoreStepIndex, }: {
6
- cursor?: Cursor | null;
7
- ignoreStepIndex?: number;
8
- }) => boolean;
9
- export declare const updateCursor: ({ cursor, stepIndex, pageNumber, providerPageCursor, position, }: {
10
- cursor?: Cursor | null;
11
- stepIndex: number;
12
- pageNumber?: number | null;
13
- providerPageCursor?: string | null;
14
- position?: number | null;
15
- }) => Cursor;
@@ -1,67 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const MINIFIED_CURSOR_SCHEMA: z.ZodObject<{
3
- r: z.ZodRecord<z.ZodString, z.ZodObject<{
4
- n: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
5
- c: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
- p: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
- }, "strip", z.ZodTypeAny, {
8
- n?: number | null | undefined;
9
- c?: string | null | undefined;
10
- p?: number | null | undefined;
11
- }, {
12
- n?: number | null | undefined;
13
- c?: string | null | undefined;
14
- p?: number | null | undefined;
15
- }>>;
16
- v: z.ZodNumber;
17
- t: z.ZodNumber;
18
- }, "strip", z.ZodTypeAny, {
19
- r: Record<string, {
20
- n?: number | null | undefined;
21
- c?: string | null | undefined;
22
- p?: number | null | undefined;
23
- }>;
24
- v: number;
25
- t: number;
26
- }, {
27
- r: Record<string, {
28
- n?: number | null | undefined;
29
- c?: string | null | undefined;
30
- p?: number | null | undefined;
31
- }>;
32
- v: number;
33
- t: number;
34
- }>;
35
- export declare const CURSOR_SCHEMA: z.ZodObject<{
36
- remote: z.ZodRecord<z.ZodString, z.ZodObject<{
37
- pageNumber: z.ZodOptional<z.ZodNumber>;
38
- providerPageCursor: z.ZodOptional<z.ZodString>;
39
- position: z.ZodOptional<z.ZodNumber>;
40
- }, "strip", z.ZodTypeAny, {
41
- pageNumber?: number | undefined;
42
- providerPageCursor?: string | undefined;
43
- position?: number | undefined;
44
- }, {
45
- pageNumber?: number | undefined;
46
- providerPageCursor?: string | undefined;
47
- position?: number | undefined;
48
- }>>;
49
- version: z.ZodNumber;
50
- timestamp: z.ZodNumber;
51
- }, "strip", z.ZodTypeAny, {
52
- remote: Record<string, {
53
- pageNumber?: number | undefined;
54
- providerPageCursor?: string | undefined;
55
- position?: number | undefined;
56
- }>;
57
- version: number;
58
- timestamp: number;
59
- }, {
60
- remote: Record<string, {
61
- pageNumber?: number | undefined;
62
- providerPageCursor?: string | undefined;
63
- position?: number | undefined;
64
- }>;
65
- version: number;
66
- timestamp: number;
67
- }>;
@@ -1,21 +0,0 @@
1
- type Position = {
2
- pageNumber?: number | null;
3
- providerPageCursor?: string | null;
4
- position?: number | null;
5
- };
6
- type MinifiedPosition = {
7
- n?: number | null;
8
- c?: string | null;
9
- p?: number | null;
10
- };
11
- export type Cursor = {
12
- remote: Record<number, Position>;
13
- version: number;
14
- timestamp: number;
15
- };
16
- export type MinifiedCursor = {
17
- r: Record<number, MinifiedPosition>;
18
- v: number;
19
- t: number;
20
- };
21
- export {};
@@ -1,14 +0,0 @@
1
- import { BlockContext } from '../blocks/types';
2
- export declare class CoreError extends Error {
3
- readonly type: string;
4
- readonly category: string;
5
- readonly context?: BlockContext;
6
- constructor({ category, name, type, context, message, }: {
7
- category: string;
8
- name: string;
9
- type: string;
10
- context?: BlockContext;
11
- message?: string;
12
- });
13
- toString(): string;
14
- }
@@ -1,2 +0,0 @@
1
- import { CoreError } from './coreError';
2
- export declare const isCoreError: (error: unknown) => error is CoreError;
@@ -1,18 +0,0 @@
1
- export type { Account } from './accounts/types';
2
- export { Block, BlockContext, BlockIndexedRecord, FieldConfig, } from './blocks/types';
3
- export { getCategoryDetails, isValidCategory } from './categories';
4
- export { Category } from './categories/types';
5
- export { decodeCompositeId, encodeCompositeId, isCompositeId } from './compositeIds';
6
- export { COMPOSITE_ID_LATEST_VERSION } from './compositeIds/constants';
7
- export { CompositeIdentifier, CompositeIdentifierConfig, CompositeIdentifierConnectorConfig, } from './compositeIds/types';
8
- export { Authentication, AuthenticationConfig, AuthenticationField, Connector, Input, InputLocation, Operation, OperationResponse, OperationType, SupportConfig, } from './connector/types';
9
- export { areCursorsEqual, expandCursor, isCursorEmpty, minifyCursor, updateCursor } from './cursor';
10
- export type { Cursor } from './cursor/types';
11
- export { CoreError } from './errors/coreError';
12
- export { isCoreError } from './errors/typeguards';
13
- export { Schema, SchemaField } from './schema/types';
14
- export { StepFunctionsFactory } from './stepFunctions/factory';
15
- export { AUTHENTICATION_SCHEMA } from './stepFunctions/request/schemas';
16
- export { StepFunctionName } from './stepFunctions/stepFunctionsList';
17
- export { StepFunction, StepFunctionOutput, StepFunctionParams } from './stepFunctions/types';
18
- export { Step, StepsSnapshots } from './steps/types';
@@ -1,17 +0,0 @@
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,10 +0,0 @@
1
- import { StepFunctionName } from './stepFunctionsList';
2
- import type { StepFunctionInstance } from './types';
3
- export declare const StepFunctionsFactory: {
4
- build({ functionName, version, validateSchemas, stepFunctionsList, }: {
5
- functionName: StepFunctionName;
6
- version?: string;
7
- validateSchemas?: boolean;
8
- stepFunctionsList?: Record<string, Record<string, StepFunctionInstance>>;
9
- }): StepFunctionInstance;
10
- };
@@ -1,2 +0,0 @@
1
- import type { StepFunction } from '../types';
2
- export declare const groupDataStepFunction: StepFunction;
@@ -1,18 +0,0 @@
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
- }>;
@@ -1 +0,0 @@
1
- export declare const getEnumMatcher: (matcher: string) => ((value: unknown) => unknown) | undefined;
@@ -1,2 +0,0 @@
1
- import { StepFunction } from '../types';
2
- export declare const mapFieldsStepFunction: StepFunction;
@@ -1,2 +0,0 @@
1
- import type { StepFunction } from '../types';
2
- export declare const mapFieldsStepFunction: StepFunction;