@atlaspack/cache 3.2.16-typescript-1fd1095e8.0 → 3.2.16-typescript-e99c742e9.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/lib/FSCache.d.ts +27 -0
- package/lib/IDBCache.browser.d.ts +22 -0
- package/lib/IDBCache.d.ts +4 -0
- package/lib/LMDBLiteCache.d.ts +78 -0
- package/lib/constants.d.ts +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/types.d.ts +2 -0
- package/package.json +13 -13
- package/index.d.ts +0 -13
package/lib/FSCache.d.ts
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { Readable } from 'stream';
|
2
|
+
import type { FilePath } from '@atlaspack/types';
|
3
|
+
import type { FileSystem } from '@atlaspack/fs';
|
4
|
+
import type { Cache } from './types';
|
5
|
+
export declare class FSCache implements Cache {
|
6
|
+
#private;
|
7
|
+
fs: FileSystem;
|
8
|
+
dir: FilePath;
|
9
|
+
constructor(fs: FileSystem, cacheDir: FilePath);
|
10
|
+
ensure(): Promise<void>;
|
11
|
+
_getCachePath(cacheId: string): FilePath;
|
12
|
+
getStream(key: string): Readable;
|
13
|
+
setStream(key: string, stream: Readable): Promise<void>;
|
14
|
+
has(key: string): Promise<boolean>;
|
15
|
+
getBlob(key: string): Promise<Buffer>;
|
16
|
+
setBlob(key: string, contents: Buffer | string): Promise<void>;
|
17
|
+
getBuffer(key: string): Promise<Buffer | null | undefined>;
|
18
|
+
hasLargeBlob(key: string): Promise<boolean>;
|
19
|
+
getLargeBlob(key: string): Promise<Buffer>;
|
20
|
+
setLargeBlob(key: string, contents: Buffer | string, options?: {
|
21
|
+
signal?: AbortSignal;
|
22
|
+
}): Promise<void>;
|
23
|
+
deleteLargeBlob(key: string): Promise<void>;
|
24
|
+
get<T>(key: string): Promise<T | null | undefined>;
|
25
|
+
set(key: string, value: unknown): Promise<void>;
|
26
|
+
refresh(): void;
|
27
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { Cache } from './types';
|
2
|
+
import { Readable } from 'stream';
|
3
|
+
export declare class IDBCache implements Cache {
|
4
|
+
store: any;
|
5
|
+
constructor();
|
6
|
+
ensure(): Promise<void>;
|
7
|
+
serialize(): Record<any, any>;
|
8
|
+
static deserialize(): IDBCache;
|
9
|
+
has(key: string): Promise<boolean>;
|
10
|
+
get<T>(key: string): Promise<T | null | undefined>;
|
11
|
+
set(key: string, value: unknown): Promise<void>;
|
12
|
+
getStream(key: string): Readable;
|
13
|
+
setStream(key: string, stream: Readable): Promise<void>;
|
14
|
+
getBlob(key: string): Promise<Buffer>;
|
15
|
+
setBlob(key: string, contents: Buffer | string): Promise<void>;
|
16
|
+
getBuffer(key: string): Promise<Buffer | null | undefined>;
|
17
|
+
hasLargeBlob(key: string): Promise<boolean>;
|
18
|
+
getLargeBlob(key: string): Promise<Buffer>;
|
19
|
+
setLargeBlob(key: string, contents: Buffer | string): Promise<void>;
|
20
|
+
deleteLargeBlob(key: string): Promise<void>;
|
21
|
+
refresh(): void;
|
22
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import { Lmdb } from '@atlaspack/rust';
|
2
|
+
import type { FilePath } from '@atlaspack/types';
|
3
|
+
import type { Cache } from './types';
|
4
|
+
import type { Readable } from 'stream';
|
5
|
+
import { NodeFS } from '@atlaspack/fs';
|
6
|
+
import { FSCache } from './FSCache';
|
7
|
+
interface DBOpenOptions {
|
8
|
+
name: string;
|
9
|
+
encoding: string;
|
10
|
+
compression: boolean;
|
11
|
+
}
|
12
|
+
export declare class LmdbWrapper {
|
13
|
+
lmdb: Lmdb;
|
14
|
+
constructor(lmdb: Lmdb);
|
15
|
+
has(key: string): boolean;
|
16
|
+
delete(key: string): Promise<void>;
|
17
|
+
get(key: string): Buffer | null;
|
18
|
+
put(key: string, value: Buffer | string): Promise<void>;
|
19
|
+
keys(): Iterable<string>;
|
20
|
+
compact(targetPath: string): void;
|
21
|
+
}
|
22
|
+
export declare function open(directory: string, openOptions: DBOpenOptions): LmdbWrapper;
|
23
|
+
export type SerLMDBLiteCache = {
|
24
|
+
dir: FilePath;
|
25
|
+
};
|
26
|
+
export declare class LMDBLiteCache implements Cache {
|
27
|
+
fs: NodeFS;
|
28
|
+
dir: FilePath;
|
29
|
+
store: LmdbWrapper;
|
30
|
+
fsCache: FSCache;
|
31
|
+
/**
|
32
|
+
* Directory where we store raw files.
|
33
|
+
*/
|
34
|
+
cacheFilesDirectory: FilePath;
|
35
|
+
constructor(cacheDir: FilePath);
|
36
|
+
/**
|
37
|
+
* Use this to pass the native LMDB instance back to Rust.
|
38
|
+
*/
|
39
|
+
getNativeRef(): Lmdb;
|
40
|
+
ensure(): Promise<void>;
|
41
|
+
serialize(): SerLMDBLiteCache;
|
42
|
+
static deserialize(cache: SerLMDBLiteCache): LMDBLiteCache;
|
43
|
+
has(key: string): Promise<boolean>;
|
44
|
+
get<T>(key: string): Promise<T | null | undefined>;
|
45
|
+
set(key: string, value: unknown): Promise<void>;
|
46
|
+
getStream(key: string): Readable;
|
47
|
+
setStream(key: string, stream: Readable): Promise<void>;
|
48
|
+
getBlob(key: string): Promise<Buffer>;
|
49
|
+
getBlobSync(key: string): Buffer;
|
50
|
+
setBlob(key: string, contents: Buffer | string): Promise<void>;
|
51
|
+
getBuffer(key: string): Promise<Buffer | null | undefined>;
|
52
|
+
hasLargeBlob(key: string): Promise<boolean>;
|
53
|
+
getLargeBlob(key: string): Promise<Buffer>;
|
54
|
+
setLargeBlob(key: string, contents: Buffer | string, options?: {
|
55
|
+
signal?: AbortSignal;
|
56
|
+
}): Promise<void>;
|
57
|
+
/**
|
58
|
+
* @deprecated Use store.delete instead.
|
59
|
+
*/
|
60
|
+
deleteLargeBlob(key: string): Promise<void>;
|
61
|
+
keys(): Iterable<string>;
|
62
|
+
compact(targetPath: string): Promise<void>;
|
63
|
+
refresh(): void;
|
64
|
+
/**
|
65
|
+
* Streams, packages are stored in files instead of LMDB.
|
66
|
+
*
|
67
|
+
* On this case, if a cache key happens to have a parent traversal, ../..
|
68
|
+
* it is treated specially
|
69
|
+
*
|
70
|
+
* That is, something/../something and something are meant to be different
|
71
|
+
* keys.
|
72
|
+
*
|
73
|
+
* Plus we do not want to store values outside of the cache directory.
|
74
|
+
*/
|
75
|
+
getFileKey(key: string): string;
|
76
|
+
clear(): Promise<void>;
|
77
|
+
}
|
78
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const WRITE_LIMIT_CHUNK: number;
|
package/lib/index.d.ts
ADDED
package/lib/types.d.ts
ADDED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaspack/cache",
|
3
3
|
"description": "Interface for defining caches and file-system, IDB and LMDB implementations.",
|
4
|
-
"version": "3.2.16-typescript-
|
4
|
+
"version": "3.2.16-typescript-e99c742e9.0",
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
6
6
|
"type": "commonjs",
|
7
7
|
"publishConfig": {
|
@@ -11,23 +11,23 @@
|
|
11
11
|
"type": "git",
|
12
12
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
13
13
|
},
|
14
|
-
"main": "lib/index.js",
|
15
|
-
"source": "src/index.ts",
|
16
|
-
"types": "
|
14
|
+
"main": "./lib/index.js",
|
15
|
+
"source": "./src/index.ts",
|
16
|
+
"types": "./lib/index.d.ts",
|
17
17
|
"engines": {
|
18
18
|
"node": ">= 16.0.0"
|
19
19
|
},
|
20
20
|
"scripts": {
|
21
21
|
"test": "mocha",
|
22
|
-
"check-ts": "tsc --
|
22
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@atlaspack/build-cache": "2.13.4-typescript-
|
26
|
-
"@atlaspack/feature-flags": "2.19.3-typescript-
|
27
|
-
"@atlaspack/fs": "2.15.16-typescript-
|
28
|
-
"@atlaspack/logger": "2.14.14-typescript-
|
29
|
-
"@atlaspack/rust": "3.4.2-typescript-
|
30
|
-
"@atlaspack/utils": "2.17.3-typescript-
|
25
|
+
"@atlaspack/build-cache": "2.13.4-typescript-e99c742e9.0",
|
26
|
+
"@atlaspack/feature-flags": "2.19.3-typescript-e99c742e9.0",
|
27
|
+
"@atlaspack/fs": "2.15.16-typescript-e99c742e9.0",
|
28
|
+
"@atlaspack/logger": "2.14.14-typescript-e99c742e9.0",
|
29
|
+
"@atlaspack/rust": "3.4.2-typescript-e99c742e9.0",
|
30
|
+
"@atlaspack/utils": "2.17.3-typescript-e99c742e9.0",
|
31
31
|
"ncp": "^2.0.0"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
@@ -36,5 +36,5 @@
|
|
36
36
|
"browser": {
|
37
37
|
"./src/IDBCache.js": "./src/IDBCache.browser.js"
|
38
38
|
},
|
39
|
-
"gitHead": "
|
40
|
-
}
|
39
|
+
"gitHead": "e99c742e92175ac411d807daf2ba45d5bacebb58"
|
40
|
+
}
|
package/index.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import type {FilePath} from '@atlaspack/types';
|
2
|
-
|
3
|
-
import type {Cache} from './lib/types';
|
4
|
-
|
5
|
-
export type {Cache} from './lib/types';
|
6
|
-
|
7
|
-
export const FSCache: {
|
8
|
-
new (cacheDir: FilePath): Cache;
|
9
|
-
};
|
10
|
-
|
11
|
-
export const LMDBLiteCache: {
|
12
|
-
new (cacheDir: FilePath): Cache;
|
13
|
-
};
|