@absolutejs/absolute 0.19.0-beta.500 → 0.19.0-beta.501

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/ai/index.js CHANGED
@@ -7186,6 +7186,7 @@ var resolveRAGStreamStage = ({
7186
7186
  return "streaming";
7187
7187
  };
7188
7188
  // src/ai/rag/sync.ts
7189
+ var {S3Client } = globalThis.Bun;
7189
7190
  import { createHash } from "crypto";
7190
7191
  import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
7191
7192
  import { dirname, resolve as resolve2 } from "path";
@@ -7337,6 +7338,110 @@ var createRAGUrlSyncSource = (options) => ({
7337
7338
  };
7338
7339
  }
7339
7340
  });
7341
+ var createRAGBunS3SyncClient = (input) => {
7342
+ const client = input instanceof S3Client ? input : new S3Client(input);
7343
+ return {
7344
+ file: (key) => client.file(key),
7345
+ list: async (options) => {
7346
+ const result = await client.list({
7347
+ maxKeys: options?.maxKeys,
7348
+ prefix: options?.prefix,
7349
+ startAfter: options?.startAfter
7350
+ });
7351
+ return {
7352
+ contents: (result.contents ?? []).map((entry) => ({
7353
+ etag: entry.eTag,
7354
+ key: entry.key,
7355
+ lastModified: entry.lastModified,
7356
+ size: entry.size
7357
+ })),
7358
+ isTruncated: result.isTruncated,
7359
+ nextContinuationToken: result.nextContinuationToken
7360
+ };
7361
+ }
7362
+ };
7363
+ };
7364
+ var createRAGStorageSyncSource = (options) => ({
7365
+ description: options.description,
7366
+ id: options.id,
7367
+ kind: "storage",
7368
+ label: options.label,
7369
+ metadata: options.metadata,
7370
+ retryAttempts: options.retryAttempts,
7371
+ retryDelayMs: options.retryDelayMs,
7372
+ target: options.keys?.length ? `${options.keys.length} object${options.keys.length === 1 ? "" : "s"}` : options.prefix ?? "storage://",
7373
+ sync: async ({ collection, deleteDocument, listDocuments }) => {
7374
+ const keys = options.keys && options.keys.length > 0 ? options.keys : await (async () => {
7375
+ const listed = [];
7376
+ let startAfter;
7377
+ let remaining = options.maxKeys;
7378
+ for (;; ) {
7379
+ const response = await options.client.list({
7380
+ maxKeys: typeof remaining === "number" ? Math.max(1, remaining) : undefined,
7381
+ prefix: options.prefix,
7382
+ startAfter
7383
+ });
7384
+ for (const entry of response.contents) {
7385
+ listed.push(entry.key);
7386
+ startAfter = entry.key;
7387
+ if (typeof remaining === "number" && listed.length >= remaining) {
7388
+ return listed;
7389
+ }
7390
+ }
7391
+ if (!response.isTruncated || response.contents.length === 0) {
7392
+ return listed;
7393
+ }
7394
+ if (typeof remaining === "number") {
7395
+ remaining -= response.contents.length;
7396
+ if (remaining <= 0) {
7397
+ return listed;
7398
+ }
7399
+ }
7400
+ }
7401
+ })();
7402
+ const uploads = await Promise.all(keys.map(async (key) => {
7403
+ const object = options.client.file(key);
7404
+ const bytes = new Uint8Array(await object.arrayBuffer());
7405
+ return {
7406
+ chunking: options.defaultChunking,
7407
+ content: Buffer.from(bytes).toString("base64"),
7408
+ contentType: undefined,
7409
+ encoding: "base64",
7410
+ metadata: {
7411
+ ...options.baseMetadata ?? {},
7412
+ storageKey: key
7413
+ },
7414
+ name: key.split("/").at(-1) ?? key,
7415
+ source: `storage/${key}`,
7416
+ title: key.split("/").at(-1) ?? key
7417
+ };
7418
+ }));
7419
+ const loaded = await loadRAGDocumentsFromUploads({
7420
+ baseMetadata: options.baseMetadata,
7421
+ defaultChunking: options.defaultChunking,
7422
+ extractors: options.extractors,
7423
+ uploads
7424
+ });
7425
+ const managedDocuments = loaded.documents.map((document) => toManagedSyncDocument(options.id, document, typeof document.metadata?.storageKey === "string" ? document.metadata.storageKey : document.source ?? document.title ?? ""));
7426
+ const reconciled = await reconcileManagedDocuments({
7427
+ collection,
7428
+ deleteDocument,
7429
+ documents: managedDocuments,
7430
+ listDocuments,
7431
+ sourceId: options.id
7432
+ });
7433
+ return {
7434
+ chunkCount: reconciled.chunkCount,
7435
+ documentCount: reconciled.documentCount,
7436
+ metadata: {
7437
+ deletedCount: reconciled.deletedCount,
7438
+ keyCount: keys.length,
7439
+ prefix: options.prefix,
7440
+ updatedCount: reconciled.updatedCount
7441
+ }
7442
+ };
7443
+ }
7444
+ });
7340
7445
  var createRAGSyncManager = (options) => {
7341
7446
  const sourceMap = new Map(options.sources.map((source) => [source.id, source]));
7342
7447
  const state = new Map(options.sources.map((source) => [source.id, toSourceRecord(source)]));
@@ -9536,6 +9641,7 @@ export {
9536
9641
  createAIStream as createRAGTransport,
9537
9642
  createRAGSyncScheduler,
9538
9643
  createRAGSyncManager,
9644
+ createRAGStorageSyncSource,
9539
9645
  createRAGReranker,
9540
9646
  createRAGQueryTransform,
9541
9647
  createRAGPDFOCRExtractor,
@@ -9552,6 +9658,7 @@ export {
9552
9658
  createRAGDirectorySyncSource,
9553
9659
  createRAGCollection,
9554
9660
  createRAGClient,
9661
+ createRAGBunS3SyncClient,
9555
9662
  createRAGArchiveFileExtractor,
9556
9663
  createRAGArchiveExpander,
9557
9664
  createRAGAnswerWorkflow,
@@ -9590,5 +9697,5 @@ export {
9590
9697
  aiChat
9591
9698
  };
9592
9699
 
9593
- //# debugId=61173B84573291CC64756E2164756E21
9700
+ //# debugId=1890BBB7D959483A64756E2164756E21
9594
9701
  //# sourceMappingURL=index.js.map