unikvs 0.0.2 → 0.0.3

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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/core/_assign-context.d.ts +3 -0
  3. package/dist/src/core/_assign-context.d.ts.map +1 -0
  4. package/dist/src/core/_assign-context.js +3 -0
  5. package/dist/src/core/_combine-signals.d.ts +3 -0
  6. package/dist/src/core/_combine-signals.d.ts.map +1 -0
  7. package/dist/src/core/_combine-signals.js +34 -0
  8. package/dist/src/core/_is-iterable.d.ts +2 -0
  9. package/dist/src/core/_is-iterable.d.ts.map +1 -0
  10. package/dist/src/core/_is-iterable.js +3 -0
  11. package/dist/src/core/_is-plain-object.d.ts +2 -0
  12. package/dist/src/core/_is-plain-object.d.ts.map +1 -0
  13. package/dist/src/core/_is-plain-object.js +7 -0
  14. package/dist/src/core/_logger.d.ts +3 -0
  15. package/dist/src/core/_logger.d.ts.map +1 -0
  16. package/dist/src/core/_logger.js +3 -0
  17. package/dist/src/core/_merge-context.d.ts +3 -0
  18. package/dist/src/core/_merge-context.d.ts.map +1 -0
  19. package/dist/src/core/_merge-context.js +4 -0
  20. package/dist/src/core/_to-context.d.ts +7 -0
  21. package/dist/src/core/_to-context.d.ts.map +1 -0
  22. package/dist/src/core/_to-context.js +42 -0
  23. package/dist/src/core/_to-value-stream.d.ts +4 -0
  24. package/dist/src/core/_to-value-stream.d.ts.map +1 -0
  25. package/dist/src/core/_to-value-stream.js +38 -0
  26. package/dist/src/core/_with-readable-stream-from.d.ts +6 -0
  27. package/dist/src/core/_with-readable-stream-from.d.ts.map +1 -0
  28. package/dist/src/core/_with-readable-stream-from.js +58 -0
  29. package/dist/src/core/context.types.d.ts +5 -0
  30. package/dist/src/core/context.types.d.ts.map +1 -0
  31. package/dist/src/core/context.types.js +1 -0
  32. package/dist/src/core/errors.d.ts +13 -0
  33. package/dist/src/core/errors.d.ts.map +1 -0
  34. package/dist/src/core/errors.js +20 -0
  35. package/dist/src/core/index.d.ts +15 -0
  36. package/dist/src/core/index.d.ts.map +1 -0
  37. package/dist/src/core/index.js +4 -0
  38. package/dist/src/core/plugin.types.d.ts +8 -0
  39. package/dist/src/core/plugin.types.d.ts.map +1 -0
  40. package/dist/src/core/plugin.types.js +1 -0
  41. package/dist/src/core/storage.types.d.ts +22 -0
  42. package/dist/src/core/storage.types.d.ts.map +1 -0
  43. package/dist/src/core/storage.types.js +1 -0
  44. package/dist/src/core/to-readable-stream.d.ts +2 -0
  45. package/dist/src/core/to-readable-stream.d.ts.map +1 -0
  46. package/dist/src/core/to-readable-stream.js +4 -0
  47. package/dist/src/core/transformer.types.d.ts +18 -0
  48. package/dist/src/core/transformer.types.d.ts.map +1 -0
  49. package/dist/src/core/transformer.types.js +1 -0
  50. package/dist/src/core/unikvs-config.d.ts +82 -0
  51. package/dist/src/core/unikvs-config.d.ts.map +1 -0
  52. package/dist/src/core/unikvs-config.js +49 -0
  53. package/dist/src/core/unikvs.d.ts +73 -0
  54. package/dist/src/core/unikvs.d.ts.map +1 -0
  55. package/dist/src/core/unikvs.js +678 -0
  56. package/dist/src/core/utils.types.d.ts +3 -0
  57. package/dist/src/core/utils.types.d.ts.map +1 -0
  58. package/dist/src/core/utils.types.js +1 -0
  59. package/dist/src/core/value-stream.types.d.ts +4 -0
  60. package/dist/src/core/value-stream.types.d.ts.map +1 -0
  61. package/dist/src/core/value-stream.types.js +1 -0
  62. package/dist/src/destinations/memory-storage.d.ts +17 -0
  63. package/dist/src/destinations/memory-storage.d.ts.map +1 -0
  64. package/dist/src/destinations/memory-storage.js +113 -0
  65. package/dist/src/types/storage.d.ts +5 -0
  66. package/dist/src/types/storage.d.ts.map +1 -0
  67. package/dist/src/types/storage.js +1 -0
  68. package/dist/src/types/transformer.d.ts +5 -0
  69. package/dist/src/types/transformer.d.ts.map +1 -0
  70. package/dist/src/types/transformer.js +1 -0
  71. package/package.json +69 -6
  72. package/src/core/_assign-context.ts +5 -0
  73. package/src/core/_combine-signals.ts +40 -0
  74. package/src/core/_is-iterable.ts +3 -0
  75. package/src/core/_is-plain-object.ts +11 -0
  76. package/src/core/_logger.ts +5 -0
  77. package/src/core/_merge-context.ts +9 -0
  78. package/src/core/_to-context.ts +59 -0
  79. package/src/core/_to-value-stream.ts +41 -0
  80. package/src/core/_with-readable-stream-from.ts +70 -0
  81. package/src/core/context.types.ts +7 -0
  82. package/src/core/errors.ts +37 -0
  83. package/src/core/index.ts +23 -0
  84. package/src/core/plugin.types.ts +10 -0
  85. package/src/core/storage.types.ts +53 -0
  86. package/src/core/to-readable-stream.ts +7 -0
  87. package/src/core/transformer.types.ts +110 -0
  88. package/src/core/unikvs-config.ts +230 -0
  89. package/src/core/unikvs.ts +740 -0
  90. package/src/core/utils.types.ts +3 -0
  91. package/src/core/value-stream.types.ts +3 -0
  92. package/src/destinations/memory-storage.ts +160 -0
  93. package/src/types/storage.ts +5 -0
  94. package/src/types/transformer.ts +5 -0
  95. package/README.md +0 -45
@@ -0,0 +1,3 @@
1
+ export type ValueOf<T> = T[keyof T];
2
+
3
+ export type MaybePromise<T> = T | PromiseLike<T>;
@@ -0,0 +1,3 @@
1
+ export interface ValueStream<T> extends ReadableStream<T> {
2
+ [Symbol.asyncIterator](): AsyncIteratorObject<T, undefined, unknown>;
3
+ }
@@ -0,0 +1,160 @@
1
+ import getType from "type-name";
2
+
3
+ import { TypeError } from "../core/errors.js";
4
+ import type { IStorage, Key } from "../core/storage.types.js";
5
+
6
+ // https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#typedarray_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88
7
+ type TypedArray =
8
+ | Int8Array
9
+ | Uint8Array
10
+ | Uint8ClampedArray
11
+ | Int16Array
12
+ | Uint16Array
13
+ | Int32Array
14
+ | Uint32Array
15
+ | Float32Array
16
+ | Float64Array
17
+ | BigInt64Array
18
+ | BigUint64Array;
19
+
20
+ type Chunk = ArrayBuffer | TypedArray;
21
+
22
+ class Chunks extends Array<Chunk> {}
23
+
24
+ function isTypedArray(x: unknown): x is TypedArray {
25
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
26
+ }
27
+
28
+ function isArrayBuffer(x: unknown): x is ArrayBuffer {
29
+ return x instanceof ArrayBuffer;
30
+ }
31
+
32
+ export default class MemoryStorage implements IStorage {
33
+ public readonly isOpen: boolean = true;
34
+
35
+ private store: Map<Key, any>;
36
+
37
+ public constructor() {
38
+ this.store = new Map();
39
+ }
40
+
41
+ public write(key: Key, data: any): void {
42
+ this.store.set(key, data);
43
+ }
44
+
45
+ public getWritable(key: Key): WritableStream<Chunk> {
46
+ const chunks = new Chunks();
47
+ let firstChunk: Chunk | null = null;
48
+
49
+ return new WritableStream({
50
+ write: (chunk) => {
51
+ if (!isTypedArray(chunk) && !isArrayBuffer(chunk)) {
52
+ throw new TypeError({
53
+ actualValue: chunk satisfies never,
54
+ expectedType: "ArrayBuffer | TypedArray",
55
+ });
56
+ }
57
+
58
+ if (firstChunk === null) {
59
+ firstChunk = chunk;
60
+ } else if (!(chunk instanceof firstChunk.constructor)) {
61
+ throw new TypeError({
62
+ actualValue: chunk,
63
+ expectedType: getType(firstChunk),
64
+ });
65
+ }
66
+
67
+ chunks.push(chunk);
68
+ },
69
+ close: () => {
70
+ this.store.set(key, chunks);
71
+ },
72
+ });
73
+ }
74
+
75
+ public read(key: Key): any {
76
+ const data = this.store.get(key);
77
+
78
+ if (data instanceof Chunks) {
79
+ if (data.length === 0) {
80
+ return null;
81
+ }
82
+
83
+ const firstChunk = data[0]!;
84
+
85
+ if (isTypedArray(firstChunk)) {
86
+ const chunks = data as TypedArray[];
87
+
88
+ const Constructor = firstChunk.constructor as { new (n: number): TypedArray };
89
+ const totalLength = chunks.reduce((len, chunk) => len + chunk.length, 0);
90
+ const mergedArray = new Constructor(totalLength);
91
+
92
+ let offset = 0;
93
+ for (const chunk of chunks) {
94
+ mergedArray.set(chunk as any, offset);
95
+ offset += chunk.length;
96
+ }
97
+
98
+ return mergedArray;
99
+ }
100
+
101
+ if (isArrayBuffer(firstChunk)) {
102
+ const chunks = data as ArrayBuffer[];
103
+
104
+ const totalLength = data.reduce((len, chunk) => len + chunk.byteLength, 0);
105
+ const mergedArray = new Uint8Array(totalLength);
106
+
107
+ let offset = 0;
108
+ for (const chunk of chunks) {
109
+ mergedArray.set(new Uint8Array(chunk), offset);
110
+ offset += chunk.byteLength;
111
+ }
112
+
113
+ return mergedArray.buffer;
114
+ }
115
+
116
+ throw new TypeError({
117
+ actualValue: firstChunk satisfies never,
118
+ expectedType: "ArrayBuffer | TypedArray",
119
+ });
120
+ }
121
+
122
+ return data;
123
+ }
124
+
125
+ public getReadable(key: Key): ReadableStream {
126
+ const data = this.store.get(key);
127
+
128
+ return new ReadableStream({
129
+ start(controller) {
130
+ if (data !== undefined) {
131
+ if (data instanceof Chunks) {
132
+ for (const chunk of data) {
133
+ controller.enqueue(chunk);
134
+ }
135
+ } else {
136
+ controller.enqueue(data);
137
+ }
138
+ }
139
+
140
+ controller.close();
141
+ },
142
+ });
143
+ }
144
+
145
+ public exists(key: Key): boolean {
146
+ return this.store.has(key);
147
+ }
148
+
149
+ // public keys(): Iterable<Key> {
150
+ // return this.store.keys();
151
+ // }
152
+
153
+ public delete(key: Key): void {
154
+ this.store.delete(key);
155
+ }
156
+
157
+ public clear(): void {
158
+ this.store.clear();
159
+ }
160
+ }
@@ -0,0 +1,5 @@
1
+ export type { Context } from "../core/context.types.js";
2
+ export type { IPlugin } from "../core/plugin.types.js";
3
+ export type { MaybePromise } from "../core/utils.types.js";
4
+
5
+ export type * from "../core/storage.types.js";
@@ -0,0 +1,5 @@
1
+ export type { Context } from "../core/context.types.js";
2
+ export type { IPlugin } from "../core/plugin.types.js";
3
+ export type { MaybePromise } from "../core/utils.types.js";
4
+
5
+ export type * from "../core/transformer.types.js";
package/README.md DELETED
@@ -1,45 +0,0 @@
1
- # unikvs
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`
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**