@volant-autonomy/via-sdk 1.3567.1 → 1.3595.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/README.md +1 -1
- package/dist/direct.d.ts +1 -65
- package/dist/index.cjs.d.ts +7 -0
- package/dist/index.cjs.js +910 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.d.ts +7 -0
- package/dist/index.esm.js +905 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/volant-schema.d.ts +28 -187
- package/package.json +16 -4
- package/dist/client.js +0 -21
- package/dist/composite.js +0 -104
- package/dist/direct.js +0 -507
- package/dist/docstringTransformer.d.ts +0 -3
- package/dist/docstringTransformer.js +0 -194
- package/dist/fetch.js +0 -201
- package/dist/index.js +0 -22
- package/dist/types.js +0 -19
- package/dist/utils.js +0 -59
- package/dist/volant-schema.js +0 -6
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = default_1;
|
|
4
|
-
let schemaLocated = false;
|
|
5
|
-
/**
|
|
6
|
-
* Follows the 'paths' import to get a mapping of endpoint -> docstrings from the schema file.
|
|
7
|
-
* The relevant part of the schema is in the shape below
|
|
8
|
-
* @example
|
|
9
|
-
* interface paths {
|
|
10
|
-
* "/endpoint": {
|
|
11
|
-
* // docstring
|
|
12
|
-
* put: data;
|
|
13
|
-
* // docstring
|
|
14
|
-
* post: data;
|
|
15
|
-
* }
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
function gatherDocstrings(node, tsInstance, program) {
|
|
19
|
-
var _a;
|
|
20
|
-
// if the current node is not an import, search this node's children
|
|
21
|
-
if (!tsInstance.isImportDeclaration(node) || !tsInstance.isStringLiteral(node.moduleSpecifier)) {
|
|
22
|
-
// forEachChild handles early returns for us
|
|
23
|
-
return node.forEachChild((child) => {
|
|
24
|
-
return gatherDocstrings(child, tsInstance, program);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const endpointDocstrings = {};
|
|
28
|
-
const typeChecker = program.getTypeChecker();
|
|
29
|
-
const importSymbol = typeChecker.getSymbolAtLocation(node.moduleSpecifier);
|
|
30
|
-
// if this import is not the schema, stop
|
|
31
|
-
if (!(importSymbol === null || importSymbol === void 0 ? void 0 : importSymbol.getName().includes('schema')))
|
|
32
|
-
return;
|
|
33
|
-
schemaLocated = true;
|
|
34
|
-
const exportSymbols = typeChecker.getExportsOfModule(importSymbol);
|
|
35
|
-
for (const rootSymbol of exportSymbols) {
|
|
36
|
-
if (rootSymbol.getName() === 'paths') {
|
|
37
|
-
if (rootSymbol.members === undefined) {
|
|
38
|
-
console.error('Paths has no members. Something is strange in the schema.ts file.');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
// iterate over each of the paths
|
|
42
|
-
for (const [pathStr, pathSymbol] of rootSymbol.members.entries()) {
|
|
43
|
-
(_a = pathSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.forEachChild((pathLiteral) => {
|
|
44
|
-
var _a, _b, _c;
|
|
45
|
-
if (!tsInstance.isTypeLiteralNode(pathLiteral)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (const methodSymbol of pathLiteral.members) {
|
|
49
|
-
const docstring = (_a = methodSymbol === null || methodSymbol === void 0 ? void 0 : methodSymbol.jsDoc) === null || _a === void 0 ? void 0 : _a.map((x) =>
|
|
50
|
-
// getFullText includes the /** and */ lines, which we do not want
|
|
51
|
-
// this strips them out
|
|
52
|
-
x
|
|
53
|
-
.getFullText()
|
|
54
|
-
.split('\n')
|
|
55
|
-
.slice(1, -1)
|
|
56
|
-
.map((x) => ' ' + x.trim())
|
|
57
|
-
.join('\n'));
|
|
58
|
-
const method = (_b = methodSymbol === null || methodSymbol === void 0 ? void 0 : methodSymbol.name) === null || _b === void 0 ? void 0 : _b.getText();
|
|
59
|
-
if (method) {
|
|
60
|
-
const path = pathStr.toString();
|
|
61
|
-
(_c = endpointDocstrings[path]) !== null && _c !== void 0 ? _c : (endpointDocstrings[path] = {});
|
|
62
|
-
endpointDocstrings[path][method] = docstring;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return endpointDocstrings;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Uses the types with the same names as the functions to get the mapping of endpoints -> function identifiers
|
|
74
|
-
* Looks for this shape: `type ident = source['path']['method']` (where source = 'paths')
|
|
75
|
-
* @description Which in the ast is (ignoring irrelevant properties):
|
|
76
|
-
* @example
|
|
77
|
-
* TypeAliasDeclaration<
|
|
78
|
-
* Identifier<ident>,
|
|
79
|
-
* IndexedAccessType<
|
|
80
|
-
* IndexedAccessType<
|
|
81
|
-
* TypeReference<source>, LiteralType<path>
|
|
82
|
-
* >,
|
|
83
|
-
* LiteralType<method>
|
|
84
|
-
* >
|
|
85
|
-
* >
|
|
86
|
-
*/
|
|
87
|
-
function gatherIdentifiers(node, identifiers, tsInstance, program) {
|
|
88
|
-
var _a;
|
|
89
|
-
// if the current node is not a type alias, continue searching
|
|
90
|
-
if (!tsInstance.isTypeAliasDeclaration(node)) {
|
|
91
|
-
node.forEachChild((child) => {
|
|
92
|
-
gatherIdentifiers(child, identifiers, tsInstance, program);
|
|
93
|
-
});
|
|
94
|
-
return identifiers;
|
|
95
|
-
}
|
|
96
|
-
// name of the function
|
|
97
|
-
let identifier;
|
|
98
|
-
let next1;
|
|
99
|
-
node.forEachChild((n) => {
|
|
100
|
-
if (tsInstance.isIndexedAccessTypeNode(n))
|
|
101
|
-
next1 = n;
|
|
102
|
-
if (tsInstance.isIdentifier(n))
|
|
103
|
-
identifier = n.getText();
|
|
104
|
-
});
|
|
105
|
-
if (identifier === undefined || next1 === undefined)
|
|
106
|
-
return;
|
|
107
|
-
// the html request method
|
|
108
|
-
let method;
|
|
109
|
-
let next2;
|
|
110
|
-
next1.forEachChild((n) => {
|
|
111
|
-
if (tsInstance.isIndexedAccessTypeNode(n))
|
|
112
|
-
next2 = n;
|
|
113
|
-
if (tsInstance.isLiteralTypeNode(n))
|
|
114
|
-
method = n.literal.getText().slice(1, -1); // FIXME:
|
|
115
|
-
});
|
|
116
|
-
if (method === undefined || next2 === undefined)
|
|
117
|
-
return;
|
|
118
|
-
// type object getting indexed, should be paths
|
|
119
|
-
let source;
|
|
120
|
-
// the path of the api being called
|
|
121
|
-
let path;
|
|
122
|
-
next2.forEachChild((n) => {
|
|
123
|
-
if (tsInstance.isTypeReferenceNode(n))
|
|
124
|
-
source = n;
|
|
125
|
-
if (tsInstance.isLiteralTypeNode(n))
|
|
126
|
-
path = n.literal.getText().slice(1, -1); // FIXME:
|
|
127
|
-
});
|
|
128
|
-
if ((source === null || source === void 0 ? void 0 : source.getText()) !== 'paths') {
|
|
129
|
-
console.error(`Source was not 'paths' for method '${identifier}' it was '${source === null || source === void 0 ? void 0 : source.getText()}'. Was indexed with ${path} / ${method}`);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (path === undefined)
|
|
133
|
-
return;
|
|
134
|
-
const constPath = path; // typescript refuses to accept this as valid unless path is const
|
|
135
|
-
(_a = identifiers[constPath]) !== null && _a !== void 0 ? _a : (identifiers[constPath] = {});
|
|
136
|
-
identifiers[constPath][method] = identifier;
|
|
137
|
-
return identifiers;
|
|
138
|
-
}
|
|
139
|
-
function default_1(program, _pluginConfig, { ts: tsInstance }) {
|
|
140
|
-
return (ctx) => {
|
|
141
|
-
return (sourceFile) => {
|
|
142
|
-
var _a;
|
|
143
|
-
if (!sourceFile.fileName.includes('direct')) {
|
|
144
|
-
return sourceFile;
|
|
145
|
-
}
|
|
146
|
-
// TODO: this ignores -s. find something that doesn't
|
|
147
|
-
// console.log(`> Applying docstring transform on ${sourceFile?.fileName}`)
|
|
148
|
-
const endpointDocstrings = gatherDocstrings(sourceFile, tsInstance, program);
|
|
149
|
-
if (endpointDocstrings === undefined) {
|
|
150
|
-
console.error('endpoint docstrings were not found');
|
|
151
|
-
if (!schemaLocated) {
|
|
152
|
-
console.error('the schema file was not found at all, file is likely missing (try npm run gen-schema)');
|
|
153
|
-
}
|
|
154
|
-
return sourceFile;
|
|
155
|
-
}
|
|
156
|
-
const endpointIdentifiers = gatherIdentifiers(sourceFile, {}, tsInstance, program);
|
|
157
|
-
if (endpointIdentifiers === undefined) {
|
|
158
|
-
console.error('endpoint -> identifiers were not found');
|
|
159
|
-
return sourceFile;
|
|
160
|
-
}
|
|
161
|
-
const identifierDocstrings = {};
|
|
162
|
-
// for each of the identifiers defined in the file, find their associated docstring
|
|
163
|
-
for (const [path, methods] of Object.entries(endpointIdentifiers)) {
|
|
164
|
-
for (const [method, identifier] of Object.entries(methods)) {
|
|
165
|
-
identifierDocstrings[identifier] = (_a = endpointDocstrings[path]) === null || _a === void 0 ? void 0 : _a[method];
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function applyDocstrings(node) {
|
|
169
|
-
if (!tsInstance.isMethodDeclaration(node)) {
|
|
170
|
-
return tsInstance.visitEachChild(node, applyDocstrings, ctx); // continue searching
|
|
171
|
-
}
|
|
172
|
-
const name = node.name.getText();
|
|
173
|
-
const text = identifierDocstrings[name];
|
|
174
|
-
if (text) {
|
|
175
|
-
// FIXME: find out what happens if text.length > 2
|
|
176
|
-
tsInstance.setSyntheticLeadingComments(node, text.map((text) => {
|
|
177
|
-
return {
|
|
178
|
-
// type definition says these have to be -1
|
|
179
|
-
pos: -1,
|
|
180
|
-
end: -1,
|
|
181
|
-
hasTrailingNewLine: true,
|
|
182
|
-
// the first line of the resulting synthetic comment gets a `/*` at the start,
|
|
183
|
-
// so adding `*\n` makes it `/**`, a jsdoc comment
|
|
184
|
-
text: '*\n' + text + '\n ',
|
|
185
|
-
kind: tsInstance.SyntaxKind.MultiLineCommentTrivia
|
|
186
|
-
};
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
return node;
|
|
190
|
-
}
|
|
191
|
-
return tsInstance.visitNode(sourceFile, applyDocstrings);
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
}
|
package/dist/fetch.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Fetcher = void 0;
|
|
13
|
-
exports.default = createFetcher;
|
|
14
|
-
const openapi_fetch_1 = require("openapi-fetch");
|
|
15
|
-
const types_1 = require("./types");
|
|
16
|
-
const querySerializer = (0, openapi_fetch_1.createQuerySerializer)();
|
|
17
|
-
class Fetcher {
|
|
18
|
-
constructor(args) {
|
|
19
|
-
var _a, _b, _c, _d;
|
|
20
|
-
this.opts = {
|
|
21
|
-
url: (_a = args.url) !== null && _a !== void 0 ? _a : 'https://via.volantautonomy.com/api/v1.0',
|
|
22
|
-
fetchFn: (_b = args.fetchFn) !== null && _b !== void 0 ? _b : undefined,
|
|
23
|
-
authFetchFn: (_c = args.authFetchFn) !== null && _c !== void 0 ? _c : undefined,
|
|
24
|
-
username: args.username,
|
|
25
|
-
password: args.password,
|
|
26
|
-
ignoreAuth: (_d = args.ignoreAuth) !== null && _d !== void 0 ? _d : false
|
|
27
|
-
};
|
|
28
|
-
this.aborts = {};
|
|
29
|
-
this.accessToken = undefined;
|
|
30
|
-
this.expiry = Date.now() - 5;
|
|
31
|
-
}
|
|
32
|
-
doAuth() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
var _a;
|
|
35
|
-
// NOTE: THIS REQUEST IS NOT TYPE CHECKED PROPERLY AS paths IS NOT KNOWN HERE!
|
|
36
|
-
if (this.opts.username === undefined || this.opts.password === undefined) {
|
|
37
|
-
throw new types_1.UnauthenticatedError('ignoreAuth is not true and either username or password is missing');
|
|
38
|
-
}
|
|
39
|
-
const authFetchFn = (_a = this.opts.authFetchFn) !== null && _a !== void 0 ? _a : globalThis.fetch;
|
|
40
|
-
const resp = yield authFetchFn(this.opts.url + '/login', {
|
|
41
|
-
body: JSON.stringify({
|
|
42
|
-
username: this.opts.username,
|
|
43
|
-
password: this.opts.password
|
|
44
|
-
}),
|
|
45
|
-
redirect: 'follow',
|
|
46
|
-
method: 'post',
|
|
47
|
-
headers: { 'Content-Type': 'application/json' }
|
|
48
|
-
});
|
|
49
|
-
if (resp.ok) {
|
|
50
|
-
const data = (yield resp.json());
|
|
51
|
-
this.expiry = Date.now() + data.expires_in - 10;
|
|
52
|
-
this.accessToken = data.access_token;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
throw new types_1.UnauthenticatedError('Invalid credentials');
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/** Takes in an abort key to determine what abort signals should be fired and a new signal */
|
|
60
|
-
handleAbortKey(abortKey) {
|
|
61
|
-
var _a;
|
|
62
|
-
if (abortKey) {
|
|
63
|
-
(_a = this.aborts[abortKey]) === null || _a === void 0 ? void 0 : _a.abort();
|
|
64
|
-
const abortController = new AbortController();
|
|
65
|
-
this.aborts[abortKey] = abortController;
|
|
66
|
-
return abortController.signal;
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
/** Transforms an error from the api into an {@link SdkErrorModel} */
|
|
71
|
-
parseError(response) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
var _a;
|
|
74
|
-
const error = (yield response.json());
|
|
75
|
-
// NOTE: throws away the status codes inside of the individual errors
|
|
76
|
-
if (((_a = error === null || error === void 0 ? void 0 : error.errors) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
77
|
-
return {
|
|
78
|
-
status: String(response.status),
|
|
79
|
-
errors: [
|
|
80
|
-
{
|
|
81
|
-
status: String(response.status),
|
|
82
|
-
detail: ''
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return {
|
|
89
|
-
status: String(response.status),
|
|
90
|
-
errors: error === null || error === void 0 ? void 0 : error.errors.map((err) => {
|
|
91
|
-
return {
|
|
92
|
-
status: String(err.status),
|
|
93
|
-
detail: err.detail
|
|
94
|
-
};
|
|
95
|
-
})
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// source: https://github.com/openapi-ts/openapi-typescript/blob/f21c05b9afcc89ee6ef73edab4045620b410eb01/packages/openapi-fetch/src/index.js#L447
|
|
101
|
-
createFinalURL(path, options) {
|
|
102
|
-
var _a;
|
|
103
|
-
let finalURL = `${this.opts.url}${path}`;
|
|
104
|
-
if (options === null || options === void 0 ? void 0 : options.path) {
|
|
105
|
-
finalURL = (0, openapi_fetch_1.defaultPathSerializer)(finalURL, options.path);
|
|
106
|
-
}
|
|
107
|
-
const search = querySerializer((_a = options.query) !== null && _a !== void 0 ? _a : {});
|
|
108
|
-
if (search) {
|
|
109
|
-
finalURL += `?${search}`;
|
|
110
|
-
}
|
|
111
|
-
return finalURL;
|
|
112
|
-
}
|
|
113
|
-
/** The actual fetch wrapper. It is type inference blind, beyond the parseAs type */
|
|
114
|
-
fetcher(method, path, data, opts) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
var _a, _b, _c;
|
|
117
|
-
if (!this.opts.ignoreAuth) {
|
|
118
|
-
if (!this.accessToken || this.expiry <= Date.now()) {
|
|
119
|
-
yield this.doAuth();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const fetchFn = (_b = (_a = opts === null || opts === void 0 ? void 0 : opts.fetch) !== null && _a !== void 0 ? _a : this.opts.fetchFn) !== null && _b !== void 0 ? _b : globalThis.fetch;
|
|
123
|
-
const parseAs = (_c = opts === null || opts === void 0 ? void 0 : opts.parseAs) !== null && _c !== void 0 ? _c : 'json';
|
|
124
|
-
const request = new Request(this.createFinalURL(path, { query: data === null || data === void 0 ? void 0 : data.query, path: data === null || data === void 0 ? void 0 : data.path }), {
|
|
125
|
-
redirect: 'follow',
|
|
126
|
-
signal: this.handleAbortKey(opts === null || opts === void 0 ? void 0 : opts.abortKey),
|
|
127
|
-
body: JSON.stringify(data === null || data === void 0 ? void 0 : data.body),
|
|
128
|
-
headers: Object.assign({ 'Content-Type': 'application/json' }, data === null || data === void 0 ? void 0 : data.header),
|
|
129
|
-
method
|
|
130
|
-
});
|
|
131
|
-
if (!this.opts.ignoreAuth) {
|
|
132
|
-
request.headers.set('Authorization', `Bearer ${this.accessToken}`);
|
|
133
|
-
}
|
|
134
|
-
let response;
|
|
135
|
-
try {
|
|
136
|
-
response = yield fetchFn(request);
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
if (err.name === 'AbortError') {
|
|
140
|
-
return { aborted: true };
|
|
141
|
-
}
|
|
142
|
-
throw err;
|
|
143
|
-
}
|
|
144
|
-
if (response.status === 401) {
|
|
145
|
-
throw new types_1.UnauthenticatedError('Unauthenticated');
|
|
146
|
-
}
|
|
147
|
-
// handle empty content
|
|
148
|
-
// note: we return `{}` because we want user truthy checks for `.data` or `.error` to succeed
|
|
149
|
-
// NOTE: this does lie to the user, as we say it is undefined
|
|
150
|
-
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
151
|
-
return response.ok
|
|
152
|
-
? { data: {}, aborted: false, response }
|
|
153
|
-
: { error: {}, aborted: false, response };
|
|
154
|
-
}
|
|
155
|
-
if (response.ok) {
|
|
156
|
-
// if "stream", skip parsing entirely
|
|
157
|
-
if (parseAs === 'stream') {
|
|
158
|
-
return { data: response.body, aborted: false, response };
|
|
159
|
-
}
|
|
160
|
-
return { data: yield response[parseAs](), aborted: false, response };
|
|
161
|
-
}
|
|
162
|
-
return { error: yield this.parseError(response), aborted: false };
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
GET(path, data, opts) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return this.fetcher('get', path, data, opts);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
PUT(path, data, opts) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return this.fetcher('put', path, data, opts);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
POST(path, data, opts) {
|
|
176
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
return this.fetcher('post', path, data, opts);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
DELETE(path, data, opts) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
return this.fetcher('delete', path, data, opts);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
OPTIONS(path, data, opts) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return this.fetcher('options', path, data, opts);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
HEAD(path, data, opts) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
return this.fetcher('post', path, data, opts);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
exports.Fetcher = Fetcher;
|
|
197
|
-
// indirection is required to get ts to accept the type magic
|
|
198
|
-
//* * `paths` MUST be passed in as a generic type arg or type inference falls apart */
|
|
199
|
-
function createFetcher(...args) {
|
|
200
|
-
return new Fetcher(...args);
|
|
201
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.UnauthenticatedError = exports.createSDK = void 0;
|
|
18
|
-
var client_1 = require("./client");
|
|
19
|
-
Object.defineProperty(exports, "createSDK", { enumerable: true, get: function () { return client_1.createSDK; } });
|
|
20
|
-
__exportStar(require("./utils"), exports);
|
|
21
|
-
var types_1 = require("./types");
|
|
22
|
-
Object.defineProperty(exports, "UnauthenticatedError", { enumerable: true, get: function () { return types_1.UnauthenticatedError; } });
|
package/dist/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnauthenticatedError = exports.sleep = void 0;
|
|
4
|
-
// eslint-disable-next-line promise/param-names
|
|
5
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
6
|
-
exports.sleep = sleep;
|
|
7
|
-
class UnauthenticatedError extends Error {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
// Both properties are needed to allow for errors to be identified when used in scenarios such
|
|
11
|
-
// as 'PromiseRejectionEvent' such as:
|
|
12
|
-
// `if (errorEvent.reason.name === UnauthenticatedError.name)`
|
|
13
|
-
// In the above, the first is the instance property and the latter a class property
|
|
14
|
-
this.name = 'Unauthenticated';
|
|
15
|
-
// FIXME: this was valid in the via codebase for some reason.
|
|
16
|
-
// public static override name = 'Unauthenticated'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.UnauthenticatedError = UnauthenticatedError;
|
package/dist/utils.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCheckpointsFromCoordinates = generateCheckpointsFromCoordinates;
|
|
4
|
-
exports.generateWaypointsFromCoordinates = generateWaypointsFromCoordinates;
|
|
5
|
-
exports.rfcDateTime = rfcDateTime;
|
|
6
|
-
/** Takes in an array of coordinates and flight options, and returns an array of checkpoints for use in the other functions */
|
|
7
|
-
function generateCheckpointsFromCoordinates(args) {
|
|
8
|
-
const { coordinates, options } = args;
|
|
9
|
-
if (coordinates.length <= 2) {
|
|
10
|
-
throw Error('Must have at least two coordinates');
|
|
11
|
-
}
|
|
12
|
-
const waypoints = [
|
|
13
|
-
{
|
|
14
|
-
type: 'start',
|
|
15
|
-
position: coordinates[0] // first coord exists because of length check above
|
|
16
|
-
}
|
|
17
|
-
];
|
|
18
|
-
for (const position of coordinates.slice(1)) {
|
|
19
|
-
waypoints.push({
|
|
20
|
-
type: 'goto',
|
|
21
|
-
position,
|
|
22
|
-
parameters: options
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return waypoints;
|
|
26
|
-
}
|
|
27
|
-
/** Takes in an array of coordinates and flight options, and returns an array of waypoints for use in the other functions */
|
|
28
|
-
function generateWaypointsFromCoordinates(args) {
|
|
29
|
-
const { coordinates, options } = args;
|
|
30
|
-
if (coordinates.length <= 2) {
|
|
31
|
-
throw Error('Must have at least two coordinates');
|
|
32
|
-
}
|
|
33
|
-
const waypoints = [
|
|
34
|
-
{
|
|
35
|
-
type: 'start',
|
|
36
|
-
position: coordinates[0] // first coord exists because of length check above
|
|
37
|
-
}
|
|
38
|
-
];
|
|
39
|
-
for (const position of coordinates.slice(1)) {
|
|
40
|
-
if (options.wind_parameters)
|
|
41
|
-
waypoints.push({
|
|
42
|
-
type: 'goto',
|
|
43
|
-
position,
|
|
44
|
-
flight_parameters: options.flight_parameters,
|
|
45
|
-
wind_parameters: options.wind_parameters
|
|
46
|
-
});
|
|
47
|
-
else
|
|
48
|
-
waypoints.push({
|
|
49
|
-
type: 'goto',
|
|
50
|
-
position,
|
|
51
|
-
flight_parameters: options.flight_parameters
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return waypoints;
|
|
55
|
-
}
|
|
56
|
-
/** Converts from seconds since epoch to a RFC3339-formatted datetime string */
|
|
57
|
-
function rfcDateTime(secondsEpoch) {
|
|
58
|
-
return new Date(secondsEpoch * 1000).toISOString().slice(0, 16) + 'Z';
|
|
59
|
-
}
|