document-drive 0.0.7 → 0.0.9
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/package.json +5 -3
- package/src/server/index.ts +3 -1
- package/src/storage/browser.ts +6 -4
- package/src/storage/filesystem.ts +1 -1
- package/src/storage/memory.ts +1 -1
- package/src/utils.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-drive",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./src/index.ts",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
".": "./src/index.ts",
|
|
10
10
|
"./server": "./src/server/index.ts",
|
|
11
11
|
"./storage": "./src/storage/index.ts",
|
|
12
|
+
"./storage/filesystem": "./src/storage/filesystem.ts",
|
|
13
|
+
"./storage/browser": "./src/storage/browser.ts",
|
|
12
14
|
"./utils": "./src/utils.ts"
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
@@ -34,8 +36,8 @@
|
|
|
34
36
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
35
37
|
"@typescript-eslint/parser": "^6.12.0",
|
|
36
38
|
"@vitest/coverage-v8": "^0.34.6",
|
|
37
|
-
"document-model": "^1.0.
|
|
38
|
-
"document-model-libs": "^1.1.
|
|
39
|
+
"document-model": "^1.0.16",
|
|
40
|
+
"document-model-libs": "^1.1.24",
|
|
39
41
|
"eslint": "^8.54.0",
|
|
40
42
|
"eslint-config-prettier": "^9.0.0",
|
|
41
43
|
"fake-indexeddb": "^5.0.1",
|
package/src/server/index.ts
CHANGED
|
@@ -40,7 +40,9 @@ export class DocumentDriveServer implements IDocumentDriveServer {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
addDrive(drive: DriveInput) {
|
|
43
|
-
const document = utils.createDocument({
|
|
43
|
+
const document = utils.createDocument({
|
|
44
|
+
state: { global: drive, local: {} }
|
|
45
|
+
});
|
|
44
46
|
return this.storage.saveDrive(document);
|
|
45
47
|
}
|
|
46
48
|
|
package/src/storage/browser.ts
CHANGED
|
@@ -53,7 +53,7 @@ export class BrowserStorage implements IDriveStorage {
|
|
|
53
53
|
await this.db
|
|
54
54
|
).getItem<DocumentDriveDocument[]>(BrowserStorage.DRIVES_KEY)) ??
|
|
55
55
|
[];
|
|
56
|
-
return drives.map(drive => drive.state.id);
|
|
56
|
+
return drives.map(drive => drive.state.global.id);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
async getDrive(id: string) {
|
|
@@ -62,7 +62,7 @@ export class BrowserStorage implements IDriveStorage {
|
|
|
62
62
|
await this.db
|
|
63
63
|
).getItem<DocumentDriveDocument[]>(BrowserStorage.DRIVES_KEY)) ??
|
|
64
64
|
[];
|
|
65
|
-
const drive = drives.find(drive => drive.state.id === id);
|
|
65
|
+
const drive = drives.find(drive => drive.state.global.id === id);
|
|
66
66
|
if (!drive) {
|
|
67
67
|
throw new Error(`Drive with id ${id} not found`);
|
|
68
68
|
}
|
|
@@ -75,7 +75,9 @@ export class BrowserStorage implements IDriveStorage {
|
|
|
75
75
|
(await db.getItem<DocumentDriveDocument[]>(
|
|
76
76
|
BrowserStorage.DRIVES_KEY
|
|
77
77
|
)) ?? [];
|
|
78
|
-
const index = drives.findIndex(
|
|
78
|
+
const index = drives.findIndex(
|
|
79
|
+
d => d.state.global.id === drive.state.global.id
|
|
80
|
+
);
|
|
79
81
|
if (index > -1) {
|
|
80
82
|
drives[index] = drive;
|
|
81
83
|
} else {
|
|
@@ -94,7 +96,7 @@ export class BrowserStorage implements IDriveStorage {
|
|
|
94
96
|
)) ?? [];
|
|
95
97
|
await db.setItem(
|
|
96
98
|
BrowserStorage.DRIVES_KEY,
|
|
97
|
-
drives.filter(drive => drive.state.id !== id)
|
|
99
|
+
drives.filter(drive => drive.state.global.id !== id)
|
|
98
100
|
);
|
|
99
101
|
}
|
|
100
102
|
}
|
package/src/storage/memory.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -10,6 +10,6 @@ export function isDocumentDrive(
|
|
|
10
10
|
): document is DocumentDriveDocument {
|
|
11
11
|
return (
|
|
12
12
|
document.documentType === DocumentDriveModel.id &&
|
|
13
|
-
z.DocumentDriveStateSchema().safeParse(document.state).success
|
|
13
|
+
z.DocumentDriveStateSchema().safeParse(document.state.global).success
|
|
14
14
|
);
|
|
15
15
|
}
|