@unikvs/memory 0.0.1 → 0.0.4
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 +21 -0
- package/dist/src/errors.d.ts +18 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +26 -0
- package/dist/src/memory.d.ts +21 -0
- package/dist/src/memory.d.ts.map +1 -0
- package/dist/src/memory.js +83 -0
- package/package.json +45 -7
- package/src/errors.ts +53 -0
- package/src/memory.ts +113 -0
- package/README.md +0 -45
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present, tai-kun
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ErrorBase, type ErrorOptions } from "@unikvs/core";
|
|
2
|
+
export type KeyNotFoundErrorMeta = {
|
|
3
|
+
readonly key: string;
|
|
4
|
+
};
|
|
5
|
+
export type KeyNotFoundErrorArgs = KeyNotFoundErrorMeta;
|
|
6
|
+
export declare class KeyNotFoundError extends ErrorBase<KeyNotFoundErrorMeta> {
|
|
7
|
+
constructor(args: KeyNotFoundErrorArgs, options?: ErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
export type InvalidChunkTypeErrorMeta = {
|
|
10
|
+
readonly key: string;
|
|
11
|
+
readonly chunk: unknown;
|
|
12
|
+
readonly chunkType: string;
|
|
13
|
+
};
|
|
14
|
+
export type InvalidChunkTypeErrorArgs = Omit<InvalidChunkTypeErrorMeta, "chunkType">;
|
|
15
|
+
export declare class InvalidChunkTypeError extends ErrorBase<InvalidChunkTypeErrorMeta> {
|
|
16
|
+
constructor(args: InvalidChunkTypeErrorArgs, options?: ErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAmB,MAAM,cAAc,CAAC;AAG7E,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAExD,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,oBAAoB,CAAC;gBAKhD,IAAI,EAAE,oBAAoB,EAAE,OAAO,CAAC,EAAE,YAAY;CAGtE;AAID,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC;AAErF,qBAAa,qBAAsB,SAAQ,SAAS,CAAC,yBAAyB,CAAC;gBAK1D,IAAI,EAAE,yBAAyB,EAAE,OAAO,CAAC,EAAE,YAAY;CAW3E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { ErrorBase, setErrorMessage } from "@unikvs/core";
|
|
3
|
+
import getTypeName from "type-name";
|
|
4
|
+
export class KeyNotFoundError extends ErrorBase {
|
|
5
|
+
constructor(args, options) {
|
|
6
|
+
super(args, ({ key }) => `Key not found: ${key}`, options);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
_a = KeyNotFoundError;
|
|
10
|
+
(() => {
|
|
11
|
+
_a.prototype.name = "MemoryKeyNotFoundError";
|
|
12
|
+
})();
|
|
13
|
+
setErrorMessage(KeyNotFoundError, ({ key }) => `キー ${key} が見つかりません`, "ja");
|
|
14
|
+
export class InvalidChunkTypeError extends ErrorBase {
|
|
15
|
+
constructor(args, options) {
|
|
16
|
+
super({
|
|
17
|
+
...args,
|
|
18
|
+
chunkType: getTypeName(args.chunk),
|
|
19
|
+
}, ({ key, chunkType }) => `Expected chunk for key ${JSON.stringify(key)} is Uint8Array<ArrayBuffer>, but got ${chunkType}`, options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
_b = InvalidChunkTypeError;
|
|
23
|
+
(() => {
|
|
24
|
+
_b.prototype.name = "MemoryInvalidChunkTypeError";
|
|
25
|
+
})();
|
|
26
|
+
setErrorMessage(InvalidChunkTypeError, ({ key, chunkType }) => `キー ${JSON.stringify(key)} のチャンク型に Uint8Array<ArrayBuffer> を期待しましたが、${chunkType} を得ました`, "ja");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IStorage } from "@unikvs/core";
|
|
2
|
+
/**
|
|
3
|
+
* メモリーを永続化先として使用するストレージクラスです。
|
|
4
|
+
*/
|
|
5
|
+
export default class Memory implements IStorage {
|
|
6
|
+
private readonly map;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/**
|
|
9
|
+
* Memory インスタンスを初期化します。
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
get isOpen(): boolean;
|
|
13
|
+
write(args: Pick<IStorage.WriteArgs<any>, "key" | "data">): void;
|
|
14
|
+
read(args: Pick<IStorage.ReadArgs, "key">): any;
|
|
15
|
+
exists(args: Pick<IStorage.ExistsArgs, "key">): boolean;
|
|
16
|
+
delete(args: Pick<IStorage.DeleteArgs, "key">): void;
|
|
17
|
+
clear(): void;
|
|
18
|
+
getWritable(args: Pick<IStorage.GetWritableArgs, "key">): WritableStream<Uint8Array<ArrayBuffer>>;
|
|
19
|
+
getReadable(args: Pick<IStorage.GetReadableArgs, "key">): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,YAAW,QAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAmB;IAEvC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;;IAMH,IAAW,MAAM,IAAI,OAAO,CAE3B;IAEM,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,GAAG,IAAI;IAKhE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,GAAG;IAW/C,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,OAAO;IAOvD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,IAAI;IASpD,KAAK,IAAI,IAAI;IAIb,WAAW,CAChB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC,GAC1C,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IA4BnC,WAAW,CAChB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC,GAC1C,cAAc,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;CAoB3C"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { InvalidChunkTypeError, KeyNotFoundError } from "./errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* メモリーを永続化先として使用するストレージクラスです。
|
|
4
|
+
*/
|
|
5
|
+
export default class Memory {
|
|
6
|
+
/**
|
|
7
|
+
* Memory インスタンスを初期化します。
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
this.name = "Memory";
|
|
11
|
+
this.map = new Map();
|
|
12
|
+
}
|
|
13
|
+
get isOpen() {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
write(args) {
|
|
17
|
+
const { key, data } = args;
|
|
18
|
+
this.map.set(key, data);
|
|
19
|
+
}
|
|
20
|
+
read(args) {
|
|
21
|
+
const { key } = args;
|
|
22
|
+
if (!this.map.has(key)) {
|
|
23
|
+
throw new KeyNotFoundError({ key });
|
|
24
|
+
}
|
|
25
|
+
const value = this.map.get(key);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
exists(args) {
|
|
29
|
+
const { key } = args;
|
|
30
|
+
const exists = this.map.has(key);
|
|
31
|
+
return exists;
|
|
32
|
+
}
|
|
33
|
+
delete(args) {
|
|
34
|
+
const { key } = args;
|
|
35
|
+
if (!this.map.has(key)) {
|
|
36
|
+
throw new KeyNotFoundError({ key });
|
|
37
|
+
}
|
|
38
|
+
this.map.delete(key);
|
|
39
|
+
}
|
|
40
|
+
clear() {
|
|
41
|
+
this.map.clear();
|
|
42
|
+
}
|
|
43
|
+
getWritable(args) {
|
|
44
|
+
const { key } = args;
|
|
45
|
+
const chunks = [];
|
|
46
|
+
const stream = new WritableStream({
|
|
47
|
+
write: (chunk) => {
|
|
48
|
+
if (!(chunk instanceof Uint8Array)) {
|
|
49
|
+
throw new InvalidChunkTypeError({ key, chunk });
|
|
50
|
+
}
|
|
51
|
+
chunks.push(chunk);
|
|
52
|
+
},
|
|
53
|
+
close: () => {
|
|
54
|
+
const totalLength = chunks.reduce((sum, c) => sum + c.byteLength, 0);
|
|
55
|
+
const merged = new Uint8Array(totalLength);
|
|
56
|
+
let offset = 0;
|
|
57
|
+
for (const c of chunks) {
|
|
58
|
+
merged.set(c, offset);
|
|
59
|
+
offset += c.byteLength;
|
|
60
|
+
}
|
|
61
|
+
this.map.set(key, merged);
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
return stream;
|
|
65
|
+
}
|
|
66
|
+
getReadable(args) {
|
|
67
|
+
const { key } = args;
|
|
68
|
+
if (!this.map.has(key)) {
|
|
69
|
+
throw new KeyNotFoundError({ key });
|
|
70
|
+
}
|
|
71
|
+
const value = this.map.get(key);
|
|
72
|
+
const stream = new ReadableStream({
|
|
73
|
+
pull: (controller) => {
|
|
74
|
+
if (!(value instanceof Uint8Array)) {
|
|
75
|
+
throw new InvalidChunkTypeError({ key, chunk: value });
|
|
76
|
+
}
|
|
77
|
+
controller.enqueue(value);
|
|
78
|
+
controller.close();
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return stream;
|
|
82
|
+
}
|
|
83
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unikvs/memory",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"homepage": "https://github.com/tai-kun/unikvs",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "tai-kun",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/tai-kun/unikvs"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"src",
|
|
14
|
+
"package.json",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"main": "./dist/src/index.js",
|
|
20
|
+
"types": "./dist/src/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/src/index.d.ts",
|
|
24
|
+
"default": "./dist/src/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc --project ./.config/tsconfig.build.json"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@unikvs/core": "0.0.4",
|
|
32
|
+
"type-name": "^2.0.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tsconfig/node22": "^22.0.5",
|
|
36
|
+
"@tsconfig/strictest": "^2.0.8",
|
|
37
|
+
"@types/node": "^22.19.17",
|
|
38
|
+
"@types/type-name": "^1.0.32",
|
|
39
|
+
"@vitest/browser": "^4.1.4",
|
|
40
|
+
"@vitest/browser-playwright": "^4.1.4",
|
|
41
|
+
"npm-check-updates": "^20.0.2",
|
|
42
|
+
"playwright": "^1.59.1",
|
|
43
|
+
"vitest": "^4.1.4"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@logtape/logtape": "^2.0.0"
|
|
47
|
+
}
|
|
10
48
|
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ErrorBase, type ErrorOptions, setErrorMessage } from "@unikvs/core";
|
|
2
|
+
import getTypeName from "type-name";
|
|
3
|
+
|
|
4
|
+
export type KeyNotFoundErrorMeta = {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type KeyNotFoundErrorArgs = KeyNotFoundErrorMeta;
|
|
9
|
+
|
|
10
|
+
export class KeyNotFoundError extends ErrorBase<KeyNotFoundErrorMeta> {
|
|
11
|
+
static {
|
|
12
|
+
this.prototype.name = "MemoryKeyNotFoundError";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public constructor(args: KeyNotFoundErrorArgs, options?: ErrorOptions) {
|
|
16
|
+
super(args, ({ key }) => `Key not found: ${key}`, options);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setErrorMessage(KeyNotFoundError, ({ key }) => `キー ${key} が見つかりません`, "ja");
|
|
21
|
+
|
|
22
|
+
export type InvalidChunkTypeErrorMeta = {
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly chunk: unknown;
|
|
25
|
+
readonly chunkType: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type InvalidChunkTypeErrorArgs = Omit<InvalidChunkTypeErrorMeta, "chunkType">;
|
|
29
|
+
|
|
30
|
+
export class InvalidChunkTypeError extends ErrorBase<InvalidChunkTypeErrorMeta> {
|
|
31
|
+
static {
|
|
32
|
+
this.prototype.name = "MemoryInvalidChunkTypeError";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public constructor(args: InvalidChunkTypeErrorArgs, options?: ErrorOptions) {
|
|
36
|
+
super(
|
|
37
|
+
{
|
|
38
|
+
...args,
|
|
39
|
+
chunkType: getTypeName(args.chunk),
|
|
40
|
+
},
|
|
41
|
+
({ key, chunkType }) =>
|
|
42
|
+
`Expected chunk for key ${JSON.stringify(key)} is Uint8Array<ArrayBuffer>, but got ${chunkType}`,
|
|
43
|
+
options,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setErrorMessage(
|
|
49
|
+
InvalidChunkTypeError,
|
|
50
|
+
({ key, chunkType }) =>
|
|
51
|
+
`キー ${JSON.stringify(key)} のチャンク型に Uint8Array<ArrayBuffer> を期待しましたが、${chunkType} を得ました`,
|
|
52
|
+
"ja",
|
|
53
|
+
);
|
package/src/memory.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { IStorage } from "@unikvs/core";
|
|
2
|
+
|
|
3
|
+
import { InvalidChunkTypeError, KeyNotFoundError } from "./errors.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* メモリーを永続化先として使用するストレージクラスです。
|
|
7
|
+
*/
|
|
8
|
+
export default class Memory implements IStorage {
|
|
9
|
+
private readonly map: Map<string, any>;
|
|
10
|
+
|
|
11
|
+
public readonly name: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Memory インスタンスを初期化します。
|
|
15
|
+
*/
|
|
16
|
+
public constructor() {
|
|
17
|
+
this.name = "Memory";
|
|
18
|
+
this.map = new Map();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public get isOpen(): boolean {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public write(args: Pick<IStorage.WriteArgs<any>, "key" | "data">): void {
|
|
26
|
+
const { key, data } = args;
|
|
27
|
+
this.map.set(key, data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public read(args: Pick<IStorage.ReadArgs, "key">): any {
|
|
31
|
+
const { key } = args;
|
|
32
|
+
if (!this.map.has(key)) {
|
|
33
|
+
throw new KeyNotFoundError({ key });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const value = this.map.get(key);
|
|
37
|
+
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public exists(args: Pick<IStorage.ExistsArgs, "key">): boolean {
|
|
42
|
+
const { key } = args;
|
|
43
|
+
const exists = this.map.has(key);
|
|
44
|
+
|
|
45
|
+
return exists;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public delete(args: Pick<IStorage.DeleteArgs, "key">): void {
|
|
49
|
+
const { key } = args;
|
|
50
|
+
if (!this.map.has(key)) {
|
|
51
|
+
throw new KeyNotFoundError({ key });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.map.delete(key);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public clear(): void {
|
|
58
|
+
this.map.clear();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public getWritable(
|
|
62
|
+
args: Pick<IStorage.GetWritableArgs, "key">,
|
|
63
|
+
): WritableStream<Uint8Array<ArrayBuffer>> {
|
|
64
|
+
const { key } = args;
|
|
65
|
+
const chunks: Uint8Array[] = [];
|
|
66
|
+
const stream = new WritableStream<Uint8Array<ArrayBuffer>>({
|
|
67
|
+
write: (chunk) => {
|
|
68
|
+
if (!(chunk instanceof Uint8Array)) {
|
|
69
|
+
throw new InvalidChunkTypeError({ key, chunk });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
chunks.push(chunk);
|
|
73
|
+
},
|
|
74
|
+
close: () => {
|
|
75
|
+
const totalLength = chunks.reduce((sum, c) => sum + c.byteLength, 0);
|
|
76
|
+
const merged = new Uint8Array(totalLength);
|
|
77
|
+
|
|
78
|
+
let offset = 0;
|
|
79
|
+
for (const c of chunks) {
|
|
80
|
+
merged.set(c, offset);
|
|
81
|
+
offset += c.byteLength;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.map.set(key, merged);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return stream;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public getReadable(
|
|
92
|
+
args: Pick<IStorage.GetReadableArgs, "key">,
|
|
93
|
+
): ReadableStream<Uint8Array<ArrayBuffer>> {
|
|
94
|
+
const { key } = args;
|
|
95
|
+
if (!this.map.has(key)) {
|
|
96
|
+
throw new KeyNotFoundError({ key });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const value = this.map.get(key);
|
|
100
|
+
const stream = new ReadableStream<Uint8Array<ArrayBuffer>>({
|
|
101
|
+
pull: (controller) => {
|
|
102
|
+
if (!(value instanceof Uint8Array)) {
|
|
103
|
+
throw new InvalidChunkTypeError({ key, chunk: value });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
controller.enqueue(value as Uint8Array<ArrayBuffer>);
|
|
107
|
+
controller.close();
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
return stream;
|
|
112
|
+
}
|
|
113
|
+
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @unikvs/memory
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@unikvs/memory`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|