@vertexvis/api-client-node 0.20.0 → 0.20.3

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 CHANGED
@@ -671,7 +671,7 @@ export interface Color3 {
671
671
  */
672
672
  export interface ColorMaterial {
673
673
  /**
674
- * Opacity from 0 to 100.
674
+ * An opacity value from 0 to 255.
675
675
  * @type {number}
676
676
  * @memberof ColorMaterial
677
677
  */
@@ -714,7 +714,7 @@ export interface ColorMaterial {
714
714
  */
715
715
  export interface ColorMaterialNullable {
716
716
  /**
717
- * Opacity from 0 to 100.
717
+ * An opacity value from 0 to 255.
718
718
  * @type {number}
719
719
  * @memberof ColorMaterialNullable
720
720
  */
@@ -1107,11 +1107,19 @@ export interface CreatePartRequestDataAttributes {
1107
1107
  */
1108
1108
  suppliedRevisionId?: string;
1109
1109
  /**
1110
- * Whether or not to index metadata in the part file.
1110
+ * Whether or not to index metadata in the part file. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field.
1111
1111
  * @type {boolean}
1112
1112
  * @memberof CreatePartRequestDataAttributes
1113
1113
  */
1114
1114
  indexMetadata?: boolean;
1115
+ /**
1116
+ * Additional metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified.
1117
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
1118
+ * @memberof CreatePartRequestDataAttributes
1119
+ */
1120
+ metadata?: {
1121
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
1122
+ };
1115
1123
  /**
1116
1124
  * Name to be used for the root part.
1117
1125
  * @type {string}
@@ -2577,30 +2585,54 @@ export interface Matrix4Nullable {
2577
2585
  /**
2578
2586
  *
2579
2587
  * @export
2580
- * @interface MetadataValue
2588
+ * @interface MetadataFloatType
2581
2589
  */
2582
- export interface MetadataValue {
2590
+ export interface MetadataFloatType {
2583
2591
  /**
2584
- * Metadata value.
2592
+ * Type of metadata value.
2585
2593
  * @type {string}
2586
- * @memberof MetadataValue
2594
+ * @memberof MetadataFloatType
2595
+ */
2596
+ type: string;
2597
+ /**
2598
+ * A numerical floating-point value.
2599
+ * @type {number}
2600
+ * @memberof MetadataFloatType
2587
2601
  */
2588
- value?: string;
2602
+ value: number;
2603
+ }
2604
+ /**
2605
+ *
2606
+ * @export
2607
+ * @interface MetadataNullType
2608
+ */
2609
+ export interface MetadataNullType {
2589
2610
  /**
2590
2611
  * Type of metadata value.
2591
2612
  * @type {string}
2592
- * @memberof MetadataValue
2613
+ * @memberof MetadataNullType
2593
2614
  */
2594
- type: MetadataValueTypeEnum;
2615
+ type: string;
2616
+ }
2617
+ /**
2618
+ *
2619
+ * @export
2620
+ * @interface MetadataStringType
2621
+ */
2622
+ export interface MetadataStringType {
2623
+ /**
2624
+ * Type of metadata value.
2625
+ * @type {string}
2626
+ * @memberof MetadataStringType
2627
+ */
2628
+ type: string;
2629
+ /**
2630
+ * A string value.
2631
+ * @type {string}
2632
+ * @memberof MetadataStringType
2633
+ */
2634
+ value: string;
2595
2635
  }
2596
- export declare const MetadataValueTypeEnum: {
2597
- readonly String: "string";
2598
- readonly Long: "long";
2599
- readonly Float: "float";
2600
- readonly Date: "date";
2601
- readonly Null: "null";
2602
- };
2603
- export declare type MetadataValueTypeEnum = typeof MetadataValueTypeEnum[keyof typeof MetadataValueTypeEnum];
2604
2636
  /**
2605
2637
  *
2606
2638
  * @export
@@ -2958,11 +2990,11 @@ export interface PartRevisionDataAttributes {
2958
2990
  created?: string;
2959
2991
  /**
2960
2992
  *
2961
- * @type {{ [key: string]: MetadataValue; }}
2993
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
2962
2994
  * @memberof PartRevisionDataAttributes
2963
2995
  */
2964
2996
  metadata?: {
2965
- [key: string]: MetadataValue;
2997
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
2966
2998
  };
2967
2999
  /**
2968
3000
  *
@@ -3694,11 +3726,11 @@ export interface SceneItemDataAttributes {
3694
3726
  materialOverride?: ColorMaterial;
3695
3727
  /**
3696
3728
  *
3697
- * @type {{ [key: string]: MetadataValue; }}
3729
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
3698
3730
  * @memberof SceneItemDataAttributes
3699
3731
  */
3700
3732
  metadata?: {
3701
- [key: string]: MetadataValue;
3733
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
3702
3734
  };
3703
3735
  /**
3704
3736
  *
@@ -4737,15 +4769,15 @@ export interface UpdatePartRevisionRequestData {
4737
4769
  */
4738
4770
  export interface UpdatePartRevisionRequestDataAttributes {
4739
4771
  /**
4740
- * Metadata about the `part` and/or `part-revision`.
4741
- * @type {{ [key: string]: MetadataValue; }}
4772
+ * Metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified.
4773
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
4742
4774
  * @memberof UpdatePartRevisionRequestDataAttributes
4743
4775
  */
4744
4776
  metadata?: {
4745
- [key: string]: MetadataValue;
4777
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
4746
4778
  };
4747
4779
  /**
4748
- * Whether or not to index metadata in the part file when sending a file relationship - not used otherwise.
4780
+ * Whether or not to index metadata in the part file when sending a file relationship - not used otherwise. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field.
4749
4781
  * @type {boolean}
4750
4782
  * @memberof UpdatePartRevisionRequestDataAttributes
4751
4783
  */
package/dist/cjs/api.js CHANGED
@@ -25,9 +25,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.FilesApiFactory = exports.FilesApiFp = exports.FilesApiAxiosParamCreator = exports.ExportsApi = exports.ExportsApiFactory = exports.ExportsApiFp = exports.ExportsApiAxiosParamCreator = exports.BatchesApi = exports.BatchesApiFactory = exports.BatchesApiFp = exports.BatchesApiAxiosParamCreator = exports.ApplicationsApi = exports.ApplicationsApiFactory = exports.ApplicationsApiFp = exports.ApplicationsApiAxiosParamCreator = exports.AccountsApi = exports.AccountsApiFactory = exports.AccountsApiFp = exports.AccountsApiAxiosParamCreator = exports.WebhookSubscriptionDataAttributesStatusEnum = exports.WebhookEventDataRelationshipsOwnerDataTypeEnum = exports.UpdateWebhookSubscriptionRequestDataAttributesStatusEnum = exports.UpdateSceneRequestDataAttributesStateEnum = exports.UpdateAccountRequestDataAttributesStatusEnum = exports.SelectOperationTypeEnum = exports.SceneViewStateRelationshipDataTypeEnum = exports.SceneViewRelationshipDataTypeEnum = exports.SceneRelationshipDataTypeEnum = exports.SceneItemRelationshipDataTypeEnum = exports.QueryByIdDataAttributesTypeEnum = exports.QueryByIdDataTypeEnum = exports.QueryByCollectionDataAttributesTypeEnum = exports.QueryByCollectionDataTypeEnum = exports.QueryAll = exports.PartRelationshipDataTypeEnum = exports.PartDataRelationshipsPartRevisionsTypeEnum = exports.MetadataValueTypeEnum = exports.GeometrySetRelationshipDataTypeEnum = exports.FileRelationshipDataTypeEnum = exports.ExportStateRelationshipDataTypeEnum = exports.ExportRelationshipDataTypeEnum = exports.DeselectOperationTypeEnum = exports.ClearTransformOperationTypeEnum = exports.ClearMaterialOperationTypeEnum = exports.ChangeVisibilityOperationTypeEnum = exports.ChangeTransformOperationTypeEnum = exports.ChangeMaterialOperationTypeEnum = exports.CameraFitTypeEnum = exports.BatchOperationRefTypeEnum = exports.BatchOperationOpEnum = void 0;
29
- exports.TranslationInspectionsApiAxiosParamCreator = exports.StreamKeysApi = exports.StreamKeysApiFactory = exports.StreamKeysApiFp = exports.StreamKeysApiAxiosParamCreator = exports.ScenesApi = exports.ScenesApiFactory = exports.ScenesApiFp = exports.ScenesApiAxiosParamCreator = exports.SceneViewsApi = exports.SceneViewsApiFactory = exports.SceneViewsApiFp = exports.SceneViewsApiAxiosParamCreator = exports.SceneViewStatesApi = exports.SceneViewStatesApiFactory = exports.SceneViewStatesApiFp = exports.SceneViewStatesApiAxiosParamCreator = exports.SceneItemsApi = exports.SceneItemsApiFactory = exports.SceneItemsApiFp = exports.SceneItemsApiAxiosParamCreator = exports.SceneItemOverridesApi = exports.SceneItemOverridesApiFactory = exports.SceneItemOverridesApiFp = exports.SceneItemOverridesApiAxiosParamCreator = exports.SceneAlterationsApi = exports.SceneAlterationsApiFactory = exports.SceneAlterationsApiFp = exports.SceneAlterationsApiAxiosParamCreator = exports.PartsApi = exports.PartsApiFactory = exports.PartsApiFp = exports.PartsApiAxiosParamCreator = exports.PartRevisionsApi = exports.PartRevisionsApiFactory = exports.PartRevisionsApiFp = exports.PartRevisionsApiAxiosParamCreator = exports.Oauth2Api = exports.Oauth2ApiFactory = exports.Oauth2ApiFp = exports.Oauth2ApiAxiosParamCreator = exports.HitsApi = exports.HitsApiFactory = exports.HitsApiFp = exports.HitsApiAxiosParamCreator = exports.GeometrySetsApi = exports.GeometrySetsApiFactory = exports.GeometrySetsApiFp = exports.GeometrySetsApiAxiosParamCreator = exports.FilesApi = void 0;
30
- exports.WebhookSubscriptionsApi = exports.WebhookSubscriptionsApiFactory = exports.WebhookSubscriptionsApiFp = exports.WebhookSubscriptionsApiAxiosParamCreator = exports.TranslationInspectionsApi = exports.TranslationInspectionsApiFactory = exports.TranslationInspectionsApiFp = void 0;
28
+ exports.FilesApi = exports.FilesApiFactory = exports.FilesApiFp = exports.FilesApiAxiosParamCreator = exports.ExportsApi = exports.ExportsApiFactory = exports.ExportsApiFp = exports.ExportsApiAxiosParamCreator = exports.BatchesApi = exports.BatchesApiFactory = exports.BatchesApiFp = exports.BatchesApiAxiosParamCreator = exports.ApplicationsApi = exports.ApplicationsApiFactory = exports.ApplicationsApiFp = exports.ApplicationsApiAxiosParamCreator = exports.AccountsApi = exports.AccountsApiFactory = exports.AccountsApiFp = exports.AccountsApiAxiosParamCreator = exports.WebhookSubscriptionDataAttributesStatusEnum = exports.WebhookEventDataRelationshipsOwnerDataTypeEnum = exports.UpdateWebhookSubscriptionRequestDataAttributesStatusEnum = exports.UpdateSceneRequestDataAttributesStateEnum = exports.UpdateAccountRequestDataAttributesStatusEnum = exports.SelectOperationTypeEnum = exports.SceneViewStateRelationshipDataTypeEnum = exports.SceneViewRelationshipDataTypeEnum = exports.SceneRelationshipDataTypeEnum = exports.SceneItemRelationshipDataTypeEnum = exports.QueryByIdDataAttributesTypeEnum = exports.QueryByIdDataTypeEnum = exports.QueryByCollectionDataAttributesTypeEnum = exports.QueryByCollectionDataTypeEnum = exports.QueryAll = exports.PartRelationshipDataTypeEnum = exports.PartDataRelationshipsPartRevisionsTypeEnum = exports.GeometrySetRelationshipDataTypeEnum = exports.FileRelationshipDataTypeEnum = exports.ExportStateRelationshipDataTypeEnum = exports.ExportRelationshipDataTypeEnum = exports.DeselectOperationTypeEnum = exports.ClearTransformOperationTypeEnum = exports.ClearMaterialOperationTypeEnum = exports.ChangeVisibilityOperationTypeEnum = exports.ChangeTransformOperationTypeEnum = exports.ChangeMaterialOperationTypeEnum = exports.CameraFitTypeEnum = exports.BatchOperationRefTypeEnum = exports.BatchOperationOpEnum = void 0;
29
+ exports.TranslationInspectionsApiFp = exports.TranslationInspectionsApiAxiosParamCreator = exports.StreamKeysApi = exports.StreamKeysApiFactory = exports.StreamKeysApiFp = exports.StreamKeysApiAxiosParamCreator = exports.ScenesApi = exports.ScenesApiFactory = exports.ScenesApiFp = exports.ScenesApiAxiosParamCreator = exports.SceneViewsApi = exports.SceneViewsApiFactory = exports.SceneViewsApiFp = exports.SceneViewsApiAxiosParamCreator = exports.SceneViewStatesApi = exports.SceneViewStatesApiFactory = exports.SceneViewStatesApiFp = exports.SceneViewStatesApiAxiosParamCreator = exports.SceneItemsApi = exports.SceneItemsApiFactory = exports.SceneItemsApiFp = exports.SceneItemsApiAxiosParamCreator = exports.SceneItemOverridesApi = exports.SceneItemOverridesApiFactory = exports.SceneItemOverridesApiFp = exports.SceneItemOverridesApiAxiosParamCreator = exports.SceneAlterationsApi = exports.SceneAlterationsApiFactory = exports.SceneAlterationsApiFp = exports.SceneAlterationsApiAxiosParamCreator = exports.PartsApi = exports.PartsApiFactory = exports.PartsApiFp = exports.PartsApiAxiosParamCreator = exports.PartRevisionsApi = exports.PartRevisionsApiFactory = exports.PartRevisionsApiFp = exports.PartRevisionsApiAxiosParamCreator = exports.Oauth2Api = exports.Oauth2ApiFactory = exports.Oauth2ApiFp = exports.Oauth2ApiAxiosParamCreator = exports.HitsApi = exports.HitsApiFactory = exports.HitsApiFp = exports.HitsApiAxiosParamCreator = exports.GeometrySetsApi = exports.GeometrySetsApiFactory = exports.GeometrySetsApiFp = exports.GeometrySetsApiAxiosParamCreator = void 0;
30
+ exports.WebhookSubscriptionsApi = exports.WebhookSubscriptionsApiFactory = exports.WebhookSubscriptionsApiFp = exports.WebhookSubscriptionsApiAxiosParamCreator = exports.TranslationInspectionsApi = exports.TranslationInspectionsApiFactory = void 0;
31
31
  const axios_1 = __importDefault(require("axios"));
32
32
  // Some imports not used depending on template conditions
33
33
  // @ts-ignore
@@ -74,13 +74,6 @@ exports.FileRelationshipDataTypeEnum = {
74
74
  exports.GeometrySetRelationshipDataTypeEnum = {
75
75
  GeometrySet: 'geometry-set',
76
76
  };
77
- exports.MetadataValueTypeEnum = {
78
- String: 'string',
79
- Long: 'long',
80
- Float: 'float',
81
- Date: 'date',
82
- Null: 'null',
83
- };
84
77
  exports.PartDataRelationshipsPartRevisionsTypeEnum = {
85
78
  PartRevision: 'part-revision',
86
79
  };
@@ -74,9 +74,10 @@ function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { i
74
74
  let attempts = 1;
75
75
  let pollRes = yield poll(attempts);
76
76
  /* eslint-disable no-await-in-loop */
77
- while ((allowed404(allow404, pollRes.status) ||
78
- validJob(pollRes.res) ||
79
- isClientError(pollRes.res)) &&
77
+ while (!completeJob(pollRes.res) &&
78
+ (allowed404(allow404, pollRes.status) ||
79
+ validJob(pollRes.res) ||
80
+ isClientError(pollRes.res)) &&
80
81
  attempts <= maxAttempts) {
81
82
  attempts += 1;
82
83
  yield (0, utils_1.delay)(intervalMs);
@@ -85,7 +86,7 @@ function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polling: { i
85
86
  /* eslint-enable no-await-in-loop */
86
87
  // At this point, the result is one of the following,
87
88
  // - An item of type `T` after being redirected to it
88
- // - A QueuedJob (after either exceeding `maxAttempts` or with `error` status)
89
+ // - A QueuedJob (after either exceeding `maxAttempts` or with `complete` or `error` status)
89
90
  // - A Failure
90
91
  return Object.assign(Object.assign({}, pollRes), { attempts, id });
91
92
  });
@@ -115,10 +116,16 @@ function allowed404(allow404, status) {
115
116
  function validJob(r) {
116
117
  return (0, utils_1.isQueuedJob)(r) && !isStatusError(r);
117
118
  }
119
+ function completeJob(r) {
120
+ return (0, utils_1.isQueuedJob)(r) && isStatusComplete(r);
121
+ }
118
122
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
119
123
  function isQueuedJobError(obj) {
120
124
  return (0, utils_1.isQueuedJob)(obj) && isStatusError(obj);
121
125
  }
126
+ function isStatusComplete(job) {
127
+ return job.data.attributes.status === 'complete';
128
+ }
122
129
  function isStatusError(job) {
123
130
  return job.data.attributes.status === 'error';
124
131
  }
@@ -17,6 +17,22 @@ export interface CreateSceneAndSceneItemsReq extends BaseReq {
17
17
  /** Whether or not to return queued scene items. */
18
18
  readonly returnQueued?: boolean;
19
19
  }
20
+ export interface CreateSceneAndSceneItemsReqEXPERIMENTAL extends BaseReq {
21
+ /** A list of {@link CreateSceneItemRequest}. */
22
+ readonly createSceneItemReqs: Array<Array<CreateSceneItemRequest>>;
23
+ /** Function returning a {@link CreateSceneRequest}. */
24
+ readonly createSceneReq: () => CreateSceneRequest;
25
+ /** Whether or not to fail if any scene item fails initial validation. */
26
+ readonly failFast?: boolean;
27
+ /** How many requests to run in parallel. */
28
+ readonly parallelism: number;
29
+ /** {@link Polling} */
30
+ readonly polling?: Polling;
31
+ /** Callback with total number of requests and number complete. */
32
+ onProgress?: (complete: number, total: number) => void;
33
+ /** Whether or not to return queued scene items. */
34
+ readonly returnQueued?: boolean;
35
+ }
20
36
  export interface CreateSceneAndSceneItemsRes {
21
37
  readonly errors: QueuedSceneItem[];
22
38
  readonly scene: Scene;
@@ -90,13 +106,13 @@ export declare function createSceneAndSceneItems({ client, createSceneItemReqs,
90
106
  */
91
107
  export declare function createSceneItems({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsRes>;
92
108
  /**
93
- * Create a scene with scene items.
109
+ * Create a scene with scene items using experimental strategy.
94
110
  */
95
- export declare function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast, onMsg, onProgress, parallelism, polling, returnQueued, verbose, }: CreateSceneAndSceneItemsReq): Promise<CreateSceneAndSceneItemsResEXPERIMENTAL>;
111
+ export declare function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast, onMsg, onProgress, parallelism, polling, returnQueued, verbose, }: CreateSceneAndSceneItemsReqEXPERIMENTAL): Promise<CreateSceneAndSceneItemsResEXPERIMENTAL>;
96
112
  /**
97
113
  * Create scene items within a scene.
98
114
  */
99
- export declare function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsResEXPERIMENTAL>;
115
+ export declare function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsResEXPERIMENTAL>;
100
116
  /**
101
117
  * Delete all scenes.
102
118
  *
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.updateScene = exports.renderScene = exports.pollSceneReady = exports.deleteAllScenes = exports.createSceneItemsEXPERIMENTAL = exports.createSceneAndSceneItemsEXPERIMENTAL = exports.createSceneItems = exports.createSceneAndSceneItems = void 0;
16
16
  const p_limit_1 = __importDefault(require("p-limit"));
17
+ const process_1 = require("process");
17
18
  const index_1 = require("../../index");
18
19
  const index_2 = require("../index");
19
20
  const utils_1 = require("../utils");
@@ -121,45 +122,93 @@ function createSceneItems({ client, createSceneItemReqs, failFast, onProgress, p
121
122
  }
122
123
  exports.createSceneItems = createSceneItems;
123
124
  /**
124
- * Create a scene with scene items.
125
+ * Create a scene with scene items using experimental strategy.
125
126
  */
126
127
  function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast = false, onMsg = console.log, onProgress, parallelism, polling = { intervalMs: index_2.PollIntervalMs, maxAttempts: index_2.MaxAttempts }, returnQueued = false, verbose, }) {
127
128
  return __awaiter(this, void 0, void 0, function* () {
129
+ const startTime = process_1.hrtime.bigint();
130
+ if (verbose)
131
+ onMsg(`Creating scene...`);
128
132
  const scene = (yield client.scenes.createScene({ createSceneRequest: createSceneReq() })).data;
129
133
  const sceneId = scene.data.id;
130
- const createRes = yield createSceneItemsEXPERIMENTAL({
131
- client,
132
- createSceneItemReqs,
133
- failFast,
134
- onProgress,
135
- parallelism,
136
- sceneId,
137
- });
138
- const { a: queuedOps, b: errors } = (0, index_2.partition)(createRes.queuedBatchOps, (i) => (0, index_2.isQueuedJob)(i.res));
139
- const queued = returnQueued ? createRes.queuedBatchOps : [];
140
- // Nothing succeeded, return early as something is likely wrong
141
- if (queuedOps.length === 0 || errors.length === createRes.chunks) {
142
- return { errors, queued, scene, sceneItemErrors: [] };
143
- }
144
134
  if (verbose)
145
- onMsg(`Polling for completed scene-item batches...`);
146
- const limit = (0, p_limit_1.default)(Math.min(parallelism, 20));
147
- function poll({ ops, res, }) {
148
- return __awaiter(this, void 0, void 0, function* () {
149
- const r = yield (0, queued_jobs_1.pollQueuedJob)({
150
- id: res.data.id,
151
- getQueuedJob: (id, cancelToken) => client.batches.getQueuedBatch({ id }, { cancelToken }),
152
- allow404: true,
153
- limit,
154
- polling,
155
- });
156
- if ((0, queued_jobs_1.isPollError)(r.res)) {
157
- failFast ? (0, queued_jobs_1.throwOnError)(r) : errors.push({ ops, res: r.res });
158
- }
159
- return r;
135
+ onMsg(`Creating scene items...`);
136
+ let itemCount = 0;
137
+ let batchQueuedOps = [];
138
+ let batchErrors = [];
139
+ let sceneItemErrors = [];
140
+ for (let depth = 0; depth < createSceneItemReqs.length; depth++) {
141
+ const createItemReqs = createSceneItemReqs[depth];
142
+ itemCount += createItemReqs.length;
143
+ if (verbose)
144
+ onMsg(`Creating ${createItemReqs.length} scene items at depth ${depth}...`);
145
+ // Await is used intentionally to defer loop iteration
146
+ // until all scene items have been created at each depth.
147
+ // eslint-disable-next-line no-await-in-loop
148
+ const createRes = yield createSceneItemsEXPERIMENTAL({
149
+ client,
150
+ createSceneItemReqs: createItemReqs,
151
+ failFast,
152
+ onProgress,
153
+ parallelism,
154
+ sceneId,
160
155
  });
156
+ const { a: queuedOps, b: errors } = (0, index_2.partition)(createRes.queuedBatchOps, (i) => (0, index_2.isQueuedJob)(i.res));
157
+ batchQueuedOps = batchQueuedOps.concat(queuedOps);
158
+ if (errors.length) {
159
+ batchErrors = batchErrors.concat(errors);
160
+ if (verbose)
161
+ onMsg(`WARNING: ${errors.length} scene item batch errors at depth ${depth}.`);
162
+ }
163
+ // Nothing succeeded, return early as something is likely wrong
164
+ if (queuedOps.length === 0 || errors.length === createRes.chunks) {
165
+ return {
166
+ errors,
167
+ queued: returnQueued ? createRes.queuedBatchOps : [],
168
+ scene,
169
+ sceneItemErrors: [],
170
+ };
171
+ }
172
+ const limit = (0, p_limit_1.default)(Math.min(parallelism, 20));
173
+ function poll({ ops, res, }) {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ const r = yield (0, queued_jobs_1.pollQueuedJob)({
176
+ id: res.data.id,
177
+ getQueuedJob: (id, cancelToken) => client.batches.getQueuedBatch({ id }, { cancelToken }),
178
+ allow404: true,
179
+ limit,
180
+ polling,
181
+ });
182
+ if ((0, queued_jobs_1.isPollError)(r.res)) {
183
+ failFast ? (0, queued_jobs_1.throwOnError)(r) : errors.push({ ops, res: r.res });
184
+ }
185
+ return r;
186
+ });
187
+ }
188
+ // eslint-disable-next-line no-await-in-loop
189
+ const batchRes = yield Promise.all(queuedOps.map((is) => limit(poll, is)));
190
+ const batchItemErrors = batchRes
191
+ .flatMap((b, i) => (0, queued_jobs_1.isBatch)(b.res)
192
+ ? b.res['vertexvis/batch:results'].map((r, j) => (0, utils_1.isApiError)(r)
193
+ ? { req: queuedOps[i].ops[j].data, res: r }
194
+ : undefined)
195
+ : [])
196
+ .filter(index_2.defined);
197
+ if (batchItemErrors.length) {
198
+ sceneItemErrors = sceneItemErrors.concat(batchItemErrors);
199
+ if (verbose)
200
+ onMsg(`WARNING: ${batchItemErrors.length} scene item creation errors at depth ${depth}.`);
201
+ }
202
+ }
203
+ if (verbose) {
204
+ onMsg(`Scene item creation complete for ${itemCount} scene items with max depth of ${createSceneItemReqs.length - 1}.`);
205
+ if (batchErrors.length) {
206
+ onMsg(` Batch errors: ${batchErrors.length}`);
207
+ }
208
+ if (sceneItemErrors.length) {
209
+ onMsg(` Scene item errors: ${sceneItemErrors.length}`);
210
+ }
161
211
  }
162
- const batchRes = yield Promise.all(queuedOps.map((is) => limit(poll, is)));
163
212
  if (verbose)
164
213
  onMsg(`Committing scene and polling until ready...`);
165
214
  yield updateScene({
@@ -169,24 +218,30 @@ function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, cre
169
218
  });
170
219
  yield pollSceneReady({ client, id: sceneId, onMsg, polling, verbose });
171
220
  if (verbose)
172
- onMsg(`Fitting scene's camera to scene-items...`);
221
+ onMsg(`Fitting scene's camera to scene items...`);
222
+ const sceneResult = (yield updateScene({
223
+ attributes: {
224
+ camera: { type: index_1.CameraFitTypeEnum.FitVisibleSceneItems },
225
+ },
226
+ client,
227
+ sceneId,
228
+ })).scene;
229
+ if (verbose) {
230
+ const formatTime = (seconds) => {
231
+ const h = Math.floor(seconds / 3600);
232
+ const m = Math.floor((seconds % 3600) / 60);
233
+ const s = Math.round(seconds % 60);
234
+ return [h, m > 9 ? m : h ? '0' + m : m || '0', s > 9 ? s : '0' + s]
235
+ .filter(Boolean)
236
+ .join(':');
237
+ };
238
+ onMsg(`Scene creation completed in ${formatTime(Number(process_1.hrtime.bigint() - startTime) / 1000000000)}.`);
239
+ }
173
240
  return {
174
- errors,
175
- queued,
176
- scene: (yield updateScene({
177
- attributes: {
178
- camera: { type: index_1.CameraFitTypeEnum.FitVisibleSceneItems },
179
- },
180
- client,
181
- sceneId,
182
- })).scene,
183
- sceneItemErrors: batchRes
184
- .flatMap((b, i) => (0, queued_jobs_1.isBatch)(b.res)
185
- ? b.res['vertexvis/batch:results'].map((r, j) => (0, utils_1.isApiError)(r)
186
- ? { req: queuedOps[i].ops[j].data, res: r }
187
- : undefined)
188
- : [])
189
- .filter(index_2.defined),
241
+ errors: batchErrors,
242
+ queued: batchQueuedOps,
243
+ scene: sceneResult,
244
+ sceneItemErrors,
190
245
  };
191
246
  });
192
247
  }
@@ -194,11 +249,10 @@ exports.createSceneAndSceneItemsEXPERIMENTAL = createSceneAndSceneItemsEXPERIMEN
194
249
  /**
195
250
  * Create scene items within a scene.
196
251
  */
197
- function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }) {
252
+ function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, parallelism, sceneId, }) {
198
253
  return __awaiter(this, void 0, void 0, function* () {
199
254
  const limit = (0, p_limit_1.default)(parallelism);
200
255
  const batchSize = 500;
201
- let complete = 0;
202
256
  const opChunks = (0, utils_1.arrayChunked)(createSceneItemReqs.map((req) => ({
203
257
  data: req.data,
204
258
  op: index_1.BatchOperationOpEnum.Add,
@@ -222,10 +276,6 @@ function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, o
222
276
  else
223
277
  throw error;
224
278
  }
225
- if (onProgress != null) {
226
- complete += opChunk.length;
227
- onProgress(complete, createSceneItemReqs.length);
228
- }
229
279
  return { ops, res };
230
280
  }), opChunk)));
231
281
  return { chunks: opChunks.length, queuedBatchOps };
@@ -1 +1 @@
1
- export declare const version = "0.20.0";
1
+ export declare const version = "0.20.3";
@@ -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.20.0';
4
+ exports.version = '0.20.3';
package/dist/esm/api.d.ts CHANGED
@@ -671,7 +671,7 @@ export interface Color3 {
671
671
  */
672
672
  export interface ColorMaterial {
673
673
  /**
674
- * Opacity from 0 to 100.
674
+ * An opacity value from 0 to 255.
675
675
  * @type {number}
676
676
  * @memberof ColorMaterial
677
677
  */
@@ -714,7 +714,7 @@ export interface ColorMaterial {
714
714
  */
715
715
  export interface ColorMaterialNullable {
716
716
  /**
717
- * Opacity from 0 to 100.
717
+ * An opacity value from 0 to 255.
718
718
  * @type {number}
719
719
  * @memberof ColorMaterialNullable
720
720
  */
@@ -1107,11 +1107,19 @@ export interface CreatePartRequestDataAttributes {
1107
1107
  */
1108
1108
  suppliedRevisionId?: string;
1109
1109
  /**
1110
- * Whether or not to index metadata in the part file.
1110
+ * Whether or not to index metadata in the part file. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field.
1111
1111
  * @type {boolean}
1112
1112
  * @memberof CreatePartRequestDataAttributes
1113
1113
  */
1114
1114
  indexMetadata?: boolean;
1115
+ /**
1116
+ * Additional metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified.
1117
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
1118
+ * @memberof CreatePartRequestDataAttributes
1119
+ */
1120
+ metadata?: {
1121
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
1122
+ };
1115
1123
  /**
1116
1124
  * Name to be used for the root part.
1117
1125
  * @type {string}
@@ -2577,30 +2585,54 @@ export interface Matrix4Nullable {
2577
2585
  /**
2578
2586
  *
2579
2587
  * @export
2580
- * @interface MetadataValue
2588
+ * @interface MetadataFloatType
2581
2589
  */
2582
- export interface MetadataValue {
2590
+ export interface MetadataFloatType {
2583
2591
  /**
2584
- * Metadata value.
2592
+ * Type of metadata value.
2585
2593
  * @type {string}
2586
- * @memberof MetadataValue
2594
+ * @memberof MetadataFloatType
2595
+ */
2596
+ type: string;
2597
+ /**
2598
+ * A numerical floating-point value.
2599
+ * @type {number}
2600
+ * @memberof MetadataFloatType
2587
2601
  */
2588
- value?: string;
2602
+ value: number;
2603
+ }
2604
+ /**
2605
+ *
2606
+ * @export
2607
+ * @interface MetadataNullType
2608
+ */
2609
+ export interface MetadataNullType {
2589
2610
  /**
2590
2611
  * Type of metadata value.
2591
2612
  * @type {string}
2592
- * @memberof MetadataValue
2613
+ * @memberof MetadataNullType
2593
2614
  */
2594
- type: MetadataValueTypeEnum;
2615
+ type: string;
2616
+ }
2617
+ /**
2618
+ *
2619
+ * @export
2620
+ * @interface MetadataStringType
2621
+ */
2622
+ export interface MetadataStringType {
2623
+ /**
2624
+ * Type of metadata value.
2625
+ * @type {string}
2626
+ * @memberof MetadataStringType
2627
+ */
2628
+ type: string;
2629
+ /**
2630
+ * A string value.
2631
+ * @type {string}
2632
+ * @memberof MetadataStringType
2633
+ */
2634
+ value: string;
2595
2635
  }
2596
- export declare const MetadataValueTypeEnum: {
2597
- readonly String: "string";
2598
- readonly Long: "long";
2599
- readonly Float: "float";
2600
- readonly Date: "date";
2601
- readonly Null: "null";
2602
- };
2603
- export declare type MetadataValueTypeEnum = typeof MetadataValueTypeEnum[keyof typeof MetadataValueTypeEnum];
2604
2636
  /**
2605
2637
  *
2606
2638
  * @export
@@ -2958,11 +2990,11 @@ export interface PartRevisionDataAttributes {
2958
2990
  created?: string;
2959
2991
  /**
2960
2992
  *
2961
- * @type {{ [key: string]: MetadataValue; }}
2993
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
2962
2994
  * @memberof PartRevisionDataAttributes
2963
2995
  */
2964
2996
  metadata?: {
2965
- [key: string]: MetadataValue;
2997
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
2966
2998
  };
2967
2999
  /**
2968
3000
  *
@@ -3694,11 +3726,11 @@ export interface SceneItemDataAttributes {
3694
3726
  materialOverride?: ColorMaterial;
3695
3727
  /**
3696
3728
  *
3697
- * @type {{ [key: string]: MetadataValue; }}
3729
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
3698
3730
  * @memberof SceneItemDataAttributes
3699
3731
  */
3700
3732
  metadata?: {
3701
- [key: string]: MetadataValue;
3733
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
3702
3734
  };
3703
3735
  /**
3704
3736
  *
@@ -4737,15 +4769,15 @@ export interface UpdatePartRevisionRequestData {
4737
4769
  */
4738
4770
  export interface UpdatePartRevisionRequestDataAttributes {
4739
4771
  /**
4740
- * Metadata about the `part` and/or `part-revision`.
4741
- * @type {{ [key: string]: MetadataValue; }}
4772
+ * Metadata about the `part` and/or `part-revision`. This metadata will take precedence over any metadata that belongs to the part file if `indexMetadata` is specified.
4773
+ * @type {{ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType; }}
4742
4774
  * @memberof UpdatePartRevisionRequestDataAttributes
4743
4775
  */
4744
4776
  metadata?: {
4745
- [key: string]: MetadataValue;
4777
+ [key: string]: MetadataStringType | MetadataFloatType | MetadataNullType;
4746
4778
  };
4747
4779
  /**
4748
- * Whether or not to index metadata in the part file when sending a file relationship - not used otherwise.
4780
+ * Whether or not to index metadata in the part file when sending a file relationship - not used otherwise. To ignore metadata from the part file and add your own, pass `false` for `indexMetadata` and supply custom metadata using the `metadata` field.
4749
4781
  * @type {boolean}
4750
4782
  * @memberof UpdatePartRevisionRequestDataAttributes
4751
4783
  */
package/dist/esm/api.js CHANGED
@@ -66,13 +66,6 @@ export const FileRelationshipDataTypeEnum = {
66
66
  export const GeometrySetRelationshipDataTypeEnum = {
67
67
  GeometrySet: 'geometry-set',
68
68
  };
69
- export const MetadataValueTypeEnum = {
70
- String: 'string',
71
- Long: 'long',
72
- Float: 'float',
73
- Date: 'date',
74
- Null: 'null',
75
- };
76
69
  export const PartDataRelationshipsPartRevisionsTypeEnum = {
77
70
  PartRevision: 'part-revision',
78
71
  };
@@ -68,9 +68,10 @@ export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polli
68
68
  let attempts = 1;
69
69
  let pollRes = yield poll(attempts);
70
70
  /* eslint-disable no-await-in-loop */
71
- while ((allowed404(allow404, pollRes.status) ||
72
- validJob(pollRes.res) ||
73
- isClientError(pollRes.res)) &&
71
+ while (!completeJob(pollRes.res) &&
72
+ (allowed404(allow404, pollRes.status) ||
73
+ validJob(pollRes.res) ||
74
+ isClientError(pollRes.res)) &&
74
75
  attempts <= maxAttempts) {
75
76
  attempts += 1;
76
77
  yield delay(intervalMs);
@@ -79,7 +80,7 @@ export function pollQueuedJob({ id, getQueuedJob, allow404 = false, limit, polli
79
80
  /* eslint-enable no-await-in-loop */
80
81
  // At this point, the result is one of the following,
81
82
  // - An item of type `T` after being redirected to it
82
- // - A QueuedJob (after either exceeding `maxAttempts` or with `error` status)
83
+ // - A QueuedJob (after either exceeding `maxAttempts` or with `complete` or `error` status)
83
84
  // - A Failure
84
85
  return Object.assign(Object.assign({}, pollRes), { attempts, id });
85
86
  });
@@ -105,10 +106,16 @@ function allowed404(allow404, status) {
105
106
  function validJob(r) {
106
107
  return isQueuedJob(r) && !isStatusError(r);
107
108
  }
109
+ function completeJob(r) {
110
+ return isQueuedJob(r) && isStatusComplete(r);
111
+ }
108
112
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
109
113
  function isQueuedJobError(obj) {
110
114
  return isQueuedJob(obj) && isStatusError(obj);
111
115
  }
116
+ function isStatusComplete(job) {
117
+ return job.data.attributes.status === 'complete';
118
+ }
112
119
  function isStatusError(job) {
113
120
  return job.data.attributes.status === 'error';
114
121
  }
@@ -17,6 +17,22 @@ export interface CreateSceneAndSceneItemsReq extends BaseReq {
17
17
  /** Whether or not to return queued scene items. */
18
18
  readonly returnQueued?: boolean;
19
19
  }
20
+ export interface CreateSceneAndSceneItemsReqEXPERIMENTAL extends BaseReq {
21
+ /** A list of {@link CreateSceneItemRequest}. */
22
+ readonly createSceneItemReqs: Array<Array<CreateSceneItemRequest>>;
23
+ /** Function returning a {@link CreateSceneRequest}. */
24
+ readonly createSceneReq: () => CreateSceneRequest;
25
+ /** Whether or not to fail if any scene item fails initial validation. */
26
+ readonly failFast?: boolean;
27
+ /** How many requests to run in parallel. */
28
+ readonly parallelism: number;
29
+ /** {@link Polling} */
30
+ readonly polling?: Polling;
31
+ /** Callback with total number of requests and number complete. */
32
+ onProgress?: (complete: number, total: number) => void;
33
+ /** Whether or not to return queued scene items. */
34
+ readonly returnQueued?: boolean;
35
+ }
20
36
  export interface CreateSceneAndSceneItemsRes {
21
37
  readonly errors: QueuedSceneItem[];
22
38
  readonly scene: Scene;
@@ -90,13 +106,13 @@ export declare function createSceneAndSceneItems({ client, createSceneItemReqs,
90
106
  */
91
107
  export declare function createSceneItems({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsRes>;
92
108
  /**
93
- * Create a scene with scene items.
109
+ * Create a scene with scene items using experimental strategy.
94
110
  */
95
- export declare function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast, onMsg, onProgress, parallelism, polling, returnQueued, verbose, }: CreateSceneAndSceneItemsReq): Promise<CreateSceneAndSceneItemsResEXPERIMENTAL>;
111
+ export declare function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast, onMsg, onProgress, parallelism, polling, returnQueued, verbose, }: CreateSceneAndSceneItemsReqEXPERIMENTAL): Promise<CreateSceneAndSceneItemsResEXPERIMENTAL>;
96
112
  /**
97
113
  * Create scene items within a scene.
98
114
  */
99
- export declare function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsResEXPERIMENTAL>;
115
+ export declare function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, parallelism, sceneId, }: CreateSceneItemsReq): Promise<CreateSceneItemsResEXPERIMENTAL>;
100
116
  /**
101
117
  * Delete all scenes.
102
118
  *
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import pLimit from 'p-limit';
11
+ import { hrtime } from 'process';
11
12
  import { BatchOperationOpEnum, BatchOperationRefTypeEnum, CameraFitTypeEnum, SceneRelationshipDataTypeEnum, UpdateSceneRequestDataAttributesStateEnum, } from '../../index';
12
13
  import { defined, getPage, hasVertexError, isQueuedJob, MaxAttempts, partition, PollIntervalMs, tryStream, } from '../index';
13
14
  import { arrayChunked, delay, isApiError, toAccept } from '../utils';
@@ -113,45 +114,93 @@ export function createSceneItems({ client, createSceneItemReqs, failFast, onProg
113
114
  });
114
115
  }
115
116
  /**
116
- * Create a scene with scene items.
117
+ * Create a scene with scene items using experimental strategy.
117
118
  */
118
119
  export function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, createSceneReq, failFast = false, onMsg = console.log, onProgress, parallelism, polling = { intervalMs: PollIntervalMs, maxAttempts: MaxAttempts }, returnQueued = false, verbose, }) {
119
120
  return __awaiter(this, void 0, void 0, function* () {
121
+ const startTime = hrtime.bigint();
122
+ if (verbose)
123
+ onMsg(`Creating scene...`);
120
124
  const scene = (yield client.scenes.createScene({ createSceneRequest: createSceneReq() })).data;
121
125
  const sceneId = scene.data.id;
122
- const createRes = yield createSceneItemsEXPERIMENTAL({
123
- client,
124
- createSceneItemReqs,
125
- failFast,
126
- onProgress,
127
- parallelism,
128
- sceneId,
129
- });
130
- const { a: queuedOps, b: errors } = partition(createRes.queuedBatchOps, (i) => isQueuedJob(i.res));
131
- const queued = returnQueued ? createRes.queuedBatchOps : [];
132
- // Nothing succeeded, return early as something is likely wrong
133
- if (queuedOps.length === 0 || errors.length === createRes.chunks) {
134
- return { errors, queued, scene, sceneItemErrors: [] };
135
- }
136
126
  if (verbose)
137
- onMsg(`Polling for completed scene-item batches...`);
138
- const limit = pLimit(Math.min(parallelism, 20));
139
- function poll({ ops, res, }) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- const r = yield pollQueuedJob({
142
- id: res.data.id,
143
- getQueuedJob: (id, cancelToken) => client.batches.getQueuedBatch({ id }, { cancelToken }),
144
- allow404: true,
145
- limit,
146
- polling,
147
- });
148
- if (isPollError(r.res)) {
149
- failFast ? throwOnError(r) : errors.push({ ops, res: r.res });
150
- }
151
- return r;
127
+ onMsg(`Creating scene items...`);
128
+ let itemCount = 0;
129
+ let batchQueuedOps = [];
130
+ let batchErrors = [];
131
+ let sceneItemErrors = [];
132
+ for (let depth = 0; depth < createSceneItemReqs.length; depth++) {
133
+ const createItemReqs = createSceneItemReqs[depth];
134
+ itemCount += createItemReqs.length;
135
+ if (verbose)
136
+ onMsg(`Creating ${createItemReqs.length} scene items at depth ${depth}...`);
137
+ // Await is used intentionally to defer loop iteration
138
+ // until all scene items have been created at each depth.
139
+ // eslint-disable-next-line no-await-in-loop
140
+ const createRes = yield createSceneItemsEXPERIMENTAL({
141
+ client,
142
+ createSceneItemReqs: createItemReqs,
143
+ failFast,
144
+ onProgress,
145
+ parallelism,
146
+ sceneId,
152
147
  });
148
+ const { a: queuedOps, b: errors } = partition(createRes.queuedBatchOps, (i) => isQueuedJob(i.res));
149
+ batchQueuedOps = batchQueuedOps.concat(queuedOps);
150
+ if (errors.length) {
151
+ batchErrors = batchErrors.concat(errors);
152
+ if (verbose)
153
+ onMsg(`WARNING: ${errors.length} scene item batch errors at depth ${depth}.`);
154
+ }
155
+ // Nothing succeeded, return early as something is likely wrong
156
+ if (queuedOps.length === 0 || errors.length === createRes.chunks) {
157
+ return {
158
+ errors,
159
+ queued: returnQueued ? createRes.queuedBatchOps : [],
160
+ scene,
161
+ sceneItemErrors: [],
162
+ };
163
+ }
164
+ const limit = pLimit(Math.min(parallelism, 20));
165
+ function poll({ ops, res, }) {
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ const r = yield pollQueuedJob({
168
+ id: res.data.id,
169
+ getQueuedJob: (id, cancelToken) => client.batches.getQueuedBatch({ id }, { cancelToken }),
170
+ allow404: true,
171
+ limit,
172
+ polling,
173
+ });
174
+ if (isPollError(r.res)) {
175
+ failFast ? throwOnError(r) : errors.push({ ops, res: r.res });
176
+ }
177
+ return r;
178
+ });
179
+ }
180
+ // eslint-disable-next-line no-await-in-loop
181
+ const batchRes = yield Promise.all(queuedOps.map((is) => limit(poll, is)));
182
+ const batchItemErrors = batchRes
183
+ .flatMap((b, i) => isBatch(b.res)
184
+ ? b.res['vertexvis/batch:results'].map((r, j) => isApiError(r)
185
+ ? { req: queuedOps[i].ops[j].data, res: r }
186
+ : undefined)
187
+ : [])
188
+ .filter(defined);
189
+ if (batchItemErrors.length) {
190
+ sceneItemErrors = sceneItemErrors.concat(batchItemErrors);
191
+ if (verbose)
192
+ onMsg(`WARNING: ${batchItemErrors.length} scene item creation errors at depth ${depth}.`);
193
+ }
194
+ }
195
+ if (verbose) {
196
+ onMsg(`Scene item creation complete for ${itemCount} scene items with max depth of ${createSceneItemReqs.length - 1}.`);
197
+ if (batchErrors.length) {
198
+ onMsg(` Batch errors: ${batchErrors.length}`);
199
+ }
200
+ if (sceneItemErrors.length) {
201
+ onMsg(` Scene item errors: ${sceneItemErrors.length}`);
202
+ }
153
203
  }
154
- const batchRes = yield Promise.all(queuedOps.map((is) => limit(poll, is)));
155
204
  if (verbose)
156
205
  onMsg(`Committing scene and polling until ready...`);
157
206
  yield updateScene({
@@ -161,35 +210,40 @@ export function createSceneAndSceneItemsEXPERIMENTAL({ client, createSceneItemRe
161
210
  });
162
211
  yield pollSceneReady({ client, id: sceneId, onMsg, polling, verbose });
163
212
  if (verbose)
164
- onMsg(`Fitting scene's camera to scene-items...`);
213
+ onMsg(`Fitting scene's camera to scene items...`);
214
+ const sceneResult = (yield updateScene({
215
+ attributes: {
216
+ camera: { type: CameraFitTypeEnum.FitVisibleSceneItems },
217
+ },
218
+ client,
219
+ sceneId,
220
+ })).scene;
221
+ if (verbose) {
222
+ const formatTime = (seconds) => {
223
+ const h = Math.floor(seconds / 3600);
224
+ const m = Math.floor((seconds % 3600) / 60);
225
+ const s = Math.round(seconds % 60);
226
+ return [h, m > 9 ? m : h ? '0' + m : m || '0', s > 9 ? s : '0' + s]
227
+ .filter(Boolean)
228
+ .join(':');
229
+ };
230
+ onMsg(`Scene creation completed in ${formatTime(Number(hrtime.bigint() - startTime) / 1000000000)}.`);
231
+ }
165
232
  return {
166
- errors,
167
- queued,
168
- scene: (yield updateScene({
169
- attributes: {
170
- camera: { type: CameraFitTypeEnum.FitVisibleSceneItems },
171
- },
172
- client,
173
- sceneId,
174
- })).scene,
175
- sceneItemErrors: batchRes
176
- .flatMap((b, i) => isBatch(b.res)
177
- ? b.res['vertexvis/batch:results'].map((r, j) => isApiError(r)
178
- ? { req: queuedOps[i].ops[j].data, res: r }
179
- : undefined)
180
- : [])
181
- .filter(defined),
233
+ errors: batchErrors,
234
+ queued: batchQueuedOps,
235
+ scene: sceneResult,
236
+ sceneItemErrors,
182
237
  };
183
238
  });
184
239
  }
185
240
  /**
186
241
  * Create scene items within a scene.
187
242
  */
188
- export function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, onProgress, parallelism, sceneId, }) {
243
+ export function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, failFast, parallelism, sceneId, }) {
189
244
  return __awaiter(this, void 0, void 0, function* () {
190
245
  const limit = pLimit(parallelism);
191
246
  const batchSize = 500;
192
- let complete = 0;
193
247
  const opChunks = arrayChunked(createSceneItemReqs.map((req) => ({
194
248
  data: req.data,
195
249
  op: BatchOperationOpEnum.Add,
@@ -213,10 +267,6 @@ export function createSceneItemsEXPERIMENTAL({ client, createSceneItemReqs, fail
213
267
  else
214
268
  throw error;
215
269
  }
216
- if (onProgress != null) {
217
- complete += opChunk.length;
218
- onProgress(complete, createSceneItemReqs.length);
219
- }
220
270
  return { ops, res };
221
271
  }), opChunk)));
222
272
  return { chunks: opChunks.length, queuedBatchOps };
@@ -1 +1 @@
1
- export declare const version = "0.20.0";
1
+ export declare const version = "0.20.3";
@@ -1 +1 @@
1
- export const version = '0.20.0';
1
+ export const version = '0.20.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertexvis/api-client-node",
3
- "version": "0.20.0",
3
+ "version": "0.20.3",
4
4
  "description": "The Vertex REST API client for Node.js.",
5
5
  "license": "MIT",
6
6
  "author": "Vertex Developers <support@vertexvis.com> (https://developer.vertexvis.com)",