@stackone/connect-sdk 1.11.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/types/blocks/createBlock.d.ts +3 -2
- package/dist/types/connectors/schemas.d.ts +188 -48
- package/dist/types/connectors/specs/examples/testConnectorWithoutOperations.d.ts +2 -0
- package/dist/types/errors/connectSDKErrors.d.ts +15 -0
- package/dist/types/errors/types.d.ts +1 -0
- package/dist/types/runners/runConnectorOperation.d.ts +20 -0
- package/package.json +4 -3
package/dist/index.es.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{StepFunctionsFactory as t,StepFunctionName as e,AUTHENTICATION_SCHEMA as n}from"@stackone/core";import{safeEvaluate as o}from"@stackone/expressions";import{notMissing as r}from"@stackone/utils";import{parse as i}from"yaml";import{z as s}from"zod";import{HttpClientManager as a}from"@stackone/transport";import{match as c}from"path-to-regexp";const p=async({block:n,stepFunctionName:o,params:r,buildStepFunction:i=t.build})=>{const s=i({functionName:o}).fn,a=await s({block:n,params:r}),c=o===e.MAP_FIELDS?{[e.MAP_FIELDS.toString()]:{output:{data:a.block.result},errors:a.errors,successful:a.successful}}:{};return{...a.block,steps:{...a?.block?.steps??{},...c}}},u=async({block:e,buildStepFunction:n=t.build})=>{const r=e.operation?.steps||[];let i={...e};const s=Object.keys(r);for(const t of s){const e=r[t].stepFunction,o=n({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await o({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=e.operation?.result?o(e.operation.result,i):void 0;return{...i,outputs:a}},l=s.object({key:s.string(),label:s.string(),type:s.string(),required:s.boolean().optional(),secret:s.boolean().optional(),placeholder:s.string().optional(),description:s.string().optional(),tooltip:s.string().optional()}),d=s.object({operationId:s.string(),categories:s.string().array(),operationType:s.string(),schema:s.string().optional(),entrypointUrl:s.string().optional(),entrypointHttpMethod:s.string().optional(),description:s.string(),inputs:s.object({name:s.string(),type:s.string(),required:s.boolean(),description:s.string(),in:s.string()}).array().optional(),fieldConfigs:s.object({targetFieldKey:s.string(),expression:s.string(),type:s.string(),isUnified:s.boolean()}).array(),steps:s.object({stepId:s.string(),description:s.string(),stepFunction:s.object({functionName:s.string(),version:s.string().optional(),parameters:s.record(s.string(),s.unknown())})}).array(),result:s.string()}),g=s.object({StackOne:s.string(),info:s.object({title:s.string(),version:s.string(),key:s.string(),description:s.string().optional()}),baseUrl:s.string(),authentication:s.record(s.string(),s.object({type:s.string(),label:s.string(),authorization:n,environments:s.object({key:s.string(),name:s.string()}).array(),support:s.object({link:s.string(),description:s.string().optional()}),configFields:l.array().optional(),setupFields:l.array().optional(),testOperationsIds:s.string().array().optional()})).array().optional(),operations:d.array().optional()});function y(t){try{const e=i(t),n=g.parse(e),o={title:n.info.title,version:n.info.version,key:n.info.key,description:n.info.description},s=b(n),a={baseUrl:n.baseUrl,authentication:f(s)},c=h(n,a);return o.operations=c,o.authentication=s,r(c)&&(o.categories=m(Object.values(c))),o}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}}const f=t=>{const e={};for(const[n,o]of Object.entries(t))if(o&&"object"==typeof o){const{setupFields:t,configFields:r,support:i,testOperationsIds:s,...a}=o;e[n]=f(a)}else e[n]=o;return e},m=t=>{const e=t.reduce(((t,e)=>{for(const n of e.categories)t.add(n);return t}),new Set);return Array.from(e)},b=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),o=n[t].environments.reduce(((e,o)=>{const{key:r,name:i}=o,{environments:s,...a}=n[t];return e[r]={...a,envKey:r,envName:i},e}),{});e[t]=o}return e},h=(t,e)=>{const n=t.operations?.reduce(((t,n)=>{const o=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),r=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[o??r]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,o)=>(t[o.stepId]={id:o.stepId,description:o.description,stepFunction:{functionName:o.stepFunction.functionName,version:o.stepFunction.version,params:{..."request"===o.stepFunction.functionName?e:{},..."map_fields"===o.stepFunction.functionName||"typecast"===o.stepFunction.functionName?{fields:n.fieldConfigs}:{},...o.stepFunction.parameters}}},t)),{}),result:n.result},t}),{});return n},k=(t,e)=>{if(!t.inputs)return{};const n=v(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},j=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=s.string();break;case"number":n=s.number();break;case"boolean":n=s.boolean();break;default:n=s.any()}e[t.name]=t.required?n:n.optional()})),s.object(e)},v=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),r=t.filter((t=>"headers"===t.in));return s.object({path:j(e).optional(),query:j(n).optional(),body:j(o).optional(),headers:j(r).optional()})},F=async({inputs:t,category:e,connectorKey:n,connectorVersion:o,authConfigKey:r,environment:i="production",operation:s,accountSecureId:c,projectSecureId:p,credentials:u,logger:l,getHttpClient:d=async()=>a.getInstance()})=>{const g=await d();return{inputs:t,fieldConfigs:[],context:{projectSecureId:p,accountSecureId:c,connectorKey:n,connectorVersion:o,category:e,schema:s.schema?.key,service:"",resource:"",operationType:s.operationType,authenticationType:r,environment:i},operation:s,credentials:u,httpClient:g,logger:l}},I=(t,e,n)=>{const o=n.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=N(e,o,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},S=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},N=(t,e,n)=>{const o=S(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),r=c(S(n))(S(o));if(!1!==r)return{path:t,params:r.params}}};export{F as createBlock,p as executeStepFunction,I as getOperationFromUrl,k as parseOperationInputs,y as parseYamlConnector,u as runStepOperation};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@stackone/core"),e=require("@stackone/expressions"),n=require("yaml"),r=require("zod"),
|
|
1
|
+
"use strict";var t=require("@stackone/core"),e=require("@stackone/expressions"),n=require("@stackone/utils"),o=require("yaml"),r=require("zod"),i=require("@stackone/transport"),s=require("path-to-regexp");const a=r.z.object({key:r.z.string(),label:r.z.string(),type:r.z.string(),required:r.z.boolean().optional(),secret:r.z.boolean().optional(),placeholder:r.z.string().optional(),description:r.z.string().optional(),tooltip:r.z.string().optional()}),c=r.z.object({operationId:r.z.string(),categories:r.z.string().array(),operationType:r.z.string(),schema:r.z.string().optional(),entrypointUrl:r.z.string().optional(),entrypointHttpMethod:r.z.string().optional(),description:r.z.string(),inputs:r.z.object({name:r.z.string(),type:r.z.string(),required:r.z.boolean(),description:r.z.string(),in:r.z.string()}).array().optional(),fieldConfigs:r.z.object({targetFieldKey:r.z.string(),expression:r.z.string(),type:r.z.string(),isUnified:r.z.boolean()}).array(),steps:r.z.object({stepId:r.z.string(),description:r.z.string(),stepFunction:r.z.object({functionName:r.z.string(),version:r.z.string().optional(),parameters:r.z.record(r.z.string(),r.z.unknown())})}).array(),result:r.z.string()}),p=r.z.object({StackOne:r.z.string(),info:r.z.object({title:r.z.string(),version:r.z.string(),key:r.z.string(),description:r.z.string().optional()}),baseUrl:r.z.string(),authentication:r.z.record(r.z.string(),r.z.object({type:r.z.string(),label:r.z.string(),authorization:t.AUTHENTICATION_SCHEMA,environments:r.z.object({key:r.z.string(),name:r.z.string()}).array(),support:r.z.object({link:r.z.string(),description:r.z.string().optional()}),configFields:a.array().optional(),setupFields:a.array().optional(),testOperationsIds:r.z.string().array().optional()})).array().optional(),operations:c.array().optional()});const u=t=>{const e={};for(const[n,o]of Object.entries(t))if(o&&"object"==typeof o){const{setupFields:t,configFields:r,support:i,testOperationsIds:s,...a}=o;e[n]=u(a)}else e[n]=o;return e},l=t=>{const e=t.reduce(((t,e)=>{for(const n of e.categories)t.add(n);return t}),new Set);return Array.from(e)},d=t=>{const e={};for(const n of t.authentication??[]){const[t]=Object.keys(n),o=n[t].environments.reduce(((e,o)=>{const{key:r,name:i}=o,{environments:s,...a}=n[t];return e[r]={...a,envKey:r,envName:i},e}),{});e[t]=o}return e},g=(t,e)=>{const n=t.operations?.reduce(((t,n)=>{const o=(t=>t.entrypointUrl&&t.entrypointHttpMethod?`${t.entrypointHttpMethod.toUpperCase()} ${t.entrypointUrl}`:void 0)(n),r=(t=>"list"===t.operationType?`GET /${t.schema}`:`GET /${t.schema}/:id`)(n),i=(t=>"list"===t.operationType?`/${t.schema}`:`/${t.schema}/:id`)(n);return t[o??r]={id:n.operationId,categories:n.categories,description:n.description,operationType:n.operationType,entrypointUrl:n.entrypointUrl??i,entrypointHttpMethod:n.entrypointHttpMethod??"get",inputs:n.inputs,steps:n.steps.reduce(((t,o)=>(t[o.stepId]={id:o.stepId,description:o.description,stepFunction:{functionName:o.stepFunction.functionName,version:o.stepFunction.version,params:{..."request"===o.stepFunction.functionName?e:{},..."map_fields"===o.stepFunction.functionName||"typecast"===o.stepFunction.functionName?{fields:n.fieldConfigs}:{},...o.stepFunction.parameters}}},t)),{}),result:n.result},t}),{});return n},y=t=>{const e={};return t.forEach((t=>{let n;switch(t.type.toLowerCase()){case"string":n=r.z.string();break;case"number":n=r.z.number();break;case"boolean":n=r.z.boolean();break;default:n=r.z.any()}e[t.name]=t.required?n:n.optional()})),r.z.object(e)},z=t=>{const e=t.filter((t=>"path"===t.in)),n=t.filter((t=>"query"===t.in)),o=t.filter((t=>"body"===t.in)),i=t.filter((t=>"headers"===t.in));return r.z.object({path:y(e).optional(),query:y(n).optional(),body:y(o).optional(),headers:y(i).optional()})},f=t=>{const e=t.startsWith("/")?t.slice(1):t;return e.endsWith("/")?e.slice(0,-1):e},b=(t,e,n)=>{const o=f(t);for(const t of n)if(t.startsWith(e)){const n=t.replace(`${e} `,"").trim(),r=s.match(f(n))(f(o));if(!1!==r)return{path:t,params:r.params}}};exports.createBlock=async({inputs:t,category:e,connectorKey:n,connectorVersion:o,authConfigKey:r,environment:s="production",operation:a,accountSecureId:c,projectSecureId:p,credentials:u,logger:l,getHttpClient:d=async()=>i.HttpClientManager.getInstance()})=>{const g=await d();return{inputs:t,fieldConfigs:[],context:{projectSecureId:p,accountSecureId:c,connectorKey:n,connectorVersion:o,category:e,schema:a.schema?.key,service:"",resource:"",operationType:a.operationType,authenticationType:r,environment:s},operation:a,credentials:u,httpClient:g,logger:l}},exports.executeStepFunction=async({block:e,stepFunctionName:n,params:o,buildStepFunction:r=t.StepFunctionsFactory.build})=>{const i=r({functionName:n}).fn,s=await i({block:e,params:o}),a=n===t.StepFunctionName.MAP_FIELDS?{[t.StepFunctionName.MAP_FIELDS.toString()]:{output:{data:s.block.result},errors:s.errors,successful:s.successful}}:{};return{...s.block,steps:{...s?.block?.steps??{},...a}}},exports.getOperationFromUrl=(t,e,n)=>{const o=n.toUpperCase();if(!t.operations)return;const r=Object.keys(t.operations),i=b(e,o,r);return i?{operation:t.operations?.[i.path],params:i.params}:void 0},exports.parseOperationInputs=(t,e)=>{if(!t.inputs)return{};const n=z(t.inputs).parse(e);return{...n.headers??{},...n.query??{},...n.path??{},...n.body??{}}},exports.parseYamlConnector=function(t){try{const e=o.parse(t),r=p.parse(e),i={title:r.info.title,version:r.info.version,key:r.info.key,description:r.info.description},s=d(r),a={baseUrl:r.baseUrl,authentication:u(s)},c=g(r,a);return i.operations=c,i.authentication=s,n.notMissing(c)&&(i.categories=l(Object.values(c))),i}catch(t){throw new Error(`Error parsing YAML file: ${t.message}`)}},exports.runStepOperation=async({block:n,buildStepFunction:o=t.StepFunctionsFactory.build})=>{const r=n.operation?.steps||[];let i={...n};const s=Object.keys(r);for(const t of s){const e=r[t].stepFunction,n=o({functionName:e.functionName,version:e.version,validateSchemas:!0}).fn,s=await n({block:i,params:e.params});i={...s.block,steps:{...s.block.steps,[t]:{successful:s.successful,errors:s.errors,output:s.output}}}}const a=n.operation?.result?e.safeEvaluate(n.operation.result,i):void 0;return{...i,outputs:a}};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Block, Category, ILogger, Operation } from '@stackone/core';
|
|
2
2
|
import { IHttpClient } from '@stackone/transport';
|
|
3
|
-
export declare const createBlock: ({ inputs, category,
|
|
3
|
+
export declare const createBlock: ({ inputs, category, connectorKey, connectorVersion, authConfigKey, environment, operation, accountSecureId, projectSecureId, credentials, logger, getHttpClient, }: {
|
|
4
4
|
inputs?: Record<string, unknown>;
|
|
5
5
|
category: Category;
|
|
6
|
-
|
|
6
|
+
connectorKey: string;
|
|
7
|
+
connectorVersion: string;
|
|
7
8
|
authConfigKey: string;
|
|
8
9
|
environment?: string;
|
|
9
10
|
operation: Operation;
|
|
@@ -1,4 +1,144 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const OPERATION_SCHEMA: z.ZodObject<{
|
|
3
|
+
operationId: z.ZodString;
|
|
4
|
+
categories: z.ZodArray<z.ZodString, "many">;
|
|
5
|
+
operationType: z.ZodString;
|
|
6
|
+
schema: z.ZodOptional<z.ZodString>;
|
|
7
|
+
entrypointUrl: z.ZodOptional<z.ZodString>;
|
|
8
|
+
entrypointHttpMethod: z.ZodOptional<z.ZodString>;
|
|
9
|
+
description: z.ZodString;
|
|
10
|
+
inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
required: z.ZodBoolean;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
in: z.ZodString;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
type: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
name: string;
|
|
21
|
+
in: string;
|
|
22
|
+
}, {
|
|
23
|
+
type: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
description: string;
|
|
26
|
+
name: string;
|
|
27
|
+
in: string;
|
|
28
|
+
}>, "many">>;
|
|
29
|
+
fieldConfigs: z.ZodArray<z.ZodObject<{
|
|
30
|
+
targetFieldKey: z.ZodString;
|
|
31
|
+
expression: z.ZodString;
|
|
32
|
+
type: z.ZodString;
|
|
33
|
+
isUnified: z.ZodBoolean;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
type: string;
|
|
36
|
+
targetFieldKey: string;
|
|
37
|
+
expression: string;
|
|
38
|
+
isUnified: boolean;
|
|
39
|
+
}, {
|
|
40
|
+
type: string;
|
|
41
|
+
targetFieldKey: string;
|
|
42
|
+
expression: string;
|
|
43
|
+
isUnified: boolean;
|
|
44
|
+
}>, "many">;
|
|
45
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
46
|
+
stepId: z.ZodString;
|
|
47
|
+
description: z.ZodString;
|
|
48
|
+
stepFunction: z.ZodObject<{
|
|
49
|
+
functionName: z.ZodString;
|
|
50
|
+
version: z.ZodOptional<z.ZodString>;
|
|
51
|
+
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
functionName: string;
|
|
54
|
+
parameters: Record<string, unknown>;
|
|
55
|
+
version?: string | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
functionName: string;
|
|
58
|
+
parameters: Record<string, unknown>;
|
|
59
|
+
version?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
description: string;
|
|
63
|
+
stepId: string;
|
|
64
|
+
stepFunction: {
|
|
65
|
+
functionName: string;
|
|
66
|
+
parameters: Record<string, unknown>;
|
|
67
|
+
version?: string | undefined;
|
|
68
|
+
};
|
|
69
|
+
}, {
|
|
70
|
+
description: string;
|
|
71
|
+
stepId: string;
|
|
72
|
+
stepFunction: {
|
|
73
|
+
functionName: string;
|
|
74
|
+
parameters: Record<string, unknown>;
|
|
75
|
+
version?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
}>, "many">;
|
|
78
|
+
result: z.ZodString;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
description: string;
|
|
81
|
+
operationId: string;
|
|
82
|
+
categories: string[];
|
|
83
|
+
operationType: string;
|
|
84
|
+
fieldConfigs: {
|
|
85
|
+
type: string;
|
|
86
|
+
targetFieldKey: string;
|
|
87
|
+
expression: string;
|
|
88
|
+
isUnified: boolean;
|
|
89
|
+
}[];
|
|
90
|
+
steps: {
|
|
91
|
+
description: string;
|
|
92
|
+
stepId: string;
|
|
93
|
+
stepFunction: {
|
|
94
|
+
functionName: string;
|
|
95
|
+
parameters: Record<string, unknown>;
|
|
96
|
+
version?: string | undefined;
|
|
97
|
+
};
|
|
98
|
+
}[];
|
|
99
|
+
result: string;
|
|
100
|
+
schema?: string | undefined;
|
|
101
|
+
entrypointUrl?: string | undefined;
|
|
102
|
+
entrypointHttpMethod?: string | undefined;
|
|
103
|
+
inputs?: {
|
|
104
|
+
type: string;
|
|
105
|
+
required: boolean;
|
|
106
|
+
description: string;
|
|
107
|
+
name: string;
|
|
108
|
+
in: string;
|
|
109
|
+
}[] | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
description: string;
|
|
112
|
+
operationId: string;
|
|
113
|
+
categories: string[];
|
|
114
|
+
operationType: string;
|
|
115
|
+
fieldConfigs: {
|
|
116
|
+
type: string;
|
|
117
|
+
targetFieldKey: string;
|
|
118
|
+
expression: string;
|
|
119
|
+
isUnified: boolean;
|
|
120
|
+
}[];
|
|
121
|
+
steps: {
|
|
122
|
+
description: string;
|
|
123
|
+
stepId: string;
|
|
124
|
+
stepFunction: {
|
|
125
|
+
functionName: string;
|
|
126
|
+
parameters: Record<string, unknown>;
|
|
127
|
+
version?: string | undefined;
|
|
128
|
+
};
|
|
129
|
+
}[];
|
|
130
|
+
result: string;
|
|
131
|
+
schema?: string | undefined;
|
|
132
|
+
entrypointUrl?: string | undefined;
|
|
133
|
+
entrypointHttpMethod?: string | undefined;
|
|
134
|
+
inputs?: {
|
|
135
|
+
type: string;
|
|
136
|
+
required: boolean;
|
|
137
|
+
description: string;
|
|
138
|
+
name: string;
|
|
139
|
+
in: string;
|
|
140
|
+
}[] | undefined;
|
|
141
|
+
}>;
|
|
2
142
|
export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
3
143
|
StackOne: z.ZodString;
|
|
4
144
|
info: z.ZodObject<{
|
|
@@ -8,13 +148,13 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
8
148
|
description: z.ZodOptional<z.ZodString>;
|
|
9
149
|
}, "strip", z.ZodTypeAny, {
|
|
10
150
|
key: string;
|
|
11
|
-
title: string;
|
|
12
151
|
version: string;
|
|
152
|
+
title: string;
|
|
13
153
|
description?: string | undefined;
|
|
14
154
|
}, {
|
|
15
155
|
key: string;
|
|
16
|
-
title: string;
|
|
17
156
|
version: string;
|
|
157
|
+
title: string;
|
|
18
158
|
description?: string | undefined;
|
|
19
159
|
}>;
|
|
20
160
|
baseUrl: z.ZodString;
|
|
@@ -206,7 +346,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
206
346
|
}[] | undefined;
|
|
207
347
|
testOperationsIds?: string[] | undefined;
|
|
208
348
|
}>>, "many">>;
|
|
209
|
-
operations: z.ZodArray<z.ZodObject<{
|
|
349
|
+
operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
210
350
|
operationId: z.ZodString;
|
|
211
351
|
categories: z.ZodArray<z.ZodString, "many">;
|
|
212
352
|
operationType: z.ZodString;
|
|
@@ -345,48 +485,16 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
345
485
|
name: string;
|
|
346
486
|
in: string;
|
|
347
487
|
}[] | undefined;
|
|
348
|
-
}>, "many"
|
|
488
|
+
}>, "many">>;
|
|
349
489
|
}, "strip", z.ZodTypeAny, {
|
|
350
490
|
StackOne: string;
|
|
351
491
|
info: {
|
|
352
492
|
key: string;
|
|
353
|
-
title: string;
|
|
354
493
|
version: string;
|
|
494
|
+
title: string;
|
|
355
495
|
description?: string | undefined;
|
|
356
496
|
};
|
|
357
497
|
baseUrl: string;
|
|
358
|
-
operations: {
|
|
359
|
-
description: string;
|
|
360
|
-
operationId: string;
|
|
361
|
-
categories: string[];
|
|
362
|
-
operationType: string;
|
|
363
|
-
fieldConfigs: {
|
|
364
|
-
type: string;
|
|
365
|
-
targetFieldKey: string;
|
|
366
|
-
expression: string;
|
|
367
|
-
isUnified: boolean;
|
|
368
|
-
}[];
|
|
369
|
-
steps: {
|
|
370
|
-
description: string;
|
|
371
|
-
stepId: string;
|
|
372
|
-
stepFunction: {
|
|
373
|
-
functionName: string;
|
|
374
|
-
parameters: Record<string, unknown>;
|
|
375
|
-
version?: string | undefined;
|
|
376
|
-
};
|
|
377
|
-
}[];
|
|
378
|
-
result: string;
|
|
379
|
-
schema?: string | undefined;
|
|
380
|
-
entrypointUrl?: string | undefined;
|
|
381
|
-
entrypointHttpMethod?: string | undefined;
|
|
382
|
-
inputs?: {
|
|
383
|
-
type: string;
|
|
384
|
-
required: boolean;
|
|
385
|
-
description: string;
|
|
386
|
-
name: string;
|
|
387
|
-
in: string;
|
|
388
|
-
}[] | undefined;
|
|
389
|
-
}[];
|
|
390
498
|
authentication?: Record<string, {
|
|
391
499
|
label: string;
|
|
392
500
|
type: string;
|
|
@@ -429,16 +537,7 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
429
537
|
}[] | undefined;
|
|
430
538
|
testOperationsIds?: string[] | undefined;
|
|
431
539
|
}>[] | undefined;
|
|
432
|
-
|
|
433
|
-
StackOne: string;
|
|
434
|
-
info: {
|
|
435
|
-
key: string;
|
|
436
|
-
title: string;
|
|
437
|
-
version: string;
|
|
438
|
-
description?: string | undefined;
|
|
439
|
-
};
|
|
440
|
-
baseUrl: string;
|
|
441
|
-
operations: {
|
|
540
|
+
operations?: {
|
|
442
541
|
description: string;
|
|
443
542
|
operationId: string;
|
|
444
543
|
categories: string[];
|
|
@@ -469,7 +568,16 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
469
568
|
name: string;
|
|
470
569
|
in: string;
|
|
471
570
|
}[] | undefined;
|
|
472
|
-
}[];
|
|
571
|
+
}[] | undefined;
|
|
572
|
+
}, {
|
|
573
|
+
StackOne: string;
|
|
574
|
+
info: {
|
|
575
|
+
key: string;
|
|
576
|
+
version: string;
|
|
577
|
+
title: string;
|
|
578
|
+
description?: string | undefined;
|
|
579
|
+
};
|
|
580
|
+
baseUrl: string;
|
|
473
581
|
authentication?: Record<string, {
|
|
474
582
|
label: string;
|
|
475
583
|
type: string;
|
|
@@ -512,4 +620,36 @@ export declare const CONNECTOR_YAML_SCHEMA: z.ZodObject<{
|
|
|
512
620
|
}[] | undefined;
|
|
513
621
|
testOperationsIds?: string[] | undefined;
|
|
514
622
|
}>[] | undefined;
|
|
623
|
+
operations?: {
|
|
624
|
+
description: string;
|
|
625
|
+
operationId: string;
|
|
626
|
+
categories: string[];
|
|
627
|
+
operationType: string;
|
|
628
|
+
fieldConfigs: {
|
|
629
|
+
type: string;
|
|
630
|
+
targetFieldKey: string;
|
|
631
|
+
expression: string;
|
|
632
|
+
isUnified: boolean;
|
|
633
|
+
}[];
|
|
634
|
+
steps: {
|
|
635
|
+
description: string;
|
|
636
|
+
stepId: string;
|
|
637
|
+
stepFunction: {
|
|
638
|
+
functionName: string;
|
|
639
|
+
parameters: Record<string, unknown>;
|
|
640
|
+
version?: string | undefined;
|
|
641
|
+
};
|
|
642
|
+
}[];
|
|
643
|
+
result: string;
|
|
644
|
+
schema?: string | undefined;
|
|
645
|
+
entrypointUrl?: string | undefined;
|
|
646
|
+
entrypointHttpMethod?: string | undefined;
|
|
647
|
+
inputs?: {
|
|
648
|
+
type: string;
|
|
649
|
+
required: boolean;
|
|
650
|
+
description: string;
|
|
651
|
+
name: string;
|
|
652
|
+
in: string;
|
|
653
|
+
}[] | undefined;
|
|
654
|
+
}[] | undefined;
|
|
515
655
|
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ErrorType } from './types';
|
|
2
|
+
export declare class ConnectSDKError extends Error {
|
|
3
|
+
readonly errorType: ErrorType;
|
|
4
|
+
constructor(errorType: ErrorType, message?: string);
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConnectorParseError extends ConnectSDKError {
|
|
8
|
+
constructor(message?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class MissingOperationError extends ConnectSDKError {
|
|
11
|
+
constructor(message?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class InvalidOperationInputsError extends ConnectSDKError {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ErrorType = 'CONNECTOR_PARSE_ERROR' | 'MISSING_OPERATION_ERROR' | 'INVALID_OPERATION_INPUTS_ERROR';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Account, Block, Category, Connector, ILogger } from '@stackone/core';
|
|
2
|
+
import { HttpMethod } from '@stackone/transport';
|
|
3
|
+
import { createBlock } from '../blocks/createBlock';
|
|
4
|
+
import { getOperationFromUrl } from '../connectors/operations';
|
|
5
|
+
import { parseOperationInputs, parseYamlConnector } from '../connectors/parsers';
|
|
6
|
+
import { runStepOperation } from './runStepOperation';
|
|
7
|
+
export declare const runConnectorOperation: ({ account, connector, category, path, method, queryParams, logger, parseConnector, getOperationFromUrlFn, parseOperationInputsFn, createBlockFn, runStepOperationFn, }: {
|
|
8
|
+
account: Account;
|
|
9
|
+
connector: Connector | string;
|
|
10
|
+
category: Category;
|
|
11
|
+
path: string;
|
|
12
|
+
method?: HttpMethod;
|
|
13
|
+
queryParams: unknown;
|
|
14
|
+
logger?: ILogger;
|
|
15
|
+
parseConnector?: typeof parseYamlConnector;
|
|
16
|
+
getOperationFromUrlFn?: typeof getOperationFromUrl;
|
|
17
|
+
parseOperationInputsFn?: typeof parseOperationInputs;
|
|
18
|
+
createBlockFn?: typeof createBlock;
|
|
19
|
+
runStepOperationFn?: typeof runStepOperation;
|
|
20
|
+
}) => Promise<Block>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackone/connect-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.mjs",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"@stackone/expressions": "*",
|
|
37
37
|
"@stackone/open-api": "*",
|
|
38
38
|
"@stackone/transport": "*",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
39
|
+
"@stackone/utils": "*",
|
|
40
|
+
"path-to-regexp": "8.2.0",
|
|
41
|
+
"yaml": "2.7.1"
|
|
41
42
|
}
|
|
42
43
|
}
|