-
Notifications
You must be signed in to change notification settings - Fork 16
/
forge.js
executable file
·626 lines (599 loc) · 30.6 KB
/
forge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
#!/usr/bin/env node
//
// Copyright (c) 2019 Autodesk, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// by Cyrille Fauvel
// Autodesk Forge Partner Development
//
/*jshint esversion: 9 */
process.setMaxListeners(100);
const program = require('commander');
const ForgeSettings = {
clientId: process.env.FORGE_CLIENT_ID || 'your_client_id',
clientSecret: process.env.FORGE_CLIENT_SECRET || 'your_client_secret',
PORT: process.env.PORT || '3000',
callback: process.env.FORGE_CALLBACK || ('http://localhost:' + (process.env.PORT || '3000') + '/oauth'),
grantType: 'client_credentials',
opts: { 'scope': 'data:read data:write data:create data:search bucket:create bucket:read bucket:update bucket:delete viewables:read' },
optsViewer: { 'scope': 'viewables:read' },
chunkSize: 5 * 1024 * 1024, // 5Mb
//chunkSize: 2 * 1024 * 1024, // 2Mb
minChunkSize: 2 * 1024 * 1024, // 2Mb
viewerVersion: 'v7.34.2',
};
const ForgeOauth = require('./api/oauth'); // Oauth
ForgeOauth.settings = ForgeSettings;
const ForgeOSS = require('./api/oss'); // OSS
ForgeOSS.oauth = ForgeOauth;
ForgeOSS.chunkSize = ForgeSettings.chunkSize;
ForgeOSS.minChunkSize = ForgeSettings.minChunkSize;
const ForgeDM = require('./api/dm'); // Data Management
ForgeDM.oauth = ForgeOauth;
const ForgeMD = require('./api/md'); // Model Derivative
ForgeMD.oauth = ForgeOauth;
const ForgeOther = require('./api/other'); // Others
ForgeOther.oauth = ForgeOauth;
ForgeOther.viewerVersion = ForgeSettings.viewerVersion;
const ForgeBIM360 = require('./api/bim360'); // BIM360
ForgeBIM360.oauth = ForgeOauth;
// commander utils
function registerCommands (p, commands) {
commands.forEach((cmd) => {
let t = p
.command(cmd.name)
.description(cmd.description)
.action(cmd.action /*|| dispatchSubCommand*/);
if (cmd.arguments)
t.arguments(cmd.arguments);
if (cmd.isDefault)
p._defaultCommand = cmd.name;
if (cmd.options) {
cmd.options.forEach(function (option) {
t.option(option.option, option.description);
//p.option(option.option, option.description);
});
}
});
}
// commands definitions
let commands = [
{
name: 'token', action: ForgeOauth.localToken,
description: 'get/set your access token (2legged/3legged)',
arguments: '[token] [refresh]'
},
{ name: '2legged', action: ForgeOauth._2legged, description: 'get an application access token (2legged)' },
{ name: '2legged-verify', action: ForgeOauth._2leggedVerify, description: 'verify access token (2legged)' },
{ name: '2legged-logout', action: ForgeOauth._2leggedRelease, description: 'release the application access token (2legged)' },
{
name: '3legged', action: ForgeOauth._3legged,
description: '3 legged operations (3legged) [code] could be empty / auto / refresh / or the autorization code',
arguments: '[code]',
options: [
{ option: '-i, --implicit', description: 'run an implicit grant vs code grant' }
]
},
{ name: '3legged-verify', action: ForgeOauth._3leggedVerify, description: 'verify access token (3legged)' },
{ name: '3legged-logout', action: ForgeOauth._2leggedRelease, description: 'release the application access token (3legged)' },
{
name: 'buckets', action: ForgeOSS.bucketsList,
description: 'list buckets (2legged)',
options: [
{ option: '-s, --startAt <startAt>', description: 'startAt: where to start in the list [string, default: none]' },
{ option: '-l, --limit <limit>', description: 'limit: how many to return [integer, default: 10]' },
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '-a, --all', description: 'get them all!' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
]
},
{
name: 'buckets-list', action: ForgeOSS.bucketsList,
description: 'list buckets (2legged)',
options: [
{ option: '-s, --startAt <startAt>', description: 'startAt: where to start in the list [string, default: none]' },
{ option: '-l, --limit <limit>', description: 'limit: how many to return [integer, default: 10]' },
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '-a, --all', description: 'get them all!' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
]
},
{
name: 'buckets-current', action: ForgeOSS.bucketsCurrent,
description: 'get/set your current bucket (2legged)',
arguments: '[bucketKey]'
},
{
name: 'buckets-new', action: ForgeOSS.bucketsNew,
description: 'create a new bucket,; default Type is persistent, values can be transient/temporary/persistent (2legged)',
arguments: '<bucketKey> [type]',
options: [
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '-k, --key <authid>', description: 'The application key to grant access to' },
{ option: '-a, --access <access>', description: 'Acceptable values: full or read [string, default: full]' }
]
},
{
name: 'buckets-delete', action: ForgeOSS.bucketsDelete,
description: 'delete a given bucket; if no parameter delete the current bucket (2legged)',
arguments: '<bucketKey>',
},
{
name: 'buckets-info', action: ForgeOSS.bucketsInfo,
description: 'check bucket validity, outputs the expiration; date/time for this bucket (2legged)',
arguments: '[bucketKey]',
},
{
name: 'buckets-ls', action: ForgeOSS.bucketsLs,
description: 'list items in a given bucket; required to be in the API white list to use this API (2legged)',
arguments: '[bucketKey]',
options: [
{ option: '-s, --startAt <startAt>', description: 'startAt: where to start in the list [string, default: none]' },
{ option: '-l, --limit <limit>', description: 'limit: how many to return [integer, default: 10]' },
{ option: '-b, --beginsWith <beginsWith>', description: 'beginsWith: String to filter the objectKeys.' },
{ option: '-a, --all', description: 'get them all!' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current object' },
]
},
{
name: 'objects-info', action: ForgeOSS.objectsInfo,
description: 'seed file information (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' }
]
},
{
name: 'objects-get', action: ForgeOSS.objectsGet,
description: 'download a seed file (2legged)',
arguments: '<filename> <outputFile>',
options: [
{ option: '-b, --bucket', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' }
]
},
{
name: 'objects-put', action: ForgeOSS.objectsPut,
description: 'upload a seed file (2legged)',
arguments: '<filename>',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-s, --strippath', description: 'strip path from filename' },
{ option: '-d, --signed <signed>', description: 'signed resource key (requires region, if not US)' },
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
]
},
{
name: 'objects-copy', action: ForgeOSS.objectsCopy,
description: 'copy a seed file in the same bucket.(2legged)',
arguments: '<filename> <target>',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filenames represent the objectKeys on OSS vs the filenames' }
]
},
{
name: 'objects-delete', action: ForgeOSS.objectsDelete,
description: 'delete a seed file (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
]
},
{
name: 'objects-sign', action: ForgeOSS.signObject,
description: 'sign a seed file (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-a, --access <access>', description: 'access for signed resource Acceptable values: read, write, readwrite Default value: read' },
{ option: '-e, --minutesexpiration <minutesexpiration>', description: 'expiration time in minutes; default: 60' },
{ option: '-s, --singleuse', description: 'expires after it is used the first time if true. Default value: false' }
]
},
{
name: 'objects-unsign', action: ForgeOSS.unsignObject,
description: 'unsign a seed file (2legged)',
arguments: '<id>',
options: [
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
]
},
{
name: 'objects-translate', action: ForgeMD.objectsTranslate,
description: 'translate a seed file (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-m, --master <master>', description: 'define the master file when using a compressed seed file' },
{ option: '-f, --force', description: 'force translation' },
{ option: '-c, --references', description: 'force using references configuration in the translation' },
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '--ifcRevit', description: 'use Revit vs Navisworks to do IFC conversion' },
{ option: '--ifcNavis', description: 'use Navisworks vs Revit to do IFC conversion' },
{ option: '--generateMasterViews', description: 'generates master views when translating from the Revit' },
{ option: '--svf', description: 'translate to the Forge SVF bubble format' },
{ option: '--svf2', description: 'translate to the Forge SVF2 bubble format' },
{ option: '--step', description: 'translate to the STEP format' },
{ option: '--protocol <protocol>', description: '203 for configuration controlled design, 214 for core data for automotive mechanical design processes, 242 for managed model based 3D engineering. Default to 214.' },
{ option: '--tolerance <tolerance>', description: 'possible values: between 0 and 1 [float, default: 0.001]' },
{ option: '--stl', description: 'translate to the STL format' },
{ option: '--ascii', description: 'translate to the ASCII STL format (otherwise default to Binary)' },
{ option: '--colors', description: 'export colors during STL translation' },
{ option: '--fs', description: 'export file structure during translation (default to single file)' },
{ option: '--iges', description: 'translate to the IGES format' },
{ option: '--surfaceType <surfaceType>', description: 'possible values: bounded, trimmed, wireframe [string, default: bounded]' },
{ option: '--sheetType <sheetType>', description: 'export the sheet body to IGES open, shell, surface or wireframe [string, default: surface]' },
{ option: '--solidType <solidType>', description: 'export the solid body to IGES solid, surface or wireframe [string, default: solid]' },
{ option: '--fbx', description: 'translate to the Autodesk FBX format' },
{ option: '--dwg', description: 'translate to the AutoCAD dwg format' },
{ option: '--ifc', description: 'translate to the IFC format' },
{ option: '--obj', description: 'translate to the OBJ format' },
{ option: '--unit <unit>', description: 'possible values: meter, decimeter, centimeter, millimeter, micrometer, nanometer, yard, foot, inch, mil, microinch [string, default: none]' },
{ option: '--guid <guid>', description: 'required for geometry extractions. The model view ID (guid). Currently only valid for 3d views [string, default: none]' },
{ option: '--ids <ids>', description: 'list of DB IDs to export during tranlation (CSV format)' }
]
},
{
name: 'objects-references', action: ForgeMD.objectsReferences,
description: 'create references for a composite design in Model Derivative (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-m, --master <filename>', description: 'specificy master (can appear multiple times' },
{ option: '-c, --child <filename [, filename]>', description: 'specificy child, comma separated (can appear multiple times' },
]
},
{
name: 'objects-progress', action: ForgeMD.objectsTranslateStatus,
description: 'translate progress/status of a seed file (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' }
]
},
{
name: 'objects-status', action: ForgeMD.objectsTranslateStatus,
description: 'translate progress/status of a seed file (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' }
]
},
{
name: 'objects-manifest', action: ForgeMD.objectsManifest,
description: 'information about derivatives that correspond to a specific seed file, including derivative URNs and statuses (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-d, --delete', description: 'delete option' },
{ option: '-s, --svf', description: 'get the SVF manifest for a SVF2 payload' }
]
},
{
name: 'objects-metadata', action: ForgeMD.objectsMetadata,
description: 'list of model view (metadata) IDs for a design model (2legged)',
arguments: '[filename]',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-g, --guid <guid>', description: 'returns an object tree, i.e., a hierarchical list of objects for a model view' },
{ option: '-p, --properties', description: 'returns a list of properties for each object in an object tree. Properties are returned according to object ID and do not follow a hierarchical structure' },
{ option: '-x, --adsForce', description: 'force retrieve the object tree even though it failed to be extracted (got 404 with error message) previously' },
{ option: '-f, --forceget', description: 'to force get the large resource even if it exceeded the expected maximum length (20 MB)' },
{ option: '-i, --objectid <id>', description: 'object id which you want to query properties for' },
]
},
{
name: 'objects-derivatives', action: ForgeMD.objectsDerivatives,
description: 'downloads the derivative specified by the derivativeurn URI parameter, which was generated from the source model specified by the urn URI parameter. To download the file, you need to specify the file’s URN, which you retrieve by calling the GET :urn/manifest endpoint.(2legged)',
arguments: '<filename> <derivativesURN> <outputFile>',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
{ option: '-i, --info', description: 'information about the specified derivative, no download' },
{ option: '-u, --uncompress', description: 'dezip response after downloads' },
]
},
{
name: 'objects-sha1', action: ForgeOSS.sha1,
description: 'calc file SHA1',
arguments: '<filename>'
},
{ name: 'user', action: ForgeOther.userAboutMe, description: 'get the profile information of an authorizing end user (3legged)', },
{
name: 'hubs', action: ForgeDM.hubsLs, description: 'get list of hubs (3legged)',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-r, --raw', description: 'display results as raw JSON' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'hubs-ls', action: ForgeDM.hubsLs, description: 'get list of hubs (3legged)',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-r, --raw', description: 'display results as raw JSON' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'hubs-info', action: ForgeDM.hubInfo, description: 'get hub information (3legged)',
arguments: '[hubId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-r, --raw', description: 'display results as raw JSON' },
],
},
{
name: 'projects', action: ForgeDM.projectsLs,
description: 'get list of projects (3legged)',
arguments: '[hubId]',
options: [
{ option: '-p, --page <page>', description: 'when using pagination specify the page number (default is 0)' },
{ option: '-l, --limit <limit>', description: 'when using pagination specify the number of item per page (default is 200)' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-r, --raw', description: 'display results as raw JSON' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'projects-ls', action: ForgeDM.projectsLs,
description: 'get list of projects (3legged)',
arguments: '[hubId]',
options: [
{ option: '-p, --page <page>', description: 'when using pagination specify the page number (default is 0)' },
{ option: '-l, --limit <limit>', description: 'when using pagination specify the number of item per page (default is 200)' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-r, --raw', description: 'display results as raw JSON' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'projects-roots', action: ForgeDM.projectsRoots,
description: 'get list of project root folders (3legged)',
arguments: '[hubId] [projectId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'projects-tree', action: ForgeDM.projectsTree,
description: 'get the hub/project content tree, can take a while (3legged)',
arguments: '[hubId] [projectId]',
options: [
{ option: '-f, --format', description: 'reformat output' }
]
},
{
name: 'folders', action: ForgeDM.foldersLs,
description: 'get list of folder content (3legged)',
arguments: '[projectId] [folderId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'folders-ls', action: ForgeDM.foldersLs,
description: 'get list of folder content (3legged)',
arguments: '[projectId] [folderId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'versions', action: ForgeDM.versionsInfo,
description: 'get list of item versions (3legged)',
arguments: '[projectId] [itemId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'versions-ls', action: ForgeDM.versionsInfo,
description: 'get list of item versions (3legged)',
arguments: '[projectId] [itemId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'version-ls', action: ForgeDM.versionsInfo,
description: 'get list of item versions (3legged)',
arguments: '[projectId] [itemId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'versions-info', action: ForgeDM.versionsInfo,
description: 'get list of item versions (3legged)',
arguments: '[projectId] [itemId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'version', action: ForgeDM.versionInfo,
description: 'get item version information (3legged)',
arguments: '[projectId] [versionId]',
},
{
name: 'version-translate', action: ForgeDM.versionTranslate,
description: 'translate a seed file (2legged)',
arguments: '[projectId] [versionId]',
options: [
{ option: '-m, --master <master>', description: 'define the master file when using a compressed seed file' },
{ option: '-f, --force', description: 'force translation' },
{ option: '-c, --references', description: 'force using references configuration in the translation' },
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '--step', description: 'translate to the STEP format' },
{ option: '--protocol <protocol>', description: '203 for configuration controlled design, 214 for core data for automotive mechanical design processes, 242 for managed model based 3D engineering. Default to 214.' },
{ option: '--tolerance <tolerance>', description: 'possible values: between 0 and 1 [float, default: 0.001]' },
{ option: '--stl', description: 'translate to the STL format' },
{ option: '--ascii', description: 'translate to the ASCII STL format (otherwise default to Binary)' },
{ option: '--colors', description: 'export colors during STL translation' },
{ option: '--fs', description: 'export file structure during translation (default to single file)' },
{ option: '--iges', description: 'translate to the IGES format' },
{ option: '--surfaceType <surfaceType>', description: 'possible values: bounded, trimmed, wireframe [string, default: bounded]' },
{ option: '--sheetType <sheetType>', description: 'export the sheet body to IGES open, shell, surface or wireframe [string, default: surface]' },
{ option: '--solidType <solidType>', description: 'export the solid body to IGES solid, surface or wireframe [string, default: solid]' },
{ option: '--fbx', description: 'translate to the Autodesk FBX format' },
{ option: '--dwg', description: 'translate to the AutoCAD dwg format' },
{ option: '--ifc', description: 'translate to the IFC format' },
{ option: '--obj', description: 'translate to the OBJ format' },
{ option: '--unit <unit>', description: 'possible values: meter, decimeter, centimeter, millimeter, micrometer, nanometer, yard, foot, inch, mil, microinch [string, default: none]' },
{ option: '--guid <guid>', description: 'required for geometry extractions. The model view ID (guid). Currently only valid for 3d views [string, default: none]' },
{ option: '--ids <ids>', description: 'list of DB IDs to export during tranlation (CSV format)' }
]
},
{
name: 'version-status', action: ForgeDM.versionStatus,
description: 'get item version status (3legged)',
arguments: '[projectId] [versionId]',
},
{
name: 'version-manifest', action: ForgeDM.versionManifest,
description: 'get item version manifest (3legged)',
arguments: '[projectId] [versionId]',
options: [
{ option: '-s, --svf', description: 'get the SVF manifest for a SVF2 payload' }
]
},
{
name: 'version-metadata', action: ForgeDM.versionMetadata,
description: 'list of model view (metadata) IDs for a design model (3legged)',
arguments: '[projectId] [versionId]',
options: [
{ option: '-g, --guid <guid>', description: 'returns an object tree, i.e., a hierarchical list of objects for a model view' },
{ option: '-p, --properties', description: 'returns a list of properties for each object in an object tree. Properties are returned according to object ID and do not follow a hierarchical structure' },
{ option: '-x, --adsForce', description: 'force retrieve the object tree even though it failed to be extracted (got 404 with error message) previously' },
{ option: '-f, --forceget', description: 'to force get the large resource even if it exceeded the expected maximum length (20 MB)' },
{ option: '-i, --objectid <id>', description: 'object id which you want to query properties for' },
]
},
{
name: 'version-derivatives', action: ForgeDM.versionDerivatives,
description: 'downloads the derivative specified by the derivativeurn URI parameter, which was generated from the source model specified by the urn URI parameter. To download the file, you need to specify the file’s URN, which you retrieve by calling the GET :urn/manifest endpoint.(3legged)',
arguments: '[projectId] [versionId] <derivativesURN> <outputFile>',
options: [
{ option: '-i, --info', description: 'information about the specified derivative, no download' },
{ option: '-u, --uncompress', description: 'dezip response after downloads' },
]
},
{
name: 'svf2-idmap', action: ForgeMD.svf2ObjectIdMapping,
description: 'downloads the dbid.idx file for SVF / SVF ObjectID mapping (2legged / 3legged)',
arguments: '<filename> <outputFile>',
options: [
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'filename represents the objectKey on OSS vs the filename' },
]
},
{
name: 'version-svf2-idmap', action: ForgeDM.svf2ObjectIdMapping,
description: 'downloads the dbid.idx file for SVF / SVF ObjectID mapping (2legged / 3legged)',
arguments: '<projectId> <versionId> <outputFile>',
},
{
name: 'decode-svf2-idmap', action: ForgeMD.decodeSvf2ObjectIdMapping,
description: 'decode the dbid.idx file',
arguments: '<filename>',
},
{
name: 'hubs-search', action: ForgeDM.searchAndSet,
description: 'search for an item (regex) and setup defaults (3legged)',
arguments: '<projectId> <search>',
options: [
{ option: '-f, --force', description: 'request the hub/project content tree, can take a while (3legged)' },
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as current bucket (i.e. buckets-current command)' },
],
},
{
name: 'bubble', action: ForgeOther.bubble,
description: 'download the bubble (2legged/3legged)',
arguments: '<urn> <outputFolder>',
options: [
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '-o, --otg', description: 'Download OTG bubble vs SVF Bubble' },
{ option: '-2, --svf2', description: 'Download SVF2 bubble vs SVF/OTG Bubble' },
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'urn represents the objectKey on OSS vs the urn' },
]
},
{
name: 'html', action: ForgeOther.htmlGet,
description: 'generate HTML/viewables (2legged/3legged)',
arguments: '<urn> <outputFilename>',
options: [
{ option: '-r, --region <region>', description: 'region: US or EMEA [string, default: US]' },
{ option: '-o, --otg', description: 'Use OTG vs SVF' },
{ option: '-2, --svf2', description: 'Use SVF2 vs SVF/OTG' },
{ option: '-l, --local', description: 'Use a local Viewer copy vs Server served Viewer' },
{ option: '-b, --bucket <bucket>', description: 'override bucket name to be used in this session' },
{ option: '-k, --key', description: 'urn represents the objectKey on OSS vs the urn' },
]
},
{
name: 'viewer', action: ForgeOther.viewerGet,
description: 'Download a local copy of the Forge Viewer',
arguments: '<outputFolder>',
},
{
name: 'get-container', action: ForgeBIM360.getContainer,
description: 'Get BIM360 container',
arguments: '[hubId] [projectId]',
options: [
{ option: '-j, --json', description: 'display results as JSON vs table' },
{ option: '-c, --current <current>', description: 'index from list to set as default' },
],
},
{
name: 'issues-ls', action: ForgeBIM360.issuesLs,
description: 'Get BIM360 issues',
arguments: '[containerId]',
}
];
registerCommands(program, commands);
program
.version('4.0.2')
//.option ('-u, --usage', 'Usage')
//.on ('--help', usage)
.parse(process.argv);