document-drive 0.0.18 → 0.0.20

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-drive",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "license": "AGPL-3.0-only",
5
5
  "type": "module",
6
6
  "module": "./src/index.ts",
@@ -33,7 +33,6 @@
33
33
  "sanitize-filename": "^1.6.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/proper-lockfile": "^4.1.4",
37
36
  "@typescript-eslint/eslint-plugin": "^6.12.0",
38
37
  "@typescript-eslint/parser": "^6.12.0",
39
38
  "@vitest/coverage-v8": "^0.34.6",
@@ -45,7 +44,6 @@
45
44
  "localforage": "^1.10.0",
46
45
  "prettier": "^3.1.0",
47
46
  "prettier-plugin-organize-imports": "^3.2.4",
48
- "tsx": "^4.6.2",
49
47
  "typescript": "^5.3.2",
50
48
  "vitest": "^0.34.6"
51
49
  }
@@ -41,7 +41,7 @@ export class DocumentDriveServer implements IDocumentDriveServer {
41
41
 
42
42
  addDrive(drive: DriveInput) {
43
43
  const document = utils.createDocument({
44
- state: { global: drive, local: {} }
44
+ state: drive
45
45
  });
46
46
  return this.storage.saveDrive(document);
47
47
  }
@@ -1,16 +1,21 @@
1
1
  import type {
2
2
  DocumentDriveAction,
3
3
  DocumentDriveDocument,
4
+ DocumentDriveLocalState,
4
5
  DocumentDriveState
5
6
  } from 'document-model-libs/document-drive';
6
7
  import type {
7
8
  BaseAction,
8
9
  Document,
9
10
  Operation,
10
- Signal
11
+ Signal,
12
+ State
11
13
  } from 'document-model/document';
12
14
 
13
- export type DriveInput = Omit<DocumentDriveState, '__typename' | 'nodes'>;
15
+ export type DriveInput = State<
16
+ Omit<DocumentDriveState, '__typename' | 'nodes'>,
17
+ DocumentDriveLocalState
18
+ >;
14
19
 
15
20
  export type CreateDocumentInput = {
16
21
  id: string;
@@ -1,7 +1,13 @@
1
1
  import { DocumentDriveDocument } from 'document-model-libs/document-drive';
2
2
  import { Document } from 'document-model/document';
3
3
  import type { Dirent } from 'fs';
4
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
4
+ import {
5
+ existsSync,
6
+ mkdirSync,
7
+ readFileSync,
8
+ readdirSync,
9
+ writeFileSync
10
+ } from 'fs';
5
11
  import fs from 'fs/promises';
6
12
  import path from 'path';
7
13
  import sanitize from 'sanitize-filename';
@@ -46,7 +52,7 @@ export class FilesystemStorage implements IDriveStorage {
46
52
  async getDocuments(drive: string) {
47
53
  let files: Dirent[] = [];
48
54
  try {
49
- files = await fs.readdir(path.join(this.basePath, drive), {
55
+ files = readdirSync(path.join(this.basePath, drive), {
50
56
  withFileTypes: true
51
57
  });
52
58
  } catch (error) {
@@ -72,10 +78,9 @@ export class FilesystemStorage implements IDriveStorage {
72
78
 
73
79
  async getDocument(drive: string, id: string) {
74
80
  try {
75
- const content = await fs.readFile(
76
- this._buildDocumentPath(drive, id),
77
- { encoding: 'utf-8' }
78
- );
81
+ const content = readFileSync(this._buildDocumentPath(drive, id), {
82
+ encoding: 'utf-8'
83
+ });
79
84
  return JSON.parse(content);
80
85
  } catch (error) {
81
86
  console.error(error);
@@ -96,7 +101,7 @@ export class FilesystemStorage implements IDriveStorage {
96
101
  }
97
102
 
98
103
  async getDrives() {
99
- const files = await fs.readdir(this.drivesPath, {
104
+ const files = await readdirSync(this.drivesPath, {
100
105
  withFileTypes: true
101
106
  });
102
107
  const drives: string[] = [];