@vercube/storage 0.0.41 → 0.0.43

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.
@@ -1,4 +1,4 @@
1
- import { t as Storage } from "../Storage-CswGuxQf.mjs";
1
+ import { t as Storage } from "../Storage-C6XPcRz-.mjs";
2
2
 
3
3
  //#region src/Drivers/MemoryStorage.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as Storage } from "../Storage-CswGuxQf.mjs";
1
+ import { t as Storage } from "../Storage-C6XPcRz-.mjs";
2
2
  import { Logger } from "@vercube/logger";
3
3
  import { S3ClientConfig } from "@aws-sdk/client-s3";
4
4
 
@@ -0,0 +1,229 @@
1
+ import { Container } from "@vercube/di";
2
+ import "@vercube/logger";
3
+ import "node:events";
4
+ import "node:fs";
5
+ import { Writable } from "node:stream";
6
+ import "node:http";
7
+ import "node:https";
8
+ import "node:net";
9
+ import "node:http2";
10
+
11
+ //#region ../../node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.d.mts
12
+ declare global {
13
+ var __c12_dotenv_vars__: Map<Record<string, any>, Set<string>>;
14
+ } //#endregion
15
+ //#region src/types.d.ts
16
+ //#endregion
17
+ //#region ../../node_modules/.pnpm/@types+aws-lambda@8.10.160/node_modules/@types/aws-lambda/handler.d.ts
18
+ /**
19
+ * {@link Handler} context parameter.
20
+ * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}.
21
+ */
22
+ interface Context {
23
+ callbackWaitsForEmptyEventLoop: boolean;
24
+ functionName: string;
25
+ functionVersion: string;
26
+ invokedFunctionArn: string;
27
+ memoryLimitInMB: string;
28
+ awsRequestId: string;
29
+ logGroupName: string;
30
+ logStreamName: string;
31
+ identity?: CognitoIdentity | undefined;
32
+ clientContext?: ClientContext | undefined;
33
+ tenantId?: string | undefined;
34
+ getRemainingTimeInMillis(): number; // Functions for compatibility with earlier Node.js Runtime v0.10.42
35
+ // No longer documented, so they are deprecated, but they still work
36
+ // as of the 12.x runtime, so they are not removed from the types.
37
+ /** @deprecated Use handler callback or promise result */
38
+ done(error?: Error, result?: any): void;
39
+ /** @deprecated Use handler callback with first argument or reject a promise result */
40
+ fail(error: Error | string): void;
41
+ /** @deprecated Use handler callback with second argument or resolve a promise result */
42
+ succeed(messageOrObject: any): void; // Unclear what behavior this is supposed to have, I couldn't find any still extant reference,
43
+ // and it behaves like the above, ignoring the object parameter.
44
+ /** @deprecated Use handler callback or promise result */
45
+ succeed(message: string, object: any): void;
46
+ }
47
+ interface CognitoIdentity {
48
+ cognitoIdentityId: string;
49
+ cognitoIdentityPoolId: string;
50
+ }
51
+ interface ClientContext {
52
+ client: ClientContextClient;
53
+ custom?: any;
54
+ env: ClientContextEnv;
55
+ }
56
+ interface ClientContextClient {
57
+ installationId: string;
58
+ appTitle: string;
59
+ appVersionName: string;
60
+ appVersionCode: string;
61
+ appPackageName: string;
62
+ }
63
+ interface ClientContextEnv {
64
+ platformVersion: string;
65
+ platform: string;
66
+ make: string;
67
+ model: string;
68
+ locale: string;
69
+ }
70
+ /**
71
+ * Interface for using response streaming from AWS Lambda.
72
+ * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator.
73
+ *
74
+ * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`.
75
+ * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream.
76
+ *
77
+ * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post}
78
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation}
79
+ *
80
+ * @example <caption>Writing to the response stream</caption>
81
+ * import 'aws-lambda';
82
+ *
83
+ * export const handler = awslambda.streamifyResponse(
84
+ * async (event, responseStream, context) => {
85
+ * responseStream.setContentType("text/plain");
86
+ * responseStream.write("Hello, world!");
87
+ * responseStream.end();
88
+ * }
89
+ * );
90
+ *
91
+ * @example <caption>Using pipeline</caption>
92
+ * import 'aws-lambda';
93
+ * import { Readable } from 'stream';
94
+ * import { pipeline } from 'stream/promises';
95
+ * import zlib from 'zlib';
96
+ *
97
+ * export const handler = awslambda.streamifyResponse(
98
+ * async (event, responseStream, context) => {
99
+ * // As an example, convert event to a readable stream.
100
+ * const requestStream = Readable.from(Buffer.from(JSON.stringify(event)));
101
+ *
102
+ * await pipeline(requestStream, zlib.createGzip(), responseStream);
103
+ * }
104
+ * );
105
+ */
106
+ type StreamifyHandler<TEvent = any, TResult = any> = (event: TEvent, responseStream: awslambda.HttpResponseStream, context: Context) => TResult | Promise<TResult>;
107
+ declare global {
108
+ namespace awslambda {
109
+ class HttpResponseStream extends Writable {
110
+ static from(writable: Writable, metadata: Record<string, unknown>): HttpResponseStream;
111
+ setContentType: (contentType: string) => void;
112
+ }
113
+ /**
114
+ * Decorator for using response streaming from AWS Lambda.
115
+ * To indicate to the runtime that Lambda should stream your function’s responses, you must wrap your function handler with the `awslambda.streamifyResponse()` decorator.
116
+ *
117
+ * The `streamifyResponse` decorator accepts the following additional parameter, `responseStream`, besides the default node handler parameters, `event`, and `context`.
118
+ * The new `responseStream` object provides a stream object that your function can write data to. Data written to this stream is sent immediately to the client. You can optionally set the Content-Type header of the response to pass additional metadata to your client about the contents of the stream.
119
+ *
120
+ * {@link https://aws.amazon.com/blogs/compute/introducing-aws-lambda-response-streaming/ AWS blog post}
121
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/config-rs-write-functions.html AWS documentation}
122
+ *
123
+ * @example <caption>Writing to the response stream</caption>
124
+ * import 'aws-lambda';
125
+ *
126
+ * export const handler = awslambda.streamifyResponse(
127
+ * async (event, responseStream, context) => {
128
+ * responseStream.setContentType("text/plain");
129
+ * responseStream.write("Hello, world!");
130
+ * responseStream.end();
131
+ * }
132
+ * );
133
+ *
134
+ * @example <caption>Using pipeline</caption>
135
+ * import 'aws-lambda';
136
+ * import { Readable } from 'stream';
137
+ * import { pipeline } from 'stream/promises';
138
+ * import zlib from 'zlib';
139
+ *
140
+ * export const handler = awslambda.streamifyResponse(
141
+ * async (event, responseStream, context) => {
142
+ * // As an example, convert event to a readable stream.
143
+ * const requestStream = Readable.from(Buffer.from(JSON.stringify(event)));
144
+ *
145
+ * await pipeline(requestStream, zlib.createGzip(), responseStream);
146
+ * }
147
+ * );
148
+ */
149
+ function streamifyResponse<TEvent = any, TResult = void>(handler: StreamifyHandler<TEvent, TResult>): StreamifyHandler<TEvent, TResult>;
150
+ }
151
+ }
152
+ //#endregion
153
+ //#region ../core/src/Types/CommonTypes.d.ts
154
+ type MaybePromise<T> = T | Promise<T>;
155
+ //#endregion
156
+ //#region src/Service/Storage.d.ts
157
+ /**
158
+ * Abstract base class for storage implementations
159
+ * Provides a common interface for different storage providers
160
+ *
161
+ * @abstract
162
+ * @class Storage
163
+ * @description
164
+ * The Storage class defines a standard interface for storing and retrieving data.
165
+ * It supports basic operations like get, set, delete, and querying storage state.
166
+ * Concrete implementations must provide the actual storage mechanism.
167
+ */
168
+ declare abstract class Storage<InitOptions = undefined> {
169
+ /**
170
+ * Initializes the storage implementation.
171
+ * Must be called before using any other storage operations.
172
+ *
173
+ * @param {InitOptions} options - Initialization parameters. May be omitted if not required by the storage implementation.
174
+ * @returns {Promise<void>} A promise that resolves when initialization is complete.
175
+ */
176
+ abstract initialize(options: InitOptions): void | Promise<void>;
177
+ /**
178
+ * Retrieves a value from storage by its key
179
+ * @template T - The type of the stored value
180
+ * @param {string} key - The key to retrieve the value for
181
+ * @returns {MaybePromise<T | null>} A promise that resolves with the stored value
182
+ */
183
+ abstract getItem<T = unknown>(key: string): MaybePromise<T | null>;
184
+ /**
185
+ * Retrieves multiple items from storage by their keys
186
+ * @template T - The type of the stored value
187
+ * @param {string[]} keys - The keys to retrieve the values for
188
+ * @returns {MaybePromise<T[]>} A promise that resolves with the stored values or empty array if not found
189
+ */
190
+ abstract getItems<T = unknown>(keys: string[]): MaybePromise<T[]>;
191
+ /**
192
+ * Stores a value in storage with the specified key
193
+ * @template T - The type of the value to store
194
+ * @template U - The type of the optional options object
195
+ * @param {string} key - The key under which to store the value
196
+ * @param {T} value - The value to store
197
+ * @returns {MaybePromise<void>} A promise that resolves when the value is stored
198
+ */
199
+ abstract setItem<T = unknown, U = unknown>(key: string, value: T, options?: U): MaybePromise<void>;
200
+ /**
201
+ * Removes a value from storage by its key
202
+ * @param {string} key - The key of the value to delete
203
+ * @returns {MaybePromise<void>} A promise that resolves when the value is deleted
204
+ */
205
+ abstract deleteItem(key: string): MaybePromise<void>;
206
+ /**
207
+ * Checks if a value exists in storage for the given key
208
+ * @param {string} key - The key to check
209
+ * @returns {MaybePromise<boolean>} A promise that resolves to true if the key exists, false otherwise
210
+ */
211
+ abstract hasItem(key: string): MaybePromise<boolean>;
212
+ /**
213
+ * Retrieves all keys currently stored in storage
214
+ * @returns {MaybePromise<string[]>} A promise that resolves with an array of all stored keys
215
+ */
216
+ abstract getKeys(): MaybePromise<string[]>;
217
+ /**
218
+ * Removes all stored values from storage
219
+ * @returns {Promise<void>} A promise that resolves when all values are cleared
220
+ */
221
+ abstract clear(): MaybePromise<void>;
222
+ /**
223
+ * Gets the number of key-value pairs stored in storage
224
+ * @returns {Promise<number>} A promise that resolves with the number of stored items
225
+ */
226
+ abstract size(): MaybePromise<number>;
227
+ }
228
+ //#endregion
229
+ export { Storage as t };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { t as Storage } from "./Storage-CswGuxQf.mjs";
1
+ import { t as Storage } from "./Storage-C6XPcRz-.mjs";
2
2
  import { IOC } from "@vercube/di";
3
3
 
4
4
  //#region src/Types/StorageTypes.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercube/storage",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "Storage module for Vercube framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,11 +24,11 @@
24
24
  "README.md"
25
25
  ],
26
26
  "dependencies": {
27
- "@vercube/di": "0.0.41",
28
- "@vercube/logger": "0.0.41"
27
+ "@vercube/di": "0.0.43",
28
+ "@vercube/logger": "0.0.43"
29
29
  },
30
30
  "optionalDependencies": {
31
- "@aws-sdk/client-s3": "3.978.0"
31
+ "@aws-sdk/client-s3": "3.983.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
@@ -1,93 +0,0 @@
1
- import { Container } from "@vercube/di";
2
- import "@vercube/logger";
3
- import "node:events";
4
- import "node:fs";
5
- import "node:stream";
6
- import "node:http";
7
- import "node:https";
8
- import "node:net";
9
- import "node:http2";
10
-
11
- //#region ../../node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.d.mts
12
- declare global {
13
- var __c12_dotenv_vars__: Map<Record<string, any>, Set<string>>;
14
- } //#endregion
15
- //#region src/types.d.ts
16
- //#endregion
17
- //#region ../core/src/Types/CommonTypes.d.ts
18
- type MaybePromise<T> = T | Promise<T>;
19
- //#endregion
20
- //#region src/Service/Storage.d.ts
21
- /**
22
- * Abstract base class for storage implementations
23
- * Provides a common interface for different storage providers
24
- *
25
- * @abstract
26
- * @class Storage
27
- * @description
28
- * The Storage class defines a standard interface for storing and retrieving data.
29
- * It supports basic operations like get, set, delete, and querying storage state.
30
- * Concrete implementations must provide the actual storage mechanism.
31
- */
32
- declare abstract class Storage<InitOptions = undefined> {
33
- /**
34
- * Initializes the storage implementation.
35
- * Must be called before using any other storage operations.
36
- *
37
- * @param {InitOptions} options - Initialization parameters. May be omitted if not required by the storage implementation.
38
- * @returns {Promise<void>} A promise that resolves when initialization is complete.
39
- */
40
- abstract initialize(options: InitOptions): void | Promise<void>;
41
- /**
42
- * Retrieves a value from storage by its key
43
- * @template T - The type of the stored value
44
- * @param {string} key - The key to retrieve the value for
45
- * @returns {MaybePromise<T | null>} A promise that resolves with the stored value
46
- */
47
- abstract getItem<T = unknown>(key: string): MaybePromise<T | null>;
48
- /**
49
- * Retrieves multiple items from storage by their keys
50
- * @template T - The type of the stored value
51
- * @param {string[]} keys - The keys to retrieve the values for
52
- * @returns {MaybePromise<T[]>} A promise that resolves with the stored values or empty array if not found
53
- */
54
- abstract getItems<T = unknown>(keys: string[]): MaybePromise<T[]>;
55
- /**
56
- * Stores a value in storage with the specified key
57
- * @template T - The type of the value to store
58
- * @template U - The type of the optional options object
59
- * @param {string} key - The key under which to store the value
60
- * @param {T} value - The value to store
61
- * @returns {MaybePromise<void>} A promise that resolves when the value is stored
62
- */
63
- abstract setItem<T = unknown, U = unknown>(key: string, value: T, options?: U): MaybePromise<void>;
64
- /**
65
- * Removes a value from storage by its key
66
- * @param {string} key - The key of the value to delete
67
- * @returns {MaybePromise<void>} A promise that resolves when the value is deleted
68
- */
69
- abstract deleteItem(key: string): MaybePromise<void>;
70
- /**
71
- * Checks if a value exists in storage for the given key
72
- * @param {string} key - The key to check
73
- * @returns {MaybePromise<boolean>} A promise that resolves to true if the key exists, false otherwise
74
- */
75
- abstract hasItem(key: string): MaybePromise<boolean>;
76
- /**
77
- * Retrieves all keys currently stored in storage
78
- * @returns {MaybePromise<string[]>} A promise that resolves with an array of all stored keys
79
- */
80
- abstract getKeys(): MaybePromise<string[]>;
81
- /**
82
- * Removes all stored values from storage
83
- * @returns {Promise<void>} A promise that resolves when all values are cleared
84
- */
85
- abstract clear(): MaybePromise<void>;
86
- /**
87
- * Gets the number of key-value pairs stored in storage
88
- * @returns {Promise<number>} A promise that resolves with the number of stored items
89
- */
90
- abstract size(): MaybePromise<number>;
91
- }
92
- //#endregion
93
- export { Storage as t };