@remotion/lambda 4.0.159 → 4.0.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import type { LogLevel } from '@remotion/renderer';
2
2
  import type { AwsRegion } from '../pricing/aws-regions';
3
- export declare const createFunction: ({ createCloudWatchLogGroup, region, zipFile, functionName, accountId, memorySizeInMb, timeoutInSeconds, alreadyCreated, retentionInDays, ephemerealStorageInMb, customRoleArn, enableLambdaInsights, enableV5Runtime, logLevel, }: {
3
+ export declare const createFunction: ({ createCloudWatchLogGroup, region, zipFile, functionName, accountId, memorySizeInMb, timeoutInSeconds, alreadyCreated, retentionInDays, ephemerealStorageInMb, customRoleArn, enableLambdaInsights, enableV5Runtime, logLevel, vpcSubnetIds, vpcSecurityGroupIds, }: {
4
4
  createCloudWatchLogGroup: boolean;
5
5
  region: AwsRegion;
6
6
  zipFile: string;
@@ -15,6 +15,8 @@ export declare const createFunction: ({ createCloudWatchLogGroup, region, zipFil
15
15
  enableLambdaInsights: boolean;
16
16
  enableV5Runtime: boolean;
17
17
  logLevel: LogLevel;
18
+ vpcSubnetIds: string;
19
+ vpcSecurityGroupIds: string;
18
20
  }) => Promise<{
19
21
  FunctionName: string;
20
22
  }>;
@@ -11,7 +11,7 @@ const aws_clients_1 = require("../shared/aws-clients");
11
11
  const hosted_layers_1 = require("../shared/hosted-layers");
12
12
  const lambda_insights_extensions_1 = require("../shared/lambda-insights-extensions");
13
13
  const suggested_policy_1 = require("./iam-validation/suggested-policy");
14
- const createFunction = async ({ createCloudWatchLogGroup, region, zipFile, functionName, accountId, memorySizeInMb, timeoutInSeconds, alreadyCreated, retentionInDays, ephemerealStorageInMb, customRoleArn, enableLambdaInsights, enableV5Runtime, logLevel, }) => {
14
+ const createFunction = async ({ createCloudWatchLogGroup, region, zipFile, functionName, accountId, memorySizeInMb, timeoutInSeconds, alreadyCreated, retentionInDays, ephemerealStorageInMb, customRoleArn, enableLambdaInsights, enableV5Runtime, logLevel, vpcSubnetIds, vpcSecurityGroupIds, }) => {
15
15
  var _a;
16
16
  if (createCloudWatchLogGroup) {
17
17
  renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, 'Creating CloudWatch group');
@@ -48,6 +48,13 @@ const createFunction = async ({ createCloudWatchLogGroup, region, zipFile, funct
48
48
  if (enableV5Runtime) {
49
49
  renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, 'New V5 runtime enabled https://remotion.dev/docs/lambda/runtime#runtime-changes-in-remotion-50');
50
50
  }
51
+ let vpcConfig;
52
+ if (vpcSubnetIds && vpcSecurityGroupIds) {
53
+ vpcConfig = {
54
+ SubnetIds: vpcSubnetIds.split(','),
55
+ SecurityGroupIds: vpcSecurityGroupIds.split(','),
56
+ };
57
+ }
51
58
  renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, 'Deploying new Lambda function');
52
59
  const { FunctionName, FunctionArn } = await (0, aws_clients_1.getLambdaClient)(region).send(new client_lambda_1.CreateFunctionCommand({
53
60
  Code: {
@@ -67,6 +74,7 @@ const createFunction = async ({ createCloudWatchLogGroup, region, zipFile, funct
67
74
  EphemeralStorage: {
68
75
  Size: ephemerealStorageInMb,
69
76
  },
77
+ VpcConfig: vpcConfig,
70
78
  }));
71
79
  renderer_1.RenderInternals.Log.verbose({ indent: false, logLevel }, 'Function deployed. Adding tags...');
72
80
  try {
@@ -14,6 +14,8 @@ type OptionalParameters = {
14
14
  indent: boolean;
15
15
  logLevel: LogLevel;
16
16
  enableV5Runtime: boolean;
17
+ vpcSubnetIds: string | undefined;
18
+ vpcSecurityGroupIds: string | undefined;
17
19
  };
18
20
  export type DeployFunctionInput = MandatoryParameters & Partial<OptionalParameters>;
19
21
  export type DeployFunctionOutput = {
@@ -34,5 +36,5 @@ export declare const errorHandled: (params: MandatoryParameters & OptionalParame
34
36
  * @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
35
37
  * @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
36
38
  */
37
- export declare const deployFunction: ({ createCloudWatchLogGroup, memorySizeInMb, region, timeoutInSeconds, cloudWatchLogRetentionPeriodInDays, customRoleArn, enableLambdaInsights, indent, logLevel, enableV5Runtime, ...options }: DeployFunctionInput) => Promise<DeployFunctionOutput>;
39
+ export declare const deployFunction: ({ createCloudWatchLogGroup, memorySizeInMb, region, timeoutInSeconds, cloudWatchLogRetentionPeriodInDays, customRoleArn, enableLambdaInsights, indent, logLevel, enableV5Runtime, vpcSubnetIds, vpcSecurityGroupIds, ...options }: DeployFunctionInput) => Promise<DeployFunctionOutput>;
38
40
  export {};
@@ -54,6 +54,8 @@ const internalDeployFunction = async (params) => {
54
54
  enableLambdaInsights: (_b = params.enableLambdaInsights) !== null && _b !== void 0 ? _b : false,
55
55
  enableV5Runtime: params.enableV5Runtime,
56
56
  logLevel: params.logLevel,
57
+ vpcSubnetIds: params.vpcSubnetIds,
58
+ vpcSecurityGroupIds: params.vpcSecurityGroupIds,
57
59
  });
58
60
  if (!created.FunctionName) {
59
61
  throw new Error('Lambda was created but has no name');
@@ -77,7 +79,7 @@ exports.errorHandled = pure_1.NoReactAPIs.wrapWithErrorHandling(exports.internal
77
79
  * @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
78
80
  * @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
79
81
  */
80
- const deployFunction = ({ createCloudWatchLogGroup, memorySizeInMb, region, timeoutInSeconds, cloudWatchLogRetentionPeriodInDays, customRoleArn, enableLambdaInsights, indent, logLevel, enableV5Runtime, ...options }) => {
82
+ const deployFunction = ({ createCloudWatchLogGroup, memorySizeInMb, region, timeoutInSeconds, cloudWatchLogRetentionPeriodInDays, customRoleArn, enableLambdaInsights, indent, logLevel, enableV5Runtime, vpcSubnetIds, vpcSecurityGroupIds, ...options }) => {
81
83
  var _a;
82
84
  const diskSizeInMb = (_a = options.diskSizeInMb) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB;
83
85
  return (0, exports.errorHandled)({
@@ -92,6 +94,8 @@ const deployFunction = ({ createCloudWatchLogGroup, memorySizeInMb, region, time
92
94
  timeoutInSeconds,
93
95
  cloudWatchLogRetentionPeriodInDays,
94
96
  enableV5Runtime: enableV5Runtime !== null && enableV5Runtime !== void 0 ? enableV5Runtime : no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES,
97
+ vpcSubnetIds,
98
+ vpcSecurityGroupIds,
95
99
  });
96
100
  };
97
101
  exports.deployFunction = deployFunction;
@@ -59,11 +59,11 @@ export declare const internalDeploySite: (args_0: MandatoryParameters & {
59
59
  getValue: ({ commandLine }: {
60
60
  commandLine: Record<string, unknown>;
61
61
  }) => {
62
- value: "error" | "verbose" | "info" | "warn";
62
+ value: "error" | "info" | "verbose" | "warn";
63
63
  source: string;
64
64
  };
65
- setConfig: (newLogLevel: "error" | "verbose" | "info" | "warn") => void;
66
- type: "error" | "verbose" | "info" | "warn";
65
+ setConfig: (newLogLevel: "error" | "info" | "verbose" | "warn") => void;
66
+ type: "error" | "info" | "verbose" | "warn";
67
67
  };
68
68
  readonly throwIfSiteExists: {
69
69
  cliFlag: string;
@@ -34,6 +34,8 @@ type LambdaCommandLineOptions = {
34
34
  ['force-bucket-name']: string | undefined;
35
35
  [BrowserSafeApis.options.deleteAfterOption.cliFlag]: DeleteAfter | undefined;
36
36
  [BrowserSafeApis.options.folderExpiryOption.cliFlag]: boolean | undefined;
37
+ ['vpc-subnet-ids']: string | undefined;
38
+ ['vpc-security-group-ids']: string | undefined;
37
39
  };
38
40
  export declare const parsedLambdaCli: LambdaCommandLineOptions & import("minimist").ParsedArgs;
39
41
  export declare const forceFlagProvided: boolean;
@@ -9,11 +9,13 @@ const validate_custom_role_arn_1 = require("../../../shared/validate-custom-role
9
9
  const validate_disk_size_in_mb_1 = require("../../../shared/validate-disk-size-in-mb");
10
10
  const validate_memory_size_1 = require("../../../shared/validate-memory-size");
11
11
  const validate_timeout_1 = require("../../../shared/validate-timeout");
12
+ const validate_vpc_security_group_ids_1 = require("../../../shared/validate-vpc-security-group-ids");
13
+ const validate_vpc_subnet_ids_1 = require("../../../shared/validate-vpc-subnet-ids");
12
14
  const args_1 = require("../../args");
13
15
  const get_aws_region_1 = require("../../get-aws-region");
14
16
  exports.FUNCTIONS_DEPLOY_SUBCOMMAND = 'deploy';
15
17
  const functionsDeploySubcommand = async (logLevel) => {
16
- var _a, _b, _c, _d, _e, _f, _g;
18
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
17
19
  const region = (0, get_aws_region_1.getAwsRegion)();
18
20
  const timeoutInSeconds = (_a = args_1.parsedLambdaCli.timeout) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_TIMEOUT;
19
21
  const memorySizeInMb = (_b = args_1.parsedLambdaCli.memory) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_MEMORY_SIZE;
@@ -23,10 +25,14 @@ const functionsDeploySubcommand = async (logLevel) => {
23
25
  const enableLambdaInsights = (_e = args_1.parsedLambdaCli['enable-lambda-insights']) !== null && _e !== void 0 ? _e : false;
24
26
  const cloudWatchLogRetentionPeriodInDays = (_f = args_1.parsedLambdaCli['retention-period']) !== null && _f !== void 0 ? _f : constants_1.DEFAULT_CLOUDWATCH_RETENTION_PERIOD;
25
27
  const enableV5Runtime = (_g = args_1.parsedLambdaCli['enable-v5-runtime']) !== null && _g !== void 0 ? _g : undefined;
28
+ const vpcSubnetIds = (_h = args_1.parsedLambdaCli['vpc-subnet-ids']) !== null && _h !== void 0 ? _h : undefined;
29
+ const vpcSecurityGroupIds = (_j = args_1.parsedLambdaCli['vpc-security-group-ids']) !== null && _j !== void 0 ? _j : undefined;
26
30
  (0, validate_memory_size_1.validateMemorySize)(memorySizeInMb);
27
31
  (0, validate_timeout_1.validateTimeout)(timeoutInSeconds);
28
32
  (0, validate_disk_size_in_mb_1.validateDiskSizeInMb)(diskSizeInMb);
29
33
  (0, validate_custom_role_arn_1.validateCustomRoleArn)(customRoleArn);
34
+ (0, validate_vpc_subnet_ids_1.validateVpcSubnetIds)(vpcSubnetIds);
35
+ (0, validate_vpc_security_group_ids_1.validateVpcSecurityGroupIds)(vpcSecurityGroupIds);
30
36
  if (!cli_1.CliInternals.quietFlagProvided()) {
31
37
  cli_1.CliInternals.Log.info({ indent: false, logLevel }, cli_1.CliInternals.chalk.gray(`
32
38
  Region = ${region}
@@ -37,6 +43,8 @@ Version = ${version_1.VERSION}
37
43
  CloudWatch Logging Enabled = ${createCloudWatchLogGroup}
38
44
  CloudWatch Retention Period = ${cloudWatchLogRetentionPeriodInDays} days
39
45
  Lambda Insights Enabled = ${enableLambdaInsights}
46
+ VPC Subnet IDs = ${vpcSubnetIds}
47
+ VPC Security Group IDs = ${vpcSecurityGroupIds}
40
48
  `.trim()));
41
49
  }
42
50
  const output = cli_1.CliInternals.createOverwriteableCliOutput({
@@ -59,11 +67,13 @@ Lambda Insights Enabled = ${enableLambdaInsights}
59
67
  enableV5Runtime,
60
68
  indent: false,
61
69
  logLevel,
70
+ vpcSubnetIds,
71
+ vpcSecurityGroupIds,
62
72
  });
63
73
  if (cli_1.CliInternals.quietFlagProvided()) {
64
74
  cli_1.CliInternals.Log.info({ indent: false, logLevel }, functionName);
65
75
  }
66
- if (alreadyExisted) {
76
+ else if (alreadyExisted) {
67
77
  output.update(`Already exists as ${functionName}`, true);
68
78
  }
69
79
  else {
@@ -1 +1 @@
1
- export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
1
+ export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "sa-east-1" | "eu-south-1" | "af-south-1" | "ap-east-1" | "me-south-1";
@@ -4,16 +4,16 @@ declare const streamingPayloadSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
4
4
  type: z.ZodLiteral<"render-id-determined">;
5
5
  renderId: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
7
- type: "render-id-determined";
8
7
  renderId: string;
9
- }, {
10
8
  type: "render-id-determined";
9
+ }, {
11
10
  renderId: string;
11
+ type: "render-id-determined";
12
12
  }>]>;
13
13
  export type StreamingPayloads = z.infer<typeof streamingPayloadSchema>;
14
14
  export declare const isStreamingPayload: (str: string) => false | {
15
- type: "render-id-determined";
16
15
  renderId: string;
16
+ type: "render-id-determined";
17
17
  };
18
18
  export declare const sendProgressEvent: (responseStream: ResponseStream, payload: StreamingPayloads) => void;
19
19
  export {};
@@ -1,5 +1,5 @@
1
1
  export declare const LambdaInternals: {
2
- executeCommand: (args: string[], remotionRoot: string, logLevel: "error" | "verbose" | "info" | "warn") => Promise<void>;
2
+ executeCommand: (args: string[], remotionRoot: string, logLevel: "error" | "info" | "verbose" | "warn") => Promise<void>;
3
3
  makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, encodingMaxRate, encodingBufferSize, downloadBehavior, muted, overwrite, jpegQuality, offthreadVideoCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, }: import("./api/make-lambda-payload").InnerRenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
4
4
  getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, logLevel, }: import(".").GetRenderProgressInput) => import("./defaults").LambdaStatusPayload;
5
5
  makeLambdaRenderStillPayload: ({ serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, }: import("./api/render-still-on-lambda").RenderStillOnLambdaNonNullInput) => Promise<{
@@ -14,7 +14,7 @@ export declare const LambdaInternals: {
14
14
  maxRetries: number;
15
15
  frame: number;
16
16
  privacy: import("./defaults").Privacy;
17
- logLevel: "error" | "verbose" | "info" | "warn";
17
+ logLevel: "error" | "info" | "verbose" | "warn";
18
18
  outName: import("./defaults").OutNameInput | null;
19
19
  timeoutInMilliseconds: number;
20
20
  chromiumOptions: import("@remotion/renderer").ChromiumOptions;
@@ -30,7 +30,7 @@ export declare const LambdaInternals: {
30
30
  internalDeploySite: (args_0: {
31
31
  entryPoint: string;
32
32
  bucketName: string;
33
- region: "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-south-1" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "af-south-1" | "ap-south-1" | "ap-east-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "me-south-1" | "sa-east-1";
33
+ region: "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-north-1" | "us-east-1" | "us-east-2" | "us-west-1" | "us-west-2" | "ap-south-1" | "ap-southeast-1" | "ap-southeast-2" | "ap-northeast-1" | "ap-northeast-2" | "ap-northeast-3" | "ca-central-1" | "sa-east-1" | "eu-south-1" | "af-south-1" | "ap-east-1" | "me-south-1";
34
34
  } & {
35
35
  siteName: string;
36
36
  options: {
@@ -56,11 +56,11 @@ export declare const LambdaInternals: {
56
56
  getValue: ({ commandLine }: {
57
57
  commandLine: Record<string, unknown>;
58
58
  }) => {
59
- value: "error" | "verbose" | "info" | "warn";
59
+ value: "error" | "info" | "verbose" | "warn";
60
60
  source: string;
61
61
  };
62
- setConfig: (newLogLevel: "error" | "verbose" | "info" | "warn") => void;
63
- type: "error" | "verbose" | "info" | "warn";
62
+ setConfig: (newLogLevel: "error" | "info" | "verbose" | "warn") => void;
63
+ type: "error" | "info" | "verbose" | "warn";
64
64
  };
65
65
  readonly throwIfSiteExists: {
66
66
  cliFlag: string;
@@ -61,7 +61,12 @@ const getCredentials = () => {
61
61
  };
62
62
  const getCredentialsHash = ({ customCredentials, region, service, }) => {
63
63
  const hashComponents = {};
64
- if (process.env.REMOTION_AWS_PROFILE) {
64
+ if (process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK) {
65
+ hashComponents.credentials = {
66
+ credentialsSkipped: true,
67
+ };
68
+ }
69
+ else if (process.env.REMOTION_AWS_PROFILE) {
65
70
  hashComponents.credentials = {
66
71
  awsProfile: process.env.REMOTION_AWS_PROFILE,
67
72
  };
@@ -120,8 +125,8 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
120
125
  });
121
126
  if (!_clients[key]) {
122
127
  (0, check_credentials_1.checkCredentials)();
123
- if (customCredentials) {
124
- _clients[key] = new Client({
128
+ const client = customCredentials
129
+ ? new Client({
125
130
  region: (_a = customCredentials.region) !== null && _a !== void 0 ? _a : 'us-east-1',
126
131
  credentials: customCredentials.accessKeyId && customCredentials.secretAccessKey
127
132
  ? {
@@ -130,14 +135,17 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
130
135
  }
131
136
  : undefined,
132
137
  endpoint: customCredentials.endpoint,
133
- });
134
- }
135
- else {
136
- _clients[key] = new Client({
137
- region,
138
- credentials: getCredentials(),
139
- });
138
+ })
139
+ : process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK
140
+ ? new Client({ region })
141
+ : new Client({
142
+ region,
143
+ credentials: getCredentials(),
144
+ });
145
+ if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {
146
+ return client;
140
147
  }
148
+ _clients[key] = client;
141
149
  }
142
150
  return _clients[key];
143
151
  };
@@ -18,6 +18,9 @@ const messageForVariable = (variable) => {
18
18
  .join('\n');
19
19
  };
20
20
  const checkCredentials = () => {
21
+ if (process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK) {
22
+ return;
23
+ }
21
24
  if (process.env.REMOTION_AWS_PROFILE || process.env.AWS_PROFILE) {
22
25
  return;
23
26
  }
@@ -0,0 +1 @@
1
+ export declare const validateVpcSecurityGroupIds: (vpcSecurityGroupIds: unknown) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateVpcSecurityGroupIds = void 0;
4
+ const isValidVpcSecurityGroupIdList = (vpcSecurityGroupIds) => {
5
+ const securityGroupIdRegex = /^sg-[0-9a-f]{17}$/;
6
+ vpcSecurityGroupIds.split(',').forEach((securityGroupId) => {
7
+ if (!securityGroupIdRegex.test(securityGroupId.trim())) {
8
+ return false;
9
+ }
10
+ });
11
+ return true;
12
+ };
13
+ const validateVpcSecurityGroupIds = (vpcSecurityGroupIds) => {
14
+ if (typeof vpcSecurityGroupIds !== 'undefined' &&
15
+ typeof vpcSecurityGroupIds !== 'string' &&
16
+ !isValidVpcSecurityGroupIdList(vpcSecurityGroupIds)) {
17
+ throw new TypeError(`parameter 'vpcSecurityGroupIds' must either be 'undefined' or a comma-separated list of VPC security group IDs string, but instead got: ${vpcSecurityGroupIds}`);
18
+ }
19
+ };
20
+ exports.validateVpcSecurityGroupIds = validateVpcSecurityGroupIds;
@@ -0,0 +1 @@
1
+ export declare const validateVpcSubnetIds: (vpcSubnetIds: unknown) => void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateVpcSubnetIds = void 0;
4
+ const isValidVpcSubnetIdList = (vpcSubnetIds) => {
5
+ const subnetIdRegex = /^subnet-[0-9a-f]{17}$/;
6
+ vpcSubnetIds.split(',').forEach((subnetId) => {
7
+ if (!subnetIdRegex.test(subnetId.trim())) {
8
+ return false;
9
+ }
10
+ });
11
+ return true;
12
+ };
13
+ const validateVpcSubnetIds = (vpcSubnetIds) => {
14
+ if (typeof vpcSubnetIds !== 'undefined' &&
15
+ typeof vpcSubnetIds !== 'string' &&
16
+ !isValidVpcSubnetIdList(vpcSubnetIds)) {
17
+ throw new TypeError(`parameter 'vpcSubnetIds' must either be 'undefined' or a comma-separated list of VPC subnet IDs string, but instead got: ${vpcSubnetIds}`);
18
+ }
19
+ };
20
+ exports.validateVpcSubnetIds = validateVpcSubnetIds;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.159",
3
+ "version": "4.0.161",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -25,10 +25,10 @@
25
25
  "@aws-sdk/s3-request-presigner": "3.382.0",
26
26
  "mime-types": "2.1.34",
27
27
  "zod": "3.22.3",
28
- "@remotion/bundler": "4.0.159",
29
- "@remotion/renderer": "4.0.159",
30
- "@remotion/cli": "4.0.159",
31
- "remotion": "4.0.159"
28
+ "@remotion/bundler": "4.0.161",
29
+ "@remotion/cli": "4.0.161",
30
+ "@remotion/renderer": "4.0.161",
31
+ "remotion": "4.0.161"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jonny/eslint-config": "3.0.281",
@@ -44,11 +44,11 @@
44
44
  "ts-node": "10.9.2",
45
45
  "vitest": "0.31.1",
46
46
  "zip-lib": "^0.7.2",
47
- "@remotion/bundler": "4.0.159",
48
- "@remotion/compositor-linux-arm64-gnu": "4.0.159"
47
+ "@remotion/bundler": "4.0.161",
48
+ "@remotion/compositor-linux-arm64-gnu": "4.0.161"
49
49
  },
50
50
  "peerDependencies": {
51
- "@remotion/bundler": "4.0.159"
51
+ "@remotion/bundler": "4.0.161"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
Binary file
@@ -1,75 +0,0 @@
1
- /// <reference types="node" />
2
- declare const framesRendered: "frames-rendered";
3
- declare const errorOccurred: "error-occurred";
4
- declare const renderIdDetermined: "render-id-determined";
5
- declare const videoChunkRendered: "video-chunk-rendered";
6
- declare const audioChunkRendered: "audio-chunk-rendered";
7
- declare const responseJson: "response-json";
8
- declare const messageTypes: {
9
- readonly '1': {
10
- readonly type: "frames-rendered";
11
- };
12
- readonly '2': {
13
- readonly type: "error-occurred";
14
- };
15
- readonly '3': {
16
- readonly type: "render-id-determined";
17
- };
18
- readonly '4': {
19
- readonly type: "video-chunk-rendered";
20
- };
21
- readonly '5': {
22
- readonly type: "audio-chunk-rendered";
23
- };
24
- readonly '6': {
25
- readonly type: "response-json";
26
- };
27
- };
28
- type MessageTypeId = keyof typeof messageTypes;
29
- type MessageType = (typeof messageTypes)[MessageTypeId]['type'];
30
- export declare const formatMap: {
31
- [key in MessageType]: 'json' | 'binary';
32
- };
33
- export type StreamingPayload = {
34
- type: typeof framesRendered;
35
- payload: {
36
- frames: number;
37
- };
38
- } | {
39
- type: typeof videoChunkRendered;
40
- payload: Buffer;
41
- } | {
42
- type: typeof audioChunkRendered;
43
- payload: Buffer;
44
- } | {
45
- type: typeof errorOccurred;
46
- payload: {
47
- error: string;
48
- };
49
- } | {
50
- type: typeof renderIdDetermined;
51
- payload: {
52
- renderId: string;
53
- };
54
- } | {
55
- type: typeof responseJson;
56
- payload: Record<string, unknown>;
57
- };
58
- export declare const messageTypeIdToMessage: (messageTypeId: MessageTypeId) => MessageType;
59
- export declare const messageTypeToMessageId: (messageType: MessageType) => MessageTypeId;
60
- type StreamingMessage = {
61
- successType: 'error' | 'success';
62
- message: StreamingPayload;
63
- };
64
- export type OnMessage = (options: StreamingMessage) => void;
65
- export declare const makeStreaming: (options: {
66
- onMessage: OnMessage;
67
- }) => {
68
- addData: (data: Buffer) => void;
69
- };
70
- export declare const makePayloadMessage: ({ message, status, }: {
71
- message: StreamingPayload;
72
- status: 0 | 1;
73
- }) => Buffer;
74
- export type OnStream = (payload: StreamingPayload) => Promise<void>;
75
- export {};
@@ -1,160 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makePayloadMessage = exports.makeStreaming = exports.messageTypeToMessageId = exports.messageTypeIdToMessage = exports.formatMap = void 0;
4
- const framesRendered = 'frames-rendered';
5
- const errorOccurred = 'error-occurred';
6
- const renderIdDetermined = 'render-id-determined';
7
- const videoChunkRendered = 'video-chunk-rendered';
8
- const audioChunkRendered = 'audio-chunk-rendered';
9
- const responseJson = 'response-json';
10
- const messageTypes = {
11
- '1': { type: framesRendered },
12
- '2': { type: errorOccurred },
13
- '3': { type: renderIdDetermined },
14
- '4': { type: videoChunkRendered },
15
- '5': { type: audioChunkRendered },
16
- '6': { type: responseJson },
17
- };
18
- exports.formatMap = {
19
- [framesRendered]: 'json',
20
- [errorOccurred]: 'json',
21
- [renderIdDetermined]: 'json',
22
- [responseJson]: 'json',
23
- [videoChunkRendered]: 'binary',
24
- [audioChunkRendered]: 'binary',
25
- };
26
- const messageTypeIdToMessage = (messageTypeId) => {
27
- const types = messageTypes[messageTypeId];
28
- if (!types) {
29
- throw new Error(`Unknown message type id ${messageTypeId}`);
30
- }
31
- return types.type;
32
- };
33
- exports.messageTypeIdToMessage = messageTypeIdToMessage;
34
- const messageTypeToMessageId = (messageType) => {
35
- const id = Object.keys(messageTypes).find((key) => messageTypes[key].type === messageType);
36
- if (!id) {
37
- throw new Error(`Unknown message type ${messageType}`);
38
- }
39
- return id;
40
- };
41
- exports.messageTypeToMessageId = messageTypeToMessageId;
42
- const magicSeparator = Buffer.from('remotion_buffer:');
43
- const parseJsonOrThrowSource = (data, type) => {
44
- const asString = data.toString('utf-8');
45
- try {
46
- return JSON.parse(asString);
47
- }
48
- catch (err) {
49
- throw new Error(`Invalid JSON (${type}): ${asString}`);
50
- }
51
- };
52
- const makeStreaming = (options) => {
53
- let outputBuffer = Buffer.from('');
54
- let unprocessedBuffers = [];
55
- let missingData = null;
56
- const processInput = () => {
57
- let separatorIndex = outputBuffer.indexOf(magicSeparator);
58
- if (separatorIndex === -1) {
59
- return;
60
- }
61
- separatorIndex += magicSeparator.length;
62
- let messageTypeString = '';
63
- let lengthString = '';
64
- let statusString = '';
65
- // Each message has the structure with `remotion_buffer:{[message_type_id]}:{[length]}`
66
- // Let's read the buffer to extract the nonce, and if the full length is available,
67
- // we'll extract the data and pass it to the callback.
68
- // eslint-disable-next-line no-constant-condition
69
- while (true) {
70
- const nextDigit = outputBuffer[separatorIndex];
71
- // 0x3a is the character ":"
72
- if (nextDigit === 0x3a) {
73
- separatorIndex++;
74
- break;
75
- }
76
- separatorIndex++;
77
- messageTypeString += String.fromCharCode(nextDigit);
78
- }
79
- // eslint-disable-next-line no-constant-condition
80
- while (true) {
81
- const nextDigit = outputBuffer[separatorIndex];
82
- if (nextDigit === 0x3a) {
83
- separatorIndex++;
84
- break;
85
- }
86
- separatorIndex++;
87
- lengthString += String.fromCharCode(nextDigit);
88
- }
89
- // eslint-disable-next-line no-constant-condition
90
- while (true) {
91
- const nextDigit = outputBuffer[separatorIndex];
92
- if (nextDigit === 0x3a) {
93
- break;
94
- }
95
- separatorIndex++;
96
- statusString += String.fromCharCode(nextDigit);
97
- }
98
- const length = Number(lengthString);
99
- const status = Number(statusString);
100
- const dataLength = outputBuffer.length - separatorIndex - 1;
101
- if (dataLength < length) {
102
- missingData = {
103
- dataMissing: length - dataLength,
104
- };
105
- return;
106
- }
107
- const data = outputBuffer.subarray(separatorIndex + 1, separatorIndex + 1 + Number(lengthString));
108
- const messageType = (0, exports.messageTypeIdToMessage)(messageTypeString);
109
- const innerPayload = exports.formatMap[messageType] === 'json'
110
- ? parseJsonOrThrowSource(data, messageType)
111
- : data;
112
- const payload = {
113
- type: messageType,
114
- payload: innerPayload,
115
- };
116
- options.onMessage({
117
- successType: status === 1 ? 'error' : 'success',
118
- message: payload,
119
- });
120
- missingData = null;
121
- outputBuffer = outputBuffer.subarray(separatorIndex + Number(lengthString) + 1);
122
- processInput();
123
- };
124
- return {
125
- addData: (data) => {
126
- unprocessedBuffers.push(data);
127
- const separatorIndex = data.indexOf(magicSeparator);
128
- if (separatorIndex === -1) {
129
- if (missingData) {
130
- missingData.dataMissing -= data.length;
131
- }
132
- if (!missingData || missingData.dataMissing > 0) {
133
- return;
134
- }
135
- }
136
- unprocessedBuffers.unshift(outputBuffer);
137
- outputBuffer = Buffer.concat(unprocessedBuffers);
138
- unprocessedBuffers = [];
139
- processInput();
140
- },
141
- };
142
- };
143
- exports.makeStreaming = makeStreaming;
144
- const makePayloadMessage = ({ message, status, }) => {
145
- const body = exports.formatMap[message.type] === 'json'
146
- ? Buffer.from(JSON.stringify(message.payload))
147
- : message.payload;
148
- const concat = Buffer.concat([
149
- magicSeparator,
150
- Buffer.from((0, exports.messageTypeToMessageId)(message.type).toString()),
151
- Buffer.from(':'),
152
- Buffer.from(body.length.toString()),
153
- Buffer.from(':'),
154
- Buffer.from(String(status)),
155
- Buffer.from(':'),
156
- body,
157
- ]);
158
- return concat;
159
- };
160
- exports.makePayloadMessage = makePayloadMessage;