MCPcopy Index your code
hub / github.com/simstudioai/sim / objectToStub

Function objectToStub

apps/sim/connectors/s3/s3.ts:436–456  ·  view source on GitHub ↗

* Builds a metadata stub for an S3 object. The content hash combines the key * and ETag — S3's ETag changes whenever object content changes, making it an * ideal change indicator. Used by both listDocuments and getDocument to * guarantee identical hashes.

(ctx: S3Context, entry: S3ObjectEntry)

Source from the content-addressed store, hash-verified

434 * guarantee identical hashes.
435 */
436function objectToStub(ctx: S3Context, entry: S3ObjectEntry): ExternalDocument {
437 const title = entry.key.split('/').pop() || entry.key
438 const prefix = entry.key.includes('/') ? entry.key.slice(0, entry.key.lastIndexOf('/')) : ''
439
440 return {
441 externalId: entry.key,
442 title,
443 content: '',
444 contentDeferred: true,
445 mimeType: 'text/plain',
446 sourceUrl: buildUrl(ctx, buildObjectPath(ctx, entry.key), ''),
447 contentHash: `s3:${entry.key}:${entry.etag}`,
448 metadata: {
449 key: entry.key,
450 prefix,
451 etag: entry.etag,
452 lastModified: entry.lastModified,
453 fileSize: entry.size,
454 },
455 }
456}
457
458/**
459 * Performs a single ListObjectsV2 page request and returns the parsed result.

Callers 1

s3.tsFile · 0.85

Calls 2

buildObjectPathFunction · 0.85
buildUrlFunction · 0.70

Tested by

no test coverage detected