@inweb/client 26.5.3 → 26.5.5

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/client.js CHANGED
@@ -907,7 +907,7 @@
907
907
  /**
908
908
  * Assembly geometry data type:
909
909
  *
910
- * - `vsfx` - `VSFX` format, assembly can be opened in `VisualizeJS` viewer.
910
+ * - `vsfx` - `VSFX` format, assembly can be opened in `VisualizeJS` 3D viewer.
911
911
  *
912
912
  * Returns an empty string if the geometry data is not yet ready.
913
913
  */
@@ -1056,17 +1056,44 @@
1056
1056
  *
1057
1057
  * @typedef {any} Properties
1058
1058
  * @property {string} handle - Object original handle.
1059
- * @property {string | any} * - Object property. Can be `any` for nested properties.
1059
+ * @property {string | any} * - Object property. Can be `any` for nested group properties.
1060
1060
  */
1061
1061
  /**
1062
1062
  * Returns the properties for an objects in the assembly.
1063
1063
  *
1064
1064
  * @param handles - Object original handle or handles array. Specify `undefined` to get properties for
1065
1065
  * all objects in the assembly.
1066
+ * @param group - If the `group` parameter is `true`, properties are returned grouped by category. By
1067
+ * default, or if `group` is set to `false`, properties are returned ungrouped.
1068
+ *
1069
+ * To get grouped properties, the `--properties_group` command line argument must be specified for the
1070
+ * `properties` File Converter job when {@link Client.createAssembly | creating the assembly}.
1071
+ *
1072
+ * ```javascript
1073
+ * await client.createAssembly([file1.id, file2.id], "AssemblyName", {
1074
+ * jobParameters: { properties: "--properties_group" },
1075
+ * waitForDone: true,
1076
+ * });
1077
+ * ```
1078
+ *
1079
+ * Otherwise, the properties will be returned ungrouped, even if the `group` is `true`.
1066
1080
  */
1067
- getProperties(handles) {
1068
- const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
1069
- return this.get(relativePath).then((response) => response.json());
1081
+ getProperties(handles, group = false) {
1082
+ const searchParams = new URLSearchParams();
1083
+ if (handles) {
1084
+ if (Array.isArray(handles))
1085
+ handles = handles.join(",");
1086
+ if (typeof handles === "string")
1087
+ handles = handles.trim();
1088
+ if (handles)
1089
+ searchParams.set("handles", handles);
1090
+ }
1091
+ if (group)
1092
+ searchParams.set("group", "true");
1093
+ let queryString = searchParams.toString();
1094
+ if (queryString)
1095
+ queryString = "?" + queryString;
1096
+ return this.get(`/properties${queryString}`).then((response) => response.json());
1070
1097
  }
1071
1098
  /**
1072
1099
  * Returns the list of original handles for an objects in the file that match the specified patterns.
@@ -1977,8 +2004,15 @@
1977
2004
  return this.data.lastUpdate;
1978
2005
  }
1979
2006
  /**
1980
- * Job type. Can be `properties`, `geomerty`, `geomertyGltf`, `validation`, `clash`, `dwg`, `obj`,
1981
- * `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job name.
2007
+ * Job type. Can be:
2008
+ *
2009
+ * - `geometry` - Convert file geometry data to `VSFX` format.
2010
+ * - `geometryGltf` - Convert file geometry data to `glTF` format.
2011
+ * - `properties` - Extract file properties.
2012
+ * - `validation` - Validate the IFC file.
2013
+ * - `clash` - Create the clash detection report.
2014
+ * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the specified format.
2015
+ * - Other custom job name.
1982
2016
  *
1983
2017
  * @readonly
1984
2018
  */
@@ -1986,7 +2020,7 @@
1986
2020
  return this.data.outputFormat;
1987
2021
  }
1988
2022
  /**
1989
- * Parameters with which the job runner was started. For more information, see
2023
+ * Parameters with which the job was started. For more information, see
1990
2024
  * {@link https://cloud.opendesign.com/docs//pages/server/api.html#Jobs | Open Cloud Jobs API}.
1991
2025
  *
1992
2026
  * @readonly
@@ -2307,7 +2341,7 @@
2307
2341
  /**
2308
2342
  * Returns a list of file formats in which the active version of the file was exported.
2309
2343
  *
2310
- * To export file to one of the supported formats create File Converter job using
2344
+ * To export file to one of the supported formats run the File Converter job using
2311
2345
  * {@link createJob | createJob()}. To download exported file use
2312
2346
  * {@link downloadResource | downloadResource()}.
2313
2347
  *
@@ -2321,8 +2355,8 @@
2321
2355
  /**
2322
2356
  * Geometry data type of the active file version. Can be one of:
2323
2357
  *
2324
- * - `vsfx` - `VSFX` format, file can be opened in `VisualizeJS` viewer.
2325
- * - `gltf` - `glTF` format, file can be opened in `Three.js` viewer.
2358
+ * - `vsfx` - `VSFX` format, file can be opened in `VisualizeJS` 3D viewer.
2359
+ * - `gltf` - `glTF` format, file can be opened in `Three.js` 3D viewer.
2326
2360
  *
2327
2361
  * Returns an empty string if geometry data has not yet been converted. A files without geometry data
2328
2362
  * can be exported to other formas, but cannot be opened in viewer.
@@ -2556,17 +2590,52 @@
2556
2590
  *
2557
2591
  * @typedef {any} Properties
2558
2592
  * @property {string} handle - Object original handle.
2559
- * @property {string | any} - Object property. Can be `any` for nested properties.
2593
+ * @property {string | any} * - Object property. Can be `any` for nested group properties.
2560
2594
  */
2561
2595
  /**
2562
2596
  * Returns the properties for an objects in the active version of the file.
2563
2597
  *
2564
2598
  * @param handles - Object original handle or handles array. Specify `undefined` to get properties for
2565
2599
  * all objects in the file.
2600
+ * @param group - If the `group` parameter is `true`, properties are returned grouped by category. By
2601
+ * default, or if `group` is set to `false`, properties are returned ungrouped.
2602
+ *
2603
+ * To get grouped properties, the `--properties_group` command line argument must be specified for the
2604
+ * `properties` File Converter job when {@link Client.uploadFile | uploading the file}:
2605
+ *
2606
+ * ```javascript
2607
+ * await client.uploadFile(file, {
2608
+ * geometry: true,
2609
+ * properties: true,
2610
+ * jobParameters: { properties: "--properties_group" },
2611
+ * waitForDone: true,
2612
+ * });
2613
+ * ```
2614
+ *
2615
+ * or when running the {@link extractProperties | extract file properties} job:
2616
+ *
2617
+ * ```javascript
2618
+ * await file.extractProperties("--properties_group");
2619
+ * ```
2620
+ *
2621
+ * Otherwise, the properties will be returned ungrouped, even if the `group` is `true`.
2566
2622
  */
2567
- getProperties(handles) {
2568
- const relativePath = handles !== undefined ? `/properties?handles=${handles}` : "/properties";
2569
- return this.get(relativePath).then((response) => response.json());
2623
+ getProperties(handles, group = false) {
2624
+ const searchParams = new URLSearchParams();
2625
+ if (handles) {
2626
+ if (Array.isArray(handles))
2627
+ handles = handles.join(",");
2628
+ if (typeof handles === "string")
2629
+ handles = handles.trim();
2630
+ if (handles)
2631
+ searchParams.set("handles", handles);
2632
+ }
2633
+ if (group)
2634
+ searchParams.set("group", "true");
2635
+ let queryString = searchParams.toString();
2636
+ if (queryString)
2637
+ queryString = "?" + queryString;
2638
+ return this.get(`/properties${queryString}`).then((response) => response.json());
2570
2639
  }
2571
2640
  /**
2572
2641
  * Search pattern.
@@ -2687,15 +2756,15 @@
2687
2756
  * Downloads a resource file of the active version of the file. Resource files are files that contain
2688
2757
  * model scene descriptions, or geometry data, or exported files.
2689
2758
  *
2690
- * @example Export file to DWG.
2759
+ * @example Export file to PDF.
2691
2760
  *
2692
2761
  * ```javascript
2693
- * const job = await file.crateJob("dwg");
2762
+ * const job = await file.createJob("pdf");
2694
2763
  * await job.waitForDone();
2695
- * const dwgFileName = file.exports.find((x) => x.endsWith(".dwg"));
2696
- * const arrayBuffer = await file.downloadResource(dwgFileName);
2764
+ * const pdfResourceName = file.exports.find((x) => x.endsWith(".pdf"));
2765
+ * const arrayBuffer = await file.downloadResource(pdfResourceName);
2697
2766
  * const blob = new Blob([arrayBuffer]);
2698
- * const fileName = file.name + ".dwg";
2767
+ * const fileName = file.name + ".pdf";
2699
2768
  * FileSaver.saveAs(blob, fileName);
2700
2769
  * ```
2701
2770
  *
@@ -2770,20 +2839,19 @@
2770
2839
  /**
2771
2840
  * Runs a new job on the server for the active version of the file.
2772
2841
  *
2773
- * @param outputFormat - The job type. Can be one of:
2842
+ * @param outputFormat - The job type. Can be:
2774
2843
  *
2775
- * - `geometry` - Convert file geometry data to `VSFX` format suitable for `VisualizeJS` viewer.
2776
- * - `geometryGltf` - Convert file geometry data to `glTF` format suitable for `Three.js` viewer.
2844
+ * - `geometry` - Convert file geometry data to `VSFX` format for opening in `VisualizeJS` 3D viewer.
2845
+ * - `geometryGltf` - Convert file geometry data to `glTF` format for opening in `Three.js` 3D viewer.
2777
2846
  * - `properties` - Extract file properties.
2778
- * - `validation` - Validate the file. Only for `IFC` files.
2779
- * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the one of the supported format.
2780
- * Use {@link exports | exports()} to get the list of completed file exports. Use
2847
+ * - `validation` - Validate the IFC file.
2848
+ * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the specified format. Use
2849
+ * {@link exports} to get the list of completed file exports. Use
2781
2850
  * {@link downloadResource | downloadResource()} to download the exported file.
2782
- * - Other custom job name. Custom job runner must be registered in the job templates before creating a
2783
- * job.
2851
+ * - Other custom job name. Custom job must be registered in the job templates before running.
2784
2852
  *
2785
- * @param parameters - Parameters for the job runner. Can be given as command line arguments for the
2786
- * File Converter tool in form `--arg=value`.
2853
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
2854
+ * line arguments in form `--arg=value`.
2787
2855
  */
2788
2856
  createJob(outputFormat, parameters) {
2789
2857
  const jobs = new Endpoint("/jobs", this.httpClient, this.headers);
@@ -2797,38 +2865,38 @@
2797
2865
  .then((data) => new Job(data, this.httpClient));
2798
2866
  }
2799
2867
  /**
2800
- * Runs a job to convert geometry data of active version of the file. This is alias to
2801
- * {@link createJob | createJob("geometry")}.
2868
+ * Runs a File Converter job to convert geometry data of active version of the file to the specified
2869
+ * format. This is alias to {@link createJob | createJob("geometry")}.
2802
2870
  *
2803
2871
  * @param type - Geometry data type. Can be one of:
2804
2872
  *
2805
- * - `vsfx` - `VSFX` format (default), for opening a file in `VisualizeJS` viewer.
2806
- * - `gltf` - `glTF` format, for opening a file in `Three.js` viewer.
2873
+ * - `vsfx` - `VSFX` format (default), for opening a file in `VisualizeJS` 3D viewer.
2874
+ * - `gltf` - `glTF` format, for opening a file in `Three.js` 3D viewer.
2807
2875
  *
2808
- * @param parameters - Parameters for the job runner. Can be given as command line arguments for the
2809
- * File Converter tool in form `--arg=value`.
2876
+ * @param parameters - Parameters for the File Converter job. Can be given as command line arguments in
2877
+ * form `--arg=value`.
2810
2878
  */
2811
2879
  extractGeometry(type, parameters) {
2812
2880
  return this.createJob(type === "gltf" ? "geometryGltf" : "geometry", parameters);
2813
2881
  }
2814
2882
  /**
2815
- * Runs a job to extract properties of the active version of the file. This is alias to
2883
+ * Runs a File Converter job to extract properties of the active version of the file. This is alias to
2816
2884
  * {@link createJob | createJob("properties")}.
2817
2885
  *
2818
- * @param parameters - Parameters for the job runner. Can be given as command line arguments for the
2819
- * File Converter tool in form `--arg=value`.
2886
+ * @param parameters - Parameters for the File Converter job. Can be given as command line arguments in
2887
+ * form `--arg=value`.
2820
2888
  */
2821
2889
  extractProperties(parameters) {
2822
2890
  return this.createJob("properties", parameters);
2823
2891
  }
2824
2892
  /**
2825
- * Runs a job to validate the active version of the file. This is alias to
2893
+ * Runs an IFC validator job to validate the active version of the file. This is alias to
2826
2894
  * {@link createJob | createJob("validation")}.
2827
2895
  *
2828
2896
  * To get validation report use {@link downloadResource | downloadResource("validation_report.json")}.
2829
2897
  *
2830
- * @param parameters - Parameters for the job runner. Can be given as command line arguments for the
2831
- * File Converter tool in form `--arg=value`.
2898
+ * @param parameters - Parameters for the IFC validator tool. Can be given as command line arguments in
2899
+ * form `--arg=value`.
2832
2900
  */
2833
2901
  validate(parameters) {
2834
2902
  return this.createJob("validation", parameters);
@@ -2837,8 +2905,9 @@
2837
2905
  * Waits for jobs of the active version of the file to be done. Job is done when it changes to `none`,
2838
2906
  * `done` or `failed` status.
2839
2907
  *
2840
- * @param jobs - Job or job array to wait on. Can be `geometry`, `geometryGltf`, `properties`,
2841
- * `validation`, `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job name.
2908
+ * @param jobs - Job name or array of job names to wait on. Can be `geometry`, `geometryGltf`,
2909
+ * `properties`, `validation`, `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` or custom job
2910
+ * name.
2842
2911
  * @param waitAll - If this parameter is `true`, the function returns when all the specified jobs have
2843
2912
  * done. If `false`, the function returns when any one of the jobs are done.
2844
2913
  * @param params - An object containing waiting parameters.
@@ -4562,7 +4631,7 @@
4562
4631
  .then((data) => ({
4563
4632
  ...data,
4564
4633
  server: data.version,
4565
- client: "26.5.3",
4634
+ client: "26.5.5",
4566
4635
  }));
4567
4636
  }
4568
4637
  /**
@@ -4971,13 +5040,17 @@
4971
5040
  * generally retrieved from a {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList}
4972
5041
  * object returned as a result of a user selecting files using the HTML `<input>` element.
4973
5042
  * @param params - An object containing upload parameters.
4974
- * @param params.geometry - Create job to convert file geometry data. Can be:
5043
+ * @param params.geometry - Run File Converter job to convert geometry data after uploading the file.
5044
+ * Can be:
4975
5045
  *
4976
- * - `true` - Convert file geometry data to `VSFX` format to open the file in `VisualizeJS` viewer.
4977
- * - `vsfx` - Convert file geometry data to `VSFX` format to open the file in `VisualizeJS` viewer.
4978
- * - `gltf` - Convert file geometry data to `glTF` format to open the file in `Three.js` viewer.
5046
+ * - `true` - Convert file geometry data to `VSFX` format for opening in `VisualizeJS` 3D viewer.
5047
+ * - `vsfx` - Convert file geometry data to `VSFX` format for opening in `VisualizeJS` 3D viewer.
5048
+ * - `gltf` - Convert file geometry data to `glTF` format for opening in `Three.js` 3D viewer.
4979
5049
  *
4980
- * @param params.properties - Create job to extract file properties.
5050
+ * @param params.properties - Run File Converter job to extract properties after uploading the file.
5051
+ * @param params.jobParameters - Parameters for the File Converter jobs. Use this to specify aditional
5052
+ * parameters for retrieving the geometry and properties of uploaded file. Can be given as command
5053
+ * line arguments in form `--arg=value`.
4981
5054
  * @param params.waitForDone - Wait for geometry and properties jobs to complete.
4982
5055
  * @param params.timeout - The time, in milliseconds that the function should wait jobs. If no one jobs
4983
5056
  * are done during this time, the `TimeoutError` exception will be thrown.
@@ -5002,11 +5075,12 @@
5002
5075
  .then((xhr) => JSON.parse(xhr.responseText))
5003
5076
  .then((data) => new File(data, this.httpClient));
5004
5077
  const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
5078
+ const jobParameters = params.jobParameters || {};
5005
5079
  const jobs = [];
5006
5080
  if (params.geometry)
5007
- jobs.push((await result.extractGeometry(geometryType)).outputFormat);
5081
+ jobs.push((await result.extractGeometry(geometryType, jobParameters.geometry)).outputFormat);
5008
5082
  if (params.properties)
5009
- jobs.push((await result.extractProperties()).outputFormat);
5083
+ jobs.push((await result.extractProperties(jobParameters.properties)).outputFormat);
5010
5084
  if (jobs.length > 0)
5011
5085
  if (params.waitForDone)
5012
5086
  await result.waitForDone(jobs, true, params);
@@ -5105,18 +5179,17 @@
5105
5179
  * Runs a new job on the server for the sepecified file.
5106
5180
  *
5107
5181
  * @param fileId - File ID.
5108
- * @param outputFormat - The job type. Can be one of:
5182
+ * @param outputFormat - The job type. Can be:
5109
5183
  *
5110
- * - `geometry` - Convert file geometry data to `VSFX` format suitable for `VisualizeJS` viewer.
5111
- * - `geometryGltf` - Convert file geometry data to `glTF` format suitable for `Three.js` viewer.
5184
+ * - `geometry` - Convert file geometry data to `VSFX` format for opening in `VisualizeJS` 3D viewer.
5185
+ * - `geometryGltf` - Convert file geometry data to `glTF` format for opening in `Three.js` 3D viewer.
5112
5186
  * - `properties` - Extract file properties.
5113
- * - `validation` - Validate the file. Only for `IFC` files.
5114
- * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the one of the supported format.
5115
- * - Other custom job name. Custom job runner must be registered in the job templates table before
5116
- * creating a job.
5187
+ * - `validation` - Validate the IFC file.
5188
+ * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the specified format.
5189
+ * - Other custom job name. Custom job must be registered in the job templates before running.
5117
5190
  *
5118
- * @param parameters - Parameters for the job runner. Can be given as command line arguments for the
5119
- * File Converter tool in form `--arg=value`.
5191
+ * @param parameters - Parameters for the File Converter jobs or custom job. Can be given as command
5192
+ * line arguments in form `--arg=value`.
5120
5193
  */
5121
5194
  createJob(fileId, outputFormat, parameters) {
5122
5195
  return this.httpClient
@@ -5211,6 +5284,9 @@
5211
5284
  * @param files - List of file IDs.
5212
5285
  * @param name - Assembly name.
5213
5286
  * @param params - Additional assembly creating parameters.
5287
+ * @param params.jobParameters - Parameters for the File Converter jobs. Use this to specify aditional
5288
+ * parameters for generating the geometry and properties of the new assembly. Can be given as command
5289
+ * line arguments in form `--arg=value`.
5214
5290
  * @param params.waitForDone - Wait for assembly to be created.
5215
5291
  * @param params.timeout - The time, in milliseconds, that the function should wait for the assembly to
5216
5292
  * be created. If the assembly is not created within this time, a TimeoutError exception will be
@@ -5222,13 +5298,20 @@
5222
5298
  * can be used to abort waiting as desired.
5223
5299
  * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
5224
5300
  */
5225
- createAssembly(files, name, params) {
5226
- const { waitForDone } = params !== null && params !== undefined ? params : {};
5301
+ createAssembly(files, name, params = {}) {
5302
+ const jobParameters = params.jobParameters || {};
5227
5303
  return this.httpClient
5228
- .post("/assemblies", { name, files })
5304
+ .post("/assemblies", {
5305
+ name,
5306
+ files,
5307
+ jobParameters: {
5308
+ geometry: parseArgs(jobParameters.geometry),
5309
+ properties: parseArgs(jobParameters.properties),
5310
+ },
5311
+ })
5229
5312
  .then((response) => response.json())
5230
5313
  .then((data) => new Assembly(data, this.httpClient))
5231
- .then((result) => (waitForDone ? result.waitForDone(params) : result));
5314
+ .then((result) => (params.waitForDone ? result.waitForDone(params) : result));
5232
5315
  }
5233
5316
  /**
5234
5317
  * Deletes the specified assembly from the server.
@@ -5447,7 +5530,7 @@
5447
5530
  // By use of this software, its documentation or related materials, you
5448
5531
  // acknowledge and accept the above terms.
5449
5532
  ///////////////////////////////////////////////////////////////////////////////
5450
- const version = "26.5.3";
5533
+ const version = "26.5.5";
5451
5534
 
5452
5535
  exports.Assembly = Assembly;
5453
5536
  exports.ClashTest = ClashTest;