@ocfl/ocfl-fs 0.2.2 → 0.4.0

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/index.js CHANGED
@@ -1,10 +1,14 @@
1
1
  //@ts-check
2
2
  const { OcflFsStore } = require('./lib/store.js');
3
- const { Ocfl } = require('@ocfl/ocfl');
3
+ const { implementOcfl } = require('@ocfl/ocfl');
4
4
  //const { default: ocfl } = require('./index.mjs');
5
5
 
6
6
  /** @type {import('./lib/store.js').OcflFsStoreConfig} */
7
7
  let defaultOptions;
8
8
 
9
- module.exports = new Ocfl(OcflFsStore, defaultOptions);
9
+ const ocfl = implementOcfl(OcflFsStore, defaultOptions);
10
+ const { OCFL_VERSIONS, StorageLayout, createStorage, loadStorage, object, storage, storageLayout } = ocfl;
11
+ module.exports = {
12
+ OCFL_VERSIONS, StorageLayout, createStorage, loadStorage, object, storage, storageLayout
13
+ };
10
14
  //module.exports.default = module.exports;
package/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './index.js';
2
- import ocfl from './index.js';
2
+ import * as ocfl from './index.js';
3
3
  export default ocfl;
4
+
package/lib/store.js CHANGED
@@ -53,7 +53,7 @@ class OcflFsStore extends OcflStore {
53
53
  }
54
54
 
55
55
  async createReadable(filePath, options) {
56
- return Readable.toWeb(this.fs.createReadStream(filePath, options));
56
+ return /** @type {ReadableStream} */ (Readable.toWeb(this.fs.createReadStream(filePath, options)));
57
57
  }
58
58
 
59
59
  async createWritable(filePath, options) {
@@ -68,6 +68,7 @@ class OcflFsStore extends OcflStore {
68
68
 
69
69
  async writeFile(filePath, data, options) {
70
70
  await this.fs.promises.mkdir(path.dirname(filePath), { recursive: true });
71
+ if (data instanceof ReadableStream) data = fs.ReadStream.fromWeb(data);
71
72
  await this.fs.promises.writeFile(filePath, data, options);
72
73
  }
73
74
 
@@ -133,6 +134,7 @@ class OcflFsStore extends OcflStore {
133
134
 
134
135
  async move(source, target) {
135
136
  try {
137
+ await this.fs.promises.mkdir(path.dirname(target), { recursive: true });
136
138
  return this.fs.promises.rename(source, target);
137
139
  } catch (error) {
138
140
  if (error.code === 'EXDEV') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ocfl/ocfl-fs",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "Oxford Common File Layout (OCFL) JS client library for filesystem storage",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -15,8 +15,7 @@
15
15
  },
16
16
  "scripts": {
17
17
  "test": "mocha",
18
- "build-docs2": "typedoc --tsconfig tsconfig.json",
19
- "build-docs": "jsdoc -c jsdoc.json"
18
+ "build-docs": "typedoc --plugin typedoc-plugin-missing-exports"
20
19
  },
21
20
  "keywords": [
22
21
  "ocfl",
@@ -27,7 +26,7 @@
27
26
  ],
28
27
  "repository": {
29
28
  "type": "git",
30
- "url": "https://github.com/Arkisto-Platform/ocfl-js"
29
+ "url": "https://github.com/Language-Research-Technology/ocfl-js.git"
31
30
  },
32
31
  "author": "Alvin Sebastian (https://orcid.org/0000-0002-9086-1722)",
33
32
  "contributors": [
@@ -36,16 +35,15 @@
36
35
  ],
37
36
  "license": "GPL-3.0-or-later",
38
37
  "devDependencies": {
39
- "@types/fs-extra": "^9.0.13",
40
- "@types/node": "^18",
41
- "clean-jsdoc-theme": "^4.3.0",
42
- "jsdoc": "^4.0.3",
43
- "mocha": "^10.7.3",
44
- "typedoc": "^0.22.15",
45
- "@ocfl/ocfl-tests": "*"
38
+ "@ocfl/ocfl-tests": "*",
39
+ "@types/fs-extra": "^11.0.4",
40
+ "@types/node": "^24",
41
+ "mocha": "^11.7.5",
42
+ "typedoc": "^0.28.19",
43
+ "typedoc-plugin-missing-exports": "^4.1.2"
46
44
  },
47
45
  "dependencies": {
48
- "@ocfl/ocfl": "0.2.2"
46
+ "@ocfl/ocfl": "0.4.0"
49
47
  },
50
48
  "files": [
51
49
  "index.js",