epicenter-libs 3.34.2 → 3.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +61 -86
- package/dist/browser/epicenter.js +1581 -226
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +1503 -141
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +1587 -225
- 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 +1497 -142
- 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/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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import 'regenerator-runtime/runtime';
|
|
2
|
-
declare const version
|
|
2
|
+
declare const version: string;
|
|
3
3
|
import { Handler } from './utils/error-manager';
|
|
4
4
|
export declare const DEFAULT_ERROR_HANDLERS: Record<string, Handler>;
|
|
5
5
|
export * from './types';
|
|
6
6
|
export { version };
|
|
7
7
|
export { SCOPE_BOUNDARY, RITUAL, PUSH_CATEGORY, ROLE, } from './utils/constants';
|
|
8
8
|
export { config, errorManager, Router, Fault, } from './utils';
|
|
9
|
-
export { accountAdapter, adminAdapter, assetAdapter, consensusAdapter, emailAdapter, authAdapter, chatAdapter, episodeAdapter, groupAdapter, leaderboardAdapter, presenceAdapter, projectAdapter, recaptchaAdapter, runAdapter, taskAdapter, timeAdapter, userAdapter, vaultAdapter, videoAdapter, vonageAdapter, worldAdapter, somebodyAdapter, dailyAdapter, matchmakerAdapter, walletAdapter, Channel, cometdAdapter, } from './adapters';
|
|
9
|
+
export { accountAdapter, adminAdapter, assetAdapter, consensusAdapter, emailAdapter, authAdapter, chatAdapter, episodeAdapter, groupAdapter, leaderboardAdapter, presenceAdapter, projectAdapter, recaptchaAdapter, runAdapter, taskAdapter, timeAdapter, userAdapter, vaultAdapter, videoAdapter, vonageAdapter, worldAdapter, somebodyAdapter, dailyAdapter, matchmakerAdapter, walletAdapter, pipelineAdapter, encyclopediaAdapter, fileAdapter, registrationAdapter, docketAdapter, Channel, cometdAdapter, gitAdapter, powerpointAdapter, } from './adapters';
|
|
10
10
|
export { videoAPI, vonageAPI, } from './apis';
|
|
11
11
|
export * as utils from './utilities';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -24,10 +24,15 @@ export type { Leaderboard, Score, Tag, } from './adapters/leaderboard';
|
|
|
24
24
|
export type { Presence, } from './adapters/presence';
|
|
25
25
|
export type { ACCESS_TYPE, AccessType, WORKER_PARTITION, WorkerPartition, PHYLOGENY, Phylogeny, FileType, CHANNEL_PROTOCOL, ChannelProtocol, ProjectMember, Deployment, TeamProject, PersonalProject, Project, } from './adapters/project';
|
|
26
26
|
export type { RunReadOutView, RunVariables, RunMetadata, RunCreateOptions, RunStrategy, ExecutionContext, ModelContext, ModelContextDefaults, OperationOptions, VariableOptions, EventOptions, RewindMarker, ReplayOperation, ReplayRestoration, SnapshotRestoration, Restorations, Protections, InputGuard, OverwriteGuard, RelativeGuard, RoleGuard, PrivilegeGuard, V1ExecutionContext, V2ModelContext, ExcelModelControl, JavaModelControl, PowersimModelControl, VensimModelControl, VensimModelTool, StellaModelTool, ProcActionable, GetActionable, SetActionable, Actionable, Route, WireExternalFunction, AptExternalDependency, CranExternalDependency, GitExternalDependency, JuliaExternalDependency, NpmExternalDependency, PypiExternalDependency, ShellExternalDependency, MORPHOLOGY, MetadataFirstPop, MetadataLastPop, MetadataAllPop, MetadataPop, MetadataUpdate, } from './adapters/run';
|
|
27
|
-
export type { RETRY_POLICY, TaskPayloadBody, TaskPayloadHeaders, StatusReadOutView, StatusCreateInView, CronTaskTriggerCreateInView, DateTaskTriggerCreateInView, OffsetTaskTriggerCreateInView, TaskTriggerCreateInView, HttpTaskPayloadCreateInView, GroupStatusTaskPayloadCreateInView, TaskPayloadCreateInView, HttpTaskPayloadReadOutView, GroupStatusTaskPayloadReadOutView, TaskPayloadReadOutView, TaskReadOutView, } from './adapters/task';
|
|
27
|
+
export type { RETRY_POLICY, TaskPayloadBody, TaskPayloadHeaders, TaskHttpMethod, TaskRetryPolicyReadOutView, TaskStatusReadOutView, TaskAddressReadOutView, TaskScopeReadOutView, StatusReadOutView, StatusCreateInView, CronTaskTriggerCreateInView, DateTaskTriggerCreateInView, OffsetTaskTriggerCreateInView, TaskTriggerCreateInView, HttpTaskPayloadCreateInView, GroupStatusTaskPayloadCreateInView, TaskPayloadCreateInView, HttpTaskPayloadCreateInput, TaskPayloadCreateInput, HttpTaskPayloadReadOutView, GroupStatusTaskPayloadReadOutView, TaskPayloadReadOutView, TaskReadOutView, TaskHistoryReadOutView, TaskPageOptions, TaskScopePageOptions, } from './adapters/task';
|
|
28
28
|
export type { UserReadOutView, UserCreateInView, NativeUserCreateInView, ExternalUserCreateInView, ExternalUserReadOutView, NativeUserReadOutView, PseudonymReadOutView, UserReport, DiscardedUser, MFADetailReadOutView, MFADetailCreateInView, GraftReadOutView, GraftCreateInView, SecretCreateInView, GroupRelationshipReadOutView, UploadOptions, Modality, MFAMethodology, Countdown, RealmData, } from './adapters/user';
|
|
29
29
|
export type { Vault, VaultItems, Items, } from './adapters/vault';
|
|
30
30
|
export type { WalletReadOutView, WalletItemReadOutView, WalletItemCreateInView, } from './adapters/wallet';
|
|
31
31
|
export type { WorldReadOutView, WorldRole, AssignmentReadOutView, AssignmentCreateInView, PersonaReadOutView, PersonaCreateInView, AssignmentMap, ColorAnimalWorldNameGenerator, SequentialWorldNameGenerator, WorldNameGenerator, WORLD_NAME_GENERATOR_TYPE, WorldNameGeneratorType, OBJECTIVE, Objective, OrbitType, } from './adapters/world';
|
|
32
|
+
export type { FileEntry, DirectoryEntry, FileSystemEntry, } from './adapters/file';
|
|
33
|
+
export type { RegistrationInfo, TeamRegistrationInfo, RegistrationResult, WhoAmI, WhoAmIObjectType, TeamRole, SsoProtocol, } from './adapters/registration';
|
|
34
|
+
export type { OperatingSystem, WorkerShape, ScaleFlavor, ScaleCreateInView, ScaleReadOutView, ScaleDocketPayloadCreateInView, ScaleDocketPayloadReadOutView, DocketPayloadCreateInView, DocketPayloadReadOutView, DocketReadOutView, } from './adapters/docket';
|
|
35
|
+
export type { EncyclopediaTranslator, DocumentedEndpointMethod, DocumentedEndpointAuthorization, DocumentedEndpointNotation, DocumentedParameterSource, DocumentedParameter, DocumentedEndpoint, DocumentedResource, KnownServiceReadOutView, } from './adapters/encyclopedia';
|
|
36
|
+
export type { PipelineExecutionStatus, PipelineAuditReadOutView, } from './adapters/pipeline';
|
|
32
37
|
export type { Somebody, } from './adapters/somebody';
|
|
33
38
|
export type { VideoReadOutView, VideoDir, AFFILIATE, Affiliate, MEDIA_FORMAT, MediaFormat, LANGUAGE_CODE, LanguageCode, ProcessingType, } from './apis/video';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epicenter-libs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.35.0",
|
|
4
4
|
"main": "dist/cjs/epicenter.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/module/epicenter.js",
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"test": "vitest",
|
|
16
|
-
"test:run": "vitest run",
|
|
17
|
-
"test:coverage": "vitest run --coverage",
|
|
16
|
+
"test:run": "npm run type-check && vitest run",
|
|
17
|
+
"test:coverage": "npm run type-check && vitest run --coverage",
|
|
18
|
+
"test:dist": "npm run build && vitest run --config vitest.dist.config.js",
|
|
18
19
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
|
19
20
|
"changelog:all": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
20
21
|
"type-check": "tsc --noEmit",
|
|
@@ -23,9 +24,7 @@
|
|
|
23
24
|
"build:types": "tsc --emitDeclarationOnly",
|
|
24
25
|
"build:js": "rollup -c -m",
|
|
25
26
|
"build": "npm run build:clean && npm run build:types && npm run build:js",
|
|
26
|
-
"
|
|
27
|
-
"pretest": "npm run type-check && npm run build:test",
|
|
28
|
-
"pretest:run": "npm run type-check && npm run build:test",
|
|
27
|
+
"prepublishOnly": "npm run test:run && npm run test:dist",
|
|
29
28
|
"start": "rollup -c -m inline -w",
|
|
30
29
|
"prepare": "node -e \"if (!process.env.CI && !process.env.JENKINS_HOME) require('child_process').execSync('husky', {stdio: 'inherit'})\""
|
|
31
30
|
},
|
|
@@ -50,6 +49,11 @@
|
|
|
50
49
|
"cometd": "^8.0.9",
|
|
51
50
|
"cross-fetch": "^3.0.6"
|
|
52
51
|
},
|
|
52
|
+
"overrides": {
|
|
53
|
+
"tar": "^7.5.16",
|
|
54
|
+
"esbuild": "^0.28.1",
|
|
55
|
+
"sigstore": "^4.1.1"
|
|
56
|
+
},
|
|
53
57
|
"devDependencies": {
|
|
54
58
|
"@babel/cli": "^7.26.0",
|
|
55
59
|
"@babel/core": "^7.26.0",
|
|
@@ -70,9 +74,10 @@
|
|
|
70
74
|
"@rollup/plugin-json": "^6.1.0",
|
|
71
75
|
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
72
76
|
"@rollup/plugin-replace": "^6.0.2",
|
|
73
|
-
"@rollup/plugin-terser": "^0.
|
|
77
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
74
78
|
"@stylistic/eslint-plugin": "^5.4.0",
|
|
75
79
|
"@types/cometd": "^4.0.8",
|
|
80
|
+
"@vitest/coverage-v8": "^3.2.6",
|
|
76
81
|
"babel-loader": "^9.2.1",
|
|
77
82
|
"conventional-changelog": "^7.1.1",
|
|
78
83
|
"conventional-changelog-angular": "^8.0.0",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { RoutingOptions } from '../utils/router';
|
|
2
|
+
import type { TaskTriggerCreateInView } from './task';
|
|
3
|
+
|
|
4
|
+
import { Router } from '../utils';
|
|
5
|
+
|
|
6
|
+
export type OperatingSystem = 'LINUX' | 'MAC' | 'WINDOWS';
|
|
7
|
+
|
|
8
|
+
export type WorkerShape =
|
|
9
|
+
| 'GS' | 'GM' | 'GL' | 'GXL' | 'G2XL' | 'G4XL'
|
|
10
|
+
| 'ML' | 'MXL' | 'M2XL' | 'M4XL'
|
|
11
|
+
| 'CL' | 'CXL' | 'C2XL' | 'C4XL';
|
|
12
|
+
|
|
13
|
+
export type ScaleFlavor = 'PROCESS' | 'DOCKER' | 'JVM' | 'WSDL';
|
|
14
|
+
|
|
15
|
+
export interface ScaleCreateInView {
|
|
16
|
+
active: boolean;
|
|
17
|
+
initialWorkerCount: number;
|
|
18
|
+
additionalWorkerLimit: number;
|
|
19
|
+
flavors?: ScaleFlavor[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ScaleReadOutView {
|
|
23
|
+
active?: boolean | null;
|
|
24
|
+
initialWorkerCount?: number | null;
|
|
25
|
+
additionalWorkerLimit?: number | null;
|
|
26
|
+
flavors?: ScaleFlavor[] | null;
|
|
27
|
+
test?: boolean | null;
|
|
28
|
+
shape?: WorkerShape | null;
|
|
29
|
+
operatingSystem?: OperatingSystem | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ScaleDocketPayloadCreateInView {
|
|
33
|
+
objectType: 'scale';
|
|
34
|
+
scale: ScaleCreateInView;
|
|
35
|
+
operatingSystem: OperatingSystem;
|
|
36
|
+
workerShape: WorkerShape;
|
|
37
|
+
test?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ScaleDocketPayloadReadOutView {
|
|
41
|
+
objectType: 'scale';
|
|
42
|
+
scale?: ScaleReadOutView | null;
|
|
43
|
+
operatingSystem?: OperatingSystem | null;
|
|
44
|
+
workerShape?: WorkerShape | null;
|
|
45
|
+
test?: boolean | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type DocketPayloadCreateInView = ScaleDocketPayloadCreateInView;
|
|
49
|
+
export type DocketPayloadReadOutView = ScaleDocketPayloadReadOutView;
|
|
50
|
+
|
|
51
|
+
export interface DocketReadOutView {
|
|
52
|
+
docketKey?: string | null;
|
|
53
|
+
date?: string | null;
|
|
54
|
+
payload?: DocketPayloadReadOutView | null;
|
|
55
|
+
ttlMinutes?: number | null;
|
|
56
|
+
complete?: boolean | null;
|
|
57
|
+
error?: string | null;
|
|
58
|
+
attempts?: number | null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new docket entry, scheduling a deferred operation for later execution.
|
|
64
|
+
* Requires `support` level authorization.
|
|
65
|
+
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/docket`
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* import { docketAdapter } from 'epicenter-libs';
|
|
69
|
+
* const docket = await docketAdapter.create(
|
|
70
|
+
* {
|
|
71
|
+
* objectType: 'scale',
|
|
72
|
+
* operatingSystem: 'LINUX',
|
|
73
|
+
* workerShape: 'GS',
|
|
74
|
+
* scale: {
|
|
75
|
+
* active: true,
|
|
76
|
+
* initialWorkerCount: 1,
|
|
77
|
+
* additionalWorkerLimit: 4,
|
|
78
|
+
* flavors: ['DOCKER'],
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* { objectType: 'date', value: '2026-06-01T00:00:00Z' },
|
|
82
|
+
* '2026-05-20T00:00:00Z',
|
|
83
|
+
* { ttlMinutes: 60 },
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* @param payload Docket payload describing the operation to schedule
|
|
87
|
+
* @param trigger Trigger describing when the operation should fire
|
|
88
|
+
* (cron, date, or offset)
|
|
89
|
+
* @param date ISO-8601 date string indicating when the docket is scheduled
|
|
90
|
+
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
91
|
+
* @param [optionals.ttlMinutes] Time-to-live in minutes for the docket entry (minimum 2)
|
|
92
|
+
* @returns promise that resolves to the newly created docket
|
|
93
|
+
*/
|
|
94
|
+
export async function create(
|
|
95
|
+
payload: DocketPayloadCreateInView,
|
|
96
|
+
trigger: TaskTriggerCreateInView,
|
|
97
|
+
date: string,
|
|
98
|
+
optionals: {
|
|
99
|
+
ttlMinutes?: number;
|
|
100
|
+
} & RoutingOptions = {},
|
|
101
|
+
): Promise<DocketReadOutView> {
|
|
102
|
+
const { ttlMinutes, ...routingOptions } = optionals;
|
|
103
|
+
return await new Router()
|
|
104
|
+
.post('/docket', {
|
|
105
|
+
body: { payload, trigger, date, ttlMinutes },
|
|
106
|
+
...routingOptions,
|
|
107
|
+
})
|
|
108
|
+
.then(({ body }) => body);
|
|
109
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { RoutingOptions } from '../utils/router';
|
|
2
|
+
|
|
3
|
+
import { Router } from '../utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type EncyclopediaTranslator = 'ASCIIDOC' | 'ASCIIDOC_TO_HTML' | 'OPENAPI';
|
|
7
|
+
|
|
8
|
+
export type DocumentedEndpointMethod = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
|
|
9
|
+
|
|
10
|
+
export type DocumentedEndpointAuthorization = 'SYSTEM' | 'DASHBOARD' | 'OWNER' | 'AUTHOR' | 'SUPPORT' | 'REVIEWER' | 'FACILITATOR' | 'LEADER' | 'PARTICIPANT' | 'ANONYMOUS';
|
|
11
|
+
|
|
12
|
+
export type DocumentedEndpointNotation = 'POST_RATHER_THAN_GET' | 'UNSUPPORTED_IGNORED';
|
|
13
|
+
|
|
14
|
+
export type DocumentedParameterSource = 'PATH' | 'HEADER' | 'QUERY' | 'MATRIX';
|
|
15
|
+
|
|
16
|
+
export interface DocumentedParameter {
|
|
17
|
+
name?: string;
|
|
18
|
+
source?: DocumentedParameterSource;
|
|
19
|
+
type?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DocumentedEndpoint {
|
|
23
|
+
method?: DocumentedEndpointMethod;
|
|
24
|
+
path?: string;
|
|
25
|
+
authorization?: DocumentedEndpointAuthorization;
|
|
26
|
+
response?: Record<string, unknown>;
|
|
27
|
+
summary?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
deprecated?: boolean;
|
|
30
|
+
paged?: boolean;
|
|
31
|
+
notations?: DocumentedEndpointNotation[];
|
|
32
|
+
body?: Record<string, unknown>;
|
|
33
|
+
parameters?: DocumentedParameter[];
|
|
34
|
+
produces?: unknown[];
|
|
35
|
+
consumes?: unknown[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface DocumentedResource {
|
|
39
|
+
silenced?: boolean;
|
|
40
|
+
endpoints?: DocumentedEndpoint[];
|
|
41
|
+
definitions?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface KnownServiceReadOutView {
|
|
45
|
+
name?: string;
|
|
46
|
+
development?: boolean;
|
|
47
|
+
trusted?: boolean;
|
|
48
|
+
published?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Lists the known API services available for the given encyclopedia version.
|
|
54
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/encyclopedia/v{version}`
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* import { encyclopediaAdapter } from 'epicenter-libs';
|
|
58
|
+
* const services = await encyclopediaAdapter.listServices(3);
|
|
59
|
+
*
|
|
60
|
+
* @param version Encyclopedia version number
|
|
61
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
62
|
+
* @returns promise that resolves to an array of known service descriptors
|
|
63
|
+
*/
|
|
64
|
+
export async function listServices(
|
|
65
|
+
version: number,
|
|
66
|
+
optionals: RoutingOptions = {},
|
|
67
|
+
): Promise<KnownServiceReadOutView[]> {
|
|
68
|
+
return await new Router()
|
|
69
|
+
.get(`/encyclopedia/v${version}`, optionals)
|
|
70
|
+
.then(({ body }) => body);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Retrieves the documented resource (API documentation) for a specific service and encyclopedia version.
|
|
76
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/encyclopedia/v{version}/{api}`
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* import { encyclopediaAdapter } from 'epicenter-libs';
|
|
80
|
+
* const resource = await encyclopediaAdapter.getResource(3, 'run');
|
|
81
|
+
*
|
|
82
|
+
* @param version Encyclopedia version number
|
|
83
|
+
* @param api Name of the API service to retrieve documentation for
|
|
84
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
85
|
+
* @returns promise that resolves to the documented resource containing endpoints and definitions
|
|
86
|
+
*/
|
|
87
|
+
export async function getResource(
|
|
88
|
+
version: number,
|
|
89
|
+
api: string,
|
|
90
|
+
optionals: RoutingOptions = {},
|
|
91
|
+
): Promise<DocumentedResource> {
|
|
92
|
+
return await new Router()
|
|
93
|
+
.get(`/encyclopedia/v${version}/${api}`, optionals)
|
|
94
|
+
.then(({ body }) => body);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves a translated representation of the API documentation for a specific service and encyclopedia version.
|
|
100
|
+
* Supported translators are ASCIIDOC, ASCIIDOC_TO_HTML, and OPENAPI.
|
|
101
|
+
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/encyclopedia/as/{translator}/v{version}/{api}`
|
|
102
|
+
*
|
|
103
|
+
* NOTE: The backend returns the translated content with a translator-specific content-type
|
|
104
|
+
* (e.g. `text/asciidoc`, `text/html`, `application/json`). The shared Router throws when the
|
|
105
|
+
* response content-type is not `application/json`, so only the OPENAPI translator works here.
|
|
106
|
+
* For ASCIIDOC and ASCIIDOC_TO_HTML, use the underlying fetch API directly against the
|
|
107
|
+
* constructed URL.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* import { encyclopediaAdapter } from 'epicenter-libs';
|
|
111
|
+
* const openApiDoc = await encyclopediaAdapter.translate('OPENAPI', 3, 'run');
|
|
112
|
+
*
|
|
113
|
+
* @param translator Output format for the documentation; one of 'ASCIIDOC', 'ASCIIDOC_TO_HTML', or 'OPENAPI'
|
|
114
|
+
* @param version Encyclopedia version number
|
|
115
|
+
* @param api Name of the API service to translate documentation for
|
|
116
|
+
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
117
|
+
* @returns promise that resolves to the translated documentation (only when translator is 'OPENAPI')
|
|
118
|
+
*/
|
|
119
|
+
export async function translate(
|
|
120
|
+
translator: EncyclopediaTranslator,
|
|
121
|
+
version: number,
|
|
122
|
+
api: string,
|
|
123
|
+
optionals: RoutingOptions = {},
|
|
124
|
+
): Promise<unknown> {
|
|
125
|
+
return await new Router()
|
|
126
|
+
.get(`/encyclopedia/as/${translator}/v${version}/${api}`, optionals)
|
|
127
|
+
.then(({ body }) => body);
|
|
128
|
+
}
|
|
@@ -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
|
+
}
|