@vercube/storage 0.0.42 → 0.0.45

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