@vertexvis/api-client-node 0.14.7 → 0.15.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.
@@ -4,8 +4,11 @@ import { CreateFileRequest, FileMetadataData } from '../../index';
4
4
  export interface UploadFileReq extends BaseReq {
5
5
  /** A {@link CreateFileRequest}. */
6
6
  readonly createFileReq: CreateFileRequest;
7
- /** File data, use {@link Buffer} or {@link ReadStream} in Node. */
8
- readonly fileData: unknown;
7
+ /** File data.
8
+ * @deprecated Use {@link filePath} instead.
9
+ */
10
+ readonly fileData?: unknown;
11
+ readonly filePath?: string;
9
12
  }
10
13
  /**
11
14
  * Delete all files.
@@ -18,10 +21,10 @@ export declare function deleteAllFiles({ client, pageSize, exceptions, }: Delete
18
21
  *
19
22
  * @param args - The {@link UploadFileReq}.
20
23
  */
21
- export declare function uploadFileIfNotExists({ client, createFileReq, fileData, onMsg, verbose, }: UploadFileReq): Promise<FileMetadataData>;
24
+ export declare function uploadFileIfNotExists({ client, createFileReq, fileData, filePath, onMsg, verbose, }: UploadFileReq): Promise<FileMetadataData>;
22
25
  /**
23
26
  * Create a file resource and upload a file.
24
27
  *
25
28
  * @param args - The {@link UploadFileReq}.
26
29
  */
27
- export declare function uploadFile({ client, createFileReq, fileData, onMsg, verbose, }: UploadFileReq): Promise<FileMetadataData>;
30
+ export declare function uploadFile({ client, createFileReq, fileData, filePath, onMsg, verbose, }: UploadFileReq): Promise<FileMetadataData>;
@@ -8,9 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.uploadFile = exports.uploadFileIfNotExists = exports.deleteAllFiles = void 0;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const util_1 = require("util");
13
18
  const index_1 = require("../../client/index");
19
+ const readFile = (0, util_1.promisify)(fs_1.default.readFile);
20
+ const stat = (0, util_1.promisify)(fs_1.default.stat);
14
21
  /**
15
22
  * Delete all files.
16
23
  *
@@ -40,7 +47,7 @@ exports.deleteAllFiles = deleteAllFiles;
40
47
  *
41
48
  * @param args - The {@link UploadFileReq}.
42
49
  */
43
- function uploadFileIfNotExists({ client, createFileReq, fileData, onMsg = console.log, verbose, }) {
50
+ function uploadFileIfNotExists({ client, createFileReq, fileData, filePath, onMsg = console.log, verbose, }) {
44
51
  return __awaiter(this, void 0, void 0, function* () {
45
52
  const suppliedId = createFileReq.data.attributes.suppliedId;
46
53
  const existingFile = suppliedId
@@ -64,7 +71,14 @@ function uploadFileIfNotExists({ client, createFileReq, fileData, onMsg = consol
64
71
  yield client.files.deleteFile({ id: fileId });
65
72
  }
66
73
  }
67
- return uploadFile({ client, createFileReq, fileData, onMsg, verbose });
74
+ return uploadFile({
75
+ client,
76
+ createFileReq,
77
+ fileData,
78
+ filePath,
79
+ onMsg,
80
+ verbose,
81
+ });
68
82
  });
69
83
  }
70
84
  exports.uploadFileIfNotExists = uploadFileIfNotExists;
@@ -73,7 +87,7 @@ exports.uploadFileIfNotExists = uploadFileIfNotExists;
73
87
  *
74
88
  * @param args - The {@link UploadFileReq}.
75
89
  */
76
- function uploadFile({ client, createFileReq, fileData, onMsg = console.log, verbose, }) {
90
+ function uploadFile({ client, createFileReq, fileData, filePath, onMsg = console.log, verbose, }) {
77
91
  return __awaiter(this, void 0, void 0, function* () {
78
92
  const fileName = createFileReq.data.attributes.name;
79
93
  const createRes = yield client.files.createFile({
@@ -82,10 +96,16 @@ function uploadFile({ client, createFileReq, fileData, onMsg = console.log, verb
82
96
  const fileId = createRes.data.data.id;
83
97
  if (verbose)
84
98
  onMsg(`Created file '${fileName}', ${fileId}`);
85
- yield client.files.uploadFile({ id: fileId, body: fileData });
99
+ const [body, { size }] = filePath
100
+ ? yield Promise.all([readFile(filePath), stat(filePath)])
101
+ : [fileData, { size: -1 }];
102
+ yield client.files.uploadFile({ id: fileId, body }, { headers: size >= 0 ? { 'Content-Length': size } : undefined });
86
103
  if (verbose)
87
104
  onMsg(`Uploaded file ${fileId}`);
88
105
  const updated = (yield client.files.getFile({ id: fileId })).data.data;
106
+ if (size >= 0 && updated.attributes.size !== size) {
107
+ onMsg(`File ${fileId} size mismatch, expected ${size} got ${updated.attributes.size}`);
108
+ }
89
109
  const status = updated.attributes.status;
90
110
  if (status === 'error')
91
111
  throw new Error(`Uploading file ${fileId} failed with status ${status}`);
@@ -7,8 +7,11 @@ export interface CreatePartFromFileReq extends BaseReq {
7
7
  readonly createFileReq: CreateFileRequest;
8
8
  /** Function returning a {@link CreatePartRequest}. */
9
9
  readonly createPartReq: (fileId: string) => CreatePartRequest;
10
- /** File data, use {@link Buffer} in Node. */
11
- readonly fileData: unknown;
10
+ /** File data.
11
+ * @deprecated Use {@link filePath} instead.
12
+ */
13
+ readonly fileData?: unknown;
14
+ readonly filePath?: string;
12
15
  /** {@link Polling} */
13
16
  readonly polling?: Polling;
14
17
  /** Whether or not to return queued translation. */
@@ -36,7 +39,7 @@ export interface GetPartRevisionBySuppliedIdReq extends BaseReq {
36
39
  *
37
40
  * @param args - The {@link CreatePartFromFileReq}.
38
41
  */
39
- export declare function createPartFromFile({ client, createFileReq, createPartReq, fileData, onMsg, polling, returnQueued, verbose, }: CreatePartFromFileReq): Promise<CreatePartFromFileRes>;
42
+ export declare function createPartFromFile({ client, createFileReq, createPartReq, fileData, filePath, onMsg, polling, returnQueued, verbose, }: CreatePartFromFileReq): Promise<CreatePartFromFileRes>;
40
43
  /**
41
44
  * Create part and file resources if they don't already exist.
42
45
  *
@@ -17,13 +17,14 @@ const queued_jobs_1 = require("./queued-jobs");
17
17
  *
18
18
  * @param args - The {@link CreatePartFromFileReq}.
19
19
  */
20
- function createPartFromFile({ client, createFileReq, createPartReq, fileData, onMsg = console.log, polling = { intervalMs: index_1.PollIntervalMs, maxAttempts: index_1.MaxAttempts }, returnQueued = false, verbose, }) {
20
+ function createPartFromFile({ client, createFileReq, createPartReq, fileData, filePath, onMsg = console.log, polling = { intervalMs: index_1.PollIntervalMs, maxAttempts: index_1.MaxAttempts }, returnQueued = false, verbose, }) {
21
21
  var _a, _b;
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  const file = yield (0, index_1.uploadFileIfNotExists)({
24
24
  client,
25
25
  verbose,
26
26
  fileData,
27
+ filePath,
27
28
  createFileReq,
28
29
  onMsg,
29
30
  });
@@ -197,7 +197,7 @@ exports.createSceneAndSceneItemsEXPERIMENTAL = createSceneAndSceneItemsEXPERIMEN
197
197
  function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }) {
198
198
  return __awaiter(this, void 0, void 0, function* () {
199
199
  const limit = (0, p_limit_1.default)(parallelism);
200
- const batchSize = 250;
200
+ const batchSize = 500;
201
201
  let complete = 0;
202
202
  const opChunks = (0, utils_1.arrayChunked)(createSceneItemReqs.map((req) => ({
203
203
  data: req.data,
@@ -28,7 +28,7 @@ export interface Polling {
28
28
  readonly maxAttempts: number;
29
29
  }
30
30
  /**
31
- * Render image arguments. Render functions return Streams in Node. Here's an
31
+ * Render image arguments. Render functions return Streams. Here's an
32
32
  * example awaiting file creation,
33
33
  *
34
34
  * @example
@@ -1 +1 @@
1
- export declare const version = "0.14.7";
1
+ export declare const version = "0.15.2";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = '0.14.7';
4
+ exports.version = '0.15.2';
@@ -1,12 +1,12 @@
1
1
  import { AxiosInstance, AxiosRequestConfig } from 'axios';
2
- import { BatchesApi, Configuration, FilesApi, GeometrySetsApi, HitsApi, OAuth2Token, PartRevisionsApi, PartsApi, SceneAlterationsApi, SceneItemOverridesApi, SceneItemsApi, ScenesApi, SceneViewsApi, SceneViewStatesApi, StreamKeysApi, TranslationInspectionsApi, WebhookSubscriptionsApi } from '../index';
2
+ import { AccountsApi, ApplicationsApi, BatchesApi, Configuration, FilesApi, GeometrySetsApi, HitsApi, OAuth2Token, PartRevisionsApi, PartsApi, SceneAlterationsApi, SceneItemOverridesApi, SceneItemsApi, ScenesApi, SceneViewsApi, SceneViewStatesApi, StreamKeysApi, TranslationInspectionsApi, WebhookSubscriptionsApi } from '../index';
3
3
  import { BasePath } from './index';
4
4
  /**
5
5
  * Static `build` function arguments.
6
6
  */
7
7
  export interface BuildReq {
8
8
  /**
9
- * A {@link AxiosRequestConfig}. For example, to use HTTP keep-alive in Node,
9
+ * A {@link AxiosRequestConfig}. For example, to use HTTP keep-alive,
10
10
  *
11
11
  * * @example
12
12
  * ```typescript
@@ -69,6 +69,8 @@ export interface BuildReq {
69
69
  * @see {@link https://developer.vertexvis.com/docs/guides|Developer Guides} to get started.
70
70
  */
71
71
  export declare class VertexClient {
72
+ accounts: AccountsApi;
73
+ applications: ApplicationsApi;
72
74
  batches: BatchesApi;
73
75
  files: FilesApi;
74
76
  geometrySets: GeometrySetsApi;
@@ -76,6 +76,8 @@ class VertexClient {
76
76
  basePath,
77
77
  });
78
78
  this.axiosInstance = axiosInst;
79
+ this.accounts = new index_1.AccountsApi(this.config, undefined, axiosInst);
80
+ this.applications = new index_1.ApplicationsApi(this.config, undefined, axiosInst);
79
81
  this.batches = new index_1.BatchesApi(this.config, undefined, axiosInst);
80
82
  this.files = new index_1.FilesApi(this.config, undefined, axiosInst);
81
83
  this.geometrySets = new index_1.GeometrySetsApi(this.config, undefined, axiosInst);