epicenter-libs 3.34.2 → 3.35.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/CHANGELOG.md +61 -0
- package/README.md +61 -86
- package/dist/browser/epicenter.js +1589 -228
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +1512 -144
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +1595 -227
- package/dist/epicenter.js.map +1 -1
- package/dist/epicenter.min.js +1 -1
- package/dist/epicenter.min.js.map +1 -1
- package/dist/module/epicenter.js +1506 -145
- package/dist/module/epicenter.js.map +1 -1
- package/dist/types/adapters/docket.d.ts +80 -0
- package/dist/types/adapters/encyclopedia.d.ts +86 -0
- package/dist/types/adapters/file.d.ts +201 -0
- package/dist/types/adapters/git.d.ts +171 -0
- package/dist/types/adapters/index.d.ts +8 -1
- package/dist/types/adapters/pipeline.d.ts +88 -0
- package/dist/types/adapters/powerpoint.d.ts +130 -0
- package/dist/types/adapters/registration.d.ts +270 -0
- package/dist/types/adapters/task.d.ts +99 -37
- package/dist/types/epicenter.d.ts +2 -2
- package/dist/types/types.d.ts +6 -1
- package/dist/types/utils/router.d.ts +1 -0
- package/package.json +12 -7
- package/src/adapters/authentication.ts +2 -1
- package/src/adapters/cometd.ts +7 -2
- package/src/adapters/docket.ts +109 -0
- package/src/adapters/encyclopedia.ts +128 -0
- package/src/adapters/file.ts +332 -0
- package/src/adapters/git.ts +278 -0
- package/src/adapters/index.ts +14 -0
- package/src/adapters/pipeline.ts +145 -0
- package/src/adapters/powerpoint.ts +238 -0
- package/src/adapters/registration.ts +413 -0
- package/src/adapters/task.ts +170 -47
- package/src/epicenter.ts +10 -3
- package/src/globals.d.ts +6 -0
- package/src/types.ts +61 -0
- package/src/utils/router.ts +1 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import type { RoutingOptions } from '../utils/router';
|
|
2
|
+
|
|
3
|
+
import { Router } from '../utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export interface FileEntry {
|
|
7
|
+
objectType: 'file';
|
|
8
|
+
name?: string;
|
|
9
|
+
lastModifiedTime?: string;
|
|
10
|
+
size?: number;
|
|
11
|
+
contentType?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface DirectoryEntry {
|
|
15
|
+
objectType: 'directory';
|
|
16
|
+
name?: string;
|
|
17
|
+
lastModifiedTime?: string;
|
|
18
|
+
children?: FileSystemEntry[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type FileSystemEntry = FileEntry | DirectoryEntry;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/* File paths are free-form, user-authored strings that may contain spaces or URL-reserved
|
|
25
|
+
* characters. Encode each segment while preserving the '/' separators that the backend's
|
|
26
|
+
* `{filePath:.*}` routes expect. */
|
|
27
|
+
const encodePath = (filePath: string): string =>
|
|
28
|
+
filePath.split('/').map(encodeURIComponent).join('/');
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Lists files and directories at the project root or at a specific path.
|
|
33
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file[/{filePath}]`
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
37
|
+
* // List all files at root
|
|
38
|
+
* const entries = await fileAdapter.list();
|
|
39
|
+
* // List contents of a specific directory up to 2 levels deep
|
|
40
|
+
* const entries = await fileAdapter.list('src', { depth: 2 });
|
|
41
|
+
*
|
|
42
|
+
* @param [filePath] Path to a file or directory; omit to list the project root
|
|
43
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
44
|
+
* @param [optionals.depth] Maximum depth of directory traversal to include in the response
|
|
45
|
+
* @returns promise that resolves to an array of file and directory entries
|
|
46
|
+
*/
|
|
47
|
+
export async function list(
|
|
48
|
+
filePath?: string,
|
|
49
|
+
optionals: {
|
|
50
|
+
depth?: number;
|
|
51
|
+
} & RoutingOptions = {},
|
|
52
|
+
): Promise<FileSystemEntry[]> {
|
|
53
|
+
const { depth, ...routingOptions } = optionals;
|
|
54
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
55
|
+
return await new Router()
|
|
56
|
+
.withSearchParams({ depth })
|
|
57
|
+
.get(`/file${uriComponent}`, routingOptions)
|
|
58
|
+
.then(({ body }) => body);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Uploads and replaces files at the project root or at a specific path using multipart/form-data (PUT).
|
|
64
|
+
* Use this when you want to overwrite existing files. For creating new files, use `create`.
|
|
65
|
+
* Base URL: PUT `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file[/{filePath}]`
|
|
66
|
+
*
|
|
67
|
+
* NOTE: This is browser-only. The `FormData` body is only serialized as multipart/form-data when
|
|
68
|
+
* running in a browser environment; in Node it will not be sent correctly.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
72
|
+
* const formData = new FormData();
|
|
73
|
+
* formData.append('file', myFile);
|
|
74
|
+
* const uploaded = await fileAdapter.upload(formData, 'models/model.py');
|
|
75
|
+
*
|
|
76
|
+
* @param formData Multipart form data containing the file(s) to upload
|
|
77
|
+
* @param [filePath] Destination path for the file(s); omit to upload to the project root
|
|
78
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
79
|
+
* @returns promise that resolves to an array of the uploaded file entries
|
|
80
|
+
*/
|
|
81
|
+
export async function upload(
|
|
82
|
+
formData: FormData,
|
|
83
|
+
filePath?: string,
|
|
84
|
+
optionals: RoutingOptions = {},
|
|
85
|
+
): Promise<FileEntry[]> {
|
|
86
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
87
|
+
return await new Router()
|
|
88
|
+
.put(`/file${uriComponent}`, {
|
|
89
|
+
body: formData,
|
|
90
|
+
...optionals,
|
|
91
|
+
}).then(({ body }) => body);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Creates new files at the project root or at a specific path using multipart/form-data (POST).
|
|
97
|
+
* Use this when creating new files. For overwriting existing files, use `upload`.
|
|
98
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file[/{filePath}]`
|
|
99
|
+
*
|
|
100
|
+
* NOTE: This is browser-only. The `FormData` body is only serialized as multipart/form-data when
|
|
101
|
+
* running in a browser environment; in Node it will not be sent correctly.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
105
|
+
* const formData = new FormData();
|
|
106
|
+
* formData.append('file', myFile);
|
|
107
|
+
* const created = await fileAdapter.create(formData, 'models/model.py');
|
|
108
|
+
*
|
|
109
|
+
* @param formData Multipart form data containing the file(s) to create
|
|
110
|
+
* @param [filePath] Destination path for the file(s); omit to create at the project root
|
|
111
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
112
|
+
* @returns promise that resolves to an array of the created file entries
|
|
113
|
+
*/
|
|
114
|
+
export async function create(
|
|
115
|
+
formData: FormData,
|
|
116
|
+
filePath?: string,
|
|
117
|
+
optionals: RoutingOptions = {},
|
|
118
|
+
): Promise<FileEntry[]> {
|
|
119
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
120
|
+
return await new Router()
|
|
121
|
+
.post(`/file${uriComponent}`, {
|
|
122
|
+
body: formData,
|
|
123
|
+
...optionals,
|
|
124
|
+
}).then(({ body }) => body);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Deletes a file or directory at the project root or at a specific path.
|
|
130
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file[/{filePath}]`
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
134
|
+
* // Delete a specific file
|
|
135
|
+
* await fileAdapter.remove('models/old-model.py');
|
|
136
|
+
* // Delete all files at the project root
|
|
137
|
+
* await fileAdapter.remove();
|
|
138
|
+
*
|
|
139
|
+
* @param [filePath] Path of the file or directory to delete; omit to delete all files at the project root
|
|
140
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
141
|
+
* @returns promise that resolves when the deletion is complete
|
|
142
|
+
*/
|
|
143
|
+
export async function remove(
|
|
144
|
+
filePath?: string,
|
|
145
|
+
optionals: RoutingOptions = {},
|
|
146
|
+
): Promise<void> {
|
|
147
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
148
|
+
return await new Router()
|
|
149
|
+
.delete(`/file${uriComponent}`, optionals)
|
|
150
|
+
.then(({ body }) => body);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Downloads the raw content of a file at the specified path.
|
|
156
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/download/{filePath}`
|
|
157
|
+
*
|
|
158
|
+
* NOTE: The backend streams the file with its detected content type (e.g. `application/zip`,
|
|
159
|
+
* `text/plain`, `application/octet-stream`). The shared Router throws when the response
|
|
160
|
+
* content-type is not `application/json`, so this call only succeeds for JSON files. To download
|
|
161
|
+
* other file types, use the underlying fetch API directly against the constructed URL.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
165
|
+
* const content = await fileAdapter.download('config.json');
|
|
166
|
+
*
|
|
167
|
+
* @param filePath Path to the file to download
|
|
168
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
169
|
+
* @param [optionals.depth] Currently unused on the backend; reserved for future expansion.
|
|
170
|
+
* @returns promise that resolves to the raw file content
|
|
171
|
+
*/
|
|
172
|
+
export async function download(
|
|
173
|
+
filePath: string,
|
|
174
|
+
optionals: {
|
|
175
|
+
depth?: number;
|
|
176
|
+
} & RoutingOptions = {},
|
|
177
|
+
): Promise<unknown> {
|
|
178
|
+
const { depth, ...routingOptions } = optionals;
|
|
179
|
+
return await new Router()
|
|
180
|
+
.withSearchParams({ depth })
|
|
181
|
+
.get(`/file/download/${encodePath(filePath)}`, routingOptions)
|
|
182
|
+
.then(({ body }) => body);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Lists files and directories matching a glob filter pattern, optionally scoped to a specific path.
|
|
188
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/filter/{filter}[/{filePath}]`
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
192
|
+
* // List all Python files in the project
|
|
193
|
+
* const pyFiles = await fileAdapter.listByFilter('*.py');
|
|
194
|
+
* // List all Python files within the 'models' directory
|
|
195
|
+
* const pyFiles = await fileAdapter.listByFilter('*.py', 'models');
|
|
196
|
+
*
|
|
197
|
+
* @param filter Glob pattern to filter files by (e.g., '*.py', '*.json')
|
|
198
|
+
* @param [filePath] Directory path to scope the filter to; omit to search the entire project
|
|
199
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
200
|
+
* @param [optionals.depth] Maximum depth of directory traversal to include in the response
|
|
201
|
+
* @returns promise that resolves to an array of matching file and directory entries
|
|
202
|
+
*/
|
|
203
|
+
export async function listByFilter(
|
|
204
|
+
filter: string,
|
|
205
|
+
filePath?: string,
|
|
206
|
+
optionals: {
|
|
207
|
+
depth?: number;
|
|
208
|
+
} & RoutingOptions = {},
|
|
209
|
+
): Promise<FileSystemEntry[]> {
|
|
210
|
+
const { depth, ...routingOptions } = optionals;
|
|
211
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
212
|
+
return await new Router()
|
|
213
|
+
.withSearchParams({ depth })
|
|
214
|
+
.get(`/file/filter/${encodeURIComponent(filter)}${uriComponent}`, routingOptions)
|
|
215
|
+
.then(({ body }) => body);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Compresses files into a ZIP archive at the project root or at a specific path.
|
|
221
|
+
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/compress[/{filePath}]`
|
|
222
|
+
*
|
|
223
|
+
* NOTE: The backend streams the resulting archive with content-type `application/zip`. The
|
|
224
|
+
* shared Router throws when the response content-type is not `application/json`, so this call
|
|
225
|
+
* will not return the archive bytes through the normal flow. To retrieve the archive, use the
|
|
226
|
+
* underlying fetch API directly against the constructed URL.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
230
|
+
* // Compress a specific file or directory
|
|
231
|
+
* await fileAdapter.compress('models');
|
|
232
|
+
* // Compress at root
|
|
233
|
+
* await fileAdapter.compress();
|
|
234
|
+
*
|
|
235
|
+
* @param [filePath] Path of the file or directory to compress; omit to compress at the project root
|
|
236
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
237
|
+
* @returns promise that resolves to the compression result
|
|
238
|
+
*/
|
|
239
|
+
export async function compress(
|
|
240
|
+
filePath?: string,
|
|
241
|
+
optionals: RoutingOptions = {},
|
|
242
|
+
): Promise<unknown> {
|
|
243
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
244
|
+
return await new Router()
|
|
245
|
+
.patch(`/file/compress${uriComponent}`, optionals)
|
|
246
|
+
.then(({ body }) => body);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Extracts (explodes) a ZIP archive at the project root or at a specific path in place,
|
|
252
|
+
* deleting the archive after extraction.
|
|
253
|
+
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/explode[/{filePath}]`
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
257
|
+
* // Extract a specific archive
|
|
258
|
+
* await fileAdapter.explode('archive.zip');
|
|
259
|
+
* // Explode at root
|
|
260
|
+
* await fileAdapter.explode();
|
|
261
|
+
*
|
|
262
|
+
* @param [filePath] Path of the archive to extract; omit to extract at the project root
|
|
263
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
264
|
+
* @returns promise that resolves when the extraction is complete
|
|
265
|
+
*/
|
|
266
|
+
export async function explode(
|
|
267
|
+
filePath?: string,
|
|
268
|
+
optionals: RoutingOptions = {},
|
|
269
|
+
): Promise<void> {
|
|
270
|
+
const uriComponent = filePath ? `/${encodePath(filePath)}` : '';
|
|
271
|
+
return await new Router()
|
|
272
|
+
.patch(`/file/explode${uriComponent}`, optionals)
|
|
273
|
+
.then(({ body }) => body);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Moves a file or directory from one path to another within the project.
|
|
279
|
+
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/move`
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
283
|
+
* await fileAdapter.move('models/old-name.py', 'models/new-name.py');
|
|
284
|
+
* // Move and include the origin directory itself
|
|
285
|
+
* await fileAdapter.move('old-dir', 'new-dir', { includeOrigin: true });
|
|
286
|
+
*
|
|
287
|
+
* @param origin Origin path of the file or directory to move
|
|
288
|
+
* @param destination Destination path to move the file or directory to
|
|
289
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
290
|
+
* @param [optionals.includeOrigin] Whether to include the origin directory itself in the move
|
|
291
|
+
* @returns promise that resolves when the move is complete
|
|
292
|
+
*/
|
|
293
|
+
export async function move(
|
|
294
|
+
origin: string,
|
|
295
|
+
destination: string,
|
|
296
|
+
optionals: {
|
|
297
|
+
includeOrigin?: boolean;
|
|
298
|
+
} & RoutingOptions = {},
|
|
299
|
+
): Promise<void> {
|
|
300
|
+
const { includeOrigin, ...routingOptions } = optionals;
|
|
301
|
+
return await new Router()
|
|
302
|
+
.patch('/file/move', {
|
|
303
|
+
body: {
|
|
304
|
+
origin,
|
|
305
|
+
destination,
|
|
306
|
+
includeOrigin,
|
|
307
|
+
},
|
|
308
|
+
...routingOptions,
|
|
309
|
+
}).then(({ body }) => body);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Creates a new directory at the specified path.
|
|
315
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/file/directory/{filePath}`
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* import { fileAdapter } from 'epicenter-libs';
|
|
319
|
+
* const dir = await fileAdapter.createDirectory('models/new-folder');
|
|
320
|
+
*
|
|
321
|
+
* @param filePath Path at which to create the new directory
|
|
322
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
323
|
+
* @returns promise that resolves to the created directory entry
|
|
324
|
+
*/
|
|
325
|
+
export async function createDirectory(
|
|
326
|
+
filePath: string,
|
|
327
|
+
optionals: RoutingOptions = {},
|
|
328
|
+
): Promise<DirectoryEntry> {
|
|
329
|
+
return await new Router()
|
|
330
|
+
.post(`/file/directory/${encodePath(filePath)}`, optionals)
|
|
331
|
+
.then(({ body }) => body);
|
|
332
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type { RoutingOptions } from '../utils/router';
|
|
2
|
+
|
|
3
|
+
import { Router } from '../utils';
|
|
4
|
+
|
|
5
|
+
// ──────────────────────────────────────────────
|
|
6
|
+
// Types
|
|
7
|
+
// ──────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export type GitAlgorithm = 'rsa' | 'ed25519';
|
|
10
|
+
export type GitKeySpec = 'openssh' | 'pkcs8' | 'x509';
|
|
11
|
+
|
|
12
|
+
export interface GitStatusReadOutView {
|
|
13
|
+
currentBranch?: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GitIntegrationReadOutView {
|
|
17
|
+
privateKeySpec?: GitKeySpec | null;
|
|
18
|
+
publicKey?: string | null;
|
|
19
|
+
uri?: string | null;
|
|
20
|
+
publicKeySpec?: GitKeySpec | null;
|
|
21
|
+
algorithm?: GitAlgorithm | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GitIntegrationCreateInView {
|
|
25
|
+
privateKey: string;
|
|
26
|
+
privateKeySpec: GitKeySpec;
|
|
27
|
+
publicKey: string;
|
|
28
|
+
uri: string;
|
|
29
|
+
publicKeySpec: GitKeySpec;
|
|
30
|
+
algorithm: GitAlgorithm;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface GitIntegrationUpdateInView {
|
|
34
|
+
privateKey?: string | null;
|
|
35
|
+
privateKeySpec: GitKeySpec;
|
|
36
|
+
publicKey?: string | null;
|
|
37
|
+
uri?: string | null;
|
|
38
|
+
publicKeySpec: GitKeySpec;
|
|
39
|
+
algorithm: GitAlgorithm;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// ──────────────────────────────────────────────
|
|
44
|
+
// Functions
|
|
45
|
+
// ──────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the git integration configuration for the project.
|
|
49
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git`
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
53
|
+
* const integration = await gitAdapter.get();
|
|
54
|
+
*
|
|
55
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
56
|
+
* @returns promise that resolves to the git integration configuration
|
|
57
|
+
*/
|
|
58
|
+
export async function get(
|
|
59
|
+
optionals: RoutingOptions = {},
|
|
60
|
+
): Promise<GitIntegrationReadOutView> {
|
|
61
|
+
return new Router()
|
|
62
|
+
.get('/git', optionals)
|
|
63
|
+
.then(({ body }) => body);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Retrieves the current git status for the project.
|
|
69
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/status`
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
73
|
+
* const status = await gitAdapter.getStatus();
|
|
74
|
+
* console.log(status.currentBranch);
|
|
75
|
+
*
|
|
76
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
77
|
+
* @returns promise that resolves to the git status, including the current branch
|
|
78
|
+
*/
|
|
79
|
+
export async function getStatus(
|
|
80
|
+
optionals: RoutingOptions = {},
|
|
81
|
+
): Promise<GitStatusReadOutView> {
|
|
82
|
+
return new Router()
|
|
83
|
+
.get('/git/status', optionals)
|
|
84
|
+
.then(({ body }) => body);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Checks out a branch in the project's git repository.
|
|
90
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/checkout/{branch}`
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
94
|
+
* await gitAdapter.checkout('main');
|
|
95
|
+
*
|
|
96
|
+
* @param branch Name of the branch to check out
|
|
97
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
98
|
+
* @returns promise that resolves when the checkout is complete
|
|
99
|
+
*/
|
|
100
|
+
export async function checkout(
|
|
101
|
+
branch: string,
|
|
102
|
+
optionals: RoutingOptions = {},
|
|
103
|
+
): Promise<void> {
|
|
104
|
+
return new Router()
|
|
105
|
+
.get(`/git/checkout/${branch}`, optionals)
|
|
106
|
+
.then(({ body }) => body);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Resets the project's git repository, optionally to a specific branch.
|
|
112
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/reset[/{branch}]`
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
116
|
+
* await gitAdapter.reset(); // reset current branch
|
|
117
|
+
* await gitAdapter.reset({ branch: 'main' }); // reset to 'main'
|
|
118
|
+
*
|
|
119
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
120
|
+
* @param [optionals.branch] Branch to reset to; if omitted, resets the current branch
|
|
121
|
+
* @returns promise that resolves when the reset is complete
|
|
122
|
+
*/
|
|
123
|
+
export async function reset(
|
|
124
|
+
optionals: { branch?: string } & RoutingOptions = {},
|
|
125
|
+
): Promise<void> {
|
|
126
|
+
const { branch, ...routingOptions } = optionals;
|
|
127
|
+
return new Router()
|
|
128
|
+
.delete(`/git/reset${branch ? `/${branch}` : ''}`, routingOptions)
|
|
129
|
+
.then(({ body }) => body);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Creates a git integration for the project.
|
|
135
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
139
|
+
* const integration = await gitAdapter.createIntegration({
|
|
140
|
+
* uri: 'git@github.com:myorg/myrepo.git',
|
|
141
|
+
* publicKey: '...',
|
|
142
|
+
* privateKey: '...',
|
|
143
|
+
* publicKeySpec: 'openssh',
|
|
144
|
+
* privateKeySpec: 'pkcs8',
|
|
145
|
+
* algorithm: 'ed25519',
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* @param integration Git integration configuration to create
|
|
149
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
150
|
+
* @returns promise that resolves to the created git integration
|
|
151
|
+
*/
|
|
152
|
+
export async function createIntegration(
|
|
153
|
+
integration: GitIntegrationCreateInView,
|
|
154
|
+
optionals: RoutingOptions = {},
|
|
155
|
+
): Promise<GitIntegrationReadOutView> {
|
|
156
|
+
return new Router()
|
|
157
|
+
.post('/git/integration', {
|
|
158
|
+
body: integration,
|
|
159
|
+
...optionals,
|
|
160
|
+
}).then(({ body }) => body);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Updates the git integration for the project.
|
|
166
|
+
* Base URL: PATCH `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
170
|
+
* const integration = await gitAdapter.updateIntegration({
|
|
171
|
+
* uri: 'git@github.com:myorg/newrepo.git',
|
|
172
|
+
* publicKeySpec: 'openssh',
|
|
173
|
+
* privateKeySpec: 'pkcs8',
|
|
174
|
+
* algorithm: 'ed25519',
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* @param integration Fields to update on the git integration
|
|
178
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
179
|
+
* @returns promise that resolves to the updated git integration
|
|
180
|
+
*/
|
|
181
|
+
export async function updateIntegration(
|
|
182
|
+
integration: GitIntegrationUpdateInView,
|
|
183
|
+
optionals: RoutingOptions = {},
|
|
184
|
+
): Promise<GitIntegrationReadOutView> {
|
|
185
|
+
return new Router()
|
|
186
|
+
.patch('/git/integration', {
|
|
187
|
+
body: integration,
|
|
188
|
+
...optionals,
|
|
189
|
+
}).then(({ body }) => body);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Removes the git integration for the project.
|
|
195
|
+
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/integration`
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
199
|
+
* await gitAdapter.removeIntegration();
|
|
200
|
+
*
|
|
201
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
202
|
+
* @returns promise that resolves when the integration is removed
|
|
203
|
+
*/
|
|
204
|
+
export async function removeIntegration(
|
|
205
|
+
optionals: RoutingOptions = {},
|
|
206
|
+
): Promise<void> {
|
|
207
|
+
return new Router()
|
|
208
|
+
.delete('/git/integration', optionals)
|
|
209
|
+
.then(({ body }) => body);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Pushes local commits to the remote git repository.
|
|
215
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/push`
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
219
|
+
* await gitAdapter.push({ message: 'Update simulation data' });
|
|
220
|
+
*
|
|
221
|
+
* @param optionals Arguments object; also accepts network call option overrides.
|
|
222
|
+
* @param optionals.message Commit message (required)
|
|
223
|
+
* @param [optionals.password] Password for authentication
|
|
224
|
+
* @param [optionals.force] Force-push, bypassing non-fast-forward checks
|
|
225
|
+
* @returns promise that resolves when the push is complete
|
|
226
|
+
*/
|
|
227
|
+
export async function push(
|
|
228
|
+
optionals: {
|
|
229
|
+
message: string;
|
|
230
|
+
password?: string | null;
|
|
231
|
+
force?: boolean | null;
|
|
232
|
+
} & RoutingOptions,
|
|
233
|
+
): Promise<void> {
|
|
234
|
+
const { message, password, force, ...routingOptions } = optionals;
|
|
235
|
+
return new Router()
|
|
236
|
+
.withSearchParams({ force })
|
|
237
|
+
.post('/git/push', {
|
|
238
|
+
body: { message, password },
|
|
239
|
+
...routingOptions,
|
|
240
|
+
}).then(({ body }) => body);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Pulls changes from the remote git repository into the project.
|
|
246
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/git/pull`
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* import { gitAdapter } from 'epicenter-libs';
|
|
250
|
+
* await gitAdapter.pull({ force: true, confirm: true });
|
|
251
|
+
*
|
|
252
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
253
|
+
* @param [optionals.password] Password for authentication
|
|
254
|
+
* @param [optionals.force] Force the pull, overwriting local changes
|
|
255
|
+
* @param [optionals.confirm] Set the `X-Forio-Confirmation` header to confirm an overwrite
|
|
256
|
+
* @returns promise that resolves when the pull is complete
|
|
257
|
+
*/
|
|
258
|
+
export async function pull(
|
|
259
|
+
optionals: {
|
|
260
|
+
password?: string | null;
|
|
261
|
+
force?: boolean | null;
|
|
262
|
+
confirm?: boolean | null;
|
|
263
|
+
} & RoutingOptions = {},
|
|
264
|
+
): Promise<void> {
|
|
265
|
+
const { password, force, confirm, headers: headersOverride, ...routingOptions } = optionals;
|
|
266
|
+
const headers = Object.assign(
|
|
267
|
+
{},
|
|
268
|
+
headersOverride,
|
|
269
|
+
confirm ? { 'X-Forio-Confirmation': true } : {},
|
|
270
|
+
);
|
|
271
|
+
return new Router()
|
|
272
|
+
.withSearchParams({ force })
|
|
273
|
+
.post('/git/pull', {
|
|
274
|
+
body: { password },
|
|
275
|
+
headers,
|
|
276
|
+
...routingOptions,
|
|
277
|
+
}).then(({ body }) => body);
|
|
278
|
+
}
|
package/src/adapters/index.ts
CHANGED
|
@@ -23,8 +23,15 @@ import * as somebodyAdapter from './somebody';
|
|
|
23
23
|
import * as matchmakerAdapter from './matchmaker';
|
|
24
24
|
import * as dailyAdapter from './daily';
|
|
25
25
|
import * as walletAdapter from './wallet';
|
|
26
|
+
import * as pipelineAdapter from './pipeline';
|
|
27
|
+
import * as encyclopediaAdapter from './encyclopedia';
|
|
28
|
+
import * as fileAdapter from './file';
|
|
29
|
+
import * as registrationAdapter from './registration';
|
|
30
|
+
import * as docketAdapter from './docket';
|
|
26
31
|
import { default as cometdAdapter } from './cometd';
|
|
27
32
|
import { default as Channel } from './channel';
|
|
33
|
+
import * as gitAdapter from './git';
|
|
34
|
+
import * as powerpointAdapter from './powerpoint';
|
|
28
35
|
|
|
29
36
|
export {
|
|
30
37
|
accountAdapter,
|
|
@@ -53,5 +60,12 @@ export {
|
|
|
53
60
|
matchmakerAdapter,
|
|
54
61
|
dailyAdapter,
|
|
55
62
|
walletAdapter,
|
|
63
|
+
pipelineAdapter,
|
|
64
|
+
encyclopediaAdapter,
|
|
65
|
+
fileAdapter,
|
|
66
|
+
registrationAdapter,
|
|
67
|
+
docketAdapter,
|
|
56
68
|
Channel,
|
|
69
|
+
gitAdapter,
|
|
70
|
+
powerpointAdapter,
|
|
57
71
|
};
|