@arcraz/common 1.0.0
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 +190 -0
- package/README.md +373 -0
- package/dist/aws/bedrock/client-factory.d.ts +45 -0
- package/dist/aws/bedrock/client-factory.d.ts.map +1 -0
- package/dist/aws/bedrock/client-factory.js +113 -0
- package/dist/aws/bedrock/index.d.ts +3 -0
- package/dist/aws/bedrock/index.d.ts.map +1 -0
- package/dist/aws/bedrock/index.js +1 -0
- package/dist/aws/bedrock/types.d.ts +95 -0
- package/dist/aws/bedrock/types.d.ts.map +1 -0
- package/dist/aws/bedrock/types.js +1 -0
- package/dist/aws/cloudfront/index.d.ts +3 -0
- package/dist/aws/cloudfront/index.d.ts.map +1 -0
- package/dist/aws/cloudfront/index.js +1 -0
- package/dist/aws/cloudfront/signer-factory.d.ts +36 -0
- package/dist/aws/cloudfront/signer-factory.d.ts.map +1 -0
- package/dist/aws/cloudfront/signer-factory.js +75 -0
- package/dist/aws/cloudfront/types.d.ts +52 -0
- package/dist/aws/cloudfront/types.d.ts.map +1 -0
- package/dist/aws/cloudfront/types.js +1 -0
- package/dist/aws/s3/client-factory.d.ts +13 -0
- package/dist/aws/s3/client-factory.d.ts.map +1 -0
- package/dist/aws/s3/client-factory.js +25 -0
- package/dist/aws/s3/index.d.ts +4 -0
- package/dist/aws/s3/index.d.ts.map +1 -0
- package/dist/aws/s3/index.js +2 -0
- package/dist/aws/s3/operations.d.ts +106 -0
- package/dist/aws/s3/operations.d.ts.map +1 -0
- package/dist/aws/s3/operations.js +234 -0
- package/dist/aws/s3/types.d.ts +88 -0
- package/dist/aws/s3/types.d.ts.map +1 -0
- package/dist/aws/s3/types.js +1 -0
- package/dist/caches/api-cache.d.ts +40 -0
- package/dist/caches/api-cache.d.ts.map +1 -0
- package/dist/caches/api-cache.js +65 -0
- package/dist/caches/database-cache.d.ts +40 -0
- package/dist/caches/database-cache.d.ts.map +1 -0
- package/dist/caches/database-cache.js +65 -0
- package/dist/caches/index.d.ts +3 -0
- package/dist/caches/index.d.ts.map +1 -0
- package/dist/caches/index.js +2 -0
- package/dist/config/env-loader.d.ts +28 -0
- package/dist/config/env-loader.d.ts.map +1 -0
- package/dist/config/env-loader.js +39 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +2 -0
- package/dist/config/schemas.d.ts +193 -0
- package/dist/config/schemas.d.ts.map +1 -0
- package/dist/config/schemas.js +92 -0
- package/dist/config/types.d.ts +23 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/constants/cache-durations.d.ts +29 -0
- package/dist/constants/cache-durations.d.ts.map +1 -0
- package/dist/constants/cache-durations.js +27 -0
- package/dist/constants/defaults.d.ts +50 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +49 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/database/base-repository.d.ts +45 -0
- package/dist/database/base-repository.d.ts.map +1 -0
- package/dist/database/base-repository.js +57 -0
- package/dist/database/helpers/converter-helper.d.ts +9 -0
- package/dist/database/helpers/converter-helper.d.ts.map +1 -0
- package/dist/database/helpers/converter-helper.js +20 -0
- package/dist/database/helpers/index.d.ts +3 -0
- package/dist/database/helpers/index.d.ts.map +1 -0
- package/dist/database/helpers/index.js +2 -0
- package/dist/database/helpers/paged-response-helper.d.ts +33 -0
- package/dist/database/helpers/paged-response-helper.d.ts.map +1 -0
- package/dist/database/helpers/paged-response-helper.js +64 -0
- package/dist/database/index.d.ts +6 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +4 -0
- package/dist/database/pool-factory.d.ts +24 -0
- package/dist/database/pool-factory.d.ts.map +1 -0
- package/dist/database/pool-factory.js +91 -0
- package/dist/database/query-helpers.d.ts +36 -0
- package/dist/database/query-helpers.d.ts.map +1 -0
- package/dist/database/query-helpers.js +68 -0
- package/dist/database/types.d.ts +55 -0
- package/dist/database/types.d.ts.map +1 -0
- package/dist/database/types.js +1 -0
- package/dist/helpers/data-obscurer.d.ts +18 -0
- package/dist/helpers/data-obscurer.d.ts.map +1 -0
- package/dist/helpers/data-obscurer.js +29 -0
- package/dist/helpers/enum-converters.d.ts +27 -0
- package/dist/helpers/enum-converters.d.ts.map +1 -0
- package/dist/helpers/enum-converters.js +37 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/remove-sensitive-values.d.ts +20 -0
- package/dist/helpers/remove-sensitive-values.d.ts.map +1 -0
- package/dist/helpers/remove-sensitive-values.js +72 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/logging/formatters.d.ts +19 -0
- package/dist/logging/formatters.d.ts.map +1 -0
- package/dist/logging/formatters.js +94 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/logger-factory.d.ts +8 -0
- package/dist/logging/logger-factory.d.ts.map +1 -0
- package/dist/logging/logger-factory.js +86 -0
- package/dist/logging/types.d.ts +52 -0
- package/dist/logging/types.d.ts.map +1 -0
- package/dist/logging/types.js +1 -0
- package/dist/rabbitmq/connection-factory.d.ts +8 -0
- package/dist/rabbitmq/connection-factory.d.ts.map +1 -0
- package/dist/rabbitmq/connection-factory.js +117 -0
- package/dist/rabbitmq/consumer.d.ts +44 -0
- package/dist/rabbitmq/consumer.d.ts.map +1 -0
- package/dist/rabbitmq/consumer.js +107 -0
- package/dist/rabbitmq/index.d.ts +6 -0
- package/dist/rabbitmq/index.d.ts.map +1 -0
- package/dist/rabbitmq/index.js +4 -0
- package/dist/rabbitmq/namespace-helpers.d.ts +33 -0
- package/dist/rabbitmq/namespace-helpers.d.ts.map +1 -0
- package/dist/rabbitmq/namespace-helpers.js +44 -0
- package/dist/rabbitmq/publisher.d.ts +27 -0
- package/dist/rabbitmq/publisher.d.ts.map +1 -0
- package/dist/rabbitmq/publisher.js +94 -0
- package/dist/rabbitmq/types.d.ts +94 -0
- package/dist/rabbitmq/types.d.ts.map +1 -0
- package/dist/rabbitmq/types.js +1 -0
- package/dist/redis/client-factory.d.ts +14 -0
- package/dist/redis/client-factory.d.ts.map +1 -0
- package/dist/redis/client-factory.js +98 -0
- package/dist/redis/index.d.ts +6 -0
- package/dist/redis/index.d.ts.map +1 -0
- package/dist/redis/index.js +4 -0
- package/dist/redis/namespace-helpers.d.ts +33 -0
- package/dist/redis/namespace-helpers.d.ts.map +1 -0
- package/dist/redis/namespace-helpers.js +43 -0
- package/dist/redis/operations/index.d.ts +3 -0
- package/dist/redis/operations/index.d.ts.map +1 -0
- package/dist/redis/operations/index.js +2 -0
- package/dist/redis/operations/list.d.ts +102 -0
- package/dist/redis/operations/list.d.ts.map +1 -0
- package/dist/redis/operations/list.js +136 -0
- package/dist/redis/operations/standard.d.ts +85 -0
- package/dist/redis/operations/standard.d.ts.map +1 -0
- package/dist/redis/operations/standard.js +136 -0
- package/dist/redis/types.d.ts +81 -0
- package/dist/redis/types.d.ts.map +1 -0
- package/dist/redis/types.js +8 -0
- package/dist/security/cors-factory.d.ts +28 -0
- package/dist/security/cors-factory.d.ts.map +1 -0
- package/dist/security/cors-factory.js +73 -0
- package/dist/security/helmet-factory.d.ts +14 -0
- package/dist/security/helmet-factory.d.ts.map +1 -0
- package/dist/security/helmet-factory.js +80 -0
- package/dist/security/index.d.ts +4 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +2 -0
- package/dist/security/types.d.ts +103 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/types.js +1 -0
- package/dist/types/custom-types.d.ts +102 -0
- package/dist/types/custom-types.d.ts.map +1 -0
- package/dist/types/custom-types.js +45 -0
- package/dist/types/enums.d.ts +26 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +30 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/package.json +154 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Bedrock client instance
|
|
4
|
+
* @param config Bedrock client configuration
|
|
5
|
+
* @returns Bedrock instance
|
|
6
|
+
*/
|
|
7
|
+
export function createBedrockClient(config) {
|
|
8
|
+
const client = new BedrockRuntimeClient({
|
|
9
|
+
region: config.region,
|
|
10
|
+
credentials: config.credentials
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
client,
|
|
14
|
+
region: config.region
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Closes a Bedrock client connection
|
|
19
|
+
* @param bedrock Bedrock instance to close
|
|
20
|
+
*/
|
|
21
|
+
export function closeBedrockClient(bedrock) {
|
|
22
|
+
bedrock.client.destroy();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Invokes Claude model with messages
|
|
26
|
+
* @param bedrock Bedrock instance
|
|
27
|
+
* @param messages Conversation messages
|
|
28
|
+
* @param options Invoke options
|
|
29
|
+
* @returns Claude response
|
|
30
|
+
*/
|
|
31
|
+
export async function invokeClaude(bedrock, messages, options = {}) {
|
|
32
|
+
const { modelId = 'anthropic.claude-3-5-sonnet-20240620-v1:0', systemPrompt, maxTokens = 4096, temperature = 0.7, topP, topK, stopSequences } = options;
|
|
33
|
+
const requestBody = {
|
|
34
|
+
anthropic_version: 'bedrock-2023-05-31',
|
|
35
|
+
messages,
|
|
36
|
+
max_tokens: maxTokens,
|
|
37
|
+
temperature
|
|
38
|
+
};
|
|
39
|
+
if (systemPrompt) {
|
|
40
|
+
requestBody.system = systemPrompt;
|
|
41
|
+
}
|
|
42
|
+
if (topP !== undefined) {
|
|
43
|
+
requestBody.top_p = topP;
|
|
44
|
+
}
|
|
45
|
+
if (topK !== undefined) {
|
|
46
|
+
requestBody.top_k = topK;
|
|
47
|
+
}
|
|
48
|
+
if (stopSequences && stopSequences.length > 0) {
|
|
49
|
+
requestBody.stop_sequences = stopSequences;
|
|
50
|
+
}
|
|
51
|
+
const command = new InvokeModelCommand({
|
|
52
|
+
modelId,
|
|
53
|
+
contentType: 'application/json',
|
|
54
|
+
accept: 'application/json',
|
|
55
|
+
body: JSON.stringify(requestBody)
|
|
56
|
+
});
|
|
57
|
+
const response = await bedrock.client.send(command);
|
|
58
|
+
const responseBody = JSON.parse(new TextDecoder().decode(response.body));
|
|
59
|
+
return {
|
|
60
|
+
content: responseBody.content[0]?.text || '',
|
|
61
|
+
stopReason: responseBody.stop_reason,
|
|
62
|
+
usage: {
|
|
63
|
+
inputTokens: responseBody.usage?.input_tokens || 0,
|
|
64
|
+
outputTokens: responseBody.usage?.output_tokens || 0
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Simple text completion with Claude
|
|
70
|
+
* @param bedrock Bedrock instance
|
|
71
|
+
* @param prompt User prompt
|
|
72
|
+
* @param options Invoke options
|
|
73
|
+
* @returns Generated text
|
|
74
|
+
*/
|
|
75
|
+
export async function complete(bedrock, prompt, options = {}) {
|
|
76
|
+
const response = await invokeClaude(bedrock, [{ role: 'user', content: prompt }], options);
|
|
77
|
+
return response.content;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generates embeddings using Titan Embeddings
|
|
81
|
+
* @param bedrock Bedrock instance
|
|
82
|
+
* @param text Text to embed
|
|
83
|
+
* @param options Embedding options
|
|
84
|
+
* @returns Embedding response
|
|
85
|
+
*/
|
|
86
|
+
export async function generateEmbedding(bedrock, text, options = {}) {
|
|
87
|
+
const { modelId = 'amazon.titan-embed-text-v1' } = options;
|
|
88
|
+
const requestBody = {
|
|
89
|
+
inputText: text
|
|
90
|
+
};
|
|
91
|
+
const command = new InvokeModelCommand({
|
|
92
|
+
modelId,
|
|
93
|
+
contentType: 'application/json',
|
|
94
|
+
accept: 'application/json',
|
|
95
|
+
body: JSON.stringify(requestBody)
|
|
96
|
+
});
|
|
97
|
+
const response = await bedrock.client.send(command);
|
|
98
|
+
const responseBody = JSON.parse(new TextDecoder().decode(response.body));
|
|
99
|
+
return {
|
|
100
|
+
embedding: responseBody.embedding,
|
|
101
|
+
inputTokens: responseBody.inputTextTokenCount
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generates embeddings for multiple texts
|
|
106
|
+
* @param bedrock Bedrock instance
|
|
107
|
+
* @param texts Texts to embed
|
|
108
|
+
* @param options Embedding options
|
|
109
|
+
* @returns Array of embedding responses
|
|
110
|
+
*/
|
|
111
|
+
export async function generateEmbeddings(bedrock, texts, options = {}) {
|
|
112
|
+
return Promise.all(texts.map((text) => generateEmbedding(bedrock, text, options)));
|
|
113
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createBedrockClient, closeBedrockClient, invokeClaude, complete, generateEmbedding, generateEmbeddings } from './client-factory.js';
|
|
2
|
+
export type { BedrockClientConfig, BedrockInstance, BedrockModelId, ClaudeMessage, ClaudeContentBlock, ClaudeInvokeOptions, ClaudeResponse, EmbeddingOptions, EmbeddingResponse } from './types.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aws/bedrock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7I,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createBedrockClient, closeBedrockClient, invokeClaude, complete, generateEmbedding, generateEmbeddings } from './client-factory.js';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { BedrockRuntimeClient } from '@aws-sdk/client-bedrock-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Bedrock client configuration
|
|
4
|
+
*/
|
|
5
|
+
export interface BedrockClientConfig {
|
|
6
|
+
/** AWS region */
|
|
7
|
+
region: string;
|
|
8
|
+
/** AWS credentials (optional - uses default credential chain if not provided) */
|
|
9
|
+
credentials?: {
|
|
10
|
+
accessKeyId: string;
|
|
11
|
+
secretAccessKey: string;
|
|
12
|
+
sessionToken?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bedrock instance wrapper
|
|
17
|
+
*/
|
|
18
|
+
export interface BedrockInstance {
|
|
19
|
+
client: BedrockRuntimeClient;
|
|
20
|
+
region: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Known Bedrock model IDs (for documentation and autocomplete)
|
|
24
|
+
*/
|
|
25
|
+
export type KnownBedrockModelId = 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-v2:1' | 'anthropic.claude-v2' | 'anthropic.claude-instant-v1' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'amazon.titan-embed-text-v1' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1';
|
|
26
|
+
/**
|
|
27
|
+
* Bedrock model ID - accepts known models or any custom model string
|
|
28
|
+
*/
|
|
29
|
+
export type BedrockModelId = KnownBedrockModelId | (string & {});
|
|
30
|
+
/**
|
|
31
|
+
* Claude message format
|
|
32
|
+
*/
|
|
33
|
+
export interface ClaudeMessage {
|
|
34
|
+
role: 'user' | 'assistant';
|
|
35
|
+
content: string | ClaudeContentBlock[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Claude content block
|
|
39
|
+
*/
|
|
40
|
+
export interface ClaudeContentBlock {
|
|
41
|
+
type: 'text' | 'image';
|
|
42
|
+
text?: string;
|
|
43
|
+
source?: {
|
|
44
|
+
type: 'base64';
|
|
45
|
+
media_type: string;
|
|
46
|
+
data: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for Claude invoke
|
|
51
|
+
*/
|
|
52
|
+
export interface ClaudeInvokeOptions {
|
|
53
|
+
/** Model ID */
|
|
54
|
+
modelId?: BedrockModelId;
|
|
55
|
+
/** System prompt */
|
|
56
|
+
systemPrompt?: string;
|
|
57
|
+
/** Maximum tokens to generate */
|
|
58
|
+
maxTokens?: number;
|
|
59
|
+
/** Temperature (0-1) */
|
|
60
|
+
temperature?: number;
|
|
61
|
+
/** Top P (0-1) */
|
|
62
|
+
topP?: number;
|
|
63
|
+
/** Top K */
|
|
64
|
+
topK?: number;
|
|
65
|
+
/** Stop sequences */
|
|
66
|
+
stopSequences?: string[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Claude response
|
|
70
|
+
*/
|
|
71
|
+
export interface ClaudeResponse {
|
|
72
|
+
content: string;
|
|
73
|
+
stopReason: string;
|
|
74
|
+
usage: {
|
|
75
|
+
inputTokens: number;
|
|
76
|
+
outputTokens: number;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Options for embedding generation
|
|
81
|
+
*/
|
|
82
|
+
export interface EmbeddingOptions {
|
|
83
|
+
/** Model ID for embeddings */
|
|
84
|
+
modelId?: string;
|
|
85
|
+
/** Input type for Cohere models */
|
|
86
|
+
inputType?: 'search_document' | 'search_query' | 'classification' | 'clustering';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Embedding response
|
|
90
|
+
*/
|
|
91
|
+
export interface EmbeddingResponse {
|
|
92
|
+
embedding: number[];
|
|
93
|
+
inputTokens?: number;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/aws/bedrock/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iBAAiB;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,WAAW,CAAC,EAAE;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,uCAAuC,GACvC,yCAAyC,GACzC,wCAAwC,GACxC,2CAA2C,GAC3C,uBAAuB,GACvB,qBAAqB,GACrB,6BAA6B,GAC7B,8BAA8B,GAC9B,2BAA2B,GAC3B,4BAA4B,GAC5B,8BAA8B,GAC9B,+BAA+B,GAC/B,yBAAyB,GACzB,+BAA+B,GAC/B,gBAAgB,GAChB,kBAAkB,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,mBAAmB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,E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 +1,3 @@
|
|
|
1
|
+
export { createCloudFrontSigner, signUrl, signCookies, getCookieHeaders } from './signer-factory.js';
|
|
2
|
+
export type { CloudFrontSignerConfig, CloudFrontSignerInstance, SignedUrlOptions, SignedCookieOptions, SignedCookies } from './types.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aws/cloudfront/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrG,YAAY,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCloudFrontSigner, signUrl, signCookies, getCookieHeaders } from './signer-factory.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CloudFrontSignerConfig, CloudFrontSignerInstance, SignedUrlOptions, SignedCookieOptions, SignedCookies } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a CloudFront signer instance
|
|
4
|
+
* @param config Signer configuration
|
|
5
|
+
* @returns CloudFront signer instance
|
|
6
|
+
*/
|
|
7
|
+
export declare function createCloudFrontSigner(config: CloudFrontSignerConfig): CloudFrontSignerInstance;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a signed URL for CloudFront
|
|
10
|
+
* @param signer CloudFront signer instance
|
|
11
|
+
* @param resourcePath Path to the resource (e.g., /images/photo.jpg)
|
|
12
|
+
* @param options Signed URL options
|
|
13
|
+
* @returns Signed URL
|
|
14
|
+
*/
|
|
15
|
+
export declare function signUrl(signer: CloudFrontSignerInstance, resourcePath: string, options: SignedUrlOptions): string;
|
|
16
|
+
/**
|
|
17
|
+
* Generates signed cookies for CloudFront
|
|
18
|
+
* @param signer CloudFront signer instance
|
|
19
|
+
* @param options Signed cookie options
|
|
20
|
+
* @returns Signed cookies
|
|
21
|
+
*/
|
|
22
|
+
export declare function signCookies(signer: CloudFrontSignerInstance, options: SignedCookieOptions): SignedCookies;
|
|
23
|
+
/**
|
|
24
|
+
* Generates cookie headers for HTTP response
|
|
25
|
+
* @param cookies Signed cookies
|
|
26
|
+
* @param domain Cookie domain
|
|
27
|
+
* @param options Cookie options
|
|
28
|
+
* @returns Array of Set-Cookie header values
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCookieHeaders(cookies: SignedCookies, domain: string, options?: {
|
|
31
|
+
path?: string;
|
|
32
|
+
secure?: boolean;
|
|
33
|
+
httpOnly?: boolean;
|
|
34
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
35
|
+
}): string[];
|
|
36
|
+
//# sourceMappingURL=signer-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer-factory.d.ts","sourceRoot":"","sources":["../../../src/aws/cloudfront/signer-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEzI;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,wBAAwB,CAM/F;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAiBjH;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,wBAAwB,EAAE,OAAO,EAAE,mBAAmB,GAAG,aAAa,CAoBzG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACjC,GACL,MAAM,EAAE,CAUV"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { getSignedUrl, getSignedCookies } from '@aws-sdk/cloudfront-signer';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a CloudFront signer instance
|
|
4
|
+
* @param config Signer configuration
|
|
5
|
+
* @returns CloudFront signer instance
|
|
6
|
+
*/
|
|
7
|
+
export function createCloudFrontSigner(config) {
|
|
8
|
+
return {
|
|
9
|
+
keyPairId: config.keyPairId,
|
|
10
|
+
privateKey: config.privateKey,
|
|
11
|
+
distributionDomain: config.distributionDomain
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates a signed URL for CloudFront
|
|
16
|
+
* @param signer CloudFront signer instance
|
|
17
|
+
* @param resourcePath Path to the resource (e.g., /images/photo.jpg)
|
|
18
|
+
* @param options Signed URL options
|
|
19
|
+
* @returns Signed URL
|
|
20
|
+
*/
|
|
21
|
+
export function signUrl(signer, resourcePath, options) {
|
|
22
|
+
const url = `https://${signer.distributionDomain}${resourcePath}`;
|
|
23
|
+
const dateLessThan = options.expires instanceof Date ? options.expires.toISOString() : new Date(options.expires * 1000).toISOString();
|
|
24
|
+
return getSignedUrl({
|
|
25
|
+
url,
|
|
26
|
+
keyPairId: signer.keyPairId,
|
|
27
|
+
privateKey: signer.privateKey,
|
|
28
|
+
dateLessThan,
|
|
29
|
+
dateGreaterThan: options.dateGreaterThan instanceof Date
|
|
30
|
+
? options.dateGreaterThan.toISOString()
|
|
31
|
+
: options.dateGreaterThan
|
|
32
|
+
? new Date(options.dateGreaterThan * 1000).toISOString()
|
|
33
|
+
: undefined,
|
|
34
|
+
ipAddress: options.ipAddress
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates signed cookies for CloudFront
|
|
39
|
+
* @param signer CloudFront signer instance
|
|
40
|
+
* @param options Signed cookie options
|
|
41
|
+
* @returns Signed cookies
|
|
42
|
+
*/
|
|
43
|
+
export function signCookies(signer, options) {
|
|
44
|
+
const resourceUrl = options.resourcePath ? `https://${signer.distributionDomain}${options.resourcePath}` : `https://${signer.distributionDomain}/*`;
|
|
45
|
+
const dateLessThan = options.expires instanceof Date ? options.expires.toISOString() : new Date(options.expires * 1000).toISOString();
|
|
46
|
+
const cookies = getSignedCookies({
|
|
47
|
+
url: resourceUrl,
|
|
48
|
+
keyPairId: signer.keyPairId,
|
|
49
|
+
privateKey: signer.privateKey,
|
|
50
|
+
dateLessThan,
|
|
51
|
+
dateGreaterThan: options.dateGreaterThan instanceof Date
|
|
52
|
+
? options.dateGreaterThan.toISOString()
|
|
53
|
+
: options.dateGreaterThan
|
|
54
|
+
? new Date(options.dateGreaterThan * 1000).toISOString()
|
|
55
|
+
: undefined,
|
|
56
|
+
ipAddress: options.ipAddress
|
|
57
|
+
});
|
|
58
|
+
return cookies;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates cookie headers for HTTP response
|
|
62
|
+
* @param cookies Signed cookies
|
|
63
|
+
* @param domain Cookie domain
|
|
64
|
+
* @param options Cookie options
|
|
65
|
+
* @returns Array of Set-Cookie header values
|
|
66
|
+
*/
|
|
67
|
+
export function getCookieHeaders(cookies, domain, options = {}) {
|
|
68
|
+
const { path = '/', secure = true, httpOnly = true, sameSite = 'Strict' } = options;
|
|
69
|
+
const cookieOptions = [`Domain=${domain}`, `Path=${path}`, secure ? 'Secure' : '', httpOnly ? 'HttpOnly' : '', `SameSite=${sameSite}`].filter(Boolean).join('; ');
|
|
70
|
+
return [
|
|
71
|
+
`CloudFront-Policy=${cookies['CloudFront-Policy']}; ${cookieOptions}`,
|
|
72
|
+
`CloudFront-Signature=${cookies['CloudFront-Signature']}; ${cookieOptions}`,
|
|
73
|
+
`CloudFront-Key-Pair-Id=${cookies['CloudFront-Key-Pair-Id']}; ${cookieOptions}`
|
|
74
|
+
];
|
|
75
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudFront signer configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface CloudFrontSignerConfig {
|
|
5
|
+
/** CloudFront key pair ID */
|
|
6
|
+
keyPairId: string;
|
|
7
|
+
/** Private key in PEM format */
|
|
8
|
+
privateKey: string;
|
|
9
|
+
/** CloudFront distribution domain (e.g., d123456789.cloudfront.net) */
|
|
10
|
+
distributionDomain: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* CloudFront signer instance
|
|
14
|
+
*/
|
|
15
|
+
export interface CloudFrontSignerInstance {
|
|
16
|
+
keyPairId: string;
|
|
17
|
+
privateKey: string;
|
|
18
|
+
distributionDomain: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for signed URL generation
|
|
22
|
+
*/
|
|
23
|
+
export interface SignedUrlOptions {
|
|
24
|
+
/** URL expiration time (Date or Unix timestamp) */
|
|
25
|
+
expires: Date | number;
|
|
26
|
+
/** Optional IP address restriction (CIDR format) */
|
|
27
|
+
ipAddress?: string;
|
|
28
|
+
/** Optional start time for URL validity */
|
|
29
|
+
dateGreaterThan?: Date | number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for signed cookie generation
|
|
33
|
+
*/
|
|
34
|
+
export interface SignedCookieOptions {
|
|
35
|
+
/** Cookie expiration time (Date or Unix timestamp) */
|
|
36
|
+
expires: Date | number;
|
|
37
|
+
/** Resource path pattern (e.g., /images/*) */
|
|
38
|
+
resourcePath?: string;
|
|
39
|
+
/** Optional IP address restriction (CIDR format) */
|
|
40
|
+
ipAddress?: string;
|
|
41
|
+
/** Optional start time for cookie validity */
|
|
42
|
+
dateGreaterThan?: Date | number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* CloudFront signed cookies
|
|
46
|
+
*/
|
|
47
|
+
export interface SignedCookies {
|
|
48
|
+
'CloudFront-Policy': string;
|
|
49
|
+
'CloudFront-Signature': string;
|
|
50
|
+
'CloudFront-Key-Pair-Id': string;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/aws/cloudfront/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mDAAmD;IACnD,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,8CAA8C;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,MAAM,CAAC;CAClC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { S3ClientConfig, S3Instance } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an S3 client instance
|
|
4
|
+
* @param config S3 client configuration
|
|
5
|
+
* @returns S3 instance
|
|
6
|
+
*/
|
|
7
|
+
export declare function createS3Client(config: S3ClientConfig): S3Instance;
|
|
8
|
+
/**
|
|
9
|
+
* Closes an S3 client connection
|
|
10
|
+
* @param s3 S3 instance to close
|
|
11
|
+
*/
|
|
12
|
+
export declare function closeS3Client(s3: S3Instance): void;
|
|
13
|
+
//# sourceMappingURL=client-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-factory.d.ts","sourceRoot":"","sources":["../../../src/aws/s3/client-factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAYjE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,UAAU,GAAG,IAAI,CAElD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an S3 client instance
|
|
4
|
+
* @param config S3 client configuration
|
|
5
|
+
* @returns S3 instance
|
|
6
|
+
*/
|
|
7
|
+
export function createS3Client(config) {
|
|
8
|
+
const client = new S3Client({
|
|
9
|
+
region: config.region,
|
|
10
|
+
credentials: config.credentials,
|
|
11
|
+
endpoint: config.endpoint,
|
|
12
|
+
forcePathStyle: config.forcePathStyle
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
client,
|
|
16
|
+
region: config.region
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Closes an S3 client connection
|
|
21
|
+
* @param s3 S3 instance to close
|
|
22
|
+
*/
|
|
23
|
+
export function closeS3Client(s3) {
|
|
24
|
+
s3.client.destroy();
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createS3Client, closeS3Client } from './client-factory.js';
|
|
2
|
+
export { upload, download, downloadAsBuffer, downloadAsString, deleteObject, deleteObjects, exists, getMetadata, listObjects, copyObject, getPresignedDownloadUrl, getPresignedUploadUrl } from './operations.js';
|
|
3
|
+
export type { S3ClientConfig, S3Instance, UploadOptions, DownloadOptions, PresignedUrlOptions, ListObjectsOptions, S3ObjectMetadata } from './types.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aws/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EACL,MAAM,EACN,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,WAAW,EACX,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { createS3Client, closeS3Client } from './client-factory.js';
|
|
2
|
+
export { upload, download, downloadAsBuffer, downloadAsString, deleteObject, deleteObjects, exists, getMetadata, listObjects, copyObject, getPresignedDownloadUrl, getPresignedUploadUrl } from './operations.js';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import type { S3Instance, UploadOptions, DownloadOptions, PresignedUrlOptions, ListObjectsOptions, S3ObjectMetadata } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Uploads data to S3
|
|
5
|
+
* @param s3 S3 instance
|
|
6
|
+
* @param bucket Bucket name
|
|
7
|
+
* @param key Object key
|
|
8
|
+
* @param body Data to upload
|
|
9
|
+
* @param options Upload options
|
|
10
|
+
*/
|
|
11
|
+
export declare function upload(s3: S3Instance, bucket: string, key: string, body: Buffer | Readable | string, options?: UploadOptions): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Downloads an object from S3
|
|
14
|
+
* @param s3 S3 instance
|
|
15
|
+
* @param bucket Bucket name
|
|
16
|
+
* @param key Object key
|
|
17
|
+
* @param options Download options
|
|
18
|
+
* @returns Object body as a readable stream
|
|
19
|
+
*/
|
|
20
|
+
export declare function download(s3: S3Instance, bucket: string, key: string, options?: DownloadOptions): Promise<Readable | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Downloads an object as a buffer
|
|
23
|
+
* @param s3 S3 instance
|
|
24
|
+
* @param bucket Bucket name
|
|
25
|
+
* @param key Object key
|
|
26
|
+
* @returns Object body as a buffer
|
|
27
|
+
*/
|
|
28
|
+
export declare function downloadAsBuffer(s3: S3Instance, bucket: string, key: string): Promise<Buffer | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Downloads an object as a string
|
|
31
|
+
* @param s3 S3 instance
|
|
32
|
+
* @param bucket Bucket name
|
|
33
|
+
* @param key Object key
|
|
34
|
+
* @param encoding String encoding
|
|
35
|
+
* @returns Object body as a string
|
|
36
|
+
*/
|
|
37
|
+
export declare function downloadAsString(s3: S3Instance, bucket: string, key: string, encoding?: globalThis.BufferEncoding): Promise<string | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes an object from S3
|
|
40
|
+
* @param s3 S3 instance
|
|
41
|
+
* @param bucket Bucket name
|
|
42
|
+
* @param key Object key
|
|
43
|
+
*/
|
|
44
|
+
export declare function deleteObject(s3: S3Instance, bucket: string, key: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes multiple objects from S3
|
|
47
|
+
* @param s3 S3 instance
|
|
48
|
+
* @param bucket Bucket name
|
|
49
|
+
* @param keys Object keys to delete
|
|
50
|
+
*/
|
|
51
|
+
export declare function deleteObjects(s3: S3Instance, bucket: string, keys: string[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if an object exists in S3
|
|
54
|
+
* @param s3 S3 instance
|
|
55
|
+
* @param bucket Bucket name
|
|
56
|
+
* @param key Object key
|
|
57
|
+
* @returns True if object exists
|
|
58
|
+
*/
|
|
59
|
+
export declare function exists(s3: S3Instance, bucket: string, key: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Gets object metadata from S3
|
|
62
|
+
* @param s3 S3 instance
|
|
63
|
+
* @param bucket Bucket name
|
|
64
|
+
* @param key Object key
|
|
65
|
+
* @returns Object metadata or null if not found
|
|
66
|
+
*/
|
|
67
|
+
export declare function getMetadata(s3: S3Instance, bucket: string, key: string): Promise<S3ObjectMetadata | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Lists objects in an S3 bucket
|
|
70
|
+
* @param s3 S3 instance
|
|
71
|
+
* @param bucket Bucket name
|
|
72
|
+
* @param options List options
|
|
73
|
+
* @returns List of object metadata and continuation token
|
|
74
|
+
*/
|
|
75
|
+
export declare function listObjects(s3: S3Instance, bucket: string, options?: ListObjectsOptions): Promise<{
|
|
76
|
+
objects: S3ObjectMetadata[];
|
|
77
|
+
continuationToken?: string;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Copies an object within S3
|
|
81
|
+
* @param s3 S3 instance
|
|
82
|
+
* @param sourceBucket Source bucket
|
|
83
|
+
* @param sourceKey Source key
|
|
84
|
+
* @param destBucket Destination bucket
|
|
85
|
+
* @param destKey Destination key
|
|
86
|
+
*/
|
|
87
|
+
export declare function copyObject(s3: S3Instance, sourceBucket: string, sourceKey: string, destBucket: string, destKey: string): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Generates a presigned URL for downloading
|
|
90
|
+
* @param s3 S3 instance
|
|
91
|
+
* @param bucket Bucket name
|
|
92
|
+
* @param key Object key
|
|
93
|
+
* @param options Presigned URL options
|
|
94
|
+
* @returns Presigned URL
|
|
95
|
+
*/
|
|
96
|
+
export declare function getPresignedDownloadUrl(s3: S3Instance, bucket: string, key: string, options?: PresignedUrlOptions): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Generates a presigned URL for uploading
|
|
99
|
+
* @param s3 S3 instance
|
|
100
|
+
* @param bucket Bucket name
|
|
101
|
+
* @param key Object key
|
|
102
|
+
* @param options Presigned URL options
|
|
103
|
+
* @returns Presigned URL
|
|
104
|
+
*/
|
|
105
|
+
export declare function getPresignedUploadUrl(s3: S3Instance, bucket: string, key: string, options?: PresignedUrlOptions): Promise<string>;
|
|
106
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/aws/s3/operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAExI;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAetJ;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI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