@bubblelab/bubble-core 0.1.200 → 0.1.202
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/dist/bubble-bundle.d.ts +189 -168
- package/dist/bubble-factory.d.ts.map +1 -1
- package/dist/bubble-factory.js +4 -0
- package/dist/bubble-factory.js.map +1 -1
- package/dist/bubbles/service-bubble/agi-inc.d.ts +110 -110
- package/dist/bubbles/service-bubble/agi-inc.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/agi-inc.js +4 -6
- package/dist/bubbles/service-bubble/agi-inc.js.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ai-agent.js +12 -4
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -1
- package/dist/bubbles/service-bubble/airtable.d.ts +76 -76
- package/dist/bubbles/service-bubble/airtable.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/airtable.js +8 -13
- package/dist/bubbles/service-bubble/airtable.js.map +1 -1
- package/dist/bubbles/service-bubble/apify/actors/google-maps-scraper.d.ts +8 -8
- package/dist/bubbles/service-bubble/apify/actors/instagram-hashtag-scraper.d.ts +6 -6
- package/dist/bubbles/service-bubble/apify/actors/instagram-scraper.d.ts +20 -20
- package/dist/bubbles/service-bubble/apify/actors/linkedin-posts-search.d.ts +20 -20
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-detail.d.ts +90 -90
- package/dist/bubbles/service-bubble/apify/actors/linkedin-profile-posts.d.ts +30 -30
- package/dist/bubbles/service-bubble/apify/actors/tiktok-scraper.d.ts +22 -22
- package/dist/bubbles/service-bubble/apify/actors/twitter-scraper.d.ts +35 -35
- package/dist/bubbles/service-bubble/apify/actors/youtube-scraper.d.ts +14 -14
- package/dist/bubbles/service-bubble/apify/apify-scraper.schema.d.ts +223 -223
- package/dist/bubbles/service-bubble/apify/apify.d.ts +4 -4
- package/dist/bubbles/service-bubble/ashby/ashby.d.ts +68 -68
- package/dist/bubbles/service-bubble/ashby/ashby.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/ashby/ashby.js +8 -10
- package/dist/bubbles/service-bubble/ashby/ashby.js.map +1 -1
- package/dist/bubbles/service-bubble/ashby/ashby.schema.d.ts +44 -44
- package/dist/bubbles/service-bubble/attio/attio.d.ts +42 -42
- package/dist/bubbles/service-bubble/attio/attio.schema.d.ts +76 -76
- package/dist/bubbles/service-bubble/browserbase/browserbase.d.ts +37 -37
- package/dist/bubbles/service-bubble/browserbase/browserbase.schema.d.ts +53 -53
- package/dist/bubbles/service-bubble/confluence/confluence.d.ts +33 -33
- package/dist/bubbles/service-bubble/confluence/confluence.schema.d.ts +44 -44
- package/dist/bubbles/service-bubble/crustdata/crustdata.d.ts +61 -61
- package/dist/bubbles/service-bubble/crustdata/crustdata.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/crustdata/crustdata.js +16 -17
- package/dist/bubbles/service-bubble/crustdata/crustdata.js.map +1 -1
- package/dist/bubbles/service-bubble/crustdata/crustdata.schema.d.ts +80 -80
- package/dist/bubbles/service-bubble/eleven-labs.d.ts +36 -36
- package/dist/bubbles/service-bubble/eleven-labs.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/eleven-labs.js +12 -14
- package/dist/bubbles/service-bubble/eleven-labs.js.map +1 -1
- package/dist/bubbles/service-bubble/firecrawl.d.ts +824 -824
- package/dist/bubbles/service-bubble/firecrawl.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/firecrawl.js +3 -12
- package/dist/bubbles/service-bubble/firecrawl.js.map +1 -1
- package/dist/bubbles/service-bubble/followupboss.d.ts +428 -428
- package/dist/bubbles/service-bubble/followupboss.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/followupboss.js +12 -13
- package/dist/bubbles/service-bubble/followupboss.js.map +1 -1
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.d.ts +300 -300
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.js +11 -12
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.js.map +1 -1
- package/dist/bubbles/service-bubble/fullenrich/fullenrich.schema.d.ts +268 -268
- package/dist/bubbles/service-bubble/github.d.ts +204 -204
- package/dist/bubbles/service-bubble/gmail.d.ts +158 -158
- package/dist/bubbles/service-bubble/google-calendar.d.ts +138 -138
- package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/google-calendar.js +10 -11
- package/dist/bubbles/service-bubble/google-calendar.js.map +1 -1
- package/dist/bubbles/service-bubble/google-drive.d.ts +110 -104
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/google-drive.js +8 -1
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -1
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.d.ts +52 -52
- package/dist/bubbles/service-bubble/google-sheets/google-sheets.schema.d.ts +78 -78
- package/dist/bubbles/service-bubble/hello-world.d.ts +4 -4
- package/dist/bubbles/service-bubble/http.d.ts +12 -12
- package/dist/bubbles/service-bubble/hubspot/hubspot.d.ts +39 -39
- package/dist/bubbles/service-bubble/hubspot/hubspot.schema.d.ts +20 -20
- package/dist/bubbles/service-bubble/insforge-db.d.ts +8 -8
- package/dist/bubbles/service-bubble/insforge-db.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/insforge-db.js +24 -26
- package/dist/bubbles/service-bubble/insforge-db.js.map +1 -1
- package/dist/bubbles/service-bubble/jira/jira.d.ts +61 -61
- package/dist/bubbles/service-bubble/jira/jira.schema.d.ts +70 -70
- package/dist/bubbles/service-bubble/linear/linear.d.ts +41 -41
- package/dist/bubbles/service-bubble/linear/linear.schema.d.ts +59 -59
- package/dist/bubbles/service-bubble/notion/notion.d.ts +1637 -1637
- package/dist/bubbles/service-bubble/notion/property-schemas.d.ts +8 -8
- package/dist/bubbles/service-bubble/postgresql.d.ts +8 -8
- package/dist/bubbles/service-bubble/posthog/posthog.d.ts +31 -31
- package/dist/bubbles/service-bubble/posthog/posthog.schema.d.ts +56 -56
- package/dist/bubbles/service-bubble/resend.d.ts +28 -28
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/resend.js +8 -13
- package/dist/bubbles/service-bubble/resend.js.map +1 -1
- package/dist/bubbles/service-bubble/s3/index.d.ts +4 -0
- package/dist/bubbles/service-bubble/s3/index.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/s3/index.js +4 -0
- package/dist/bubbles/service-bubble/s3/index.js.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.d.ts +301 -0
- package/dist/bubbles/service-bubble/s3/s3.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.js +320 -0
- package/dist/bubbles/service-bubble/s3/s3.js.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.schema.d.ts +262 -0
- package/dist/bubbles/service-bubble/s3/s3.schema.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.schema.js +212 -0
- package/dist/bubbles/service-bubble/s3/s3.schema.js.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.utils.d.ts +17 -0
- package/dist/bubbles/service-bubble/s3/s3.utils.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/s3/s3.utils.js +46 -0
- package/dist/bubbles/service-bubble/s3/s3.utils.js.map +1 -0
- package/dist/bubbles/service-bubble/sendsafely/sendsafely.d.ts +12 -12
- package/dist/bubbles/service-bubble/sendsafely/sendsafely.schema.d.ts +14 -14
- package/dist/bubbles/service-bubble/slack/slack.d.ts +609 -609
- package/dist/bubbles/service-bubble/storage.d.ts +40 -40
- package/dist/bubbles/service-bubble/stripe/stripe.d.ts +186 -186
- package/dist/bubbles/service-bubble/stripe/stripe.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/stripe/stripe.js +5 -7
- package/dist/bubbles/service-bubble/stripe/stripe.js.map +1 -1
- package/dist/bubbles/service-bubble/stripe/stripe.schema.d.ts +143 -143
- package/dist/bubbles/service-bubble/telegram.d.ts +1832 -1832
- package/dist/bubbles/service-bubble/telegram.d.ts.map +1 -1
- package/dist/bubbles/service-bubble/telegram.js +3 -3
- package/dist/bubbles/service-bubble/telegram.js.map +1 -1
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.d.ts +23 -23
- package/dist/bubbles/tool-bubble/amazon-shopping-tool/amazon-shopping-tool.schema.d.ts +39 -39
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/schema.d.ts +5 -5
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-accept-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/schema.d.ts +4 -4
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-connection/tool.d.ts +6 -6
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/schema.d.ts +4 -4
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-received-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/schema.d.ts +4 -4
- package/dist/bubbles/tool-bubble/browser-tools/linkedin-sent-invitations/tool.d.ts +2 -2
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +16 -16
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +22 -22
- package/dist/bubbles/tool-bubble/code-edit-tool.d.ts.map +1 -1
- package/dist/bubbles/tool-bubble/code-edit-tool.js +3 -1
- package/dist/bubbles/tool-bubble/code-edit-tool.js.map +1 -1
- package/dist/bubbles/tool-bubble/company-enrichment-tool.d.ts +84 -84
- package/dist/bubbles/tool-bubble/google-maps-tool.d.ts +16 -16
- package/dist/bubbles/tool-bubble/instagram-tool.d.ts +22 -22
- package/dist/bubbles/tool-bubble/linkedin-tool.d.ts +622 -622
- package/dist/bubbles/tool-bubble/list-capabilities-tool.d.ts +8 -8
- package/dist/bubbles/tool-bubble/people-search-tool.d.ts +124 -124
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +26 -26
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +4 -4
- package/dist/bubbles/tool-bubble/tiktok-tool.d.ts +36 -36
- package/dist/bubbles/tool-bubble/twitter-tool.d.ts +82 -82
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +14 -14
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +12 -12
- package/dist/bubbles/tool-bubble/yc-scraper-tool.d.ts +24 -24
- package/dist/bubbles/tool-bubble/youtube-tool.d.ts +18 -18
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +24 -24
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +4 -4
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +66 -66
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +8 -8
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +28 -28
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +52 -52
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +4 -4
- package/dist/bubbles.json +489 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { S3Client, PutObjectCommand, GetObjectCommand, DeleteObjectCommand, HeadObjectCommand, ListBucketsCommand, } from '@aws-sdk/client-s3';
|
|
2
|
+
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
3
|
+
import { ServiceBubble } from '../../../types/service-bubble-class.js';
|
|
4
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
5
|
+
import { S3ParamsSchema, S3ResultSchema, } from './s3.schema.js';
|
|
6
|
+
import { parseS3Credential, isBase64 } from './s3.utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* S3 Storage Service Bubble
|
|
9
|
+
*
|
|
10
|
+
* S3-compatible storage operations for file management.
|
|
11
|
+
* Works with AWS S3, MinIO, DigitalOcean Spaces, Backblaze B2, and other
|
|
12
|
+
* S3-compatible providers via a configurable endpoint.
|
|
13
|
+
*
|
|
14
|
+
* Uses a single bundled credential (S3_CRED) containing:
|
|
15
|
+
* - accessKeyId, secretAccessKey (required)
|
|
16
|
+
* - endpoint (optional, for non-AWS providers)
|
|
17
|
+
* - region (optional, defaults to us-east-1)
|
|
18
|
+
*/
|
|
19
|
+
export class S3Bubble extends ServiceBubble {
|
|
20
|
+
static service = 's3';
|
|
21
|
+
static authType = 'apikey';
|
|
22
|
+
static bubbleName = 's3-storage';
|
|
23
|
+
static type = 'service';
|
|
24
|
+
static schema = S3ParamsSchema;
|
|
25
|
+
static resultSchema = S3ResultSchema;
|
|
26
|
+
static shortDescription = 'S3-compatible storage operations for file management';
|
|
27
|
+
static longDescription = `
|
|
28
|
+
A comprehensive storage bubble for S3-compatible storage providers.
|
|
29
|
+
Works with AWS S3, MinIO, DigitalOcean Spaces, Backblaze B2, and more.
|
|
30
|
+
Use cases:
|
|
31
|
+
- Generate presigned upload URLs for client-side file uploads
|
|
32
|
+
- Get secure download URLs for file retrieval with authentication
|
|
33
|
+
- Delete files from S3 buckets
|
|
34
|
+
- Update/replace files in S3 buckets (supports base64 encoded content for binary files like images)
|
|
35
|
+
- Manage file access with time-limited URLs
|
|
36
|
+
`;
|
|
37
|
+
static alias = 's3';
|
|
38
|
+
s3Client = null;
|
|
39
|
+
constructor(params = {
|
|
40
|
+
operation: 'getUploadUrl',
|
|
41
|
+
bucketName: 'my-bucket',
|
|
42
|
+
fileName: 'example.txt',
|
|
43
|
+
}, context, instanceId) {
|
|
44
|
+
super(params, context, instanceId);
|
|
45
|
+
}
|
|
46
|
+
chooseCredential() {
|
|
47
|
+
const { credentials } = this.params;
|
|
48
|
+
if (!credentials || typeof credentials !== 'object') {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return credentials[CredentialType.S3_CRED];
|
|
52
|
+
}
|
|
53
|
+
initializeS3Client(regionOverride) {
|
|
54
|
+
const credentialValue = this.chooseCredential();
|
|
55
|
+
if (!credentialValue) {
|
|
56
|
+
throw new Error('S3 credentials not found. Provide an S3_CRED credential.');
|
|
57
|
+
}
|
|
58
|
+
const creds = parseS3Credential(credentialValue);
|
|
59
|
+
// Region: explicit override > per-operation > credential > default
|
|
60
|
+
const region = regionOverride || this.params.region || creds.region || 'us-east-1';
|
|
61
|
+
const clientConfig = {
|
|
62
|
+
region,
|
|
63
|
+
credentials: {
|
|
64
|
+
accessKeyId: creds.accessKeyId,
|
|
65
|
+
secretAccessKey: creds.secretAccessKey,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
// Only set endpoint for non-AWS providers
|
|
69
|
+
if (creds.endpoint) {
|
|
70
|
+
clientConfig.endpoint = creds.endpoint;
|
|
71
|
+
clientConfig.forcePathStyle = true;
|
|
72
|
+
}
|
|
73
|
+
this.s3Client = new S3Client(clientConfig);
|
|
74
|
+
return creds;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Extract the correct region from an S3 PermanentRedirect error.
|
|
78
|
+
* AWS returns the correct endpoint in the error message, e.g.
|
|
79
|
+
* "...endpoint: gymii-test.s3.us-east-2.amazonaws.com"
|
|
80
|
+
*/
|
|
81
|
+
extractRegionFromRedirectError(error) {
|
|
82
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
83
|
+
// Match patterns like "bucketname.s3.us-east-2.amazonaws.com" or just "s3.us-west-1.amazonaws.com"
|
|
84
|
+
const match = message.match(/s3[.-]([a-z0-9-]+)\.amazonaws\.com/);
|
|
85
|
+
return match?.[1];
|
|
86
|
+
}
|
|
87
|
+
async testCredential() {
|
|
88
|
+
const credential = this.chooseCredential();
|
|
89
|
+
if (!credential) {
|
|
90
|
+
throw new Error('S3 credentials not provided');
|
|
91
|
+
}
|
|
92
|
+
const creds = parseS3Credential(credential);
|
|
93
|
+
if (!creds.accessKeyId || !creds.secretAccessKey) {
|
|
94
|
+
throw new Error('S3 credential is missing accessKeyId or secretAccessKey');
|
|
95
|
+
}
|
|
96
|
+
this.initializeS3Client();
|
|
97
|
+
if (!this.s3Client) {
|
|
98
|
+
throw new Error('Failed to initialize S3 client');
|
|
99
|
+
}
|
|
100
|
+
// Actually call S3 to verify the credentials work — let errors propagate
|
|
101
|
+
// so the validator can surface vendor-specific messages
|
|
102
|
+
await this.s3Client.send(new ListBucketsCommand({}));
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
async executeOperation() {
|
|
106
|
+
const { operation } = this.params;
|
|
107
|
+
switch (operation) {
|
|
108
|
+
case 'getUploadUrl':
|
|
109
|
+
return await this.getUploadUrl(this.params);
|
|
110
|
+
case 'getFile':
|
|
111
|
+
return await this.getFile(this.params);
|
|
112
|
+
case 'deleteFile':
|
|
113
|
+
return await this.deleteFile(this.params);
|
|
114
|
+
case 'updateFile':
|
|
115
|
+
return await this.updateFile(this.params);
|
|
116
|
+
case 'getMultipleUploadUrls':
|
|
117
|
+
return await this.getMultipleUploadUrls(this.params);
|
|
118
|
+
default:
|
|
119
|
+
throw new Error(`Unsupported operation: ${operation}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async performAction(context) {
|
|
123
|
+
void context;
|
|
124
|
+
const { operation } = this.params;
|
|
125
|
+
try {
|
|
126
|
+
this.initializeS3Client();
|
|
127
|
+
if (!this.s3Client) {
|
|
128
|
+
throw new Error('Failed to initialize S3 client');
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const result = await this.executeOperation();
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
// Auto-retry on region mismatch (PermanentRedirect)
|
|
136
|
+
const redirectRegion = this.extractRegionFromRedirectError(error);
|
|
137
|
+
if (redirectRegion) {
|
|
138
|
+
console.log(`[S3Bubble] Region redirect detected, retrying with region: ${redirectRegion}`);
|
|
139
|
+
this.initializeS3Client(redirectRegion);
|
|
140
|
+
const result = await this.executeOperation();
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return {
|
|
148
|
+
operation,
|
|
149
|
+
success: false,
|
|
150
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async getUploadUrl(params) {
|
|
155
|
+
if (!this.s3Client)
|
|
156
|
+
throw new Error('S3 client not initialized');
|
|
157
|
+
// Generate secure filename with timestamp and optional userId for isolation
|
|
158
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
159
|
+
const fileExtension = params.fileName.split('.').pop() || 'bin';
|
|
160
|
+
const baseName = params.fileName.replace(/\.[^/.]+$/, '');
|
|
161
|
+
const sanitizedBaseName = baseName.replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
162
|
+
const userPrefix = params.userId ? `${params.userId}/` : '';
|
|
163
|
+
const secureFileName = `${userPrefix}${timestamp}-${sanitizedBaseName}.${fileExtension}`;
|
|
164
|
+
const command = new PutObjectCommand({
|
|
165
|
+
Bucket: params.bucketName,
|
|
166
|
+
Key: secureFileName,
|
|
167
|
+
ContentType: params.contentType,
|
|
168
|
+
});
|
|
169
|
+
const uploadUrl = await getSignedUrl(this.s3Client, command, {
|
|
170
|
+
expiresIn: params.expirationMinutes * 60,
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
operation: 'getUploadUrl',
|
|
174
|
+
success: true,
|
|
175
|
+
uploadUrl,
|
|
176
|
+
fileName: secureFileName,
|
|
177
|
+
contentType: params.contentType,
|
|
178
|
+
error: '',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async getFile(params) {
|
|
182
|
+
if (!this.s3Client)
|
|
183
|
+
throw new Error('S3 client not initialized');
|
|
184
|
+
const command = new GetObjectCommand({
|
|
185
|
+
Bucket: params.bucketName,
|
|
186
|
+
Key: params.fileName,
|
|
187
|
+
});
|
|
188
|
+
const downloadUrl = await getSignedUrl(this.s3Client, command, {
|
|
189
|
+
expiresIn: params.expirationMinutes * 60,
|
|
190
|
+
});
|
|
191
|
+
// Also get file metadata
|
|
192
|
+
try {
|
|
193
|
+
const headCommand = new HeadObjectCommand({
|
|
194
|
+
Bucket: params.bucketName,
|
|
195
|
+
Key: params.fileName,
|
|
196
|
+
});
|
|
197
|
+
const metadata = await this.s3Client.send(headCommand);
|
|
198
|
+
return {
|
|
199
|
+
operation: 'getFile',
|
|
200
|
+
success: true,
|
|
201
|
+
downloadUrl,
|
|
202
|
+
fileUrl: downloadUrl,
|
|
203
|
+
fileName: params.fileName,
|
|
204
|
+
fileSize: metadata.ContentLength,
|
|
205
|
+
contentType: metadata.ContentType,
|
|
206
|
+
lastModified: metadata.LastModified?.toISOString(),
|
|
207
|
+
error: '',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
// If metadata fetch fails, still return the download URL
|
|
212
|
+
return {
|
|
213
|
+
operation: 'getFile',
|
|
214
|
+
success: true,
|
|
215
|
+
downloadUrl,
|
|
216
|
+
fileUrl: downloadUrl,
|
|
217
|
+
fileName: params.fileName,
|
|
218
|
+
error: '',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async deleteFile(params) {
|
|
223
|
+
if (!this.s3Client)
|
|
224
|
+
throw new Error('S3 client not initialized');
|
|
225
|
+
const command = new DeleteObjectCommand({
|
|
226
|
+
Bucket: params.bucketName,
|
|
227
|
+
Key: params.fileName,
|
|
228
|
+
});
|
|
229
|
+
await this.s3Client.send(command);
|
|
230
|
+
return {
|
|
231
|
+
operation: 'deleteFile',
|
|
232
|
+
success: true,
|
|
233
|
+
fileName: params.fileName,
|
|
234
|
+
deleted: true,
|
|
235
|
+
error: '',
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
async updateFile(params) {
|
|
239
|
+
if (!this.s3Client)
|
|
240
|
+
throw new Error('S3 client not initialized');
|
|
241
|
+
// Generate secure filename with timestamp
|
|
242
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
243
|
+
const fileExtension = params.fileName.split('.').pop() || 'bin';
|
|
244
|
+
const baseName = params.fileName.replace(/\.[^/.]+$/, '');
|
|
245
|
+
const sanitizedBaseName = baseName.replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
246
|
+
const secureFileName = `${timestamp}-${crypto.randomUUID()}-${sanitizedBaseName}.${fileExtension}`;
|
|
247
|
+
// Handle base64 encoded content
|
|
248
|
+
let bodyContent;
|
|
249
|
+
if (isBase64(params.fileContent)) {
|
|
250
|
+
const base64Data = params.fileContent.replace(/^data:[^;]+;base64,/, '');
|
|
251
|
+
bodyContent = Buffer.from(base64Data, 'base64');
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
bodyContent = params.fileContent;
|
|
255
|
+
}
|
|
256
|
+
const command = new PutObjectCommand({
|
|
257
|
+
Bucket: params.bucketName,
|
|
258
|
+
Key: secureFileName,
|
|
259
|
+
ContentType: params.contentType,
|
|
260
|
+
Body: bodyContent,
|
|
261
|
+
});
|
|
262
|
+
await this.s3Client.send(command);
|
|
263
|
+
return {
|
|
264
|
+
operation: 'updateFile',
|
|
265
|
+
success: true,
|
|
266
|
+
fileName: secureFileName,
|
|
267
|
+
updated: true,
|
|
268
|
+
contentType: params.contentType,
|
|
269
|
+
error: '',
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
async getMultipleUploadUrls(params) {
|
|
273
|
+
if (!this.s3Client)
|
|
274
|
+
throw new Error('S3 client not initialized');
|
|
275
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
276
|
+
const userPrefix = params.userId ? `${params.userId}/` : '';
|
|
277
|
+
// Generate secure PDF filename
|
|
278
|
+
const pdfExtension = params.pdfFileName.split('.').pop() || 'pdf';
|
|
279
|
+
const pdfBaseName = params.pdfFileName
|
|
280
|
+
.replace(/\.[^/.]+$/, '')
|
|
281
|
+
.replace(/[^a-zA-Z0-9-_]/g, '_');
|
|
282
|
+
const securePdfFileName = `${userPrefix}${timestamp}-${pdfBaseName}.${pdfExtension}`;
|
|
283
|
+
// Generate PDF upload URL
|
|
284
|
+
const pdfCommand = new PutObjectCommand({
|
|
285
|
+
Bucket: params.bucketName,
|
|
286
|
+
Key: securePdfFileName,
|
|
287
|
+
ContentType: 'application/pdf',
|
|
288
|
+
});
|
|
289
|
+
const pdfUploadUrl = await getSignedUrl(this.s3Client, pdfCommand, {
|
|
290
|
+
expiresIn: params.expirationMinutes * 60,
|
|
291
|
+
});
|
|
292
|
+
// Generate page image upload URLs
|
|
293
|
+
const pageUploadUrls = [];
|
|
294
|
+
for (let pageNum = 1; pageNum <= params.pageCount; pageNum++) {
|
|
295
|
+
const pageFileName = `${userPrefix}${timestamp}-${pdfBaseName}_page${pageNum}.jpeg`;
|
|
296
|
+
const pageCommand = new PutObjectCommand({
|
|
297
|
+
Bucket: params.bucketName,
|
|
298
|
+
Key: pageFileName,
|
|
299
|
+
ContentType: 'image/jpeg',
|
|
300
|
+
});
|
|
301
|
+
const pageUploadUrl = await getSignedUrl(this.s3Client, pageCommand, {
|
|
302
|
+
expiresIn: params.expirationMinutes * 60,
|
|
303
|
+
});
|
|
304
|
+
pageUploadUrls.push({
|
|
305
|
+
pageNumber: pageNum,
|
|
306
|
+
uploadUrl: pageUploadUrl,
|
|
307
|
+
fileName: pageFileName,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
operation: 'getMultipleUploadUrls',
|
|
312
|
+
success: true,
|
|
313
|
+
pdfUploadUrl,
|
|
314
|
+
pdfFileName: securePdfFileName,
|
|
315
|
+
pageUploadUrls,
|
|
316
|
+
error: '',
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=s3.js.map
|
|
@@ -0,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ACZ,WAAW,EAAE,iBAAiB;YAC9B,cAAc;YACd,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
3
|
+
export declare const S3ParamsSchema: z.ZodDiscriminatedUnion<"operation", [z.ZodObject<{
|
|
4
|
+
operation: z.ZodLiteral<"getUploadUrl">;
|
|
5
|
+
bucketName: z.ZodString;
|
|
6
|
+
fileName: z.ZodString;
|
|
7
|
+
region: z.ZodOptional<z.ZodString>;
|
|
8
|
+
expirationMinutes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
10
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
operation: "getUploadUrl";
|
|
14
|
+
bucketName: string;
|
|
15
|
+
fileName: string;
|
|
16
|
+
expirationMinutes: number;
|
|
17
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
18
|
+
contentType?: string | undefined;
|
|
19
|
+
region?: string | undefined;
|
|
20
|
+
userId?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
operation: "getUploadUrl";
|
|
23
|
+
bucketName: string;
|
|
24
|
+
fileName: string;
|
|
25
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
26
|
+
contentType?: string | undefined;
|
|
27
|
+
region?: string | undefined;
|
|
28
|
+
expirationMinutes?: number | undefined;
|
|
29
|
+
userId?: string | undefined;
|
|
30
|
+
}>, z.ZodObject<{
|
|
31
|
+
operation: z.ZodLiteral<"getFile">;
|
|
32
|
+
bucketName: z.ZodString;
|
|
33
|
+
fileName: z.ZodString;
|
|
34
|
+
region: z.ZodOptional<z.ZodString>;
|
|
35
|
+
expirationMinutes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
36
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
37
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
operation: "getFile";
|
|
40
|
+
bucketName: string;
|
|
41
|
+
fileName: string;
|
|
42
|
+
expirationMinutes: number;
|
|
43
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
44
|
+
region?: string | undefined;
|
|
45
|
+
userId?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
operation: "getFile";
|
|
48
|
+
bucketName: string;
|
|
49
|
+
fileName: string;
|
|
50
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
51
|
+
region?: string | undefined;
|
|
52
|
+
expirationMinutes?: number | undefined;
|
|
53
|
+
userId?: string | undefined;
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
operation: z.ZodLiteral<"deleteFile">;
|
|
56
|
+
bucketName: z.ZodString;
|
|
57
|
+
fileName: z.ZodString;
|
|
58
|
+
region: z.ZodOptional<z.ZodString>;
|
|
59
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
operation: "deleteFile";
|
|
62
|
+
bucketName: string;
|
|
63
|
+
fileName: string;
|
|
64
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
65
|
+
region?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
operation: "deleteFile";
|
|
68
|
+
bucketName: string;
|
|
69
|
+
fileName: string;
|
|
70
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
71
|
+
region?: string | undefined;
|
|
72
|
+
}>, z.ZodObject<{
|
|
73
|
+
operation: z.ZodLiteral<"updateFile">;
|
|
74
|
+
bucketName: z.ZodDefault<z.ZodString>;
|
|
75
|
+
fileName: z.ZodString;
|
|
76
|
+
region: z.ZodOptional<z.ZodString>;
|
|
77
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
78
|
+
fileContent: z.ZodString;
|
|
79
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
operation: "updateFile";
|
|
82
|
+
bucketName: string;
|
|
83
|
+
fileName: string;
|
|
84
|
+
fileContent: string;
|
|
85
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
86
|
+
contentType?: string | undefined;
|
|
87
|
+
region?: string | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
operation: "updateFile";
|
|
90
|
+
fileName: string;
|
|
91
|
+
fileContent: string;
|
|
92
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
93
|
+
contentType?: string | undefined;
|
|
94
|
+
bucketName?: string | undefined;
|
|
95
|
+
region?: string | undefined;
|
|
96
|
+
}>, z.ZodObject<{
|
|
97
|
+
operation: z.ZodLiteral<"getMultipleUploadUrls">;
|
|
98
|
+
bucketName: z.ZodString;
|
|
99
|
+
pdfFileName: z.ZodString;
|
|
100
|
+
pageCount: z.ZodNumber;
|
|
101
|
+
region: z.ZodOptional<z.ZodString>;
|
|
102
|
+
expirationMinutes: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
103
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
104
|
+
credentials: z.ZodOptional<z.ZodRecord<z.ZodNativeEnum<typeof CredentialType>, z.ZodString>>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
operation: "getMultipleUploadUrls";
|
|
107
|
+
bucketName: string;
|
|
108
|
+
expirationMinutes: number;
|
|
109
|
+
pdfFileName: string;
|
|
110
|
+
pageCount: number;
|
|
111
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
112
|
+
region?: string | undefined;
|
|
113
|
+
userId?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
operation: "getMultipleUploadUrls";
|
|
116
|
+
bucketName: string;
|
|
117
|
+
pdfFileName: string;
|
|
118
|
+
pageCount: number;
|
|
119
|
+
credentials?: Partial<Record<CredentialType, string>> | undefined;
|
|
120
|
+
region?: string | undefined;
|
|
121
|
+
expirationMinutes?: number | undefined;
|
|
122
|
+
userId?: string | undefined;
|
|
123
|
+
}>]>;
|
|
124
|
+
export declare const S3ResultSchema: z.ZodDiscriminatedUnion<"operation", [z.ZodObject<{
|
|
125
|
+
operation: z.ZodLiteral<"getUploadUrl">;
|
|
126
|
+
success: z.ZodBoolean;
|
|
127
|
+
uploadUrl: z.ZodOptional<z.ZodString>;
|
|
128
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
129
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
130
|
+
error: z.ZodString;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
operation: "getUploadUrl";
|
|
133
|
+
error: string;
|
|
134
|
+
success: boolean;
|
|
135
|
+
contentType?: string | undefined;
|
|
136
|
+
fileName?: string | undefined;
|
|
137
|
+
uploadUrl?: string | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
operation: "getUploadUrl";
|
|
140
|
+
error: string;
|
|
141
|
+
success: boolean;
|
|
142
|
+
contentType?: string | undefined;
|
|
143
|
+
fileName?: string | undefined;
|
|
144
|
+
uploadUrl?: string | undefined;
|
|
145
|
+
}>, z.ZodObject<{
|
|
146
|
+
operation: z.ZodLiteral<"getFile">;
|
|
147
|
+
success: z.ZodBoolean;
|
|
148
|
+
downloadUrl: z.ZodOptional<z.ZodString>;
|
|
149
|
+
fileUrl: z.ZodOptional<z.ZodString>;
|
|
150
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
151
|
+
fileSize: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
153
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
154
|
+
error: z.ZodString;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
operation: "getFile";
|
|
157
|
+
error: string;
|
|
158
|
+
success: boolean;
|
|
159
|
+
contentType?: string | undefined;
|
|
160
|
+
fileName?: string | undefined;
|
|
161
|
+
downloadUrl?: string | undefined;
|
|
162
|
+
fileUrl?: string | undefined;
|
|
163
|
+
fileSize?: number | undefined;
|
|
164
|
+
lastModified?: string | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
operation: "getFile";
|
|
167
|
+
error: string;
|
|
168
|
+
success: boolean;
|
|
169
|
+
contentType?: string | undefined;
|
|
170
|
+
fileName?: string | undefined;
|
|
171
|
+
downloadUrl?: string | undefined;
|
|
172
|
+
fileUrl?: string | undefined;
|
|
173
|
+
fileSize?: number | undefined;
|
|
174
|
+
lastModified?: string | undefined;
|
|
175
|
+
}>, z.ZodObject<{
|
|
176
|
+
operation: z.ZodLiteral<"deleteFile">;
|
|
177
|
+
success: z.ZodBoolean;
|
|
178
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
179
|
+
deleted: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
error: z.ZodString;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
operation: "deleteFile";
|
|
183
|
+
error: string;
|
|
184
|
+
success: boolean;
|
|
185
|
+
deleted?: boolean | undefined;
|
|
186
|
+
fileName?: string | undefined;
|
|
187
|
+
}, {
|
|
188
|
+
operation: "deleteFile";
|
|
189
|
+
error: string;
|
|
190
|
+
success: boolean;
|
|
191
|
+
deleted?: boolean | undefined;
|
|
192
|
+
fileName?: string | undefined;
|
|
193
|
+
}>, z.ZodObject<{
|
|
194
|
+
operation: z.ZodLiteral<"updateFile">;
|
|
195
|
+
success: z.ZodBoolean;
|
|
196
|
+
fileName: z.ZodOptional<z.ZodString>;
|
|
197
|
+
updated: z.ZodOptional<z.ZodBoolean>;
|
|
198
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
199
|
+
error: z.ZodString;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
operation: "updateFile";
|
|
202
|
+
error: string;
|
|
203
|
+
success: boolean;
|
|
204
|
+
contentType?: string | undefined;
|
|
205
|
+
updated?: boolean | undefined;
|
|
206
|
+
fileName?: string | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
operation: "updateFile";
|
|
209
|
+
error: string;
|
|
210
|
+
success: boolean;
|
|
211
|
+
contentType?: string | undefined;
|
|
212
|
+
updated?: boolean | undefined;
|
|
213
|
+
fileName?: string | undefined;
|
|
214
|
+
}>, z.ZodObject<{
|
|
215
|
+
operation: z.ZodLiteral<"getMultipleUploadUrls">;
|
|
216
|
+
success: z.ZodBoolean;
|
|
217
|
+
pdfUploadUrl: z.ZodOptional<z.ZodString>;
|
|
218
|
+
pdfFileName: z.ZodOptional<z.ZodString>;
|
|
219
|
+
pageUploadUrls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
220
|
+
pageNumber: z.ZodNumber;
|
|
221
|
+
uploadUrl: z.ZodString;
|
|
222
|
+
fileName: z.ZodString;
|
|
223
|
+
}, "strip", z.ZodTypeAny, {
|
|
224
|
+
fileName: string;
|
|
225
|
+
uploadUrl: string;
|
|
226
|
+
pageNumber: number;
|
|
227
|
+
}, {
|
|
228
|
+
fileName: string;
|
|
229
|
+
uploadUrl: string;
|
|
230
|
+
pageNumber: number;
|
|
231
|
+
}>, "many">>;
|
|
232
|
+
error: z.ZodString;
|
|
233
|
+
}, "strip", z.ZodTypeAny, {
|
|
234
|
+
operation: "getMultipleUploadUrls";
|
|
235
|
+
error: string;
|
|
236
|
+
success: boolean;
|
|
237
|
+
pdfFileName?: string | undefined;
|
|
238
|
+
pdfUploadUrl?: string | undefined;
|
|
239
|
+
pageUploadUrls?: {
|
|
240
|
+
fileName: string;
|
|
241
|
+
uploadUrl: string;
|
|
242
|
+
pageNumber: number;
|
|
243
|
+
}[] | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
operation: "getMultipleUploadUrls";
|
|
246
|
+
error: string;
|
|
247
|
+
success: boolean;
|
|
248
|
+
pdfFileName?: string | undefined;
|
|
249
|
+
pdfUploadUrl?: string | undefined;
|
|
250
|
+
pageUploadUrls?: {
|
|
251
|
+
fileName: string;
|
|
252
|
+
uploadUrl: string;
|
|
253
|
+
pageNumber: number;
|
|
254
|
+
}[] | undefined;
|
|
255
|
+
}>]>;
|
|
256
|
+
export type S3Result = z.output<typeof S3ResultSchema>;
|
|
257
|
+
export type S3Params = z.output<typeof S3ParamsSchema>;
|
|
258
|
+
export type S3ParamsInput = z.input<typeof S3ParamsSchema>;
|
|
259
|
+
export type S3OperationResult<T extends S3Params['operation']> = Extract<S3Result, {
|
|
260
|
+
operation: T;
|
|
261
|
+
}>;
|
|
262
|
+
//# sourceMappingURL=s3.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.schema.d.ts","sourceRoot":"","sources":["../../../../src/bubbles/service-bubble/s3/s3.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAS3D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4HzB,CAAC;AAGH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA8FzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AACvD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AACvD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG3D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CACtE,QAAQ,EACR;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CACjB,CAAC"}
|