🎥 Make videos programmatically with React
`@remotion/lambda-client`: New package
Jonny Burger485d2ad77523
diff --git a/packages/.monorepo/builder.ts b/packages/.monorepo/builder.tsindex c789e51f37..b829eef339 100644--- a/packages/.monorepo/builder.ts+++ b/packages/.monorepo/builder.ts@@ -33,6 +33,7 @@ const validateExports = (entry !== 'module' &&entry !== 'types') {+ console.log(exports);throw new Error(`Invalid export: ${entry}`);}const pathToCheck = path.join(process.cwd(), value[entry]);@@ -44,6 +45,16 @@ const validateExports = (}};+const getExternal = (deps: string[] | 'dependencies'): string[] => {+ if (deps === 'dependencies') {+ return Object.keys(+ require(path.join(process.cwd(), 'package.json')).dependencies,+ );+ }++ return deps;+};+export const buildPackage = async ({formats,external,@@ -51,7 +62,7 @@ export const buildPackage = async ({entrypoints,}: {formats: Format[];- external: string[];+ external: 'dependencies' | string[];target: 'node' | 'browser';entrypoints: string[];}) => {@@ -65,24 +76,32 @@ export const buildPackage = async ({const output = await build({entrypoints: entrypoints.map((e) => path.join(process.cwd(), e)),naming: `[name].${format === 'esm' ? 'mjs' : 'js'}`,- external,+ external: getExternal(external),target,format,});for (const file of output.outputs) {const text = await file.text();- if (text.includes('jonathanburger')) {- throw new Error('Absolute path was included');- }const outputPath = './' + path.join('./dist', format, file.path);+ const typesOutputPath =+ './' ++ path.join(+ './dist',+ file.path.replace('.mjs', '.d.ts').replace('.js', '.d.ts'),+ );await Bun.write(path.join(process.cwd(), outputPath), text);+ if (text.includes('jonathanburger')) {+ throw new Error('Absolute path was included, see ' + outputPath);+ }+const firstName = file.path.split('.')[1].slice(1);- const exportName = firstName === 'index' ? '.' : firstName;+ const exportName = firstName === 'index' ? '.' : './' + firstName;newExports[exportName] = {...(newExports[exportName] ?? {}),+ types: typesOutputPath,...(format === 'esm'? {import: outputPath,diff --git a/packages/example/package.json b/packages/example/package.jsonindex 3aa45db58d..970376454a 100644--- a/packages/example/package.json+++ b/packages/example/package.json@@ -44,6 +44,7 @@"@remotion/gif": "workspace:*","@remotion/google-fonts": "workspace:*","@remotion/lambda": "workspace:*",+ "@remotion/lambda-client": "workspace:*","@remotion/layout-utils": "workspace:*","@remotion/lottie": "workspace:*","@remotion/media-utils": "workspace:*",diff --git a/packages/example/run-lambda-repro.ts b/packages/example/run-lambda-repro.tsindex a1783421e1..12a8e76636 100644--- a/packages/example/run-lambda-repro.ts+++ b/packages/example/run-lambda-repro.ts@@ -1,7 +1,3 @@-import {- _InternalAwsProvider,- _InternalOverallRenderProgress,-} from '@remotion/lambda';import {$} from 'bun';const progress = (await Bun.file(diff --git a/packages/lambda-client/.gitignore b/packages/lambda-client/.gitignorenew file mode 100644index 0000000000..3c3629e647--- /dev/null+++ b/packages/lambda-client/.gitignore@@ -0,0 +1 @@+node_modulesdiff --git a/packages/lambda-client/bundle.ts b/packages/lambda-client/bundle.tsnew file mode 100644index 0000000000..dacec41c63--- /dev/null+++ b/packages/lambda-client/bundle.ts@@ -0,0 +1,8 @@+import {buildPackage} from '../.monorepo/builder';++await buildPackage({+ formats: ['cjs', 'esm'],+ external: 'dependencies',+ target: 'node',+ entrypoints: ['src/index.ts', 'src/constants.ts', 'src/regions.ts'],+});diff --git a/packages/lambda-client/eslint.config.mjs b/packages/lambda-client/eslint.config.mjsnew file mode 100644index 0000000000..ce2fc683dd--- /dev/null+++ b/packages/lambda-client/eslint.config.mjs@@ -0,0 +1,5 @@+import {remotionFlatConfig} from '@remotion/eslint-config-internal';++const config = remotionFlatConfig({react: false});++export default [config];diff --git a/packages/lambda-client/package.json b/packages/lambda-client/package.jsonnew file mode 100644index 0000000000..b49f1757ae--- /dev/null+++ b/packages/lambda-client/package.json@@ -0,0 +1,70 @@+{+ "repository": {+ "url": "https://github.com/remotion-dev/remotion/tree/main/packages/lambda"+ },+ "name": "@remotion/lambda-client",+ "version": "4.0.260",+ "description": "Render Remotion videos on AWS Lambda",+ "main": "dist/index.js",+ "sideEffects": false,+ "scripts": {+ "formatting": "prettier src --check",+ "lint": "eslint src",+ "make": "tsc -d && bun --env-file=../.env.bundle bundle.ts"+ },+ "author": "Jonny Burger <[email protected]>",+ "license": "MIT",+ "dependencies": {+ "@aws-sdk/client-cloudwatch-logs": "3.738.0",+ "@aws-sdk/client-iam": "3.738.0",+ "@aws-sdk/client-lambda": "3.738.0",+ "@aws-sdk/s3-request-presigner": "3.738.0",+ "@aws-sdk/client-s3": "3.738.0",+ "@aws-sdk/client-service-quotas": "3.738.0",+ "@aws-sdk/client-sts": "3.738.0",+ "@remotion/serverless": "workspace:*",+ "@remotion/streaming": "workspace:*"+ },+ "devDependencies": {+ "@types/express": "^5.0.0",+ "express": "4.21.0",+ "@remotion/eslint-config-internal": "workspace:*",+ "eslint": "9.19.0",+ "next": "15.1.6"+ },+ "publishConfig": {+ "access": "public"+ },+ "exports": {+ "./package.json": "./package.json",+ ".": {+ "require": "./dist/cjs/index.js",+ "import": "./dist/esm/index.mjs",+ "module": "./dist/esm/index.mjs",+ "types": "./dist/index.d.ts"+ },+ "./constants": {+ "types": "./dist/constants.d.ts",+ "require": "./dist/cjs/constants.js",+ "import": "./dist/esm/constants.mjs",+ "module": "./dist/esm/constants.mjs"+ },+ "./regions": {+ "types": "./dist/regions.d.ts",+ "require": "./dist/cjs/regions.js",+ "import": "./dist/esm/regions.mjs",+ "module": "./dist/esm/regions.mjs"+ }+ },+ "typesVersions": {+ ">=1.0": {+ "constants": [+ "dist/constants.d.ts"+ ],+ "regions": [+ "dist/regions.d.ts"+ ]+ }+ },+ "homepage": "https://www.remotion.dev/docs/lambda"+}diff --git a/packages/lambda/src/api/app-router-webhook.ts b/packages/lambda-client/src/app-router-webhook.tssimilarity index 100%rename from packages/lambda/src/api/app-router-webhook.tsrename to packages/lambda-client/src/app-router-webhook.tsdiff --git a/packages/lambda/src/functions/helpers/apply-lifecyle.ts b/packages/lambda-client/src/apply-lifecycle.tssimilarity index 100%rename from packages/lambda/src/functions/helpers/apply-lifecyle.tsrename to packages/lambda-client/src/apply-lifecycle.tsdiff --git a/packages/lambda/src/shared/aws-clients.ts b/packages/lambda-client/src/aws-clients.tssimilarity index 97%rename from packages/lambda/src/shared/aws-clients.tsrename to packages/lambda-client/src/aws-clients.tsindex 9eafde8a2d..ad66ecefc4 100644--- a/packages/lambda/src/shared/aws-clients.ts+++ b/packages/lambda-client/src/aws-clients.ts@@ -3,8 +3,8 @@ import type {IAMClient} from '@aws-sdk/client-iam';import type {LambdaClient} from '@aws-sdk/client-lambda';import type {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';import type {STSClient} from '@aws-sdk/client-sts';-import type {AwsRegion} from '../regions';import {getServiceClient} from './get-service-client';+import type {AwsRegion} from './regions';export const getCloudWatchLogsClient = (region: AwsRegion,diff --git a/packages/lambda/src/functions/aws-implementation.ts b/packages/lambda-client/src/aws-provider.tssimilarity index 60%rename from packages/lambda/src/functions/aws-implementation.tsrename to packages/lambda-client/src/aws-provider.tsindex ced5cb9ff3..844d27b3e7 100644--- a/packages/lambda/src/functions/aws-implementation.ts+++ b/packages/lambda-client/src/aws-provider.ts@@ -1,37 +1,53 @@+import type {AwsRegion} from './regions';++export type AwsProvider = {+ type: 'aws';+ region: AwsRegion;+ receivedArtifactType: {+ s3Key: string;+ s3Url: string;+ };+ creationFunctionOptions: {+ createCloudWatchLogGroup: boolean;+ accountId: string;+ alreadyCreated: boolean;+ retentionInDays: number;+ customRoleArn: string;+ enableLambdaInsights: boolean;+ vpcSubnetIds: string;+ vpcSecurityGroupIds: string;+ runtimePreference: RuntimePreference;+ };+};+import type {ProviderSpecifics} from '@remotion/serverless';import {expiryDays} from '@remotion/serverless/client';import {EventEmitter} from 'node:events';-import {bucketExistsInRegionImplementation} from '../api/bucket-exists';-import {createBucket} from '../api/create-bucket';-import {deleteFunction} from '../api/delete-function';-import {estimatePrice} from '../api/estimate-price';-import {getRemotionBuckets} from '../api/get-buckets';-import {getFunctions} from '../api/get-functions';-import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../defaults';-import {lambdaDeleteFileImplementation} from '../io/delete-file';-import {lambdaHeadFileImplementation} from '../io/head-file';-import {lambdaLsImplementation} from '../io/list-objects';-import {lambdaReadFileImplementation} from '../io/read-file';-import {lambdaWriteFileImplementation} from '../io/write-file';-import type {AwsRegion} from '../regions';-import {callFunctionAsyncImplementation} from '../shared/call-lambda-async';-import {callFunctionWithStreamingImplementation} from '../shared/call-lambda-streaming';-import {callFunctionSyncImplementation} from '../shared/call-lambda-sync';-import {convertToServeUrlImplementation} from '../shared/convert-to-serve-url';-import {getAccountIdImplementation} from '../shared/get-account-id';-import {- getCloudwatchMethodUrl,- getCloudwatchRendererUrl,-} from '../shared/get-aws-urls';-import type {RuntimePreference} from '../shared/get-layers';-import {isFlakyError} from '../shared/is-flaky-error';-import {applyLifeCyleOperation} from '../shared/lifecycle-rules';-import {randomHashImplementation} from '../shared/random-hash';-import {getCurrentRegionInFunctionImplementation} from './helpers/get-current-region';-import {getFolderFiles} from './helpers/get-folder-files';-import {getOutputUrlFromMetadata} from './helpers/get-output-url-from-metadata';-import {makeAwsArtifact} from './helpers/make-aws-artifact';-import {parseFunctionName} from './helpers/parse-function-name';+import {bucketExistsInRegionImplementation} from './bucket-exists';+import {callFunctionAsyncImplementation} from './call-lambda-async';+import {callFunctionWithStreamingImplementation} from './call-lambda-streaming';+import {callFunctionSyncImplementation} from './call-lambda-sync';+import {checkCredentials} from './check-credentials';+import {MAX_EPHEMERAL_STORAGE_IN_MB} from './constants';+import {convertToServeUrlImplementation} from './convert-to-serve-url';+import {createBucket} from './create-bucket';+import {lambdaDeleteFileImplementation} from './delete-file';+import {deleteFunction} from './delete-function';+import {estimatePrice} from './estimate-price';+import {getAccountIdImplementation} from './get-account-id';+import {getCloudwatchMethodUrl, getCloudwatchRendererUrl} from './get-aws-urls';+import {getRemotionBuckets} from './get-buckets';+import {getFunctions} from './get-functions';+import {getOutputUrlFromMetadata} from './get-output-url-from-metadata';+import {lambdaHeadFileImplementation} from './head-file';+import {isFlakyError} from './is-flaky-error';+import {applyLifeCyleOperation} from './lifecycle-rules';+import {lambdaLsImplementation} from './list-objects';+import {parseFunctionName} from './parse-function-name';+import {randomHashImplementation} from './random-hash';+import {lambdaReadFileImplementation} from './read-file';+import type {RuntimePreference} from './runtime-preference';+import {lambdaWriteFileImplementation} from './write-file';if (/^AWS_Lambda_nodejs(?:18|20)[.]x$/.test(@@ -51,26 +67,6 @@ if ((globalThis._dumpUnreleasedBuffers as EventEmitter).setMaxListeners(201);}-export type AwsProvider = {- type: 'aws';- region: AwsRegion;- receivedArtifactType: {- s3Key: string;- s3Url: string;- };- creationFunctionOptions: {- createCloudWatchLogGroup: boolean;- accountId: string;- alreadyCreated: boolean;- retentionInDays: number;- customRoleArn: string;- enableLambdaInsights: boolean;- vpcSubnetIds: string;- vpcSecurityGroupIds: string;- runtimePreference: RuntimePreference;- };-};-const validateDeleteAfter = (lifeCycleValue: unknown) => {if (lifeCycleValue === null) {return;@@ -101,7 +97,6 @@ export const awsImplementation: ProviderSpecifics<AwsProvider> = {getChromiumPath() {return '/opt/bin/chromium';},- getCurrentRegionInFunction: getCurrentRegionInFunctionImplementation,getBuckets: getRemotionBuckets,createBucket,applyLifeCycle: applyLifeCyleOperation,@@ -114,8 +109,6 @@ export const awsImplementation: ProviderSpecifics<AwsProvider> = {headFile: lambdaHeadFileImplementation,convertToServeUrl: convertToServeUrlImplementation,printLoggingHelper: true,- getFolderFiles,- makeArtifactWithDetails: makeAwsArtifact,validateDeleteAfter,callFunctionAsync: callFunctionAsyncImplementation,callFunctionStreaming: callFunctionWithStreamingImplementation,@@ -137,4 +130,5 @@ export const awsImplementation: ProviderSpecifics<AwsProvider> = {deleteFunction,getFunctions,parseFunctionName,+ checkCredentials,};diff --git a/packages/lambda/src/api/bucket-exists.ts b/packages/lambda-client/src/bucket-exists.tssimilarity index 86%rename from packages/lambda/src/api/bucket-exists.tsrename to packages/lambda-client/src/bucket-exists.tsindex 836504478e..70fc4d6bba 100644--- a/packages/lambda/src/api/bucket-exists.ts+++ b/packages/lambda-client/src/bucket-exists.ts@@ -1,7 +1,7 @@import {GetBucketLocationCommand} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {getS3Client} from '../shared/get-s3-client';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';export const bucketExistsInRegionImplementation: ProviderSpecifics<AwsProvider>['bucketExists'] =async ({bucketName, region, expectedBucketOwner, forcePathStyle}) => {diff --git a/packages/lambda/src/shared/call-lambda-async.ts b/packages/lambda-client/src/call-lambda-async.tssimilarity index 96%rename from packages/lambda/src/shared/call-lambda-async.tsrename to packages/lambda-client/src/call-lambda-async.tsindex ea5feef81c..560e044e64 100644--- a/packages/lambda/src/shared/call-lambda-async.ts+++ b/packages/lambda-client/src/call-lambda-async.ts@@ -1,8 +1,8 @@import {InvokeCommand} from '@aws-sdk/client-lambda';import type {CallFunctionOptions, CloudProvider} from '@remotion/serverless';import type {ServerlessRoutines} from '@remotion/serverless/client';-import type {AwsRegion} from '../regions';import {getLambdaClient} from './aws-clients';+import type {AwsRegion} from './regions';export const callFunctionAsyncImplementation = async <T extends ServerlessRoutines,diff --git a/packages/lambda/src/shared/call-lambda-streaming.ts b/packages/lambda-client/src/call-lambda-streaming.tssimilarity index 98%rename from packages/lambda/src/shared/call-lambda-streaming.tsrename to packages/lambda-client/src/call-lambda-streaming.tsindex 4828924e4e..3b44e74000 100644--- a/packages/lambda/src/shared/call-lambda-streaming.ts+++ b/packages/lambda-client/src/call-lambda-streaming.ts@@ -1,3 +1,4 @@+/* eslint-disable no-console */import type {InvokeWithResponseStreamCommandOutput} from '@aws-sdk/client-lambda';import {InvokeWithResponseStreamCommand,@@ -18,8 +19,8 @@ import {messageTypeIdToMessageType,} from '@remotion/serverless/client';import {makeStreamer} from '@remotion/streaming';-import type {AwsRegion} from '../regions';import {getLambdaClient} from './aws-clients';+import type {AwsRegion} from './regions';const STREAM_STALL_TIMEOUT = 30000;const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;diff --git a/packages/lambda/src/shared/call-lambda-sync.ts b/packages/lambda-client/src/call-lambda-sync.tssimilarity index 97%rename from packages/lambda/src/shared/call-lambda-sync.tsrename to packages/lambda-client/src/call-lambda-sync.tsindex 37bd33c832..137e99272b 100644--- a/packages/lambda/src/shared/call-lambda-sync.ts+++ b/packages/lambda-client/src/call-lambda-sync.ts@@ -6,8 +6,8 @@ import type {ServerlessReturnValues,} from '@remotion/serverless';import type {ServerlessRoutines} from '@remotion/serverless/client';-import type {AwsRegion} from '../regions';import {getLambdaClient} from './aws-clients';+import type {AwsRegion} from './regions';const callLambdaSyncWithoutRetry = async <T extends ServerlessRoutines,diff --git a/packages/lambda/src/shared/check-credentials.ts b/packages/lambda-client/src/check-credentials.tssimilarity index 97%rename from packages/lambda/src/shared/check-credentials.tsrename to packages/lambda-client/src/check-credentials.tsindex 86e14d9ece..d80505e128 100644--- a/packages/lambda/src/shared/check-credentials.ts+++ b/packages/lambda-client/src/check-credentials.ts@@ -1,6 +1,6 @@import {DOCS_URL, truthy} from '@remotion/serverless/client';-import {getIsCli} from '../cli/is-cli';import {getEnvVariable} from './get-env-variable';+import {getIsCli} from './is-cli';import {isLikelyToHaveAwsProfile} from './is-likely-to-have-aws-profile';const messageForVariable = (variable: string) => {diff --git a/packages/lambda/src/api/clean-items.ts b/packages/lambda-client/src/clean-items.tssimilarity index 95%rename from packages/lambda/src/api/clean-items.tsrename to packages/lambda-client/src/clean-items.tsindex f441243fb2..fb53e0bdfe 100644--- a/packages/lambda/src/api/clean-items.ts+++ b/packages/lambda-client/src/clean-items.ts@@ -1,5 +1,5 @@import type {CloudProvider, ProviderSpecifics} from '@remotion/serverless';-import {pLimit} from '../shared/p-limit';+import {pLimit} from './p-limit';const limit = pLimit(10);diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda-client/src/constants.tssimilarity index 92%rename from packages/lambda/src/shared/constants.tsrename to packages/lambda-client/src/constants.tsindex c9cf020a33..3bbf80b502 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda-client/src/constants.ts@@ -4,8 +4,8 @@ import {MINIMUM_FRAMES_PER_FUNCTIONS,} from '@remotion/serverless/client';import {NoReactInternals} from 'remotion/no-react';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import type {AwsProvider} from './aws-provider';+import type {AwsRegion} from './regions';export const MIN_MEMORY = 512;export const MAX_MEMORY = 10240;diff --git a/packages/lambda/src/shared/content-disposition-header.ts b/packages/lambda-client/src/content-disposition-header.tssimilarity index 100%rename from packages/lambda/src/shared/content-disposition-header.tsrename to packages/lambda-client/src/content-disposition-header.tsdiff --git a/packages/lambda/src/shared/convert-to-serve-url.ts b/packages/lambda-client/src/convert-to-serve-url.tssimilarity index 93%rename from packages/lambda/src/shared/convert-to-serve-url.tsrename to packages/lambda-client/src/convert-to-serve-url.tsindex b3f0b242be..157a345e91 100644--- a/packages/lambda/src/shared/convert-to-serve-url.ts+++ b/packages/lambda-client/src/convert-to-serve-url.ts@@ -1,5 +1,5 @@import {DOCS_URL} from '@remotion/serverless/client';-import type {AwsRegion} from '../regions';+import type {AwsRegion} from './regions';export const convertToServeUrlImplementation = ({urlOrId,diff --git a/packages/lambda/src/api/create-bucket.ts b/packages/lambda-client/src/create-bucket.tssimilarity index 95%rename from packages/lambda/src/api/create-bucket.tsrename to packages/lambda-client/src/create-bucket.tsindex bf47734b71..e3c9d254fc 100644--- a/packages/lambda/src/api/create-bucket.ts+++ b/packages/lambda-client/src/create-bucket.ts@@ -5,8 +5,8 @@ import {PutBucketAclCommand,} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {getS3Client} from '../shared/get-s3-client';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';export const createBucket: ProviderSpecifics<AwsProvider>['createBucket'] =async ({region, bucketName, forcePathStyle}) => {diff --git a/packages/lambda/src/io/delete-file.ts b/packages/lambda-client/src/delete-file.tssimilarity index 74%rename from packages/lambda/src/io/delete-file.tsrename to packages/lambda-client/src/delete-file.tsindex 9906133931..50704181a8 100644--- a/packages/lambda/src/io/delete-file.ts+++ b/packages/lambda-client/src/delete-file.ts@@ -1,9 +1,9 @@import {DeleteObjectCommand} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';-import type {CustomCredentials} from '../client';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {getS3Client} from '../shared/get-s3-client';+import type {CustomCredentials} from '@remotion/serverless/client';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';+import type {AwsRegion} from './regions';export const lambdaDeleteFileImplementation: ProviderSpecifics<AwsProvider>['deleteFile'] =async ({diff --git a/packages/lambda/src/api/delete-function.ts b/packages/lambda-client/src/delete-function.tssimilarity index 84%rename from packages/lambda/src/api/delete-function.tsrename to packages/lambda-client/src/delete-function.tsindex 6ca61c2a6c..052e5a1431 100644--- a/packages/lambda/src/api/delete-function.ts+++ b/packages/lambda-client/src/delete-function.ts@@ -3,8 +3,8 @@ import type {DeleteFunction,DeleteFunctionInput as GenericDeleteFunctionInput,} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {getLambdaClient} from '../shared/aws-clients';+import {getLambdaClient} from './aws-clients';+import type {AwsProvider} from './aws-provider';export type DeleteFunctionInput = GenericDeleteFunctionInput<AwsProvider>;diff --git a/packages/lambda/src/api/delete-render.ts b/packages/lambda-client/src/delete-render.tssimilarity index 93%rename from packages/lambda/src/api/delete-render.tsrename to packages/lambda-client/src/delete-render.tsindex a846dfde74..770f4d0057 100644--- a/packages/lambda/src/api/delete-render.ts+++ b/packages/lambda-client/src/delete-render.ts@@ -5,10 +5,10 @@ import {rendersPrefix,type CustomCredentials,} from '@remotion/serverless/client';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import type {AwsProvider} from './aws-provider';+import {awsImplementation} from './aws-provider';import {cleanItems} from './clean-items';+import type {AwsRegion} from './regions';export type DeleteRenderInput = {region: AwsRegion;diff --git a/packages/lambda/src/shared/encode-aws-url-params.ts b/packages/lambda-client/src/encode-aws-url-params.tssimilarity index 100%rename from packages/lambda/src/shared/encode-aws-url-params.tsrename to packages/lambda-client/src/encode-aws-url-params.tsdiff --git a/packages/lambda/src/api/estimate-price.ts b/packages/lambda-client/src/estimate-price.tssimilarity index 86%rename from packages/lambda/src/api/estimate-price.tsrename to packages/lambda-client/src/estimate-price.tsindex 43a359ceed..fe6566b0b6 100644--- a/packages/lambda/src/api/estimate-price.ts+++ b/packages/lambda-client/src/estimate-price.ts@@ -1,9 +1,9 @@-import {MIN_EPHEMERAL_STORAGE_IN_MB} from '../defaults';-import {pricing} from '../pricing/price-per-1-s';-import type {AwsRegion} from '../regions';-import {validateAwsRegion} from '../shared/validate-aws-region';-import {validateDiskSizeInMb} from '../shared/validate-disk-size-in-mb';-import {validateMemorySize} from '../shared/validate-memory-size';+import {MIN_EPHEMERAL_STORAGE_IN_MB} from './constants';+import {pricing} from './price-per-1s';+import type {AwsRegion} from './regions';+import {validateAwsRegion} from './validate-aws-region';+import {validateDiskSizeInMb} from './validate-disk-size-in-mb';+import {validateMemorySize} from './validate-memory-size';type Miliseconds =| {diff --git a/packages/lambda/src/api/express-webhook.ts b/packages/lambda-client/src/express-webhook.tssimilarity index 100%rename from packages/lambda/src/api/express-webhook.tsrename to packages/lambda-client/src/express-webhook.tsdiff --git a/packages/lambda/src/shared/get-account-id.ts b/packages/lambda-client/src/get-account-id.tssimilarity index 84%rename from packages/lambda/src/shared/get-account-id.tsrename to packages/lambda-client/src/get-account-id.tsindex 48225bba2a..a6391283a1 100644--- a/packages/lambda/src/shared/get-account-id.ts+++ b/packages/lambda-client/src/get-account-id.ts@@ -1,8 +1,8 @@import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';import type {GetAccountId} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';import {getStsClient} from './aws-clients';+import type {AwsProvider} from './aws-provider';+import type {AwsRegion} from './regions';import {validateAwsRegion} from './validate-aws-region';export const getAccountIdImplementation: GetAccountId<diff --git a/packages/lambda/src/api/get-aws-client.ts b/packages/lambda-client/src/get-aws-client.tssimilarity index 89%rename from packages/lambda/src/api/get-aws-client.tsrename to packages/lambda-client/src/get-aws-client.tsindex 5112f8e9eb..76bfbfe64d 100644--- a/packages/lambda/src/api/get-aws-client.ts+++ b/packages/lambda-client/src/get-aws-client.ts@@ -5,12 +5,9 @@ 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 {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {- getServiceClient,- type ServiceMapping,-} from '../shared/get-service-client';+import type {AwsProvider} from './aws-provider';+import {getServiceClient, type ServiceMapping} from './get-service-client';+import type {AwsRegion} from './regions';export type GetAwsClientInput<T extends keyof ServiceMapping> = {region: AwsRegion;diff --git a/packages/lambda/src/shared/get-aws-urls.ts b/packages/lambda-client/src/get-aws-urls.tssimilarity index 95%rename from packages/lambda/src/shared/get-aws-urls.tsrename to packages/lambda-client/src/get-aws-urls.tsindex 91bd482aa3..7d4fac463d 100644--- a/packages/lambda/src/shared/get-aws-urls.ts+++ b/packages/lambda-client/src/get-aws-urls.ts@@ -1,8 +1,8 @@import type {GetLoggingUrlForRendererFunction} from '@remotion/serverless';import type {ServerlessRoutines} from '@remotion/serverless/client';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import type {AwsProvider} from './aws-provider';import {encodeAwsUrlParams} from './encode-aws-url-params';+import type {AwsRegion} from './regions';const cloudWatchUrlWithQuery = ({region,diff --git a/packages/lambda/src/api/get-buckets.ts b/packages/lambda-client/src/get-buckets.tssimilarity index 89%rename from packages/lambda/src/api/get-buckets.tsrename to packages/lambda-client/src/get-buckets.tsindex 2a6eb86ba3..a311723621 100644--- a/packages/lambda/src/api/get-buckets.ts+++ b/packages/lambda-client/src/get-buckets.ts@@ -1,10 +1,10 @@import {GetBucketLocationCommand, ListBucketsCommand} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';import {REMOTION_BUCKET_PREFIX} from '@remotion/serverless/client';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {getS3Client} from '../shared/get-s3-client';-import {parseBucketName} from '../shared/validate-bucketname';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';+import type {AwsRegion} from './regions';+import {parseBucketName} from './validate-bucketname';export type BucketWithLocation = {name: string;diff --git a/packages/lambda/src/api/get-compositions-on-lambda.ts b/packages/lambda-client/src/get-compositions-on-lambda.tssimilarity index 96%rename from packages/lambda/src/api/get-compositions-on-lambda.tsrename to packages/lambda-client/src/get-compositions-on-lambda.tsindex 5063e27347..e2c224c214 100644--- a/packages/lambda/src/api/get-compositions-on-lambda.ts+++ b/packages/lambda-client/src/get-compositions-on-lambda.ts@@ -8,8 +8,8 @@ import {} from '@remotion/serverless/client';import type {VideoConfig} from 'remotion/no-react';import {VERSION} from 'remotion/version';-import {awsImplementation} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import {awsImplementation} from './aws-provider';+import type {AwsRegion} from './regions';export type GetCompositionsOnLambdaInput = {chromiumOptions?: ChromiumOptions;diff --git a/packages/lambda/src/shared/get-credentials.ts b/packages/lambda-client/src/get-credentials.tssimilarity index 100%rename from packages/lambda/src/shared/get-credentials.tsrename to packages/lambda-client/src/get-credentials.tsdiff --git a/packages/lambda/src/shared/get-env-variable.ts b/packages/lambda-client/src/get-env-variable.tssimilarity index 100%rename from packages/lambda/src/shared/get-env-variable.tsrename to packages/lambda-client/src/get-env-variable.tsdiff --git a/packages/lambda-client/src/get-function-name.ts b/packages/lambda-client/src/get-function-name.tsnew file mode 100644index 0000000000..f825c16e9f--- /dev/null+++ b/packages/lambda-client/src/get-function-name.ts@@ -0,0 +1,24 @@+import {RENDER_FN_PREFIX} from './constants';++type ReturnType = {+ version: string;+ memorySizeInMb: number;+ diskSizeInMb: number;+ timeoutInSeconds: number;+};++export const parseFunctionName = (functionName: string): ReturnType | null => {+ const match = functionName.match(+ new RegExp(RENDER_FN_PREFIX + '(.*)-mem(\\d+)mb-disk(\\d+)mb-(\\d+)sec$'),+ );+ if (!match) {+ return null;+ }++ return {+ version: match[1],+ memorySizeInMb: parseInt(match[2], 10),+ diskSizeInMb: parseInt(match[3], 10),+ timeoutInSeconds: parseInt(match[4], 10),+ };+};diff --git a/packages/lambda/src/shared/get-function-version.ts b/packages/lambda-client/src/get-function-version.tssimilarity index 88%rename from packages/lambda/src/shared/get-function-version.tsrename to packages/lambda-client/src/get-function-version.tsindex 7d31ff97d3..11a96d4e82 100644--- a/packages/lambda/src/shared/get-function-version.ts+++ b/packages/lambda-client/src/get-function-version.ts@@ -3,8 +3,8 @@ import {COMMAND_NOT_FOUND,ServerlessRoutines,} from '@remotion/serverless/client';-import {awsImplementation} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import {awsImplementation} from './aws-provider';+import type {AwsRegion} from './regions';export const getFunctionVersion = async ({functionName,diff --git a/packages/lambda/src/api/get-functions.ts b/packages/lambda-client/src/get-functions.tssimilarity index 90%rename from packages/lambda/src/api/get-functions.tsrename to packages/lambda-client/src/get-functions.tsindex a1f13c6862..1432e5cfe4 100644--- a/packages/lambda/src/api/get-functions.ts+++ b/packages/lambda-client/src/get-functions.ts@@ -3,13 +3,10 @@ import {ListFunctionsCommand} from '@aws-sdk/client-lambda';import type {LogLevel} from '@remotion/renderer';import type {FunctionInfo} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import type {AwsRegion} from '../regions';-import {getLambdaClient} from '../shared/aws-clients';-import {- DEFAULT_EPHEMERAL_STORAGE_IN_MB,- RENDER_FN_PREFIX,-} from '../shared/constants';-import {getFunctionVersion} from '../shared/get-function-version';+import {getLambdaClient} from './aws-clients';+import {DEFAULT_EPHEMERAL_STORAGE_IN_MB, RENDER_FN_PREFIX} from './constants';+import {getFunctionVersion} from './get-function-version';+import type {AwsRegion} from './regions';export type GetFunctionsInput = {region: AwsRegion;diff --git a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts b/packages/lambda-client/src/get-output-url-from-metadata.tssimilarity index 89%rename from packages/lambda/src/functions/helpers/get-output-url-from-metadata.tsrename to packages/lambda-client/src/get-output-url-from-metadata.tsindex 49c2d4b9ca..bb2eb6cd8c 100644--- a/packages/lambda/src/functions/helpers/get-output-url-from-metadata.ts+++ b/packages/lambda-client/src/get-output-url-from-metadata.ts@@ -1,6 +1,6 @@import type {GetOutputUrl} from '@remotion/serverless';import {getExpectedOutName} from '@remotion/serverless/client';-import type {AwsProvider} from '../aws-implementation';+import type {AwsProvider} from './aws-provider';export const getOutputUrlFromMetadata: GetOutputUrl<AwsProvider> = ({renderMetadata,diff --git a/packages/lambda/src/api/get-render-progress.ts b/packages/lambda-client/src/get-render-progress.tssimilarity index 88%rename from packages/lambda/src/api/get-render-progress.tsrename to packages/lambda-client/src/get-render-progress.tsindex a027e0d60f..0394ef85b4 100644--- a/packages/lambda/src/api/get-render-progress.ts+++ b/packages/lambda-client/src/get-render-progress.ts@@ -1,14 +1,11 @@import type {LogLevel} from '@remotion/renderer';import type {CustomCredentials} from '@remotion/serverless/client';import {getProgress, ServerlessRoutines} from '@remotion/serverless/client';-import {- awsImplementation,- type AwsProvider,-} from '../functions/aws-implementation';-import {parseFunctionName} from '../functions/helpers/parse-function-name';-import type {AwsRegion} from '../regions';-import type {RenderProgress} from '../shared/constants';+import {awsImplementation, type AwsProvider} from './aws-provider';+import type {RenderProgress} from './constants';import {getRenderProgressPayload} from './make-lambda-payload';+import {parseFunctionName} from './parse-function-name';+import type {AwsRegion} from './regions';export type GetRenderProgressInput = {functionName: string;diff --git a/packages/lambda/src/shared/get-s3-client.ts b/packages/lambda-client/src/get-s3-client.tssimilarity index 73%rename from packages/lambda/src/shared/get-s3-client.tsrename to packages/lambda-client/src/get-s3-client.tsindex 6048a83bc3..086618fd52 100644--- a/packages/lambda/src/shared/get-s3-client.ts+++ b/packages/lambda-client/src/get-s3-client.ts@@ -1,8 +1,8 @@import type {S3Client} from '@aws-sdk/client-s3';-import type {CustomCredentials} from '../client';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import type {CustomCredentials} from '@remotion/serverless/client';+import type {AwsProvider} from './aws-provider';import {getServiceClient} from './get-service-client';+import type {AwsRegion} from './regions';export const getS3Client = ({region,diff --git a/packages/lambda/src/shared/get-service-client.ts b/packages/lambda-client/src/get-service-client.tssimilarity index 96%rename from packages/lambda/src/shared/get-service-client.tsrename to packages/lambda-client/src/get-service-client.tsindex 76f8c5b4c1..7c70116bbf 100644--- a/packages/lambda/src/shared/get-service-client.ts+++ b/packages/lambda-client/src/get-service-client.ts@@ -4,14 +4,14 @@ import {LambdaClient} from '@aws-sdk/client-lambda';import {S3Client} from '@aws-sdk/client-s3';import {ServiceQuotasClient} from '@aws-sdk/client-service-quotas';import {STSClient} from '@aws-sdk/client-sts';+import type {CustomCredentials} from '@remotion/serverless/client';import {MAX_FUNCTIONS_PER_RENDER} from '@remotion/serverless/client';import {random} from 'remotion/no-react';-import type {CustomCredentials} from '../client';-import type {AwsProvider} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import type {AwsProvider} from './aws-provider';import {checkCredentials} from './check-credentials';import {getCredentials} from './get-credentials';import {getEnvVariable} from './get-env-variable';+import type {AwsRegion} from './regions';export type ServiceMapping = {s3: S3Client;diff --git a/packages/lambda/src/api/get-sites.ts b/packages/lambda-client/src/get-sites.tssimilarity index 91%rename from packages/lambda/src/api/get-sites.tsrename to packages/lambda-client/src/get-sites.tsindex 03aa9f34ae..e7d3e9d4c0 100644--- a/packages/lambda/src/api/get-sites.ts+++ b/packages/lambda-client/src/get-sites.ts@@ -1,10 +1,10 @@import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {getSitesKey} from '../shared/constants';-import {makeS3ServeUrl} from '../shared/make-s3-url';+import type {AwsProvider} from './aws-provider';+import {awsImplementation} from './aws-provider';+import {getSitesKey} from './constants';import type {BucketWithLocation} from './get-buckets';+import {makeS3ServeUrl} from './make-s3-url';+import type {AwsRegion} from './regions';type Site = {sizeInBytes: number;diff --git a/packages/lambda/src/io/head-file.ts b/packages/lambda-client/src/head-file.tssimilarity index 82%rename from packages/lambda/src/io/head-file.tsrename to packages/lambda-client/src/head-file.tsindex 5eea6db929..d122dd1419 100644--- a/packages/lambda/src/io/head-file.ts+++ b/packages/lambda-client/src/head-file.ts@@ -1,7 +1,7 @@import {HeadObjectCommand} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {getS3Client} from '../shared/get-s3-client';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';export const lambdaHeadFileImplementation: ProviderSpecifics<AwsProvider>['headFile'] =async ({diff --git a/packages/lambda-client/src/index.ts b/packages/lambda-client/src/index.tsnew file mode 100644index 0000000000..a9e277b36f--- /dev/null+++ b/packages/lambda-client/src/index.ts@@ -0,0 +1,144 @@+export type {+ EnhancedErrorInfo,+ FunctionInfo,+ LambdaErrorInfo,+} from '@remotion/serverless';+export {+ GetOrCreateBucketInput,+ GetOrCreateBucketOutput,+} from '@remotion/serverless/client';+export type {RuntimePreference} from './runtime-preference';+import {+ getCloudWatchLogsClient,+ getIamClient,+ getLambdaClient,+ getServiceQuotasClient,+ getStsClient,+} from './aws-clients';+import {awsImplementation} from './aws-provider';+import {parseJsonOrThrowSource} from './call-lambda-streaming';+import {cleanItems} from './clean-items';+import {+ DEFAULT_CLOUDWATCH_RETENTION_PERIOD,+ DEFAULT_EPHEMERAL_STORAGE_IN_MB,+ MAX_EPHEMERAL_STORAGE_IN_MB,+} from './constants';+import {convertToServeUrlImplementation} from './convert-to-serve-url';+import {internalDeleteRender} from './delete-render';+import {+ getCloudwatchMethodUrl,+ getCloudwatchRendererUrl,+ getS3RenderUrl,+} from './get-aws-urls';+import {getEnvVariable} from './get-env-variable';+import {getS3Client} from './get-s3-client';+import {internalGetSites} from './get-sites';+import {isFlakyError} from './is-flaky-error';+import {LAMBDA_VERSION_STRING} from './lambda-version-string';+import {+ generateRandomHashWithLifeCycleRule,+ getLifeCycleRules,+} from './lifecycle';+import {makeLambdaRenderMediaPayload} from './make-lambda-payload';+import {makeS3ServeUrl} from './make-s3-url';+import {pLimit} from './p-limit';+import {parseFunctionName} from './parse-function-name';+import {randomHashImplementation} from './random-hash';+import {+ internalRenderMediaOnLambdaRaw,+ renderMediaOnLambdaOptionalToRequired,+} from './render-media-on-lambda';+import {runtimePreferenceOptions} from './runtime-preference';+import {validateAwsRegion} from './validate-aws-region';+import {parseBucketName} from './validate-bucketname';+import {validateDiskSizeInMb} from './validate-disk-size-in-mb';+import {validateMemorySize} from './validate-memory-size';+import {validateServeUrl} from './validate-serveurl';++export type {+ WebhookErrorPayload,+ WebhookPayload,+ WebhookSuccessPayload,+ WebhookTimeoutPayload,+} from '@remotion/serverless';+export type {CustomCredentials, DeleteAfter} from '@remotion/serverless/client';+export {appRouterWebhook, NextWebhookArgs} from './app-router-webhook';+export {AwsProvider} from './aws-provider';+export type {RenderProgress} from './constants';+export {deleteFunction, DeleteFunctionInput} from './delete-function';+export {deleteRender, type DeleteRenderInput} from './delete-render';+export {estimatePrice, EstimatePriceInput} from './estimate-price';+export {expressWebhook} from './express-webhook';+export {+ getAwsClient,+ type GetAwsClientInput,+ type GetAwsClientOutput,+} from './get-aws-client';+export {+ getCompositionsOnLambda,+ type GetCompositionsOnLambdaInput,+ type GetCompositionsOnLambdaOutput,+} from './get-compositions-on-lambda';+export {getFunctionVersion} from './get-function-version';+export {getFunctions, type GetFunctionsInput} from './get-functions';+export {getRenderProgress} from './get-render-progress';+export type {GetRenderProgressInput} from './get-render-progress';+export {getSites, type GetSitesInput, type GetSitesOutput} from './get-sites';+export {pagesRouterWebhook} from './pages-router-webhook';+export {presignUrl, type PresignUrlInput} from './presign-url';+export type {AwsRegion} from './regions';+export {+ renderMediaOnLambda,+ renderVideoOnLambda,+ type RenderMediaOnLambdaInput,+ type RenderMediaOnLambdaOutput,+} from './render-media-on-lambda';+export {+ renderStillOnLambda,+ type RenderStillOnLambdaInput,+ type RenderStillOnLambdaOutput,+} from './render-still-on-lambda';+export {+ speculateFunctionName,+ type SpeculateFunctionNameInput,+} from './speculate-function-name';+export {validateWebhookSignature} from './validate-webhook-signature';++export const LambdaClientInternals = {+ generateRandomHashWithLifeCycleRule,+ getLambdaClient,+ getS3Client,+ getS3RenderUrl,+ getIamClient,+ getStsClient,+ getCloudWatchLogsClient,+ getServiceQuotasClient,+ parseJsonOrThrowSource,+ getCloudwatchMethodUrl,+ getCloudwatchRendererUrl,+ MAX_EPHEMERAL_STORAGE_IN_MB,+ parseFunctionName,+ isFlakyError,+ convertToServeUrlImplementation,+ randomHashImplementation,+ parseBucketName,+ makeLambdaRenderMediaPayload,+ renderMediaOnLambdaOptionalToRequired,+ internalDeleteRender,+ internalGetSites,+ getLifeCycleRules,+ awsImplementation,+ runtimePreferenceOptions,+ validateAwsRegion,+ validateDiskSizeInMb,+ validateMemorySize,+ DEFAULT_CLOUDWATCH_RETENTION_PERIOD,+ DEFAULT_EPHEMERAL_STORAGE_IN_MB,+ LAMBDA_VERSION_STRING,+ pLimit,+ makeS3ServeUrl,+ validateServeUrl,+ getEnvVariable,+ internalRenderMediaOnLambdaRaw,+ cleanItems,+};diff --git a/packages/lambda/src/cli/is-cli.ts b/packages/lambda-client/src/is-cli.tssimilarity index 100%rename from packages/lambda/src/cli/is-cli.tsrename to packages/lambda-client/src/is-cli.tsdiff --git a/packages/lambda/src/shared/is-flaky-error.ts b/packages/lambda-client/src/is-flaky-error.tssimilarity index 100%rename from packages/lambda/src/shared/is-flaky-error.tsrename to packages/lambda-client/src/is-flaky-error.tsdiff --git a/packages/lambda/src/shared/is-in-lambda.ts b/packages/lambda-client/src/is-in-lambda.tssimilarity index 100%rename from packages/lambda/src/shared/is-in-lambda.tsrename to packages/lambda-client/src/is-in-lambda.tsdiff --git a/packages/lambda/src/shared/is-likely-to-have-aws-profile.ts b/packages/lambda-client/src/is-likely-to-have-aws-profile.tssimilarity index 100%rename from packages/lambda/src/shared/is-likely-to-have-aws-profile.tsrename to packages/lambda-client/src/is-likely-to-have-aws-profile.tsdiff --git a/packages/lambda/src/shared/lambda-version-string.ts b/packages/lambda-client/src/lambda-version-string.tssimilarity index 100%rename from packages/lambda/src/shared/lambda-version-string.tsrename to packages/lambda-client/src/lambda-version-string.tsdiff --git a/packages/lambda/src/shared/lifecycle-rules.ts b/packages/lambda-client/src/lifecycle-rules.tssimilarity index 90%rename from packages/lambda/src/shared/lifecycle-rules.tsrename to packages/lambda-client/src/lifecycle-rules.tsindex fa56ec6987..f3a1ab202c 100644--- a/packages/lambda/src/shared/lifecycle-rules.ts+++ b/packages/lambda-client/src/lifecycle-rules.ts@@ -3,14 +3,11 @@ import {PutBucketLifecycleConfigurationCommand,} from '@aws-sdk/client-s3';import type {CustomCredentials} from '@remotion/serverless/client';-import type {AwsProvider} from '../functions/aws-implementation';-import {- createLifeCycleInput,- deleteLifeCycleInput,-} from '../functions/helpers/apply-lifecyle';-import {getLifeCycleRules} from '../functions/helpers/lifecycle';-import type {AwsRegion} from '../regions';+import {createLifeCycleInput, deleteLifeCycleInput} from './apply-lifecycle';+import type {AwsProvider} from './aws-provider';import {getS3Client} from './get-s3-client';+import {getLifeCycleRules} from './lifecycle';+import type {AwsRegion} from './regions';const createLCRules = async ({bucketName,diff --git a/packages/lambda/src/functions/helpers/lifecycle.ts b/packages/lambda-client/src/lifecycle.tssimilarity index 100%rename from packages/lambda/src/functions/helpers/lifecycle.tsrename to packages/lambda-client/src/lifecycle.tsdiff --git a/packages/lambda/src/io/list-objects.ts b/packages/lambda-client/src/list-objects.tssimilarity index 94%rename from packages/lambda/src/io/list-objects.tsrename to packages/lambda-client/src/list-objects.tsindex e7d4329b4a..bef4a97867 100644--- a/packages/lambda/src/io/list-objects.ts+++ b/packages/lambda-client/src/list-objects.ts@@ -1,7 +1,7 @@import {ListObjectsV2Command} from '@aws-sdk/client-s3';import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';-import {getS3Client} from '../shared/get-s3-client';+import type {AwsProvider} from './aws-provider';+import {getS3Client} from './get-s3-client';export const lambdaLsImplementation: ProviderSpecifics<AwsProvider>['listObjects'] =async ({diff --git a/packages/lambda/src/api/make-lambda-payload.ts b/packages/lambda-client/src/make-lambda-payload.tssimilarity index 95%rename from packages/lambda/src/api/make-lambda-payload.tsrename to packages/lambda-client/src/make-lambda-payload.tsindex 9a24e96b51..f637003711 100644--- a/packages/lambda/src/api/make-lambda-payload.ts+++ b/packages/lambda-client/src/make-lambda-payload.ts@@ -12,6 +12,7 @@ import type {} from '@remotion/renderer';import type {BrowserSafeApis} from '@remotion/renderer/client';import type {+ DeleteAfter,DownloadBehavior,OutNameInput,Privacy,@@ -30,17 +31,16 @@ import {validateFramesPerFunction,} from '@remotion/serverless/client';import {VERSION} from 'remotion/version';-import type {DeleteAfter} from '../client';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';+import type {AwsProvider} from './aws-provider';+import {awsImplementation} from './aws-provider';import {validateWebhook} from '@remotion/serverless/client';import {NoReactInternals} from 'remotion/no-react';-import type {AwsRegion} from '../regions';-import {validateLambdaCodec} from '../shared/validate-lambda-codec';-import {validateServeUrl} from '../shared/validate-serveurl';import type {GetRenderProgressInput} from './get-render-progress';+import type {AwsRegion} from './regions';import type {RenderStillOnLambdaNonNullInput} from './render-still-on-lambda';+import {validateLambdaCodec} from './validate-lambda-codec';+import {validateServeUrl} from './validate-serveurl';export type InnerRenderMediaOnLambdaInput = {region: AwsRegion;diff --git a/packages/lambda/src/shared/make-s3-url.ts b/packages/lambda-client/src/make-s3-url.tssimilarity index 84%rename from packages/lambda/src/shared/make-s3-url.tsrename to packages/lambda-client/src/make-s3-url.tsindex d1cbfcb7e7..bab1ca4747 100644--- a/packages/lambda/src/shared/make-s3-url.ts+++ b/packages/lambda-client/src/make-s3-url.ts@@ -1,4 +1,4 @@-import type {AwsRegion} from '../regions';+import type {AwsRegion} from './regions';export const makeS3ServeUrl = ({bucketName,diff --git a/packages/lambda/src/shared/p-limit.ts b/packages/lambda-client/src/p-limit.tssimilarity index 100%rename from packages/lambda/src/shared/p-limit.tsrename to packages/lambda-client/src/p-limit.tsdiff --git a/packages/lambda/src/api/pages-router-webhook.ts b/packages/lambda-client/src/pages-router-webhook.tssimilarity index 100%rename from packages/lambda/src/api/pages-router-webhook.tsrename to packages/lambda-client/src/pages-router-webhook.tsdiff --git a/packages/lambda/src/functions/helpers/parse-function-name.ts b/packages/lambda-client/src/parse-function-name.tssimilarity index 91%rename from packages/lambda/src/functions/helpers/parse-function-name.tsrename to packages/lambda-client/src/parse-function-name.tsindex cd91f77a9e..f825c16e9f 100644--- a/packages/lambda/src/functions/helpers/parse-function-name.ts+++ b/packages/lambda-client/src/parse-function-name.ts@@ -1,4 +1,4 @@-import {RENDER_FN_PREFIX} from '../../defaults';+import {RENDER_FN_PREFIX} from './constants';type ReturnType = {version: string;diff --git a/packages/lambda/src/api/presign-url.ts b/packages/lambda-client/src/presign-url.tssimilarity index 93%rename from packages/lambda/src/api/presign-url.tsrename to packages/lambda-client/src/presign-url.tsindex f1333888aa..506ff70540 100644--- a/packages/lambda/src/api/presign-url.ts+++ b/packages/lambda-client/src/presign-url.ts@@ -1,9 +1,9 @@import {GetObjectCommand, HeadObjectCommand} from '@aws-sdk/client-s3';import {getSignedUrl} from '@aws-sdk/s3-request-presigner';import {validateBucketName} from '@remotion/serverless/client';-import type {AwsRegion} from '../regions';-import {getS3Client} from '../shared/get-s3-client';-import {validatePresignExpiration} from '../shared/validate-presign-expiration';+import {getS3Client} from './get-s3-client';+import type {AwsRegion} from './regions';+import {validatePresignExpiration} from './validate-presign-expiration';type MandatoryParameters = {region: AwsRegion;diff --git a/packages/lambda/src/pricing/price-per-1-s.ts b/packages/lambda-client/src/price-per-1s.tssimilarity index 99%rename from packages/lambda/src/pricing/price-per-1-s.tsrename to packages/lambda-client/src/price-per-1s.tsindex 48019ae174..e543978775 100644--- a/packages/lambda/src/pricing/price-per-1-s.ts+++ b/packages/lambda-client/src/price-per-1s.ts@@ -1,6 +1,6 @@// From https://calculator.aws/pricing/2.0/meteredUnitMaps/lambda/USD/current/lambda.json-import type {AwsRegion} from '../regions';+import type {AwsRegion} from './regions';export const pricing: {[key in AwsRegion]: {diff --git a/packages/lambda/src/shared/random-hash.ts b/packages/lambda-client/src/random-hash.tssimilarity index 100%rename from packages/lambda/src/shared/random-hash.tsrename to packages/lambda-client/src/random-hash.tsdiff --git a/packages/lambda/src/io/read-file.ts b/packages/lambda-client/src/read-file.tssimilarity index 86%rename from packages/lambda/src/io/read-file.tsrename to packages/lambda-client/src/read-file.tsindex f7d682c4fd..762312a30a 100644--- a/packages/lambda/src/io/read-file.ts+++ b/packages/lambda-client/src/read-file.ts@@ -1,7 +1,7 @@import {GetObjectCommand} from '@aws-sdk/client-s3';import type {Readable} from 'stream';-import type {AwsRegion} from '../regions';-import {getS3Client} from '../shared/get-s3-client';+import {getS3Client} from './get-s3-client';+import type {AwsRegion} from './regions';export const lambdaReadFileImplementation = async ({bucketName,diff --git a/packages/lambda/src/regions.ts b/packages/lambda-client/src/regions.tssimilarity index 100%rename from packages/lambda/src/regions.tsrename to packages/lambda-client/src/regions.tsdiff --git a/packages/lambda/src/api/render-media-on-lambda.ts b/packages/lambda-client/src/render-media-on-lambda.tssimilarity index 97%rename from packages/lambda/src/api/render-media-on-lambda.tsrename to packages/lambda-client/src/render-media-on-lambda.tsindex 097eb4704b..ad785e58e4 100644--- a/packages/lambda/src/api/render-media-on-lambda.ts+++ b/packages/lambda-client/src/render-media-on-lambda.ts@@ -17,20 +17,17 @@ import type {WebhookOption,} from '@remotion/serverless/client';import {ServerlessRoutines} from '@remotion/serverless/client';-import {- awsImplementation,- type AwsProvider,-} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';+import {awsImplementation, type AwsProvider} from './aws-provider';import {getCloudwatchMethodUrl,getCloudwatchRendererUrl,getLambdaInsightsUrl,getProgressJsonUrl,getS3RenderUrl,-} from '../shared/get-aws-urls';+} from './get-aws-urls';import type {InnerRenderMediaOnLambdaInput} from './make-lambda-payload';import {makeLambdaRenderMediaPayload} from './make-lambda-payload';+import type {AwsRegion} from './regions';export type RenderMediaOnLambdaInput = {region: AwsRegion;diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda-client/src/render-still-on-lambda.tssimilarity index 95%rename from packages/lambda/src/api/render-still-on-lambda.tsrename to packages/lambda-client/src/render-still-on-lambda.tsindex c3874dd1cf..847e77d103 100644--- a/packages/lambda/src/api/render-still-on-lambda.ts+++ b/packages/lambda-client/src/render-still-on-lambda.ts@@ -14,17 +14,11 @@ import type {RenderStillFunctionResponsePayload,} from '@remotion/serverless';import type {OutNameInput, Privacy} from '@remotion/serverless/client';-import {- awsImplementation,- type AwsProvider,-} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {DEFAULT_MAX_RETRIES} from '../shared/constants';-import {- getCloudwatchMethodUrl,- getLambdaInsightsUrl,-} from '../shared/get-aws-urls';+import {awsImplementation, type AwsProvider} from './aws-provider';+import {DEFAULT_MAX_RETRIES} from './constants';+import {getCloudwatchMethodUrl, getLambdaInsightsUrl} from './get-aws-urls';import {makeLambdaRenderStillPayload} from './make-lambda-payload';+import type {AwsRegion} from './regions';type MandatoryParameters = {region: AwsRegion;diff --git a/packages/lambda-client/src/runtime-preference.ts b/packages/lambda-client/src/runtime-preference.tsnew file mode 100644index 0000000000..380ede0278--- /dev/null+++ b/packages/lambda-client/src/runtime-preference.ts@@ -0,0 +1,7 @@+export const runtimePreferenceOptions = [+ 'default',+ 'apple-emojis',+ 'cjk',+] as const;++export type RuntimePreference = (typeof runtimePreferenceOptions)[number];diff --git a/packages/lambda/src/api/speculate-function-name.ts b/packages/lambda-client/src/speculate-function-name.tssimilarity index 87%rename from packages/lambda/src/api/speculate-function-name.tsrename to packages/lambda-client/src/speculate-function-name.tsindex 1be3fcec5d..105f9e5eb9 100644--- a/packages/lambda/src/api/speculate-function-name.ts+++ b/packages/lambda-client/src/speculate-function-name.ts@@ -1,5 +1,5 @@-import {RENDER_FN_PREFIX} from '../defaults';-import {LAMBDA_VERSION_STRING} from '../shared/lambda-version-string';+import {RENDER_FN_PREFIX} from './constants';+import {LAMBDA_VERSION_STRING} from './lambda-version-string';export type SpeculateFunctionNameInput = {memorySizeInMb: string | number;diff --git a/packages/lambda/src/test/unit/encode-aws-url.test.ts b/packages/lambda-client/src/test/encode-aws-url.test.tssimilarity index 72%rename from packages/lambda/src/test/unit/encode-aws-url.test.tsrename to packages/lambda-client/src/test/encode-aws-url.test.tsindex c18a626ccf..5ff585f885 100644--- a/packages/lambda/src/test/unit/encode-aws-url.test.ts+++ b/packages/lambda-client/src/test/encode-aws-url.test.ts@@ -1,5 +1,5 @@import {expect, test} from 'bun:test';-import {encodeAwsUrlParams} from '../../shared/encode-aws-url-params';+import {encodeAwsUrlParams} from '../encode-aws-url-params';test('Encode AWS URL test', () => {const params = encodeAwsUrlParams('"method=test"');diff --git a/packages/lambda/src/test/unit/price-calculation.test.ts b/packages/lambda-client/src/test/price-calculation.test.tssimilarity index 95%rename from packages/lambda/src/test/unit/price-calculation.test.tsrename to packages/lambda-client/src/test/price-calculation.test.tsindex a05401ece0..282d18e98c 100644--- a/packages/lambda/src/test/unit/price-calculation.test.ts+++ b/packages/lambda-client/src/test/price-calculation.test.ts@@ -1,6 +1,6 @@import {estimatePriceFromBucket} from '@remotion/serverless';import {expect, test} from 'bun:test';-import {awsImplementation} from '../../functions/aws-implementation';+import {awsImplementation} from '../aws-provider';test('Should not throw while calculating prices when time shifts occur', () => {const aDate = Date.now();diff --git a/packages/lambda/src/test/unit/pricing.test.ts b/packages/lambda-client/src/test/pricing.test.tssimilarity index 92%rename from packages/lambda/src/test/unit/pricing.test.tsrename to packages/lambda-client/src/test/pricing.test.tsindex ca3377802e..26bebd8888 100644--- a/packages/lambda/src/test/unit/pricing.test.ts+++ b/packages/lambda-client/src/test/pricing.test.ts@@ -1,5 +1,5 @@import {expect, test} from 'bun:test';-import {estimatePrice} from '../../api/estimate-price';+import {estimatePrice} from '../estimate-price';test('Should calculate costs accurately', () => {expect(diff --git a/packages/lambda/src/test/unit/validate-disk-size-in-mb.test.ts b/packages/lambda-client/src/test/validate-disk-size-in-mb.test.tssimilarity index 85%rename from packages/lambda/src/test/unit/validate-disk-size-in-mb.test.tsrename to packages/lambda-client/src/test/validate-disk-size-in-mb.test.tsindex 8bd9cefa37..1318a591c8 100644--- a/packages/lambda/src/test/unit/validate-disk-size-in-mb.test.ts+++ b/packages/lambda-client/src/test/validate-disk-size-in-mb.test.ts@@ -1,5 +1,5 @@import {expect, test} from 'bun:test';-import {validateDiskSizeInMb} from '../../shared/validate-disk-size-in-mb';+import {validateDiskSizeInMb} from '../validate-disk-size-in-mb';test('Disk size tests', () => {expect(() => validateDiskSizeInMb(512)).not.toThrow();diff --git a/packages/lambda/src/shared/validate-aws-region.ts b/packages/lambda-client/src/validate-aws-region.tssimilarity index 76%rename from packages/lambda/src/shared/validate-aws-region.tsrename to packages/lambda-client/src/validate-aws-region.tsindex d332ab7d81..b93e9c5d13 100644--- a/packages/lambda/src/shared/validate-aws-region.ts+++ b/packages/lambda-client/src/validate-aws-region.ts@@ -1,5 +1,5 @@-import type {AwsRegion} from '../regions';-import {AWS_REGIONS} from '../regions';+import type {AwsRegion} from './regions';+import {AWS_REGIONS} from './regions';export function validateAwsRegion(region: unknown,diff --git a/packages/lambda/src/shared/validate-bucketname.ts b/packages/lambda-client/src/validate-bucketname.tssimilarity index 85%rename from packages/lambda/src/shared/validate-bucketname.tsrename to packages/lambda-client/src/validate-bucketname.tsindex fbbfb15fb0..b772962056 100644--- a/packages/lambda/src/shared/validate-bucketname.ts+++ b/packages/lambda-client/src/validate-bucketname.ts@@ -1,6 +1,6 @@import {REMOTION_BUCKET_PREFIX} from '@remotion/serverless/client';-import type {AwsRegion} from '../regions';-import {AWS_REGIONS} from '../regions';+import type {AwsRegion} from './regions';+import {AWS_REGIONS} from './regions';export const parseBucketName = (name: string,diff --git a/packages/lambda/src/shared/validate-disk-size-in-mb.ts b/packages/lambda-client/src/validate-disk-size-in-mb.tssimilarity index 100%rename from packages/lambda/src/shared/validate-disk-size-in-mb.tsrename to packages/lambda-client/src/validate-disk-size-in-mb.tsdiff --git a/packages/lambda/src/shared/validate-lambda-codec.ts b/packages/lambda-client/src/validate-lambda-codec.tssimilarity index 95%rename from packages/lambda/src/shared/validate-lambda-codec.tsrename to packages/lambda-client/src/validate-lambda-codec.tsindex f06e1f524f..ae2c246a63 100644--- a/packages/lambda/src/shared/validate-lambda-codec.ts+++ b/packages/lambda-client/src/validate-lambda-codec.ts@@ -1,3 +1,4 @@+/* eslint-disable no-console */import type {ServerlessCodec} from '@remotion/serverless/client';import {serverlessCodecs} from '@remotion/serverless/client';diff --git a/packages/lambda/src/shared/validate-memory-size.ts b/packages/lambda-client/src/validate-memory-size.tssimilarity index 100%rename from packages/lambda/src/shared/validate-memory-size.tsrename to packages/lambda-client/src/validate-memory-size.tsdiff --git a/packages/lambda/src/shared/validate-presign-expiration.ts b/packages/lambda-client/src/validate-presign-expiration.tssimilarity index 100%rename from packages/lambda/src/shared/validate-presign-expiration.tsrename to packages/lambda-client/src/validate-presign-expiration.tsdiff --git a/packages/lambda/src/shared/validate-serveurl.ts b/packages/lambda-client/src/validate-serveurl.tssimilarity index 100%rename from packages/lambda/src/shared/validate-serveurl.tsrename to packages/lambda-client/src/validate-serveurl.tsdiff --git a/packages/lambda/src/api/validate-webhook-signature.ts b/packages/lambda-client/src/validate-webhook-signature.tssimilarity index 100%rename from packages/lambda/src/api/validate-webhook-signature.tsrename to packages/lambda-client/src/validate-webhook-signature.tsdiff --git a/packages/lambda/src/io/write-file.ts b/packages/lambda-client/src/write-file.tssimilarity index 85%rename from packages/lambda/src/io/write-file.tsrename to packages/lambda-client/src/write-file.tsindex 32b7cf8d91..a79c27d11d 100644--- a/packages/lambda/src/io/write-file.ts+++ b/packages/lambda-client/src/write-file.ts@@ -1,10 +1,11 @@+/* eslint-disable no-console */import {PutObjectCommand} from '@aws-sdk/client-s3';import type {WriteFileInput} from '@remotion/serverless';+import type {CustomCredentials} from '@remotion/serverless/client';import mimeTypes from 'mime-types';-import type {CustomCredentials} from '../client';-import type {AwsProvider} from '../functions/aws-implementation';-import {getContentDispositionHeader} from '../shared/content-disposition-header';-import {getS3Client} from '../shared/get-s3-client';+import type {AwsProvider} from './aws-provider';+import {getContentDispositionHeader} from './content-disposition-header';+import {getS3Client} from './get-s3-client';const tryLambdaWriteFile = async ({bucketName,diff --git a/packages/lambda-client/tsconfig.json b/packages/lambda-client/tsconfig.jsonnew file mode 100644index 0000000000..d0ebe1ffa7--- /dev/null+++ b/packages/lambda-client/tsconfig.json@@ -0,0 +1,9 @@+{+ "extends": "../tsconfig.settings.json",+ "compilerOptions": {+ "rootDir": "src",+ "outDir": "dist"+ },+ "include": ["src"],+ "references": [{"path": "../serverless"}]+}diff --git a/packages/lambda/package.json b/packages/lambda/package.jsonindex 1b716c16f1..e87d4bacdc 100644--- a/packages/lambda/package.json+++ b/packages/lambda/package.json@@ -18,17 +18,12 @@"author": "Jonny Burger <[email protected]>","license": "MIT","dependencies": {- "@aws-sdk/client-cloudwatch-logs": "3.738.0",- "@aws-sdk/client-iam": "3.738.0",- "@aws-sdk/client-lambda": "3.738.0",- "@aws-sdk/client-s3": "3.738.0",- "@aws-sdk/client-service-quotas": "3.738.0",- "@aws-sdk/client-sts": "3.738.0",+ "@aws-sdk/s3-request-presigner": "3.738.0","@aws-sdk/credential-providers": "3.738.0","@aws-sdk/lib-storage": "3.738.0",- "@aws-sdk/s3-request-presigner": "3.738.0","@remotion/bundler": "workspace:*","@remotion/cli": "workspace:*",+ "@remotion/lambda-client": "workspace:*","@remotion/renderer": "workspace:*","@remotion/serverless": "workspace:*","@remotion/streaming": "workspace:*",diff --git a/packages/lambda/src/admin/make-layer-public.ts b/packages/lambda/src/admin/make-layer-public.tsindex 44b22367d4..30a1320d65 100644--- a/packages/lambda/src/admin/make-layer-public.ts+++ b/packages/lambda/src/admin/make-layer-public.ts@@ -3,11 +3,10 @@ import {AddLayerVersionPermissionCommand,PublishLayerVersionCommand,} from '@aws-sdk/client-lambda';+import {LambdaClientInternals, type AwsRegion} from '@remotion/lambda-client';import {VERSION} from 'remotion/version';import {getRegions} from '../api/get-regions';import {quit} from '../cli/helpers/quit';-import type {AwsRegion} from '../regions';-import {getLambdaClient} from '../shared/aws-clients';import type {HostedLayers} from '../shared/hosted-layers';const layerInfo: HostedLayers = {@@ -54,7 +53,9 @@ const makeLayerPublic = async () => {for (const region of getRegions()) {for (const layer of layers) {const layerName = `remotion-binaries-${layer}-arm64`;- const {Version, LayerArn} = await getLambdaClient(region).send(+ const {Version, LayerArn} = await LambdaClientInternals.getLambdaClient(+ region,+ ).send(new PublishLayerVersionCommand({Content: {S3Bucket: getBucketName(region),@@ -75,7 +76,7 @@ const makeLayerPublic = async () => {Description: VERSION,}),);- await getLambdaClient(region).send(+ await LambdaClientInternals.getLambdaClient(region).send(new AddLayerVersionPermissionCommand({Action: 'lambda:GetLayerVersion',LayerName: layerName,@@ -84,8 +85,8 @@ const makeLayerPublic = async () => {StatementId: 'public-layer',}),);- if (!layerInfo[region]) {- layerInfo[region] = [];+ if (!layerInfo[region as AwsRegion]) {+ layerInfo[region as AwsRegion] = [];}if (!LayerArn) {diff --git a/packages/lambda/src/api/create-function.ts b/packages/lambda/src/api/create-function.tsindex 09e0a57501..5fd3b1f50e 100644--- a/packages/lambda/src/api/create-function.ts+++ b/packages/lambda/src/api/create-function.ts@@ -10,14 +10,16 @@ import {PutRuntimeManagementConfigCommand,TagResourceCommand,} from '@aws-sdk/client-lambda';+import {+ LambdaClientInternals,+ type AwsRegion,+ type RuntimePreference,+} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {readFileSync} from 'node:fs';import {VERSION} from 'remotion/version';import {LOG_GROUP_PREFIX} from '../defaults';-import type {AwsRegion} from '../regions';-import {getCloudWatchLogsClient, getLambdaClient} from '../shared/aws-clients';-import type {RuntimePreference} from '../shared/get-layers';import {getLayers} from '../shared/get-layers';import {lambdaInsightsExtensions} from '../shared/lambda-insights-extensions';import {ROLE_NAME} from './iam-validation/suggested-policy';@@ -63,7 +65,7 @@ export const createFunction = async ({'Creating CloudWatch group',);try {- await getCloudWatchLogsClient(region).send(+ await LambdaClientInternals.getCloudWatchLogsClient(region).send(new CreateLogGroupCommand({logGroupName: `${LOG_GROUP_PREFIX}${functionName}`,}),@@ -88,7 +90,7 @@ export const createFunction = async ({{indent: false, logLevel},'Adding retention policy to the CloudWatch group',);- await getCloudWatchLogsClient(region).send(+ await LambdaClientInternals.getCloudWatchLogsClient(region).send(new PutRetentionPolicyCommand({logGroupName: `${LOG_GROUP_PREFIX}${functionName}`,retentionInDays,@@ -137,28 +139,29 @@ export const createFunction = async ({);}- const {FunctionName, FunctionArn} = await getLambdaClient(region).send(- new CreateFunctionCommand({- Code: {- ZipFile: readFileSync(zipFile),- },- FunctionName: functionName,- Handler: 'index.handler',- Role: customRoleArn ?? defaultRoleName,- Runtime: 'nodejs20.x',- Description: 'Renders a Remotion video.',- MemorySize: memorySizeInMb,- Timeout: timeoutInSeconds,- Layers: layers- .map(({layerArn, version}) => `${layerArn}:${version}`)- .concat(insightsLayer ? [insightsLayer] : []),- Architectures: ['arm64'],- EphemeralStorage: {- Size: ephemerealStorageInMb,- },- VpcConfig: vpcConfig,- }),- );+ const {FunctionName, FunctionArn} =+ await LambdaClientInternals.getLambdaClient(region).send(+ new CreateFunctionCommand({+ Code: {+ ZipFile: readFileSync(zipFile),+ },+ FunctionName: functionName,+ Handler: 'index.handler',+ Role: customRoleArn ?? defaultRoleName,+ Runtime: 'nodejs20.x',+ Description: 'Renders a Remotion video.',+ MemorySize: memorySizeInMb,+ Timeout: timeoutInSeconds,+ Layers: layers+ .map(({layerArn, version}) => `${layerArn}:${version}`)+ .concat(insightsLayer ? [insightsLayer] : []),+ Architectures: ['arm64'],+ EphemeralStorage: {+ Size: ephemerealStorageInMb,+ },+ VpcConfig: vpcConfig,+ }),+ );RenderInternals.Log.verbose({indent: false, logLevel},@@ -166,7 +169,7 @@ export const createFunction = async ({);try {- await getLambdaClient(region).send(+ await LambdaClientInternals.getLambdaClient(region).send(new TagResourceCommand({Resource: FunctionArn,Tags: {@@ -194,7 +197,7 @@ export const createFunction = async ({{indent: false, logLevel},'Disabling function retries (Remotion handles retries itself)...',);- await getLambdaClient(region).send(+ await LambdaClientInternals.getLambdaClient(region).send(new PutFunctionEventInvokeConfigCommand({MaximumRetryAttempts: 0,FunctionName,@@ -212,7 +215,7 @@ export const createFunction = async ({let state = 'Pending';while (state === 'Pending') {- const getFn = await getLambdaClient(region).send(+ const getFn = await LambdaClientInternals.getLambdaClient(region).send(new GetFunctionCommand({FunctionName,}),@@ -235,7 +238,7 @@ export const createFunction = async ({const RuntimeVersionArn = `arn:aws:lambda:${region}::runtime:da57c20c4b965d5b75540f6865a35fc8030358e33ec44ecfed33e90901a27a72`;try {- await getLambdaClient(region).send(+ await LambdaClientInternals.getLambdaClient(region).send(new PutRuntimeManagementConfigCommand({FunctionName,UpdateRuntimeOn: 'Manual',diff --git a/packages/lambda/src/api/delete-site.ts b/packages/lambda/src/api/delete-site.tsindex e765684817..421e7b1b60 100644--- a/packages/lambda/src/api/delete-site.ts+++ b/packages/lambda/src/api/delete-site.ts@@ -1,9 +1,7 @@+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';import type {ProviderSpecifics} from '@remotion/serverless';import {getSitesKey} from '../defaults';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';-import type {AwsRegion} from '../regions';-import {cleanItems} from './clean-items';type MandatoryParameters = {bucketName: string;@@ -53,7 +51,7 @@ export const internalDeleteSite = async ({totalSize += files.reduce((a, b) => {return a + (b.Size ?? 0);}, 0);- await cleanItems({+ await LambdaClientInternals.cleanItems({list: files.map((f) => f.Key as string),bucket: bucketName as string,onAfterItemDeleted: onAfterItemDeleted ?? (() => undefined),@@ -88,6 +86,6 @@ export const deleteSite = (...props,onAfterItemDeleted: props.onAfterItemDeleted ?? null,forcePathStyle: props.forcePathStyle ?? false,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,});};diff --git a/packages/lambda/src/api/deploy-function.ts b/packages/lambda/src/api/deploy-function.tsindex dbe68a6495..bc0b6ce1cb 100644--- a/packages/lambda/src/api/deploy-function.ts+++ b/packages/lambda/src/api/deploy-function.ts@@ -1,3 +1,9 @@+import type {RuntimePreference} from '@remotion/lambda-client';+import {+ LambdaClientInternals,+ speculateFunctionName,+ type AwsRegion,+} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {wrapWithErrorHandling} from '@remotion/renderer/error-handling';import type {@@ -6,25 +12,13 @@ import type {ProviderSpecifics,} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import {awsImplementation} from '../functions/aws-implementation';+import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../defaults';import {awsFullClientSpecifics} from '../functions/full-client-implementation';-import type {AwsRegion} from '../regions';-import {- DEFAULT_CLOUDWATCH_RETENTION_PERIOD,- DEFAULT_EPHEMERAL_STORAGE_IN_MB,-} from '../shared/constants';import {FUNCTION_ZIP_ARM64} from '../shared/function-zip-path';-import {- validateRuntimePreference,- type RuntimePreference,-} from '../shared/get-layers';-import {validateAwsRegion} from '../shared/validate-aws-region';+import {validateRuntimePreference} from '../shared/get-layers';import {validateCustomRoleArn} from '../shared/validate-custom-role-arn';-import {validateDiskSizeInMb} from '../shared/validate-disk-size-in-mb';-import {validateMemorySize} from '../shared/validate-memory-size';import {validateCloudWatchRetentionPeriod} from '../shared/validate-retention-period';import {validateTimeout} from '../shared/validate-timeout';-import {speculateFunctionName} from './speculate-function-name';type MandatoryParameters = {createCloudWatchLogGroup: boolean;@@ -60,11 +54,11 @@ export const internalDeployFunction = async <Provider extends CloudProvider>(fullClientSpecifics: FullClientSpecifics<Provider>;},): Promise<DeployFunctionOutput> => {- validateMemorySize(params.memorySizeInMb);+ LambdaClientInternals.validateMemorySize(params.memorySizeInMb);validateTimeout(params.timeoutInSeconds);- validateAwsRegion(params.region);+ LambdaClientInternals.validateAwsRegion(params.region);validateCloudWatchRetentionPeriod(params.cloudWatchLogRetentionPeriodInDays);- validateDiskSizeInMb(params.diskSizeInMb);+ LambdaClientInternals.validateDiskSizeInMb(params.diskSizeInMb);validateCustomRoleArn(params.customRoleArn);validateRuntimePreference(params.runtimePreference);@@ -100,7 +94,7 @@ export const internalDeployFunction = async <Provider extends CloudProvider>(timeoutInSeconds: params.timeoutInSeconds,retentionInDays:params.cloudWatchLogRetentionPeriodInDays ??- DEFAULT_CLOUDWATCH_RETENTION_PERIOD,+ LambdaClientInternals.DEFAULT_CLOUDWATCH_RETENTION_PERIOD,alreadyCreated: Boolean(alreadyDeployed),ephemerealStorageInMb: params.diskSizeInMb,customRoleArn: params.customRoleArn as string,@@ -166,7 +160,7 @@ export const deployFunction = ({vpcSubnetIds,vpcSecurityGroupIds,runtimePreference: runtimePreference ?? 'default',- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,fullClientSpecifics: awsFullClientSpecifics,});};diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.tsindex b4462a79f8..6feb320e7f 100644--- a/packages/lambda/src/api/deploy-site.ts+++ b/packages/lambda/src/api/deploy-site.ts@@ -1,4 +1,6 @@import {type GitSource, type WebpackOverrideFn} from '@remotion/bundler';+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';import type {ToOptions} from '@remotion/renderer';import type {BrowserSafeApis} from '@remotion/renderer/client';import {wrapWithErrorHandling} from '@remotion/renderer/error-handling';@@ -9,14 +11,9 @@ import type {} from '@remotion/serverless';import {validateBucketName, validatePrivacy} from '@remotion/serverless/client';import fs from 'node:fs';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';+import {getSitesKey} from '../defaults';import {awsFullClientSpecifics} from '../functions/full-client-implementation';-import type {AwsRegion} from '../regions';-import {getSitesKey} from '../shared/constants';import {getS3DiffOperations} from '../shared/get-s3-operations';-import {makeS3ServeUrl} from '../shared/make-s3-url';-import {validateAwsRegion} from '../shared/validate-aws-region';import {validateSiteName} from '../shared/validate-site-name';type MandatoryParameters = {@@ -73,7 +70,7 @@ const mandatoryDeploySite = async ({providerSpecifics: ProviderSpecifics<AwsProvider>;fullClientSpecifics: FullClientSpecifics<AwsProvider>;}): DeploySiteOutput => {- validateAwsRegion(region);+ LambdaClientInternals.validateAwsRegion(region);validateBucketName(bucketName, {mustStartWithRemotion: !options?.bypassBucketNameValidation,});@@ -181,7 +178,11 @@ const mandatoryDeploySite = async ({}return {- serveUrl: makeS3ServeUrl({bucketName, subFolder, region}),+ serveUrl: LambdaClientInternals.makeS3ServeUrl({+ bucketName,+ subFolder,+ region,+ }),siteName,stats: {uploadedFiles: toUpload.length,@@ -205,11 +206,12 @@ export const deploySite = (args: DeploySiteInput) => {gitSource: args.gitSource ?? null,options: args.options ?? {},privacy: args.privacy ?? 'public',- siteName: args.siteName ?? awsImplementation.randomHash(),+ siteName:+ args.siteName ?? LambdaClientInternals.awsImplementation.randomHash(),indent: false,logLevel: 'info',throwIfSiteExists: args.throwIfSiteExists ?? false,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,forcePathStyle: args.forcePathStyle ?? false,fullClientSpecifics: awsFullClientSpecifics,});diff --git a/packages/lambda/src/api/download-media.ts b/packages/lambda/src/api/download-media.tsindex 94492bf8ac..11190c0bf4 100644--- a/packages/lambda/src/api/download-media.ts+++ b/packages/lambda/src/api/download-media.ts@@ -1,3 +1,5 @@+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';@@ -7,11 +9,8 @@ import {type CustomCredentials,} from '@remotion/serverless/client';import path from 'node:path';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';import type {LambdaReadFileProgress} from '../functions/helpers/read-with-progress';import {lambdaDownloadFileWithProgress} from '../functions/helpers/read-with-progress';-import type {AwsRegion} from '../regions';export type DownloadMediaInput = {region: AwsRegion;@@ -88,7 +87,7 @@ export const downloadMedia = (): Promise<DownloadMediaOutput> => {return internalDownloadMedia({...input,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,forcePathStyle: false,});};diff --git a/packages/lambda/src/api/get-function-info.ts b/packages/lambda/src/api/get-function-info.tsindex 2c1f55803f..0eab171489 100644--- a/packages/lambda/src/api/get-function-info.ts+++ b/packages/lambda/src/api/get-function-info.ts@@ -1,11 +1,12 @@import {GetFunctionCommand} from '@aws-sdk/client-lambda';+import type {AwsRegion} from '@remotion/lambda-client';+import {+ getFunctionVersion,+ LambdaClientInternals,+} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import type {FunctionInfo} from '@remotion/serverless';-import type {AwsRegion} from '../regions';-import {getLambdaClient} from '../shared/aws-clients';-import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../shared/constants';-import {getFunctionVersion} from '../shared/get-function-version';-import {validateAwsRegion} from '../shared/validate-aws-region';+import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../defaults';export type GetFunctionInfoInput = {region: AwsRegion;@@ -22,10 +23,10 @@ export const getFunctionInfo = async ({functionName,logLevel,}: GetFunctionInfoInput): Promise<FunctionInfo> => {- validateAwsRegion(region);+ LambdaClientInternals.validateAwsRegion(region);const [functionInfo, version] = await Promise.all([- getLambdaClient(region).send(+ LambdaClientInternals.getLambdaClient(region).send(new GetFunctionCommand({FunctionName: functionName,}),diff --git a/packages/lambda/src/api/get-or-create-bucket.ts b/packages/lambda/src/api/get-or-create-bucket.tsindex 61e25f1f52..8ed17a633c 100644--- a/packages/lambda/src/api/get-or-create-bucket.ts+++ b/packages/lambda/src/api/get-or-create-bucket.ts@@ -1,7 +1,7 @@+import type {AwsProvider} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {GetOrCreateBucketInput} from '@remotion/serverless/client';import {internalGetOrCreateBucket} from '@remotion/serverless/client';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';/** @description Creates a Cloud Storage bucket for Remotion Cloud Run in your GCP project. If one already exists, it will get returned instead.@@ -14,7 +14,7 @@ export const getOrCreateBucket = (region: options.region,enableFolderExpiry: options.enableFolderExpiry ?? null,customCredentials: options.customCredentials ?? null,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,forcePathStyle: false,skipPutAcl: false,});diff --git a/packages/lambda/src/api/get-regions.ts b/packages/lambda/src/api/get-regions.tsindex c0dc5afb42..8ee5397296 100644--- a/packages/lambda/src/api/get-regions.ts+++ b/packages/lambda/src/api/get-regions.ts@@ -1,5 +1,8 @@-import type {AwsRegion} from '../regions';-import {AWS_REGIONS, DEFAULT_AWS_REGIONS} from '../regions';+import type {AwsRegion} from '@remotion/lambda-client';+import {+ AWS_REGIONS,+ DEFAULT_AWS_REGIONS,+} from '@remotion/lambda-client/regions';type Options = {enabledByDefaultOnly?: boolean;diff --git a/packages/lambda/src/api/iam-validation/role-permissions.ts b/packages/lambda/src/api/iam-validation/role-permissions.tsindex b010935fdc..29a1259cca 100644--- a/packages/lambda/src/api/iam-validation/role-permissions.ts+++ b/packages/lambda/src/api/iam-validation/role-permissions.ts@@ -3,7 +3,7 @@ import {LAMBDA_INSIGHTS_PREFIX,LOG_GROUP_PREFIX,RENDER_FN_PREFIX,-} from '../../shared/constants';+} from '../../defaults';export const rolePermissions: {actions: string[];diff --git a/packages/lambda/src/api/iam-validation/simulate-rule.ts b/packages/lambda/src/api/iam-validation/simulate-rule.tsindex 980bfa8775..6367ccce57 100644--- a/packages/lambda/src/api/iam-validation/simulate-rule.ts+++ b/packages/lambda/src/api/iam-validation/simulate-rule.ts@@ -1,6 +1,6 @@import {SimulatePrincipalPolicyCommand} from '@aws-sdk/client-iam';-import type {AwsRegion} from '../../regions';-import {getIamClient} from '../../shared/aws-clients';+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';export type EvalDecision = 'allowed' | 'explicitDeny' | 'implicitDeny';@@ -17,7 +17,7 @@ export const simulateRule = async (options: {retries: number;}): Promise<SimulationResult[]> => {try {- const res = await getIamClient(options.region).send(+ const res = await LambdaClientInternals.getIamClient(options.region).send(new SimulatePrincipalPolicyCommand({ActionNames: options.actionNames,PolicySourceArn: options.arn,diff --git a/packages/lambda/src/api/iam-validation/simulate.ts b/packages/lambda/src/api/iam-validation/simulate.tsindex 46fc2a65c1..1cb52d61cd 100644--- a/packages/lambda/src/api/iam-validation/simulate.ts+++ b/packages/lambda/src/api/iam-validation/simulate.ts@@ -1,6 +1,6 @@import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';-import type {AwsRegion} from '../../regions';-import {getStsClient} from '../../shared/aws-clients';+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {EvalDecision, SimulationResult} from './simulate-rule';import {simulateRule} from './simulate-rule';import {requiredPermissions} from './user-permissions';@@ -34,9 +34,9 @@ export type SimulatePermissionsOutput = {export const simulatePermissions = async (options: SimulatePermissionsInput,): Promise<SimulatePermissionsOutput> => {- const callerIdentity = await getStsClient(options.region).send(- new GetCallerIdentityCommand({}),- );+ const callerIdentity = await LambdaClientInternals.getStsClient(+ options.region,+ ).send(new GetCallerIdentityCommand({}));if (!callerIdentity?.Arn) {throw new Error('No valid AWS Caller Identity detected');diff --git a/packages/lambda/src/api/iam-validation/user-permissions.ts b/packages/lambda/src/api/iam-validation/user-permissions.tsindex 83bcda23a1..dd8c8aeb9a 100644--- a/packages/lambda/src/api/iam-validation/user-permissions.ts+++ b/packages/lambda/src/api/iam-validation/user-permissions.ts@@ -1,5 +1,5 @@import {REMOTION_BUCKET_PREFIX} from '@remotion/serverless/client';-import {LOG_GROUP_PREFIX, RENDER_FN_PREFIX} from '../../shared/constants';+import {LOG_GROUP_PREFIX, RENDER_FN_PREFIX} from '../../defaults';import {REMOTION_HOSTED_LAYER_ARN} from '../../shared/hosted-layers';export const requiredPermissions: {diff --git a/packages/lambda/src/api/upload-dir.ts b/packages/lambda/src/api/upload-dir.tsindex bb64280e5d..c3133aefe1 100644--- a/packages/lambda/src/api/upload-dir.ts+++ b/packages/lambda/src/api/upload-dir.ts@@ -1,14 +1,13 @@import {Upload} from '@aws-sdk/lib-storage';+import type {AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {UploadDirProgress} from '@remotion/serverless';import type {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 {AwsRegion} from '../regions';-import {getS3Client} from '../shared/get-s3-client';import {makeS3Key} from '../shared/make-s3-key';-import {pLimit} from '../shared/p-limit';type FileInfo = {name: string;@@ -59,7 +58,7 @@ async function getFiles(return _files.flat(1);}-const limit = pLimit(15);+const limit = LambdaClientInternals.pLimit(15);export const uploadDir = async ({bucket,@@ -86,7 +85,11 @@ export const uploadDir = async ({progresses[file.name] = 0;}- const client = getS3Client({region, customCredentials: null, forcePathStyle});+ const client = LambdaClientInternals.getS3Client({+ region,+ customCredentials: null,+ forcePathStyle,+ });const uploadWithoutRetry = async (filePath: FileInfo) => {const Key = makeS3Key(keyPrefix, localDir, filePath.name);diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.tsindex 26e1037149..c96a279229 100644--- a/packages/lambda/src/cli/args.ts+++ b/packages/lambda/src/cli/args.ts@@ -1,10 +1,8 @@import {CliInternals} from '@remotion/cli';import type {BrowserSafeApis} from '@remotion/renderer/client';-import type {DeleteAfter} from '../client';+import type {AwsRegion, DeleteAfter, RuntimePreference} from '../client';import type {Privacy} from '@remotion/serverless/client';-import {AwsRegion} from '../regions';-import type {RuntimePreference} from '../shared/get-layers';type LambdaCommandLineOptions = {help: boolean;diff --git a/packages/lambda/src/cli/commands/compositions/index.ts b/packages/lambda/src/cli/commands/compositions/index.tsindex cfca3e58df..5c3ddc8867 100644--- a/packages/lambda/src/cli/commands/compositions/index.ts+++ b/packages/lambda/src/cli/commands/compositions/index.ts@@ -1,11 +1,13 @@import {CliInternals} from '@remotion/cli';+import {+ AwsProvider,+ getCompositionsOnLambda,+ LambdaClientInternals,+} from '@remotion/lambda-client';import type {ChromiumOptions, LogLevel} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';import {ProviderSpecifics} from '@remotion/serverless';-import {getCompositionsOnLambda} from '../../..';-import {AwsProvider} from '../../../functions/aws-implementation';-import {BINARY_NAME} from '../../../shared/constants';-import {validateServeUrl} from '../../../shared/validate-serveurl';+import {BINARY_NAME} from '../../../defaults';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {findFunctionName} from '../../helpers/find-function-name';@@ -79,7 +81,7 @@ export const compositionsCommand = async ({};const region = getAwsRegion();- validateServeUrl(serveUrl);+ LambdaClientInternals.validateServeUrl(serveUrl);const functionName = await findFunctionName({logLevel, providerSpecifics});const comps = await getCompositionsOnLambda({diff --git a/packages/lambda/src/cli/commands/functions/deploy.ts b/packages/lambda/src/cli/commands/functions/deploy.tsindex 690ec3eb9e..ac4137481c 100644--- a/packages/lambda/src/cli/commands/functions/deploy.ts+++ b/packages/lambda/src/cli/commands/functions/deploy.ts@@ -1,18 +1,16 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider, LambdaClientInternals} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {FullClientSpecifics, ProviderSpecifics} from '@remotion/serverless';import {VERSION} from 'remotion/version';import {internalDeployFunction} from '../../../api/deploy-function';-import {AwsProvider} from '../../../functions/aws-implementation';import {DEFAULT_CLOUDWATCH_RETENTION_PERIOD,DEFAULT_EPHEMERAL_STORAGE_IN_MB,DEFAULT_MEMORY_SIZE,DEFAULT_TIMEOUT,-} from '../../../shared/constants';+} from '../../../defaults';import {validateCustomRoleArn} from '../../../shared/validate-custom-role-arn';-import {validateDiskSizeInMb} from '../../../shared/validate-disk-size-in-mb';-import {validateMemorySize} from '../../../shared/validate-memory-size';import {validateTimeout} from '../../../shared/validate-timeout';import {validateVpcSecurityGroupIds} from '../../../shared/validate-vpc-security-group-ids';import {validateVpcSubnetIds} from '../../../shared/validate-vpc-subnet-ids';@@ -53,9 +51,9 @@ export const functionsDeploySubcommand = async ({parsedLambdaCli['vpc-security-group-ids'] ?? undefined;const runtimePreference = parsedLambdaCli['runtime-preference'] ?? 'default';- validateMemorySize(memorySizeInMb);+ LambdaClientInternals.validateMemorySize(memorySizeInMb);validateTimeout(timeoutInSeconds);- validateDiskSizeInMb(diskSizeInMb);+ LambdaClientInternals.validateDiskSizeInMb(diskSizeInMb);validateCustomRoleArn(customRoleArn);validateVpcSubnetIds(vpcSubnetIds);validateVpcSecurityGroupIds(vpcSecurityGroupIds);diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.tsindex e9dedaa9f5..6d06a4ed5a 100644--- a/packages/lambda/src/cli/commands/functions/index.ts+++ b/packages/lambda/src/cli/commands/functions/index.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';import type {LogLevel} from '@remotion/renderer';import {FullClientSpecifics, ProviderSpecifics} from '@remotion/serverless';-import {AwsProvider} from '../../../functions/aws-implementation';-import {BINARY_NAME} from '../../../shared/constants';+import {AwsProvider} from '../../../client';+import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {FUNCTIONS_DEPLOY_SUBCOMMAND, functionsDeploySubcommand} from './deploy';import {FUNCTIONS_LS_SUBCOMMAND, functionsLsCommand} from './ls';diff --git a/packages/lambda/src/cli/commands/functions/ls.ts b/packages/lambda/src/cli/commands/functions/ls.tsindex 39b547744d..eb1f66f772 100644--- a/packages/lambda/src/cli/commands/functions/ls.ts+++ b/packages/lambda/src/cli/commands/functions/ls.ts@@ -1,7 +1,7 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {ProviderSpecifics} from '@remotion/serverless';-import {AwsProvider} from '../../../functions/aws-implementation';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';diff --git a/packages/lambda/src/cli/commands/functions/rm.ts b/packages/lambda/src/cli/commands/functions/rm.tsindex e6fa4be395..89fe1b29a1 100644--- a/packages/lambda/src/cli/commands/functions/rm.ts+++ b/packages/lambda/src/cli/commands/functions/rm.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';+import {deleteFunction} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';-import {deleteFunction} from '../../../api/delete-function';import {getFunctionInfo} from '../../../api/get-function-info';-import {BINARY_NAME} from '../../../shared/constants';+import {BINARY_NAME} from '../../../defaults';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';import {quit} from '../../helpers/quit';diff --git a/packages/lambda/src/cli/commands/functions/rmall.ts b/packages/lambda/src/cli/commands/functions/rmall.tsindex 03da144671..1dbcecd306 100644--- a/packages/lambda/src/cli/commands/functions/rmall.ts+++ b/packages/lambda/src/cli/commands/functions/rmall.ts@@ -1,9 +1,8 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider, deleteFunction} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {ProviderSpecifics} from '@remotion/serverless';-import {deleteFunction} from '../../../api/delete-function';import {getFunctionInfo} from '../../../api/get-function-info';-import {AwsProvider} from '../../../functions/aws-implementation';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';diff --git a/packages/lambda/src/cli/commands/policies/policies.ts b/packages/lambda/src/cli/commands/policies/policies.tsindex 0ac6f05b33..3863ac9c94 100644--- a/packages/lambda/src/cli/commands/policies/policies.ts+++ b/packages/lambda/src/cli/commands/policies/policies.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';import type {LogLevel} from '@remotion/renderer';-import {BINARY_NAME} from '../../../shared/constants';+import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {Log} from '../../log';import {ROLE_SUBCOMMAND, roleSubcommand} from './role';diff --git a/packages/lambda/src/cli/commands/quotas/increase.ts b/packages/lambda/src/cli/commands/quotas/increase.tsindex 37d3e2c972..1b0a23f3d6 100644--- a/packages/lambda/src/cli/commands/quotas/increase.ts+++ b/packages/lambda/src/cli/commands/quotas/increase.ts@@ -4,12 +4,11 @@ import {ListRequestedServiceQuotaChangeHistoryByQuotaCommand,RequestServiceQuotaIncreaseCommand,} from '@aws-sdk/client-service-quotas';+import {AwsRegion, LambdaClientInternals} from '@remotion/lambda-client';import type {LogLevel, LogOptions} from '@remotion/renderer';import {exit} from 'node:process';import {QUOTAS_COMMAND} from '.';import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';-import {AwsRegion} from '../../../regions';-import {getServiceQuotasClient} from '../../../shared/aws-clients';import {forceFlagProvided} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';@@ -33,19 +32,19 @@ export const quotasIncreaseCommand = async (logLevel: LogLevel) => {const [concurrencyLimit, defaultConcurrencyLimit, changes] =await Promise.all([- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new GetServiceQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',}),),- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new GetAWSDefaultServiceQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',}),),- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new ListRequestedServiceQuotaChangeHistoryByQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',@@ -110,7 +109,7 @@ export const quotasIncreaseCommand = async (logLevel: LogLevel) => {}try {- await getServiceQuotasClient(region).send(+ await LambdaClientInternals.getServiceQuotasClient(region).send(new RequestServiceQuotaIncreaseCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,DesiredValue: newLimit,diff --git a/packages/lambda/src/cli/commands/quotas/list.ts b/packages/lambda/src/cli/commands/quotas/list.tsindex d8fd95280b..4a0d2c48f0 100644--- a/packages/lambda/src/cli/commands/quotas/list.ts+++ b/packages/lambda/src/cli/commands/quotas/list.ts@@ -4,10 +4,10 @@ import {ListRequestedServiceQuotaChangeHistoryByQuotaCommand,} from '@aws-sdk/client-service-quotas';import {CliInternals} from '@remotion/cli';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {QUOTAS_COMMAND} from '.';import {BINARY_NAME, LAMBDA_CONCURRENCY_LIMIT_QUOTA} from '../../../defaults';-import {getServiceQuotasClient} from '../../../shared/aws-clients';import {getAwsRegion} from '../../get-aws-region';import {Log} from '../../log';import {INCREASE_SUBCOMMAND} from './increase';@@ -21,19 +21,19 @@ export const quotasListCommand = async (logLevel: LogLevel) => {Log.info({indent: false, logLevel});const [concurrencyLimit, defaultConcurrencyLimit, changes] =await Promise.all([- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new GetServiceQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',}),),- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new GetAWSDefaultServiceQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',}),),- getServiceQuotasClient(region).send(+ LambdaClientInternals.getServiceQuotasClient(region).send(new ListRequestedServiceQuotaChangeHistoryByQuotaCommand({QuotaCode: LAMBDA_CONCURRENCY_LIMIT_QUOTA,ServiceCode: 'lambda',diff --git a/packages/lambda/src/cli/commands/render/render.ts b/packages/lambda/src/cli/commands/render/render.tsindex e9fa46caf6..a272258644 100644--- a/packages/lambda/src/cli/commands/render/render.ts+++ b/packages/lambda/src/cli/commands/render/render.ts@@ -6,25 +6,25 @@ import {BrowserSafeApis} from '@remotion/renderer/client';import path from 'path';import {NoReactInternals} from 'remotion/no-react';import {internalDownloadMedia} from '../../../api/download-media';-import {getRenderProgress} from '../../../api/get-render-progress';-import {internalRenderMediaOnLambdaRaw} from '../../../api/render-media-on-lambda';+import {+ AwsProvider,+ getRenderProgress,+ LambdaClientInternals,+} from '@remotion/lambda-client';import type {EnhancedErrorInfo, ProviderSpecifics} from '@remotion/serverless';import {validateFramesPerFunction,validatePrivacy,type ServerlessCodec,} from '@remotion/serverless/client';-import type {AwsProvider} from '../../../functions/aws-implementation';-import {parseFunctionName} from '../../../functions/helpers/parse-function-name';import {BINARY_NAME,DEFAULT_MAX_RETRIES,DEFAULT_OUTPUT_PRIVACY,-} from '../../../shared/constants';+} from '../../../defaults';import {sleep} from '../../../shared/sleep';import {validateMaxRetries} from '../../../shared/validate-retries';-import {validateServeUrl} from '../../../shared/validate-serveurl';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {findFunctionName} from '../../helpers/find-function-name';@@ -192,7 +192,7 @@ export const renderCommand = async ({'No compositions passed. Fetching compositions...',);- validateServeUrl(serveUrl);+ LambdaClientInternals.validateServeUrl(serveUrl);if (!serveUrl.startsWith('https://') && !serveUrl.startsWith('http://')) {throw Error(@@ -285,7 +285,7 @@ export const renderCommand = async ({const webhookCustomData = getWebhookCustomData(logLevel);- const res = await internalRenderMediaOnLambdaRaw({+ const res = await LambdaClientInternals.internalRenderMediaOnLambdaRaw({functionName,serveUrl,inputProps,@@ -429,7 +429,8 @@ export const renderCommand = async ({);}- const adheresToFunctionNameConvention = parseFunctionName(functionName);+ const adheresToFunctionNameConvention =+ LambdaClientInternals.parseFunctionName(functionName);const status = await getRenderProgress({functionName,diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex fe32bdb8d8..f7bfa9f66e 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -3,16 +3,16 @@ import {ConfigInternals} from '@remotion/cli/config';import type {LogLevel} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';+import {AwsProvider} from '@remotion/lambda-client';import type {ProviderSpecifics} from '@remotion/serverless';import {internalGetOrCreateBucket,type Privacy,} from '@remotion/serverless/client';import {NoReactInternals} from 'remotion/no-react';-import type {AwsProvider} from '../../../functions/aws-implementation';+import {BINARY_NAME} from '../../../defaults';import {awsFullClientSpecifics} from '../../../functions/full-client-implementation';import {LambdaInternals} from '../../../internals';-import {BINARY_NAME} from '../../../shared/constants';import {validateSiteName} from '../../../shared/validate-site-name';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';diff --git a/packages/lambda/src/cli/commands/sites/index.ts b/packages/lambda/src/cli/commands/sites/index.tsindex 3f60f613a2..e487e20da6 100644--- a/packages/lambda/src/cli/commands/sites/index.ts+++ b/packages/lambda/src/cli/commands/sites/index.ts@@ -1,8 +1,8 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../../../functions/aws-implementation';-import {BINARY_NAME} from '../../../shared/constants';+import {BINARY_NAME} from '../../../defaults';import {quit} from '../../helpers/quit';import {SITES_CREATE_SUBCOMMAND, sitesCreateSubcommand} from './create';import {SITES_LS_SUBCOMMAND, sitesLsSubcommand} from './ls';diff --git a/packages/lambda/src/cli/commands/sites/ls.ts b/packages/lambda/src/cli/commands/sites/ls.tsindex 600454b043..3fca8261b1 100644--- a/packages/lambda/src/cli/commands/sites/ls.ts+++ b/packages/lambda/src/cli/commands/sites/ls.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';+import {getSites} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';-import {getSites} from '../../../api/get-sites';import {getAwsRegion} from '../../get-aws-region';import {dateString} from '../../helpers/date-string';diff --git a/packages/lambda/src/cli/commands/sites/rm.ts b/packages/lambda/src/cli/commands/sites/rm.tsindex e1d615ef1c..b8c7ce365f 100644--- a/packages/lambda/src/cli/commands/sites/rm.ts+++ b/packages/lambda/src/cli/commands/sites/rm.ts@@ -1,10 +1,9 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider, getSites} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';import {internalGetOrCreateBucket} from '@remotion/serverless/client';import {deleteSite} from '../../../api/delete-site';-import {getSites} from '../../../api/get-sites';-import type {AwsProvider} from '../../../functions/aws-implementation';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';diff --git a/packages/lambda/src/cli/commands/sites/rmall.ts b/packages/lambda/src/cli/commands/sites/rmall.tsindex 6daf385fdf..53e475ad5c 100644--- a/packages/lambda/src/cli/commands/sites/rmall.ts+++ b/packages/lambda/src/cli/commands/sites/rmall.ts@@ -1,10 +1,9 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider, getSites} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import type {ProviderSpecifics} from '@remotion/serverless';import {internalGetOrCreateBucket} from '@remotion/serverless/client';import {deleteSite} from '../../../api/delete-site';-import {getSites} from '../../../api/get-sites';-import type {AwsProvider} from '../../../functions/aws-implementation';import {parsedLambdaCli} from '../../args';import {getAwsRegion} from '../../get-aws-region';import {confirmCli} from '../../helpers/confirm';diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.tsindex d0aa1a26e0..02e9b79703 100644--- a/packages/lambda/src/cli/commands/still.ts+++ b/packages/lambda/src/cli/commands/still.ts@@ -1,5 +1,10 @@import {CliInternals} from '@remotion/cli';import {ConfigInternals} from '@remotion/cli/config';+import {+ AwsProvider,+ LambdaClientInternals,+ renderStillOnLambda,+} from '@remotion/lambda-client';import type {ChromiumOptions, LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {BrowserSafeApis} from '@remotion/renderer/client';@@ -8,16 +13,12 @@ import {validatePrivacy} from '@remotion/serverless/client';import path from 'path';import {NoReactInternals} from 'remotion/no-react';import {internalDownloadMedia} from '../../api/download-media';-import {renderStillOnLambda} from '../../api/render-still-on-lambda';-import type {AwsProvider} from '../../functions/aws-implementation';import {BINARY_NAME,DEFAULT_MAX_RETRIES,DEFAULT_OUTPUT_PRIVACY,-} from '../../shared/constants';-import {getS3RenderUrl} from '../../shared/get-aws-urls';+} from '../../defaults';import {validateMaxRetries} from '../../shared/validate-retries';-import {validateServeUrl} from '../../shared/validate-serveurl';import {parsedLambdaCli} from '../args';import {getAwsRegion} from '../get-aws-region';import {findFunctionName} from '../helpers/find-function-name';@@ -129,7 +130,7 @@ export const stillCommand = async ({'No compositions passed. Fetching compositions...',);- validateServeUrl(serveUrl);+ LambdaClientInternals.validateServeUrl(serveUrl);if (!serveUrl.startsWith('https://') && !serveUrl.startsWith('http://')) {throw Error(@@ -270,7 +271,7 @@ export const stillCommand = async ({Log.info({indent: false, logLevel},CliInternals.chalk.gray(- `Render ID: ${CliInternals.makeHyperlink({text: res.renderId, fallback: res.renderId, url: getS3RenderUrl({bucketName: res.bucketName, renderId: res.renderId, region: getAwsRegion()})})}`,+ `Render ID: ${CliInternals.makeHyperlink({text: res.renderId, fallback: res.renderId, url: LambdaClientInternals.getS3RenderUrl({bucketName: res.bucketName, renderId: res.renderId, region: getAwsRegion()})})}`,),);Log.info(diff --git a/packages/lambda/src/cli/get-aws-region.ts b/packages/lambda/src/cli/get-aws-region.tsindex d382fedafc..17b7b18f1f 100644--- a/packages/lambda/src/cli/get-aws-region.ts+++ b/packages/lambda/src/cli/get-aws-region.ts@@ -1,19 +1,18 @@-import type {AwsRegion} from '../regions';-import {DEFAULT_REGION} from '../shared/constants';-import {getEnvVariable} from '../shared/get-env-variable';-import {validateAwsRegion} from '../shared/validate-aws-region';+import {AwsRegion, LambdaClientInternals} from '@remotion/lambda-client';+import {DEFAULT_REGION} from '../defaults';import {parsedLambdaCli} from './args';export const getAwsRegion = (): AwsRegion => {if (parsedLambdaCli.region) {- validateAwsRegion(parsedLambdaCli.region);+ LambdaClientInternals.validateAwsRegion(parsedLambdaCli.region);return parsedLambdaCli.region;}const envVariable =- getEnvVariable('REMOTION_AWS_REGION') ?? getEnvVariable('AWS_REGION');+ LambdaClientInternals.getEnvVariable('REMOTION_AWS_REGION') ??+ LambdaClientInternals.getEnvVariable('AWS_REGION');if (envVariable) {- validateAwsRegion(envVariable);+ LambdaClientInternals.validateAwsRegion(envVariable);return envVariable;}diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.tsindex 049c1bff83..8415b04bdf 100644--- a/packages/lambda/src/cli/help.ts+++ b/packages/lambda/src/cli/help.ts@@ -1,6 +1,6 @@import {CliInternals} from '@remotion/cli';import type {LogLevel} from '@remotion/renderer';-import {BINARY_NAME} from '../shared/constants';+import {BINARY_NAME} from '../defaults';import {COMPOSITIONS_COMMAND} from './commands/compositions';import {FUNCTIONS_COMMAND} from './commands/functions';import {POLICIES_COMMAND} from './commands/policies/policies';diff --git a/packages/lambda/src/cli/helpers/find-function-name.ts b/packages/lambda/src/cli/helpers/find-function-name.tsindex e02381ab9d..b75e414957 100644--- a/packages/lambda/src/cli/helpers/find-function-name.ts+++ b/packages/lambda/src/cli/helpers/find-function-name.ts@@ -1,9 +1,8 @@+import {AwsProvider, speculateFunctionName} from '@remotion/lambda-client';import type {LogLevel, LogOptions} from '@remotion/renderer';import {ProviderSpecifics} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import {speculateFunctionName} from '../../api/speculate-function-name';-import {AwsProvider} from '../../functions/aws-implementation';-import {BINARY_NAME} from '../../shared/constants';+import {BINARY_NAME} from '../../defaults';import {parsedLambdaCli} from '../args';import {FUNCTIONS_COMMAND} from '../commands/functions';import {FUNCTIONS_DEPLOY_SUBCOMMAND} from '../commands/functions/deploy';diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.tsindex b1cbc2481b..3952fabc0f 100644--- a/packages/lambda/src/cli/index.ts+++ b/packages/lambda/src/cli/index.ts@@ -1,4 +1,5 @@import {CliInternals} from '@remotion/cli';+import {AwsProvider, LambdaClientInternals} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import {@@ -8,10 +9,7 @@ import {import {DOCS_URL} from '@remotion/serverless/client';import {ROLE_NAME} from '../api/iam-validation/suggested-policy';import {BINARY_NAME} from '../defaults';-import type {AwsProvider} from '../functions/aws-implementation';-import {awsImplementation} from '../functions/aws-implementation';import {awsFullClientSpecifics} from '../functions/full-client-implementation';-import {getEnvVariable} from '../shared/get-env-variable';import {parsedLambdaCli} from './args';import {COMPOSITIONS_COMMAND,@@ -28,7 +26,6 @@ import {SITES_COMMAND, sitesCommand} from './commands/sites';import {STILL_COMMAND, stillCommand} from './commands/still';import {printHelp} from './help';import {quit} from './helpers/quit';-import {setIsCli} from './is-cli';import {Log} from './log';const requiresCredentials = (args: string[]) => {@@ -68,7 +65,7 @@ const matchCommand = ({}if (requiresCredentials(args)) {- fullClientSpecifics.checkCredentials();+ providerSpecifics.checkCredentials();}if (args[0] === RENDER_COMMAND) {@@ -180,16 +177,17 @@ export const executeCommand = async (args: string[],remotionRoot: string,logLevel: LogLevel,- providerSpecifics: ProviderSpecifics<AwsProvider> | null,+ _providerSpecifics: ProviderSpecifics<AwsProvider> | null,fullClientSpecifics: FullClientSpecifics<AwsProvider> | null,) => {try {- setIsCli(true);+ const providerSpecifics =+ _providerSpecifics ?? LambdaClientInternals.awsImplementation;await matchCommand({args,remotionRoot,logLevel,- providerSpecifics: providerSpecifics ?? awsImplementation,+ providerSpecifics: providerSpecifics,fullClientSpecifics: fullClientSpecifics ?? awsFullClientSpecifics,});} catch (err) {@@ -248,13 +246,17 @@ AWS returned an "TooManyRequestsException" error message which could mean you re)) {const keyButDoesntStartWithAki =- getEnvVariable('REMOTION_AWS_ACCESS_KEY_ID') &&- !(getEnvVariable('REMOTION_AWS_ACCESS_KEY_ID') as string).startsWith(- 'AKI',- );+ LambdaClientInternals.getEnvVariable('REMOTION_AWS_ACCESS_KEY_ID') &&+ !(+ LambdaClientInternals.getEnvVariable(+ 'REMOTION_AWS_ACCESS_KEY_ID',+ ) as string+ ).startsWith('AKI');const pureKeyButDoesntStartWithAki =- getEnvVariable('AWS_ACCESS_KEY_ID') &&- !(getEnvVariable('AWS_ACCESS_KEY_ID') as string).startsWith('AKI');+ LambdaClientInternals.getEnvVariable('AWS_ACCESS_KEY_ID') &&+ !(+ LambdaClientInternals.getEnvVariable('AWS_ACCESS_KEY_ID') as string+ ).startsWith('AKI');if (keyButDoesntStartWithAki || pureKeyButDoesntStartWithAki) {Log.error({indent: false, logLevel},@@ -300,7 +302,7 @@ export const cli = async (logLevel: LogLevel) => {parsedLambdaCli._,remotionRoot,logLevel,- awsImplementation,+ LambdaClientInternals.awsImplementation,awsFullClientSpecifics,);};diff --git a/packages/lambda/src/client.ts b/packages/lambda/src/client.tsindex a2ae4e1c2a..a4a467c519 100644--- a/packages/lambda/src/client.ts+++ b/packages/lambda/src/client.ts@@ -1,48 +1 @@-export type {- WebhookErrorPayload,- WebhookPayload,- WebhookSuccessPayload,- WebhookTimeoutPayload,-} from '@remotion/serverless';-export type {CustomCredentials, DeleteAfter} from '@remotion/serverless/client';-export {NextWebhookArgs, appRouterWebhook} from './api/app-router-webhook';-export {deleteRender, type DeleteRenderInput} from './api/delete-render';-export {expressWebhook} from './api/express-webhook';-export {- getAwsClient,- type GetAwsClientInput,- type GetAwsClientOutput,-} from './api/get-aws-client';-export {- getCompositionsOnLambda,- type GetCompositionsOnLambdaInput,- type GetCompositionsOnLambdaOutput,-} from './api/get-compositions-on-lambda';-export {getFunctions, type GetFunctionsInput} from './api/get-functions';-export {getRenderProgress} from './api/get-render-progress';-export type {GetRenderProgressInput} from './api/get-render-progress';-export {- getSites,- type GetSitesInput,- type GetSitesOutput,-} from './api/get-sites';-export {pagesRouterWebhook} from './api/pages-router-webhook';-export {presignUrl, type PresignUrlInput} from './api/presign-url';-export {- renderMediaOnLambda,- renderVideoOnLambda,- type RenderMediaOnLambdaInput,- type RenderMediaOnLambdaOutput,-} from './api/render-media-on-lambda';-export {- renderStillOnLambda,- type RenderStillOnLambdaInput,- type RenderStillOnLambdaOutput,-} from './api/render-still-on-lambda';-export {- speculateFunctionName,- type SpeculateFunctionNameInput,-} from './api/speculate-function-name';-export {validateWebhookSignature} from './api/validate-webhook-signature';-export type {AwsRegion} from './regions';-export type {RenderProgress} from './shared/constants';+export * from '@remotion/lambda-client';diff --git a/packages/lambda/src/defaults.ts b/packages/lambda/src/defaults.tsindex 2d0232d4d1..9244e09e07 100644--- a/packages/lambda/src/defaults.ts+++ b/packages/lambda/src/defaults.ts@@ -1 +1 @@-export * from './shared/constants';+export * from '@remotion/lambda-client/constants';diff --git a/packages/lambda/src/functions/aws-server-implementation.ts b/packages/lambda/src/functions/aws-server-implementation.tsindex 20a753c576..f9905141ec 100644--- a/packages/lambda/src/functions/aws-server-implementation.ts+++ b/packages/lambda/src/functions/aws-server-implementation.ts@@ -1,3 +1,4 @@+import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';import type {InsideFunctionSpecifics} from '@remotion/serverless';import {forgetBrowserEventLoopImplementation,@@ -5,15 +6,22 @@ import {invokeWebhook,} from '@remotion/serverless';import {deleteTmpDir} from './helpers/clean-tmpdir';-import {generateRandomHashWithLifeCycleRule} from './helpers/lifecycle';+import {getCurrentRegionInFunctionImplementation} from './helpers/get-current-region';+import {getFolderFiles} from './helpers/get-folder-files';+import {makeAwsArtifact} from './helpers/make-aws-artifact';import {timer} from './helpers/timer';-export const serverAwsImplementation: InsideFunctionSpecifics = {+export const serverAwsImplementation: InsideFunctionSpecifics<AwsProvider> = {forgetBrowserEventLoop: forgetBrowserEventLoopImplementation,getBrowserInstance: getBrowserInstanceImplementation,timer,+ getCurrentRegionInFunction: getCurrentRegionInFunctionImplementation,+generateRandomId: ({deleteAfter, randomHashFn}) => {- return generateRandomHashWithLifeCycleRule({deleteAfter, randomHashFn});+ return LambdaClientInternals.generateRandomHashWithLifeCycleRule({+ deleteAfter,+ randomHashFn,+ });},deleteTmpDir: () => Promise.resolve(deleteTmpDir()),getCurrentFunctionName: () => {@@ -27,4 +35,6 @@ export const serverAwsImplementation: InsideFunctionSpecifics = {return Number(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE);},invokeWebhook,+ makeArtifactWithDetails: makeAwsArtifact,+ getFolderFiles,};diff --git a/packages/lambda/src/functions/full-client-implementation.ts b/packages/lambda/src/functions/full-client-implementation.tsindex 90948a3052..fd646e9c87 100644--- a/packages/lambda/src/functions/full-client-implementation.ts+++ b/packages/lambda/src/functions/full-client-implementation.ts@@ -1,10 +1,9 @@import {bundle} from '@remotion/bundler';+import type {AwsProvider} from '@remotion/lambda-client';import type {FullClientSpecifics} from '@remotion/serverless';import {createFunction} from '../api/create-function';import {uploadDir} from '../api/upload-dir';-import {checkCredentials} from '../shared/check-credentials';import {readDirectory} from '../shared/read-dir';-import type {AwsProvider} from './aws-implementation';export const awsFullClientSpecifics: FullClientSpecifics<AwsProvider> = {bundleSite: bundle,@@ -12,5 +11,4 @@ export const awsFullClientSpecifics: FullClientSpecifics<AwsProvider> = {readDirectory,uploadDir,createFunction,- checkCredentials,};diff --git a/packages/lambda/src/functions/helpers/get-current-region.ts b/packages/lambda/src/functions/helpers/get-current-region.tsindex 35ff36a193..e973cf34e1 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 '../../regions';+import type {AwsRegion} from '@remotion/lambda-client';export const getCurrentRegionInFunctionImplementation = () => {if (!process.env.AWS_REGION) {diff --git a/packages/lambda/src/functions/helpers/make-aws-artifact.ts b/packages/lambda/src/functions/helpers/make-aws-artifact.tsindex 09829760b0..dd08b69b2d 100644--- a/packages/lambda/src/functions/helpers/make-aws-artifact.ts+++ b/packages/lambda/src/functions/helpers/make-aws-artifact.ts@@ -1,5 +1,5 @@+import type {AwsProvider} from '@remotion/lambda-client';import type {MakeArtifactWithDetails} from '@remotion/serverless';-import type {AwsProvider} from '../aws-implementation';export const makeAwsArtifact: MakeArtifactWithDetails<AwsProvider> = ({region,diff --git a/packages/lambda/src/functions/helpers/read-with-progress.ts b/packages/lambda/src/functions/helpers/read-with-progress.tsindex 956c251c1b..ec70e8b5d4 100644--- a/packages/lambda/src/functions/helpers/read-with-progress.ts+++ b/packages/lambda/src/functions/helpers/read-with-progress.ts@@ -1,11 +1,10 @@import {GetObjectCommand} from '@aws-sdk/client-s3';import {getSignedUrl} from '@aws-sdk/s3-request-presigner';+import type {AwsProvider, AwsRegion} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {LogLevel} from '@remotion/renderer';import {RenderInternals} from '@remotion/renderer';import type {CustomCredentials} from '@remotion/serverless/client';-import type {AwsRegion} from '../../regions';-import {getS3Client} from '../../shared/get-s3-client';-import type {AwsProvider} from '../aws-implementation';export type LambdaReadFileProgress = (progress: {totalSize: number;@@ -34,7 +33,11 @@ export const lambdaDownloadFileWithProgress = async ({logLevel: LogLevel;forcePathStyle: boolean;}): Promise<{sizeInBytes: number; to: string}> => {- const client = getS3Client({region, customCredentials, forcePathStyle});+ const client = LambdaClientInternals.getS3Client({+ region,+ customCredentials,+ forcePathStyle,+ });const command = new GetObjectCommand({Bucket: bucketName,ExpectedBucketOwner: customCredentials ? undefined : expectedBucketOwner,diff --git a/packages/lambda/src/functions/index.ts b/packages/lambda/src/functions/index.tsindex da2442ba90..1ee0de2dc9 100644--- a/packages/lambda/src/functions/index.ts+++ b/packages/lambda/src/functions/index.ts@@ -1,8 +1,8 @@+import type {AwsProvider} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {RequestContext, ResponseStream} from '@remotion/serverless';import {innerHandler, streamWriter} from '@remotion/serverless';import type {ServerlessPayload} from '@remotion/serverless/client';-import type {AwsProvider} from './aws-implementation';-import {awsImplementation} from './aws-implementation';import {serverAwsImplementation} from './aws-server-implementation';import {streamifyResponse} from './helpers/streamify-response';import {getWebhookClient} from './http-client';@@ -18,7 +18,7 @@ export const routine = (params,responseWriter,context,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,insideFunctionSpecifics: serverAwsImplementation,webhookClient: getWebhookClient,});diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.tsindex b2369dbced..e9e5553e40 100644--- a/packages/lambda/src/index.ts+++ b/packages/lambda/src/index.ts@@ -1,18 +1,44 @@import type {+ AwsRegion,+ CustomCredentials,+ deleteFunction,+ DeleteFunctionInput,+ DeleteRenderInput,EnhancedErrorInfo,+ estimatePrice,+ EstimatePriceInput,FunctionInfo,- LambdaErrorInfo,-} from '@remotion/serverless';-import type {- CustomCredentials,+ getAwsClient,+ GetAwsClientInput,+ GetAwsClientOutput,+ getCompositionsOnLambda,+ GetCompositionsOnLambdaInput,+ GetCompositionsOnLambdaOutput,+ getFunctions,+ GetFunctionsInput,GetOrCreateBucketInput,GetOrCreateBucketOutput,-} from '@remotion/serverless/client';+ GetRenderProgressInput,+ GetSitesInput,+ GetSitesOutput,+ LambdaErrorInfo,+ RenderMediaOnLambdaInput,+ RenderMediaOnLambdaOutput,+ RenderProgress,+ RenderStillOnLambdaInput,+ RenderStillOnLambdaOutput,+} from '@remotion/lambda-client';+import {+ deleteRender,+ getRenderProgress as deprecatedGetRenderProgress,+ getSites as deprecatedGetSites,+ presignUrl as deprecatedPresignUrl,+ renderMediaOnLambda as deprecatedRenderMediaOnLambda,+ renderStillOnLambda as deprecatedRenderStillOnLambda,+ renderVideoOnLambda,+ validateWebhookSignature,+} from '@remotion/lambda-client';import {NoReactInternals} from 'remotion/no-react';-import type {DeleteFunctionInput} from './api/delete-function';-import {deleteFunction} from './api/delete-function';-import type {DeleteRenderInput} from './api/delete-render';-import {deleteRender} from './api/delete-render';import type {DeleteSiteInput, DeleteSiteOutput} from './api/delete-site';import {deleteSite} from './api/delete-site';import type {@@ -27,25 +53,10 @@ import type {DownloadMediaOutput,} from './api/download-media';import {downloadMedia} from './api/download-media';-import type {EstimatePriceInput} from './api/estimate-price';-import {estimatePrice} from './api/estimate-price';-import type {GetAwsClientInput, GetAwsClientOutput} from './api/get-aws-client';-import {getAwsClient} from './api/get-aws-client';-import type {- GetCompositionsOnLambdaInput,- GetCompositionsOnLambdaOutput,-} from './api/get-compositions-on-lambda';-import {getCompositionsOnLambda} from './api/get-compositions-on-lambda';import type {GetFunctionInfoInput} from './api/get-function-info';import {getFunctionInfo} from './api/get-function-info';-import type {GetFunctionsInput} from './api/get-functions';-import {getFunctions} from './api/get-functions';import {getOrCreateBucket} from './api/get-or-create-bucket';import {getRegions} from './api/get-regions';-import type {GetRenderProgressInput} from './api/get-render-progress';-import {getRenderProgress as deprecatedGetRenderProgress} from './api/get-render-progress';-import type {GetSitesInput, GetSitesOutput} from './api/get-sites';-import {getSites as deprecatedGetSites} from './api/get-sites';import type {SimulatePermissionsInput,SimulatePermissionsOutput,@@ -55,82 +66,64 @@ import {getRolePolicy,getUserPolicy,} from './api/iam-validation/suggested-policy';-import {presignUrl as deprecatedPresignUrl} from './api/presign-url';-import type {- RenderMediaOnLambdaInput,- RenderMediaOnLambdaOutput,-} from './api/render-media-on-lambda';-import {- renderMediaOnLambda as deprecatedRenderMediaOnLambda,- renderVideoOnLambda,-} from './api/render-media-on-lambda';-import type {- RenderStillOnLambdaInput,- RenderStillOnLambdaOutput,-} from './api/render-still-on-lambda';-import {renderStillOnLambda as deprecatedRenderStillOnLambda} from './api/render-still-on-lambda';-import {validateWebhookSignature} from './api/validate-webhook-signature';import {LambdaInternals,- type _InternalAwsProvider,type _InternalOverallRenderProgress,} from './internals';-import type {AwsRegion} from './regions';-import type {RenderProgress} from './shared/constants';-export type {WebhookPayload} from '@remotion/serverless';+export type {WebhookPayload} from '@remotion/lambda-client';/**- * @deprecated Import this from `@remotion/lambda/client` instead+ * @deprecated Import this from `@remotion/lambda-client` instead*/const renderMediaOnLambda = NoReactInternals.ENABLE_V5_BREAKING_CHANGES? () => {throw new Error(- 'renderMediaOnLambda() has moved to `@remotion/lambda/client`. Please import it from there.',+ 'renderMediaOnLambda() has moved to `@remotion/lambda-client`. Please import it from there.',);}: deprecatedRenderMediaOnLambda;/**- * @deprecated Import this from `@remotion/lambda/client` instead+ * @deprecated Import this from `@remotion/lambda-client` instead*/const getRenderProgress = NoReactInternals.ENABLE_V5_BREAKING_CHANGES? () => {throw new Error(- 'getRenderProgress() has moved to `@remotion/lambda/client`. Please import it from there.',+ 'getRenderProgress() has moved to `@remotion/lambda-client`. Please import it from there.',);}: deprecatedGetRenderProgress;/**- * @deprecated Import this from `@remotion/lambda/client` instead+ * @deprecated Import this from `@remotion/lambda-client` instead*/const renderStillOnLambda = NoReactInternals.ENABLE_V5_BREAKING_CHANGES? () => {throw new Error(- 'renderStillOnLambda() has moved to `@remotion/lambda/client`. Please import it from there.',+ 'renderStillOnLambda() has moved to `@remotion/lambda-client`. Please import it from there.',);}: deprecatedRenderStillOnLambda;/**- * @deprecated Import this from `@remotion/lambda/client` instead+ * @deprecated Import this from `@remotion/lambda-client` instead*/const presignUrl = NoReactInternals.ENABLE_V5_BREAKING_CHANGES? () => {throw new Error(- 'presignUrl() has moved to `@remotion/lambda/client`. Please import it from there.',+ 'presignUrl() has moved to `@remotion/lambda-client`. Please import it from there.',);}: deprecatedPresignUrl;/**- * @deprecated Import this from `@remotion/lambda/client` instead+ * @deprecated Import this from `@remotion/lambda-client` instead*/const getSites = NoReactInternals.ENABLE_V5_BREAKING_CHANGES? () => {throw new Error(- 'getSites() has moved to `@remotion/lambda/client`. Please import it from there.',+ 'getSites() has moved to `@remotion/lambda-client`. Please import it from there.',);}: deprecatedGetSites;@@ -198,4 +191,4 @@ export type {SimulatePermissionsOutput,};-export {_InternalAwsProvider, _InternalOverallRenderProgress};+export {_InternalOverallRenderProgress};diff --git a/packages/lambda/src/internals.ts b/packages/lambda/src/internals.tsindex 00cd542dd6..413d82bd60 100644--- a/packages/lambda/src/internals.ts+++ b/packages/lambda/src/internals.ts@@ -1,18 +1,9 @@import {internalDeploySite} from './api/deploy-site';-import {- getRenderProgressPayload,- makeLambdaRenderMediaPayload,- makeLambdaRenderStillPayload,-} from './api/make-lambda-payload';import {executeCommand} from './cli/index';export const LambdaInternals = {executeCommand,- makeLambdaRenderMediaPayload,- getRenderProgressPayload,- makeLambdaRenderStillPayload,internalDeploySite,};export type {OverallRenderProgress as _InternalOverallRenderProgress} from '@remotion/serverless';-export type {AwsProvider as _InternalAwsProvider} from './functions/aws-implementation';diff --git a/packages/lambda/src/shared/get-layers.ts b/packages/lambda/src/shared/get-layers.tsindex cb1d980093..352c73b113 100644--- a/packages/lambda/src/shared/get-layers.ts+++ b/packages/lambda/src/shared/get-layers.ts@@ -1,19 +1,20 @@-import type {AwsRegion} from '../regions';+import type {AwsRegion, RuntimePreference} from '@remotion/lambda-client';+import {LambdaClientInternals} from '@remotion/lambda-client';import type {AwsLayer} from './hosted-layers';import {hostedLayers} from './hosted-layers';-const runtimePreferenceOptions = ['default', 'apple-emojis', 'cjk'] as const;--export type RuntimePreference = (typeof runtimePreferenceOptions)[number];-export const validateRuntimePreference = (option: unknown) => {if (!option) {return;}- if (!runtimePreferenceOptions.includes(option as RuntimePreference)) {+ if (+ !LambdaClientInternals.runtimePreferenceOptions.includes(+ option as RuntimePreference,+ )+ ) {throw new Error(- `Invalid runtime preference ${option}. Must be one of ${runtimePreferenceOptions.join(+ `Invalid runtime preference ${option}. Must be one of ${LambdaClientInternals.runtimePreferenceOptions.join(', ',)}`,);diff --git a/packages/lambda/src/shared/get-s3-operations.ts b/packages/lambda/src/shared/get-s3-operations.tsindex f23a87b8cb..ccd2bfd8dd 100644--- a/packages/lambda/src/shared/get-s3-operations.ts+++ b/packages/lambda/src/shared/get-s3-operations.ts@@ -1,6 +1,6 @@import type {_Object} from '@aws-sdk/client-s3';+import type {AwsProvider} from '@remotion/lambda-client';import type {FullClientSpecifics} from '@remotion/serverless';-import type {AwsProvider} from '../functions/aws-implementation';export const getS3DiffOperations = async ({objects,diff --git a/packages/lambda/src/shared/hosted-layers.ts b/packages/lambda/src/shared/hosted-layers.tsindex b48ec3125f..d3a983014d 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 '../regions';+import type {AwsRegion} from '@remotion/lambda-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.tsindex 5206193096..e15928ca0a 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 '../regions';+import type {AwsRegion} from '@remotion/lambda-client';export const lambdaInsightsExtensions: {[region in AwsRegion]: string | null} ={diff --git a/packages/lambda/src/shared/validate-timeout.ts b/packages/lambda/src/shared/validate-timeout.tsindex 179819a55f..6cab4a059a 100644--- a/packages/lambda/src/shared/validate-timeout.ts+++ b/packages/lambda/src/shared/validate-timeout.ts@@ -1,4 +1,4 @@-import {MAX_TIMEOUT, MIN_TIMEOUT} from './constants';+import {MAX_TIMEOUT, MIN_TIMEOUT} from '../defaults';export const validateTimeout = (timeoutInSeconds: unknown) => {if (typeof timeoutInSeconds !== 'number') {diff --git a/packages/lambda/src/test/integration/cli.test.ts b/packages/lambda/src/test/integration/cli.test.tsindex bfced0d67a..50c5c2a024 100644--- a/packages/lambda/src/test/integration/cli.test.ts+++ b/packages/lambda/src/test/integration/cli.test.ts@@ -1,5 +1,6 @@// eslint-disable-next-line no-restricted-importsimport {CliInternals} from '@remotion/cli';+import {LambdaClientInternals} from '@remotion/lambda-client';import {afterEach, beforeEach, expect, test} from 'bun:test';import {DEFAULT_EPHEMERAL_STORAGE_IN_MB,@@ -7,11 +8,8 @@ import {DEFAULT_TIMEOUT,} from '../../defaults';import {LambdaInternals} from '../../internals';-import {LAMBDA_VERSION_STRING} from '../../shared/lambda-version-string';-import {- mockFullClientSpecifics,- mockImplementation,-} from '../mock-implementation';+import {mockFullClientSpecifics} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';import {doAfter, doBefore, getProcessWriteOutput} from './console-hooks';const remotionRoot = process.cwd();@@ -33,7 +31,7 @@ test('Deploy function', async () => {mockFullClientSpecifics,);expect(getProcessWriteOutput()).toContain(- `Deployed as remotion-render-${LAMBDA_VERSION_STRING}-mem${DEFAULT_MEMORY_SIZE}mb-disk${DEFAULT_EPHEMERAL_STORAGE_IN_MB}mb-${DEFAULT_TIMEOUT}sec\n`,+ `Deployed as remotion-render-${LambdaClientInternals.LAMBDA_VERSION_STRING}-mem${DEFAULT_MEMORY_SIZE}mb-disk${DEFAULT_EPHEMERAL_STORAGE_IN_MB}mb-${DEFAULT_TIMEOUT}sec\n`,);});diff --git a/packages/lambda/src/test/integration/delete-site.test.ts b/packages/lambda/src/test/integration/delete-site.test.tsindex d11c016e7d..f58813451a 100644--- a/packages/lambda/src/test/integration/delete-site.test.ts+++ b/packages/lambda/src/test/integration/delete-site.test.ts@@ -2,10 +2,8 @@ import {internalGetOrCreateBucket} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {internalDeleteSite} from '../../api/delete-site';import {internalDeploySite} from '../../api/deploy-site';-import {- mockFullClientSpecifics,- mockImplementation,-} from '../mock-implementation';+import {mockFullClientSpecifics} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';test('Return 0 total size if site did not exist', async () => {const {bucketName} = await internalGetOrCreateBucket({diff --git a/packages/lambda/src/test/integration/deploy-function.test.ts b/packages/lambda/src/test/integration/deploy-function.test.tsindex cb964b2f33..693516cf0d 100644--- a/packages/lambda/src/test/integration/deploy-function.test.ts+++ b/packages/lambda/src/test/integration/deploy-function.test.ts@@ -1,16 +1,18 @@+import {+ LambdaClientInternals,+ speculateFunctionName,+} from '@remotion/lambda-client';import {expect, test} from 'bun:test';import {VERSION} from 'remotion/version';import {internalDeployFunction} from '../../api/deploy-function';-import {speculateFunctionName} from '../../api/speculate-function-name';-import {DEFAULT_EPHEMERAL_STORAGE_IN_MB} from '../../shared/constants';-import {- mockFullClientSpecifics,- mockImplementation,-} from '../mock-implementation';+import {mockFullClientSpecifics} from '../mock-implementation';import {cleanFnStore,markFunctionAsIncompatible,} from '../mocks/mock-functions';+import {mockImplementation} from '../mocks/mock-implementation';++const {DEFAULT_EPHEMERAL_STORAGE_IN_MB} = LambdaClientInternals;test('Should be able to deploy function', async () => {const {functionName} = await internalDeployFunction({@@ -34,7 +36,7 @@ test('Should be able to deploy function', async () => {speculateFunctionName({memorySizeInMb: 2048,timeoutInSeconds: 120,- diskSizeInMb: DEFAULT_EPHEMERAL_STORAGE_IN_MB,+ diskSizeInMb: LambdaClientInternals.DEFAULT_EPHEMERAL_STORAGE_IN_MB,}),);});diff --git a/packages/lambda/src/test/integration/deploy-site.test.ts b/packages/lambda/src/test/integration/deploy-site.test.tsindex 242807ef5b..20a10f0b2e 100644--- a/packages/lambda/src/test/integration/deploy-site.test.ts+++ b/packages/lambda/src/test/integration/deploy-site.test.ts@@ -1,12 +1,10 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {internalGetOrCreateBucket} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {internalDeleteSite} from '../../api/delete-site';import {internalDeploySite} from '../../api/deploy-site';-import {awsImplementation} from '../../functions/aws-implementation';-import {- mockFullClientSpecifics,- mockImplementation,-} from '../mock-implementation';+import {mockFullClientSpecifics} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';import {getDirFiles} from '../mocks/upload-dir';test('Should throw on wrong prefix', async () => {@@ -38,12 +36,14 @@ test('Should throw if invalid region was passed', () => {region: 'ap-northeast-9',siteName: 'testing',gitSource: null,- providerSpecifics: awsImplementation,+ providerSpecifics: LambdaClientInternals.awsImplementation,indent: false,logLevel: 'info',options: {},privacy: 'public',throwIfSiteExists: true,+ forcePathStyle: false,+ fullClientSpecifics: mockFullClientSpecifics,}),).rejects.toThrow(/ap-northeast-9 is not a supported AWS region/);});diff --git a/packages/lambda/src/test/integration/get-sites.test.ts b/packages/lambda/src/test/integration/get-sites.test.tsindex f1e74477df..a77387aaae 100644--- a/packages/lambda/src/test/integration/get-sites.test.ts+++ b/packages/lambda/src/test/integration/get-sites.test.ts@@ -1,17 +1,15 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {internalGetOrCreateBucket} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {internalDeploySite} from '../../api/deploy-site';-import {internalGetSites} from '../../api/get-sites';-import {- mockFullClientSpecifics,- mockImplementation,-} from '../mock-implementation';+import {mockFullClientSpecifics} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';import {resetMockStore} from '../mocks/mock-store';test('Should have no buckets at first', async () => {resetMockStore();expect(- await internalGetSites({+ await LambdaClientInternals.internalGetSites({region: 'us-east-1',providerSpecifics: mockImplementation,forcePathStyle: false,@@ -57,7 +55,7 @@ test('Should have a site after deploying', async () => {},});expect(- await internalGetSites({+ await LambdaClientInternals.internalGetSites({region: 'eu-central-1',providerSpecifics: mockImplementation,forcePathStyle: false,diff --git a/packages/lambda/src/test/integration/handlers.test.ts b/packages/lambda/src/test/integration/handlers.test.tsindex 78ab27539f..41f1e9b5b8 100644--- a/packages/lambda/src/test/integration/handlers.test.ts+++ b/packages/lambda/src/test/integration/handlers.test.ts@@ -1,7 +1,7 @@import {ServerlessRoutines} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {VERSION} from 'remotion/version';-import {mockImplementation} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';test('Call function locally', async () => {expect(diff --git a/packages/lambda/src/test/integration/lifecycle.test.ts b/packages/lambda/src/test/integration/lifecycle.test.tsindex 6bb85c43ae..02cc2d1b9f 100644--- a/packages/lambda/src/test/integration/lifecycle.test.ts+++ b/packages/lambda/src/test/integration/lifecycle.test.ts@@ -1,8 +1,8 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {expect, test} from 'bun:test';-import {getLifeCycleRules} from '../../functions/helpers/lifecycle';test('Lifecycle', () => {- expect(getLifeCycleRules()).toEqual([+ expect(LambdaClientInternals.getLifeCycleRules()).toEqual([{Expiration: {Days: 1,diff --git a/packages/lambda/src/test/integration/renders/muted-render.test.ts b/packages/lambda/src/test/integration/renders/muted-render.test.tsindex 3b520965d5..17451405ea 100644--- a/packages/lambda/src/test/integration/renders/muted-render.test.ts+++ b/packages/lambda/src/test/integration/renders/muted-render.test.ts@@ -1,11 +1,11 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {RenderInternals, getVideoMetadata} from '@remotion/renderer';import {rendersPrefix} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {createWriteStream, unlinkSync} from 'node:fs';import {tmpdir} from 'node:os';import path from 'path';-import {internalDeleteRender} from '../../../api/delete-render';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';import {simulateLambdaRender} from '../simulate-lambda-render';test('Should make muted render audio', async () => {@@ -53,7 +53,7 @@ test('Should make muted render audio', async () => {expect(files.length).toBe(2);- await internalDeleteRender({+ await LambdaClientInternals.internalDeleteRender({bucketName: progress.outBucket as string,region: 'eu-central-1',renderId,diff --git a/packages/lambda/src/test/integration/renders/old-version.test.ts b/packages/lambda/src/test/integration/renders/old-version.test.tsindex f6cc6e59eb..d055359aea 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 {ServerlessRoutines} from '@remotion/serverless/client';import {expect, test} from 'bun:test';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';test('Should fail when using an incompatible version', async () => {try {diff --git a/packages/lambda/src/test/integration/renders/regular-audio.test.ts b/packages/lambda/src/test/integration/renders/regular-audio.test.tsindex e35f3af9e2..560833c305 100644--- a/packages/lambda/src/test/integration/renders/regular-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/regular-audio.test.ts@@ -1,9 +1,9 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {rendersPrefix} from '@remotion/serverless/client';import {expect, test} from 'bun:test';import {createWriteStream, unlinkSync} from 'fs';import path from 'path';-import {internalDeleteRender} from '../../../api/delete-render';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';import {Wavedraw} from '../draw-wav';import {simulateLambdaRender} from '../simulate-lambda-render';@@ -58,7 +58,7 @@ test(expect(files.length).toBe(2);- await internalDeleteRender({+ await LambdaClientInternals.internalDeleteRender({bucketName: progress.outBucket as string,region: 'eu-central-1',renderId,diff --git a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts b/packages/lambda/src/test/integration/renders/seamless-audio.test.tsindex a894ae9331..5bd161fdff 100644--- a/packages/lambda/src/test/integration/renders/seamless-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/seamless-audio.test.ts@@ -1,10 +1,10 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {rendersPrefix} from '@remotion/serverless/client';import {$} from 'bun';import {expect, test} from 'bun:test';import {existsSync, unlinkSync} from 'fs';import path from 'path';-import {internalDeleteRender} from '../../../api/delete-render';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';import {streamToUint8Array} from '../../mocks/mock-store';import {Wavedraw} from '../draw-wav';import {simulateLambdaRender} from '../simulate-lambda-render';@@ -64,7 +64,7 @@ test(expect(files.length).toBe(2);- await internalDeleteRender({+ await LambdaClientInternals.internalDeleteRender({bucketName: progress.outBucket as string,region: 'eu-central-1',renderId,diff --git a/packages/lambda/src/test/integration/renders/slow-seamless-audio.test.ts b/packages/lambda/src/test/integration/renders/slow-seamless-audio.test.tsindex 95788931c5..c896678142 100644--- a/packages/lambda/src/test/integration/renders/slow-seamless-audio.test.ts+++ b/packages/lambda/src/test/integration/renders/slow-seamless-audio.test.ts@@ -1,10 +1,10 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {rendersPrefix} from '@remotion/serverless/client';import {$} from 'bun';import {expect, test} from 'bun:test';import {existsSync, unlinkSync} from 'fs';import path from 'path';-import {internalDeleteRender} from '../../../api/delete-render';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';import {streamToUint8Array} from '../../mocks/mock-store';import {Wavedraw} from '../draw-wav';import {simulateLambdaRender} from '../simulate-lambda-render';@@ -63,7 +63,7 @@ test(expect(files.length).toBe(2);- await internalDeleteRender({+ await LambdaClientInternals.internalDeleteRender({bucketName: progress.outBucket as string,region: 'eu-central-1',renderId,diff --git a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts b/packages/lambda/src/test/integration/renders/transparent-webm.test.tsindex 374048156f..91257aed7b 100644--- a/packages/lambda/src/test/integration/renders/transparent-webm.test.ts+++ b/packages/lambda/src/test/integration/renders/transparent-webm.test.ts@@ -1,11 +1,11 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {ensureBrowser, RenderInternals} from '@remotion/renderer';import {rendersPrefix} from '@remotion/serverless/client';import {beforeAll, expect, test} from 'bun:test';import fs, {createWriteStream} from 'node:fs';import os from 'node:os';import path from 'node:path';-import {internalDeleteRender} from '../../../api/delete-render';-import {mockImplementation} from '../../mock-implementation';+import {mockImplementation} from '../../mocks/mock-implementation';import {simulateLambdaRender} from '../simulate-lambda-render';beforeAll(async () => {@@ -61,7 +61,7 @@ test(expect(files.length).toBe(2);- await internalDeleteRender({+ await LambdaClientInternals.internalDeleteRender({bucketName: progress.outBucket as string,region: 'eu-central-1',renderId,diff --git a/packages/lambda/src/test/integration/simulate-lambda-render.ts b/packages/lambda/src/test/integration/simulate-lambda-render.tsindex 37b04205ed..008963f10d 100644--- a/packages/lambda/src/test/integration/simulate-lambda-render.ts+++ b/packages/lambda/src/test/integration/simulate-lambda-render.ts@@ -1,10 +1,11 @@+import {+ LambdaClientInternals,+ type RenderMediaOnLambdaInput,+} from '@remotion/lambda-client';import {RenderInternals} from '@remotion/renderer';import {ServerlessRoutines} from '@remotion/serverless/client';import path from 'path';-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 {mockImplementation} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';import {waitUntilDone} from './wait-until-done';const functionName = 'remotion-dev-render';@@ -28,8 +29,8 @@ export const simulateLambdaRender = async (forceIPv4: false,});- const payload = await makeLambdaRenderMediaPayload(- renderMediaOnLambdaOptionalToRequired({+ const payload = await LambdaClientInternals.makeLambdaRenderMediaPayload(+ LambdaClientInternals.renderMediaOnLambdaOptionalToRequired({...input,serveUrl: `http://localhost:${port}`,functionName,diff --git a/packages/lambda/src/test/integration/wait-until-done.ts b/packages/lambda/src/test/integration/wait-until-done.tsindex f6d72b9e2b..d2c5bd484e 100644--- a/packages/lambda/src/test/integration/wait-until-done.ts+++ b/packages/lambda/src/test/integration/wait-until-done.ts@@ -1,6 +1,6 @@import {ServerlessRoutines} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import {mockImplementation} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';export const waitUntilDone = async (bucketName: string, renderId: string) => {while (true) {diff --git a/packages/lambda/src/test/integration/webhooks.test.ts b/packages/lambda/src/test/integration/webhooks.test.tsindex 8e146643c9..81a2b39ae5 100644--- a/packages/lambda/src/test/integration/webhooks.test.ts+++ b/packages/lambda/src/test/integration/webhooks.test.ts@@ -3,11 +3,8 @@ import {ServerlessRoutines} from '@remotion/serverless/client';import {beforeAll, expect, test} from 'bun:test';import path from 'path';import {VERSION} from 'remotion/version';-import {- getWebhookCalls,- mockImplementation,- resetWebhookCalls,-} from '../mock-implementation';+import {getWebhookCalls, resetWebhookCalls} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';import {waitUntilDone} from './wait-until-done';beforeAll(async () => {diff --git a/packages/lambda/src/test/mock-implementation.ts b/packages/lambda/src/test/mock-implementation.tsindex ae4bfa20c8..0ca6294ae1 100644--- a/packages/lambda/src/test/mock-implementation.ts+++ b/packages/lambda/src/test/mock-implementation.ts@@ -1,43 +1,18 @@-import {openBrowser, RenderInternals} from '@remotion/renderer';+import type {AwsProvider} from '@remotion/lambda-client';+import {+ LambdaClientInternals,+ speculateFunctionName,+} from '@remotion/lambda-client';+import {openBrowser} from '@remotion/renderer';import type {FullClientSpecifics,GetBrowserInstance,InsideFunctionSpecifics,InvokeWebhookParams,- ProviderSpecifics,} from '@remotion/serverless';-import {createReadStream, writeFileSync} from 'fs';-import path from 'path';-import {estimatePrice} from '../api/estimate-price';-import {speculateFunctionName} from '../api/speculate-function-name';-import {MAX_EPHEMERAL_STORAGE_IN_MB} from '../defaults';-import type {AwsProvider} from '../functions/aws-implementation';-import {parseFunctionName} from '../functions/helpers/parse-function-name';-import {convertToServeUrlImplementation} from '../shared/convert-to-serve-url';-import {- getCloudwatchMethodUrl,- getCloudwatchRendererUrl,-} from '../shared/get-aws-urls';-import {isFlakyError} from '../shared/is-flaky-error';-import {randomHashImplementation} from '../shared/random-hash';-import {- getMockCallFunctionAsync,- getMockCallFunctionStreaming,- getMockCallFunctionSync,-} from './mocks/aws-clients';import {mockBundleSite} from './mocks/mock-bundle-site';import {mockCreateFunction} from './mocks/mock-create-function';-import {deleteMockFunction, getAllMockFunctions} from './mocks/mock-functions';import {mockReadDirectory} from './mocks/mock-read-dir';-import {- addMockBucket,- getMockBuckets,- getS3FilesInBucket,- mockBucketExists,- mockDeleteS3File,- readMockS3File,- writeMockS3File,-} from './mocks/mock-store';import {mockUploadDir} from './mocks/upload-dir';type Await<T> = T extends PromiseLike<infer U> ? U : T;@@ -48,148 +23,17 @@ export const getBrowserInstance: GetBrowserInstance = async () => {return {instance: _browserInstance, configurationString: 'chrome'};};-export const mockImplementation: ProviderSpecifics<AwsProvider> = {- getAccountId: () =>- Promise.resolve('aws:iam::123456789'.match(/aws:iam::([0-9]+)/)?.[1]!),- getMaxNonInlinePayloadSizePerFunction: () => 200_000,- getMaxStillInlinePayloadSize() {- return 5_000_000;- },- serverStorageProductName: () => 'file system',- applyLifeCycle: () => Promise.resolve(),- getChromiumPath() {- return null;- },- getEphemeralStorageForPriceCalculation: () => MAX_EPHEMERAL_STORAGE_IN_MB,- getLoggingUrlForMethod: getCloudwatchMethodUrl,- getLoggingUrlForRendererFunction: getCloudwatchRendererUrl,- getCurrentRegionInFunction: () => 'eu-central-1',- createBucket: (input) => {- addMockBucket({- region: input.region,- creationDate: 0,- name: input.bucketName,- });- return Promise.resolve();- },- getBuckets: ({region}) =>- Promise.resolve(getMockBuckets().filter((b) => b.region === region)),- listObjects: (input) => {- if (!input) {- throw new Error('need to pass input');- }-- const files = getS3FilesInBucket({- bucketName: input.bucketName,- region: input.region,- });-- return Promise.resolve(- files- .filter((p) => p.key.startsWith(input.prefix))- .map((file) => {- const size = file.content.byteLength;- return {- Key: file.key,- ETag: 'etag',- LastModified: new Date(0),- Owner: undefined,- Size: size,- StorageClass: undefined,- };- }),- );- },- deleteFile: ({bucketName, key, region}) => {- mockDeleteS3File({- bucketName,- key,- region,- });- return Promise.resolve();- },- bucketExists: ({bucketName, region}) => {- return Promise.resolve(mockBucketExists(bucketName, region));- },- randomHash: () => 'abcdef',- readFile: ({bucketName, key, region}) => {- const file = readMockS3File({region, key, bucketName});- if (!file) {- throw new Error(`no file ${key}`);- }-- const tmp = path.join(RenderInternals.tmpDir('justtest'), 'test');- writeFileSync(tmp, file.content);- return Promise.resolve(createReadStream(tmp));- },- writeFile: async ({body, bucketName, key, privacy, region}) => {- await writeMockS3File({- body,- bucketName,- key,- privacy,- region,- });- return Promise.resolve(undefined);- },- headFile: ({bucketName, key, region}) => {- const read = readMockS3File({- bucketName,- key,- region,- });- if (!read) {- const err = new Error('File not found');- err.name = 'NotFound';- throw err;- }-- return Promise.resolve({- ContentLength: read.content.toString().length,- LastModified: new Date(),- });- },- convertToServeUrl: convertToServeUrlImplementation,- printLoggingHelper: false,- getFolderFiles: () => [- {- filename: 'something',- size: 0,- },- ],- makeArtifactWithDetails: () => ({- filename: 'something',- sizeInBytes: 0,- s3Url: 'https://s3.af-south-1.amazonaws.com/bucket/key',- s3Key: 'key',- }),- validateDeleteAfter: () => {},- callFunctionAsync: getMockCallFunctionAsync,- callFunctionStreaming: getMockCallFunctionStreaming,- callFunctionSync: getMockCallFunctionSync,- estimatePrice,- getOutputUrl: () => {- return {- key: 'mock/mock.mp4',- url: 'https://s3.mock-region-1.amazonaws.com/bucket/mock.mp4',- };- },- isFlakyError,- deleteFunction: deleteMockFunction,- getFunctions: getAllMockFunctions,- parseFunctionName,-};-const paramsArray: InvokeWebhookParams[] = [];-export const mockServerImplementation: InsideFunctionSpecifics = {+export const mockServerImplementation: InsideFunctionSpecifics<AwsProvider> = {forgetBrowserEventLoop: () => {},+ getCurrentRegionInFunction: () => 'eu-central-1',getBrowserInstance,timer: () => ({end: () => {},}),deleteTmpDir: () => Promise.resolve(),- generateRandomId: randomHashImplementation,+ generateRandomId: LambdaClientInternals.randomHashImplementation,getCurrentFunctionName: () =>speculateFunctionName({diskSizeInMb: 10240,@@ -201,6 +45,18 @@ export const mockServerImplementation: InsideFunctionSpecifics = {paramsArray.push(params);return Promise.resolve();},+ getFolderFiles: () => [+ {+ filename: 'something',+ size: 0,+ },+ ],+ makeArtifactWithDetails: () => ({+ filename: 'something',+ sizeInBytes: 0,+ s3Url: 'https://s3.af-south-1.amazonaws.com/bucket/key',+ s3Key: 'key',+ }),};export const resetWebhookCalls = () => {@@ -217,5 +73,4 @@ export const mockFullClientSpecifics: FullClientSpecifics<AwsProvider> = {readDirectory: mockReadDirectory,uploadDir: mockUploadDir,createFunction: mockCreateFunction,- checkCredentials: () => undefined,};diff --git a/packages/lambda/src/test/mocks/aws-clients.ts b/packages/lambda/src/test/mocks/aws-clients.tsindex 8db80ba573..e77232b857 100644--- a/packages/lambda/src/test/mocks/aws-clients.ts+++ b/packages/lambda/src/test/mocks/aws-clients.ts@@ -1,3 +1,4 @@+import {LambdaClientInternals, type AwsProvider} from '@remotion/lambda-client';import type {CallFunctionAsync,CallFunctionOptions,@@ -16,13 +17,9 @@ import {messageTypeIdToMessageType,} from '@remotion/serverless/client';import {makeStreamer} from '@remotion/streaming';-import type {AwsProvider} from '../../functions/aws-implementation';import {getWebhookClient} from '../../functions/http-client';-import {parseJsonOrThrowSource} from '../../shared/call-lambda-streaming';-import {- mockImplementation,- mockServerImplementation,-} from '../mock-implementation';+import {mockServerImplementation} from '../mock-implementation';+import {mockImplementation} from './mock-implementation';export const getMockCallFunctionStreaming: CallFunctionStreaming<AwsProvider@@ -40,7 +37,7 @@ export const getMockCallFunctionStreaming: CallFunctionStreaming<);const innerPayload =formatMap[messageType] === 'json'- ? parseJsonOrThrowSource(data, messageType)+ ? LambdaClientInternals.parseJsonOrThrowSource(data, messageType): data;const message: StreamingMessage<AwsProvider> = {diff --git a/packages/lambda/src/test/mocks/mock-create-function.ts b/packages/lambda/src/test/mocks/mock-create-function.tsindex 6a8e91ff75..a203176214 100644--- a/packages/lambda/src/test/mocks/mock-create-function.ts+++ b/packages/lambda/src/test/mocks/mock-create-function.ts@@ -1,6 +1,6 @@+import type {AwsProvider} from '@remotion/lambda-client';import type {CreateFunction} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import type {AwsProvider} from '../../functions/aws-implementation';import {addFunction} from './mock-functions';export const mockCreateFunction: CreateFunction<AwsProvider> = (input) => {diff --git a/packages/lambda/src/test/mocks/mock-functions.ts b/packages/lambda/src/test/mocks/mock-functions.tsindex 902717c00a..b6bc9b4707 100644--- a/packages/lambda/src/test/mocks/mock-functions.ts+++ b/packages/lambda/src/test/mocks/mock-functions.ts@@ -1,11 +1,10 @@+import type {AwsProvider, AwsRegion} from '@remotion/lambda-client';import type {DeleteFunction,FunctionInfo,GetFunctions,} from '@remotion/serverless';import {VERSION} from 'remotion/version';-import type {AwsProvider} from '../../functions/aws-implementation';-import type {AwsRegion} from '../../regions';export let mockFunctionsStore: (FunctionInfo & {region: AwsRegion;diff --git a/packages/lambda/src/test/mocks/mock-implementation.ts b/packages/lambda/src/test/mocks/mock-implementation.tsnew file mode 100644index 0000000000..40ebca6734--- /dev/null+++ b/packages/lambda/src/test/mocks/mock-implementation.ts@@ -0,0 +1,143 @@+import type {AwsProvider} from '@remotion/lambda-client';+import {estimatePrice, LambdaClientInternals} from '@remotion/lambda-client';+import {RenderInternals} from '@remotion/renderer';+import type {ProviderSpecifics} from '@remotion/serverless';+import {createReadStream, writeFileSync} from 'fs';+import path from 'path';+import {+ getMockCallFunctionAsync,+ getMockCallFunctionStreaming,+ getMockCallFunctionSync,+} from './aws-clients';+import {deleteMockFunction, getAllMockFunctions} from './mock-functions';+import {+ addMockBucket,+ getMockBuckets,+ getS3FilesInBucket,+ mockBucketExists,+ mockDeleteS3File,+ readMockS3File,+ writeMockS3File,+} from './mock-store';++export const mockImplementation: ProviderSpecifics<AwsProvider> = {+ getAccountId: () =>+ Promise.resolve('aws:iam::123456789'.match(/aws:iam::([0-9]+)/)?.[1]!),+ getMaxNonInlinePayloadSizePerFunction: () => 200_000,+ getMaxStillInlinePayloadSize() {+ return 5_000_000;+ },+ serverStorageProductName: () => 'file system',+ applyLifeCycle: () => Promise.resolve(),+ getChromiumPath() {+ return null;+ },+ getEphemeralStorageForPriceCalculation: () =>+ LambdaClientInternals.MAX_EPHEMERAL_STORAGE_IN_MB,+ getLoggingUrlForMethod: LambdaClientInternals.getCloudwatchMethodUrl,+ getLoggingUrlForRendererFunction:+ LambdaClientInternals.getCloudwatchRendererUrl,+ createBucket: (input) => {+ addMockBucket({+ region: input.region,+ creationDate: 0,+ name: input.bucketName,+ });+ return Promise.resolve();+ },+ getBuckets: ({region}) =>+ Promise.resolve(getMockBuckets().filter((b) => b.region === region)),+ listObjects: (input) => {+ if (!input) {+ throw new Error('need to pass input');+ }++ const files = getS3FilesInBucket({+ bucketName: input.bucketName,+ region: input.region,+ });++ return Promise.resolve(+ files+ .filter((p) => p.key.startsWith(input.prefix))+ .map((file) => {+ const size = file.content.byteLength;+ return {+ Key: file.key,+ ETag: 'etag',+ LastModified: new Date(0),+ Owner: undefined,+ Size: size,+ StorageClass: undefined,+ };+ }),+ );+ },+ deleteFile: ({bucketName, key, region}) => {+ mockDeleteS3File({+ bucketName,+ key,+ region,+ });+ return Promise.resolve();+ },+ bucketExists: ({bucketName, region}) => {+ return Promise.resolve(mockBucketExists(bucketName, region));+ },+ randomHash: () => 'abcdef',+ readFile: ({bucketName, key, region}) => {+ const file = readMockS3File({region, key, bucketName});+ if (!file) {+ throw new Error(`no file ${key}`);+ }++ const tmp = path.join(RenderInternals.tmpDir('justtest'), 'test');+ writeFileSync(tmp, file.content);+ return Promise.resolve(createReadStream(tmp));+ },+ writeFile: async ({body, bucketName, key, privacy, region}) => {+ await writeMockS3File({+ body,+ bucketName,+ key,+ privacy,+ region,+ });+ return Promise.resolve(undefined);+ },+ headFile: ({bucketName, key, region}) => {+ const read = readMockS3File({+ bucketName,+ key,+ region,+ });+ if (!read) {+ const err = new Error('File not found');+ err.name = 'NotFound';+ throw err;+ }++ return Promise.resolve({+ ContentLength: read.content.toString().length,+ LastModified: new Date(),+ });+ },+ convertToServeUrl: LambdaClientInternals.convertToServeUrlImplementation,+ printLoggingHelper: false,+ validateDeleteAfter: () => {},+ callFunctionAsync: getMockCallFunctionAsync,+ callFunctionStreaming: getMockCallFunctionStreaming,+ callFunctionSync: getMockCallFunctionSync,+ estimatePrice,+ getOutputUrl: () => {+ return {+ key: 'mock/mock.mp4',+ url: 'https://s3.mock-region-1.amazonaws.com/bucket/mock.mp4',+ };+ },+ isFlakyError: LambdaClientInternals.isFlakyError,+ deleteFunction: deleteMockFunction,+ getFunctions: getAllMockFunctions,+ parseFunctionName: LambdaClientInternals.parseFunctionName,+ checkCredentials: () => Promise.resolve(),+};diff --git a/packages/lambda/src/test/mocks/mock-store.ts b/packages/lambda/src/test/mocks/mock-store.tsindex b82045aa14..481a3b7333 100644--- a/packages/lambda/src/test/mocks/mock-store.ts+++ b/packages/lambda/src/test/mocks/mock-store.ts@@ -1,11 +1,9 @@-import type {CloudProvider} from '@remotion/serverless';+import type {AwsProvider, AwsRegion} from '@remotion/lambda-client';+import type {BucketWithLocation, CloudProvider} from '@remotion/serverless';import type {Privacy} from '@remotion/serverless/client';import {Readable} from 'stream';-import type {BucketWithLocation} from '../../api/get-buckets';-import type {AwsProvider} from '../../functions/aws-implementation';-import type {AwsRegion} from '../../regions';-export const mockBucketStore: BucketWithLocation[] = [];+export const mockBucketStore: BucketWithLocation<AwsProvider>[] = [];type S3MockFile<Provider extends CloudProvider> = {bucketName: string;@@ -17,7 +15,7 @@ type S3MockFile<Provider extends CloudProvider> = {let mockS3Store: S3MockFile<AwsProvider>[] = [];-export const addMockBucket = (bucket: BucketWithLocation) => {+export const addMockBucket = (bucket: BucketWithLocation<AwsProvider>) => {mockBucketStore.push(bucket);};diff --git a/packages/lambda/src/test/unit/best-bucketnames.test.ts b/packages/lambda/src/test/unit/best-bucketnames.test.tsindex 71647781fd..c5f8a9f724 100644--- a/packages/lambda/src/test/unit/best-bucketnames.test.ts+++ b/packages/lambda/src/test/unit/best-bucketnames.test.ts@@ -1,12 +1,12 @@+import {LambdaClientInternals} from '@remotion/lambda-client';import {makeBucketName} from '@remotion/serverless/client';import {expect, test} from 'bun:test';-import {parseBucketName} from '../../shared/validate-bucketname';-import {mockImplementation} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';test('Generate and parse bucket names correctly', () => {const name = makeBucketName('us-east-1', mockImplementation);expect(name).toBe('remotionlambda-useast1-abcdef');- const parsed = parseBucketName(name);+ const parsed = LambdaClientInternals.parseBucketName(name);expect(parsed).toEqual({region: 'us-east-1'});});diff --git a/packages/lambda/src/test/unit/handlers.test.ts b/packages/lambda/src/test/unit/handlers.test.tsindex c342b55c3e..cefdb2c451 100644--- a/packages/lambda/src/test/unit/handlers.test.ts+++ b/packages/lambda/src/test/unit/handlers.test.ts@@ -1,6 +1,6 @@import {ServerlessRoutines} from '@remotion/serverless/client';import {expect, test} from 'bun:test';-import {mockImplementation} from '../mock-implementation';+import {mockImplementation} from '../mocks/mock-implementation';test('Info handler should return version', async () => {const response = await mockImplementation.callFunctionSync({diff --git a/packages/lambda/tsconfig.json b/packages/lambda/tsconfig.jsonindex f802c24668..bbe43174f9 100644--- a/packages/lambda/tsconfig.json+++ b/packages/lambda/tsconfig.json@@ -8,6 +8,7 @@"references": [{"path": "../core"},{"path": "../bundler"},+ {"path": "../lambda-client"},{"path": "../cli"},{"path": "../streaming"},{"path": "../serverless"},diff --git a/packages/serverless/src/cleanup-props.ts b/packages/serverless/src/cleanup-props.tsindex 0a0b20cac3..32de538ef1 100644--- a/packages/serverless/src/cleanup-props.ts+++ b/packages/serverless/src/cleanup-props.ts@@ -3,7 +3,10 @@ import {cleanupSerializedResolvedProps,} from './cleanup-serialized-input-props';import type {SerializedInputProps} from './constants';-import type {ProviderSpecifics} from './provider-implementation';+import type {+ InsideFunctionSpecifics,+ ProviderSpecifics,+} from './provider-implementation';import type {CloudProvider} from './types';export const cleanupProps = <Provider extends CloudProvider>({@@ -11,20 +14,22 @@ export const cleanupProps = <Provider extends CloudProvider>({inputProps,providerSpecifics,forcePathStyle,+ insideFunctionSpecifics,}: {serializedResolvedProps: SerializedInputProps;inputProps: SerializedInputProps;providerSpecifics: ProviderSpecifics<Provider>;forcePathStyle: boolean;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<[number, number]> => {const cleanupSerializedInputPropsProm = cleanupSerializedInputProps({- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: inputProps,providerSpecifics,forcePathStyle,});const cleanupResolvedInputPropsProm = cleanupSerializedResolvedProps({- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: serializedResolvedProps,providerSpecifics,forcePathStyle,diff --git a/packages/serverless/src/concat-videos.ts b/packages/serverless/src/concat-videos.tsindex 1653391ce4..b21951d666 100644--- a/packages/serverless/src/concat-videos.ts+++ b/packages/serverless/src/concat-videos.ts@@ -13,8 +13,9 @@ import {type ServerlessCodec,} from './constants';import type {InsideFunctionSpecifics} from './provider-implementation';+import type {CloudProvider} from './types';-export const concatVideos = async ({+export const concatVideos = async <Provider extends CloudProvider>({onProgress,numberOfFrames,codec,@@ -49,7 +50,7 @@ export const concatVideos = async ({preferLossless: boolean;muted: boolean;metadata: Record<string, string> | null;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}) => {const outfile = join(RenderInternals.tmpDir(REMOTION_CONCATENATED_TOKEN),diff --git a/packages/serverless/src/get-browser-instance.ts b/packages/serverless/src/get-browser-instance.tsindex e565aa6c7f..747b2b4595 100644--- a/packages/serverless/src/get-browser-instance.ts+++ b/packages/serverless/src/get-browser-instance.ts@@ -71,7 +71,7 @@ export const getBrowserInstanceImplementation: GetBrowserInstance = async <indent: boolean;chromiumOptions: ChromiumOptions;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<LaunchedBrowser> => {const actualChromiumOptions: ChromiumOptions = {...chromiumOptions,diff --git a/packages/serverless/src/handlers/check-version-mismatch.ts b/packages/serverless/src/handlers/check-version-mismatch.tsindex 22d7f8c9e7..a6a35f6dcb 100644--- a/packages/serverless/src/handlers/check-version-mismatch.ts+++ b/packages/serverless/src/handlers/check-version-mismatch.ts@@ -9,7 +9,7 @@ export const checkVersionMismatch = <Provider extends CloudProvider>({apiName,}: {params: ServerlessPayload<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;apiName: string;}) => {if (params.type === ServerlessRoutines.info) {diff --git a/packages/serverless/src/handlers/compositions.ts b/packages/serverless/src/handlers/compositions.tsindex 426a97e3cc..2072819371 100644--- a/packages/serverless/src/handlers/compositions.ts+++ b/packages/serverless/src/handlers/compositions.ts@@ -24,7 +24,7 @@ export const compositionsHandler = async <Provider extends CloudProvider>({params: ServerlessPayload<Provider>;options: Options;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}) => {if (params.type !== ServerlessRoutines.compositions) {throw new TypeError('Expected info compositions');@@ -37,7 +37,7 @@ export const compositionsHandler = async <Provider extends CloudProvider>({});try {- const region = providerSpecifics.getCurrentRegionInFunction();+ const region = insideFunctionSpecifics.getCurrentRegionInFunction();const browserInstancePromise = insideFunctionSpecifics.getBrowserInstance({logLevel: params.logLevel,@@ -61,7 +61,7 @@ export const compositionsHandler = async <Provider extends CloudProvider>({const serializedInputPropsWithCustomSchema = await decompressInputProps({bucketName: await bucketNamePromise,expectedBucketOwner: options.expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: params.inputProps,propsType: 'input-props',providerSpecifics,diff --git a/packages/serverless/src/handlers/launch.ts b/packages/serverless/src/handlers/launch.tsindex 77a23261f0..e74233b34c 100644--- a/packages/serverless/src/handlers/launch.ts+++ b/packages/serverless/src/handlers/launch.ts@@ -62,7 +62,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({overallProgress: OverallProgressHelper<Provider>;registerCleanupTask: (cleanupTask: CleanupTask) => void;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<PostRenderData<Provider>> => {if (params.type !== ServerlessRoutines.launch) {throw new Error('Expected launch type');@@ -81,7 +81,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({const inputPropsPromise = decompressInputProps({bucketName: params.bucketName,expectedBucketOwner: options.expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: params.inputProps,propsType: 'input-props',providerSpecifics,@@ -204,7 +204,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({const serializedResolvedProps = await compressInputProps({propsType: 'resolved-props',- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),stringifiedInputProps: serializedResolved,userSpecifiedBucketName: params.bucketName,needsToUpload,@@ -214,11 +214,12 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({});registerCleanupTask(() => {- return cleanupProps({+ return cleanupProps<Provider>({serializedResolvedProps,inputProps: params.inputProps,providerSpecifics,forcePathStyle: params.forcePathStyle,+ insideFunctionSpecifics,});});@@ -310,7 +311,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({lambdaVersion: VERSION,framesPerLambda,memorySizeInMb: insideFunctionSpecifics.getCurrentMemorySizeInMb(),- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),renderId: params.renderId,outName: params.outName ?? undefined,privacy: params.privacy,@@ -350,14 +351,14 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({bucketName: params.bucketName,customCredentials,renderMetadata,- region: providerSpecifics.getCurrentRegionInFunction(),- currentRegion: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),+ currentRegion: insideFunctionSpecifics.getCurrentRegionInFunction(),providerSpecifics,forcePathStyle: params.forcePathStyle,});if (output) {throw new TypeError(- `Output file "${key}" in bucket "${renderBucketName}" in region "${providerSpecifics.getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in renderMediaOnLambda() to overwrite it."`,+ `Output file "${key}" in bucket "${renderBucketName}" in region "${insideFunctionSpecifics.getCurrentRegionInFunction()}" already exists. Delete it before re-rendering, or set the 'overwrite' option in renderMediaOnLambda() to overwrite it."`,);}@@ -386,7 +387,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({return {alreadyExisted: true};}- const region = providerSpecifics.getCurrentRegionInFunction();+ const region = insideFunctionSpecifics.getCurrentRegionInFunction();const storageKey = artifactName(renderMetadata.renderId, artifact.filename);const start = Date.now();@@ -413,7 +414,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({);overallProgress.addReceivedArtifact(- providerSpecifics.makeArtifactWithDetails({+ insideFunctionSpecifics.makeArtifactWithDetails({region,renderBucketName,storageKey,@@ -456,6 +457,7 @@ const innerLaunchHandler = async <Provider extends CloudProvider>({logLevel: params.logLevel,onArtifact,providerSpecifics,+ insideFunctionSpecifics,});}),);@@ -508,7 +510,7 @@ export const launchHandler = async <Provider extends CloudProvider>({params: ServerlessPayload<Provider>;options: Options;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;client: WebhookClient;}): Promise<{type: 'success';@@ -661,7 +663,7 @@ export const launchHandler = async <Provider extends CloudProvider>({renderId: params.renderId,bucketName: params.bucketName,expectedBucketOwner: options.expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),timeoutTimestamp: options.getRemainingTimeInMillis() + Date.now(),logLevel: params.logLevel,providerSpecifics,@@ -764,7 +766,7 @@ export const launchHandler = async <Provider extends CloudProvider>({isFatal: true,tmpDir: getTmpDirStateIfENoSp((err as Error).stack as string,- providerSpecifics,+ insideFunctionSpecifics,),attempt: 1,totalAttempts: 1,diff --git a/packages/serverless/src/handlers/progress.ts b/packages/serverless/src/handlers/progress.tsindex 554a149604..0615e6e599 100644--- a/packages/serverless/src/handlers/progress.ts+++ b/packages/serverless/src/handlers/progress.ts@@ -14,7 +14,7 @@ type Options<Provider extends CloudProvider> = {timeoutInMilliseconds: number;retriesRemaining: number;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;};export const progressHandler = async <Provider extends CloudProvider>({@@ -39,7 +39,7 @@ export const progressHandler = async <Provider extends CloudProvider>({bucketName: params.bucketName,renderId: params.renderId,expectedBucketOwner: options.expectedBucketOwner,- region: options.providerSpecifics.getCurrentRegionInFunction(),+ region: options.insideFunctionSpecifics.getCurrentRegionInFunction(),memorySizeInMb:options.insideFunctionSpecifics.getCurrentMemorySizeInMb(),timeoutInMilliseconds: options.timeoutInMilliseconds,diff --git a/packages/serverless/src/handlers/renderer.ts b/packages/serverless/src/handlers/renderer.tsindex 4c9bd36ea4..b53a6dcb6f 100644--- a/packages/serverless/src/handlers/renderer.ts+++ b/packages/serverless/src/handlers/renderer.ts@@ -54,7 +54,7 @@ const renderHandler = async <Provider extends CloudProvider>({logs: BrowserLog[];onStream: OnStream<Provider>;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<{}> => {if (params.type !== ServerlessRoutines.renderer) {throw new Error('Params must be renderer');@@ -69,7 +69,7 @@ const renderHandler = async <Provider extends CloudProvider>({const inputPropsPromise = decompressInputProps({bucketName: params.bucketName,expectedBucketOwner: options.expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: params.inputProps,propsType: 'input-props',providerSpecifics,@@ -79,7 +79,7 @@ const renderHandler = async <Provider extends CloudProvider>({const resolvedPropsPromise = decompressInputProps({bucketName: params.bucketName,expectedBucketOwner: options.expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: params.resolvedProps,propsType: 'resolved-props',providerSpecifics,@@ -424,7 +424,7 @@ export const rendererHandler = async <Provider extends CloudProvider>({onStream: OnStream<Provider>;requestContext: RequestContext;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<{type: 'success';}> => {@@ -492,7 +492,7 @@ export const rendererHandler = async <Provider extends CloudProvider>({isFatal: !shouldRetry,tmpDir: getTmpDirStateIfENoSp((err as Error).stack as string,- providerSpecifics,+ insideFunctionSpecifics,),attempt: params.attempt,totalAttempts: params.retriesLeft + params.attempt,diff --git a/packages/serverless/src/handlers/start.ts b/packages/serverless/src/handlers/start.tsindex 343057e0b3..c6b2214e5e 100644--- a/packages/serverless/src/handlers/start.ts+++ b/packages/serverless/src/handlers/start.ts@@ -24,7 +24,7 @@ export const startHandler = async <Provider extends CloudProvider>({params: ServerlessPayload<Provider>;options: Options;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}) => {if (params.type !== ServerlessRoutines.start) {throw new TypeError('Expected type start');@@ -36,12 +36,12 @@ export const startHandler = async <Provider extends CloudProvider>({params,});- const region = providerSpecifics.getCurrentRegionInFunction();+ const region = insideFunctionSpecifics.getCurrentRegionInFunction();const bucketName =params.bucketName ??(await internalGetOrCreateBucket({- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),enableFolderExpiry: null,customCredentials: null,providerSpecifics,diff --git a/packages/serverless/src/handlers/still.ts b/packages/serverless/src/handlers/still.tsindex 1c8164aa41..143ac1ede8 100644--- a/packages/serverless/src/handlers/still.ts+++ b/packages/serverless/src/handlers/still.ts@@ -47,7 +47,7 @@ type Options<Provider extends CloudProvider> = {onStream: OnStream<Provider>;timeoutInMilliseconds: number;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;};const innerStillHandler = async <Provider extends CloudProvider>(@@ -93,7 +93,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(const bucketNamePromise =params.bucketName ??internalGetOrCreateBucket({- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),enableFolderExpiry: null,customCredentials: null,providerSpecifics,@@ -105,7 +105,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(const outputPath = path.join(outputDir, 'output');- const region = providerSpecifics.getCurrentRegionInFunction();+ const region = insideFunctionSpecifics.getCurrentRegionInFunction();const bucketName = await bucketNamePromise;const serializedInputPropsWithCustomSchema = await decompressInputProps({bucketName,@@ -179,7 +179,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(lambdaVersion: VERSION,framesPerLambda: 1,memorySizeInMb: insideFunctionSpecifics.getCurrentMemorySizeInMb(),- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),renderId,outName: params.outName ?? undefined,privacy: params.privacy,@@ -204,7 +204,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(bucketName,key: overallProgressKey(renderId),body: JSON.stringify(still),- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),privacy: 'private',expectedBucketOwner,downloadBehavior: null,@@ -232,7 +232,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(const storageKey = artifactName(renderMetadata.renderId, artifact.filename);receivedArtifact.push(- providerSpecifics.makeArtifactWithDetails({+ insideFunctionSpecifics.makeArtifactWithDetails({storageKey,artifact,region,@@ -319,7 +319,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(privacy: params.privacy,body: fs.createReadStream(outputPath),expectedBucketOwner,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),downloadBehavior: params.downloadBehavior,customCredentials,forcePathStyle: params.forcePathStyle,@@ -328,7 +328,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(await Promise.all([fs.promises.rm(outputPath, {recursive: true}),cleanupSerializedInputProps({- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),serialized: params.inputProps,providerSpecifics,forcePathStyle: params.forcePathStyle,@@ -340,7 +340,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(const estimatedPrice = providerSpecifics.estimatePrice({durationInMilliseconds: Date.now() - start + 100,memorySizeInMb: insideFunctionSpecifics.getCurrentMemorySizeInMb(),- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),lambdasInvoked: 1,diskSizeInMb: providerSpecifics.getEphemeralStorageForPriceCalculation(),});@@ -349,7 +349,7 @@ const innerStillHandler = async <Provider extends CloudProvider>(renderMetadata,bucketName,customCredentials,- currentRegion: providerSpecifics.getCurrentRegionInFunction(),+ currentRegion: insideFunctionSpecifics.getCurrentRegionInFunction(),});const payload: RenderStillFunctionResponsePayload<Provider> = {@@ -429,7 +429,7 @@ export const stillHandler = async <Provider extends CloudProvider>(isFatal: false,tmpDir: getTmpDirStateIfENoSp((err as Error).stack as string,- options.providerSpecifics,+ options.insideFunctionSpecifics,),attempt: params.attempt,totalAttempts: 1 + params.maxRetries,diff --git a/packages/serverless/src/inner-routine.ts b/packages/serverless/src/inner-routine.tsindex 222121a43d..7fdd17a8f7 100644--- a/packages/serverless/src/inner-routine.ts+++ b/packages/serverless/src/inner-routine.ts@@ -35,7 +35,7 @@ export const innerHandler = async <Provider extends CloudProvider>({responseWriter: ResponseStreamWriter;context: RequestContext;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;webhookClient: WebhookClient;}): Promise<void> => {setCurrentRequestId(context.awsRequestId);@@ -362,7 +362,7 @@ export const innerRoutine = async <Provider extends CloudProvider>({responseWriter: ResponseStreamWriter;context: RequestContext;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;webhookClient: WebhookClient;}): Promise<void> => {try {diff --git a/packages/serverless/src/merge-chunks.ts b/packages/serverless/src/merge-chunks.tsindex 4a397c3cba..f7db51627e 100644--- a/packages/serverless/src/merge-chunks.ts+++ b/packages/serverless/src/merge-chunks.ts@@ -52,7 +52,7 @@ export const mergeChunksAndFinishRender = async <overallProgress: OverallProgressHelper<Provider>;startTime: number;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;forcePathStyle: boolean;}): Promise<PostRenderData<Provider>> => {const onProgress = (framesEncoded: number) => {@@ -101,7 +101,7 @@ export const mergeChunksAndFinishRender = async <bucketName: options.renderBucketName,key: options.key,body: fs.readFileSync(outfile),- region: options.providerSpecifics.getCurrentRegionInFunction(),+ region: options.insideFunctionSpecifics.getCurrentRegionInFunction(),privacy: options.privacy,expectedBucketOwner: options.expectedBucketOwner,downloadBehavior: options.downloadBehavior,@@ -120,17 +120,18 @@ export const mergeChunksAndFinishRender = async <serializedResolvedProps: options.serializedResolvedProps,providerSpecifics: options.providerSpecifics,forcePathStyle: options.forcePathStyle,+ insideFunctionSpecifics: options.insideFunctionSpecifics,});const {url: outputUrl} = options.providerSpecifics.getOutputUrl({bucketName: options.renderBucketName,- currentRegion: options.providerSpecifics.getCurrentRegionInFunction(),+ currentRegion: options.insideFunctionSpecifics.getCurrentRegionInFunction(),customCredentials: options.customCredentials,renderMetadata: options.renderMetadata,});const postRenderData = createPostRenderData({- region: options.providerSpecifics.getCurrentRegionInFunction(),+ region: options.insideFunctionSpecifics.getCurrentRegionInFunction(),memorySizeInMb: options.insideFunctionSpecifics.getCurrentMemorySizeInMb(),renderMetadata: options.renderMetadata,errorExplanations,diff --git a/packages/serverless/src/provider-implementation.ts b/packages/serverless/src/provider-implementation.tsindex 6ca7a94114..446ae90fe3 100644--- a/packages/serverless/src/provider-implementation.ts+++ b/packages/serverless/src/provider-implementation.ts@@ -227,7 +227,7 @@ export type GetBrowserInstance = <Provider extends CloudProvider>({indent: boolean;chromiumOptions: ChromiumOptions;providerSpecifics: ProviderSpecifics<Provider>;- insideFunctionSpecifics: InsideFunctionSpecifics;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}) => Promise<LaunchedBrowser>;export type ForgetBrowserEventLoop = (logLevel: LogLevel) => void;@@ -348,7 +348,7 @@ export type InvokeWebhookParams = {export type InvokeWebhook = (params: InvokeWebhookParams) => Promise<void>;-export type InsideFunctionSpecifics = {+export type InsideFunctionSpecifics<Provider extends CloudProvider> = {getBrowserInstance: GetBrowserInstance;forgetBrowserEventLoop: ForgetBrowserEventLoop;timer: DebuggingTimer;@@ -357,6 +357,9 @@ export type InsideFunctionSpecifics = {getCurrentFunctionName: () => string;getCurrentMemorySizeInMb: () => number;invokeWebhook: InvokeWebhook;+ getCurrentRegionInFunction: () => Provider['region'];+ makeArtifactWithDetails: MakeArtifactWithDetails<Provider>;+ getFolderFiles: GetFolderFiles;};export type FullClientSpecifics<Provider extends CloudProvider> = {@@ -365,12 +368,10 @@ export type FullClientSpecifics<Provider extends CloudProvider> = {readDirectory: ReadDir;uploadDir: UploadDir<Provider>;createFunction: CreateFunction<Provider>;- checkCredentials: () => void;};export type ProviderSpecifics<Provider extends CloudProvider> = {getChromiumPath: () => string | null;- getCurrentRegionInFunction: () => Provider['region'];getBuckets: GetBuckets<Provider>;createBucket: CreateBucket<Provider>;applyLifeCycle: ApplyLifeCycle<Provider>;@@ -383,8 +384,6 @@ export type ProviderSpecifics<Provider extends CloudProvider> = {headFile: HeadFile<Provider>;convertToServeUrl: ConvertToServeUrl<Provider>;printLoggingHelper: boolean;- getFolderFiles: GetFolderFiles;- makeArtifactWithDetails: MakeArtifactWithDetails<Provider>;validateDeleteAfter: (lifeCycleValue: unknown) => void;callFunctionAsync: CallFunctionAsync<Provider>;callFunctionStreaming: CallFunctionStreaming<Provider>;@@ -402,4 +401,5 @@ export type ProviderSpecifics<Provider extends CloudProvider> = {deleteFunction: DeleteFunction<Provider>;getFunctions: GetFunctions<Provider>;parseFunctionName: ParseFunctionName;+ checkCredentials: () => void;};diff --git a/packages/serverless/src/stream-renderer.ts b/packages/serverless/src/stream-renderer.tsindex 3e2fbaecab..cddb729389 100644--- a/packages/serverless/src/stream-renderer.ts+++ b/packages/serverless/src/stream-renderer.ts@@ -6,7 +6,10 @@ import {join} from 'path';import type {ServerlessPayload} from './constants';import {ServerlessRoutines} from './constants';import type {OverallProgressHelper} from './overall-render-progress';-import type {ProviderSpecifics} from './provider-implementation';+import type {+ InsideFunctionSpecifics,+ ProviderSpecifics,+} from './provider-implementation';import {deserializeArtifact} from './serialize-artifact';import type {OnMessage} from './streaming/streaming';import type {CloudProvider} from './types';@@ -30,6 +33,7 @@ const streamRenderer = <Provider extends CloudProvider>({logLevel,onArtifact,providerSpecifics,+ insideFunctionSpecifics,}: {payload: ServerlessPayload<Provider>;functionName: string;@@ -39,6 +43,7 @@ const streamRenderer = <Provider extends CloudProvider>({logLevel: LogLevel;onArtifact: (asset: EmittedArtifact) => {alreadyExisted: boolean};providerSpecifics: ProviderSpecifics<Provider>;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}) => {if (payload.type !== ServerlessRoutines.renderer) {throw new Error('Expected renderer type');@@ -162,7 +167,7 @@ const streamRenderer = <Provider extends CloudProvider>({functionName,payload,retriesRemaining: 1,- region: providerSpecifics.getCurrentRegionInFunction(),+ region: insideFunctionSpecifics.getCurrentRegionInFunction(),timeoutInTest: 12000,type: ServerlessRoutines.renderer,receivedStreamingPayload,@@ -196,6 +201,7 @@ export const streamRendererFunctionWithRetry = async <logLevel,onArtifact,providerSpecifics,+ insideFunctionSpecifics,}: {payload: ServerlessPayload<Provider>;functionName: string;@@ -205,6 +211,7 @@ export const streamRendererFunctionWithRetry = async <logLevel: LogLevel;onArtifact: (asset: EmittedArtifact) => {alreadyExisted: boolean};providerSpecifics: ProviderSpecifics<Provider>;+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>;}): Promise<unknown> => {if (payload.type !== ServerlessRoutines.renderer) {throw new Error('Expected renderer type');@@ -219,6 +226,7 @@ export const streamRendererFunctionWithRetry = async <logLevel,onArtifact,providerSpecifics,+ insideFunctionSpecifics,});if (result.type === 'error') {@@ -245,6 +253,7 @@ export const streamRendererFunctionWithRetry = async <logLevel,onArtifact,providerSpecifics,+ insideFunctionSpecifics,});}};diff --git a/packages/serverless/src/write-error-to-storage.ts b/packages/serverless/src/write-error-to-storage.tsindex ee64c102c7..9980237c29 100644--- a/packages/serverless/src/write-error-to-storage.ts+++ b/packages/serverless/src/write-error-to-storage.ts@@ -1,6 +1,6 @@import {errorIsOutOfSpaceError} from './error-category';import type {FileNameAndSize} from './get-files-in-folder';-import type {ProviderSpecifics} from './provider-implementation';+import type {InsideFunctionSpecifics} from './provider-implementation';import type {CloudProvider} from './types';export type FunctionErrorInfo = {@@ -19,13 +19,13 @@ export type FunctionErrorInfo = {export const getTmpDirStateIfENoSp = <Provider extends CloudProvider>(err: string,- providerSpecifics: ProviderSpecifics<Provider>,+ insideFunctionSpecifics: InsideFunctionSpecifics<Provider>,): FunctionErrorInfo['tmpDir'] => {if (!errorIsOutOfSpaceError(err)) {return null;}- const files = providerSpecifics.getFolderFiles('/tmp');+ const files = insideFunctionSpecifics.getFolderFiles('/tmp');return {files: files.slice(0)diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 9223a888ae..591beaf542 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1000,6 +1000,9 @@ importers:'@remotion/lambda':specifier: workspace:*version: link:../lambda+ '@remotion/lambda-client':+ specifier: workspace:*+ version: link:../lambda-client'@remotion/layout-utils':specifier: workspace:*version: link:../layout-utils@@ -1344,24 +1347,6 @@ importers:packages/lambda:dependencies:- '@aws-sdk/client-cloudwatch-logs':- specifier: 3.738.0- version: 3.738.0- '@aws-sdk/client-iam':- specifier: 3.738.0- version: 3.738.0- '@aws-sdk/client-lambda':- specifier: 3.738.0- version: 3.738.0- '@aws-sdk/client-s3':- specifier: 3.738.0- version: 3.738.0- '@aws-sdk/client-service-quotas':- specifier: 3.738.0- version: 3.738.0- '@aws-sdk/client-sts':- specifier: 3.738.0- version: 3.738.0'@aws-sdk/credential-providers':specifier: 3.738.0version: 3.738.0@@ -1377,6 +1362,9 @@ importers:'@remotion/cli':specifier: workspace:*version: link:../cli+ '@remotion/lambda-client':+ specifier: workspace:*+ version: link:../lambda-client'@remotion/renderer':specifier: workspace:*version: link:../renderer@@ -1433,6 +1421,52 @@ importers:specifier: ^0.7.2version: 0.7.2+ packages/lambda-client:+ dependencies:+ '@aws-sdk/client-cloudwatch-logs':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/client-iam':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/client-lambda':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/client-s3':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/client-service-quotas':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/client-sts':+ specifier: 3.738.0+ version: 3.738.0+ '@aws-sdk/s3-request-presigner':+ specifier: 3.738.0+ version: 3.738.0+ '@remotion/serverless':+ specifier: workspace:*+ version: link:../serverless+ '@remotion/streaming':+ specifier: workspace:*+ version: link:../streaming+ devDependencies:+ '@remotion/eslint-config-internal':+ specifier: workspace:*+ version: link:../eslint-config-internal+ '@types/express':+ specifier: ^5.0.0+ version: 5.0.0+ eslint:+ specifier: 9.19.0+ version: 9.19.0+ express:+ specifier: 4.21.0+ version: 4.21.0+ next:+ specifier: 15.1.6+packages/lambda-go:devDependencies:remotion:@@ -13685,7 +13719,7 @@ packages:engines: {node: '>=16.0.0'}dependencies:'@smithy/types': 3.3.0- tslib: 2.6.2+ tslib: 2.8.1dev: false/@smithy/[email protected]:@@ -27110,7 +27144,7 @@ packages:resolution: {integrity: sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==}engines: {node: '>=0.6'}dependencies:- side-channel: 1.0.6+ side-channel: 1.1.0resolution: {integrity: sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==}@@ -28707,15 +28741,6 @@ packages:object-inspect: 1.13.3side-channel-map: 1.0.1- resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==}- engines: {node: '>= 0.4'}- dependencies:- call-bind: 1.0.8- es-errors: 1.3.0- get-intrinsic: 1.2.7- object-inspect: 1.13.3-resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}engines: {node: '>= 0.4'}