@itwin/workspace-editor 4.5.0-dev.39 → 4.5.0-dev.40
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/lib/WorkspaceEditor.js +18 -17
- package/package.json +5 -5
package/lib/WorkspaceEditor.js
CHANGED
|
@@ -46,7 +46,7 @@ function friendlyFileSize(size) {
|
|
|
46
46
|
/** Create a new empty WorkspaceDb */
|
|
47
47
|
async function createWorkspaceDb(args) {
|
|
48
48
|
args.writeable = true;
|
|
49
|
-
const wsFile =
|
|
49
|
+
const wsFile = core_backend_1.EditableWorkspaceDb.construct(args, core_backend_1.IModelHost.appWorkspace.getContainer(args));
|
|
50
50
|
await wsFile.createDb();
|
|
51
51
|
showMessage(`created WorkspaceDb ${wsFile.sqliteDb.nativeDb.getFilePath()}`);
|
|
52
52
|
wsFile.close();
|
|
@@ -76,15 +76,15 @@ function getCloudContainer(args) {
|
|
|
76
76
|
return cloudContainer;
|
|
77
77
|
}
|
|
78
78
|
function fixVersionArg(args) {
|
|
79
|
-
const dbParts = core_backend_1.
|
|
79
|
+
const dbParts = core_backend_1.WorkspaceContainer.parseDbFileName(args.dbName);
|
|
80
80
|
args.dbName = dbParts.dbName;
|
|
81
81
|
args.version = args.version ?? dbParts.version;
|
|
82
|
-
args.dbFileName = core_backend_1.
|
|
82
|
+
args.dbFileName = core_backend_1.WorkspaceContainer.makeDbFileName(dbParts.dbName, dbParts.version);
|
|
83
83
|
}
|
|
84
84
|
/** Open for write, call a function to process, then close a WorkspaceDb */
|
|
85
85
|
async function editWorkspace(args, fn) {
|
|
86
86
|
fixVersionArg(args);
|
|
87
|
-
const ws =
|
|
87
|
+
const ws = core_backend_1.EditableWorkspaceDb.construct(args, getContainer(args));
|
|
88
88
|
const cloudContainer = ws.container.cloudContainer;
|
|
89
89
|
if (cloudContainer && cloudContainer.queryDatabase(ws.dbFileName)?.state !== "copied")
|
|
90
90
|
throw new Error(`${args.dbFileName} is not editable. Create a new version first`);
|
|
@@ -93,7 +93,7 @@ async function editWorkspace(args, fn) {
|
|
|
93
93
|
/** Open for read, call a function to process, then close a WorkspaceDb */
|
|
94
94
|
async function readWorkspace(args, fn) {
|
|
95
95
|
fixVersionArg(args);
|
|
96
|
-
return processWorkspace(args,
|
|
96
|
+
return processWorkspace(args, core_backend_1.WorkspaceDb.construct(args, getContainer(args)), fn);
|
|
97
97
|
}
|
|
98
98
|
/** List the contents of a WorkspaceDb */
|
|
99
99
|
async function listWorkspaceDb(args) {
|
|
@@ -242,7 +242,7 @@ async function removeResource(args) {
|
|
|
242
242
|
async function vacuumWorkspaceDb(args) {
|
|
243
243
|
const container = getContainer(args);
|
|
244
244
|
fixVersionArg(args);
|
|
245
|
-
const localFile =
|
|
245
|
+
const localFile = core_backend_1.WorkspaceDb.construct(args, container).dbFileName;
|
|
246
246
|
doVacuum(localFile, container.cloudContainer);
|
|
247
247
|
}
|
|
248
248
|
/** Either upload or download a WorkspaceDb to/from a cloud WorkspaceContainer. Shows progress % during transfer */
|
|
@@ -274,7 +274,7 @@ async function performTransfer(container, direction, args) {
|
|
|
274
274
|
async function importWorkspaceDb(args) {
|
|
275
275
|
const container = getCloudContainer(args);
|
|
276
276
|
if ("" === (0, path_1.extname)(args.localFileName))
|
|
277
|
-
args.localFileName = `${args.localFileName}.${core_backend_1.
|
|
277
|
+
args.localFileName = `${args.localFileName}.${core_backend_1.WorkspaceDb.fileExt}`;
|
|
278
278
|
if (!core_backend_1.IModelJsFs.existsSync(args.localFileName))
|
|
279
279
|
args.localFileName = (0, path_1.join)(args.directory ?? core_backend_1.IModelHost.appWorkspace.containerDir, args.localFileName);
|
|
280
280
|
await core_backend_1.CloudSqlite.withWriteLock({ ...args, container }, async () => {
|
|
@@ -285,8 +285,8 @@ async function importWorkspaceDb(args) {
|
|
|
285
285
|
/** export a WorkspaceDb from a cloud WorkspaceContainer. */
|
|
286
286
|
async function exportWorkspaceDb(args) {
|
|
287
287
|
if (!(0, path_1.extname)(args.localFileName))
|
|
288
|
-
args.localFileName = `${args.localFileName}.${core_backend_1.
|
|
289
|
-
const dbParts = core_backend_1.
|
|
288
|
+
args.localFileName = `${args.localFileName}.${core_backend_1.WorkspaceDb.fileExt}`;
|
|
289
|
+
const dbParts = core_backend_1.WorkspaceContainer.parseDbFileName(args.dbName);
|
|
290
290
|
if (!dbParts.version)
|
|
291
291
|
throw new Error("exportDb requires a version");
|
|
292
292
|
await performTransfer(getCloudContainer(args), "download", args);
|
|
@@ -331,19 +331,20 @@ async function detachWorkspace(args) {
|
|
|
331
331
|
}
|
|
332
332
|
/** Make a copy of a WorkspaceDb with a new name. */
|
|
333
333
|
async function copyWorkspaceDb(args) {
|
|
334
|
-
const container =
|
|
335
|
-
const oldName =
|
|
336
|
-
const newVersion = core_backend_1.
|
|
337
|
-
core_backend_1.
|
|
338
|
-
const newName = core_backend_1.
|
|
339
|
-
|
|
334
|
+
const container = getContainer(args);
|
|
335
|
+
const oldName = container.resolveDbFileName(args);
|
|
336
|
+
const newVersion = core_backend_1.WorkspaceContainer.parseDbFileName(args.newDbName);
|
|
337
|
+
core_backend_1.WorkspaceContainer.validateDbName(newVersion.dbName);
|
|
338
|
+
const newName = core_backend_1.WorkspaceContainer.makeDbFileName(newVersion.dbName, core_backend_1.WorkspaceContainer.validateVersion(newVersion.version));
|
|
339
|
+
const cloudContainer = getCloudContainer(args);
|
|
340
|
+
await core_backend_1.CloudSqlite.withWriteLock({ ...args, container: cloudContainer }, async () => cloudContainer.copyDatabase(oldName, newName));
|
|
340
341
|
showMessage(`copied WorkspaceDb [${oldName}] to [${newName}] in ${sayContainer(args)}`);
|
|
341
342
|
}
|
|
342
343
|
/** Make a copy of a WorkspaceDb with a new name. */
|
|
343
344
|
async function versionWorkspaceDb(args) {
|
|
344
345
|
fixVersionArg(args);
|
|
345
|
-
const container =
|
|
346
|
-
const result = await
|
|
346
|
+
const container = getContainer(args);
|
|
347
|
+
const result = await container.makeNewVersion(args, args.versionType);
|
|
347
348
|
showMessage(`created new version: [${result.newName}] from [${result.oldName}] in ${sayContainer(args)}`);
|
|
348
349
|
}
|
|
349
350
|
/** pin a WorkspaceDb from a WorkspaceContainer. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@itwin/workspace-editor",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "lib/WorkspaceEditor.js",
|
|
5
|
-
"version": "4.5.0-dev.
|
|
5
|
+
"version": "4.5.0-dev.40",
|
|
6
6
|
"bin": {
|
|
7
7
|
"WorkspaceEditor": "./lib/WorkspaceEditor.js"
|
|
8
8
|
},
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"glob": "^7.1.2",
|
|
19
19
|
"yargs": "^17.4.0",
|
|
20
|
-
"@itwin/core-
|
|
21
|
-
"@itwin/core-
|
|
22
|
-
"@itwin/core-
|
|
20
|
+
"@itwin/core-common": "4.5.0-dev.40",
|
|
21
|
+
"@itwin/core-bentley": "4.5.0-dev.40",
|
|
22
|
+
"@itwin/core-backend": "4.5.0-dev.40"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@itwin/eslint-plugin": "4.0.0-dev.44",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"mocha": "^10.2.0",
|
|
32
32
|
"rimraf": "^3.0.2",
|
|
33
33
|
"typescript": "~5.0.2",
|
|
34
|
-
"@itwin/build-tools": "4.5.0-dev.
|
|
34
|
+
"@itwin/build-tools": "4.5.0-dev.40"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc 1>&2",
|