@ocfl/ocfl 0.4.0 → 1.0.0-beta.1
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/LICENSE +674 -0
- package/README.md +24 -9
- package/dist/constants.d.ts +15 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +14 -0
- package/dist/constants.js.map +1 -0
- package/dist/digest.d.ts +58 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +204 -0
- package/dist/digest.js.map +1 -0
- package/dist/error.d.ts +5 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +9 -0
- package/dist/error.js.map +1 -0
- package/dist/extension.d.ts +83 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +170 -0
- package/dist/extension.js.map +1 -0
- package/dist/extensions/0002-flat-direct-storage-layout.d.ts +12 -0
- package/dist/extensions/0002-flat-direct-storage-layout.d.ts.map +1 -0
- package/dist/extensions/0002-flat-direct-storage-layout.js +34 -0
- package/dist/extensions/0002-flat-direct-storage-layout.js.map +1 -0
- package/dist/extensions/0003-hash-and-id-n-tuple-storage-layout.d.ts +15 -0
- package/dist/extensions/0003-hash-and-id-n-tuple-storage-layout.d.ts.map +1 -0
- package/dist/extensions/0003-hash-and-id-n-tuple-storage-layout.js +49 -0
- package/dist/extensions/0003-hash-and-id-n-tuple-storage-layout.js.map +1 -0
- package/dist/extensions/0004-hashed-n-tuple-storage-layout.d.ts +17 -0
- package/dist/extensions/0004-hashed-n-tuple-storage-layout.d.ts.map +1 -0
- package/dist/extensions/0004-hashed-n-tuple-storage-layout.js +54 -0
- package/dist/extensions/0004-hashed-n-tuple-storage-layout.js.map +1 -0
- package/dist/extensions/0006-flat-omit-prefix-storage-layout.d.ts +6 -0
- package/dist/extensions/0006-flat-omit-prefix-storage-layout.d.ts.map +1 -0
- package/dist/extensions/0006-flat-omit-prefix-storage-layout.js +8 -0
- package/dist/extensions/0006-flat-omit-prefix-storage-layout.js.map +1 -0
- package/dist/extensions/0007-n-tuple-omit-prefix-storage-layout.d.ts +6 -0
- package/dist/extensions/0007-n-tuple-omit-prefix-storage-layout.d.ts.map +1 -0
- package/dist/extensions/0007-n-tuple-omit-prefix-storage-layout.js +8 -0
- package/dist/extensions/0007-n-tuple-omit-prefix-storage-layout.js.map +1 -0
- package/dist/extensions/0009-digest-algorithms.d.ts +9 -0
- package/dist/extensions/0009-digest-algorithms.d.ts.map +1 -0
- package/dist/extensions/0009-digest-algorithms.js +11 -0
- package/dist/extensions/0009-digest-algorithms.js.map +1 -0
- package/dist/extensions/000N-path-direct-storage-layout.d.ts +16 -0
- package/dist/extensions/000N-path-direct-storage-layout.d.ts.map +1 -0
- package/dist/extensions/000N-path-direct-storage-layout.js +46 -0
- package/dist/extensions/000N-path-direct-storage-layout.js.map +1 -0
- package/dist/extensions/index.d.ts +23 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/index.js +8 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/file.d.ts +87 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +118 -0
- package/dist/file.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +155 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +591 -0
- package/dist/inventory.js.map +1 -0
- package/dist/object.d.ts +188 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +425 -0
- package/dist/object.js.map +1 -0
- package/dist/storage.d.ts +94 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +302 -0
- package/dist/storage.js.map +1 -0
- package/dist/store.d.ts +100 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +157 -0
- package/dist/store.js.map +1 -0
- package/dist/transaction.d.ts +155 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +395 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.d.ts +107 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +24 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +85 -0
- package/dist/utils.js.map +1 -0
- package/dist/validation.d.ts +32 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +31 -0
- package/dist/validation.js.map +1 -0
- package/package.json +31 -51
- package/src/constants.ts +16 -0
- package/src/digest.ts +258 -0
- package/src/error.ts +9 -0
- package/src/extension.ts +206 -0
- package/{lib/extensions/0002-flat-direct-storage-layout.js → src/extensions/0002-flat-direct-storage-layout.ts} +15 -22
- package/src/extensions/0003-hash-and-id-n-tuple-storage-layout.ts +56 -0
- package/src/extensions/0004-hashed-n-tuple-storage-layout.ts +59 -0
- package/src/extensions/0006-flat-omit-prefix-storage-layout.ts +9 -0
- package/src/extensions/0007-n-tuple-omit-prefix-storage-layout.ts +9 -0
- package/src/extensions/0009-digest-algorithms.ts +12 -0
- package/src/extensions/000N-path-direct-storage-layout.ts +51 -0
- package/src/extensions/index.ts +24 -0
- package/src/file.ts +161 -0
- package/src/index.ts +92 -0
- package/src/inventory.ts +634 -0
- package/src/object.ts +473 -0
- package/src/storage.ts +342 -0
- package/src/store.ts +199 -0
- package/src/transaction.ts +456 -0
- package/{lib/types.d.ts → src/types.ts} +28 -74
- package/src/utils.ts +94 -0
- package/src/validation.ts +46 -0
- package/index.js +0 -129
- package/index.mjs +0 -18
- package/lib/constants.js +0 -24
- package/lib/digest.js +0 -307
- package/lib/enum.js +0 -90
- package/lib/error.js +0 -19
- package/lib/extension.js +0 -194
- package/lib/extensions/0003-hash-and-id-n-tuple-storage-layout.js +0 -60
- package/lib/extensions/0004-hashed-n-tuple-storage-layout.js +0 -63
- package/lib/extensions/0005-mutable-head.js +0 -0
- package/lib/extensions/0006-flat-omit-prefix-storage-layout.js +0 -7
- package/lib/extensions/0007-n-tuple-omit-prefix-storage-layout.js +0 -7
- package/lib/extensions/0008-schema-registry.js +0 -0
- package/lib/extensions/0009-digest-algorithms.js +0 -18
- package/lib/extensions/000N-path-direct-storage-layout.js +0 -61
- package/lib/extensions/index.js +0 -13
- package/lib/file.js +0 -147
- package/lib/index.js +0 -13
- package/lib/inventory.js +0 -564
- package/lib/object.js +0 -499
- package/lib/storage.js +0 -338
- package/lib/store.js +0 -191
- package/lib/transaction.js +0 -448
- package/lib/utils.js +0 -122
- package/lib/validation.js +0 -174
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ContentAlgorithm } from './digest.ts';
|
|
2
|
+
export interface InventoryDigests {
|
|
3
|
+
[key: string]: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface InventoryVersion {
|
|
6
|
+
created: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
state: InventoryDigests;
|
|
9
|
+
user?: {
|
|
10
|
+
name: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface Inventory {
|
|
15
|
+
/** A unique identifier for the OCFL Object. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The URI of the inventory section of the specification version matching the object conformance declaration. */
|
|
18
|
+
type: 'https://ocfl.io/1.0/spec/#inventory' | 'https://ocfl.io/1.1/spec/#inventory';
|
|
19
|
+
/**
|
|
20
|
+
* The algorithm used for calculating digests for content-addressing
|
|
21
|
+
* within the OCFL Object and for the Inventory Digest.
|
|
22
|
+
* This MUST be the algorithm used in the manifest and state blocks
|
|
23
|
+
*/
|
|
24
|
+
digestAlgorithm: ContentAlgorithm;
|
|
25
|
+
/** The version directory name of the most recent version of the object. */
|
|
26
|
+
head: string;
|
|
27
|
+
manifest: InventoryDigests;
|
|
28
|
+
versions: {
|
|
29
|
+
[key: string]: InventoryVersion;
|
|
30
|
+
};
|
|
31
|
+
fixity?: {
|
|
32
|
+
[key: string]: {
|
|
33
|
+
[key: string]: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The name of the designated content directory within the version directories.
|
|
38
|
+
* @default content
|
|
39
|
+
*/
|
|
40
|
+
contentDirectory?: string;
|
|
41
|
+
}
|
|
42
|
+
export type IDataType = string | ArrayBufferLike | Uint8Array | Uint16Array | Uint32Array;
|
|
43
|
+
export interface CommonHasher {
|
|
44
|
+
init: () => CommonHasher;
|
|
45
|
+
update: (data: IDataType) => CommonHasher;
|
|
46
|
+
digest: {
|
|
47
|
+
(outputType: 'binary'): Uint8Array;
|
|
48
|
+
(outputType?: 'hex'): string;
|
|
49
|
+
};
|
|
50
|
+
digestSize: number;
|
|
51
|
+
}
|
|
52
|
+
export interface MultiHasher {
|
|
53
|
+
multi: true;
|
|
54
|
+
update: (data: IDataType) => MultiHasher;
|
|
55
|
+
digest: {
|
|
56
|
+
(outputType: 'binary'): {
|
|
57
|
+
[key: string]: Uint8Array;
|
|
58
|
+
};
|
|
59
|
+
(outputType?: 'hex'): {
|
|
60
|
+
[key: string]: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type OcflVersion = '1.0' | '1.1';
|
|
65
|
+
export type OcflExtensionConfig = {
|
|
66
|
+
extensionName?: string;
|
|
67
|
+
[key: string]: unknown;
|
|
68
|
+
};
|
|
69
|
+
type OcflStorageLayout = import('./extension.ts').OcflStorageLayout;
|
|
70
|
+
/** Configuration options for an OCFL Object. */
|
|
71
|
+
export type OcflStorageConfig = {
|
|
72
|
+
/** Absolute path to the ocfl storage root. */
|
|
73
|
+
root: string;
|
|
74
|
+
/** Absolute path to storage workspace directory. */
|
|
75
|
+
workspace?: string | undefined;
|
|
76
|
+
/** A layout that identifies an arrangement of directories and OCFL objects under the storage root */
|
|
77
|
+
layout?: OcflStorageLayout | OcflExtensionConfig | string | undefined;
|
|
78
|
+
/** A default list of digest algorithm names to be added to the fixity block of objects under this storage. */
|
|
79
|
+
fixityAlgorithms?: string[] | undefined;
|
|
80
|
+
/** Digest algorithm for content-addressing, must use either sha512 or sha256. Defaults to 'sha512'. */
|
|
81
|
+
digestAlgorithm?: ContentAlgorithm | undefined;
|
|
82
|
+
/** Content directory name. Only applies to a newly created object. @defaultValue `"content"` */
|
|
83
|
+
contentDirectory?: string | undefined;
|
|
84
|
+
/** Ocfl version. Only applies to a newly created object. @defaultValue {@link OcflConstants.OCFL_VERSION} */
|
|
85
|
+
ocflVersion?: OcflVersion | undefined;
|
|
86
|
+
};
|
|
87
|
+
/** Configuration options for an OCFL Object. */
|
|
88
|
+
export type OcflObjectConfig = {
|
|
89
|
+
/** Absolute path to the ocfl object root. */
|
|
90
|
+
root: string;
|
|
91
|
+
/** Absolute path to object workspace directory. */
|
|
92
|
+
workspace?: string | undefined;
|
|
93
|
+
/** Identifier for the object. Only be used in a newly created object. */
|
|
94
|
+
id?: string | undefined;
|
|
95
|
+
/** Reference to existing extensions defined outside of the object, such as in the storage root. */
|
|
96
|
+
extensions?: import('./extension.ts').OcflExtension[] | undefined;
|
|
97
|
+
/** Additional digest algorithms to be calculated for each file and added to the fixity block. */
|
|
98
|
+
fixityAlgorithms?: string[] | undefined;
|
|
99
|
+
/** Digest algorithm for content-addressing, must use either sha512 or sha256. Defaults to 'sha512'. */
|
|
100
|
+
digestAlgorithm?: ContentAlgorithm | undefined;
|
|
101
|
+
/** Content directory name. Only applies to a newly created object. @defaultValue `"content"` */
|
|
102
|
+
contentDirectory?: string | undefined;
|
|
103
|
+
/** Ocfl version. Only applies to a newly created object. @defaultValue {@link OcflConstants.OCFL_VERSION} */
|
|
104
|
+
ocflVersion?: OcflVersion | undefined;
|
|
105
|
+
};
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,gB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AG,SAAS,CAAC;IAC/B,0EAA0E;IAC1E,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,mGAAmG;IACnG,UAAU,CAAC,EAAE,OAAO,gBAAgB,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IAClE,iGAAiG;IACjG,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,uGAAuG;IACvG,eAAe,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAC/C,gGAAgG;IAChG,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,6GAA6G;IAC7G,WAAW,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACvC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { OcflStore } from './store.ts';
|
|
2
|
+
import type { OcflVersion } from './types.ts';
|
|
3
|
+
declare function isErrnoException(error: unknown): error is NodeJS.ErrnoException;
|
|
4
|
+
/**
|
|
5
|
+
* Run `asyncFn` over every element of `inputStack` with at most `count` calls in flight.
|
|
6
|
+
* Rejections are returned in the result array rather than thrown.
|
|
7
|
+
* @param inputStack - Consumed during the process.
|
|
8
|
+
* @param count - Maximum number of concurrency
|
|
9
|
+
*/
|
|
10
|
+
declare function parallelize<T, R>(inputStack: T[], asyncFn: (input: T) => Promise<R>, count?: number): Promise<(R | Error)[]>;
|
|
11
|
+
declare function isDirEmpty(store: OcflStore, dirPath: string): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if there is any valid namaste in the rootPath and return the version number.
|
|
14
|
+
* @returns The version, `''` if a namaste exists but is invalid, or `undefined` if there is none.
|
|
15
|
+
*/
|
|
16
|
+
declare function findNamasteVersion(store: OcflStore, prefix: string, rootPath: string): Promise<OcflVersion | '' | undefined>;
|
|
17
|
+
type TypedArray = ArrayLike<number> & {
|
|
18
|
+
buffer: ArrayBufferLike;
|
|
19
|
+
byteLength: number;
|
|
20
|
+
set(array: ArrayLike<number>, offset?: number): void;
|
|
21
|
+
};
|
|
22
|
+
declare function joinTypedArray(target: ArrayBuffer | TypedArray, source: ArrayBuffer | TypedArray): TypedArray;
|
|
23
|
+
export { findNamasteVersion, isDirEmpty, isErrnoException, joinTypedArray, parallelize };
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAI9C,iBAAS,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,cAAc,CAExE;AAED;;;;;GAKG;AACH,iBAAe,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAqBvH;AAED,iBAAe,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU7E;AAED;;;GAGG;AACH,iBAAe,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,EAAE,GAAG,SAAS,CAAC,CAc3H;AAED,KAAK,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG;IAAE,MAAM,EAAE,eAAe,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAM5I,iBAAS,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,CActG;AAED,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { OcflConstants } from './constants.js';
|
|
2
|
+
const { OCFL_VERSIONS, NAMASTE_T } = OcflConstants;
|
|
3
|
+
function isErrnoException(error) {
|
|
4
|
+
return error instanceof Error && 'code' in error;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Run `asyncFn` over every element of `inputStack` with at most `count` calls in flight.
|
|
8
|
+
* Rejections are returned in the result array rather than thrown.
|
|
9
|
+
* @param inputStack - Consumed during the process.
|
|
10
|
+
* @param count - Maximum number of concurrency
|
|
11
|
+
*/
|
|
12
|
+
async function parallelize(inputStack, asyncFn, count = 10) {
|
|
13
|
+
const promises = [];
|
|
14
|
+
let len = Math.min(inputStack.length, count);
|
|
15
|
+
const result = [];
|
|
16
|
+
while (len--) {
|
|
17
|
+
promises.push((async () => {
|
|
18
|
+
while (inputStack.length) {
|
|
19
|
+
const input = inputStack.pop();
|
|
20
|
+
const index = inputStack.length;
|
|
21
|
+
try {
|
|
22
|
+
result[index] = await asyncFn(input);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
result[index] = error instanceof Error ? error : new Error(String(error), { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
})().catch(() => { }));
|
|
29
|
+
}
|
|
30
|
+
await Promise.all(promises);
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
async function isDirEmpty(store, dirPath) {
|
|
34
|
+
let de;
|
|
35
|
+
try {
|
|
36
|
+
const dir = await store.opendir(dirPath);
|
|
37
|
+
de = await dir.read();
|
|
38
|
+
await dir.close();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return isErrnoException(error) && error.code === 'ENOENT';
|
|
42
|
+
}
|
|
43
|
+
return !de;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if there is any valid namaste in the rootPath and return the version number.
|
|
47
|
+
* @returns The version, `''` if a namaste exists but is invalid, or `undefined` if there is none.
|
|
48
|
+
*/
|
|
49
|
+
async function findNamasteVersion(store, prefix, rootPath) {
|
|
50
|
+
const namastePath = `${rootPath}/${NAMASTE_T}${prefix}`;
|
|
51
|
+
let version;
|
|
52
|
+
try {
|
|
53
|
+
version = await Promise.any(OCFL_VERSIONS.map(async (v) => ((await store.readFile(namastePath + v, 'utf8')) === `${prefix}${v}\n` ? v : null)));
|
|
54
|
+
if (!version) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (!(error instanceof AggregateError) || error.errors.some((e) => !isErrnoException(e) || e.code !== 'ENOENT')) {
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return version ?? undefined;
|
|
64
|
+
}
|
|
65
|
+
function isTypedArray(obj) {
|
|
66
|
+
return ArrayBuffer.isView(obj) && !(obj instanceof DataView);
|
|
67
|
+
}
|
|
68
|
+
function joinTypedArray(target, source) {
|
|
69
|
+
const sourceArray = isTypedArray(source) ? source : new Uint8Array(source);
|
|
70
|
+
const [targetBuffer, targetArray] = isTypedArray(target) ? [target.buffer, target] : [target, new Uint8Array(target)];
|
|
71
|
+
const targetLength = targetArray.byteLength;
|
|
72
|
+
const totalSize = targetLength + sourceArray.byteLength;
|
|
73
|
+
let mergedArray = targetArray;
|
|
74
|
+
if (targetBuffer.resizable && targetBuffer.maxByteLength >= totalSize) {
|
|
75
|
+
targetBuffer.resize(totalSize);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
mergedArray = new Uint8Array(totalSize);
|
|
79
|
+
mergedArray.set(targetArray, 0);
|
|
80
|
+
}
|
|
81
|
+
mergedArray.set(sourceArray, targetLength);
|
|
82
|
+
return mergedArray;
|
|
83
|
+
}
|
|
84
|
+
export { findNamasteVersion, isDirEmpty, isErrnoException, joinTypedArray, parallelize };
|
|
85
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;AAEnD,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,WAAW,CAAO,UAAe,EAAE,OAAiC,EAAE,KAAK,GAAG,EAAE;IAC7F,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,OAAO,GAAG,EAAE,EAAE,CAAC;QACb,QAAQ,CAAC,IAAI,CACX,CAAC,KAAK,IAAI,EAAE;YACV,OAAO,UAAU,CAAC,MAAM,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAO,CAAC;gBACpC,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC;gBAChC,IAAI,CAAC;oBACH,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;gBACvC,CAA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AC,SAAS,IAAI,YAAY,CAAC,aAAa,IAAI,SAAS,EAAE,CAAC;QACtE,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC;QACxC,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IACD,WAAW,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAC3C,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare const ERRORS: {
|
|
2
|
+
E007: string;
|
|
3
|
+
E036: string;
|
|
4
|
+
E040: string;
|
|
5
|
+
E050: string;
|
|
6
|
+
E060: string;
|
|
7
|
+
E069: string;
|
|
8
|
+
E080: string;
|
|
9
|
+
E082: string;
|
|
10
|
+
};
|
|
11
|
+
type ErrorCode = keyof typeof ERRORS;
|
|
12
|
+
interface ValidationErrorOptions {
|
|
13
|
+
code: ErrorCode;
|
|
14
|
+
description: string;
|
|
15
|
+
path: string;
|
|
16
|
+
detail?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
declare class ValidationError extends Error {
|
|
19
|
+
code: ErrorCode;
|
|
20
|
+
description: string;
|
|
21
|
+
path: string;
|
|
22
|
+
detail?: string | undefined;
|
|
23
|
+
constructor(options: ValidationErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @param code - OCFL validation code, eg 'E060'
|
|
27
|
+
* @param path - Path the problem was found at
|
|
28
|
+
* @param detail - Extra context appended to the message
|
|
29
|
+
*/
|
|
30
|
+
export declare const createError: (code: ErrorCode, path: string, detail?: string) => ValidationError;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM;IACV,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACL,CAAC;AAEF,KAAK,SAAS,GAAG,MAAM,OAAO,MAAM,CAAC;AAErC,UAAU,sBAAsB;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,cAAM,eAAgB,SAAQ,KAAK;IACzB,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC,YAAY,OAAO,EAAE,sBAAsB,EAI1C;CACF;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,SAAS,QAAQ,MAAM,WAAW,MAAM,oBAMzE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Messages for the OCFL 1.1 validation codes this library raises: https://ocfl.io/1.1/spec/validation-codes.html
|
|
2
|
+
const ERRORS = {
|
|
3
|
+
E007: 'The text contents of the [version declaration] file must be the same as dvalue, followed by a newline (\\n).',
|
|
4
|
+
E036: 'An OCFL Object Inventory MUST include the following keys: [id, type, digestAlgorithm, head].',
|
|
5
|
+
E040: '[head] MUST be the version directory name with the highest version number.',
|
|
6
|
+
E050: 'The keys of [the state JSON object] are digest values, each of which MUST correspond to an entry in the manifest of the inventory.',
|
|
7
|
+
E060: 'The digest sidecar file must contain the digest of the inventory file.',
|
|
8
|
+
E069: 'An OCFL Storage Root MUST contain a Root Conformance Declaration identifying it as such.',
|
|
9
|
+
E080: 'The text contents of [the OCFL version declaration file] MUST be the same as dvalue, followed by a newline (\\n).',
|
|
10
|
+
E082: 'OCFL Object Roots MUST be stored either as the terminal resource at the end of a directory storage hierarchy or as direct children of a containing OCFL Storage Root.',
|
|
11
|
+
};
|
|
12
|
+
class ValidationError extends Error {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
super(`${options.code}: ${options.description} At ${options.path}${options.detail ? ` (${options.detail})` : ''}`);
|
|
15
|
+
this.name = 'ValidationError';
|
|
16
|
+
Object.assign(this, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @param code - OCFL validation code, eg 'E060'
|
|
21
|
+
* @param path - Path the problem was found at
|
|
22
|
+
* @param detail - Extra context appended to the message
|
|
23
|
+
*/
|
|
24
|
+
export const createError = (code, path, detail) => {
|
|
25
|
+
const description = Object.hasOwn(ERRORS, code) ? ERRORS[code] : undefined;
|
|
26
|
+
if (!description) {
|
|
27
|
+
throw new RangeError(`Unknown OCFL validation code ${code}`);
|
|
28
|
+
}
|
|
29
|
+
return new ValidationError({ code, description, path, detail });
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,iHAAiH;AACjH,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,8GAA8G;IACpH,IAAI,EAAE,8FAA8F;IACpG,IAAI,EAAE,4EAA4E;IAClF,IAAI,EAAE,oIAAoI;IAC1I,IAAI,EAAE,wEAAwE;IAC9E,IAAI,EAAE,0FAA0F;IAChG,IAAI,EAAE,mHAAmH;IACzH,IAAI,EAAE,uKAAuK;CAC9K,CAAC;AAWF,MAAM,eAAgB,SAAQ,KAAK;IAMjC,YAAY,OAA+B;QACzC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,WAAW,OAAO,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnH,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAe,EAAE,IAAY,EAAE,MAAe,EAAE,EAAE;IAC5E,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,UAAU,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,74 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocfl/ocfl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "Oxford Common File Layout (OCFL) JS library",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": [
|
|
8
|
-
{
|
|
9
|
-
"import": "./index.mjs",
|
|
10
|
-
"require": "./index.js",
|
|
11
|
-
"default": "./index.js"
|
|
12
|
-
},
|
|
13
|
-
"./index.js"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"test": "mocha",
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"build-docs": "typedoc --plugin typedoc-plugin-missing-exports"
|
|
20
|
-
},
|
|
21
5
|
"keywords": [
|
|
22
6
|
"ocfl",
|
|
23
7
|
"Oxford Common File Layout",
|
|
24
8
|
"preservation",
|
|
25
9
|
"storage"
|
|
26
10
|
],
|
|
11
|
+
"homepage": "https://github.com/Language-Research-Technology/ocfl-js#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Language-Research-Technology/ocfl-js/issues"
|
|
14
|
+
},
|
|
27
15
|
"repository": {
|
|
28
16
|
"type": "git",
|
|
29
|
-
"url": "
|
|
17
|
+
"url": "https://github.com/Language-Research-Technology/ocfl-js",
|
|
18
|
+
"directory": "ocfl"
|
|
30
19
|
},
|
|
20
|
+
"license": "GPL-3.0-or-later",
|
|
31
21
|
"author": "Alvin Sebastian (https://orcid.org/0000-0002-9086-1722)",
|
|
32
22
|
"contributors": [
|
|
33
23
|
"Moises Sacal Bonequi (https://orcid.org/0000-0002-4438-2755)",
|
|
34
24
|
"Peter Sefton (https://orcid.org/0000-0002-3545-944X)"
|
|
35
25
|
],
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"@types/mocha": "^10.0.10",
|
|
43
|
-
"@types/node": "^24.12.2",
|
|
44
|
-
"memfs": "^4.50.0",
|
|
45
|
-
"mocha": "^11.7.5",
|
|
46
|
-
"typedoc": "^0.28.19",
|
|
47
|
-
"typedoc-plugin-missing-exports": "^4.1.2"
|
|
48
|
-
},
|
|
49
|
-
"mocha": {
|
|
50
|
-
"extension": [
|
|
51
|
-
".spec.js",
|
|
52
|
-
".spec.cjs",
|
|
53
|
-
".spec.mjs"
|
|
54
|
-
],
|
|
55
|
-
"recursive": true
|
|
56
|
-
},
|
|
57
|
-
"bugs": {
|
|
58
|
-
"url": "https://github.com/Language-Research-Technology/ocfl-js/issues"
|
|
59
|
-
},
|
|
60
|
-
"homepage": "https://github.com/Language-Research-Technology/ocfl-js#readme",
|
|
61
|
-
"directories": {
|
|
62
|
-
"lib": "lib",
|
|
63
|
-
"test": "test"
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
}
|
|
64
32
|
},
|
|
65
33
|
"files": [
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"lib",
|
|
34
|
+
"dist",
|
|
35
|
+
"src",
|
|
69
36
|
"resources"
|
|
70
37
|
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.20.5",
|
|
40
|
+
"typescript": "^7.0.2"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"provenance": true
|
|
45
|
+
},
|
|
71
46
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
47
|
+
"node": ">=22.12.0"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"test": "node --test 'test/**/*.spec.ts'",
|
|
51
|
+
"build": "tsc",
|
|
52
|
+
"typecheck": "tsc --noEmit && tsc -p test"
|
|
73
53
|
}
|
|
74
|
-
}
|
|
54
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { OcflVersion } from './types.ts';
|
|
2
|
+
|
|
3
|
+
const OcflConstants = {
|
|
4
|
+
OCFL_VERSION: '1.1' as OcflVersion,
|
|
5
|
+
OCFL_VERSIONS: Object.freeze(['1.1', '1.0'] as const),
|
|
6
|
+
OCFL_LAYOUT: 'ocfl_layout.json',
|
|
7
|
+
NAMASTE_T: '0=',
|
|
8
|
+
NAMASTE_PREFIX_OBJECT: 'ocfl_object_',
|
|
9
|
+
NAMASTE_PREFIX_STORAGE: 'ocfl_',
|
|
10
|
+
INVENTORY_NAME: 'inventory.json',
|
|
11
|
+
EXTENSIONS_DIR: 'extensions',
|
|
12
|
+
EXTENSION_CONFIG: 'config.json',
|
|
13
|
+
DIGEST_ALGORITHM: 'sha512',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { OcflConstants };
|