@@ -348,62 +348,70 @@ export function devTool (
348
348
. description ( 'create workspace' )
349
349
. option ( '-i, --init <ws>' , 'Init from workspace' )
350
350
. option ( '-r, --region <region>' , 'Region' )
351
+ . option ( '-d, --dataId <dataId>' , 'DataId for workspace' )
351
352
. option ( '-b, --branding <key>' , 'Branding key' )
352
- . action ( async ( name , socialString , cmd : { account : string , init ?: string , branding ?: string , region ?: string } ) => {
353
- const { txes, version, migrateOperations } = prepareTools ( )
354
- await withAccountDatabase ( async ( db ) => {
355
- const measureCtx = new MeasureMetricsContext ( 'create-workspace' , { } )
356
- const brandingObj =
357
- cmd . branding !== undefined || cmd . init !== undefined ? { key : cmd . branding , initWorkspace : cmd . init } : null
358
- const socialId = await db . socialId . findOne ( { key : socialString as PersonId } )
359
- if ( socialId == null ) {
360
- throw new Error ( `Social id ${ socialString } not found` )
361
- }
353
+ . action (
354
+ async (
355
+ name ,
356
+ socialString ,
357
+ cmd : { account : string , init ?: string , branding ?: string , region ?: string , dataId ?: string }
358
+ ) => {
359
+ const { txes, version, migrateOperations } = prepareTools ( )
360
+ await withAccountDatabase ( async ( db ) => {
361
+ const measureCtx = new MeasureMetricsContext ( 'create-workspace' , { } )
362
+ const brandingObj =
363
+ cmd . branding !== undefined || cmd . init !== undefined ? { key : cmd . branding , initWorkspace : cmd . init } : null
364
+ const socialId = await db . socialId . findOne ( { key : socialString as PersonId } )
365
+ if ( socialId == null ) {
366
+ throw new Error ( `Social id ${ socialString } not found` )
367
+ }
362
368
363
- const res = await createWorkspaceRecord (
364
- measureCtx ,
365
- db ,
366
- brandingObj ,
367
- name ,
368
- socialId . personUuid ,
369
- cmd . region ,
370
- 'manual-creation'
371
- )
372
- const wsInfo = await getWorkspaceInfoWithStatusById ( db , res . workspaceUuid )
369
+ const res = await createWorkspaceRecord (
370
+ measureCtx ,
371
+ db ,
372
+ brandingObj ,
373
+ name ,
374
+ socialId . personUuid ,
375
+ cmd . region ,
376
+ 'manual-creation' ,
377
+ cmd . dataId as WorkspaceDataId
378
+ )
379
+ const wsInfo = await getWorkspaceInfoWithStatusById ( db , res . workspaceUuid )
380
+
381
+ if ( wsInfo == null ) {
382
+ throw new Error ( `Created workspace record ${ res . workspaceUuid } not found` )
383
+ }
384
+ const coreWsInfo = flattenStatus ( wsInfo )
385
+ const accountClient = getAccountClient ( getToolToken ( ) )
373
386
374
- if ( wsInfo == null ) {
375
- throw new Error ( `Created workspace record ${ res . workspaceUuid } not found` )
376
- }
377
- const coreWsInfo = flattenStatus ( wsInfo )
378
- const accountClient = getAccountClient ( getToolToken ( ) )
387
+ const queue = getPlatformQueue ( 'tool' , cmd . region )
388
+ const wsProducer = queue . getProducer < QueueWorkspaceMessage > ( toolCtx , QueueTopic . Workspace )
379
389
380
- const queue = getPlatformQueue ( 'tool' , cmd . region )
381
- const wsProducer = queue . getProducer < QueueWorkspaceMessage > ( toolCtx , QueueTopic . Workspace )
390
+ await createWorkspace (
391
+ measureCtx ,
392
+ version ,
393
+ brandingObj ,
394
+ coreWsInfo ,
395
+ txes ,
396
+ migrateOperations ,
397
+ accountClient ,
398
+ wsProducer ,
399
+ undefined ,
400
+ true
401
+ )
402
+ await updateWorkspaceInfo ( measureCtx , db , brandingObj , getToolToken ( ) , {
403
+ workspaceUuid : res . workspaceUuid ,
404
+ event : 'create-done' ,
405
+ version,
406
+ progress : 100
407
+ } )
382
408
383
- await createWorkspace (
384
- measureCtx ,
385
- version ,
386
- brandingObj ,
387
- coreWsInfo ,
388
- txes ,
389
- migrateOperations ,
390
- accountClient ,
391
- wsProducer ,
392
- undefined ,
393
- true
394
- )
395
- await updateWorkspaceInfo ( measureCtx , db , brandingObj , getToolToken ( ) , {
396
- workspaceUuid : res . workspaceUuid ,
397
- event : 'create-done' ,
398
- version,
399
- progress : 100
409
+ await wsProducer . send ( res . workspaceUuid , [ workspaceEvents . created ( ) ] )
410
+ await queue . shutdown ( )
411
+ console . log ( queue )
400
412
} )
401
-
402
- await wsProducer . send ( res . workspaceUuid , [ workspaceEvents . created ( ) ] )
403
- await queue . shutdown ( )
404
- console . log ( queue )
405
- } )
406
- } )
413
+ }
414
+ )
407
415
408
416
program
409
417
. command ( 'set-user-role <email> <workspace> <role>' )
0 commit comments