Skip to content

🎥 Make videos programmatically with React

extract

Jonny Burger5fe043dbfa6b
diff --git a/packages/lambda/package.json b/packages/lambda/package.json
index 752eaafc42..ce6012269d 100644
--- a/packages/lambda/package.json
+++ b/packages/lambda/package.json
@@ -33,6 +33,7 @@
"@remotion/renderer": "workspace:*",
"@remotion/studio-server": "workspace:*",
"@remotion/streaming": "workspace:*",
+ "@remotion/serverless": "workspace:*",
"mime-types": "2.1.34",
"remotion": "workspace:*",
"zod": "3.22.3"
diff --git a/packages/lambda/src/api/bucket-exists.ts b/packages/lambda/src/api/bucket-exists.ts
index 34e96ed6ba..32e0b42401 100644
--- a/packages/lambda/src/api/bucket-exists.ts
+++ b/packages/lambda/src/api/bucket-exists.ts
@@ -1,5 +1,5 @@
import {GetBucketLocationCommand} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getS3Client} from '../shared/aws-clients';
export const bucketExistsInRegion = async ({
diff --git a/packages/lambda/src/api/clean-items.ts b/packages/lambda/src/api/clean-items.ts
index eb405f11f6..9201a28ac5 100644
--- a/packages/lambda/src/api/clean-items.ts
+++ b/packages/lambda/src/api/clean-items.ts
@@ -1,5 +1,5 @@
import {DeleteObjectCommand} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getS3Client} from '../shared/aws-clients';
import {pLimit} from '../shared/p-limit';
diff --git a/packages/lambda/src/api/create-bucket.ts b/packages/lambda/src/api/create-bucket.ts
index 5a8ac7e649..5ced8510b1 100644
--- a/packages/lambda/src/api/create-bucket.ts
+++ b/packages/lambda/src/api/create-bucket.ts
@@ -4,7 +4,7 @@ import {
DeletePublicAccessBlockCommand,
PutBucketAclCommand,
} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getS3Client} from '../shared/aws-clients';
export const createBucket = async ({
diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.ts
index 191e398869..f2e375bae0 100644
--- a/packages/lambda/src/api/create-function.ts
+++ b/packages/lambda/src/api/create-function.ts
@@ -12,10 +12,10 @@ import {
} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {AwsRegion} from '@remotion/serverless/client';
import {readFileSync} from 'node:fs';
import {VERSION} from 'remotion/version';
import {LOG_GROUP_PREFIX} from '../defaults';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';
import {hostedLayers, v5HostedLayers} from '../shared/hosted-layers';
import {lambdaInsightsExtensions} from '../shared/lambda-insights-extensions';
diff --git a/packages/lambda/src/api/delete-function.ts b/packages/lambda/src/api/delete-function.ts
index 3da32e3263..cc19690eaf 100644
--- a/packages/lambda/src/api/delete-function.ts
+++ b/packages/lambda/src/api/delete-function.ts
@@ -1,5 +1,5 @@
import {DeleteFunctionCommand} from '@aws-sdk/client-lambda';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getLambdaClient} from '../shared/aws-clients';
export type DeleteFunctionInput = {
diff --git a/packages/lambda/src/api/delete-render.ts b/packages/lambda/src/api/delete-render.ts
index 01fae60cad..e202aa1332 100644
--- a/packages/lambda/src/api/delete-render.ts
+++ b/packages/lambda/src/api/delete-render.ts
@@ -1,9 +1,8 @@
-import type {AwsRegion} from '../client';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {rendersPrefix} from '../defaults';
import {getExpectedOutName} from '../functions/helpers/expected-out-name';
import {getOverallProgressS3} from '../functions/helpers/get-overall-progress-s3';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
-import type {CustomCredentials} from '../shared/aws-clients';
import {getAccountId} from '../shared/get-account-id';
import {cleanItems} from './clean-items';
diff --git a/packages/lambda/src/api/delete-site.ts b/packages/lambda/src/api/delete-site.ts
index 05dfae709a..259526fd75 100644
--- a/packages/lambda/src/api/delete-site.ts
+++ b/packages/lambda/src/api/delete-site.ts
@@ -1,6 +1,6 @@
+import type {AwsRegion} from '@remotion/serverless/client';
import {getSitesKey} from '../defaults';
import {lambdaLs} from '../functions/helpers/io';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getAccountId} from '../shared/get-account-id';
import {cleanItems} from './clean-items';
diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.ts
index f7eda38b94..d3d9a624b5 100644
--- a/packages/lambda/src/api/deploy-function.ts
+++ b/packages/lambda/src/api/deploy-function.ts
@@ -1,9 +1,9 @@
import type {LogLevel} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
+import type {AwsRegion} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
import {VERSION} from 'remotion/version';
import {getFunctions} from '../api/get-functions';
-import type {AwsRegion} from '../pricing/aws-regions';
import {
DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
DEFAULT_EPHEMERAL_STORAGE_IN_MB,
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.ts
index 51f085bfe0..f17c7afb57 100644
--- a/packages/lambda/src/api/deploy-site.ts
+++ b/packages/lambda/src/api/deploy-site.ts
@@ -2,9 +2,9 @@ import {type GitSource, type WebpackOverrideFn} from '@remotion/bundler';
import type {ToOptions} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
+import type {AwsRegion} from '@remotion/serverless/client';
import fs from 'node:fs';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
-import type {AwsRegion} from '../pricing/aws-regions';
import {bundleSite} from '../shared/bundle-site';
import {getSitesKey} from '../shared/constants';
import {getAccountId} from '../shared/get-account-id';
diff --git a/packages/lambda/src/api/download-media.ts b/packages/lambda/src/api/download-media.ts
index e64f1dd8d1..60b2b4a4a7 100644
--- a/packages/lambda/src/api/download-media.ts
+++ b/packages/lambda/src/api/download-media.ts
@@ -1,12 +1,11 @@
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import path from 'node:path';
import {getExpectedOutName} from '../functions/helpers/expected-out-name';
import {getOverallProgressS3} from '../functions/helpers/get-overall-progress-s3';
import type {LambdaReadFileProgress} from '../functions/helpers/read-with-progress';
import {lambdaDownloadFileWithProgress} from '../functions/helpers/read-with-progress';
-import type {AwsRegion} from '../pricing/aws-regions';
-import type {CustomCredentials} from '../shared/aws-clients';
import {getAccountId} from '../shared/get-account-id';
export type DownloadMediaInput = {
diff --git a/packages/lambda/src/api/estimate-price.ts b/packages/lambda/src/api/estimate-price.ts
index de269a3ce2..fd651b3325 100644
--- a/packages/lambda/src/api/estimate-price.ts
+++ b/packages/lambda/src/api/estimate-price.ts
@@ -1,5 +1,5 @@
+import type {AwsRegion} from '@remotion/serverless/client';
import {MIN_EPHEMERAL_STORAGE_IN_MB} from '../defaults';
-import type {AwsRegion} from '../pricing/aws-regions';
import {pricing} from '../pricing/price-per-1-s';
import {validateAwsRegion} from '../shared/validate-aws-region';
import {validateDiskSizeInMb} from '../shared/validate-disk-size-in-mb';
diff --git a/packages/lambda/src/api/get-aws-client.ts b/packages/lambda/src/api/get-aws-client.ts
index 8b4c4141b8..18bf972756 100644
--- a/packages/lambda/src/api/get-aws-client.ts
+++ b/packages/lambda/src/api/get-aws-client.ts
@@ -4,8 +4,9 @@ import * as LambdaSDK from '@aws-sdk/client-lambda';
import * as S3SDK from '@aws-sdk/client-s3';
import * as ServiceQuotasSDK from '@aws-sdk/client-service-quotas';
import * as StsSdk from '@aws-sdk/client-sts';
+import type {CustomCredentials} from '@remotion/serverless/client';
import type {AwsRegion} from '../client';
-import type {CustomCredentials, ServiceMapping} from '../shared/aws-clients';
+import type {ServiceMapping} from '../shared/aws-clients';
import {getServiceClient} from '../shared/aws-clients';
export type GetAwsClientInput<T extends keyof ServiceMapping> = {
diff --git a/packages/lambda/src/api/get-buckets.ts b/packages/lambda/src/api/get-buckets.ts
index 14e30db6c9..e46dca88be 100644
--- a/packages/lambda/src/api/get-buckets.ts
+++ b/packages/lambda/src/api/get-buckets.ts
@@ -1,6 +1,6 @@
import {GetBucketLocationCommand, ListBucketsCommand} from '@aws-sdk/client-s3';
+import type {AwsRegion} from '@remotion/serverless/client';
import {REMOTION_BUCKET_PREFIX} from '../defaults';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getS3Client} from '../shared/aws-clients';
import {parseBucketName} from '../shared/validate-bucketname';
diff --git a/packages/lambda/src/api/get-compositions-on-lambda.ts b/packages/lambda/src/api/get-compositions-on-lambda.ts
index f4b4b93c80..e16951ccbd 100644
--- a/packages/lambda/src/api/get-compositions-on-lambda.ts
+++ b/packages/lambda/src/api/get-compositions-on-lambda.ts
@@ -1,9 +1,9 @@
import type {ChromiumOptions, ToOptions} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import type {VideoConfig} from 'remotion/no-react';
import {VERSION} from 'remotion/version';
import type {AwsRegion} from '../client';
-import {LambdaRoutines} from '../defaults';
import {callLambda} from '../shared/call-lambda';
import {
compressInputProps,
diff --git a/packages/lambda/src/api/get-function-info.ts b/packages/lambda/src/api/get-function-info.ts
index 2ce6ed95c1..38c854b86e 100644
--- a/packages/lambda/src/api/get-function-info.ts
+++ b/packages/lambda/src/api/get-function-info.ts
@@ -1,6 +1,6 @@
import {GetFunctionCommand} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getLambdaClient} from '../shared/aws-clients';
import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../shared/constants';
import {getFunctionVersion} from '../shared/get-function-version';
diff --git a/packages/lambda/src/api/get-functions.ts b/packages/lambda/src/api/get-functions.ts
index c56fa49873..c3d8b990b2 100644
--- a/packages/lambda/src/api/get-functions.ts
+++ b/packages/lambda/src/api/get-functions.ts
@@ -1,8 +1,8 @@
import type {FunctionConfiguration} from '@aws-sdk/client-lambda';
import {ListFunctionsCommand} from '@aws-sdk/client-lambda';
import type {LogLevel} from '@remotion/renderer';
+import type {AwsRegion} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getLambdaClient} from '../shared/aws-clients';
import {
DEFAULT_EPHEMERAL_STORAGE_IN_MB,
diff --git a/packages/lambda/src/api/get-or-create-bucket.ts b/packages/lambda/src/api/get-or-create-bucket.ts
index 111ab61104..fd1f4ce88c 100644
--- a/packages/lambda/src/api/get-or-create-bucket.ts
+++ b/packages/lambda/src/api/get-or-create-bucket.ts
@@ -1,5 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
-import type {CustomCredentials} from '../shared/aws-clients';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {REMOTION_BUCKET_PREFIX} from '../shared/constants';
import {applyLifeCyleOperation} from '../shared/lifecycle-rules';
import {makeBucketName} from '../shared/validate-bucketname';
diff --git a/packages/lambda/src/api/get-regions.ts b/packages/lambda/src/api/get-regions.ts
index e80b42c9c5..024188ce28 100644
--- a/packages/lambda/src/api/get-regions.ts
+++ b/packages/lambda/src/api/get-regions.ts
@@ -1,5 +1,5 @@
-import type {AwsRegion} from '../pricing/aws-regions';
-import {DEFAULT_AWS_REGIONS} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
+import {DEFAULT_AWS_REGIONS} from '@remotion/serverless/client';
import {AWS_REGIONS} from '../regions';
type Options = {
diff --git a/packages/lambda/src/api/get-render-progress.ts b/packages/lambda/src/api/get-render-progress.ts
index 6757c389b6..04767acfcd 100644
--- a/packages/lambda/src/api/get-render-progress.ts
+++ b/packages/lambda/src/api/get-render-progress.ts
@@ -1,9 +1,8 @@
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '../pricing/aws-regions';
-import type {CustomCredentials} from '../shared/aws-clients';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {callLambda} from '../shared/call-lambda';
import type {RenderProgress} from '../shared/constants';
-import {LambdaRoutines} from '../shared/constants';
import {getRenderProgressPayload} from './make-lambda-payload';
export type GetRenderProgressInput = {
diff --git a/packages/lambda/src/api/get-sites.ts b/packages/lambda/src/api/get-sites.ts
index cc9d67fbde..abcaf4c4c9 100644
--- a/packages/lambda/src/api/get-sites.ts
+++ b/packages/lambda/src/api/get-sites.ts
@@ -1,5 +1,5 @@
+import type {AwsRegion} from '@remotion/serverless/client';
import {lambdaLs} from '../functions/helpers/io';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getSitesKey} from '../shared/constants';
import {getAccountId} from '../shared/get-account-id';
import {makeS3ServeUrl} from '../shared/make-s3-url';
diff --git a/packages/lambda/src/api/iam-validation/simulate-rule.ts b/packages/lambda/src/api/iam-validation/simulate-rule.ts
index 97378fddbd..a99c71cbfb 100644
--- a/packages/lambda/src/api/iam-validation/simulate-rule.ts
+++ b/packages/lambda/src/api/iam-validation/simulate-rule.ts
@@ -1,5 +1,5 @@
import {SimulatePrincipalPolicyCommand} from '@aws-sdk/client-iam';
-import type {AwsRegion} from '../../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getIamClient} from '../../shared/aws-clients';
export type EvalDecision = 'allowed' | 'explicitDeny' | 'implicitDeny';
diff --git a/packages/lambda/src/api/iam-validation/simulate.ts b/packages/lambda/src/api/iam-validation/simulate.ts
index 72b069e7b7..394515c21d 100644
--- a/packages/lambda/src/api/iam-validation/simulate.ts
+++ b/packages/lambda/src/api/iam-validation/simulate.ts
@@ -1,5 +1,5 @@
import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';
-import type {AwsRegion} from '../../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getStsClient} from '../../shared/aws-clients';
import type {EvalDecision, SimulationResult} from './simulate-rule';
import {simulateRule} from './simulate-rule';
diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda/src/api/make-lambda-payload.ts
index 248a84b87e..e2486e6196 100644
--- a/packages/lambda/src/api/make-lambda-payload.ts
+++ b/packages/lambda/src/api/make-lambda-payload.ts
@@ -11,26 +11,26 @@ import type {
X264Preset,
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
-import {VERSION} from 'remotion/version';
-import type {AwsRegion, DeleteAfter} from '../client';
import type {
+ DownloadBehavior,
+ LambdaCodec,
LambdaPayloads,
LambdaStartPayload,
LambdaStatusPayload,
OutNameInput,
Privacy,
WebhookOption,
-} from '../defaults';
-import {LambdaRoutines} from '../defaults';
+} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
+import {VERSION} from 'remotion/version';
+import type {AwsRegion, DeleteAfter} from '../client';
import {
compressInputProps,
getNeedsToUpload,
serializeOrThrow,
} from '../shared/compress-props';
-import type {DownloadBehavior} from '../shared/content-disposition-header';
import {validateDownloadBehavior} from '../shared/validate-download-behavior';
import {validateFramesPerLambda} from '../shared/validate-frames-per-lambda';
-import type {LambdaCodec} from '../shared/validate-lambda-codec';
import {validateLambdaCodec} from '../shared/validate-lambda-codec';
import {validateServeUrl} from '../shared/validate-serveurl';
import {validateWebhook} from '../shared/validate-webhook';
diff --git a/packages/lambda/src/api/mock-functions.ts b/packages/lambda/src/api/mock-functions.ts
index e3dd9f6daa..856dd8a54f 100644
--- a/packages/lambda/src/api/mock-functions.ts
+++ b/packages/lambda/src/api/mock-functions.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import type {FunctionInfo} from './get-function-info';
export let mockFunctionsStore: (FunctionInfo & {
diff --git a/packages/lambda/src/api/presign-url.ts b/packages/lambda/src/api/presign-url.ts
index da9af5a128..1096f548ec 100644
--- a/packages/lambda/src/api/presign-url.ts
+++ b/packages/lambda/src/api/presign-url.ts
@@ -1,6 +1,6 @@
import {GetObjectCommand, HeadObjectCommand} from '@aws-sdk/client-s3';
import {getSignedUrl} from '@aws-sdk/s3-request-presigner';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getS3Client} from '../shared/aws-clients';
import {validateBucketName} from '../shared/validate-bucketname';
import {validatePresignExpiration} from '../shared/validate-presign-expiration';
diff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda/src/api/render-media-on-lambda.ts
index a76f2ecd54..89c97551ec 100644
--- a/packages/lambda/src/api/render-media-on-lambda.ts
+++ b/packages/lambda/src/api/render-media-on-lambda.ts
@@ -9,11 +9,16 @@ import type {
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {
+ AwsRegion,
+ DownloadBehavior,
+ LambdaCodec,
+ OutNameInput,
+ Privacy,
+ WebhookOption,
+} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {callLambda} from '../shared/call-lambda';
-import type {OutNameInput, Privacy, WebhookOption} from '../shared/constants';
-import {LambdaRoutines} from '../shared/constants';
-import type {DownloadBehavior} from '../shared/content-disposition-header';
import {
getCloudwatchMethodUrl,
getCloudwatchRendererUrl,
@@ -21,7 +26,6 @@ import {
getProgressJsonUrl,
getS3RenderUrl,
} from '../shared/get-aws-urls';
-import type {LambdaCodec} from '../shared/validate-lambda-codec';
import type {InnerRenderMediaOnLambdaInput} from './make-lambda-payload';
import {makeLambdaRenderMediaPayload} from './make-lambda-payload';
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index fe00d4cfd5..c2a90d7507 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -5,13 +5,15 @@ import type {
} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
+import type {AwsRegion, DownloadBehavior} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import type {ReceivedArtifact} from '../functions/helpers/overall-render-progress';
import type {RenderStillLambdaResponsePayload} from '../functions/still';
-import type {AwsRegion} from '../pricing/aws-regions';
import {callLambdaWithStreaming} from '../shared/call-lambda';
-import type {CostsInfo, OutNameInput, Privacy} from '../shared/constants';
-import {DEFAULT_MAX_RETRIES, LambdaRoutines} from '../shared/constants';
-import type {DownloadBehavior} from '../shared/content-disposition-header';
+
+import type {OutNameInput, Privacy} from '@remotion/serverless/client';
+import type {CostsInfo} from '../shared/constants';
+import {DEFAULT_MAX_RETRIES} from '../shared/constants';
import {
getCloudwatchMethodUrl,
getLambdaInsightsUrl,
diff --git a/packages/lambda/src/api/upload-dir.ts b/packages/lambda/src/api/upload-dir.ts
index b49e64e923..dd45e53dcd 100644
--- a/packages/lambda/src/api/upload-dir.ts
+++ b/packages/lambda/src/api/upload-dir.ts
@@ -1,10 +1,9 @@
import {Upload} from '@aws-sdk/lib-storage';
+import type {AwsRegion, Privacy} from '@remotion/serverless/client';
import mimeTypes from 'mime-types';
import type {Dirent} from 'node:fs';
import {createReadStream, promises as fs} from 'node:fs';
import path from 'node:path';
-import type {Privacy} from '../defaults';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getS3Client} from '../shared/aws-clients';
import {makeS3Key} from '../shared/make-s3-key';
import {pLimit} from '../shared/p-limit';
diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.ts
index 4e5e82a340..49abdac139 100644
--- a/packages/lambda/src/cli/args.ts
+++ b/packages/lambda/src/cli/args.ts
@@ -2,8 +2,7 @@ import {CliInternals} from '@remotion/cli';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import type {DeleteAfter} from '../client';
-import type {AwsRegion} from '../pricing/aws-regions';
-import type {Privacy} from '../shared/constants';
+import type {AwsRegion, Privacy} from '@remotion/serverless/client';
type LambdaCommandLineOptions = {
help: boolean;
diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.ts
index 317307aa54..b6ae2579b9 100644
--- a/packages/lambda/src/cli/commands/render/render.ts
+++ b/packages/lambda/src/cli/commands/render/render.ts
@@ -10,6 +10,7 @@ import {getRenderProgress} from '../../../api/get-render-progress';
import {internalRenderMediaOnLambdaRaw} from '../../../api/render-media-on-lambda';
import type {EnhancedErrorInfo} from '../../../functions/helpers/write-lambda-error';
+import type {LambdaCodec} from '@remotion/serverless/client';
import {
BINARY_NAME,
DEFAULT_MAX_RETRIES,
@@ -17,7 +18,6 @@ import {
} from '../../../shared/constants';
import {sleep} from '../../../shared/sleep';
import {validateFramesPerLambda} from '../../../shared/validate-frames-per-lambda';
-import type {LambdaCodec} from '../../../shared/validate-lambda-codec';
import {validatePrivacy} from '../../../shared/validate-privacy';
import {validateMaxRetries} from '../../../shared/validate-retries';
import {validateServeUrl} from '../../../shared/validate-serveurl';
diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.ts
index 17c4206241..f389a6637a 100644
--- a/packages/lambda/src/cli/commands/sites/create.ts
+++ b/packages/lambda/src/cli/commands/sites/create.ts
@@ -3,10 +3,10 @@ import {ConfigInternals} from '@remotion/cli/config';
import type {LogLevel} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
+import type {Privacy} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
import {internalGetOrCreateBucket} from '../../../api/get-or-create-bucket';
import {LambdaInternals} from '../../../internals';
-import type {Privacy} from '../../../shared/constants';
import {BINARY_NAME} from '../../../shared/constants';
import {randomHash} from '../../../shared/random-hash';
import {validateSiteName} from '../../../shared/validate-site-name';
diff --git a/packages/lambda/src/cli/get-aws-region.ts b/packages/lambda/src/cli/get-aws-region.ts
index d0dbde63be..da13fc5d5b 100644
--- a/packages/lambda/src/cli/get-aws-region.ts
+++ b/packages/lambda/src/cli/get-aws-region.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {DEFAULT_REGION} from '../shared/constants';
import {isInsideLambda} from '../shared/is-in-lambda';
import {validateAwsRegion} from '../shared/validate-aws-region';
diff --git a/packages/lambda/src/client.ts b/packages/lambda/src/client.ts
index 366c1f8cf9..7ea3632db3 100644
--- a/packages/lambda/src/client.ts
+++ b/packages/lambda/src/client.ts
@@ -23,19 +23,17 @@ import {renderStillOnLambda} from './api/render-still-on-lambda';
import type {SpeculateFunctionNameInput} from './api/speculate-function-name';
import {speculateFunctionName} from './api/speculate-function-name';
import {validateWebhookSignature} from './api/validate-webhook-signature';
-import {DeleteAfter} from './functions/helpers/lifecycle';
-import type {AwsRegion} from './pricing/aws-regions';
import type {RenderProgress} from './shared/constants';
import type {WebhookPayload} from './shared/invoke-webhook';
+export {CustomCredentials, DeleteAfter} from '@remotion/serverless/client';
+export type {AwsRegion} from '@remotion/serverless/client';
export {
GetAwsClientInput,
GetAwsClientOutput,
getAwsClient,
} from './api/get-aws-client';
-export {CustomCredentials} from './shared/aws-clients';
export {
- DeleteAfter,
deleteRender,
getCompositionsOnLambda,
getFunctions,
@@ -49,7 +47,6 @@ export {
validateWebhookSignature,
};
export type {
- AwsRegion,
DeleteRenderInput,
GetRenderProgressInput,
PresignUrlInput,
diff --git a/packages/lambda/src/functions/compositions.ts b/packages/lambda/src/functions/compositions.ts
index 9cbbe4975b..0bfa18f7d4 100644
--- a/packages/lambda/src/functions/compositions.ts
+++ b/packages/lambda/src/functions/compositions.ts
@@ -1,8 +1,8 @@
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
-import type {LambdaPayload} from '../defaults';
-import {LambdaRoutines} from '../defaults';
import {decompressInputProps} from '../shared/compress-props';
import {convertToServeUrl} from '../shared/convert-to-serve-url';
import {
diff --git a/packages/lambda/src/functions/helpers/cleanup-props.ts b/packages/lambda/src/functions/helpers/cleanup-props.ts
index c69dc6a6e8..f3ccef3abe 100644
--- a/packages/lambda/src/functions/helpers/cleanup-props.ts
+++ b/packages/lambda/src/functions/helpers/cleanup-props.ts
@@ -1,4 +1,4 @@
-import type {SerializedInputProps} from '../../defaults';
+import type {SerializedInputProps} from '@remotion/serverless/client';
import {
cleanupSerializedInputProps,
cleanupSerializedResolvedProps,
diff --git a/packages/lambda/src/functions/helpers/concat-videos.ts b/packages/lambda/src/functions/helpers/concat-videos.ts
index 1573b94bcb..690f0542d9 100644
--- a/packages/lambda/src/functions/helpers/concat-videos.ts
+++ b/packages/lambda/src/functions/helpers/concat-videos.ts
@@ -1,12 +1,12 @@
import type {AudioCodec, CancelSignal, LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaCodec} from '@remotion/serverless/client';
import fs from 'node:fs';
import {join} from 'node:path';
import {
REMOTION_CONCATED_TOKEN,
REMOTION_FILELIST_TOKEN,
} from '../../shared/constants';
-import type {LambdaCodec} from '../../shared/validate-lambda-codec';
import {
canConcatAudioSeamlessly,
canConcatVideoSeamlessly,
diff --git a/packages/lambda/src/functions/helpers/create-post-render-data.ts b/packages/lambda/src/functions/helpers/create-post-render-data.ts
index c2725428cc..e90e2bd7cc 100644
--- a/packages/lambda/src/functions/helpers/create-post-render-data.ts
+++ b/packages/lambda/src/functions/helpers/create-post-render-data.ts
@@ -1,5 +1,5 @@
+import type {AwsRegion} from '@remotion/serverless/client';
import {estimatePrice} from '../../api/estimate-price';
-import type {AwsRegion} from '../../pricing/aws-regions';
import type {PostRenderData, RenderMetadata} from '../../shared/constants';
import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../../shared/constants';
import {
diff --git a/packages/lambda/src/functions/helpers/expected-out-name.ts b/packages/lambda/src/functions/helpers/expected-out-name.ts
index 0e6694891a..b0e8ce05a6 100644
--- a/packages/lambda/src/functions/helpers/expected-out-name.ts
+++ b/packages/lambda/src/functions/helpers/expected-out-name.ts
@@ -1,8 +1,11 @@
import type {Codec} from '@remotion/renderer';
import {NoReactAPIs} from '@remotion/renderer/pure';
-import type {OutNameInput, OutNameOutput, RenderMetadata} from '../../defaults';
+import type {
+ CustomCredentials,
+ OutNameInput,
+} from '@remotion/serverless/client';
+import type {OutNameOutput, RenderMetadata} from '../../defaults';
import {customOutName, outName, outStillName} from '../../defaults';
-import type {CustomCredentials} from '../../shared/aws-clients';
import {validateOutname} from '../../shared/validate-outname';
import {getCustomOutName} from './get-custom-out-name';
diff --git a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
index 3a7aa29dd5..5b959b61cf 100644
--- a/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
+++ b/packages/lambda/src/functions/helpers/find-output-file-in-bucket.ts
@@ -1,6 +1,5 @@
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {ROLE_NAME} from '../../api/iam-validation/suggested-policy';
-import type {AwsRegion} from '../../client';
-import type {CustomCredentials} from '../../shared/aws-clients';
import type {RenderMetadata} from '../../shared/constants';
import {getExpectedOutName} from './expected-out-name';
import {getOutputUrlFromMetadata} from './get-output-url-from-metadata';
diff --git a/packages/lambda/src/functions/helpers/get-current-region.ts b/packages/lambda/src/functions/helpers/get-current-region.ts
index d391935632..95bf658181 100644
--- a/packages/lambda/src/functions/helpers/get-current-region.ts
+++ b/packages/lambda/src/functions/helpers/get-current-region.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {isInsideLambda} from '../../shared/is-in-lambda';
export const getCurrentRegionInFunction = () => {
diff --git a/packages/lambda/src/functions/helpers/get-custom-out-name.ts b/packages/lambda/src/functions/helpers/get-custom-out-name.ts
index a4e07983a2..88c2fb5aba 100644
--- a/packages/lambda/src/functions/helpers/get-custom-out-name.ts
+++ b/packages/lambda/src/functions/helpers/get-custom-out-name.ts
@@ -1,5 +1,8 @@
-import type {OutNameInput, RenderMetadata} from '../../defaults';
-import type {CustomCredentials} from '../../shared/aws-clients';
+import type {
+ CustomCredentials,
+ OutNameInput,
+} from '@remotion/serverless/client';
+import type {RenderMetadata} from '../../defaults';
export const getCustomOutName = ({
renderMetadata,
diff --git a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts b/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
index 58e6fe1260..da69ccdfc4 100644
--- a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
+++ b/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts
@@ -1,5 +1,5 @@
+import type {CustomCredentials} from '@remotion/serverless/client';
import type {RenderMetadata} from '../../defaults';
-import type {CustomCredentials} from '../../shared/aws-clients';
import {getExpectedOutName} from './expected-out-name';
import {getCurrentRegionInFunction} from './get-current-region';
diff --git a/packages/lambda/src/functions/helpers/get-progress.ts b/packages/lambda/src/functions/helpers/get-progress.ts
index e22af635f2..4d29d38778 100644
--- a/packages/lambda/src/functions/helpers/get-progress.ts
+++ b/packages/lambda/src/functions/helpers/get-progress.ts
@@ -1,7 +1,6 @@
import {RenderInternals} from '@remotion/renderer';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
-import type {AwsRegion} from '../../pricing/aws-regions';
-import type {CustomCredentials} from '../../shared/aws-clients';
import type {CleanupInfo, RenderProgress} from '../../shared/constants';
import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../../shared/constants';
import {truthy} from '../../shared/truthy';
diff --git a/packages/lambda/src/functions/helpers/io.ts b/packages/lambda/src/functions/helpers/io.ts
index adc8d2f190..1fe90da46a 100644
--- a/packages/lambda/src/functions/helpers/io.ts
+++ b/packages/lambda/src/functions/helpers/io.ts
@@ -6,14 +6,16 @@ import {
ListObjectsV2Command,
PutObjectCommand,
} from '@aws-sdk/client-s3';
+import type {
+ AwsRegion,
+ CustomCredentials,
+ DownloadBehavior,
+ Privacy,
+} from '@remotion/serverless/client';
import mimeTypes from 'mime-types';
import type {ReadStream} from 'node:fs';
import type {Readable} from 'stream';
-import type {AwsRegion} from '../../pricing/aws-regions';
-import type {CustomCredentials} from '../../shared/aws-clients';
import {getS3Client} from '../../shared/aws-clients';
-import type {Privacy} from '../../shared/constants';
-import type {DownloadBehavior} from '../../shared/content-disposition-header';
import {getContentDispositionHeader} from '../../shared/content-disposition-header';
export type LambdaLSInput = {
diff --git a/packages/lambda/src/functions/helpers/lifecycle.ts b/packages/lambda/src/functions/helpers/lifecycle.ts
index 2a17d667c3..3f7f9ec085 100644
--- a/packages/lambda/src/functions/helpers/lifecycle.ts
+++ b/packages/lambda/src/functions/helpers/lifecycle.ts
@@ -1,17 +1,9 @@
import type {LifecycleRule} from '@aws-sdk/client-s3';
+import type {DeleteAfter} from '@remotion/serverless/client';
+import {expiryDays} from '@remotion/serverless/client';
import {randomHash} from '../../shared/random-hash';
import {truthy} from '../../shared/truthy';
-// Needs to be in sync with renderer/src/options/delete-after.ts#L7
-const expiryDays = {
- '1-day': 1,
- '3-days': 3,
- '7-days': 7,
- '30-days': 30,
-} as const;
-
-export type DeleteAfter = keyof typeof expiryDays;
-
const getEnabledLifeCycleRule = ({
key,
value,
diff --git a/packages/lambda/src/functions/helpers/make-timeout-message.ts b/packages/lambda/src/functions/helpers/make-timeout-message.ts
index b5e52e0454..b39a47dc77 100644
--- a/packages/lambda/src/functions/helpers/make-timeout-message.ts
+++ b/packages/lambda/src/functions/helpers/make-timeout-message.ts
@@ -1,5 +1,5 @@
+import {LambdaRoutines} from '@remotion/serverless/client';
import type {RenderMetadata} from '../../defaults';
-import {LambdaRoutines} from '../../defaults';
import {DOCS_URL} from '../../shared/docs-url';
import {
getCloudwatchMethodUrl,
diff --git a/packages/lambda/src/functions/helpers/merge-chunks.ts b/packages/lambda/src/functions/helpers/merge-chunks.ts
index ae8535abc4..89c8d72611 100644
--- a/packages/lambda/src/functions/helpers/merge-chunks.ts
+++ b/packages/lambda/src/functions/helpers/merge-chunks.ts
@@ -1,14 +1,13 @@
import type {AudioCodec, LogLevel} from '@remotion/renderer';
-import fs from 'fs';
-import type {CustomCredentials} from '../../shared/aws-clients';
import type {
- PostRenderData,
+ CustomCredentials,
+ DownloadBehavior,
+ LambdaCodec,
Privacy,
- RenderMetadata,
SerializedInputProps,
-} from '../../shared/constants';
-import type {DownloadBehavior} from '../../shared/content-disposition-header';
-import type {LambdaCodec} from '../../shared/validate-lambda-codec';
+} from '@remotion/serverless/client';
+import fs from 'fs';
+import type {PostRenderData, RenderMetadata} from '../../shared/constants';
import {cleanupProps} from './cleanup-props';
import {concatVideos} from './concat-videos';
import {createPostRenderData} from './create-post-render-data';
diff --git a/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts b/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts
index da85478df4..6dc5268368 100644
--- a/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts
+++ b/packages/lambda/src/functions/helpers/print-cloudwatch-helper.ts
@@ -1,6 +1,6 @@
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {LambdaRoutines} from '../../defaults';
+import type {LambdaRoutines} from '@remotion/serverless/client';
export const printCloudwatchHelper = (
type: LambdaRoutines,
diff --git a/packages/lambda/src/functions/helpers/read-with-progress.ts b/packages/lambda/src/functions/helpers/read-with-progress.ts
index 07d515b450..1adcc3a38b 100644
--- a/packages/lambda/src/functions/helpers/read-with-progress.ts
+++ b/packages/lambda/src/functions/helpers/read-with-progress.ts
@@ -2,8 +2,7 @@ import {GetObjectCommand} from '@aws-sdk/client-s3';
import {getSignedUrl} from '@aws-sdk/s3-request-presigner';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {AwsRegion} from '../../pricing/aws-regions';
-import type {CustomCredentials} from '../../shared/aws-clients';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {getS3Client} from '../../shared/aws-clients';
export type LambdaReadFileProgress = (progress: {
diff --git a/packages/lambda/src/functions/helpers/stream-renderer.ts b/packages/lambda/src/functions/helpers/stream-renderer.ts
index 7f39b5ee60..65beab174f 100644
--- a/packages/lambda/src/functions/helpers/stream-renderer.ts
+++ b/packages/lambda/src/functions/helpers/stream-renderer.ts
@@ -1,9 +1,9 @@
import type {EmittedArtifact, LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {writeFileSync} from 'fs';
import {join} from 'path';
-import type {LambdaPayload} from '../../defaults';
-import {LambdaRoutines} from '../../defaults';
import {callLambdaWithStreaming} from '../../shared/call-lambda';
import type {OnMessage} from '../streaming/streaming';
import {getCurrentRegionInFunction} from './get-current-region';
diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.ts
index 3fccf215c1..e483a0ccf9 100644
--- a/packages/lambda/src/functions/index.ts
+++ b/packages/lambda/src/functions/index.ts
@@ -1,6 +1,7 @@
import {RenderInternals} from '@remotion/renderer';
-import type {LambdaPayload} from '../shared/constants';
-import {COMMAND_NOT_FOUND, LambdaRoutines} from '../shared/constants';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
+import {COMMAND_NOT_FOUND} from '../shared/constants';
import {compositionsHandler} from './compositions';
import {deleteTmpDir} from './helpers/clean-tmpdir';
import {getWarm, setWarm} from './helpers/is-warm';
diff --git a/packages/lambda/src/functions/info.ts b/packages/lambda/src/functions/info.ts
index 671aae6b10..4f64eee81d 100644
--- a/packages/lambda/src/functions/info.ts
+++ b/packages/lambda/src/functions/info.ts
@@ -1,6 +1,6 @@
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
-import type {LambdaPayload} from '../shared/constants';
-import {LambdaRoutines} from '../shared/constants';
export const infoHandler = (lambdaParams: LambdaPayload) => {
if (lambdaParams.type !== LambdaRoutines.info) {
diff --git a/packages/lambda/src/functions/launch.ts b/packages/lambda/src/functions/launch.ts
index 55a3df02d8..ede6370fd3 100644
--- a/packages/lambda/src/functions/launch.ts
+++ b/packages/lambda/src/functions/launch.ts
@@ -1,6 +1,8 @@
/* eslint-disable @typescript-eslint/no-use-before-define */
import type {EmittedArtifact, LogOptions} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {existsSync, mkdirSync, rmSync} from 'fs';
import {join} from 'path';
import {VERSION} from 'remotion/version';
@@ -11,14 +13,9 @@ import {
getNeedsToUpload,
serializeOrThrow,
} from '../shared/compress-props';
-import type {
- LambdaPayload,
- PostRenderData,
- RenderMetadata,
-} from '../shared/constants';
+import type {PostRenderData, RenderMetadata} from '../shared/constants';
import {
CONCAT_FOLDER_TOKEN,
- LambdaRoutines,
MAX_FUNCTIONS_PER_RENDER,
artifactName,
} from '../shared/constants';
diff --git a/packages/lambda/src/functions/progress.ts b/packages/lambda/src/functions/progress.ts
index 0089fe0489..97988ade90 100644
--- a/packages/lambda/src/functions/progress.ts
+++ b/packages/lambda/src/functions/progress.ts
@@ -1,6 +1,7 @@
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
-import type {LambdaPayload, RenderProgress} from '../shared/constants';
-import {LambdaRoutines} from '../shared/constants';
+import type {RenderProgress} from '../shared/constants';
import {getCurrentRegionInFunction} from './helpers/get-current-region';
import {getProgress} from './helpers/get-progress';
diff --git a/packages/lambda/src/functions/renderer.ts b/packages/lambda/src/functions/renderer.ts
index f6ac91c2b0..cac49d2c8e 100644
--- a/packages/lambda/src/functions/renderer.ts
+++ b/packages/lambda/src/functions/renderer.ts
@@ -5,12 +5,13 @@ import type {
OnArtifact,
} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import fs from 'node:fs';
import path from 'node:path';
import {VERSION} from 'remotion/version';
import {decompressInputProps} from '../shared/compress-props';
-import type {LambdaPayload} from '../shared/constants';
-import {LambdaRoutines, RENDERER_PATH_TOKEN} from '../shared/constants';
+import {RENDERER_PATH_TOKEN} from '../shared/constants';
import {isFlakyError} from '../shared/is-flaky-error';
import {truthy} from '../shared/truthy';
import {enableNodeIntrospection} from '../shared/why-is-node-running';
diff --git a/packages/lambda/src/functions/start.ts b/packages/lambda/src/functions/start.ts
index e915874812..5735ac5f24 100644
--- a/packages/lambda/src/functions/start.ts
+++ b/packages/lambda/src/functions/start.ts
@@ -1,9 +1,10 @@
import {InvokeCommand} from '@aws-sdk/client-lambda';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
import {getLambdaClient} from '../shared/aws-clients';
-import type {LambdaPayload} from '../shared/constants';
-import {LambdaRoutines, overallProgressKey} from '../shared/constants';
+import {overallProgressKey} from '../shared/constants';
import {convertToServeUrl} from '../shared/convert-to-serve-url';
import {getCurrentRegionInFunction} from './helpers/get-current-region';
import {lambdaWriteFile} from './helpers/io';
diff --git a/packages/lambda/src/functions/still.ts b/packages/lambda/src/functions/still.ts
index 49c9d7aeb4..545ee79168 100644
--- a/packages/lambda/src/functions/still.ts
+++ b/packages/lambda/src/functions/still.ts
@@ -1,5 +1,7 @@
import type {EmittedArtifact, StillImageFormat} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {LambdaPayload} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import fs from 'node:fs';
import path from 'node:path';
import {NoReactInternals} from 'remotion/no-react';
@@ -8,13 +10,8 @@ import {estimatePrice} from '../api/estimate-price';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
import {cleanupSerializedInputProps} from '../shared/cleanup-serialized-input-props';
import {decompressInputProps} from '../shared/compress-props';
-import type {
- CostsInfo,
- LambdaPayload,
- RenderMetadata,
-} from '../shared/constants';
+import type {CostsInfo, RenderMetadata} from '../shared/constants';
import {
- LambdaRoutines,
MAX_EPHEMERAL_STORAGE_IN_MB,
artifactName,
overallProgressKey,
diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.ts
index 61119d40cf..a469d64b22 100644
--- a/packages/lambda/src/index.ts
+++ b/packages/lambda/src/index.ts
@@ -1,3 +1,4 @@
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import type {DeleteFunctionInput} from './api/delete-function';
import {deleteFunction} from './api/delete-function';
import type {DeleteRenderInput} from './api/delete-render';
@@ -69,8 +70,6 @@ import type {
LambdaErrorInfo,
} from './functions/helpers/write-lambda-error';
import {LambdaInternals} from './internals';
-import type {AwsRegion} from './pricing/aws-regions';
-import type {CustomCredentials} from './shared/aws-clients';
import type {RenderProgress} from './shared/constants';
import type {WebhookPayload} from './shared/invoke-webhook';
diff --git a/packages/lambda/src/pricing/aws-regions.ts b/packages/lambda/src/pricing/aws-regions.ts
index 8bbae45f60..e69de29bb2 100644
--- a/packages/lambda/src/pricing/aws-regions.ts
+++ b/packages/lambda/src/pricing/aws-regions.ts
@@ -1,45 +0,0 @@
-export const DEFAULT_AWS_REGIONS = [
- 'eu-central-1',
- 'eu-west-1',
- 'eu-west-2',
- 'eu-west-3',
- 'eu-north-1',
- 'us-east-1', // N. Virginia
- 'us-east-2', // Ohio;
- 'us-west-1',
- 'us-west-2', // Oregon
- 'ap-south-1',
- 'ap-southeast-1',
- 'ap-southeast-2',
- 'ap-northeast-1',
- 'ap-northeast-2',
- 'ap-northeast-3',
- 'ca-central-1',
- 'sa-east-1',
-] as const;
-
-export const AWS_REGIONS = [
- 'eu-central-1',
- 'eu-west-1',
- 'eu-west-2',
- 'eu-west-3',
- 'eu-south-1',
- 'eu-north-1',
- 'us-east-1', // N. Virginia
- 'us-east-2', // Ohio;
- 'us-west-1',
- 'us-west-2', // Oregon
- 'af-south-1',
- 'ap-south-1',
- 'ap-east-1',
- 'ap-southeast-1',
- 'ap-southeast-2',
- 'ap-northeast-1',
- 'ap-northeast-2',
- 'ap-northeast-3',
- 'ca-central-1',
- 'me-south-1',
- 'sa-east-1',
-] as const;
-
-export type AwsRegion = (typeof AWS_REGIONS)[number];
diff --git a/packages/lambda/src/pricing/price-per-1-s.ts b/packages/lambda/src/pricing/price-per-1-s.ts
index b1c3b25a1e..1855c323a7 100644
--- a/packages/lambda/src/pricing/price-per-1-s.ts
+++ b/packages/lambda/src/pricing/price-per-1-s.ts
@@ -1,6 +1,6 @@
// From https://calculator.aws/pricing/2.0/meteredUnitMaps/lambda/USD/current/lambda.json
-import type {AwsRegion} from './aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
export const pricing: {
[key in AwsRegion]: {
diff --git a/packages/lambda/src/regions.ts b/packages/lambda/src/regions.ts
index 3c43e1d22f..8715bcf446 100644
--- a/packages/lambda/src/regions.ts
+++ b/packages/lambda/src/regions.ts
@@ -1,3 +1,3 @@
-import {AWS_REGIONS} from './pricing/aws-regions';
+import {AWS_REGIONS} from '@remotion/serverless/client';
export {AWS_REGIONS};
diff --git a/packages/lambda/src/shared/aws-clients.ts b/packages/lambda/src/shared/aws-clients.ts
index 2e263a316f..41dfe26adf 100644
--- a/packages/lambda/src/shared/aws-clients.ts
+++ b/packages/lambda/src/shared/aws-clients.ts
@@ -5,8 +5,8 @@ import {S3Client} from '@aws-sdk/client-s3';
import {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';
import {STSClient} from '@aws-sdk/client-sts';
import {fromIni} from '@aws-sdk/credential-providers';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {random} from 'remotion/no-react';
-import type {AwsRegion} from '../pricing/aws-regions';
import {checkCredentials} from './check-credentials';
import {MAX_FUNCTIONS_PER_RENDER} from './constants';
import {isInsideLambda} from './is-in-lambda';
@@ -151,16 +151,6 @@ export type ServiceMapping = {
sts: STSClient;
};
-export type CustomCredentialsWithoutSensitiveData = {
- endpoint: string;
-};
-
-export type CustomCredentials = CustomCredentialsWithoutSensitiveData & {
- accessKeyId: string | null;
- secretAccessKey: string | null;
- region?: AwsRegion;
-};
-
export const getServiceClient = <T extends keyof ServiceMapping>({
region,
service,
diff --git a/packages/lambda/src/shared/call-lambda.ts b/packages/lambda/src/shared/call-lambda.ts
index 0eee2bd9cb..291c95ceac 100644
--- a/packages/lambda/src/shared/call-lambda.ts
+++ b/packages/lambda/src/shared/call-lambda.ts
@@ -7,6 +7,11 @@ import {
InvokeCommand,
InvokeWithResponseStreamCommand,
} from '@aws-sdk/client-lambda';
+import type {
+ AwsRegion,
+ LambdaPayloads,
+ LambdaRoutines,
+} from '@remotion/serverless/client';
import {makeStreamer} from '@remotion/streaming';
import type {OrError} from '../functions';
import type {
@@ -18,9 +23,7 @@ import {
formatMap,
messageTypeIdToMessageType,
} from '../functions/streaming/streaming';
-import type {AwsRegion} from '../pricing/aws-regions';
import {getLambdaClient} from './aws-clients';
-import type {LambdaPayloads, LambdaRoutines} from './constants';
import type {LambdaReturnValues} from './return-values';
const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
diff --git a/packages/lambda/src/shared/cleanup-serialized-input-props.ts b/packages/lambda/src/shared/cleanup-serialized-input-props.ts
index cbb909ac7c..51bb0a849d 100644
--- a/packages/lambda/src/shared/cleanup-serialized-input-props.ts
+++ b/packages/lambda/src/shared/cleanup-serialized-input-props.ts
@@ -1,6 +1,6 @@
+import type {SerializedInputProps} from '@remotion/serverless/client';
import type {AwsRegion} from '../client';
import {lambdaDeleteFile} from '../functions/helpers/io';
-import type {SerializedInputProps} from './constants';
import {inputPropsKey, resolvedPropsKey} from './constants';
export const cleanupSerializedInputProps = async ({
diff --git a/packages/lambda/src/shared/compress-props.ts b/packages/lambda/src/shared/compress-props.ts
index b29c2130e3..1d2331b591 100644
--- a/packages/lambda/src/shared/compress-props.ts
+++ b/packages/lambda/src/shared/compress-props.ts
@@ -1,8 +1,8 @@
+import type {SerializedInputProps} from '@remotion/serverless/client';
import {NoReactInternals} from 'remotion/no-react';
import {internalGetOrCreateBucket} from '../api/get-or-create-bucket';
import type {AwsRegion} from '../client';
import {lambdaReadFile, lambdaWriteFile} from '../functions/helpers/io';
-import type {SerializedInputProps} from './constants';
import {inputPropsKey, resolvedPropsKey} from './constants';
import {randomHash} from './random-hash';
import {streamToString} from './stream-to-string';
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index ec4ad1d54a..3f686a741a 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -1,29 +1,23 @@
import type {
AudioCodec,
- ChromiumOptions,
- ColorSpace,
- FrameRange,
- LogLevel,
- PixelFormat,
- ProResProfile,
StillImageFormat,
- ToOptions,
VideoImageFormat,
- X264Preset,
} from '@remotion/renderer';
-import type {BrowserSafeApis} from '@remotion/renderer/client';
-import type {ChunkRetry} from '../functions/helpers/get-retry-stats';
-import type {DeleteAfter} from '../functions/helpers/lifecycle';
-import type {ReceivedArtifact} from '../functions/helpers/overall-render-progress';
-import type {EnhancedErrorInfo} from '../functions/helpers/write-lambda-error';
-import type {AwsRegion} from '../pricing/aws-regions';
import type {
+ AwsRegion,
CustomCredentials,
CustomCredentialsWithoutSensitiveData,
-} from './aws-clients';
-import type {DownloadBehavior} from './content-disposition-header';
+ DeleteAfter,
+ DownloadBehavior,
+ LambdaCodec,
+ OutNameInput,
+ Privacy,
+ SerializedInputProps,
+} from '@remotion/serverless/client';
+import type {ChunkRetry} from '../functions/helpers/get-retry-stats';
+import type {ReceivedArtifact} from '../functions/helpers/overall-render-progress';
+import type {EnhancedErrorInfo} from '../functions/helpers/write-lambda-error';
import type {ExpensiveChunk} from './get-most-expensive-chunks';
-import type {LambdaCodec} from './validate-lambda-codec';
export const MIN_MEMORY = 512;
export const MAX_MEMORY = 10240;
@@ -59,14 +53,6 @@ export const rendersPrefix = (renderId: string) => `renders/${renderId}`;
export const overallProgressKey = (renderId: string) =>
`${rendersPrefix(renderId)}/progress.json`;
-export type OutNameInput =
- | string
- | {
- bucketName: string;
- key: string;
- s3OutputProvider?: CustomCredentials;
- };
-
export type OutNameInputWithoutCredentials =
| string
| {
@@ -121,237 +107,6 @@ export const CONCAT_FOLDER_TOKEN = 'remotion-concat';
export const REMOTION_CONCATED_TOKEN = 'remotion-concated-token';
export const REMOTION_FILELIST_TOKEN = 'remotion-filelist';
-export enum LambdaRoutines {
- info = 'info',
- start = 'start',
- launch = 'launch',
- status = 'status',
- renderer = 'renderer',
- still = 'still',
- compositions = 'compositions',
-}
-
-type Prettify<T> = {
- [K in keyof T]: T[K];
-} & {};
-
-export type WebhookOption = Prettify<
- | null
- | ({
- url: string;
- secret: string | null;
- } & Partial<
- ToOptions<{
- customData: typeof BrowserSafeApis.options.webhookCustomDataOption;
- }>
- >)
->;
-
-export type SerializedInputProps =
- | {
- type: 'bucket-url';
- hash: string;
- bucketName: string;
- }
- | {
- type: 'payload';
- payload: string;
- };
-
-export type LambdaStartPayload = {
- rendererFunctionName: string | null;
- type: LambdaRoutines.start;
- serveUrl: string;
- composition: string;
- framesPerLambda: number | null;
- inputProps: SerializedInputProps;
- codec: LambdaCodec;
- audioCodec: AudioCodec | null;
- imageFormat: VideoImageFormat;
- crf: number | undefined;
- envVariables: Record<string, string> | undefined;
- pixelFormat: PixelFormat | undefined;
- proResProfile: ProResProfile | undefined;
- x264Preset: X264Preset | null;
- jpegQuality: number | undefined;
- maxRetries: number;
- privacy: Privacy;
- logLevel: LogLevel;
- frameRange: FrameRange | null;
- outName: OutNameInput | null;
- timeoutInMilliseconds: number;
- chromiumOptions: ChromiumOptions;
- scale: number;
- everyNthFrame: number;
- numberOfGifLoops: number | null;
- concurrencyPerLambda: number;
- downloadBehavior: DownloadBehavior;
- muted: boolean;
- version: string;
- overwrite: boolean;
- audioBitrate: string | null;
- videoBitrate: string | null;
- encodingMaxRate: string | null;
- encodingBufferSize: string | null;
- webhook: WebhookOption;
- forceHeight: number | null;
- forceWidth: number | null;
- bucketName: string | null;
- offthreadVideoCacheSizeInBytes: number | null;
- deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace | null;
- preferLossless: boolean;
-};
-
-export type LambdaStatusPayload = {
- type: LambdaRoutines.status;
- bucketName: string;
- renderId: string;
- version: string;
- logLevel: LogLevel;
- s3OutputProvider?: CustomCredentials;
-};
-
-export type LambdaPayloads = {
- info: {
- type: LambdaRoutines.info;
- logLevel: LogLevel;
- };
- start: LambdaStartPayload;
- launch: {
- rendererFunctionName: string | null;
- type: LambdaRoutines.launch;
- serveUrl: string;
- composition: string;
- framesPerLambda: number | null;
- bucketName: string;
- inputProps: SerializedInputProps;
- renderId: string;
- imageFormat: VideoImageFormat;
- codec: LambdaCodec;
- audioCodec: AudioCodec | null;
- crf: number | undefined;
- envVariables: Record<string, string> | undefined;
- pixelFormat: PixelFormat | undefined;
- proResProfile: ProResProfile | undefined;
- x264Preset: X264Preset | null;
- jpegQuality: number | undefined;
- maxRetries: number;
- privacy: Privacy;
- logLevel: LogLevel;
- frameRange: FrameRange | null;
- outName: OutNameInput | null;
- timeoutInMilliseconds: number;
- chromiumOptions: ChromiumOptions;
- scale: number;
- everyNthFrame: number;
- numberOfGifLoops: number | null;
- concurrencyPerLambda: number;
- downloadBehavior: DownloadBehavior;
- muted: boolean;
- overwrite: boolean;
- audioBitrate: string | null;
- videoBitrate: string | null;
- encodingMaxRate: string | null;
- encodingBufferSize: string | null;
- webhook: WebhookOption;
- forceHeight: number | null;
- forceWidth: number | null;
- offthreadVideoCacheSizeInBytes: number | null;
- deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace | null;
- preferLossless: boolean;
- };
- status: LambdaStatusPayload;
- renderer: {
- concurrencyPerLambda: number;
- type: LambdaRoutines.renderer;
- serveUrl: string;
- frameRange: [number, number];
- chunk: number;
- bucketName: string;
- composition: string;
- fps: number;
- height: number;
- width: number;
- durationInFrames: number;
- retriesLeft: number;
- inputProps: SerializedInputProps;
- renderId: string;
- imageFormat: VideoImageFormat;
- codec: LambdaCodec;
- crf: number | undefined;
- proResProfile: ProResProfile | undefined;
- x264Preset: X264Preset | null;
- pixelFormat: PixelFormat | undefined;
- jpegQuality: number | undefined;
- envVariables: Record<string, string> | undefined;
- privacy: Privacy;
- attempt: number;
- logLevel: LogLevel;
- timeoutInMilliseconds: number;
- chromiumOptions: ChromiumOptions;
- resolvedProps: SerializedInputProps;
- scale: number;
- everyNthFrame: number;
- muted: boolean;
- audioBitrate: string | null;
- videoBitrate: string | null;
- encodingBufferSize: string | null;
- encodingMaxRate: string | null;
- launchFunctionConfig: {
- version: string;
- };
- preferLossless: boolean;
- offthreadVideoCacheSizeInBytes: number | null;
- deleteAfter: DeleteAfter | null;
- colorSpace: ColorSpace | null;
- compositionStart: number;
- framesPerLambda: number;
- progressEveryNthFrame: number;
- };
- still: {
- type: LambdaRoutines.still;
- serveUrl: string;
- composition: string;
- inputProps: SerializedInputProps;
- imageFormat: StillImageFormat;
- envVariables: Record<string, string>;
- attempt: number;
- jpegQuality: number | undefined;
- maxRetries: number;
- frame: number;
- privacy: Privacy;
- logLevel: LogLevel;
- outName: OutNameInput | null;
- timeoutInMilliseconds: number;
- chromiumOptions: ChromiumOptions;
- scale: number;
- downloadBehavior: DownloadBehavior;
- version: string;
- forceHeight: number | null;
- forceWidth: number | null;
- bucketName: string | null;
- offthreadVideoCacheSizeInBytes: number | null;
- deleteAfter: DeleteAfter | null;
- streamed: boolean;
- };
- compositions: {
- type: LambdaRoutines.compositions;
- version: string;
- chromiumOptions: ChromiumOptions;
- logLevel: LogLevel;
- inputProps: SerializedInputProps;
- envVariables: Record<string, string> | undefined;
- timeoutInMilliseconds: number;
- serveUrl: string;
- bucketName: string | null;
- offthreadVideoCacheSizeInBytes: number | null;
- };
-};
-
-export type LambdaPayload = LambdaPayloads[LambdaRoutines];
-
type Discriminated =
| {
type: 'still';
@@ -474,6 +229,4 @@ export type RenderProgress = {
artifacts: ReceivedArtifact[];
};
-export type Privacy = 'public' | 'private' | 'no-acl';
-
export const LAMBDA_CONCURRENCY_LIMIT_QUOTA = 'L-B99A9384';
diff --git a/packages/lambda/src/shared/content-disposition-header.ts b/packages/lambda/src/shared/content-disposition-header.ts
index fa570f379b..3f43428fd6 100644
--- a/packages/lambda/src/shared/content-disposition-header.ts
+++ b/packages/lambda/src/shared/content-disposition-header.ts
@@ -1,16 +1,9 @@
+import type {DownloadBehavior} from '@remotion/serverless/client';
+
// By setting the Content-Disposition header in an S3 object,
// you can control if the user downloads the item if you
// visit the link
-export type DownloadBehavior =
- | {
- type: 'play-in-browser';
- }
- | {
- type: 'download';
- fileName: string | null;
- };
-
const problematicCharacters = {
'%3A': ':',
'%2F': '/',
diff --git a/packages/lambda/src/shared/convert-to-serve-url.ts b/packages/lambda/src/shared/convert-to-serve-url.ts
index e3c51ac869..c3b4b6ae50 100644
--- a/packages/lambda/src/shared/convert-to-serve-url.ts
+++ b/packages/lambda/src/shared/convert-to-serve-url.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {DOCS_URL} from './docs-url';
export const convertToServeUrl = ({
diff --git a/packages/lambda/src/shared/get-account-id.ts b/packages/lambda/src/shared/get-account-id.ts
index 2f145cc48a..f330123900 100644
--- a/packages/lambda/src/shared/get-account-id.ts
+++ b/packages/lambda/src/shared/get-account-id.ts
@@ -1,5 +1,5 @@
import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
import {getStsClient} from './aws-clients';
import {validateAwsRegion} from './validate-aws-region';
diff --git a/packages/lambda/src/shared/get-aws-urls.ts b/packages/lambda/src/shared/get-aws-urls.ts
index 6e3ff7c1ec..a4da4ea40e 100644
--- a/packages/lambda/src/shared/get-aws-urls.ts
+++ b/packages/lambda/src/shared/get-aws-urls.ts
@@ -1,5 +1,5 @@
+import type {LambdaRoutines} from '@remotion/serverless/client';
import type {AwsRegion} from '../client';
-import type {LambdaRoutines} from './constants';
import {encodeAwsUrlParams} from './encode-aws-url-params';
const cloudWatchUrlWithQuery = ({
diff --git a/packages/lambda/src/shared/get-function-version.ts b/packages/lambda/src/shared/get-function-version.ts
index b9c584618a..0dac8fff4b 100644
--- a/packages/lambda/src/shared/get-function-version.ts
+++ b/packages/lambda/src/shared/get-function-version.ts
@@ -1,7 +1,8 @@
import type {LogLevel} from '@remotion/renderer';
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {callLambda} from './call-lambda';
-import {COMMAND_NOT_FOUND, LambdaRoutines} from './constants';
+import {COMMAND_NOT_FOUND} from './constants';
export const getFunctionVersion = async ({
functionName,
diff --git a/packages/lambda/src/shared/hosted-layers.ts b/packages/lambda/src/shared/hosted-layers.ts
index 7a68086c13..30e1e8c527 100644
--- a/packages/lambda/src/shared/hosted-layers.ts
+++ b/packages/lambda/src/shared/hosted-layers.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
export const REMOTION_HOSTED_LAYER_ARN = `arn:aws:lambda:*:678892195805:layer:remotion-binaries-*`;
diff --git a/packages/lambda/src/shared/lambda-insights-extensions.ts b/packages/lambda/src/shared/lambda-insights-extensions.ts
index 57720b7fed..51dcff31fa 100644
--- a/packages/lambda/src/shared/lambda-insights-extensions.ts
+++ b/packages/lambda/src/shared/lambda-insights-extensions.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
export const lambdaInsightsExtensions: {[region in AwsRegion]: string} = {
'us-east-1':
diff --git a/packages/lambda/src/shared/lifecycle-rules.ts b/packages/lambda/src/shared/lifecycle-rules.ts
index a8c70bffb2..fcfb9a7a82 100644
--- a/packages/lambda/src/shared/lifecycle-rules.ts
+++ b/packages/lambda/src/shared/lifecycle-rules.ts
@@ -2,13 +2,12 @@ import {
DeleteBucketLifecycleCommand,
PutBucketLifecycleConfigurationCommand,
} from '@aws-sdk/client-s3';
-import type {AwsRegion} from '../client';
+import type {AwsRegion, CustomCredentials} from '@remotion/serverless/client';
import {
createLifeCycleInput,
deleteLifeCycleInput,
} from '../functions/helpers/apply-lifecyle';
import {getLifeCycleRules} from '../functions/helpers/lifecycle';
-import type {CustomCredentials} from './aws-clients';
import {getS3Client} from './aws-clients';
const createLCRules = async ({
diff --git a/packages/lambda/src/shared/make-s3-url.ts b/packages/lambda/src/shared/make-s3-url.ts
index f63a5c1d09..41a3617d5d 100644
--- a/packages/lambda/src/shared/make-s3-url.ts
+++ b/packages/lambda/src/shared/make-s3-url.ts
@@ -1,4 +1,4 @@
-import type {AwsRegion} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
export const makeS3ServeUrl = ({
bucketName,
diff --git a/packages/lambda/src/shared/return-values.ts b/packages/lambda/src/shared/return-values.ts
index bcf2aa0d8e..f00a7770f1 100644
--- a/packages/lambda/src/shared/return-values.ts
+++ b/packages/lambda/src/shared/return-values.ts
@@ -1,3 +1,4 @@
+import type {LambdaRoutines} from '@remotion/serverless/client';
import type {compositionsHandler} from '../functions/compositions';
import type {infoHandler} from '../functions/info';
import type {launchHandler} from '../functions/launch';
@@ -5,7 +6,6 @@ import type {progressHandler} from '../functions/progress';
import type {rendererHandler} from '../functions/renderer';
import type {startHandler} from '../functions/start';
import type {stillHandler} from '../functions/still';
-import type {LambdaRoutines} from './constants';
export interface LambdaReturnValues {
[LambdaRoutines.start]: ReturnType<typeof startHandler>;
diff --git a/packages/lambda/src/shared/validate-aws-region.ts b/packages/lambda/src/shared/validate-aws-region.ts
index 2e03455b95..988c6c2c05 100644
--- a/packages/lambda/src/shared/validate-aws-region.ts
+++ b/packages/lambda/src/shared/validate-aws-region.ts
@@ -1,5 +1,5 @@
-import type {AwsRegion} from '../pricing/aws-regions';
-import {AWS_REGIONS} from '../pricing/aws-regions';
+import type {AwsRegion} from '@remotion/serverless/client';
+import {AWS_REGIONS} from '@remotion/serverless/client';
export function validateAwsRegion(
region: unknown,
diff --git a/packages/lambda/src/shared/validate-download-behavior.ts b/packages/lambda/src/shared/validate-download-behavior.ts
index d9a94ab318..e05d5ccd66 100644
--- a/packages/lambda/src/shared/validate-download-behavior.ts
+++ b/packages/lambda/src/shared/validate-download-behavior.ts
@@ -1,4 +1,4 @@
-import type {DownloadBehavior} from './content-disposition-header';
+import type {DownloadBehavior} from '@remotion/serverless/client';
export const validateDownloadBehavior = (downloadBehavior: unknown) => {
if (downloadBehavior === null || downloadBehavior === undefined) {
diff --git a/packages/lambda/src/shared/validate-lambda-codec.ts b/packages/lambda/src/shared/validate-lambda-codec.ts
index 3043592305..a5302d8391 100644
--- a/packages/lambda/src/shared/validate-lambda-codec.ts
+++ b/packages/lambda/src/shared/validate-lambda-codec.ts
@@ -1,16 +1,5 @@
-const lambdaCodecs = [
- 'h264',
- 'h265',
- 'vp8',
- 'vp9',
- 'mp3',
- 'aac',
- 'wav',
- 'gif',
- 'prores',
-] as const;
-
-export type LambdaCodec = (typeof lambdaCodecs)[number];
+import type {LambdaCodec} from '@remotion/serverless/client';
+import {lambdaCodecs} from '@remotion/serverless/client';
export const validateLambdaCodec = (codec: unknown): LambdaCodec => {
if (typeof codec !== 'string') {
diff --git a/packages/lambda/src/shared/validate-privacy.ts b/packages/lambda/src/shared/validate-privacy.ts
index 222240edb5..a53f976c83 100644
--- a/packages/lambda/src/shared/validate-privacy.ts
+++ b/packages/lambda/src/shared/validate-privacy.ts
@@ -1,4 +1,4 @@
-import type {Privacy} from './constants';
+import type {Privacy} from '@remotion/serverless/client';
export function validatePrivacy(
privacy: unknown,
diff --git a/packages/lambda/src/shared/validate-webhook.ts b/packages/lambda/src/shared/validate-webhook.ts
index f400d049d5..a6509f74eb 100644
--- a/packages/lambda/src/shared/validate-webhook.ts
+++ b/packages/lambda/src/shared/validate-webhook.ts
@@ -1,4 +1,4 @@
-import type {WebhookOption} from './constants';
+import type {WebhookOption} from '@remotion/serverless/client';
export const MAX_WEBHOOK_CUSTOM_DATA_SIZE = 1024;
diff --git a/packages/lambda/src/test/integration/handlers.test.ts b/packages/lambda/src/test/integration/handlers.test.ts
index 948531386c..f3a9102d18 100644
--- a/packages/lambda/src/test/integration/handlers.test.ts
+++ b/packages/lambda/src/test/integration/handlers.test.ts
@@ -1,6 +1,6 @@
+import {LambdaRoutines} from '@remotion/serverless/client';
import {VERSION} from 'remotion/version';
import {expect, test} from 'vitest';
-import {LambdaRoutines} from '../../defaults';
import {callLambda} from '../../shared/call-lambda';
test('Call function locally', async () => {
diff --git a/packages/lambda/src/test/integration/renders/old-version.test.ts b/packages/lambda/src/test/integration/renders/old-version.test.ts
index cb3d6da91e..f903397436 100644
--- a/packages/lambda/src/test/integration/renders/old-version.test.ts
+++ b/packages/lambda/src/test/integration/renders/old-version.test.ts
@@ -1,6 +1,6 @@
import {RenderInternals} from '@remotion/renderer';
+import {LambdaRoutines} from '@remotion/serverless/client';
import {afterAll, expect, test} from 'vitest';
-import {LambdaRoutines} from '../../../defaults';
import {callLambda} from '../../../shared/call-lambda';
afterAll(async () => {
diff --git a/packages/lambda/src/test/integration/simulate-lambda-render.ts b/packages/lambda/src/test/integration/simulate-lambda-render.ts
index 6a9ecfae16..94c077573a 100644
--- a/packages/lambda/src/test/integration/simulate-lambda-render.ts
+++ b/packages/lambda/src/test/integration/simulate-lambda-render.ts
@@ -1,10 +1,10 @@
import {RenderInternals} from '@remotion/renderer';
+import {LambdaRoutines} from '@remotion/serverless/client';
import path from 'path';
import {VERSION} from 'remotion/version';
import {makeLambdaRenderMediaPayload} from '../../api/make-lambda-payload';
import type {RenderMediaOnLambdaInput} from '../../api/render-media-on-lambda';
import {renderMediaOnLambdaOptionalToRequired} from '../../api/render-media-on-lambda';
-import {LambdaRoutines} from '../../defaults';
import {lambdaReadFile} from '../../functions/helpers/io';
import {callLambda} from '../../shared/call-lambda';
diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.ts
index 74348438fd..5f28d387bd 100644
--- a/packages/lambda/src/test/integration/webhooks.test.ts
+++ b/packages/lambda/src/test/integration/webhooks.test.ts
@@ -1,8 +1,8 @@
import {RenderInternals} from '@remotion/renderer';
+import {LambdaRoutines} from '@remotion/serverless/client';
import path from 'path';
import {VERSION} from 'remotion/version';
import {beforeAll, beforeEach, describe, expect, test, vi} from 'vitest';
-import {LambdaRoutines} from '../../defaults';
import {callLambda} from '../../shared/call-lambda';
import {mockableHttpClients} from '../../shared/invoke-webhook';
diff --git a/packages/lambda/src/test/unit/handlers.test.ts b/packages/lambda/src/test/unit/handlers.test.ts
index 94f648489d..3048b0458f 100644
--- a/packages/lambda/src/test/unit/handlers.test.ts
+++ b/packages/lambda/src/test/unit/handlers.test.ts
@@ -1,6 +1,6 @@
+import {LambdaRoutines} from '@remotion/serverless/client';
import {expect, test} from 'vitest';
import {callLambda} from '../../shared/call-lambda';
-import {LambdaRoutines} from '../../shared/constants';
test('Info handler should return version', async () => {
const response = await callLambda({
diff --git a/packages/serverless/package.json b/packages/serverless/package.json
index 0471c770a5..c026b62568 100644
--- a/packages/serverless/package.json
+++ b/packages/serverless/package.json
@@ -21,10 +21,19 @@
"access": "public"
},
"dependencies": {
+ "remotion": "workspace:*",
"@remotion/renderer": "workspace:*"
},
"exports": {
".": "./dist/index.js",
+ "./client": "./dist/client.js",
"./package.json": "./package.json"
+ },
+ "typesVersions": {
+ ">=1.0": {
+ "client": [
+ "dist/client.d.ts"
+ ]
+ }
}
}
diff --git a/packages/serverless/src/client.ts b/packages/serverless/src/client.ts
new file mode 100644
index 0000000000..47ce697168
--- /dev/null
+++ b/packages/serverless/src/client.ts
@@ -0,0 +1,19 @@
+export {
+ LambdaCodec,
+ LambdaPayload,
+ LambdaPayloads,
+ LambdaRoutines,
+ LambdaStartPayload,
+ LambdaStatusPayload,
+ expiryDays,
+ lambdaCodecs,
+ type CustomCredentials,
+ type CustomCredentialsWithoutSensitiveData,
+ type DeleteAfter,
+ type DownloadBehavior,
+ type OutNameInput,
+ type Privacy,
+ type SerializedInputProps,
+ type WebhookOption,
+} from './constants';
+export {AWS_REGIONS, AwsRegion, DEFAULT_AWS_REGIONS} from './region';
diff --git a/packages/serverless/src/constants.ts b/packages/serverless/src/constants.ts
new file mode 100644
index 0000000000..c5fa353965
--- /dev/null
+++ b/packages/serverless/src/constants.ts
@@ -0,0 +1,298 @@
+import type {
+ AudioCodec,
+ ChromiumOptions,
+ ColorSpace,
+ FrameRange,
+ LogLevel,
+ PixelFormat,
+ ProResProfile,
+ StillImageFormat,
+ ToOptions,
+ VideoImageFormat,
+ X264Preset,
+} from '@remotion/renderer';
+import type {BrowserSafeApis} from '@remotion/renderer/client';
+import type {AwsRegion} from './region';
+
+// Needs to be in sync with renderer/src/options/delete-after.ts#L7
+export const expiryDays = {
+ '1-day': 1,
+ '3-days': 3,
+ '7-days': 7,
+ '30-days': 30,
+} as const;
+
+export type DeleteAfter = keyof typeof expiryDays;
+
+export enum LambdaRoutines {
+ info = 'info',
+ start = 'start',
+ launch = 'launch',
+ status = 'status',
+ renderer = 'renderer',
+ still = 'still',
+ compositions = 'compositions',
+}
+
+export type CustomCredentialsWithoutSensitiveData = {
+ endpoint: string;
+};
+
+export type CustomCredentials = CustomCredentialsWithoutSensitiveData & {
+ accessKeyId: string | null;
+ secretAccessKey: string | null;
+ region?: AwsRegion;
+};
+
+export type OutNameInput =
+ | string
+ | {
+ bucketName: string;
+ key: string;
+ s3OutputProvider?: CustomCredentials;
+ };
+
+export type SerializedInputProps =
+ | {
+ type: 'bucket-url';
+ hash: string;
+ bucketName: string;
+ }
+ | {
+ type: 'payload';
+ payload: string;
+ };
+
+export const lambdaCodecs = [
+ 'h264',
+ 'h265',
+ 'vp8',
+ 'vp9',
+ 'mp3',
+ 'aac',
+ 'wav',
+ 'gif',
+ 'prores',
+] as const;
+
+export type LambdaCodec = (typeof lambdaCodecs)[number];
+export type Privacy = 'public' | 'private' | 'no-acl';
+
+export type DownloadBehavior =
+ | {
+ type: 'play-in-browser';
+ }
+ | {
+ type: 'download';
+ fileName: string | null;
+ };
+
+type Prettify<T> = {
+ [K in keyof T]: T[K];
+} & {};
+
+export type WebhookOption = Prettify<
+ | null
+ | ({
+ url: string;
+ secret: string | null;
+ } & Partial<
+ ToOptions<{
+ customData: typeof BrowserSafeApis.options.webhookCustomDataOption;
+ }>
+ >)
+>;
+
+export type LambdaStatusPayload = {
+ type: LambdaRoutines.status;
+ bucketName: string;
+ renderId: string;
+ version: string;
+ logLevel: LogLevel;
+ s3OutputProvider?: CustomCredentials;
+};
+
+export type LambdaStartPayload = {
+ rendererFunctionName: string | null;
+ type: LambdaRoutines.start;
+ serveUrl: string;
+ composition: string;
+ framesPerLambda: number | null;
+ inputProps: SerializedInputProps;
+ codec: LambdaCodec;
+ audioCodec: AudioCodec | null;
+ imageFormat: VideoImageFormat;
+ crf: number | undefined;
+ envVariables: Record<string, string> | undefined;
+ pixelFormat: PixelFormat | undefined;
+ proResProfile: ProResProfile | undefined;
+ x264Preset: X264Preset | null;
+ jpegQuality: number | undefined;
+ maxRetries: number;
+ privacy: Privacy;
+ logLevel: LogLevel;
+ frameRange: FrameRange | null;
+ outName: OutNameInput | null;
+ timeoutInMilliseconds: number;
+ chromiumOptions: ChromiumOptions;
+ scale: number;
+ everyNthFrame: number;
+ numberOfGifLoops: number | null;
+ concurrencyPerLambda: number;
+ downloadBehavior: DownloadBehavior;
+ muted: boolean;
+ version: string;
+ overwrite: boolean;
+ audioBitrate: string | null;
+ videoBitrate: string | null;
+ encodingMaxRate: string | null;
+ encodingBufferSize: string | null;
+ webhook: WebhookOption;
+ forceHeight: number | null;
+ forceWidth: number | null;
+ bucketName: string | null;
+ offthreadVideoCacheSizeInBytes: number | null;
+ deleteAfter: DeleteAfter | null;
+ colorSpace: ColorSpace | null;
+ preferLossless: boolean;
+};
+
+export type LambdaPayloads = {
+ info: {
+ type: LambdaRoutines.info;
+ logLevel: LogLevel;
+ };
+ start: LambdaStartPayload;
+ launch: {
+ rendererFunctionName: string | null;
+ type: LambdaRoutines.launch;
+ serveUrl: string;
+ composition: string;
+ framesPerLambda: number | null;
+ bucketName: string;
+ inputProps: SerializedInputProps;
+ renderId: string;
+ imageFormat: VideoImageFormat;
+ codec: LambdaCodec;
+ audioCodec: AudioCodec | null;
+ crf: number | undefined;
+ envVariables: Record<string, string> | undefined;
+ pixelFormat: PixelFormat | undefined;
+ proResProfile: ProResProfile | undefined;
+ x264Preset: X264Preset | null;
+ jpegQuality: number | undefined;
+ maxRetries: number;
+ privacy: Privacy;
+ logLevel: LogLevel;
+ frameRange: FrameRange | null;
+ outName: OutNameInput | null;
+ timeoutInMilliseconds: number;
+ chromiumOptions: ChromiumOptions;
+ scale: number;
+ everyNthFrame: number;
+ numberOfGifLoops: number | null;
+ concurrencyPerLambda: number;
+ downloadBehavior: DownloadBehavior;
+ muted: boolean;
+ overwrite: boolean;
+ audioBitrate: string | null;
+ videoBitrate: string | null;
+ encodingMaxRate: string | null;
+ encodingBufferSize: string | null;
+ webhook: WebhookOption;
+ forceHeight: number | null;
+ forceWidth: number | null;
+ offthreadVideoCacheSizeInBytes: number | null;
+ deleteAfter: DeleteAfter | null;
+ colorSpace: ColorSpace | null;
+ preferLossless: boolean;
+ };
+ status: LambdaStatusPayload;
+ renderer: {
+ concurrencyPerLambda: number;
+ type: LambdaRoutines.renderer;
+ serveUrl: string;
+ frameRange: [number, number];
+ chunk: number;
+ bucketName: string;
+ composition: string;
+ fps: number;
+ height: number;
+ width: number;
+ durationInFrames: number;
+ retriesLeft: number;
+ inputProps: SerializedInputProps;
+ renderId: string;
+ imageFormat: VideoImageFormat;
+ codec: LambdaCodec;
+ crf: number | undefined;
+ proResProfile: ProResProfile | undefined;
+ x264Preset: X264Preset | null;
+ pixelFormat: PixelFormat | undefined;
+ jpegQuality: number | undefined;
+ envVariables: Record<string, string> | undefined;
+ privacy: Privacy;
+ attempt: number;
+ logLevel: LogLevel;
+ timeoutInMilliseconds: number;
+ chromiumOptions: ChromiumOptions;
+ resolvedProps: SerializedInputProps;
+ scale: number;
+ everyNthFrame: number;
+ muted: boolean;
+ audioBitrate: string | null;
+ videoBitrate: string | null;
+ encodingBufferSize: string | null;
+ encodingMaxRate: string | null;
+ launchFunctionConfig: {
+ version: string;
+ };
+ preferLossless: boolean;
+ offthreadVideoCacheSizeInBytes: number | null;
+ deleteAfter: DeleteAfter | null;
+ colorSpace: ColorSpace | null;
+ compositionStart: number;
+ framesPerLambda: number;
+ progressEveryNthFrame: number;
+ };
+ still: {
+ type: LambdaRoutines.still;
+ serveUrl: string;
+ composition: string;
+ inputProps: SerializedInputProps;
+ imageFormat: StillImageFormat;
+ envVariables: Record<string, string>;
+ attempt: number;
+ jpegQuality: number | undefined;
+ maxRetries: number;
+ frame: number;
+ privacy: Privacy;
+ logLevel: LogLevel;
+ outName: OutNameInput | null;
+ timeoutInMilliseconds: number;
+ chromiumOptions: ChromiumOptions;
+ scale: number;
+ downloadBehavior: DownloadBehavior;
+ version: string;
+ forceHeight: number | null;
+ forceWidth: number | null;
+ bucketName: string | null;
+ offthreadVideoCacheSizeInBytes: number | null;
+ deleteAfter: DeleteAfter | null;
+ streamed: boolean;
+ };
+ compositions: {
+ type: LambdaRoutines.compositions;
+ version: string;
+ chromiumOptions: ChromiumOptions;
+ logLevel: LogLevel;
+ inputProps: SerializedInputProps;
+ envVariables: Record<string, string> | undefined;
+ timeoutInMilliseconds: number;
+ serveUrl: string;
+ bucketName: string | null;
+ offthreadVideoCacheSizeInBytes: number | null;
+ };
+};
+
+export type LambdaPayload = LambdaPayloads[LambdaRoutines];
diff --git a/packages/serverless/src/info.ts b/packages/serverless/src/info.ts
new file mode 100644
index 0000000000..9a5c0f35b3
--- /dev/null
+++ b/packages/serverless/src/info.ts
@@ -0,0 +1,16 @@
+import {VERSION} from 'remotion/version';
+import type {LambdaPayload} from './constants';
+import {LambdaRoutines} from './constants';
+
+export const infoHandler = (lambdaParams: LambdaPayload) => {
+ if (lambdaParams.type !== LambdaRoutines.info) {
+ throw new TypeError('Expected info type');
+ }
+
+ const returnValue = {
+ version: VERSION,
+ type: 'success' as const,
+ };
+
+ return Promise.resolve(returnValue);
+};
diff --git a/packages/serverless/src/region.ts b/packages/serverless/src/region.ts
new file mode 100644
index 0000000000..8bbae45f60
--- /dev/null
+++ b/packages/serverless/src/region.ts
@@ -0,0 +1,45 @@
+export const DEFAULT_AWS_REGIONS = [
+ 'eu-central-1',
+ 'eu-west-1',
+ 'eu-west-2',
+ 'eu-west-3',
+ 'eu-north-1',
+ 'us-east-1', // N. Virginia
+ 'us-east-2', // Ohio;
+ 'us-west-1',
+ 'us-west-2', // Oregon
+ 'ap-south-1',
+ 'ap-southeast-1',
+ 'ap-southeast-2',
+ 'ap-northeast-1',
+ 'ap-northeast-2',
+ 'ap-northeast-3',
+ 'ca-central-1',
+ 'sa-east-1',
+] as const;
+
+export const AWS_REGIONS = [
+ 'eu-central-1',
+ 'eu-west-1',
+ 'eu-west-2',
+ 'eu-west-3',
+ 'eu-south-1',
+ 'eu-north-1',
+ 'us-east-1', // N. Virginia
+ 'us-east-2', // Ohio;
+ 'us-west-1',
+ 'us-west-2', // Oregon
+ 'af-south-1',
+ 'ap-south-1',
+ 'ap-east-1',
+ 'ap-southeast-1',
+ 'ap-southeast-2',
+ 'ap-northeast-1',
+ 'ap-northeast-2',
+ 'ap-northeast-3',
+ 'ca-central-1',
+ 'me-south-1',
+ 'sa-east-1',
+] as const;
+
+export type AwsRegion = (typeof AWS_REGIONS)[number];
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a82c62bbf1..9b9d449cb9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1071,6 +1071,9 @@ importers:
'@remotion/renderer':
specifier: workspace:*
version: link:../renderer
+ '@remotion/serverless':
+ specifier: workspace:*
+ version: link:../serverless
'@remotion/streaming':
specifier: workspace:*
version: link:../streaming
@@ -1336,6 +1339,9 @@ importers:
'@remotion/renderer':
specifier: workspace:*
version: link:../renderer
+ remotion:
+ specifier: workspace:*
+ version: link:../core
packages/shapes:
dependencies: