memfs 4.1.0 → 4.2.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/README.md +10 -7
- package/demo/runkit.js +5 -0
- package/lib/Dirent.js +1 -0
- package/lib/Dirent.js.map +1 -0
- package/lib/Stats.js +2 -2
- package/lib/Stats.js.map +1 -0
- package/lib/__tests__/util.js +1 -0
- package/lib/__tests__/util.js.map +1 -0
- package/lib/cas/types.d.ts +10 -0
- package/lib/{node/types/callback.js → cas/types.js} +1 -0
- package/lib/cas/types.js.map +1 -0
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -0
- package/lib/consts/AMODE.js +1 -0
- package/lib/consts/AMODE.js.map +1 -0
- package/lib/consts/FLAG.d.ts +6 -0
- package/lib/consts/FLAG.js +1 -0
- package/lib/consts/FLAG.js.map +1 -0
- package/lib/crud/__tests__/matryoshka.test.d.ts +1 -0
- package/lib/crud/__tests__/matryoshka.test.js +69 -0
- package/lib/crud/__tests__/matryoshka.test.js.map +1 -0
- package/lib/crud/__tests__/testCrudfs.d.ts +6 -0
- package/lib/crud/__tests__/testCrudfs.js +278 -0
- package/lib/crud/__tests__/testCrudfs.js.map +1 -0
- package/lib/crud/types.d.ts +80 -0
- package/lib/{node/types/promises.js → crud/types.js} +1 -0
- package/lib/crud/types.js.map +1 -0
- package/lib/crud/util.d.ts +2 -0
- package/lib/crud/util.js +11 -0
- package/lib/crud/util.js.map +1 -0
- package/lib/crud-to-cas/CrudCas.d.ts +14 -0
- package/lib/crud-to-cas/CrudCas.js +57 -0
- package/lib/crud-to-cas/CrudCas.js.map +1 -0
- package/lib/crud-to-cas/__tests__/CrudCas.test.d.ts +1 -0
- package/lib/crud-to-cas/__tests__/CrudCas.test.js +38 -0
- package/lib/crud-to-cas/__tests__/CrudCas.test.js.map +1 -0
- package/lib/crud-to-cas/__tests__/testCasfs.d.ts +9 -0
- package/lib/crud-to-cas/__tests__/testCasfs.js +108 -0
- package/lib/crud-to-cas/__tests__/testCasfs.js.map +1 -0
- package/lib/crud-to-cas/index.d.ts +1 -0
- package/lib/crud-to-cas/index.js +6 -0
- package/lib/crud-to-cas/index.js.map +1 -0
- package/lib/crud-to-cas/util.d.ts +2 -0
- package/lib/crud-to-cas/util.js +13 -0
- package/lib/crud-to-cas/util.js.map +1 -0
- package/lib/encoding.js +1 -0
- package/lib/encoding.js.map +1 -0
- package/lib/fsa/types.js +1 -0
- package/lib/fsa/types.js.map +1 -0
- package/lib/fsa-to-crud/FsaCrud.d.ts +15 -0
- package/lib/fsa-to-crud/FsaCrud.js +191 -0
- package/lib/fsa-to-crud/FsaCrud.js.map +1 -0
- package/lib/fsa-to-crud/__tests__/FsaCrud.test.d.ts +1 -0
- package/lib/fsa-to-crud/__tests__/FsaCrud.test.js +17 -0
- package/lib/fsa-to-crud/__tests__/FsaCrud.test.js.map +1 -0
- package/lib/fsa-to-crud/index.d.ts +1 -0
- package/lib/fsa-to-crud/index.js +6 -0
- package/lib/fsa-to-crud/index.js.map +1 -0
- package/lib/fsa-to-crud/util.d.ts +5 -0
- package/lib/fsa-to-crud/util.js +12 -0
- package/lib/fsa-to-crud/util.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeCore.d.ts +3 -2
- package/lib/fsa-to-node/FsaNodeCore.js +109 -87
- package/lib/fsa-to-node/FsaNodeCore.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeDirent.js +1 -0
- package/lib/fsa-to-node/FsaNodeDirent.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeFs.d.ts +14 -2
- package/lib/fsa-to-node/FsaNodeFs.js +156 -143
- package/lib/fsa-to-node/FsaNodeFs.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeFsOpenFile.js +13 -25
- package/lib/fsa-to-node/FsaNodeFsOpenFile.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeReadStream.js +14 -24
- package/lib/fsa-to-node/FsaNodeReadStream.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeStats.js +1 -0
- package/lib/fsa-to-node/FsaNodeStats.js.map +1 -0
- package/lib/fsa-to-node/FsaNodeWriteStream.js +35 -47
- package/lib/fsa-to-node/FsaNodeWriteStream.js.map +1 -0
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js +357 -348
- package/lib/fsa-to-node/__tests__/FsaNodeFs.test.js.map +1 -0
- package/lib/fsa-to-node/__tests__/util.test.js +4 -0
- package/lib/fsa-to-node/__tests__/util.test.js.map +1 -0
- package/lib/fsa-to-node/constants.js +1 -0
- package/lib/fsa-to-node/constants.js.map +1 -0
- package/lib/fsa-to-node/index.js +1 -0
- package/lib/fsa-to-node/index.js.map +1 -0
- package/lib/fsa-to-node/json.js +1 -0
- package/lib/fsa-to-node/json.js.map +1 -0
- package/lib/fsa-to-node/types.js +1 -0
- package/lib/fsa-to-node/types.js.map +1 -0
- package/lib/fsa-to-node/util.js +7 -13
- package/lib/fsa-to-node/util.js.map +1 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js +31 -41
- package/lib/fsa-to-node/worker/FsaNodeSyncAdapterWorker.js.map +1 -0
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js +91 -105
- package/lib/fsa-to-node/worker/FsaNodeSyncWorker.js.map +1 -0
- package/lib/fsa-to-node/worker/SyncMessenger.js +4 -12
- package/lib/fsa-to-node/worker/SyncMessenger.js.map +1 -0
- package/lib/fsa-to-node/worker/constants.js +1 -0
- package/lib/fsa-to-node/worker/constants.js.map +1 -0
- package/lib/fsa-to-node/worker/types.js +1 -0
- package/lib/fsa-to-node/worker/types.js.map +1 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.js +8 -6
- package/lib/index.js.map +1 -0
- package/lib/internal/buffer.js +1 -0
- package/lib/internal/buffer.js.map +1 -0
- package/lib/internal/errors.js +1 -0
- package/lib/internal/errors.js.map +1 -0
- package/lib/node/FileHandle.js +1 -0
- package/lib/node/FileHandle.js.map +1 -0
- package/lib/node/FsPromises.d.ts +86 -0
- package/lib/node/FsPromises.js +54 -0
- package/lib/node/FsPromises.js.map +1 -0
- package/lib/node/constants.js +2 -1
- package/lib/node/constants.js.map +1 -0
- package/lib/node/lists/fsCallbackApiList.d.ts +2 -0
- package/lib/node/lists/fsCallbackApiList.js +47 -0
- package/lib/node/lists/fsCallbackApiList.js.map +1 -0
- package/lib/node/lists/fsCommonObjectsList.d.ts +2 -0
- package/lib/node/lists/fsCommonObjectsList.js +19 -0
- package/lib/node/lists/fsCommonObjectsList.js.map +1 -0
- package/lib/node/lists/fsSynchronousApiList.d.ts +2 -0
- package/lib/node/lists/fsSynchronousApiList.js +46 -0
- package/lib/node/lists/fsSynchronousApiList.js.map +1 -0
- package/lib/node/options.js +1 -0
- package/lib/node/options.js.map +1 -0
- package/lib/node/types/{callback.d.ts → FsCallbackApi.d.ts} +49 -40
- package/lib/node/types/FsCallbackApi.js +3 -0
- package/lib/node/types/FsCallbackApi.js.map +1 -0
- package/lib/node/types/FsCommonObjects.d.ts +4 -4
- package/lib/node/types/FsCommonObjects.js +1 -0
- package/lib/node/types/FsCommonObjects.js.map +1 -0
- package/lib/node/types/{promises.d.ts → FsPromisesApi.d.ts} +11 -0
- package/lib/node/types/FsPromisesApi.js +3 -0
- package/lib/node/types/FsPromisesApi.js.map +1 -0
- package/lib/node/types/FsSynchronousApi.d.ts +64 -58
- package/lib/node/types/FsSynchronousApi.js +1 -0
- package/lib/node/types/FsSynchronousApi.js.map +1 -0
- package/lib/node/types/index.d.ts +2 -2
- package/lib/node/types/index.js +1 -0
- package/lib/node/types/index.js.map +1 -0
- package/lib/node/types/misc.d.ts +20 -0
- package/lib/node/types/misc.js +1 -0
- package/lib/node/types/misc.js.map +1 -0
- package/lib/node/types/options.d.ts +62 -0
- package/lib/node/types/options.js +1 -0
- package/lib/node/types/options.js.map +1 -0
- package/lib/node/util.d.ts +2 -1
- package/lib/node/util.js +30 -1
- package/lib/node/util.js.map +1 -0
- package/lib/node-to-crud/NodeCrud.d.ts +22 -0
- package/lib/node-to-crud/NodeCrud.js +233 -0
- package/lib/node-to-crud/NodeCrud.js.map +1 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.d.ts +1 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.js +18 -0
- package/lib/node-to-crud/__tests__/FsaCrud.test.js.map +1 -0
- package/lib/node-to-crud/index.d.ts +1 -0
- package/lib/node-to-crud/index.js +6 -0
- package/lib/node-to-crud/index.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.d.ts +3 -2
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js +112 -151
- package/lib/node-to-fsa/NodeFileSystemDirectoryHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemFileHandle.js +25 -36
- package/lib/node-to-fsa/NodeFileSystemFileHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemHandle.js +3 -13
- package/lib/node-to-fsa/NodeFileSystemHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js +42 -62
- package/lib/node-to-fsa/NodeFileSystemSyncAccessHandle.js.map +1 -0
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js +92 -116
- package/lib/node-to-fsa/NodeFileSystemWritableFileStream.js.map +1 -0
- package/lib/node-to-fsa/NodePermissionStatus.js +1 -0
- package/lib/node-to-fsa/NodePermissionStatus.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js +175 -234
- package/lib/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js +91 -99
- package/lib/node-to-fsa/__tests__/NodeFileSystemFileHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js +10 -18
- package/lib/node-to-fsa/__tests__/NodeFileSystemHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js +70 -78
- package/lib/node-to-fsa/__tests__/NodeFileSystemSyncAccessHandle.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js +31 -39
- package/lib/node-to-fsa/__tests__/NodeFileSystemWritableFileStream.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/scenarios.test.js +18 -26
- package/lib/node-to-fsa/__tests__/scenarios.test.js.map +1 -0
- package/lib/node-to-fsa/__tests__/util.test.js +5 -0
- package/lib/node-to-fsa/__tests__/util.test.js.map +1 -0
- package/lib/node-to-fsa/index.js +6 -18
- package/lib/node-to-fsa/index.js.map +1 -0
- package/lib/node-to-fsa/types.d.ts +5 -2
- package/lib/node-to-fsa/types.js +1 -0
- package/lib/node-to-fsa/types.js.map +1 -0
- package/lib/node-to-fsa/util.js +3 -0
- package/lib/node-to-fsa/util.js.map +1 -0
- package/lib/node.js +1 -0
- package/lib/node.js.map +1 -0
- package/lib/print/__tests__/index.test.d.ts +1 -0
- package/lib/print/__tests__/index.test.js +77 -0
- package/lib/print/__tests__/index.test.js.map +1 -0
- package/lib/print/index.d.ts +8 -0
- package/lib/print/index.js +33 -0
- package/lib/print/index.js.map +1 -0
- package/lib/process.js +1 -0
- package/lib/process.js.map +1 -0
- package/lib/setImmediate.js +1 -0
- package/lib/setImmediate.js.map +1 -0
- package/lib/setTimeoutUnref.js +1 -0
- package/lib/setTimeoutUnref.js.map +1 -0
- package/lib/snapshot/__tests__/async.test.d.ts +1 -0
- package/lib/snapshot/__tests__/async.test.js +63 -0
- package/lib/snapshot/__tests__/async.test.js.map +1 -0
- package/lib/snapshot/__tests__/binary.test.d.ts +1 -0
- package/lib/snapshot/__tests__/binary.test.js +59 -0
- package/lib/snapshot/__tests__/binary.test.js.map +1 -0
- package/lib/snapshot/__tests__/json.test.d.ts +1 -0
- package/lib/snapshot/__tests__/json.test.js +68 -0
- package/lib/snapshot/__tests__/json.test.js.map +1 -0
- package/lib/snapshot/__tests__/sync.test.d.ts +1 -0
- package/lib/snapshot/__tests__/sync.test.js +63 -0
- package/lib/snapshot/__tests__/sync.test.js.map +1 -0
- package/lib/snapshot/async.d.ts +3 -0
- package/lib/snapshot/async.js +59 -0
- package/lib/snapshot/async.js.map +1 -0
- package/lib/snapshot/binary.d.ts +6 -0
- package/lib/snapshot/binary.js +31 -0
- package/lib/snapshot/binary.js.map +1 -0
- package/lib/snapshot/constants.d.ts +5 -0
- package/lib/snapshot/constants.js +3 -0
- package/lib/snapshot/constants.js.map +1 -0
- package/lib/snapshot/index.d.ts +5 -0
- package/lib/snapshot/index.js +8 -0
- package/lib/snapshot/index.js.map +1 -0
- package/lib/snapshot/json.d.ts +10 -0
- package/lib/snapshot/json.js +31 -0
- package/lib/snapshot/json.js.map +1 -0
- package/lib/snapshot/shared.d.ts +2 -0
- package/lib/snapshot/shared.js +6 -0
- package/lib/snapshot/shared.js.map +1 -0
- package/lib/snapshot/sync.d.ts +3 -0
- package/lib/snapshot/sync.js +59 -0
- package/lib/snapshot/sync.js.map +1 -0
- package/lib/snapshot/types.d.ts +30 -0
- package/lib/snapshot/types.js +3 -0
- package/lib/snapshot/types.js.map +1 -0
- package/lib/volume-localstorage.js +1 -0
- package/lib/volume-localstorage.js.map +1 -0
- package/lib/volume.d.ts +18 -7
- package/lib/volume.js +25 -16
- package/lib/volume.js.map +1 -0
- package/lib/webfs/index.js +1 -0
- package/lib/webfs/index.js.map +1 -0
- package/package.json +67 -26
- package/lib/getBigInt.js +0 -5
- package/lib/node/promises.d.ts +0 -2
- package/lib/node/promises.js +0 -86
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface CrudApi {
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new resource, or overwrites an existing one.
|
|
4
|
+
*
|
|
5
|
+
* @param collection Type of the resource, collection name.
|
|
6
|
+
* @param id Id of the resource, document name.
|
|
7
|
+
* @param data Blob content of the resource.
|
|
8
|
+
* @param options Write behavior options.
|
|
9
|
+
*/
|
|
10
|
+
put: (collection: CrudCollection, id: string, data: Uint8Array, options?: CrudPutOptions) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the content of a resource.
|
|
13
|
+
*
|
|
14
|
+
* @param collection Type of the resource, collection name.
|
|
15
|
+
* @param id Id of the resource, document name.
|
|
16
|
+
* @returns Blob content of the resource.
|
|
17
|
+
*/
|
|
18
|
+
get: (collection: CrudCollection, id: string) => Promise<Uint8Array>;
|
|
19
|
+
/**
|
|
20
|
+
* Deletes a resource.
|
|
21
|
+
*
|
|
22
|
+
* @param collection Type of the resource, collection name.
|
|
23
|
+
* @param id Id of the resource, document name.
|
|
24
|
+
* @param silent When true, does not throw an error if the collection or
|
|
25
|
+
* resource does not exist. Default is false.
|
|
26
|
+
*/
|
|
27
|
+
del: (collection: CrudCollection, id: string, silent?: boolean) => Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetches information about a resource.
|
|
30
|
+
*
|
|
31
|
+
* @param collection Type of the resource, collection name.
|
|
32
|
+
* @param id Id of the resource, document name, if any.
|
|
33
|
+
* @returns Information about the resource.
|
|
34
|
+
*/
|
|
35
|
+
info: (collection: CrudCollection, id?: string) => Promise<CrudResourceInfo>;
|
|
36
|
+
/**
|
|
37
|
+
* Deletes all resources of a collection, and deletes recursively all sub-collections.
|
|
38
|
+
*
|
|
39
|
+
* @param collection Type of the resource, collection name.
|
|
40
|
+
* @param silent When true, does not throw an error if the collection or
|
|
41
|
+
* resource does not exist. Default is false.
|
|
42
|
+
*/
|
|
43
|
+
drop: (collection: CrudCollection, silent?: boolean) => Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches a list of resources of a collection, and sub-collections.
|
|
46
|
+
*
|
|
47
|
+
* @param collection Type of the resource, collection name.
|
|
48
|
+
* @returns List of resources of the given type, and sub-types.
|
|
49
|
+
*/
|
|
50
|
+
list: (collection: CrudCollection) => Promise<CrudCollectionEntry[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new CrudApi instance, with the given collection as root.
|
|
53
|
+
*
|
|
54
|
+
* @param collection Type of the resource, collection name.
|
|
55
|
+
* @returns A new CrudApi instance, with the given collection as root.
|
|
56
|
+
*/
|
|
57
|
+
from: (collection: CrudCollection) => Promise<CrudApi>;
|
|
58
|
+
}
|
|
59
|
+
export type CrudCollection = string[];
|
|
60
|
+
export interface CrudPutOptions {
|
|
61
|
+
throwIf?: 'exists' | 'missing';
|
|
62
|
+
}
|
|
63
|
+
export interface CrudCollectionEntry {
|
|
64
|
+
/** Kind of the resource, type or item. */
|
|
65
|
+
type: 'resource' | 'collection';
|
|
66
|
+
/** Name of the resource. */
|
|
67
|
+
id: string;
|
|
68
|
+
}
|
|
69
|
+
export interface CrudResourceInfo extends CrudCollectionEntry {
|
|
70
|
+
/** Size of the resource in bytes. */
|
|
71
|
+
size?: number;
|
|
72
|
+
/** Timestamp when the resource last modified. */
|
|
73
|
+
modified?: number;
|
|
74
|
+
/** Timestamp when the resource was created. */
|
|
75
|
+
created?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface CrudScanResult {
|
|
78
|
+
cursor: string | '';
|
|
79
|
+
list: CrudCollectionEntry[];
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/crud/types.ts"],"names":[],"mappings":""}
|
package/lib/crud/util.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertType = void 0;
|
|
4
|
+
const util_1 = require("../node-to-fsa/util");
|
|
5
|
+
const assertType = (type, method, klass) => {
|
|
6
|
+
const length = type.length;
|
|
7
|
+
for (let i = 0; i < length; i++)
|
|
8
|
+
(0, util_1.assertName)(type[i], method, klass);
|
|
9
|
+
};
|
|
10
|
+
exports.assertType = assertType;
|
|
11
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/crud/util.ts"],"names":[],"mappings":";;;AACA,8CAAiD;AAE1C,MAAM,UAAU,GAAG,CAAC,IAAoB,EAAE,MAAc,EAAE,KAAa,EAAQ,EAAE;IACtF,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE;QAAE,IAAA,iBAAU,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACtE,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CasApi, CasGetOptions } from '../cas/types';
|
|
2
|
+
import type { CrudApi, CrudResourceInfo } from '../crud/types';
|
|
3
|
+
export interface CrudCasOptions {
|
|
4
|
+
hash: (blob: Uint8Array) => Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare class CrudCas implements CasApi {
|
|
7
|
+
protected readonly crud: CrudApi;
|
|
8
|
+
protected readonly options: CrudCasOptions;
|
|
9
|
+
constructor(crud: CrudApi, options: CrudCasOptions);
|
|
10
|
+
readonly put: (blob: Uint8Array) => Promise<string>;
|
|
11
|
+
readonly get: (hash: string, options?: CasGetOptions) => Promise<Uint8Array>;
|
|
12
|
+
readonly del: (hash: string, silent?: boolean) => Promise<void>;
|
|
13
|
+
readonly info: (hash: string) => Promise<CrudResourceInfo>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudCas = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
const normalizeErrors = async (code) => {
|
|
6
|
+
try {
|
|
7
|
+
return await code();
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error && typeof error === 'object') {
|
|
11
|
+
switch (error.name) {
|
|
12
|
+
case 'ResourceNotFound':
|
|
13
|
+
case 'CollectionNotFound':
|
|
14
|
+
throw new DOMException(error.message, 'BlobNotFound');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
class CrudCas {
|
|
21
|
+
constructor(crud, options) {
|
|
22
|
+
this.crud = crud;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.put = async (blob) => {
|
|
25
|
+
const digest = await this.options.hash(blob);
|
|
26
|
+
const [collection, resource] = (0, util_1.hashToLocation)(digest);
|
|
27
|
+
await this.crud.put(collection, resource, blob);
|
|
28
|
+
return digest;
|
|
29
|
+
};
|
|
30
|
+
this.get = async (hash, options) => {
|
|
31
|
+
const [collection, resource] = (0, util_1.hashToLocation)(hash);
|
|
32
|
+
return await normalizeErrors(async () => {
|
|
33
|
+
const blob = await this.crud.get(collection, resource);
|
|
34
|
+
if (!(options === null || options === void 0 ? void 0 : options.skipVerification)) {
|
|
35
|
+
const digest = await this.options.hash(blob);
|
|
36
|
+
if (hash !== digest)
|
|
37
|
+
throw new DOMException('Blob contents does not match hash', 'Integrity');
|
|
38
|
+
}
|
|
39
|
+
return blob;
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
this.del = async (hash, silent) => {
|
|
43
|
+
const [collection, resource] = (0, util_1.hashToLocation)(hash);
|
|
44
|
+
await normalizeErrors(async () => {
|
|
45
|
+
return await this.crud.del(collection, resource, silent);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
this.info = async (hash) => {
|
|
49
|
+
const [collection, resource] = (0, util_1.hashToLocation)(hash);
|
|
50
|
+
return await normalizeErrors(async () => {
|
|
51
|
+
return await this.crud.info(collection, resource);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CrudCas = CrudCas;
|
|
57
|
+
//# sourceMappingURL=CrudCas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"C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,QAAQ,CAAC,CAAC;gBACvD,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAA,EAAE;oBAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC7C,IAAI,IAAI,KAAK,MAAM;wBAAE,MAAM,IAAI,YAAY,CAAC,mCAAmC,EAAE,WAAW,CAAC,CAAC;iBAC/F;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEc,QAAG,GAAG,KAAK,EAAE,IAAY,EAAE,MAAgB,EAAiB,EAAE;YAC5E,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;YACpD,MAAM,eAAe,CAAC,KAAK,IAAI,EAAE;gBAC/B,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEc,SAAI,GAAG,KAAK,EAAE,IAAY,EAA6B,EAAE;YACvE,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;YACpD,OAAO,MAAM,eAAe,CAAC,KAAK,IAAI,EAAE;gBACtC,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAjCyF,CAAC;CAkC7F;AAnCD,0BAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __1 = require("../..");
|
|
4
|
+
const util_1 = require("../../__tests__/util");
|
|
5
|
+
const node_to_fsa_1 = require("../../node-to-fsa");
|
|
6
|
+
const FsaCrud_1 = require("../../fsa-to-crud/FsaCrud");
|
|
7
|
+
const CrudCas_1 = require("../CrudCas");
|
|
8
|
+
const testCasfs_1 = require("./testCasfs");
|
|
9
|
+
const NodeCrud_1 = require("../../node-to-crud/NodeCrud");
|
|
10
|
+
(0, util_1.onlyOnNode20)('CrudCas on FsaCrud', () => {
|
|
11
|
+
const setup = () => {
|
|
12
|
+
const { fs } = (0, __1.memfs)();
|
|
13
|
+
const fsa = new node_to_fsa_1.NodeFileSystemDirectoryHandle(fs, '/', { mode: 'readwrite' });
|
|
14
|
+
const crud = new FsaCrud_1.FsaCrud(fsa);
|
|
15
|
+
const cas = new CrudCas_1.CrudCas(crud, { hash: testCasfs_1.hash });
|
|
16
|
+
return { fs, fsa, crud, cas, snapshot: () => fs.__vol.toJSON() };
|
|
17
|
+
};
|
|
18
|
+
(0, testCasfs_1.testCasfs)(setup);
|
|
19
|
+
});
|
|
20
|
+
(0, util_1.onlyOnNode20)('CrudCas on NodeCrud at root', () => {
|
|
21
|
+
const setup = () => {
|
|
22
|
+
const { fs } = (0, __1.memfs)();
|
|
23
|
+
const crud = new NodeCrud_1.NodeCrud({ fs: fs.promises, dir: '/' });
|
|
24
|
+
const cas = new CrudCas_1.CrudCas(crud, { hash: testCasfs_1.hash });
|
|
25
|
+
return { fs, crud, cas, snapshot: () => fs.__vol.toJSON() };
|
|
26
|
+
};
|
|
27
|
+
(0, testCasfs_1.testCasfs)(setup);
|
|
28
|
+
});
|
|
29
|
+
(0, util_1.onlyOnNode20)('CrudCas on NodeCrud at in sub-folder', () => {
|
|
30
|
+
const setup = () => {
|
|
31
|
+
const { fs } = (0, __1.memfs)({ '/a/b/c': null });
|
|
32
|
+
const crud = new NodeCrud_1.NodeCrud({ fs: fs.promises, dir: '/a/b/c' });
|
|
33
|
+
const cas = new CrudCas_1.CrudCas(crud, { hash: testCasfs_1.hash });
|
|
34
|
+
return { fs, crud, cas, snapshot: () => fs.__vol.toJSON() };
|
|
35
|
+
};
|
|
36
|
+
(0, testCasfs_1.testCasfs)(setup);
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=CrudCas.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrudCas.test.js","sourceRoot":"","sources":["../../../src/crud-to-cas/__tests__/CrudCas.test.ts"],"names":[],"mappings":";;AAAA,6BAA8B;AAC9B,+CAAoD;AACpD,mDAAkE;AAClE,uDAAoD;AACpD,wCAAqC;AACrC,2CAA8C;AAC9C,0DAAuD;AAEvD,IAAA,mBAAY,EAAC,oBAAoB,EAAE,GAAG,EAAE;IACtC,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,MAAM,EAAE,EAAE,EAAE,GAAG,IAAA,SAAK,GAAE,CAAC;QACvB,MAAM,GAAG,GAAG,IAAI,2CAA6B,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9E,MAAM,IAAI,GAAG,IAAI,iBAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,GAAG,GAAG,IAAI,iBAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAJ,gBAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAO,EAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;IAC1E,CAAC,CAAC;IACF,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,IAAA,mBAAY,EAAC,6BAA6B,EAAE,GAAG,EAAE;IAC/C,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,MAAM,EAAE,EAAE,EAAE,GAAG,IAAA,SAAK,GAAE,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,mBAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,IAAI,iBAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAJ,gBAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAO,EAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;IACrE,CAAC,CAAC;IACF,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,IAAA,mBAAY,EAAC,sCAAsC,EAAE,GAAG,EAAE;IACxD,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,MAAM,EAAE,EAAE,EAAE,GAAG,IAAA,SAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,mBAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,MAAM,GAAG,GAAG,IAAI,iBAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAJ,gBAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAO,EAAG,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;IACrE,CAAC,CAAC;IACF,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CasApi } from '../../cas/types';
|
|
2
|
+
import type { CrudApi } from '../../crud/types';
|
|
3
|
+
export declare const hash: (blob: Uint8Array) => Promise<string>;
|
|
4
|
+
export type Setup = () => {
|
|
5
|
+
cas: CasApi;
|
|
6
|
+
crud: CrudApi;
|
|
7
|
+
snapshot: () => Record<string, string | null>;
|
|
8
|
+
};
|
|
9
|
+
export declare const testCasfs: (setup: Setup) => void;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testCasfs = exports.hash = void 0;
|
|
4
|
+
const thingies_1 = require("thingies");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const util_1 = require("../util");
|
|
7
|
+
const hash = async (blob) => {
|
|
8
|
+
const shasum = (0, crypto_1.createHash)('sha1');
|
|
9
|
+
shasum.update(blob);
|
|
10
|
+
return shasum.digest('hex');
|
|
11
|
+
};
|
|
12
|
+
exports.hash = hash;
|
|
13
|
+
const b = (str) => {
|
|
14
|
+
const buf = Buffer.from(str);
|
|
15
|
+
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
16
|
+
};
|
|
17
|
+
const testCasfs = (setup) => {
|
|
18
|
+
describe('.put()', () => {
|
|
19
|
+
test('can store a blob', async () => {
|
|
20
|
+
const blob = b('hello world');
|
|
21
|
+
const { cas, snapshot } = setup();
|
|
22
|
+
const hash = await cas.put(blob);
|
|
23
|
+
expect(hash).toBe('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed');
|
|
24
|
+
expect(snapshot()).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('.get()', () => {
|
|
28
|
+
test('can retrieve existing blob', async () => {
|
|
29
|
+
const blob = b('hello world');
|
|
30
|
+
const { cas } = setup();
|
|
31
|
+
const hash = await cas.put(blob);
|
|
32
|
+
const blob2 = await cas.get(hash);
|
|
33
|
+
expect(blob2).toStrictEqual(blob);
|
|
34
|
+
});
|
|
35
|
+
test('throws if blob does not exist', async () => {
|
|
36
|
+
const blob = b('hello world 2');
|
|
37
|
+
const { cas } = setup();
|
|
38
|
+
const hash = await cas.put(blob);
|
|
39
|
+
const [, err] = await (0, thingies_1.of)(cas.get('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'));
|
|
40
|
+
expect(err).toBeInstanceOf(DOMException);
|
|
41
|
+
expect(err.name).toBe('BlobNotFound');
|
|
42
|
+
});
|
|
43
|
+
test('throws if blob contents does not match the hash', async () => {
|
|
44
|
+
const blob = b('hello world');
|
|
45
|
+
const { cas, crud } = setup();
|
|
46
|
+
const hash = await cas.put(blob);
|
|
47
|
+
const location = (0, util_1.hashToLocation)(hash);
|
|
48
|
+
await crud.put(location[0], location[1], b('hello world!'));
|
|
49
|
+
const [, err] = await (0, thingies_1.of)(cas.get(hash));
|
|
50
|
+
expect(err).toBeInstanceOf(DOMException);
|
|
51
|
+
expect(err.name).toBe('Integrity');
|
|
52
|
+
});
|
|
53
|
+
test('does not throw if integrity check is skipped', async () => {
|
|
54
|
+
const blob = b('hello world');
|
|
55
|
+
const { cas, crud } = setup();
|
|
56
|
+
const hash = await cas.put(blob);
|
|
57
|
+
const location = (0, util_1.hashToLocation)(hash);
|
|
58
|
+
await crud.put(location[0], location[1], b('hello world!'));
|
|
59
|
+
const blob2 = await cas.get(hash, { skipVerification: true });
|
|
60
|
+
expect(blob2).toStrictEqual(b('hello world!'));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
describe('.info()', () => {
|
|
64
|
+
test('can retrieve existing blob info', async () => {
|
|
65
|
+
const blob = b('hello world');
|
|
66
|
+
const { cas } = setup();
|
|
67
|
+
const hash = await cas.put(blob);
|
|
68
|
+
const info = await cas.info(hash);
|
|
69
|
+
expect(info.size).toBe(11);
|
|
70
|
+
});
|
|
71
|
+
test('throws if blob does not exist', async () => {
|
|
72
|
+
const blob = b('hello world 2');
|
|
73
|
+
const { cas } = setup();
|
|
74
|
+
const hash = await cas.put(blob);
|
|
75
|
+
const [, err] = await (0, thingies_1.of)(cas.info('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'));
|
|
76
|
+
expect(err).toBeInstanceOf(DOMException);
|
|
77
|
+
expect(err.name).toBe('BlobNotFound');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
describe('.del()', () => {
|
|
81
|
+
test('can delete an existing blob', async () => {
|
|
82
|
+
const blob = b('hello world');
|
|
83
|
+
const { cas } = setup();
|
|
84
|
+
const hash = await cas.put(blob);
|
|
85
|
+
const info = await cas.info(hash);
|
|
86
|
+
await cas.del(hash);
|
|
87
|
+
const [, err] = await (0, thingies_1.of)(cas.info(hash));
|
|
88
|
+
expect(err).toBeInstanceOf(DOMException);
|
|
89
|
+
expect(err.name).toBe('BlobNotFound');
|
|
90
|
+
});
|
|
91
|
+
test('throws if blob does not exist', async () => {
|
|
92
|
+
const blob = b('hello world 2');
|
|
93
|
+
const { cas } = setup();
|
|
94
|
+
const hash = await cas.put(blob);
|
|
95
|
+
const [, err] = await (0, thingies_1.of)(cas.del('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'));
|
|
96
|
+
expect(err).toBeInstanceOf(DOMException);
|
|
97
|
+
expect(err.name).toBe('BlobNotFound');
|
|
98
|
+
});
|
|
99
|
+
test('does not throw if "silent" flag is provided', async () => {
|
|
100
|
+
const blob = b('hello world 2');
|
|
101
|
+
const { cas } = setup();
|
|
102
|
+
const hash = await cas.put(blob);
|
|
103
|
+
await cas.del('2aae6c35c94fcfb415dbe95f408b9ce91ee846ed', true);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
exports.testCasfs = testCasfs;
|
|
108
|
+
//# sourceMappingURL=testCasfs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testCasfs.js","sourceRoot":"","sources":["../../../src/crud-to-cas/__tests__/testCasfs.ts"],"names":[],"mappings":";;;AAAA,uCAA8B;AAC9B,mCAAoC;AACpC,kCAAyC;AAIlC,MAAM,IAAI,GAAG,KAAK,EAAE,IAAgB,EAAmB,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,MAA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CAAC,CAAC;QAEH,IAAI,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;YAChC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,MAAM,IAAA,aAAE,EAAC,GAAG,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC,CAAC;YAC9E,MAAM,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;YACzC,MAAM,CAAO,GAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,IAAI,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC;YAChC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,GAAG,CAAC,GAAG,CAAC,0CAA0C,EAAE,IAAI,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlGW,QAAA,SAAS,aAkGpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CrudCas, CrudCasOptions } from './CrudCas';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudCas = void 0;
|
|
4
|
+
var CrudCas_1 = require("./CrudCas");
|
|
5
|
+
Object.defineProperty(exports, "CrudCas", { enumerable: true, get: function () { return CrudCas_1.CrudCas; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/crud-to-cas/index.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAA3C,kGAAA,OAAO,OAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashToLocation = void 0;
|
|
4
|
+
const hashToLocation = (hash) => {
|
|
5
|
+
if (hash.length < 20)
|
|
6
|
+
throw new TypeError('Hash is too short');
|
|
7
|
+
const lastTwo = hash.slice(-2);
|
|
8
|
+
const twoBeforeLastTwo = hash.slice(-4, -2);
|
|
9
|
+
const folder = [lastTwo, twoBeforeLastTwo];
|
|
10
|
+
return [folder, hash];
|
|
11
|
+
};
|
|
12
|
+
exports.hashToLocation = hashToLocation;
|
|
13
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/crud-to-cas/util.ts"],"names":[],"mappings":";;;AAEO,MAAM,cAAc,GAAG,CAAC,IAAY,EAAc,EAAE;IACzD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC3C,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB"}
|
package/lib/encoding.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,4CAA4C;AAK/B,QAAA,aAAa,GAAmB,MAAM,CAAC;AAEpD,SAAgB,cAAc,CAAC,QAA4B;IACzD,IAAI,QAAQ,IAAI,CAAC,eAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAC;AACvH,CAAC;AAFD,wCAEC;AAED,SAAgB,aAAa,CAAC,GAAW,EAAE,QAA4B;IACrE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,qBAAa;QAAE,OAAO,GAAG,CAAC,CAAC,QAAQ;IACjE,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC,CAAC,oBAAoB;IACvE,OAAO,IAAI,eAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB;AAC/D,CAAC;AAJD,sCAIC"}
|
package/lib/fsa/types.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fsa/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as crud from '../crud/types';
|
|
2
|
+
import type * as fsa from '../fsa/types';
|
|
3
|
+
export declare class FsaCrud implements crud.CrudApi {
|
|
4
|
+
protected readonly root: fsa.IFileSystemDirectoryHandle | Promise<fsa.IFileSystemDirectoryHandle>;
|
|
5
|
+
constructor(root: fsa.IFileSystemDirectoryHandle | Promise<fsa.IFileSystemDirectoryHandle>);
|
|
6
|
+
protected getDir(collection: crud.CrudCollection, create: boolean): Promise<[dir: fsa.IFileSystemDirectoryHandle, parent: fsa.IFileSystemDirectoryHandle | undefined]>;
|
|
7
|
+
protected getFile(collection: crud.CrudCollection, id: string): Promise<[dir: fsa.IFileSystemDirectoryHandle, file: fsa.IFileSystemFileHandle]>;
|
|
8
|
+
readonly put: (collection: crud.CrudCollection, id: string, data: Uint8Array, options?: crud.CrudPutOptions) => Promise<void>;
|
|
9
|
+
readonly get: (collection: crud.CrudCollection, id: string) => Promise<Uint8Array>;
|
|
10
|
+
readonly del: (collection: crud.CrudCollection, id: string, silent?: boolean) => Promise<void>;
|
|
11
|
+
readonly info: (collection: crud.CrudCollection, id?: string) => Promise<crud.CrudResourceInfo>;
|
|
12
|
+
readonly drop: (collection: crud.CrudCollection, silent?: boolean) => Promise<void>;
|
|
13
|
+
readonly list: (collection: crud.CrudCollection) => Promise<crud.CrudCollectionEntry[]>;
|
|
14
|
+
readonly from: (collection: crud.CrudCollection) => Promise<crud.CrudApi>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FsaCrud = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const util_1 = require("../node-to-fsa/util");
|
|
6
|
+
const util_2 = require("../crud/util");
|
|
7
|
+
const util_3 = require("./util");
|
|
8
|
+
class FsaCrud {
|
|
9
|
+
constructor(root) {
|
|
10
|
+
this.root = root;
|
|
11
|
+
this.put = async (collection, id, data, options) => {
|
|
12
|
+
(0, util_2.assertType)(collection, 'put', 'crudfs');
|
|
13
|
+
(0, util_1.assertName)(id, 'put', 'crudfs');
|
|
14
|
+
const [dir] = await this.getDir(collection, true);
|
|
15
|
+
let file;
|
|
16
|
+
switch (options === null || options === void 0 ? void 0 : options.throwIf) {
|
|
17
|
+
case 'exists': {
|
|
18
|
+
try {
|
|
19
|
+
file = await dir.getFileHandle(id, { create: false });
|
|
20
|
+
throw (0, util_3.newExistsError)();
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
if (e.name !== 'NotFoundError')
|
|
24
|
+
throw e;
|
|
25
|
+
file = await dir.getFileHandle(id, { create: true });
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case 'missing': {
|
|
30
|
+
try {
|
|
31
|
+
file = await dir.getFileHandle(id, { create: false });
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
if (e.name === 'NotFoundError')
|
|
35
|
+
throw (0, util_3.newMissingError)();
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
file = await dir.getFileHandle(id, { create: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const writable = await file.createWritable();
|
|
45
|
+
await writable.write(data);
|
|
46
|
+
await writable.close();
|
|
47
|
+
};
|
|
48
|
+
this.get = async (collection, id) => {
|
|
49
|
+
(0, util_2.assertType)(collection, 'get', 'crudfs');
|
|
50
|
+
(0, util_1.assertName)(id, 'get', 'crudfs');
|
|
51
|
+
const [, file] = await this.getFile(collection, id);
|
|
52
|
+
const blob = await file.getFile();
|
|
53
|
+
const buffer = await blob.arrayBuffer();
|
|
54
|
+
return new Uint8Array(buffer);
|
|
55
|
+
};
|
|
56
|
+
this.del = async (collection, id, silent) => {
|
|
57
|
+
(0, util_2.assertType)(collection, 'del', 'crudfs');
|
|
58
|
+
(0, util_1.assertName)(id, 'del', 'crudfs');
|
|
59
|
+
try {
|
|
60
|
+
const [dir] = await this.getFile(collection, id);
|
|
61
|
+
await dir.removeEntry(id, { recursive: false });
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (!silent)
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
this.info = async (collection, id) => {
|
|
69
|
+
(0, util_2.assertType)(collection, 'info', 'crudfs');
|
|
70
|
+
if (id) {
|
|
71
|
+
(0, util_1.assertName)(id, 'info', 'crudfs');
|
|
72
|
+
const [, file] = await this.getFile(collection, id);
|
|
73
|
+
const blob = await file.getFile();
|
|
74
|
+
return {
|
|
75
|
+
type: 'resource',
|
|
76
|
+
id,
|
|
77
|
+
size: blob.size,
|
|
78
|
+
modified: blob.lastModified,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
await this.getDir(collection, false);
|
|
83
|
+
return {
|
|
84
|
+
type: 'collection',
|
|
85
|
+
id: '',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.drop = async (collection, silent) => {
|
|
90
|
+
var _a, e_1, _b, _c;
|
|
91
|
+
(0, util_2.assertType)(collection, 'drop', 'crudfs');
|
|
92
|
+
try {
|
|
93
|
+
const [dir, parent] = await this.getDir(collection, false);
|
|
94
|
+
if (parent) {
|
|
95
|
+
await parent.removeEntry(dir.name, { recursive: true });
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const root = await this.root;
|
|
99
|
+
try {
|
|
100
|
+
for (var _d = true, _e = tslib_1.__asyncValues(root.keys()), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
|
101
|
+
_c = _f.value;
|
|
102
|
+
_d = false;
|
|
103
|
+
const name = _c;
|
|
104
|
+
await root.removeEntry(name, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
108
|
+
finally {
|
|
109
|
+
try {
|
|
110
|
+
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
|
111
|
+
}
|
|
112
|
+
finally { if (e_1) throw e_1.error; }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (!silent)
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
this.list = async (collection) => {
|
|
122
|
+
var _a, e_2, _b, _c;
|
|
123
|
+
(0, util_2.assertType)(collection, 'drop', 'crudfs');
|
|
124
|
+
const [dir] = await this.getDir(collection, false);
|
|
125
|
+
const entries = [];
|
|
126
|
+
try {
|
|
127
|
+
for (var _d = true, _e = tslib_1.__asyncValues(dir.entries()), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
|
|
128
|
+
_c = _f.value;
|
|
129
|
+
_d = false;
|
|
130
|
+
const [id, handle] = _c;
|
|
131
|
+
if (handle.kind === 'file') {
|
|
132
|
+
entries.push({
|
|
133
|
+
type: 'resource',
|
|
134
|
+
id,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else if (handle.kind === 'directory') {
|
|
138
|
+
entries.push({
|
|
139
|
+
type: 'collection',
|
|
140
|
+
id,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
146
|
+
finally {
|
|
147
|
+
try {
|
|
148
|
+
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
|
149
|
+
}
|
|
150
|
+
finally { if (e_2) throw e_2.error; }
|
|
151
|
+
}
|
|
152
|
+
return entries;
|
|
153
|
+
};
|
|
154
|
+
this.from = async (collection) => {
|
|
155
|
+
(0, util_2.assertType)(collection, 'from', 'crudfs');
|
|
156
|
+
const [dir] = await this.getDir(collection, true);
|
|
157
|
+
return new FsaCrud(dir);
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async getDir(collection, create) {
|
|
161
|
+
let parent = undefined;
|
|
162
|
+
let dir = await this.root;
|
|
163
|
+
try {
|
|
164
|
+
for (const name of collection) {
|
|
165
|
+
const child = await dir.getDirectoryHandle(name, { create });
|
|
166
|
+
parent = dir;
|
|
167
|
+
dir = child;
|
|
168
|
+
}
|
|
169
|
+
return [dir, parent];
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (error.name === 'NotFoundError')
|
|
173
|
+
throw (0, util_3.newFolder404Error)(collection);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async getFile(collection, id) {
|
|
178
|
+
const [dir] = await this.getDir(collection, false);
|
|
179
|
+
try {
|
|
180
|
+
const file = await dir.getFileHandle(id, { create: false });
|
|
181
|
+
return [dir, file];
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (error.name === 'NotFoundError')
|
|
185
|
+
throw (0, util_3.newFile404Error)(collection, id);
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.FsaCrud = FsaCrud;
|
|
191
|
+
//# sourceMappingURL=FsaCrud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FsaCrud.js","sourceRoot":"","sources":["../../src/fsa-to-crud/FsaCrud.ts"],"names":[],"mappings":";;;;AAEA,8CAAiD;AACjD,uCAA0C;AAC1C,iCAA6F;AAE7F,MAAa,OAAO;IAClB,YACqB,IAA8E;QAA9E,SAAI,GAAJ,IAAI,CAA0E;QAoCnF,QAAG,GAAG,KAAK,EACzB,UAA+B,EAC/B,EAAU,EACV,IAAgB,EAChB,OAA6B,EACd,EAAE;YACjB,IAAA,iBAAU,EAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YACxC,IAAA,iBAAU,EAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,IAA2C,CAAC;YAChD,QAAQ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,EAAE;gBACxB,KAAK,QAAQ,CAAC,CAAC;oBACb,IAAI;wBACF,IAAI,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;wBACtD,MAAM,IAAA,qBAAc,GAAE,CAAC;qBACxB;oBAAC,OAAO,CAAC,EAAE;wBACV,IAAI,CAAC,CA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