clhq-cache-module 1.1.0-alpha.156 → 1.1.0-alpha.158
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/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class ValkeyProxyClient {
|
|
2
|
-
private functionName;
|
|
3
|
-
constructor();
|
|
4
|
-
get<T>(key: string): Promise<T | undefined>;
|
|
5
|
-
set<T>(key: string, value: T, ttlMs?: number): Promise<void>;
|
|
6
|
-
del(key: string): Promise<void>;
|
|
7
|
-
delMany(keys: string[]): Promise<void>;
|
|
8
|
-
private invoke;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=valkey-proxy-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"valkey-proxy-client.d.ts","sourceRoot":"/","sources":["valkey-proxy-client.ts"],"names":[],"mappings":"AAoBA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,YAAY,CAAS;;IASvB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAK3C,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAI9B,MAAM;CAsBrB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValkeyProxyClient = void 0;
|
|
4
|
-
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
5
|
-
const lambdaClient = new client_lambda_1.Lambda({
|
|
6
|
-
region: process.env.CLIPPY_AWS_DEFAULT_REGION || 'ap-southeast-2',
|
|
7
|
-
});
|
|
8
|
-
class ValkeyProxyClient {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.functionName = process.env.VALKEY_PROXY_FUNCTION_NAME;
|
|
11
|
-
if (!this.functionName) {
|
|
12
|
-
throw new Error('VALKEY_PROXY_FUNCTION_NAME environment variable not set');
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async get(key) {
|
|
16
|
-
const response = await this.invoke({ operation: 'get', key });
|
|
17
|
-
return response.value;
|
|
18
|
-
}
|
|
19
|
-
async set(key, value, ttlMs) {
|
|
20
|
-
await this.invoke({ operation: 'set', key, value, ttlMs });
|
|
21
|
-
}
|
|
22
|
-
async del(key) {
|
|
23
|
-
await this.invoke({ operation: 'del', key });
|
|
24
|
-
}
|
|
25
|
-
async delMany(keys) {
|
|
26
|
-
await this.invoke({ operation: 'delMany', keys });
|
|
27
|
-
}
|
|
28
|
-
async invoke(payload) {
|
|
29
|
-
try {
|
|
30
|
-
const result = await lambdaClient.invoke({
|
|
31
|
-
FunctionName: this.functionName,
|
|
32
|
-
InvocationType: 'RequestResponse',
|
|
33
|
-
Payload: Buffer.from(JSON.stringify(payload)),
|
|
34
|
-
});
|
|
35
|
-
const responsePayload = JSON.parse(new TextDecoder().decode(result.Payload));
|
|
36
|
-
if (!responsePayload.success) {
|
|
37
|
-
throw new Error(`Valkey proxy error: ${responsePayload.error}`);
|
|
38
|
-
}
|
|
39
|
-
return responsePayload;
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error('Failed to invoke valkey-proxy:', error);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ValkeyProxyClient = ValkeyProxyClient;
|
|
48
|
-
//# sourceMappingURL=valkey-proxy-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"valkey-proxy-client.js","sourceR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E,iBAAiB;gBACjC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;aAC9C,CAAC,CAAC;YAEH,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAChC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CACxB,CAAC;YAEnB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC;YAClE,CAAC;YAED,OAAO,eAAe,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAjDD,8CAiDC","sourcesContent":["import { Lambda } from '@aws-sdk/client-lambda';\n\nconst lambdaClient = new Lambda({\n region: process.env.CLIPPY_AWS_DEFAULT_REGION || 'ap-southeast-2',\n});\n\ninterface CacheRequest {\n operation: 'get' | 'set' | 'del' | 'delMany';\n key?: string;\n keys?: string[];\n value?: unknown;\n ttlMs?: number;\n}\n\ninterface CacheResponse {\n success: boolean;\n value?: unknown;\n error?: string;\n}\n\nexport class ValkeyProxyClient {\n private functionName: string;\n\n constructor() {\n this.functionName = process.env.VALKEY_PROXY_FUNCTION_NAME;\n if (!this.functionName) {\n throw new Error('VALKEY_PROXY_FUNCTION_NAME environment variable not set');\n }\n }\n\n async get<T>(key: string): Promise<T | undefined> {\n const response = await this.invoke({ operation: 'get', key });\n return response.value as T;\n }\n\n async set<T>(key: string, value: T, ttlMs?: number): Promise<void> {\n await this.invoke({ operation: 'set', key, value, ttlMs });\n }\n\n async del(key: string): Promise<void> {\n await this.invoke({ operation: 'del', key });\n }\n\n async delMany(keys: string[]): Promise<void> {\n await this.invoke({ operation: 'delMany', keys });\n }\n\n private async invoke(payload: CacheRequest): Promise<CacheResponse> {\n try {\n const result = await lambdaClient.invoke({\n FunctionName: this.functionName,\n InvocationType: 'RequestResponse',\n Payload: Buffer.from(JSON.stringify(payload)),\n });\n\n const responsePayload = JSON.parse(\n new TextDecoder().decode(result.Payload),\n ) as CacheResponse;\n\n if (!responsePayload.success) {\n throw new Error(`Valkey proxy error: ${responsePayload.error}`);\n }\n\n return responsePayload;\n } catch (error) {\n console.error('Failed to invoke valkey-proxy:', error);\n throw error;\n }\n }\n}\n"]}
|