@hyperframes/aws-lambda 0.8.177 → 0.8.179

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.
@@ -20,6 +20,7 @@ export declare class S3PlanV2ArtifactPublisher implements PlanV2ArtifactPublishe
20
20
  readonly manifestUri: string;
21
21
  constructor(options: Readonly<S3PlanV2ArtifactPublisherOptions>);
22
22
  putBlob(blob: Readonly<PlanV2PublishBlob>): Promise<void>;
23
+ referenceStoredBlob(blob: Readonly<Omit<PlanV2PublishBlob, "sourcePath">>): Promise<void>;
23
24
  commitManifest(manifestBytes: string): Promise<void>;
24
25
  abort(): Promise<void>;
25
26
  }
@@ -30,6 +30,11 @@ export declare function formatS3Uri(loc: S3Location): string;
30
30
  export declare function downloadS3ObjectToFile(client: S3Client, uri: string, destPath: string): Promise<void>;
31
31
  /** Download and verify an immutable plan-v2 artifact before materialization. */
32
32
  export declare function downloadS3ObjectToFileVerified(client: S3Client, uri: string, destPath: string, expectedSha256: string): Promise<void>;
33
+ /**
34
+ * Pre-sign a GET for a plan-v2 artifact, after S3 attests the object's stored
35
+ * SHA-256 and size are the ones the manifest pins.
36
+ */
37
+ export declare function presignVerifiedS3GetUrl(client: S3Client, uri: string, expectedSha256: string, expectedSize: number, expiresInSeconds: number): Promise<string>;
33
38
  /**
34
39
  * Upload a local file's contents to an S3 URI using a streaming
35
40
  * `PutObjectCommand`. PutObject's 5 GB cap comfortably exceeds the
@@ -44,14 +49,22 @@ export declare function uploadFileToS3(client: S3Client, localPath: string, uri:
44
49
  * and a conflicting one is never overwritten, since a chunk may already be reading that plan.
45
50
  */
46
51
  export declare function uploadContentAddressedFileToS3(client: S3Client, localPath: string, uri: string, expectedSha256: string, contentType?: string): Promise<"uploaded" | "reused">;
52
+ export declare function mapConcurrent<T>(values: readonly T[], concurrency: number, fn: (value: T) => Promise<void>): Promise<void>;
47
53
  export declare function sha256File(path: string): Promise<string>;
54
+ /** Put a file into the shared content store once; reusing an aging object restarts its expiry. */
55
+ export declare function putContentStoreFile(client: S3Client, localPath: string, bucket: string, sha256: string): Promise<"uploaded" | "reused">;
56
+ /** Confirm an object the caller never uploaded is in the content store, restarting an aging one. */
57
+ export declare function ensureContentStoreObject(client: S3Client, bucket: string, sha256: string, sizeBytes: number): Promise<void>;
58
+ export declare function presignS3GetUrl(client: S3Client, uri: string, expiresInSeconds: number): Promise<string>;
59
+ export declare function s3ObjectExists(client: S3Client, uri: string): Promise<boolean>;
60
+ export declare function isS3NotFound(error: unknown): boolean;
48
61
  /**
49
62
  * Pack a directory into a `.tar.gz` at `destTarball`. Uses the `tar` npm
50
63
  * package (pure JS over `node:zlib`) rather than spawning a system tar
51
64
  * binary — the AWS Lambda Node 22 base image ships a minimal set of
52
65
  * userland tools and does NOT include `tar` in `/usr/bin`.
53
66
  */
54
- export declare function tarDirectory(sourceDir: string, destTarball: string): Promise<void>;
67
+ export declare function tarDirectory(sourceDir: string, destTarball: string, files?: string[]): Promise<void>;
55
68
  /**
56
69
  * Extract a `.tar.gz` produced by {@link tarDirectory} into `destDir`.
57
70
  * The directory is created (or cleared) before extraction so a retried
@@ -1,15 +1,14 @@
1
1
  /**
2
- * `deploySite` — upload a project directory to S3 once per content hash
3
- * and return a reusable handle.
2
+ * `deploySite` — upload a project directory to S3 and return a reusable handle.
4
3
  *
5
4
  * `renderToLambda` calls this implicitly when no `siteHandle` is passed,
6
- * but exposing it as a standalone verb lets adopters bundle a project
7
- * ahead of time and reuse the handle across many renders without
8
- * re-tarring the project tree on every call.
5
+ * but exposing it as a standalone verb lets adopters upload a project
6
+ * ahead of time and reuse the handle across many renders.
9
7
  *
10
- * The handle is **content-addressed**: `siteId` is derived from a SHA-256
11
- * over the project files. Two `deploySite` calls on an unchanged tree
12
- * produce the same `siteId` and `HeadObject`-short-circuit the upload.
8
+ * Every file goes into the bucket's shared content store under its SHA-256,
9
+ * once: a file any earlier site or render already stored is skipped. The
10
+ * site itself is a small `sites/<siteId>/files.json` listing path → hash,
11
+ * where `siteId` is derived from a SHA-256 over the project files.
13
12
  */
14
13
  import { S3Client } from "@aws-sdk/client-s3";
15
14
  /** Options for {@link deploySite}. */
@@ -35,20 +34,21 @@ export interface SiteHandle {
35
34
  siteId: string;
36
35
  /** Bucket the site landed in. Surfaced separately so callers don't have to re-parse `projectS3Uri`. */
37
36
  bucketName: string;
38
- /** Full `s3://bucket/sites/<siteId>/project.tar.gz` URI; pass through to `renderToLambda`. */
37
+ /** Full `s3://bucket/sites/<siteId>/files.json` URI; pass through to `renderToLambda`. */
39
38
  projectS3Uri: string;
40
- /** Tarball size in bytes; useful for "did we actually skip the upload?" assertions. */
39
+ /** Total size of the project's files in bytes. */
41
40
  bytes: number;
42
- /** ISO timestamp of the most recent upload OR the existing object the short-circuit found. */
41
+ /** ISO timestamp of this `deploySite` call. */
43
42
  uploadedAt: string;
44
- /** `false` if the object already existed and we skipped the PUT. */
43
+ /** `false` if every file and the site manifest were already in the bucket. */
45
44
  uploaded: boolean;
46
45
  }
46
+ /** Handle for a site an earlier {@link deploySite} uploaded; `bytes` and `uploadedAt` are unknown. */
47
+ export declare function siteHandleFromId(bucketName: string, siteId: string): SiteHandle;
47
48
  /**
48
- * Upload `projectDir` to `s3://bucketName/sites/<siteId>/project.tar.gz`.
49
- *
50
- * Short-circuits when an object with the same key already exists in the
51
- * bucket — `siteId` derives from the project's content hash, so the same
52
- * bytes produce the same key, and re-uploading would be redundant.
49
+ * Before a render reuses `site`, re-store any file the content store expired, from `projectDir`.
50
+ * Returns the handle to render: a site uploaded before site manifests resolves to its tarball.
53
51
  */
52
+ export declare function ensureSiteStored(site: SiteHandle, s3: S3Client, projectDir?: string): Promise<SiteHandle>;
53
+ /** Upload `projectDir`'s files to the content store and write the site manifest. */
54
54
  export declare function deploySite(opts: DeploySiteOptions): Promise<SiteHandle>;
@@ -7,10 +7,11 @@
7
7
  * `puppeteer-core` into the module graph. The SDK files here are
8
8
  * AWS-SDK only — safe to load in any Node environment.
9
9
  */
10
- export { deploySite, type DeploySiteOptions, type SiteHandle } from "./deploySite.js";
11
- export { renderToLambda, type RenderHandle, type RenderToLambdaOptions } from "./renderToLambda.js";
10
+ export { deploySite, type DeploySiteOptions, type SiteHandle, siteHandleFromId, } from "./deploySite.js";
11
+ export { assertStackReadsSites, renderToLambda, type RenderHandle, type RenderToLambdaOptions, } from "./renderToLambda.js";
12
12
  export { getRenderProgress, type GetRenderProgressOptions, type RenderError, type RenderProgress, type RenderStatus, } from "./getRenderProgress.js";
13
13
  export { type BilledLambdaInvocation, computeRenderCost, type RenderCost, } from "./costAccounting.js";
14
14
  export { InvalidConfigError, MAX_STEP_FUNCTIONS_INPUT_BYTES, validateDistributedRenderConfig, validateStepFunctionsInputSize, validateVariablesPayload, } from "./validateConfig.js";
15
+ export { type PrebuiltHandler, prebuiltHandler } from "./prebuiltHandler.js";
15
16
  export type { SerializableDistributedRenderConfig } from "../events.js";
16
17
  export type { DistributedFormat } from "../formatExtension.js";