@vertexvis/api-client-node 0.15.4 → 0.16.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/dist/cjs/api.d.ts +554 -507
- package/dist/cjs/api.js +260 -341
- package/dist/cjs/base.d.ts +2 -2
- package/dist/cjs/client/helpers/files.d.ts +3 -13
- package/dist/cjs/client/helpers/files.js +8 -48
- package/dist/cjs/client/helpers/parts.d.ts +3 -5
- package/dist/cjs/client/helpers/queued-jobs.js +1 -1
- package/dist/cjs/client/helpers/scenes.d.ts +1 -1
- package/dist/cjs/client/helpers/scenes.js +2 -11
- package/dist/cjs/client/utils.js +1 -0
- package/dist/cjs/client/version.d.ts +1 -1
- package/dist/cjs/client/version.js +1 -1
- package/dist/cjs/common.d.ts +2 -2
- package/dist/esm/api.d.ts +554 -507
- package/dist/esm/api.js +260 -341
- package/dist/esm/base.d.ts +2 -2
- package/dist/esm/client/helpers/files.d.ts +3 -13
- package/dist/esm/client/helpers/files.js +8 -44
- package/dist/esm/client/helpers/parts.d.ts +3 -5
- package/dist/esm/client/helpers/queued-jobs.js +1 -1
- package/dist/esm/client/helpers/scenes.d.ts +1 -1
- package/dist/esm/client/helpers/scenes.js +2 -11
- package/dist/esm/client/utils.js +1 -0
- package/dist/esm/client/version.d.ts +1 -1
- package/dist/esm/client/version.js +1 -1
- package/dist/esm/common.d.ts +2 -2
- package/package.json +20 -20
package/dist/cjs/base.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
12
|
import { Configuration } from './configuration';
|
|
13
|
-
import { AxiosInstance } from 'axios';
|
|
13
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
14
14
|
export declare const BASE_PATH: string;
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -29,7 +29,7 @@ export declare const COLLECTION_FORMATS: {
|
|
|
29
29
|
*/
|
|
30
30
|
export interface RequestArgs {
|
|
31
31
|
url: string;
|
|
32
|
-
options:
|
|
32
|
+
options: AxiosRequestConfig;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
*
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { RequestOptions } from 'https';
|
|
3
2
|
import { BaseReq, DeleteReq } from '../../client/index';
|
|
4
3
|
import { CreateFileRequest, FileMetadataData } from '../../index';
|
|
5
4
|
/** Upload file arguments. */
|
|
6
5
|
export interface UploadFileReq extends BaseReq {
|
|
7
6
|
/** A {@link CreateFileRequest}. */
|
|
8
7
|
readonly createFileReq: CreateFileRequest;
|
|
9
|
-
/** File data.
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
readonly fileData?: unknown;
|
|
13
|
-
readonly filePath?: string;
|
|
14
|
-
readonly bypassAxiosEXPERIMENTAL?: boolean;
|
|
8
|
+
/** File data. */
|
|
9
|
+
readonly fileData: Buffer;
|
|
15
10
|
}
|
|
16
11
|
/**
|
|
17
12
|
* Delete all files.
|
|
@@ -30,9 +25,4 @@ export declare function uploadFileIfNotExists({ client, createFileReq, onMsg, ve
|
|
|
30
25
|
*
|
|
31
26
|
* @param args - The {@link UploadFileReq}.
|
|
32
27
|
*/
|
|
33
|
-
export declare function uploadFile({ client, createFileReq, fileData,
|
|
34
|
-
interface UploadRes {
|
|
35
|
-
readonly status: number;
|
|
36
|
-
}
|
|
37
|
-
export declare const upload: (body: Buffer, opts: RequestOptions) => Promise<UploadRes>;
|
|
38
|
-
export {};
|
|
28
|
+
export declare function uploadFile({ client, createFileReq, fileData, onMsg, verbose, }: UploadFileReq): Promise<FileMetadataData>;
|
|
@@ -19,17 +19,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const fs_1 = __importDefault(require("fs"));
|
|
28
|
-
const https_1 = require("https");
|
|
29
|
-
const util_1 = require("util");
|
|
23
|
+
exports.uploadFile = exports.uploadFileIfNotExists = exports.deleteAllFiles = void 0;
|
|
30
24
|
const index_1 = require("../../client/index");
|
|
31
|
-
const readFile = (0, util_1.promisify)(fs_1.default.readFile);
|
|
32
|
-
const stat = (0, util_1.promisify)(fs_1.default.stat);
|
|
33
25
|
/**
|
|
34
26
|
* Delete all files.
|
|
35
27
|
*
|
|
@@ -93,8 +85,7 @@ exports.uploadFileIfNotExists = uploadFileIfNotExists;
|
|
|
93
85
|
*
|
|
94
86
|
* @param args - The {@link UploadFileReq}.
|
|
95
87
|
*/
|
|
96
|
-
function uploadFile({ client, createFileReq, fileData,
|
|
97
|
-
var _a;
|
|
88
|
+
function uploadFile({ client, createFileReq, fileData, onMsg = console.log, verbose, }) {
|
|
98
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
90
|
const fileName = createFileReq.data.attributes.name;
|
|
100
91
|
const createRes = yield client.files.createFile({
|
|
@@ -103,52 +94,21 @@ function uploadFile({ client, createFileReq, fileData, filePath, onMsg = console
|
|
|
103
94
|
const fileId = createRes.data.data.id;
|
|
104
95
|
if (verbose)
|
|
105
96
|
onMsg(`Created file '${fileName}', ${fileId}`);
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
:
|
|
109
|
-
|
|
110
|
-
? (0, exports.upload)(body, {
|
|
111
|
-
headers: {
|
|
112
|
-
Authorization: `Bearer ${client.token.access_token}`,
|
|
113
|
-
'Content-Type': 'application/octet-stream',
|
|
114
|
-
'Content-Length': size,
|
|
115
|
-
},
|
|
116
|
-
hostname: new URL((_a = client.config.basePath) !== null && _a !== void 0 ? _a : '').hostname,
|
|
117
|
-
method: 'POST',
|
|
118
|
-
port: 443,
|
|
119
|
-
path: `/files/${fileId}`,
|
|
120
|
-
})
|
|
121
|
-
: client.files.uploadFile({ id: fileId, body }, { headers: size >= 0 ? { 'Content-Length': size } : undefined }));
|
|
97
|
+
const uploadRes = yield client.files.uploadFile({
|
|
98
|
+
id: fileId,
|
|
99
|
+
body: fileData,
|
|
100
|
+
});
|
|
122
101
|
if (uploadRes.status !== 204) {
|
|
123
102
|
throw new Error(`Uploading file ${fileId} failed with status code ${uploadRes.status}`);
|
|
124
103
|
}
|
|
125
|
-
if (verbose)
|
|
126
|
-
onMsg(`Uploaded file ${fileId}`);
|
|
127
104
|
const getRes = (yield client.files.getFile({ id: fileId })).data.data;
|
|
128
|
-
if (size >= 0 && getRes.attributes.size !== size) {
|
|
129
|
-
onMsg(`File ${fileId} size mismatch, expected ${size} got ${getRes.attributes.size}`);
|
|
130
|
-
}
|
|
131
105
|
const status = getRes.attributes.status;
|
|
132
106
|
if (status === 'error') {
|
|
133
107
|
throw new Error(`Uploading file ${fileId} failed with status ${status}`);
|
|
134
108
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (verbose)
|
|
138
|
-
onMsg(`File ${fileId} in status ${status}, waiting...`);
|
|
139
|
-
yield (0, index_1.delay)(1000);
|
|
140
|
-
}
|
|
109
|
+
if (verbose)
|
|
110
|
+
onMsg(`Uploaded file ${fileId}, status ${status}`);
|
|
141
111
|
return getRes;
|
|
142
112
|
});
|
|
143
113
|
}
|
|
144
114
|
exports.uploadFile = uploadFile;
|
|
145
|
-
const upload = (body, opts) => new Promise((resolve, reject) => {
|
|
146
|
-
const req = (0, https_1.request)(opts, (r) => {
|
|
147
|
-
var _a;
|
|
148
|
-
r.resume();
|
|
149
|
-
resolve({ status: (_a = r.statusCode) !== null && _a !== void 0 ? _a : -1 });
|
|
150
|
-
});
|
|
151
|
-
req.on('error', (error) => (req.aborted ? null : reject(error)));
|
|
152
|
-
req.end(body);
|
|
153
|
-
});
|
|
154
|
-
exports.upload = upload;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { AxiosResponse } from 'axios';
|
|
2
3
|
import { CreateFileRequest, CreateGeometrySetRequest, CreatePartRequest, Failure, PartData, PartRevisionData, QueuedJob } from '../../index';
|
|
3
4
|
import { BaseReq, DeleteReq, Polling, RenderImageReq } from '../index';
|
|
@@ -7,11 +8,8 @@ export interface CreatePartFromFileReq extends BaseReq {
|
|
|
7
8
|
readonly createFileReq: CreateFileRequest;
|
|
8
9
|
/** Function returning a {@link CreatePartRequest}. */
|
|
9
10
|
readonly createPartReq: (fileId: string) => CreatePartRequest;
|
|
10
|
-
/** File data.
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
readonly fileData?: unknown;
|
|
14
|
-
readonly filePath?: string;
|
|
11
|
+
/** File data. */
|
|
12
|
+
readonly fileData: Buffer;
|
|
15
13
|
/** {@link Polling} */
|
|
16
14
|
readonly polling?: Polling;
|
|
17
15
|
/** Whether or not to return queued translation. */
|
|
@@ -97,7 +97,7 @@ function isPollError(r) {
|
|
|
97
97
|
exports.isPollError = isPollError;
|
|
98
98
|
function isBatch(obj) {
|
|
99
99
|
const b = obj;
|
|
100
|
-
return (0, utils_1.defined)(b) && (0, utils_1.defined)(b
|
|
100
|
+
return (0, utils_1.defined)(b) && (0, utils_1.defined)(b['vertexvis/batch:results']);
|
|
101
101
|
}
|
|
102
102
|
exports.isBatch = isBatch;
|
|
103
103
|
function throwOnError(r) {
|
|
@@ -182,7 +182,7 @@ function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, cre
|
|
|
182
182
|
})).scene,
|
|
183
183
|
sceneItemErrors: batchRes
|
|
184
184
|
.flatMap((b, i) => (0, queued_jobs_1.isBatch)(b.res)
|
|
185
|
-
? b.res.
|
|
185
|
+
? b.res['vertexvis/batch:results'].map((r, j) => (0, utils_1.isApiError)(r)
|
|
186
186
|
? { req: queuedOps[i].ops[j].data, res: r }
|
|
187
187
|
: undefined)
|
|
188
188
|
: [])
|
|
@@ -212,16 +212,7 @@ function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, o
|
|
|
212
212
|
let res;
|
|
213
213
|
try {
|
|
214
214
|
res = (yield client.batches.createBatch({
|
|
215
|
-
createBatchRequest: {
|
|
216
|
-
vertexvis_batchoperations: ops,
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
218
|
-
// @ts-ignore
|
|
219
|
-
toJSON() {
|
|
220
|
-
return {
|
|
221
|
-
'vertexvis/batch:operations': this.vertexvis_batchoperations,
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
},
|
|
215
|
+
createBatchRequest: { 'vertexvis/batch:operations': ops },
|
|
225
216
|
})).data;
|
|
226
217
|
}
|
|
227
218
|
catch (error) {
|
package/dist/cjs/client/utils.js
CHANGED
|
@@ -393,6 +393,7 @@ function tryStream(fn) {
|
|
|
393
393
|
return yield fn();
|
|
394
394
|
}
|
|
395
395
|
catch (error) {
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
396
397
|
const ae = error;
|
|
397
398
|
// eslint-disable-next-line promise/param-names
|
|
398
399
|
return new Promise((_resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.15.
|
|
1
|
+
export declare const version = "0.15.6";
|
package/dist/cjs/common.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { Configuration } from './configuration';
|
|
13
13
|
import { RequestArgs } from './base';
|
|
14
|
-
import { AxiosInstance } from 'axios';
|
|
14
|
+
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
* @export
|
|
@@ -62,4 +62,4 @@ export declare const toPathString: (url: URL) => string;
|
|
|
62
62
|
*
|
|
63
63
|
* @export
|
|
64
64
|
*/
|
|
65
|
-
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => (axios?: AxiosInstance, basePath?: string) => Promise<
|
|
65
|
+
export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration | undefined) => <T = unknown, R = AxiosResponse<T, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
|