@supermodeltools/sdk 0.5.4 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/DefaultApi.d.ts +12 -12
- package/dist/apis/DefaultApi.js +6 -6
- package/dist/async.d.ts +152 -0
- package/dist/async.js +235 -0
- package/dist/esm/apis/DefaultApi.d.ts +12 -12
- package/dist/esm/apis/DefaultApi.js +7 -7
- package/dist/esm/async.d.ts +152 -0
- package/dist/esm/async.js +229 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/models/ClassificationStats.d.ts +1 -1
- package/dist/esm/models/ClassificationStats.js +1 -1
- package/dist/esm/models/CodeGraphEnvelope.d.ts +1 -1
- package/dist/esm/models/CodeGraphEnvelope.js +1 -1
- package/dist/esm/models/CodeGraphEnvelopeAsync.d.ts +66 -0
- package/dist/esm/models/CodeGraphEnvelopeAsync.js +60 -0
- package/dist/esm/models/CodeGraphEnvelopeGraph.d.ts +1 -1
- package/dist/esm/models/CodeGraphEnvelopeGraph.js +1 -1
- package/dist/esm/models/CodeGraphNode.d.ts +1 -1
- package/dist/esm/models/CodeGraphNode.js +1 -1
- package/dist/esm/models/CodeGraphRelationship.d.ts +1 -1
- package/dist/esm/models/CodeGraphRelationship.js +1 -1
- package/dist/esm/models/CodeGraphStats.d.ts +1 -1
- package/dist/esm/models/CodeGraphStats.js +1 -1
- package/dist/esm/models/DomainClassAssignment.d.ts +1 -1
- package/dist/esm/models/DomainClassAssignment.js +1 -1
- package/dist/esm/models/DomainClassificationResponse.d.ts +1 -1
- package/dist/esm/models/DomainClassificationResponse.js +1 -1
- package/dist/esm/models/DomainClassificationResponseAsync.d.ts +66 -0
- package/dist/esm/models/DomainClassificationResponseAsync.js +60 -0
- package/dist/esm/models/DomainFileAssignment.d.ts +1 -1
- package/dist/esm/models/DomainFileAssignment.js +1 -1
- package/dist/esm/models/DomainFunctionAssignment.d.ts +1 -1
- package/dist/esm/models/DomainFunctionAssignment.js +1 -1
- package/dist/esm/models/DomainRelationship.d.ts +1 -1
- package/dist/esm/models/DomainRelationship.js +1 -1
- package/dist/esm/models/DomainSummary.d.ts +1 -1
- package/dist/esm/models/DomainSummary.js +1 -1
- package/dist/esm/models/ErrorDetailsInner.d.ts +1 -1
- package/dist/esm/models/ErrorDetailsInner.js +1 -1
- package/dist/esm/models/FunctionDescription.d.ts +1 -1
- package/dist/esm/models/FunctionDescription.js +1 -1
- package/dist/esm/models/JobStatus.d.ts +59 -0
- package/dist/esm/models/JobStatus.js +57 -0
- package/dist/esm/models/ModelError.d.ts +1 -1
- package/dist/esm/models/ModelError.js +1 -1
- package/dist/esm/models/SubdomainSummary.d.ts +1 -1
- package/dist/esm/models/SubdomainSummary.js +1 -1
- package/dist/esm/models/SupermodelArtifact.d.ts +1 -1
- package/dist/esm/models/SupermodelArtifact.js +1 -1
- package/dist/esm/models/SupermodelIR.d.ts +1 -1
- package/dist/esm/models/SupermodelIR.js +1 -1
- package/dist/esm/models/SupermodelIRAsync.d.ts +66 -0
- package/dist/esm/models/SupermodelIRAsync.js +60 -0
- package/dist/esm/models/SupermodelIRGraph.d.ts +1 -1
- package/dist/esm/models/SupermodelIRGraph.js +1 -1
- package/dist/esm/models/UnassignedFunction.d.ts +1 -1
- package/dist/esm/models/UnassignedFunction.js +1 -1
- package/dist/esm/models/index.d.ts +4 -0
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/runtime.d.ts +1 -1
- package/dist/esm/runtime.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/models/ClassificationStats.d.ts +1 -1
- package/dist/models/ClassificationStats.js +1 -1
- package/dist/models/CodeGraphEnvelope.d.ts +1 -1
- package/dist/models/CodeGraphEnvelope.js +1 -1
- package/dist/models/CodeGraphEnvelopeAsync.d.ts +66 -0
- package/dist/models/CodeGraphEnvelopeAsync.js +67 -0
- package/dist/models/CodeGraphEnvelopeGraph.d.ts +1 -1
- package/dist/models/CodeGraphEnvelopeGraph.js +1 -1
- package/dist/models/CodeGraphNode.d.ts +1 -1
- package/dist/models/CodeGraphNode.js +1 -1
- package/dist/models/CodeGraphRelationship.d.ts +1 -1
- package/dist/models/CodeGraphRelationship.js +1 -1
- package/dist/models/CodeGraphStats.d.ts +1 -1
- package/dist/models/CodeGraphStats.js +1 -1
- package/dist/models/DomainClassAssignment.d.ts +1 -1
- package/dist/models/DomainClassAssignment.js +1 -1
- package/dist/models/DomainClassificationResponse.d.ts +1 -1
- package/dist/models/DomainClassificationResponse.js +1 -1
- package/dist/models/DomainClassificationResponseAsync.d.ts +66 -0
- package/dist/models/DomainClassificationResponseAsync.js +67 -0
- package/dist/models/DomainFileAssignment.d.ts +1 -1
- package/dist/models/DomainFileAssignment.js +1 -1
- package/dist/models/DomainFunctionAssignment.d.ts +1 -1
- package/dist/models/DomainFunctionAssignment.js +1 -1
- package/dist/models/DomainRelationship.d.ts +1 -1
- package/dist/models/DomainRelationship.js +1 -1
- package/dist/models/DomainSummary.d.ts +1 -1
- package/dist/models/DomainSummary.js +1 -1
- package/dist/models/ErrorDetailsInner.d.ts +1 -1
- package/dist/models/ErrorDetailsInner.js +1 -1
- package/dist/models/FunctionDescription.d.ts +1 -1
- package/dist/models/FunctionDescription.js +1 -1
- package/dist/models/JobStatus.d.ts +59 -0
- package/dist/models/JobStatus.js +64 -0
- package/dist/models/ModelError.d.ts +1 -1
- package/dist/models/ModelError.js +1 -1
- package/dist/models/SubdomainSummary.d.ts +1 -1
- package/dist/models/SubdomainSummary.js +1 -1
- package/dist/models/SupermodelArtifact.d.ts +1 -1
- package/dist/models/SupermodelArtifact.js +1 -1
- package/dist/models/SupermodelIR.d.ts +1 -1
- package/dist/models/SupermodelIR.js +1 -1
- package/dist/models/SupermodelIRAsync.d.ts +66 -0
- package/dist/models/SupermodelIRAsync.js +67 -0
- package/dist/models/SupermodelIRGraph.d.ts +1 -1
- package/dist/models/SupermodelIRGraph.js +1 -1
- package/dist/models/UnassignedFunction.d.ts +1 -1
- package/dist/models/UnassignedFunction.js +1 -1
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Client Wrapper for Supermodel API
|
|
3
|
+
*
|
|
4
|
+
* Provides automatic polling for async job endpoints, so you can use them
|
|
5
|
+
* like synchronous APIs without manually implementing polling loops.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { DefaultApi, Configuration, SupermodelClient } from '@supermodeltools/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const api = new DefaultApi(new Configuration({
|
|
12
|
+
* basePath: 'https://api.supermodel.tools',
|
|
13
|
+
* apiKey: () => 'your-api-key'
|
|
14
|
+
* }));
|
|
15
|
+
*
|
|
16
|
+
* const client = new SupermodelClient(api);
|
|
17
|
+
*
|
|
18
|
+
* // Returns the unwrapped result - polling is automatic!
|
|
19
|
+
* const graph = await client.generateDependencyGraph(zipFile);
|
|
20
|
+
* console.log(graph.graph.nodes.length);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import type { InitOverrideFunction } from './runtime';
|
|
24
|
+
import type { DefaultApi } from './apis/DefaultApi';
|
|
25
|
+
import type { CodeGraphEnvelope, DomainClassificationResponse, SupermodelIR } from './models';
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the async client.
|
|
28
|
+
*/
|
|
29
|
+
export interface AsyncClientOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Maximum time to wait for a job to complete (in milliseconds).
|
|
32
|
+
* Default: 300000 (5 minutes)
|
|
33
|
+
*/
|
|
34
|
+
timeoutMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Default retry interval when server doesn't specify (in milliseconds).
|
|
37
|
+
* Default: 5000 (5 seconds)
|
|
38
|
+
*/
|
|
39
|
+
defaultRetryIntervalMs?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum number of polling attempts.
|
|
42
|
+
* Default: 60
|
|
43
|
+
*/
|
|
44
|
+
maxPollingAttempts?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Callback for polling progress updates.
|
|
47
|
+
* Useful for showing progress indicators in UIs.
|
|
48
|
+
*/
|
|
49
|
+
onPollingProgress?: (status: PollingProgress) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Function to generate idempotency keys.
|
|
52
|
+
* Default: crypto.randomUUID() or fallback
|
|
53
|
+
*/
|
|
54
|
+
generateIdempotencyKey?: () => string;
|
|
55
|
+
/**
|
|
56
|
+
* AbortSignal for cancelling the polling operation.
|
|
57
|
+
* When aborted, throws an AbortError.
|
|
58
|
+
*/
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Polling progress information passed to onPollingProgress callback.
|
|
63
|
+
*/
|
|
64
|
+
export interface PollingProgress {
|
|
65
|
+
jobId: string;
|
|
66
|
+
status: string;
|
|
67
|
+
attempt: number;
|
|
68
|
+
maxAttempts: number;
|
|
69
|
+
elapsedMs: number;
|
|
70
|
+
nextRetryMs?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Options for individual graph generation requests.
|
|
74
|
+
*/
|
|
75
|
+
export interface GraphRequestOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Idempotency key for the request (auto-generated if not provided).
|
|
78
|
+
*/
|
|
79
|
+
idempotencyKey?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Optional fetch init overrides (e.g., for API key auth headers).
|
|
82
|
+
*/
|
|
83
|
+
initOverrides?: RequestInit | InitOverrideFunction;
|
|
84
|
+
/**
|
|
85
|
+
* AbortSignal for cancelling this specific request.
|
|
86
|
+
* Overrides the signal set at client construction.
|
|
87
|
+
*/
|
|
88
|
+
signal?: AbortSignal;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Error thrown when a job fails.
|
|
92
|
+
*/
|
|
93
|
+
export declare class JobFailedError extends Error {
|
|
94
|
+
readonly jobId: string;
|
|
95
|
+
readonly errorMessage: string;
|
|
96
|
+
constructor(jobId: string, errorMessage: string);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Error thrown when polling times out.
|
|
100
|
+
*/
|
|
101
|
+
export declare class PollingTimeoutError extends Error {
|
|
102
|
+
readonly jobId: string;
|
|
103
|
+
readonly timeoutMs: number;
|
|
104
|
+
readonly attempts: number;
|
|
105
|
+
constructor(jobId: string, timeoutMs: number, attempts: number);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Async client wrapper that handles polling automatically.
|
|
109
|
+
*
|
|
110
|
+
* Wraps the generated DefaultApi and provides simplified methods
|
|
111
|
+
* for graph generation that handle async job polling internally.
|
|
112
|
+
*/
|
|
113
|
+
export declare class SupermodelClient {
|
|
114
|
+
private api;
|
|
115
|
+
private options;
|
|
116
|
+
private generateIdempotencyKey;
|
|
117
|
+
constructor(api: DefaultApi, options?: AsyncClientOptions);
|
|
118
|
+
/**
|
|
119
|
+
* Generate a dependency graph from a zip file.
|
|
120
|
+
* Automatically handles polling until the job completes.
|
|
121
|
+
*
|
|
122
|
+
* @param file - Zip file containing the repository
|
|
123
|
+
* @param options - Optional request options
|
|
124
|
+
* @returns The dependency graph result
|
|
125
|
+
*/
|
|
126
|
+
generateDependencyGraph(file: Blob, options?: GraphRequestOptions): Promise<CodeGraphEnvelope>;
|
|
127
|
+
/**
|
|
128
|
+
* Generate a call graph from a zip file.
|
|
129
|
+
* Automatically handles polling until the job completes.
|
|
130
|
+
*/
|
|
131
|
+
generateCallGraph(file: Blob, options?: GraphRequestOptions): Promise<CodeGraphEnvelope>;
|
|
132
|
+
/**
|
|
133
|
+
* Generate a domain graph from a zip file.
|
|
134
|
+
* Automatically handles polling until the job completes.
|
|
135
|
+
*/
|
|
136
|
+
generateDomainGraph(file: Blob, options?: GraphRequestOptions): Promise<DomainClassificationResponse>;
|
|
137
|
+
/**
|
|
138
|
+
* Generate a parse graph from a zip file.
|
|
139
|
+
* Automatically handles polling until the job completes.
|
|
140
|
+
*/
|
|
141
|
+
generateParseGraph(file: Blob, options?: GraphRequestOptions): Promise<CodeGraphEnvelope>;
|
|
142
|
+
/**
|
|
143
|
+
* Generate a Supermodel IR from a zip file.
|
|
144
|
+
* Automatically handles polling until the job completes.
|
|
145
|
+
*/
|
|
146
|
+
generateSupermodelGraph(file: Blob, options?: GraphRequestOptions): Promise<SupermodelIR>;
|
|
147
|
+
/**
|
|
148
|
+
* Access the underlying raw API for methods that don't need polling
|
|
149
|
+
* or when you want direct control over the async envelope responses.
|
|
150
|
+
*/
|
|
151
|
+
get rawApi(): DefaultApi;
|
|
152
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Client Wrapper for Supermodel API
|
|
3
|
+
*
|
|
4
|
+
* Provides automatic polling for async job endpoints, so you can use them
|
|
5
|
+
* like synchronous APIs without manually implementing polling loops.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { DefaultApi, Configuration, SupermodelClient } from '@supermodeltools/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const api = new DefaultApi(new Configuration({
|
|
12
|
+
* basePath: 'https://api.supermodel.tools',
|
|
13
|
+
* apiKey: () => 'your-api-key'
|
|
14
|
+
* }));
|
|
15
|
+
*
|
|
16
|
+
* const client = new SupermodelClient(api);
|
|
17
|
+
*
|
|
18
|
+
* // Returns the unwrapped result - polling is automatic!
|
|
19
|
+
* const graph = await client.generateDependencyGraph(zipFile);
|
|
20
|
+
* console.log(graph.graph.nodes.length);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a job fails.
|
|
34
|
+
*/
|
|
35
|
+
export class JobFailedError extends Error {
|
|
36
|
+
constructor(jobId, errorMessage) {
|
|
37
|
+
super(`Job ${jobId} failed: ${errorMessage}`);
|
|
38
|
+
this.jobId = jobId;
|
|
39
|
+
this.errorMessage = errorMessage;
|
|
40
|
+
this.name = 'JobFailedError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when polling times out.
|
|
45
|
+
*/
|
|
46
|
+
export class PollingTimeoutError extends Error {
|
|
47
|
+
constructor(jobId, timeoutMs, attempts) {
|
|
48
|
+
super(`Polling timed out for job ${jobId} after ${timeoutMs}ms (${attempts} attempts)`);
|
|
49
|
+
this.jobId = jobId;
|
|
50
|
+
this.timeoutMs = timeoutMs;
|
|
51
|
+
this.attempts = attempts;
|
|
52
|
+
this.name = 'PollingTimeoutError';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Default idempotency key generator.
|
|
57
|
+
*/
|
|
58
|
+
function defaultGenerateIdempotencyKey() {
|
|
59
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
60
|
+
return crypto.randomUUID();
|
|
61
|
+
}
|
|
62
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
63
|
+
const r = (Math.random() * 16) | 0;
|
|
64
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
65
|
+
return v.toString(16);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function sleep(ms) {
|
|
69
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
70
|
+
}
|
|
71
|
+
function sleepWithAbort(ms, signal) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
74
|
+
const error = new Error('Polling aborted');
|
|
75
|
+
error.name = 'AbortError';
|
|
76
|
+
reject(error);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const timeout = setTimeout(() => {
|
|
80
|
+
if (signal && onAbort) {
|
|
81
|
+
signal.removeEventListener('abort', onAbort);
|
|
82
|
+
}
|
|
83
|
+
resolve();
|
|
84
|
+
}, ms);
|
|
85
|
+
let onAbort;
|
|
86
|
+
if (signal) {
|
|
87
|
+
onAbort = () => {
|
|
88
|
+
clearTimeout(timeout);
|
|
89
|
+
signal.removeEventListener('abort', onAbort);
|
|
90
|
+
const error = new Error('Polling aborted');
|
|
91
|
+
error.name = 'AbortError';
|
|
92
|
+
reject(error);
|
|
93
|
+
};
|
|
94
|
+
signal.addEventListener('abort', onAbort);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Poll an async endpoint until completion.
|
|
100
|
+
*/
|
|
101
|
+
function pollUntilComplete(apiCall, options) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const { timeoutMs = 300000, defaultRetryIntervalMs = 5000, maxPollingAttempts = 60, onPollingProgress, signal, } = options;
|
|
104
|
+
const startTime = Date.now();
|
|
105
|
+
let attempt = 0;
|
|
106
|
+
let jobId = '';
|
|
107
|
+
while (attempt < maxPollingAttempts) {
|
|
108
|
+
// Check for abort before each attempt
|
|
109
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
110
|
+
const error = new Error('Polling aborted');
|
|
111
|
+
error.name = 'AbortError';
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
attempt++;
|
|
115
|
+
const elapsedMs = Date.now() - startTime;
|
|
116
|
+
if (elapsedMs >= timeoutMs) {
|
|
117
|
+
throw new PollingTimeoutError(jobId || 'unknown', timeoutMs, attempt);
|
|
118
|
+
}
|
|
119
|
+
const response = yield apiCall();
|
|
120
|
+
jobId = response.jobId;
|
|
121
|
+
const status = response.status;
|
|
122
|
+
if (onPollingProgress) {
|
|
123
|
+
const nextRetryMs = status === 'completed' || status === 'failed'
|
|
124
|
+
? undefined
|
|
125
|
+
: (response.retryAfter || defaultRetryIntervalMs / 1000) * 1000;
|
|
126
|
+
onPollingProgress({
|
|
127
|
+
jobId,
|
|
128
|
+
status,
|
|
129
|
+
attempt,
|
|
130
|
+
maxAttempts: maxPollingAttempts,
|
|
131
|
+
elapsedMs,
|
|
132
|
+
nextRetryMs,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (status === 'completed') {
|
|
136
|
+
if (response.result !== undefined) {
|
|
137
|
+
return response.result;
|
|
138
|
+
}
|
|
139
|
+
throw new Error(`Job ${jobId} completed but result is undefined`);
|
|
140
|
+
}
|
|
141
|
+
if (status === 'failed') {
|
|
142
|
+
throw new JobFailedError(jobId, response.error || 'Unknown error');
|
|
143
|
+
}
|
|
144
|
+
const retryAfterMs = (response.retryAfter || defaultRetryIntervalMs / 1000) * 1000;
|
|
145
|
+
// Use abortable sleep
|
|
146
|
+
yield sleepWithAbort(retryAfterMs, signal);
|
|
147
|
+
}
|
|
148
|
+
throw new PollingTimeoutError(jobId || 'unknown', timeoutMs, attempt);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Async client wrapper that handles polling automatically.
|
|
153
|
+
*
|
|
154
|
+
* Wraps the generated DefaultApi and provides simplified methods
|
|
155
|
+
* for graph generation that handle async job polling internally.
|
|
156
|
+
*/
|
|
157
|
+
export class SupermodelClient {
|
|
158
|
+
constructor(api, options = {}) {
|
|
159
|
+
this.api = api;
|
|
160
|
+
this.options = options;
|
|
161
|
+
this.generateIdempotencyKey = options.generateIdempotencyKey || defaultGenerateIdempotencyKey;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Generate a dependency graph from a zip file.
|
|
165
|
+
* Automatically handles polling until the job completes.
|
|
166
|
+
*
|
|
167
|
+
* @param file - Zip file containing the repository
|
|
168
|
+
* @param options - Optional request options
|
|
169
|
+
* @returns The dependency graph result
|
|
170
|
+
*/
|
|
171
|
+
generateDependencyGraph(file, options) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
const key = (options === null || options === void 0 ? void 0 : options.idempotencyKey) || this.generateIdempotencyKey();
|
|
174
|
+
const pollOptions = (options === null || options === void 0 ? void 0 : options.signal) ? Object.assign(Object.assign({}, this.options), { signal: options.signal }) : this.options;
|
|
175
|
+
return pollUntilComplete(() => this.api.generateDependencyGraph({ idempotencyKey: key, file }, options === null || options === void 0 ? void 0 : options.initOverrides), pollOptions);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Generate a call graph from a zip file.
|
|
180
|
+
* Automatically handles polling until the job completes.
|
|
181
|
+
*/
|
|
182
|
+
generateCallGraph(file, options) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
const key = (options === null || options === void 0 ? void 0 : options.idempotencyKey) || this.generateIdempotencyKey();
|
|
185
|
+
const pollOptions = (options === null || options === void 0 ? void 0 : options.signal) ? Object.assign(Object.assign({}, this.options), { signal: options.signal }) : this.options;
|
|
186
|
+
return pollUntilComplete(() => this.api.generateCallGraph({ idempotencyKey: key, file }, options === null || options === void 0 ? void 0 : options.initOverrides), pollOptions);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Generate a domain graph from a zip file.
|
|
191
|
+
* Automatically handles polling until the job completes.
|
|
192
|
+
*/
|
|
193
|
+
generateDomainGraph(file, options) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
+
const key = (options === null || options === void 0 ? void 0 : options.idempotencyKey) || this.generateIdempotencyKey();
|
|
196
|
+
const pollOptions = (options === null || options === void 0 ? void 0 : options.signal) ? Object.assign(Object.assign({}, this.options), { signal: options.signal }) : this.options;
|
|
197
|
+
return pollUntilComplete(() => this.api.generateDomainGraph({ idempotencyKey: key, file }, options === null || options === void 0 ? void 0 : options.initOverrides), pollOptions);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Generate a parse graph from a zip file.
|
|
202
|
+
* Automatically handles polling until the job completes.
|
|
203
|
+
*/
|
|
204
|
+
generateParseGraph(file, options) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const key = (options === null || options === void 0 ? void 0 : options.idempotencyKey) || this.generateIdempotencyKey();
|
|
207
|
+
const pollOptions = (options === null || options === void 0 ? void 0 : options.signal) ? Object.assign(Object.assign({}, this.options), { signal: options.signal }) : this.options;
|
|
208
|
+
return pollUntilComplete(() => this.api.generateParseGraph({ idempotencyKey: key, file }, options === null || options === void 0 ? void 0 : options.initOverrides), pollOptions);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Generate a Supermodel IR from a zip file.
|
|
213
|
+
* Automatically handles polling until the job completes.
|
|
214
|
+
*/
|
|
215
|
+
generateSupermodelGraph(file, options) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const key = (options === null || options === void 0 ? void 0 : options.idempotencyKey) || this.generateIdempotencyKey();
|
|
218
|
+
const pollOptions = (options === null || options === void 0 ? void 0 : options.signal) ? Object.assign(Object.assign({}, this.options), { signal: options.signal }) : this.options;
|
|
219
|
+
return pollUntilComplete(() => this.api.generateSupermodelGraph({ idempotencyKey: key, file }, options === null || options === void 0 ? void 0 : options.initOverrides), pollOptions);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Access the underlying raw API for methods that don't need polling
|
|
224
|
+
* or when you want direct control over the async envelope responses.
|
|
225
|
+
*/
|
|
226
|
+
get rawApi() {
|
|
227
|
+
return this.api;
|
|
228
|
+
}
|
|
229
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supermodel
|
|
3
|
+
* Code Graphing & Analysis API
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 0.6.2
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import type { CodeGraphEnvelope } from './CodeGraphEnvelope';
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @interface CodeGraphEnvelopeAsync
|
|
17
|
+
*/
|
|
18
|
+
export interface CodeGraphEnvelopeAsync {
|
|
19
|
+
/**
|
|
20
|
+
* Current status of the job.
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @memberof CodeGraphEnvelopeAsync
|
|
23
|
+
*/
|
|
24
|
+
status: CodeGraphEnvelopeAsyncStatusEnum;
|
|
25
|
+
/**
|
|
26
|
+
* Unique identifier for the job.
|
|
27
|
+
* @type {string}
|
|
28
|
+
* @memberof CodeGraphEnvelopeAsync
|
|
29
|
+
*/
|
|
30
|
+
jobId: string;
|
|
31
|
+
/**
|
|
32
|
+
* Recommended seconds to wait before polling again.
|
|
33
|
+
* @type {number}
|
|
34
|
+
* @memberof CodeGraphEnvelopeAsync
|
|
35
|
+
*/
|
|
36
|
+
retryAfter?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Error message (present when status is failed).
|
|
39
|
+
* @type {string}
|
|
40
|
+
* @memberof CodeGraphEnvelopeAsync
|
|
41
|
+
*/
|
|
42
|
+
error?: string;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @type {CodeGraphEnvelope}
|
|
46
|
+
* @memberof CodeGraphEnvelopeAsync
|
|
47
|
+
*/
|
|
48
|
+
result?: CodeGraphEnvelope;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @export
|
|
52
|
+
*/
|
|
53
|
+
export declare const CodeGraphEnvelopeAsyncStatusEnum: {
|
|
54
|
+
readonly Pending: "pending";
|
|
55
|
+
readonly Processing: "processing";
|
|
56
|
+
readonly Completed: "completed";
|
|
57
|
+
readonly Failed: "failed";
|
|
58
|
+
};
|
|
59
|
+
export type CodeGraphEnvelopeAsyncStatusEnum = typeof CodeGraphEnvelopeAsyncStatusEnum[keyof typeof CodeGraphEnvelopeAsyncStatusEnum];
|
|
60
|
+
/**
|
|
61
|
+
* Check if a given object implements the CodeGraphEnvelopeAsync interface.
|
|
62
|
+
*/
|
|
63
|
+
export declare function instanceOfCodeGraphEnvelopeAsync(value: object): value is CodeGraphEnvelopeAsync;
|
|
64
|
+
export declare function CodeGraphEnvelopeAsyncFromJSON(json: any): CodeGraphEnvelopeAsync;
|
|
65
|
+
export declare function CodeGraphEnvelopeAsyncFromJSONTyped(json: any, ignoreDiscriminator: boolean): CodeGraphEnvelopeAsync;
|
|
66
|
+
export declare function CodeGraphEnvelopeAsyncToJSON(value?: CodeGraphEnvelopeAsync | null): any;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Supermodel
|
|
5
|
+
* Code Graphing & Analysis API
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 0.6.2
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
import { CodeGraphEnvelopeFromJSON, CodeGraphEnvelopeToJSON, } from './CodeGraphEnvelope';
|
|
15
|
+
/**
|
|
16
|
+
* @export
|
|
17
|
+
*/
|
|
18
|
+
export const CodeGraphEnvelopeAsyncStatusEnum = {
|
|
19
|
+
Pending: 'pending',
|
|
20
|
+
Processing: 'processing',
|
|
21
|
+
Completed: 'completed',
|
|
22
|
+
Failed: 'failed'
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Check if a given object implements the CodeGraphEnvelopeAsync interface.
|
|
26
|
+
*/
|
|
27
|
+
export function instanceOfCodeGraphEnvelopeAsync(value) {
|
|
28
|
+
if (!('status' in value) || value['status'] === undefined)
|
|
29
|
+
return false;
|
|
30
|
+
if (!('jobId' in value) || value['jobId'] === undefined)
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
export function CodeGraphEnvelopeAsyncFromJSON(json) {
|
|
35
|
+
return CodeGraphEnvelopeAsyncFromJSONTyped(json, false);
|
|
36
|
+
}
|
|
37
|
+
export function CodeGraphEnvelopeAsyncFromJSONTyped(json, ignoreDiscriminator) {
|
|
38
|
+
if (json == null) {
|
|
39
|
+
return json;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
'status': json['status'],
|
|
43
|
+
'jobId': json['jobId'],
|
|
44
|
+
'retryAfter': json['retryAfter'] == null ? undefined : json['retryAfter'],
|
|
45
|
+
'error': json['error'] == null ? undefined : json['error'],
|
|
46
|
+
'result': json['result'] == null ? undefined : CodeGraphEnvelopeFromJSON(json['result']),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function CodeGraphEnvelopeAsyncToJSON(value) {
|
|
50
|
+
if (value == null) {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
'status': value['status'],
|
|
55
|
+
'jobId': value['jobId'],
|
|
56
|
+
'retryAfter': value['retryAfter'],
|
|
57
|
+
'error': value['error'],
|
|
58
|
+
'result': CodeGraphEnvelopeToJSON(value['result']),
|
|
59
|
+
};
|
|
60
|
+
}
|