@dungarees/make-com-api 0.11.4
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/api.d.ts +50 -0
- package/api.js +35 -0
- package/package.json +452 -0
- package/service.d.ts +3 -0
- package/service.js +13 -0
- package/service.test.d.ts +1 -0
- package/service.test.js +68 -0
- package/stub.d.ts +13 -0
- package/stub.js +57 -0
- package/type.d.ts +52 -0
- package/type.js +4 -0
package/api.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AuthSearchParams, Scenario, ScenarioAction, ScenarioActionResponse } from './type.ts';
|
|
2
|
+
import { createJsonRestClient } from '@dungarees/rest/json.ts';
|
|
3
|
+
import type { AUTH_HEADER, RestEndpoint } from '@dungarees/rest/type.ts';
|
|
4
|
+
export declare const MAKE_COM_BASE_URL = "https://eu2.make.com";
|
|
5
|
+
export declare const SCENARIO_BASE_PATHNAME = "api/v2/scenarios";
|
|
6
|
+
export type ScenarioApiListRequest = {
|
|
7
|
+
method: 'GET';
|
|
8
|
+
pathname: typeof SCENARIO_BASE_PATHNAME;
|
|
9
|
+
search: AuthSearchParams;
|
|
10
|
+
headers: AUTH_HEADER;
|
|
11
|
+
};
|
|
12
|
+
export type ScenarioApiListResponse = {
|
|
13
|
+
scenarios: Scenario[];
|
|
14
|
+
};
|
|
15
|
+
export type ScenarioApiListEndpoint = RestEndpoint<ScenarioApiListRequest, ScenarioApiListResponse>;
|
|
16
|
+
export type ScenarioApiSingleRequest = {
|
|
17
|
+
method: 'GET';
|
|
18
|
+
pathname: `${typeof SCENARIO_BASE_PATHNAME}/${number}`;
|
|
19
|
+
headers: AUTH_HEADER;
|
|
20
|
+
};
|
|
21
|
+
export type ScenarioApiSingleResponse = {
|
|
22
|
+
scenario: Scenario;
|
|
23
|
+
};
|
|
24
|
+
export type ScenarioApiSingleEndpoint = RestEndpoint<ScenarioApiSingleRequest, ScenarioApiSingleResponse>;
|
|
25
|
+
export type ScenarioApiActionRequest = {
|
|
26
|
+
method: 'POST';
|
|
27
|
+
pathname: `${typeof SCENARIO_BASE_PATHNAME}/${number}/${ScenarioAction}`;
|
|
28
|
+
headers: AUTH_HEADER;
|
|
29
|
+
};
|
|
30
|
+
export type ScenarioApiActionResponse = {
|
|
31
|
+
scenario: ScenarioActionResponse;
|
|
32
|
+
};
|
|
33
|
+
export type ScenarioApiActionEndpoint = RestEndpoint<ScenarioApiActionRequest, ScenarioApiActionResponse>;
|
|
34
|
+
export type ScenarioApi = ScenarioApiListEndpoint | ScenarioApiSingleEndpoint | ScenarioApiActionEndpoint;
|
|
35
|
+
export type ScenarioApiClient = ReturnType<typeof createJsonRestClient<ScenarioApi>>;
|
|
36
|
+
export declare const createScenarioApiClient: (baseUrl?: string) => ScenarioApiClient;
|
|
37
|
+
export declare const createListScenarioRequest: ({ accessToken, organizationId, teamId, }: {
|
|
38
|
+
accessToken: string;
|
|
39
|
+
organizationId?: string;
|
|
40
|
+
teamId?: string;
|
|
41
|
+
}) => ScenarioApiListRequest;
|
|
42
|
+
export declare const createGetScenarioRequest: ({ scenarioId, accessToken, }: {
|
|
43
|
+
scenarioId: number;
|
|
44
|
+
accessToken: string;
|
|
45
|
+
}) => ScenarioApiSingleRequest;
|
|
46
|
+
export declare const createScenarioActionRequest: ({ action, scenarioId, accessToken, }: {
|
|
47
|
+
action: ScenarioAction;
|
|
48
|
+
scenarioId: number;
|
|
49
|
+
accessToken: string;
|
|
50
|
+
}) => ScenarioApiActionRequest;
|
package/api.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createJsonRestClient } from '@dungarees/rest/json.ts';
|
|
2
|
+
export const MAKE_COM_BASE_URL = 'https://eu2.make.com';
|
|
3
|
+
export const SCENARIO_BASE_PATHNAME = 'api/v2/scenarios';
|
|
4
|
+
// A creator rather than a module-level client, so the base url is configurable and no network
|
|
5
|
+
// client is built as a side effect of importing this module.
|
|
6
|
+
export const createScenarioApiClient = (baseUrl = MAKE_COM_BASE_URL) => createJsonRestClient(baseUrl);
|
|
7
|
+
const toAuthHeader = (accessToken) => ({
|
|
8
|
+
Authorization: `Token ${accessToken}`,
|
|
9
|
+
});
|
|
10
|
+
// An organization narrows further than a team, so it wins when both are given.
|
|
11
|
+
const toAuthSearch = ({ organizationId, teamId, }) => {
|
|
12
|
+
if (organizationId !== undefined) {
|
|
13
|
+
return { organizationId };
|
|
14
|
+
}
|
|
15
|
+
return teamId !== undefined ? { teamId } : {};
|
|
16
|
+
};
|
|
17
|
+
export const createListScenarioRequest = ({ accessToken, organizationId, teamId, }) => ({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
pathname: SCENARIO_BASE_PATHNAME,
|
|
20
|
+
search: toAuthSearch({
|
|
21
|
+
...(organizationId !== undefined && { organizationId }),
|
|
22
|
+
...(teamId !== undefined && { teamId }),
|
|
23
|
+
}),
|
|
24
|
+
headers: toAuthHeader(accessToken),
|
|
25
|
+
});
|
|
26
|
+
export const createGetScenarioRequest = ({ scenarioId, accessToken, }) => ({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
pathname: `${SCENARIO_BASE_PATHNAME}/${scenarioId}`,
|
|
29
|
+
headers: toAuthHeader(accessToken),
|
|
30
|
+
});
|
|
31
|
+
export const createScenarioActionRequest = ({ action, scenarioId, accessToken, }) => ({
|
|
32
|
+
method: 'POST',
|
|
33
|
+
pathname: `${SCENARIO_BASE_PATHNAME}/${scenarioId}/${action}`,
|
|
34
|
+
headers: toAuthHeader(accessToken),
|
|
35
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dungarees/make-com-api",
|
|
3
|
+
"engines": {
|
|
4
|
+
"node": ">=22.0.0"
|
|
5
|
+
},
|
|
6
|
+
"scripts": {
|
|
7
|
+
"type-check": "tsc --noEmit"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@dungarees/core": "*",
|
|
12
|
+
"@dungarees/rest": "*",
|
|
13
|
+
"rxjs": "^7.8.1"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"typescript": "^5.9.3",
|
|
17
|
+
"vitest": "^3.0.2"
|
|
18
|
+
},
|
|
19
|
+
"author": "info@productkind.com",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"version": "0.11.4",
|
|
22
|
+
"exports": {
|
|
23
|
+
"./api.ts": {
|
|
24
|
+
"import": "./api.js",
|
|
25
|
+
"types": "./api.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./node_modules/typescript/lib/lib.d.ts": {
|
|
28
|
+
"import": "./node_modules/typescript/lib/lib.d.js",
|
|
29
|
+
"types": "./node_modules/typescript/lib/lib.d.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./node_modules/typescript/lib/lib.decorators.d.ts": {
|
|
32
|
+
"import": "./node_modules/typescript/lib/lib.decorators.d.js",
|
|
33
|
+
"types": "./node_modules/typescript/lib/lib.decorators.d.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./node_modules/typescript/lib/lib.decorators.legacy.d.ts": {
|
|
36
|
+
"import": "./node_modules/typescript/lib/lib.decorators.legacy.d.js",
|
|
37
|
+
"types": "./node_modules/typescript/lib/lib.decorators.legacy.d.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./node_modules/typescript/lib/lib.dom.asynciterable.d.ts": {
|
|
40
|
+
"import": "./node_modules/typescript/lib/lib.dom.asynciterable.d.js",
|
|
41
|
+
"types": "./node_modules/typescript/lib/lib.dom.asynciterable.d.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./node_modules/typescript/lib/lib.dom.d.ts": {
|
|
44
|
+
"import": "./node_modules/typescript/lib/lib.dom.d.js",
|
|
45
|
+
"types": "./node_modules/typescript/lib/lib.dom.d.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./node_modules/typescript/lib/lib.dom.iterable.d.ts": {
|
|
48
|
+
"import": "./node_modules/typescript/lib/lib.dom.iterable.d.js",
|
|
49
|
+
"types": "./node_modules/typescript/lib/lib.dom.iterable.d.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./node_modules/typescript/lib/lib.es2015.collection.d.ts": {
|
|
52
|
+
"import": "./node_modules/typescript/lib/lib.es2015.collection.d.js",
|
|
53
|
+
"types": "./node_modules/typescript/lib/lib.es2015.collection.d.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./node_modules/typescript/lib/lib.es2015.core.d.ts": {
|
|
56
|
+
"import": "./node_modules/typescript/lib/lib.es2015.core.d.js",
|
|
57
|
+
"types": "./node_modules/typescript/lib/lib.es2015.core.d.d.ts"
|
|
58
|
+
},
|
|
59
|
+
"./node_modules/typescript/lib/lib.es2015.d.ts": {
|
|
60
|
+
"import": "./node_modules/typescript/lib/lib.es2015.d.js",
|
|
61
|
+
"types": "./node_modules/typescript/lib/lib.es2015.d.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./node_modules/typescript/lib/lib.es2015.generator.d.ts": {
|
|
64
|
+
"import": "./node_modules/typescript/lib/lib.es2015.generator.d.js",
|
|
65
|
+
"types": "./node_modules/typescript/lib/lib.es2015.generator.d.d.ts"
|
|
66
|
+
},
|
|
67
|
+
"./node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
|
|
68
|
+
"import": "./node_modules/typescript/lib/lib.es2015.iterable.d.js",
|
|
69
|
+
"types": "./node_modules/typescript/lib/lib.es2015.iterable.d.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./node_modules/typescript/lib/lib.es2015.promise.d.ts": {
|
|
72
|
+
"import": "./node_modules/typescript/lib/lib.es2015.promise.d.js",
|
|
73
|
+
"types": "./node_modules/typescript/lib/lib.es2015.promise.d.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
|
|
76
|
+
"import": "./node_modules/typescript/lib/lib.es2015.proxy.d.js",
|
|
77
|
+
"types": "./node_modules/typescript/lib/lib.es2015.proxy.d.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
|
|
80
|
+
"import": "./node_modules/typescript/lib/lib.es2015.reflect.d.js",
|
|
81
|
+
"types": "./node_modules/typescript/lib/lib.es2015.reflect.d.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
|
|
84
|
+
"import": "./node_modules/typescript/lib/lib.es2015.symbol.d.js",
|
|
85
|
+
"types": "./node_modules/typescript/lib/lib.es2015.symbol.d.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
|
|
88
|
+
"import": "./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.js",
|
|
89
|
+
"types": "./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
|
|
92
|
+
"import": "./node_modules/typescript/lib/lib.es2016.array.include.d.js",
|
|
93
|
+
"types": "./node_modules/typescript/lib/lib.es2016.array.include.d.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./node_modules/typescript/lib/lib.es2016.d.ts": {
|
|
96
|
+
"import": "./node_modules/typescript/lib/lib.es2016.d.js",
|
|
97
|
+
"types": "./node_modules/typescript/lib/lib.es2016.d.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./node_modules/typescript/lib/lib.es2016.full.d.ts": {
|
|
100
|
+
"import": "./node_modules/typescript/lib/lib.es2016.full.d.js",
|
|
101
|
+
"types": "./node_modules/typescript/lib/lib.es2016.full.d.d.ts"
|
|
102
|
+
},
|
|
103
|
+
"./node_modules/typescript/lib/lib.es2016.intl.d.ts": {
|
|
104
|
+
"import": "./node_modules/typescript/lib/lib.es2016.intl.d.js",
|
|
105
|
+
"types": "./node_modules/typescript/lib/lib.es2016.intl.d.d.ts"
|
|
106
|
+
},
|
|
107
|
+
"./node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts": {
|
|
108
|
+
"import": "./node_modules/typescript/lib/lib.es2017.arraybuffer.d.js",
|
|
109
|
+
"types": "./node_modules/typescript/lib/lib.es2017.arraybuffer.d.d.ts"
|
|
110
|
+
},
|
|
111
|
+
"./node_modules/typescript/lib/lib.es2017.d.ts": {
|
|
112
|
+
"import": "./node_modules/typescript/lib/lib.es2017.d.js",
|
|
113
|
+
"types": "./node_modules/typescript/lib/lib.es2017.d.d.ts"
|
|
114
|
+
},
|
|
115
|
+
"./node_modules/typescript/lib/lib.es2017.date.d.ts": {
|
|
116
|
+
"import": "./node_modules/typescript/lib/lib.es2017.date.d.js",
|
|
117
|
+
"types": "./node_modules/typescript/lib/lib.es2017.date.d.d.ts"
|
|
118
|
+
},
|
|
119
|
+
"./node_modules/typescript/lib/lib.es2017.full.d.ts": {
|
|
120
|
+
"import": "./node_modules/typescript/lib/lib.es2017.full.d.js",
|
|
121
|
+
"types": "./node_modules/typescript/lib/lib.es2017.full.d.d.ts"
|
|
122
|
+
},
|
|
123
|
+
"./node_modules/typescript/lib/lib.es2017.intl.d.ts": {
|
|
124
|
+
"import": "./node_modules/typescript/lib/lib.es2017.intl.d.js",
|
|
125
|
+
"types": "./node_modules/typescript/lib/lib.es2017.intl.d.d.ts"
|
|
126
|
+
},
|
|
127
|
+
"./node_modules/typescript/lib/lib.es2017.object.d.ts": {
|
|
128
|
+
"import": "./node_modules/typescript/lib/lib.es2017.object.d.js",
|
|
129
|
+
"types": "./node_modules/typescript/lib/lib.es2017.object.d.d.ts"
|
|
130
|
+
},
|
|
131
|
+
"./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
|
|
132
|
+
"import": "./node_modules/typescript/lib/lib.es2017.sharedmemory.d.js",
|
|
133
|
+
"types": "./node_modules/typescript/lib/lib.es2017.sharedmemory.d.d.ts"
|
|
134
|
+
},
|
|
135
|
+
"./node_modules/typescript/lib/lib.es2017.string.d.ts": {
|
|
136
|
+
"import": "./node_modules/typescript/lib/lib.es2017.string.d.js",
|
|
137
|
+
"types": "./node_modules/typescript/lib/lib.es2017.string.d.d.ts"
|
|
138
|
+
},
|
|
139
|
+
"./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
|
|
140
|
+
"import": "./node_modules/typescript/lib/lib.es2017.typedarrays.d.js",
|
|
141
|
+
"types": "./node_modules/typescript/lib/lib.es2017.typedarrays.d.d.ts"
|
|
142
|
+
},
|
|
143
|
+
"./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts": {
|
|
144
|
+
"import": "./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.js",
|
|
145
|
+
"types": "./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.d.ts"
|
|
146
|
+
},
|
|
147
|
+
"./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts": {
|
|
148
|
+
"import": "./node_modules/typescript/lib/lib.es2018.asynciterable.d.js",
|
|
149
|
+
"types": "./node_modules/typescript/lib/lib.es2018.asynciterable.d.d.ts"
|
|
150
|
+
},
|
|
151
|
+
"./node_modules/typescript/lib/lib.es2018.d.ts": {
|
|
152
|
+
"import": "./node_modules/typescript/lib/lib.es2018.d.js",
|
|
153
|
+
"types": "./node_modules/typescript/lib/lib.es2018.d.d.ts"
|
|
154
|
+
},
|
|
155
|
+
"./node_modules/typescript/lib/lib.es2018.full.d.ts": {
|
|
156
|
+
"import": "./node_modules/typescript/lib/lib.es2018.full.d.js",
|
|
157
|
+
"types": "./node_modules/typescript/lib/lib.es2018.full.d.d.ts"
|
|
158
|
+
},
|
|
159
|
+
"./node_modules/typescript/lib/lib.es2018.intl.d.ts": {
|
|
160
|
+
"import": "./node_modules/typescript/lib/lib.es2018.intl.d.js",
|
|
161
|
+
"types": "./node_modules/typescript/lib/lib.es2018.intl.d.d.ts"
|
|
162
|
+
},
|
|
163
|
+
"./node_modules/typescript/lib/lib.es2018.promise.d.ts": {
|
|
164
|
+
"import": "./node_modules/typescript/lib/lib.es2018.promise.d.js",
|
|
165
|
+
"types": "./node_modules/typescript/lib/lib.es2018.promise.d.d.ts"
|
|
166
|
+
},
|
|
167
|
+
"./node_modules/typescript/lib/lib.es2018.regexp.d.ts": {
|
|
168
|
+
"import": "./node_modules/typescript/lib/lib.es2018.regexp.d.js",
|
|
169
|
+
"types": "./node_modules/typescript/lib/lib.es2018.regexp.d.d.ts"
|
|
170
|
+
},
|
|
171
|
+
"./node_modules/typescript/lib/lib.es2019.array.d.ts": {
|
|
172
|
+
"import": "./node_modules/typescript/lib/lib.es2019.array.d.js",
|
|
173
|
+
"types": "./node_modules/typescript/lib/lib.es2019.array.d.d.ts"
|
|
174
|
+
},
|
|
175
|
+
"./node_modules/typescript/lib/lib.es2019.d.ts": {
|
|
176
|
+
"import": "./node_modules/typescript/lib/lib.es2019.d.js",
|
|
177
|
+
"types": "./node_modules/typescript/lib/lib.es2019.d.d.ts"
|
|
178
|
+
},
|
|
179
|
+
"./node_modules/typescript/lib/lib.es2019.full.d.ts": {
|
|
180
|
+
"import": "./node_modules/typescript/lib/lib.es2019.full.d.js",
|
|
181
|
+
"types": "./node_modules/typescript/lib/lib.es2019.full.d.d.ts"
|
|
182
|
+
},
|
|
183
|
+
"./node_modules/typescript/lib/lib.es2019.intl.d.ts": {
|
|
184
|
+
"import": "./node_modules/typescript/lib/lib.es2019.intl.d.js",
|
|
185
|
+
"types": "./node_modules/typescript/lib/lib.es2019.intl.d.d.ts"
|
|
186
|
+
},
|
|
187
|
+
"./node_modules/typescript/lib/lib.es2019.object.d.ts": {
|
|
188
|
+
"import": "./node_modules/typescript/lib/lib.es2019.object.d.js",
|
|
189
|
+
"types": "./node_modules/typescript/lib/lib.es2019.object.d.d.ts"
|
|
190
|
+
},
|
|
191
|
+
"./node_modules/typescript/lib/lib.es2019.string.d.ts": {
|
|
192
|
+
"import": "./node_modules/typescript/lib/lib.es2019.string.d.js",
|
|
193
|
+
"types": "./node_modules/typescript/lib/lib.es2019.string.d.d.ts"
|
|
194
|
+
},
|
|
195
|
+
"./node_modules/typescript/lib/lib.es2019.symbol.d.ts": {
|
|
196
|
+
"import": "./node_modules/typescript/lib/lib.es2019.symbol.d.js",
|
|
197
|
+
"types": "./node_modules/typescript/lib/lib.es2019.symbol.d.d.ts"
|
|
198
|
+
},
|
|
199
|
+
"./node_modules/typescript/lib/lib.es2020.bigint.d.ts": {
|
|
200
|
+
"import": "./node_modules/typescript/lib/lib.es2020.bigint.d.js",
|
|
201
|
+
"types": "./node_modules/typescript/lib/lib.es2020.bigint.d.d.ts"
|
|
202
|
+
},
|
|
203
|
+
"./node_modules/typescript/lib/lib.es2020.d.ts": {
|
|
204
|
+
"import": "./node_modules/typescript/lib/lib.es2020.d.js",
|
|
205
|
+
"types": "./node_modules/typescript/lib/lib.es2020.d.d.ts"
|
|
206
|
+
},
|
|
207
|
+
"./node_modules/typescript/lib/lib.es2020.date.d.ts": {
|
|
208
|
+
"import": "./node_modules/typescript/lib/lib.es2020.date.d.js",
|
|
209
|
+
"types": "./node_modules/typescript/lib/lib.es2020.date.d.d.ts"
|
|
210
|
+
},
|
|
211
|
+
"./node_modules/typescript/lib/lib.es2020.full.d.ts": {
|
|
212
|
+
"import": "./node_modules/typescript/lib/lib.es2020.full.d.js",
|
|
213
|
+
"types": "./node_modules/typescript/lib/lib.es2020.full.d.d.ts"
|
|
214
|
+
},
|
|
215
|
+
"./node_modules/typescript/lib/lib.es2020.intl.d.ts": {
|
|
216
|
+
"import": "./node_modules/typescript/lib/lib.es2020.intl.d.js",
|
|
217
|
+
"types": "./node_modules/typescript/lib/lib.es2020.intl.d.d.ts"
|
|
218
|
+
},
|
|
219
|
+
"./node_modules/typescript/lib/lib.es2020.number.d.ts": {
|
|
220
|
+
"import": "./node_modules/typescript/lib/lib.es2020.number.d.js",
|
|
221
|
+
"types": "./node_modules/typescript/lib/lib.es2020.number.d.d.ts"
|
|
222
|
+
},
|
|
223
|
+
"./node_modules/typescript/lib/lib.es2020.promise.d.ts": {
|
|
224
|
+
"import": "./node_modules/typescript/lib/lib.es2020.promise.d.js",
|
|
225
|
+
"types": "./node_modules/typescript/lib/lib.es2020.promise.d.d.ts"
|
|
226
|
+
},
|
|
227
|
+
"./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts": {
|
|
228
|
+
"import": "./node_modules/typescript/lib/lib.es2020.sharedmemory.d.js",
|
|
229
|
+
"types": "./node_modules/typescript/lib/lib.es2020.sharedmemory.d.d.ts"
|
|
230
|
+
},
|
|
231
|
+
"./node_modules/typescript/lib/lib.es2020.string.d.ts": {
|
|
232
|
+
"import": "./node_modules/typescript/lib/lib.es2020.string.d.js",
|
|
233
|
+
"types": "./node_modules/typescript/lib/lib.es2020.string.d.d.ts"
|
|
234
|
+
},
|
|
235
|
+
"./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts": {
|
|
236
|
+
"import": "./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.js",
|
|
237
|
+
"types": "./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.d.ts"
|
|
238
|
+
},
|
|
239
|
+
"./node_modules/typescript/lib/lib.es2021.d.ts": {
|
|
240
|
+
"import": "./node_modules/typescript/lib/lib.es2021.d.js",
|
|
241
|
+
"types": "./node_modules/typescript/lib/lib.es2021.d.d.ts"
|
|
242
|
+
},
|
|
243
|
+
"./node_modules/typescript/lib/lib.es2021.full.d.ts": {
|
|
244
|
+
"import": "./node_modules/typescript/lib/lib.es2021.full.d.js",
|
|
245
|
+
"types": "./node_modules/typescript/lib/lib.es2021.full.d.d.ts"
|
|
246
|
+
},
|
|
247
|
+
"./node_modules/typescript/lib/lib.es2021.intl.d.ts": {
|
|
248
|
+
"import": "./node_modules/typescript/lib/lib.es2021.intl.d.js",
|
|
249
|
+
"types": "./node_modules/typescript/lib/lib.es2021.intl.d.d.ts"
|
|
250
|
+
},
|
|
251
|
+
"./node_modules/typescript/lib/lib.es2021.promise.d.ts": {
|
|
252
|
+
"import": "./node_modules/typescript/lib/lib.es2021.promise.d.js",
|
|
253
|
+
"types": "./node_modules/typescript/lib/lib.es2021.promise.d.d.ts"
|
|
254
|
+
},
|
|
255
|
+
"./node_modules/typescript/lib/lib.es2021.string.d.ts": {
|
|
256
|
+
"import": "./node_modules/typescript/lib/lib.es2021.string.d.js",
|
|
257
|
+
"types": "./node_modules/typescript/lib/lib.es2021.string.d.d.ts"
|
|
258
|
+
},
|
|
259
|
+
"./node_modules/typescript/lib/lib.es2021.weakref.d.ts": {
|
|
260
|
+
"import": "./node_modules/typescript/lib/lib.es2021.weakref.d.js",
|
|
261
|
+
"types": "./node_modules/typescript/lib/lib.es2021.weakref.d.d.ts"
|
|
262
|
+
},
|
|
263
|
+
"./node_modules/typescript/lib/lib.es2022.array.d.ts": {
|
|
264
|
+
"import": "./node_modules/typescript/lib/lib.es2022.array.d.js",
|
|
265
|
+
"types": "./node_modules/typescript/lib/lib.es2022.array.d.d.ts"
|
|
266
|
+
},
|
|
267
|
+
"./node_modules/typescript/lib/lib.es2022.d.ts": {
|
|
268
|
+
"import": "./node_modules/typescript/lib/lib.es2022.d.js",
|
|
269
|
+
"types": "./node_modules/typescript/lib/lib.es2022.d.d.ts"
|
|
270
|
+
},
|
|
271
|
+
"./node_modules/typescript/lib/lib.es2022.error.d.ts": {
|
|
272
|
+
"import": "./node_modules/typescript/lib/lib.es2022.error.d.js",
|
|
273
|
+
"types": "./node_modules/typescript/lib/lib.es2022.error.d.d.ts"
|
|
274
|
+
},
|
|
275
|
+
"./node_modules/typescript/lib/lib.es2022.full.d.ts": {
|
|
276
|
+
"import": "./node_modules/typescript/lib/lib.es2022.full.d.js",
|
|
277
|
+
"types": "./node_modules/typescript/lib/lib.es2022.full.d.d.ts"
|
|
278
|
+
},
|
|
279
|
+
"./node_modules/typescript/lib/lib.es2022.intl.d.ts": {
|
|
280
|
+
"import": "./node_modules/typescript/lib/lib.es2022.intl.d.js",
|
|
281
|
+
"types": "./node_modules/typescript/lib/lib.es2022.intl.d.d.ts"
|
|
282
|
+
},
|
|
283
|
+
"./node_modules/typescript/lib/lib.es2022.object.d.ts": {
|
|
284
|
+
"import": "./node_modules/typescript/lib/lib.es2022.object.d.js",
|
|
285
|
+
"types": "./node_modules/typescript/lib/lib.es2022.object.d.d.ts"
|
|
286
|
+
},
|
|
287
|
+
"./node_modules/typescript/lib/lib.es2022.regexp.d.ts": {
|
|
288
|
+
"import": "./node_modules/typescript/lib/lib.es2022.regexp.d.js",
|
|
289
|
+
"types": "./node_modules/typescript/lib/lib.es2022.regexp.d.d.ts"
|
|
290
|
+
},
|
|
291
|
+
"./node_modules/typescript/lib/lib.es2022.string.d.ts": {
|
|
292
|
+
"import": "./node_modules/typescript/lib/lib.es2022.string.d.js",
|
|
293
|
+
"types": "./node_modules/typescript/lib/lib.es2022.string.d.d.ts"
|
|
294
|
+
},
|
|
295
|
+
"./node_modules/typescript/lib/lib.es2023.array.d.ts": {
|
|
296
|
+
"import": "./node_modules/typescript/lib/lib.es2023.array.d.js",
|
|
297
|
+
"types": "./node_modules/typescript/lib/lib.es2023.array.d.d.ts"
|
|
298
|
+
},
|
|
299
|
+
"./node_modules/typescript/lib/lib.es2023.collection.d.ts": {
|
|
300
|
+
"import": "./node_modules/typescript/lib/lib.es2023.collection.d.js",
|
|
301
|
+
"types": "./node_modules/typescript/lib/lib.es2023.collection.d.d.ts"
|
|
302
|
+
},
|
|
303
|
+
"./node_modules/typescript/lib/lib.es2023.d.ts": {
|
|
304
|
+
"import": "./node_modules/typescript/lib/lib.es2023.d.js",
|
|
305
|
+
"types": "./node_modules/typescript/lib/lib.es2023.d.d.ts"
|
|
306
|
+
},
|
|
307
|
+
"./node_modules/typescript/lib/lib.es2023.full.d.ts": {
|
|
308
|
+
"import": "./node_modules/typescript/lib/lib.es2023.full.d.js",
|
|
309
|
+
"types": "./node_modules/typescript/lib/lib.es2023.full.d.d.ts"
|
|
310
|
+
},
|
|
311
|
+
"./node_modules/typescript/lib/lib.es2023.intl.d.ts": {
|
|
312
|
+
"import": "./node_modules/typescript/lib/lib.es2023.intl.d.js",
|
|
313
|
+
"types": "./node_modules/typescript/lib/lib.es2023.intl.d.d.ts"
|
|
314
|
+
},
|
|
315
|
+
"./node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts": {
|
|
316
|
+
"import": "./node_modules/typescript/lib/lib.es2024.arraybuffer.d.js",
|
|
317
|
+
"types": "./node_modules/typescript/lib/lib.es2024.arraybuffer.d.d.ts"
|
|
318
|
+
},
|
|
319
|
+
"./node_modules/typescript/lib/lib.es2024.collection.d.ts": {
|
|
320
|
+
"import": "./node_modules/typescript/lib/lib.es2024.collection.d.js",
|
|
321
|
+
"types": "./node_modules/typescript/lib/lib.es2024.collection.d.d.ts"
|
|
322
|
+
},
|
|
323
|
+
"./node_modules/typescript/lib/lib.es2024.d.ts": {
|
|
324
|
+
"import": "./node_modules/typescript/lib/lib.es2024.d.js",
|
|
325
|
+
"types": "./node_modules/typescript/lib/lib.es2024.d.d.ts"
|
|
326
|
+
},
|
|
327
|
+
"./node_modules/typescript/lib/lib.es2024.full.d.ts": {
|
|
328
|
+
"import": "./node_modules/typescript/lib/lib.es2024.full.d.js",
|
|
329
|
+
"types": "./node_modules/typescript/lib/lib.es2024.full.d.d.ts"
|
|
330
|
+
},
|
|
331
|
+
"./node_modules/typescript/lib/lib.es2024.object.d.ts": {
|
|
332
|
+
"import": "./node_modules/typescript/lib/lib.es2024.object.d.js",
|
|
333
|
+
"types": "./node_modules/typescript/lib/lib.es2024.object.d.d.ts"
|
|
334
|
+
},
|
|
335
|
+
"./node_modules/typescript/lib/lib.es2024.promise.d.ts": {
|
|
336
|
+
"import": "./node_modules/typescript/lib/lib.es2024.promise.d.js",
|
|
337
|
+
"types": "./node_modules/typescript/lib/lib.es2024.promise.d.d.ts"
|
|
338
|
+
},
|
|
339
|
+
"./node_modules/typescript/lib/lib.es2024.regexp.d.ts": {
|
|
340
|
+
"import": "./node_modules/typescript/lib/lib.es2024.regexp.d.js",
|
|
341
|
+
"types": "./node_modules/typescript/lib/lib.es2024.regexp.d.d.ts"
|
|
342
|
+
},
|
|
343
|
+
"./node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts": {
|
|
344
|
+
"import": "./node_modules/typescript/lib/lib.es2024.sharedmemory.d.js",
|
|
345
|
+
"types": "./node_modules/typescript/lib/lib.es2024.sharedmemory.d.d.ts"
|
|
346
|
+
},
|
|
347
|
+
"./node_modules/typescript/lib/lib.es2024.string.d.ts": {
|
|
348
|
+
"import": "./node_modules/typescript/lib/lib.es2024.string.d.js",
|
|
349
|
+
"types": "./node_modules/typescript/lib/lib.es2024.string.d.d.ts"
|
|
350
|
+
},
|
|
351
|
+
"./node_modules/typescript/lib/lib.es5.d.ts": {
|
|
352
|
+
"import": "./node_modules/typescript/lib/lib.es5.d.js",
|
|
353
|
+
"types": "./node_modules/typescript/lib/lib.es5.d.d.ts"
|
|
354
|
+
},
|
|
355
|
+
"./node_modules/typescript/lib/lib.es6.d.ts": {
|
|
356
|
+
"import": "./node_modules/typescript/lib/lib.es6.d.js",
|
|
357
|
+
"types": "./node_modules/typescript/lib/lib.es6.d.d.ts"
|
|
358
|
+
},
|
|
359
|
+
"./node_modules/typescript/lib/lib.esnext.array.d.ts": {
|
|
360
|
+
"import": "./node_modules/typescript/lib/lib.esnext.array.d.js",
|
|
361
|
+
"types": "./node_modules/typescript/lib/lib.esnext.array.d.d.ts"
|
|
362
|
+
},
|
|
363
|
+
"./node_modules/typescript/lib/lib.esnext.collection.d.ts": {
|
|
364
|
+
"import": "./node_modules/typescript/lib/lib.esnext.collection.d.js",
|
|
365
|
+
"types": "./node_modules/typescript/lib/lib.esnext.collection.d.d.ts"
|
|
366
|
+
},
|
|
367
|
+
"./node_modules/typescript/lib/lib.esnext.d.ts": {
|
|
368
|
+
"import": "./node_modules/typescript/lib/lib.esnext.d.js",
|
|
369
|
+
"types": "./node_modules/typescript/lib/lib.esnext.d.d.ts"
|
|
370
|
+
},
|
|
371
|
+
"./node_modules/typescript/lib/lib.esnext.decorators.d.ts": {
|
|
372
|
+
"import": "./node_modules/typescript/lib/lib.esnext.decorators.d.js",
|
|
373
|
+
"types": "./node_modules/typescript/lib/lib.esnext.decorators.d.d.ts"
|
|
374
|
+
},
|
|
375
|
+
"./node_modules/typescript/lib/lib.esnext.disposable.d.ts": {
|
|
376
|
+
"import": "./node_modules/typescript/lib/lib.esnext.disposable.d.js",
|
|
377
|
+
"types": "./node_modules/typescript/lib/lib.esnext.disposable.d.d.ts"
|
|
378
|
+
},
|
|
379
|
+
"./node_modules/typescript/lib/lib.esnext.error.d.ts": {
|
|
380
|
+
"import": "./node_modules/typescript/lib/lib.esnext.error.d.js",
|
|
381
|
+
"types": "./node_modules/typescript/lib/lib.esnext.error.d.d.ts"
|
|
382
|
+
},
|
|
383
|
+
"./node_modules/typescript/lib/lib.esnext.float16.d.ts": {
|
|
384
|
+
"import": "./node_modules/typescript/lib/lib.esnext.float16.d.js",
|
|
385
|
+
"types": "./node_modules/typescript/lib/lib.esnext.float16.d.d.ts"
|
|
386
|
+
},
|
|
387
|
+
"./node_modules/typescript/lib/lib.esnext.full.d.ts": {
|
|
388
|
+
"import": "./node_modules/typescript/lib/lib.esnext.full.d.js",
|
|
389
|
+
"types": "./node_modules/typescript/lib/lib.esnext.full.d.d.ts"
|
|
390
|
+
},
|
|
391
|
+
"./node_modules/typescript/lib/lib.esnext.intl.d.ts": {
|
|
392
|
+
"import": "./node_modules/typescript/lib/lib.esnext.intl.d.js",
|
|
393
|
+
"types": "./node_modules/typescript/lib/lib.esnext.intl.d.d.ts"
|
|
394
|
+
},
|
|
395
|
+
"./node_modules/typescript/lib/lib.esnext.iterator.d.ts": {
|
|
396
|
+
"import": "./node_modules/typescript/lib/lib.esnext.iterator.d.js",
|
|
397
|
+
"types": "./node_modules/typescript/lib/lib.esnext.iterator.d.d.ts"
|
|
398
|
+
},
|
|
399
|
+
"./node_modules/typescript/lib/lib.esnext.promise.d.ts": {
|
|
400
|
+
"import": "./node_modules/typescript/lib/lib.esnext.promise.d.js",
|
|
401
|
+
"types": "./node_modules/typescript/lib/lib.esnext.promise.d.d.ts"
|
|
402
|
+
},
|
|
403
|
+
"./node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts": {
|
|
404
|
+
"import": "./node_modules/typescript/lib/lib.esnext.sharedmemory.d.js",
|
|
405
|
+
"types": "./node_modules/typescript/lib/lib.esnext.sharedmemory.d.d.ts"
|
|
406
|
+
},
|
|
407
|
+
"./node_modules/typescript/lib/lib.scripthost.d.ts": {
|
|
408
|
+
"import": "./node_modules/typescript/lib/lib.scripthost.d.js",
|
|
409
|
+
"types": "./node_modules/typescript/lib/lib.scripthost.d.d.ts"
|
|
410
|
+
},
|
|
411
|
+
"./node_modules/typescript/lib/lib.webworker.asynciterable.d.ts": {
|
|
412
|
+
"import": "./node_modules/typescript/lib/lib.webworker.asynciterable.d.js",
|
|
413
|
+
"types": "./node_modules/typescript/lib/lib.webworker.asynciterable.d.d.ts"
|
|
414
|
+
},
|
|
415
|
+
"./node_modules/typescript/lib/lib.webworker.d.ts": {
|
|
416
|
+
"import": "./node_modules/typescript/lib/lib.webworker.d.js",
|
|
417
|
+
"types": "./node_modules/typescript/lib/lib.webworker.d.d.ts"
|
|
418
|
+
},
|
|
419
|
+
"./node_modules/typescript/lib/lib.webworker.importscripts.d.ts": {
|
|
420
|
+
"import": "./node_modules/typescript/lib/lib.webworker.importscripts.d.js",
|
|
421
|
+
"types": "./node_modules/typescript/lib/lib.webworker.importscripts.d.d.ts"
|
|
422
|
+
},
|
|
423
|
+
"./node_modules/typescript/lib/lib.webworker.iterable.d.ts": {
|
|
424
|
+
"import": "./node_modules/typescript/lib/lib.webworker.iterable.d.js",
|
|
425
|
+
"types": "./node_modules/typescript/lib/lib.webworker.iterable.d.d.ts"
|
|
426
|
+
},
|
|
427
|
+
"./node_modules/typescript/lib/tsserverlibrary.d.ts": {
|
|
428
|
+
"import": "./node_modules/typescript/lib/tsserverlibrary.d.js",
|
|
429
|
+
"types": "./node_modules/typescript/lib/tsserverlibrary.d.d.ts"
|
|
430
|
+
},
|
|
431
|
+
"./node_modules/typescript/lib/typescript.d.ts": {
|
|
432
|
+
"import": "./node_modules/typescript/lib/typescript.d.js",
|
|
433
|
+
"types": "./node_modules/typescript/lib/typescript.d.d.ts"
|
|
434
|
+
},
|
|
435
|
+
"./service.test.ts": {
|
|
436
|
+
"import": "./service.test.js",
|
|
437
|
+
"types": "./service.test.d.ts"
|
|
438
|
+
},
|
|
439
|
+
"./service.ts": {
|
|
440
|
+
"import": "./service.js",
|
|
441
|
+
"types": "./service.d.ts"
|
|
442
|
+
},
|
|
443
|
+
"./stub.ts": {
|
|
444
|
+
"import": "./stub.js",
|
|
445
|
+
"types": "./stub.d.ts"
|
|
446
|
+
},
|
|
447
|
+
"./type.ts": {
|
|
448
|
+
"import": "./type.js",
|
|
449
|
+
"types": "./type.d.ts"
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
package/service.d.ts
ADDED
package/service.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createGetScenarioRequest, createListScenarioRequest, createScenarioActionRequest, } from './api.js';
|
|
2
|
+
import { SCENARIO_ACTIONS, } from './type.js';
|
|
3
|
+
import { map } from 'rxjs/operators';
|
|
4
|
+
export const createScenarioService = (scenarioApiClient) => {
|
|
5
|
+
const runAction = (action, params) => scenarioApiClient(createScenarioActionRequest({ ...params, action })).pipe(map(({ scenario }) => scenario));
|
|
6
|
+
return {
|
|
7
|
+
// Make answers a list request with no scenarios key at all when there are none.
|
|
8
|
+
getAllScenarios: (params) => scenarioApiClient(createListScenarioRequest(params)).pipe(map(({ scenarios }) => scenarios ?? [])),
|
|
9
|
+
getScenarioById: (params) => scenarioApiClient(createGetScenarioRequest(params)).pipe(map(({ scenario }) => scenario)),
|
|
10
|
+
startScenario: (params) => runAction(SCENARIO_ACTIONS.start, params),
|
|
11
|
+
stopScenario: (params) => runAction(SCENARIO_ACTIONS.stop, params),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/service.test.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createGetScenarioRequest, createListScenarioRequest, createScenarioActionRequest, createScenarioApiClient, MAKE_COM_BASE_URL, SCENARIO_BASE_PATHNAME, } from './api.js';
|
|
2
|
+
import { createScenarioService } from './service.js';
|
|
3
|
+
import { createScenarioApiStub, FAKE_SCENARIO } from './stub.js';
|
|
4
|
+
import { SCENARIO_ACTIONS } from './type.js';
|
|
5
|
+
import { mtest } from '@dungarees/core/marbles-vitest.ts';
|
|
6
|
+
import { firstValueFrom } from 'rxjs';
|
|
7
|
+
import { expect, test } from 'vitest';
|
|
8
|
+
const AUTH = { accessToken: '12345', organizationId: '1' };
|
|
9
|
+
const createService = () => createScenarioService(createScenarioApiStub());
|
|
10
|
+
mtest('getAllScenarios lists the scenarios Make answered with', ({ expect }) => {
|
|
11
|
+
expect(createService().getAllScenarios(AUTH)).toBeObservable('-(s|)', {
|
|
12
|
+
s: [FAKE_SCENARIO],
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
mtest('getScenarioById returns the scenario that was asked for', ({ expect }) => {
|
|
16
|
+
expect(createService().getScenarioById({ accessToken: AUTH.accessToken, scenarioId: 1 })).toBeObservable('-(s|)', { s: FAKE_SCENARIO });
|
|
17
|
+
});
|
|
18
|
+
mtest('startScenario reports the scenario as linked', ({ expect }) => {
|
|
19
|
+
expect(createService().startScenario({ accessToken: AUTH.accessToken, scenarioId: 1 })).toBeObservable('-(s|)', { s: { id: 1, islinked: true } });
|
|
20
|
+
});
|
|
21
|
+
mtest('stopScenario reports the scenario as unlinked', ({ expect }) => {
|
|
22
|
+
expect(createService().stopScenario({ accessToken: AUTH.accessToken, scenarioId: 1 })).toBeObservable('-(s|)', { s: { id: 1, islinked: false } });
|
|
23
|
+
});
|
|
24
|
+
test('a request with the wrong access token is not answered', async () => {
|
|
25
|
+
await expect(firstValueFrom(createService().getAllScenarios({ accessToken: 'wrong', organizationId: '1' }))).rejects.toThrow('No stubbed endpoint matches the request');
|
|
26
|
+
});
|
|
27
|
+
test('a list request identifies the caller by organization when one is given', () => {
|
|
28
|
+
expect(createListScenarioRequest({ accessToken: 'token', organizationId: 'org', teamId: 'team' })).toEqual({
|
|
29
|
+
method: 'GET',
|
|
30
|
+
pathname: SCENARIO_BASE_PATHNAME,
|
|
31
|
+
search: { organizationId: 'org' },
|
|
32
|
+
headers: { Authorization: 'Token token' },
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
test('a list request falls back to the team when there is no organization', () => {
|
|
36
|
+
expect(createListScenarioRequest({ accessToken: 'token', teamId: 'team' })).toHaveProperty('search', { teamId: 'team' });
|
|
37
|
+
});
|
|
38
|
+
test('a list request identifies nobody when neither is given', () => {
|
|
39
|
+
expect(createListScenarioRequest({ accessToken: 'token' })).toHaveProperty('search', {});
|
|
40
|
+
});
|
|
41
|
+
test('a single scenario request addresses the scenario by id', () => {
|
|
42
|
+
expect(createGetScenarioRequest({ accessToken: 'token', scenarioId: 7 })).toEqual({
|
|
43
|
+
method: 'GET',
|
|
44
|
+
pathname: 'api/v2/scenarios/7',
|
|
45
|
+
headers: { Authorization: 'Token token' },
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
test('an action request posts to the action path of the scenario', () => {
|
|
49
|
+
expect(createScenarioActionRequest({
|
|
50
|
+
accessToken: 'token',
|
|
51
|
+
scenarioId: 7,
|
|
52
|
+
action: SCENARIO_ACTIONS.start,
|
|
53
|
+
})).toEqual({
|
|
54
|
+
method: 'POST',
|
|
55
|
+
pathname: 'api/v2/scenarios/7/start',
|
|
56
|
+
headers: { Authorization: 'Token token' },
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
test('the two scenario actions are start and stop', () => {
|
|
60
|
+
expect(Object.values(SCENARIO_ACTIONS)).toEqual(['start', 'stop']);
|
|
61
|
+
});
|
|
62
|
+
test('the client defaults to the Make host', () => {
|
|
63
|
+
expect(MAKE_COM_BASE_URL).toBe('https://eu2.make.com');
|
|
64
|
+
expect(typeof createScenarioApiClient()).toBe('function');
|
|
65
|
+
});
|
|
66
|
+
test('the client can be pointed at another host', () => {
|
|
67
|
+
expect(typeof createScenarioApiClient('https://make.example.com')).toBe('function');
|
|
68
|
+
});
|
package/stub.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ScenarioApiClient } from './api.ts';
|
|
2
|
+
import { type Scenario } from './type.ts';
|
|
3
|
+
export declare const FAKE_USER: {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const FAKE_SCENARIO: Scenario;
|
|
9
|
+
export declare const createScenarioApiStub: ({ accessToken, organizationId, scenario, }?: {
|
|
10
|
+
accessToken?: string;
|
|
11
|
+
organizationId?: string;
|
|
12
|
+
scenario?: Scenario;
|
|
13
|
+
}) => ScenarioApiClient;
|
package/stub.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createGetScenarioRequest, createListScenarioRequest, createScenarioActionRequest, } from './api.js';
|
|
2
|
+
import { SCENARIO_ACTIONS } from './type.js';
|
|
3
|
+
import { createStubRestClient } from '@dungarees/rest/stub.ts';
|
|
4
|
+
export const FAKE_USER = {
|
|
5
|
+
id: 1,
|
|
6
|
+
name: 'Test User',
|
|
7
|
+
email: 'test@email.com',
|
|
8
|
+
};
|
|
9
|
+
export const FAKE_SCENARIO = {
|
|
10
|
+
id: 1,
|
|
11
|
+
name: 'Test Scenario',
|
|
12
|
+
description: 'This is a test scenario',
|
|
13
|
+
teamId: 1,
|
|
14
|
+
scheduling: {
|
|
15
|
+
type: 'interval',
|
|
16
|
+
interval: 5000,
|
|
17
|
+
},
|
|
18
|
+
lastEdit: '2021-08-10T15:00:00.000Z',
|
|
19
|
+
isinvalid: false,
|
|
20
|
+
islinked: false,
|
|
21
|
+
islocked: false,
|
|
22
|
+
isPaused: false,
|
|
23
|
+
iswaiting: false,
|
|
24
|
+
usedPackages: [],
|
|
25
|
+
nextExec: '2021-08-10T15:00:00.000Z',
|
|
26
|
+
createdByUser: FAKE_USER,
|
|
27
|
+
updatedByUser: FAKE_USER,
|
|
28
|
+
};
|
|
29
|
+
export const createScenarioApiStub = ({ accessToken = '12345', organizationId = '1', scenario = FAKE_SCENARIO, } = {}) => {
|
|
30
|
+
const endpoints = [
|
|
31
|
+
{
|
|
32
|
+
request: createListScenarioRequest({ accessToken, organizationId }),
|
|
33
|
+
response: { scenarios: [scenario] },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
request: createGetScenarioRequest({ accessToken, scenarioId: scenario.id }),
|
|
37
|
+
response: { scenario },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
request: createScenarioActionRequest({
|
|
41
|
+
accessToken,
|
|
42
|
+
scenarioId: scenario.id,
|
|
43
|
+
action: SCENARIO_ACTIONS.start,
|
|
44
|
+
}),
|
|
45
|
+
response: { scenario: { id: scenario.id, islinked: true } },
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
request: createScenarioActionRequest({
|
|
49
|
+
accessToken,
|
|
50
|
+
scenarioId: scenario.id,
|
|
51
|
+
action: SCENARIO_ACTIONS.stop,
|
|
52
|
+
}),
|
|
53
|
+
response: { scenario: { id: scenario.id, islinked: false } },
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
return createStubRestClient(endpoints);
|
|
57
|
+
};
|
package/type.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
export type UserInfo = {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
email: string;
|
|
6
|
+
};
|
|
7
|
+
export type Scenario = {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
teamId?: number;
|
|
11
|
+
hookId?: number;
|
|
12
|
+
deviceId?: number;
|
|
13
|
+
description?: string;
|
|
14
|
+
folderId?: number;
|
|
15
|
+
isinvalid: boolean;
|
|
16
|
+
islinked: boolean;
|
|
17
|
+
islocked: boolean;
|
|
18
|
+
isPaused: boolean;
|
|
19
|
+
lastEdit: string;
|
|
20
|
+
scheduling?: {
|
|
21
|
+
type: string;
|
|
22
|
+
interval: number;
|
|
23
|
+
};
|
|
24
|
+
iswaiting: boolean;
|
|
25
|
+
usedPackages: string[];
|
|
26
|
+
nextExec: string;
|
|
27
|
+
createdByUser: UserInfo;
|
|
28
|
+
updatedByUser: UserInfo;
|
|
29
|
+
};
|
|
30
|
+
export type ScenarioActionResponse = Pick<Scenario, 'id' | 'islinked'>;
|
|
31
|
+
export declare const SCENARIO_ACTIONS: {
|
|
32
|
+
readonly start: "start";
|
|
33
|
+
readonly stop: "stop";
|
|
34
|
+
};
|
|
35
|
+
export type ScenarioAction = (typeof SCENARIO_ACTIONS)[keyof typeof SCENARIO_ACTIONS];
|
|
36
|
+
export type AuthSearchParams = {
|
|
37
|
+
teamId?: string;
|
|
38
|
+
} | {
|
|
39
|
+
organizationId: string;
|
|
40
|
+
};
|
|
41
|
+
export type AuthParams = {
|
|
42
|
+
accessToken: string;
|
|
43
|
+
};
|
|
44
|
+
export type ScenarioRequestParams = AuthParams & {
|
|
45
|
+
scenarioId: number;
|
|
46
|
+
};
|
|
47
|
+
export type ScenarioService = {
|
|
48
|
+
getAllScenarios: (params: AuthParams & AuthSearchParams) => Observable<Scenario[]>;
|
|
49
|
+
getScenarioById: (params: ScenarioRequestParams) => Observable<Scenario | undefined>;
|
|
50
|
+
startScenario: (params: ScenarioRequestParams) => Observable<ScenarioActionResponse | undefined>;
|
|
51
|
+
stopScenario: (params: ScenarioRequestParams) => Observable<ScenarioActionResponse | undefined>;
|
|
52
|
+
};
|
package/type.js
ADDED