@remotion/lambda 4.0.0-alpha8 → 4.0.0-alpha9

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.
Files changed (42) hide show
  1. package/dist/api/delete-function.d.ts +2 -2
  2. package/dist/api/delete-function.js +2 -2
  3. package/dist/api/delete-site.d.ts +4 -4
  4. package/dist/api/delete-site.js +4 -4
  5. package/dist/api/deploy-function.d.ts +8 -7
  6. package/dist/api/deploy-function.js +26 -25
  7. package/dist/api/deploy-site.d.ts +2 -1
  8. package/dist/api/deploy-site.js +5 -2
  9. package/dist/api/download-media.d.ts +1 -1
  10. package/dist/api/download-media.js +1 -1
  11. package/dist/api/get-compositions-on-lambda.d.ts +1 -1
  12. package/dist/api/get-functions.d.ts +3 -3
  13. package/dist/api/get-functions.js +7 -7
  14. package/dist/api/get-or-create-bucket.d.ts +2 -2
  15. package/dist/api/get-or-create-bucket.js +6 -6
  16. package/dist/api/make-lambda-payload.js +1 -1
  17. package/dist/api/render-media-on-lambda.d.ts +1 -1
  18. package/dist/api/render-still-on-lambda.d.ts +1 -1
  19. package/dist/api/speculate-function-name.d.ts +3 -3
  20. package/dist/api/speculate-function-name.js +3 -3
  21. package/dist/cli/commands/render/render.js +1 -1
  22. package/dist/cli/commands/sites/create.js +1 -0
  23. package/dist/cli/commands/still.js +1 -1
  24. package/dist/functions/helpers/io.d.ts +7 -1
  25. package/dist/functions/helpers/io.js +22 -2
  26. package/dist/functions/helpers/streamify-response.d.ts +16 -0
  27. package/dist/functions/helpers/streamify-response.js +67 -0
  28. package/dist/functions/helpers/validate-composition.d.ts +1 -1
  29. package/dist/functions/helpers/validate-composition.js +1 -1
  30. package/dist/functions/index.d.ts +1 -18
  31. package/dist/functions/index.js +31 -10
  32. package/dist/functions/launch.js +1 -1
  33. package/dist/functions/still.js +1 -1
  34. package/dist/shared/call-lambda.js +27 -13
  35. package/dist/shared/deserialize-input-props.d.ts +1 -1
  36. package/dist/shared/return-values.d.ts +5 -0
  37. package/dist/shared/serialize-input-props.d.ts +1 -1
  38. package/dist/shared/validate-privacy.d.ts +1 -1
  39. package/dist/shared/validate-privacy.js +4 -1
  40. package/package.json +21 -20
  41. package/remotionlambda-arm64.zip +0 -0
  42. package/remotionlambda-x64.zip +0 -0
@@ -6,8 +6,8 @@ export declare type DeleteFunctionInput = {
6
6
  /**
7
7
  * @description Deletes a function from AWS Lambda.
8
8
  * @see [Documentation](https://remotion.dev/docs/lambda/deletefunction)
9
- * @param options.region The region the function was deployed to.
10
- * @param options.functionName The name of the function.
9
+ * @param params.region The region the function was deployed to.
10
+ * @param params.functionName The name of the function.
11
11
  * @returns {Promise<void>} Nothing. Throws if the function failed to delete.
12
12
  */
13
13
  export declare const deleteFunction: ({ region, functionName, }: DeleteFunctionInput) => Promise<void>;
@@ -6,8 +6,8 @@ const aws_clients_1 = require("../shared/aws-clients");
6
6
  /**
7
7
  * @description Deletes a function from AWS Lambda.
8
8
  * @see [Documentation](https://remotion.dev/docs/lambda/deletefunction)
9
- * @param options.region The region the function was deployed to.
10
- * @param options.functionName The name of the function.
9
+ * @param params.region The region the function was deployed to.
10
+ * @param params.functionName The name of the function.
11
11
  * @returns {Promise<void>} Nothing. Throws if the function failed to delete.
12
12
  */
13
13
  const deleteFunction = async ({ region, functionName, }) => {
@@ -15,10 +15,10 @@ export declare type DeleteSiteOutput = {
15
15
  *
16
16
  * @description Deletes a deployed site from your S3 bucket. The opposite of deploySite().
17
17
  * @see [Documentation](https://remotion.dev/docs/lambda/deletesite)
18
- * @param options.bucketName The S3 bucket name where the site resides in.
19
- * @param options.siteName The ID of the site that you want to delete.
20
- * @param {AwsRegion} options.region The region in where the S3 bucket resides in.
21
- * @param options.onAfterItemDeleted Function that gets called after each file that gets deleted, useful for showing progress.
18
+ * @param params.bucketName The S3 bucket name where the site resides in.
19
+ * @param params.siteName The ID of the site that you want to delete.
20
+ * @param {AwsRegion} params.region The region in where the S3 bucket resides in.
21
+ * @param params.onAfterItemDeleted Function that gets called after each file that gets deleted, useful for showing progress.
22
22
  * @returns {Promise<DeleteSiteOutput>} Object containing info about how much space was freed.
23
23
  */
24
24
  export declare const deleteSite: ({ bucketName, siteName, region, onAfterItemDeleted, }: DeleteSiteInput) => Promise<DeleteSiteOutput>;
@@ -9,10 +9,10 @@ const clean_items_1 = require("./clean-items");
9
9
  *
10
10
  * @description Deletes a deployed site from your S3 bucket. The opposite of deploySite().
11
11
  * @see [Documentation](https://remotion.dev/docs/lambda/deletesite)
12
- * @param options.bucketName The S3 bucket name where the site resides in.
13
- * @param options.siteName The ID of the site that you want to delete.
14
- * @param {AwsRegion} options.region The region in where the S3 bucket resides in.
15
- * @param options.onAfterItemDeleted Function that gets called after each file that gets deleted, useful for showing progress.
12
+ * @param params.bucketName The S3 bucket name where the site resides in.
13
+ * @param params.siteName The ID of the site that you want to delete.
14
+ * @param {AwsRegion} params.region The region in where the S3 bucket resides in.
15
+ * @param params.onAfterItemDeleted Function that gets called after each file that gets deleted, useful for showing progress.
16
16
  * @returns {Promise<DeleteSiteOutput>} Object containing info about how much space was freed.
17
17
  */
18
18
  const deleteSite = async ({ bucketName, siteName, region, onAfterItemDeleted, }) => {
@@ -15,12 +15,13 @@ export declare type DeployFunctionOutput = {
15
15
  /**
16
16
  * @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
17
17
  * @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
18
- * @param options.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
19
- * @param options.cloudWatchLogRetentionPeriodInDays (optional) The number of days to retain the CloudWatch logs for this function. Default is 14 days.
20
- * @param options.region The region you want to deploy your function to.
21
- * @param options.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
22
- * @param options.memorySizeInMb How much memory should be allocated to the Lambda function.
23
- * @param options.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
18
+ * @param params.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
19
+ * @param params.cloudWatchLogRetentionPeriodInDays (optional) The number of days to retain the CloudWatch logs for this function. Default is 14 days.
20
+ * @param params.region The region you want to deploy your function to.
21
+ * @param params.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
22
+ * @param params.memorySizeInMb How much memory should be allocated to the Lambda function.
23
+ * @param params.architecture The architecture Lambda should run on. One of x86_64 and x64
24
+ * @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
24
25
  * @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
25
26
  */
26
- export declare const deployFunction: (options: DeployFunctionInput) => Promise<DeployFunctionOutput>;
27
+ export declare const deployFunction: (params: DeployFunctionInput) => Promise<DeployFunctionOutput>;
@@ -17,50 +17,51 @@ const create_function_1 = require("./create-function");
17
17
  /**
18
18
  * @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
19
19
  * @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
20
- * @param options.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
21
- * @param options.cloudWatchLogRetentionPeriodInDays (optional) The number of days to retain the CloudWatch logs for this function. Default is 14 days.
22
- * @param options.region The region you want to deploy your function to.
23
- * @param options.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
24
- * @param options.memorySizeInMb How much memory should be allocated to the Lambda function.
25
- * @param options.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
20
+ * @param params.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
21
+ * @param params.cloudWatchLogRetentionPeriodInDays (optional) The number of days to retain the CloudWatch logs for this function. Default is 14 days.
22
+ * @param params.region The region you want to deploy your function to.
23
+ * @param params.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
24
+ * @param params.memorySizeInMb How much memory should be allocated to the Lambda function.
25
+ * @param params.architecture The architecture Lambda should run on. One of x86_64 and x64
26
+ * @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
26
27
  * @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
27
28
  */
28
- const deployFunction = async (options) => {
29
+ const deployFunction = async (params) => {
29
30
  var _a, _b;
30
- const diskSizeInMb = (_a = options.diskSizeInMb) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB;
31
- (0, validate_memory_size_1.validateMemorySize)(options.memorySizeInMb);
32
- (0, validate_timeout_1.validateTimeout)(options.timeoutInSeconds);
33
- (0, validate_aws_region_1.validateAwsRegion)(options.region);
34
- (0, validate_retention_period_1.validateCloudWatchRetentionPeriod)(options.cloudWatchLogRetentionPeriodInDays);
31
+ const diskSizeInMb = (_a = params.diskSizeInMb) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB;
32
+ (0, validate_memory_size_1.validateMemorySize)(params.memorySizeInMb);
33
+ (0, validate_timeout_1.validateTimeout)(params.timeoutInSeconds);
34
+ (0, validate_aws_region_1.validateAwsRegion)(params.region);
35
+ (0, validate_retention_period_1.validateCloudWatchRetentionPeriod)(params.cloudWatchLogRetentionPeriodInDays);
35
36
  (0, validate_disk_size_in_mb_1.validateDiskSizeInMb)(diskSizeInMb);
36
- (0, validate_custom_role_arn_1.validateCustomRoleArn)(options.customRoleArn);
37
+ (0, validate_custom_role_arn_1.validateCustomRoleArn)(params.customRoleArn);
37
38
  const fnNameRender = [
38
39
  `${constants_1.RENDER_FN_PREFIX}${lambda_version_string_1.LAMBDA_VERSION_STRING}`,
39
- `mem${options.memorySizeInMb}mb`,
40
+ `mem${params.memorySizeInMb}mb`,
40
41
  `disk${diskSizeInMb}mb`,
41
- `${options.timeoutInSeconds}sec`,
42
+ `${params.timeoutInSeconds}sec`,
42
43
  ].join('-');
43
- const accountId = await (0, get_account_id_1.getAccountId)({ region: options.region });
44
+ const accountId = await (0, get_account_id_1.getAccountId)({ region: params.region });
44
45
  const fns = await (0, get_functions_1.getFunctions)({
45
46
  compatibleOnly: true,
46
- region: options.region,
47
+ region: params.region,
47
48
  });
48
49
  const alreadyDeployed = fns.find((f) => f.version === version_1.VERSION &&
49
- f.memorySizeInMb === options.memorySizeInMb &&
50
- f.timeoutInSeconds === options.timeoutInSeconds &&
50
+ f.memorySizeInMb === params.memorySizeInMb &&
51
+ f.timeoutInSeconds === params.timeoutInSeconds &&
51
52
  f.diskSizeInMb === diskSizeInMb);
52
53
  const created = await (0, create_function_1.createFunction)({
53
- createCloudWatchLogGroup: options.createCloudWatchLogGroup,
54
- region: options.region,
54
+ createCloudWatchLogGroup: params.createCloudWatchLogGroup,
55
+ region: params.region,
55
56
  zipFile: function_zip_path_1.FUNCTION_ZIP_ARM64,
56
57
  functionName: fnNameRender,
57
58
  accountId,
58
- memorySizeInMb: options.memorySizeInMb,
59
- timeoutInSeconds: options.timeoutInSeconds,
60
- retentionInDays: (_b = options.cloudWatchLogRetentionPeriodInDays) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
59
+ memorySizeInMb: params.memorySizeInMb,
60
+ timeoutInSeconds: params.timeoutInSeconds,
61
+ retentionInDays: (_b = params.cloudWatchLogRetentionPeriodInDays) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_CLOUDWATCH_RETENTION_PERIOD,
61
62
  alreadyCreated: Boolean(alreadyDeployed),
62
63
  ephemerealStorageInMb: diskSizeInMb,
63
- customRoleArn: options.customRoleArn,
64
+ customRoleArn: params.customRoleArn,
64
65
  });
65
66
  if (!created.FunctionName) {
66
67
  throw new Error('Lambda was created but has no name');
@@ -16,6 +16,7 @@ export declare type DeploySiteInput = {
16
16
  rootDir?: string;
17
17
  bypassBucketNameValidation?: boolean;
18
18
  };
19
+ privacy?: 'public' | 'no-acl';
19
20
  };
20
21
  export declare type DeploySiteOutput = Promise<{
21
22
  serveUrl: string;
@@ -35,4 +36,4 @@ export declare type DeploySiteOutput = Promise<{
35
36
  * @param {string} params.siteName The name of the folder in which the project gets deployed to.
36
37
  * @param {object} params.options Further options, see documentation page for this function.
37
38
  */
38
- export declare const deploySite: ({ bucketName, entryPoint, siteName, options, region, }: DeploySiteInput) => DeploySiteOutput;
39
+ export declare const deploySite: ({ bucketName, entryPoint, siteName, options, region, privacy: passedPrivacy, }: DeploySiteInput) => DeploySiteOutput;
@@ -14,6 +14,7 @@ const make_s3_url_1 = require("../shared/make-s3-url");
14
14
  const random_hash_1 = require("../shared/random-hash");
15
15
  const validate_aws_region_1 = require("../shared/validate-aws-region");
16
16
  const validate_bucketname_1 = require("../shared/validate-bucketname");
17
+ const validate_privacy_1 = require("../shared/validate-privacy");
17
18
  const validate_site_name_1 = require("../shared/validate-site-name");
18
19
  const bucket_exists_1 = require("./bucket-exists");
19
20
  const upload_dir_1 = require("./upload-dir");
@@ -26,7 +27,7 @@ const upload_dir_1 = require("./upload-dir");
26
27
  * @param {string} params.siteName The name of the folder in which the project gets deployed to.
27
28
  * @param {object} params.options Further options, see documentation page for this function.
28
29
  */
29
- const deploySite = async ({ bucketName, entryPoint, siteName, options, region, }) => {
30
+ const deploySite = async ({ bucketName, entryPoint, siteName, options, region, privacy: passedPrivacy, }) => {
30
31
  var _a, _b, _c, _d;
31
32
  (0, validate_aws_region_1.validateAwsRegion)(region);
32
33
  (0, validate_bucketname_1.validateBucketName)(bucketName, {
@@ -34,6 +35,8 @@ const deploySite = async ({ bucketName, entryPoint, siteName, options, region, }
34
35
  });
35
36
  const siteId = siteName !== null && siteName !== void 0 ? siteName : (0, random_hash_1.randomHash)();
36
37
  (0, validate_site_name_1.validateSiteName)(siteId);
38
+ const privacy = passedPrivacy !== null && passedPrivacy !== void 0 ? passedPrivacy : 'public';
39
+ (0, validate_privacy_1.validatePrivacy)(privacy, false);
37
40
  const accountId = await (0, get_account_id_1.getAccountId)({ region });
38
41
  const bucketExists = await (0, bucket_exists_1.bucketExistsInRegion)({
39
42
  bucketName,
@@ -74,7 +77,7 @@ const deploySite = async ({ bucketName, entryPoint, siteName, options, region, }
74
77
  localDir: bundled,
75
78
  onProgress: (_d = options === null || options === void 0 ? void 0 : options.onUploadProgress) !== null && _d !== void 0 ? _d : (() => undefined),
76
79
  keyPrefix: subFolder,
77
- privacy: 'public',
80
+ privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
78
81
  toUpload,
79
82
  }),
80
83
  Promise.all(toDelete.map((d) => {
@@ -14,7 +14,7 @@ export declare type DownloadMediaOutput = {
14
14
  sizeInBytes: number;
15
15
  };
16
16
  /**
17
- * @description Triggers a render on a lambda given a composition and a lambda function.
17
+ * @description Downloads a rendered video, audio or still to the disk of the machine this API is called from.
18
18
  * @see [Documentation](https://remotion.dev/docs/lambda/downloadmedia)
19
19
  * @param params.region The AWS region in which the media resides.
20
20
  * @param params.bucketName The `bucketName` that was specified during the render.
@@ -11,7 +11,7 @@ const get_render_metadata_1 = require("../functions/helpers/get-render-metadata"
11
11
  const read_with_progress_1 = require("../functions/helpers/read-with-progress");
12
12
  const get_account_id_1 = require("../shared/get-account-id");
13
13
  /**
14
- * @description Triggers a render on a lambda given a composition and a lambda function.
14
+ * @description Downloads a rendered video, audio or still to the disk of the machine this API is called from.
15
15
  * @see [Documentation](https://remotion.dev/docs/lambda/downloadmedia)
16
16
  * @param params.region The AWS region in which the media resides.
17
17
  * @param params.bucketName The `bucketName` that was specified during the render.
@@ -4,7 +4,7 @@ import type { AwsRegion } from '../client';
4
4
  export declare type GetCompositionsOnLambdaInput = {
5
5
  chromiumOptions?: ChromiumOptions;
6
6
  region: AwsRegion;
7
- inputProps: unknown;
7
+ inputProps: Record<string, unknown>;
8
8
  functionName: string;
9
9
  serveUrl: string;
10
10
  envVariables?: Record<string, string>;
@@ -7,8 +7,8 @@ export declare type GetFunctionsInput = {
7
7
  /**
8
8
  * @description Lists Remotion Lambda render functions deployed to AWS Lambda.
9
9
  * @see [Documentation](https://remotion.dev/docs/lambda/getfunctions)
10
- * @param options.region The region of which the functions should be listed.
11
- * @param options.compatibleOnly Whether only functions compatible with the installed version of Remotion Lambda should be returned.
10
+ * @param params.region The region of which the functions should be listed.
11
+ * @param params.compatibleOnly Whether only functions compatible with the installed version of Remotion Lambda should be returned.
12
12
  * @returns {Promise<FunctionInfo[]>} An array with the objects containing information about the deployed functions.
13
13
  */
14
- export declare const getFunctions: (options: GetFunctionsInput) => Promise<FunctionInfo[]>;
14
+ export declare const getFunctions: (params: GetFunctionsInput) => Promise<FunctionInfo[]>;
@@ -29,15 +29,15 @@ const getAllFunctions = async ({ existing, nextMarker, region, }) => {
29
29
  /**
30
30
  * @description Lists Remotion Lambda render functions deployed to AWS Lambda.
31
31
  * @see [Documentation](https://remotion.dev/docs/lambda/getfunctions)
32
- * @param options.region The region of which the functions should be listed.
33
- * @param options.compatibleOnly Whether only functions compatible with the installed version of Remotion Lambda should be returned.
32
+ * @param params.region The region of which the functions should be listed.
33
+ * @param params.compatibleOnly Whether only functions compatible with the installed version of Remotion Lambda should be returned.
34
34
  * @returns {Promise<FunctionInfo[]>} An array with the objects containing information about the deployed functions.
35
35
  */
36
- const getFunctions = async (options) => {
36
+ const getFunctions = async (params) => {
37
37
  const lambdas = await getAllFunctions({
38
38
  existing: [],
39
39
  nextMarker: null,
40
- region: options.region,
40
+ region: params.region,
41
41
  });
42
42
  const remotionLambdas = lambdas.filter((f) => {
43
43
  var _a;
@@ -47,7 +47,7 @@ const getFunctions = async (options) => {
47
47
  try {
48
48
  const version = await (0, get_function_version_1.getFunctionVersion)({
49
49
  functionName: fn.FunctionName,
50
- region: options.region,
50
+ region: params.region,
51
51
  });
52
52
  return version;
53
53
  }
@@ -65,11 +65,11 @@ const getFunctions = async (options) => {
65
65
  diskSizeInMb: (_b = (_a = lambda.EphemeralStorage) === null || _a === void 0 ? void 0 : _a.Size) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB,
66
66
  };
67
67
  });
68
- if (!options.compatibleOnly) {
68
+ if (!params.compatibleOnly) {
69
69
  return list;
70
70
  }
71
71
  return list.filter((l) => {
72
- if (!options.compatibleOnly) {
72
+ if (!params.compatibleOnly) {
73
73
  return true;
74
74
  }
75
75
  return l.version === version_1.VERSION;
@@ -9,7 +9,7 @@ export declare type GetOrCreateBucketOutput = {
9
9
  /**
10
10
  * @description Creates a bucket for Remotion Lambda in your S3 account. If one already exists, it will get returned instead.
11
11
  * @see [Documentation](https://remotion.dev/docs/lambda/getorcreatebucket)
12
- * @param options.region The region in which you want your S3 bucket to reside in.
12
+ * @param params.region The region in which you want your S3 bucket to reside in.
13
13
  * @returns {Promise<GetOrCreateBucketOutput>} An object containing the `bucketName`.
14
14
  */
15
- export declare const getOrCreateBucket: (options: GetOrCreateBucketInput) => Promise<GetOrCreateBucketOutput>;
15
+ export declare const getOrCreateBucket: (params: GetOrCreateBucketInput) => Promise<GetOrCreateBucketOutput>;
@@ -8,21 +8,21 @@ const get_buckets_1 = require("./get-buckets");
8
8
  /**
9
9
  * @description Creates a bucket for Remotion Lambda in your S3 account. If one already exists, it will get returned instead.
10
10
  * @see [Documentation](https://remotion.dev/docs/lambda/getorcreatebucket)
11
- * @param options.region The region in which you want your S3 bucket to reside in.
11
+ * @param params.region The region in which you want your S3 bucket to reside in.
12
12
  * @returns {Promise<GetOrCreateBucketOutput>} An object containing the `bucketName`.
13
13
  */
14
- const getOrCreateBucket = async (options) => {
15
- const { remotionBuckets } = await (0, get_buckets_1.getRemotionS3Buckets)(options.region);
14
+ const getOrCreateBucket = async (params) => {
15
+ const { remotionBuckets } = await (0, get_buckets_1.getRemotionS3Buckets)(params.region);
16
16
  if (remotionBuckets.length > 1) {
17
- throw new Error(`You have multiple buckets (${remotionBuckets.map((b) => b.name)}) in your S3 region (${options.region}) starting with "${constants_1.REMOTION_BUCKET_PREFIX}". Please see https://remotion.dev/docs/lambda/multiple-buckets.`);
17
+ throw new Error(`You have multiple buckets (${remotionBuckets.map((b) => b.name)}) in your S3 region (${params.region}) starting with "${constants_1.REMOTION_BUCKET_PREFIX}". Please see https://remotion.dev/docs/lambda/multiple-buckets.`);
18
18
  }
19
19
  if (remotionBuckets.length === 1) {
20
20
  return { bucketName: remotionBuckets[0].name, alreadyExisted: true };
21
21
  }
22
- const bucketName = (0, validate_bucketname_1.makeBucketName)(options.region);
22
+ const bucketName = (0, validate_bucketname_1.makeBucketName)(params.region);
23
23
  await (0, create_bucket_1.createBucket)({
24
24
  bucketName,
25
- region: options.region,
25
+ region: params.region,
26
26
  });
27
27
  return { bucketName, alreadyExisted: false };
28
28
  };
@@ -19,7 +19,7 @@ const makeLambdaPayload = async ({ rendererFunctionName, frameRange, framesPerLa
19
19
  });
20
20
  (0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
21
21
  const serializedInputProps = await (0, serialize_input_props_1.serializeInputProps)({
22
- inputProps,
22
+ inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
23
23
  region,
24
24
  type: 'video-or-audio',
25
25
  userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
@@ -8,7 +8,7 @@ export declare type RenderMediaOnLambdaInput = {
8
8
  functionName: string;
9
9
  serveUrl: string;
10
10
  composition: string;
11
- inputProps?: unknown;
11
+ inputProps?: Record<string, unknown>;
12
12
  codec: LambdaCodec;
13
13
  imageFormat?: VideoImageFormat;
14
14
  crf?: number | undefined;
@@ -7,7 +7,7 @@ export declare type RenderStillOnLambdaInput = {
7
7
  functionName: string;
8
8
  serveUrl: string;
9
9
  composition: string;
10
- inputProps: unknown;
10
+ inputProps: Record<string, unknown>;
11
11
  imageFormat: StillImageFormat;
12
12
  privacy: Privacy;
13
13
  maxRetries?: number;
@@ -6,9 +6,9 @@ export declare type SpeculateFunctionNameInput = {
6
6
  /**
7
7
  * @description Speculate the name of a lambda function that will be created when you call `deployFunction`, based on the function configuration.
8
8
  * @see [Documentation](https://www.remotion.dev/docs/lambda/speculatefunctionname)
9
- * @param options.memorySizeInMb How much memory is allocated to the Lambda function.
10
- * @param options.diskSizeInMb The amount of storage the function is allocated.
11
- * @param options.timeoutInSeconds Time in seconds until the function times out.
9
+ * @param params.memorySizeInMb How much memory is allocated to the Lambda function.
10
+ * @param params.diskSizeInMb The amount of storage the function is allocated.
11
+ * @param params.timeoutInSeconds Time in seconds until the function times out.
12
12
  * @returns {string} The speculated lambda function name
13
13
  */
14
14
  export declare const speculateFunctionName: ({ memorySizeInMb, diskSizeInMb, timeoutInSeconds, }: SpeculateFunctionNameInput) => string;
@@ -6,9 +6,9 @@ const lambda_version_string_1 = require("../shared/lambda-version-string");
6
6
  /**
7
7
  * @description Speculate the name of a lambda function that will be created when you call `deployFunction`, based on the function configuration.
8
8
  * @see [Documentation](https://www.remotion.dev/docs/lambda/speculatefunctionname)
9
- * @param options.memorySizeInMb How much memory is allocated to the Lambda function.
10
- * @param options.diskSizeInMb The amount of storage the function is allocated.
11
- * @param options.timeoutInSeconds Time in seconds until the function times out.
9
+ * @param params.memorySizeInMb How much memory is allocated to the Lambda function.
10
+ * @param params.diskSizeInMb The amount of storage the function is allocated.
11
+ * @param params.timeoutInSeconds Time in seconds until the function times out.
12
12
  * @returns {string} The speculated lambda function name
13
13
  */
14
14
  const speculateFunctionName = ({ memorySizeInMb, diskSizeInMb, timeoutInSeconds, }) => {
@@ -61,7 +61,7 @@ const renderCommand = async (args, remotionRoot) => {
61
61
  const maxRetries = (_c = args_1.parsedLambdaCli['max-retries']) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_MAX_RETRIES;
62
62
  (0, validate_retries_1.validateMaxRetries)(maxRetries);
63
63
  const privacy = (_d = args_1.parsedLambdaCli.privacy) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_OUTPUT_PRIVACY;
64
- (0, validate_privacy_1.validatePrivacy)(privacy);
64
+ (0, validate_privacy_1.validatePrivacy)(privacy, true);
65
65
  const framesPerLambda = (_e = args_1.parsedLambdaCli['frames-per-lambda']) !== null && _e !== void 0 ? _e : undefined;
66
66
  (0, validate_frames_per_lambda_1.validateFramesPerLambda)({ framesPerLambda, durationInFrames: 1 });
67
67
  const res = await (0, render_media_on_lambda_1.renderMediaOnLambda)({
@@ -92,6 +92,7 @@ const sitesCreateSubcommand = async (args, remotionRoot) => {
92
92
  webpackOverride: (_c = config_1.ConfigInternals.getWebpackOverrideFn()) !== null && _c !== void 0 ? _c : ((f) => f),
93
93
  },
94
94
  region: (0, get_aws_region_1.getAwsRegion)(),
95
+ privacy: args_1.parsedLambdaCli.privacy,
95
96
  });
96
97
  const uploadDuration = Date.now() - uploadStart;
97
98
  multiProgress.deployProgress = {
@@ -46,7 +46,7 @@ const stillCommand = async (args, remotionRoot) => {
46
46
  const maxRetries = (_b = args_1.parsedLambdaCli['max-retries']) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_MAX_RETRIES;
47
47
  (0, validate_retries_1.validateMaxRetries)(maxRetries);
48
48
  const privacy = (_c = args_1.parsedLambdaCli.privacy) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_OUTPUT_PRIVACY;
49
- (0, validate_privacy_1.validatePrivacy)(privacy);
49
+ (0, validate_privacy_1.validatePrivacy)(privacy, true);
50
50
  const { format: imageFormat, source: imageFormatReason } = cli_1.CliInternals.determineFinalStillImageFormat({
51
51
  downloadName,
52
52
  outName: outName !== null && outName !== void 0 ? outName : null,
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import type { _Object } from '@aws-sdk/client-s3';
2
3
  import type { ReadStream } from 'node:fs';
3
4
  import type { Readable } from 'stream';
@@ -20,7 +21,7 @@ export declare const lambdaDeleteFile: ({ bucketName, key, region, customCredent
20
21
  key: string;
21
22
  customCredentials: CustomCredentials | null;
22
23
  }) => Promise<void>;
23
- export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }: {
24
+ declare type LambdaWriteFileInput = {
24
25
  bucketName: string;
25
26
  key: string;
26
27
  body: ReadStream | string;
@@ -29,6 +30,10 @@ export declare const lambdaWriteFile: ({ bucketName, key, body, region, privacy,
29
30
  expectedBucketOwner: string | null;
30
31
  downloadBehavior: DownloadBehavior | null;
31
32
  customCredentials: CustomCredentials | null;
33
+ };
34
+ export declare const tryLambdaWriteFile: ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }: LambdaWriteFileInput) => Promise<void>;
35
+ export declare const lambdaWriteFile: (params: LambdaWriteFileInput & {
36
+ retries?: number;
32
37
  }) => Promise<void>;
33
38
  export declare const lambdaReadFile: ({ bucketName, key, region, expectedBucketOwner, }: {
34
39
  bucketName: string;
@@ -44,3 +49,4 @@ export declare const lambdaHeadCommand: ({ bucketName, key, region, }: {
44
49
  LastModified?: Date | undefined;
45
50
  ContentLength?: number | undefined;
46
51
  }>;
52
+ export {};
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.lambdaHeadCommand = exports.lambdaReadFile = exports.lambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
6
+ exports.lambdaHeadCommand = exports.lambdaReadFile = exports.lambdaWriteFile = exports.tryLambdaWriteFile = exports.lambdaDeleteFile = exports.lambdaLs = void 0;
7
7
  const client_s3_1 = require("@aws-sdk/client-s3");
8
8
  const mime_types_1 = __importDefault(require("mime-types"));
9
9
  const aws_clients_1 = require("../../shared/aws-clients");
@@ -54,7 +54,7 @@ const lambdaDeleteFile = async ({ bucketName, key, region, customCredentials, })
54
54
  }));
55
55
  };
56
56
  exports.lambdaDeleteFile = lambdaDeleteFile;
57
- const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }) => {
57
+ const tryLambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }) => {
58
58
  await (0, aws_clients_1.getS3Client)(region, customCredentials).send(new client_s3_1.PutObjectCommand({
59
59
  Bucket: bucketName,
60
60
  Key: key,
@@ -71,6 +71,26 @@ const lambdaWriteFile = async ({ bucketName, key, body, region, privacy, expecte
71
71
  ContentDisposition: (0, content_disposition_header_1.getContentDispositionHeader)(downloadBehavior),
72
72
  }));
73
73
  };
74
+ exports.tryLambdaWriteFile = tryLambdaWriteFile;
75
+ const lambdaWriteFile = async (params) => {
76
+ var _a;
77
+ const remainingRetries = (_a = params.retries) !== null && _a !== void 0 ? _a : 2;
78
+ try {
79
+ await (0, exports.tryLambdaWriteFile)(params);
80
+ }
81
+ catch (err) {
82
+ if (remainingRetries === 0) {
83
+ throw err;
84
+ }
85
+ console.warn('Failed to write file to Lambda:');
86
+ console.warn(err);
87
+ console.warn(`Retrying (${remainingRetries} retries remaining)...`);
88
+ return (0, exports.lambdaWriteFile)({
89
+ ...params,
90
+ retries: (remainingRetries !== null && remainingRetries !== void 0 ? remainingRetries : 0) - 1,
91
+ });
92
+ }
93
+ };
74
94
  exports.lambdaWriteFile = lambdaWriteFile;
75
95
  const lambdaReadFile = async ({ bucketName, key, region, expectedBucketOwner, }) => {
76
96
  const { Body } = await (0, aws_clients_1.getS3Client)(region, null).send(new client_s3_1.GetObjectCommand({
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" />
2
+ import { Stream } from 'stream';
3
+ export declare class ResponseStream extends Stream.Writable {
4
+ private response;
5
+ _contentType?: string;
6
+ _isBase64Encoded?: boolean;
7
+ constructor();
8
+ _write(chunk: string, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
9
+ getBufferedData(): Buffer;
10
+ setContentType(contentType: string): void;
11
+ setIsBase64Encoded(isBase64Encoded: boolean): void;
12
+ }
13
+ export declare const HANDLER_STREAMING: unique symbol;
14
+ export declare const STREAM_RESPONSE = "response";
15
+ export declare function isInAWS(handler: Function): boolean;
16
+ export declare function streamifyResponse(handler: Function): Function;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.streamifyResponse = exports.isInAWS = exports.STREAM_RESPONSE = exports.HANDLER_STREAMING = exports.ResponseStream = void 0;
4
+ const stream_1 = require("stream");
5
+ class ResponseStream extends stream_1.Stream.Writable {
6
+ constructor() {
7
+ super();
8
+ this.response = [];
9
+ }
10
+ _write(chunk, encoding, callback) {
11
+ this.response.push(Buffer.from(chunk, encoding));
12
+ callback();
13
+ }
14
+ getBufferedData() {
15
+ return Buffer.concat(this.response);
16
+ }
17
+ setContentType(contentType) {
18
+ this._contentType = contentType;
19
+ }
20
+ setIsBase64Encoded(isBase64Encoded) {
21
+ this._isBase64Encoded = isBase64Encoded;
22
+ }
23
+ }
24
+ exports.ResponseStream = ResponseStream;
25
+ exports.HANDLER_STREAMING = Symbol.for('aws.lambda.runtime.handler.streaming');
26
+ exports.STREAM_RESPONSE = 'response';
27
+ function isInAWS(handler) {
28
+ return (
29
+ // @ts-expect-error
30
+ handler[exports.HANDLER_STREAMING] !== undefined &&
31
+ // @ts-expect-error
32
+ handler[exports.HANDLER_STREAMING] === exports.STREAM_RESPONSE);
33
+ }
34
+ exports.isInAWS = isInAWS;
35
+ function streamifyResponse(handler) {
36
+ // Check for global awslambda
37
+ if (isInAWS(handler)) {
38
+ // @ts-expect-error
39
+ return awslambda.streamifyResponse(handler);
40
+ }
41
+ return new Proxy(handler, {
42
+ async apply(target, _, argList) {
43
+ const responseStream = patchArgs(argList);
44
+ await target(...argList);
45
+ return {
46
+ statusCode: 200,
47
+ headers: {
48
+ 'content-type': responseStream._contentType || 'application/json',
49
+ },
50
+ ...(responseStream._isBase64Encoded
51
+ ? { isBase64Encoded: responseStream._isBase64Encoded }
52
+ : {}),
53
+ body: responseStream._isBase64Encoded
54
+ ? responseStream.getBufferedData().toString('base64')
55
+ : responseStream.getBufferedData().toString(),
56
+ };
57
+ },
58
+ });
59
+ }
60
+ exports.streamifyResponse = streamifyResponse;
61
+ function patchArgs(argList) {
62
+ if (!(argList[1] instanceof ResponseStream)) {
63
+ const responseStream = new ResponseStream();
64
+ argList.splice(1, 0, responseStream);
65
+ }
66
+ return argList[1];
67
+ }
@@ -5,7 +5,7 @@ declare type ValidateCompositionOptions = {
5
5
  serveUrl: string;
6
6
  composition: string;
7
7
  browserInstance: Await<ReturnType<typeof openBrowser>>;
8
- inputProps: unknown;
8
+ inputProps: Record<string, unknown>;
9
9
  envVariables: Record<string, string> | undefined;
10
10
  timeoutInMilliseconds: number;
11
11
  chromiumOptions: ChromiumOptions;
@@ -6,7 +6,7 @@ const get_chromium_executable_path_1 = require("./get-chromium-executable-path")
6
6
  const validateComposition = async ({ serveUrl, composition, browserInstance, inputProps, envVariables, timeoutInMilliseconds, chromiumOptions, port, downloadMap, forceHeight, forceWidth, }) => {
7
7
  const compositions = await (0, renderer_1.getCompositions)(serveUrl, {
8
8
  puppeteerInstance: browserInstance,
9
- inputProps: inputProps,
9
+ inputProps,
10
10
  envVariables,
11
11
  timeoutInMilliseconds,
12
12
  chromiumOptions,
@@ -1,18 +1 @@
1
- import type { LambdaPayload } from '../shared/constants';
2
- export declare const handler: (params: LambdaPayload, context: {
3
- invokedFunctionArn: string;
4
- getRemainingTimeInMillis: () => number;
5
- }) => Promise<void> | Promise<{
6
- compositions: import("remotion").AnyCompMetadata[];
7
- }> | Promise<{
8
- version: string;
9
- }> | Promise<{
10
- bucketName: string;
11
- renderId: string;
12
- }> | Promise<import("../shared/constants").RenderProgress> | Promise<Promise<{
13
- output: string;
14
- size: number;
15
- bucketName: string;
16
- estimatedPrice: import("../shared/constants").CostsInfo;
17
- renderId: string;
18
- }>>;
1
+ export declare const handler: Function;
@@ -7,13 +7,14 @@ const compositions_1 = require("./compositions");
7
7
  const clean_tmpdir_1 = require("./helpers/clean-tmpdir");
8
8
  const is_warm_1 = require("./helpers/is-warm");
9
9
  const print_cloudwatch_helper_1 = require("./helpers/print-cloudwatch-helper");
10
+ const streamify_response_1 = require("./helpers/streamify-response");
10
11
  const info_1 = require("./info");
11
12
  const launch_1 = require("./launch");
12
13
  const progress_1 = require("./progress");
13
14
  const renderer_2 = require("./renderer");
14
15
  const start_1 = require("./start");
15
16
  const still_1 = require("./still");
16
- const handler = (params, context) => {
17
+ exports.handler = (0, streamify_response_1.streamifyResponse)(async (params, responseStream, context) => {
17
18
  process.env.__RESERVED_IS_INSIDE_REMOTION_LAMBDA = 'true';
18
19
  const timeoutInMilliseconds = context.getRemainingTimeInMillis();
19
20
  if (!context || !context.invokedFunctionArn) {
@@ -28,16 +29,24 @@ const handler = (params, context) => {
28
29
  inputProps: JSON.stringify(params.inputProps),
29
30
  isWarm,
30
31
  });
31
- return (0, still_1.stillHandler)(params, {
32
+ const response = await (0, still_1.stillHandler)(params, {
32
33
  expectedBucketOwner: currentUserId,
33
34
  });
35
+ responseStream.write(JSON.stringify(response));
36
+ responseStream.end();
37
+ return;
34
38
  }
35
39
  if (params.type === constants_1.LambdaRoutines.start) {
36
40
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.start, {
37
41
  inputProps: JSON.stringify(params.inputProps),
38
42
  isWarm,
39
43
  });
40
- return (0, start_1.startHandler)(params, { expectedBucketOwner: currentUserId });
44
+ const response = await (0, start_1.startHandler)(params, {
45
+ expectedBucketOwner: currentUserId,
46
+ });
47
+ responseStream.write(JSON.stringify(response));
48
+ responseStream.end();
49
+ return;
41
50
  }
42
51
  if (params.type === constants_1.LambdaRoutines.launch) {
43
52
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.launch, {
@@ -45,20 +54,25 @@ const handler = (params, context) => {
45
54
  inputProps: JSON.stringify(params.inputProps),
46
55
  isWarm,
47
56
  });
48
- return (0, launch_1.launchHandler)(params, {
57
+ await (0, launch_1.launchHandler)(params, {
49
58
  expectedBucketOwner: currentUserId,
50
59
  getRemainingTimeInMillis: context.getRemainingTimeInMillis,
51
60
  });
61
+ responseStream.end();
62
+ return;
52
63
  }
53
64
  if (params.type === constants_1.LambdaRoutines.status) {
54
65
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.status, {
55
66
  renderId: params.renderId,
56
67
  isWarm,
57
68
  });
58
- return (0, progress_1.progressHandler)(params, {
69
+ const response = await (0, progress_1.progressHandler)(params, {
59
70
  expectedBucketOwner: currentUserId,
60
71
  timeoutInMilliseconds,
61
72
  });
73
+ responseStream.write(JSON.stringify(response));
74
+ responseStream.end();
75
+ return;
62
76
  }
63
77
  if (params.type === constants_1.LambdaRoutines.renderer) {
64
78
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.renderer, {
@@ -68,25 +82,32 @@ const handler = (params, context) => {
68
82
  inputProps: JSON.stringify(params.inputProps),
69
83
  isWarm,
70
84
  });
71
- return (0, renderer_2.rendererHandler)(params, {
85
+ await (0, renderer_2.rendererHandler)(params, {
72
86
  expectedBucketOwner: currentUserId,
73
87
  isWarm,
74
88
  });
89
+ responseStream.end();
90
+ return;
75
91
  }
76
92
  if (params.type === constants_1.LambdaRoutines.info) {
77
93
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.info, {
78
94
  isWarm,
79
95
  });
80
- return (0, info_1.infoHandler)(params);
96
+ const response = await (0, info_1.infoHandler)(params);
97
+ responseStream.write(JSON.stringify(response));
98
+ responseStream.end();
99
+ return;
81
100
  }
82
101
  if (params.type === constants_1.LambdaRoutines.compositions) {
83
102
  (0, print_cloudwatch_helper_1.printCloudwatchHelper)(constants_1.LambdaRoutines.compositions, {
84
103
  isWarm,
85
104
  });
86
- return (0, compositions_1.compositionsHandler)(params, {
105
+ const response = await (0, compositions_1.compositionsHandler)(params, {
87
106
  expectedBucketOwner: currentUserId,
88
107
  });
108
+ responseStream.write(JSON.stringify(response));
109
+ responseStream.end();
110
+ return;
89
111
  }
90
112
  throw new Error(constants_1.COMMAND_NOT_FOUND);
91
- };
92
- exports.handler = handler;
113
+ });
@@ -179,7 +179,7 @@ const innerLaunchHandler = async (params, options) => {
179
179
  throw new Error(`Too many functions: This render would cause ${chunkCount} functions to spawn. We limit this amount to ${constants_1.MAX_FUNCTIONS_PER_RENDER} functions as more would result in diminishing returns. Values set: frameCount = ${frameCount}, framesPerLambda=${framesPerLambda}. See ${docs_url_1.DOCS_URL}/docs/lambda/concurrency#too-many-functions for help.`);
180
180
  }
181
181
  (0, validate_outname_1.validateOutname)(params.outName, params.codec, params.audioCodec);
182
- (0, validate_privacy_1.validatePrivacy)(params.privacy);
182
+ (0, validate_privacy_1.validatePrivacy)(params.privacy, true);
183
183
  renderer_1.RenderInternals.validatePuppeteerTimeout(params.timeoutInMilliseconds);
184
184
  const { chunks } = (0, plan_frame_ranges_1.planFrameRanges)({
185
185
  framesPerLambda,
@@ -42,7 +42,7 @@ const innerStillHandler = async (lambdaParams, renderId, options) => {
42
42
  throw new Error(`Version mismatch: When calling renderStillOnLambda(), you passed ${process.env.AWS_LAMBDA_FUNCTION_NAME} as the function, which has the version ${version_1.VERSION}, but the @remotion/lambda package you used to invoke the function has version ${lambdaParams.version}. Deploy a new function and use it to call renderStillOnLambda(). See: https://www.remotion.dev/docs/lambda/upgrading`);
43
43
  }
44
44
  (0, validate_download_behavior_1.validateDownloadBehavior)(lambdaParams.downloadBehavior);
45
- (0, validate_privacy_1.validatePrivacy)(lambdaParams.privacy);
45
+ (0, validate_privacy_1.validatePrivacy)(lambdaParams.privacy, true);
46
46
  (0, validate_outname_1.validateOutname)(lambdaParams.outName, null, null);
47
47
  const start = Date.now();
48
48
  const [bucketName, browserInstance] = await Promise.all([
@@ -5,30 +5,44 @@ const client_lambda_1 = require("@aws-sdk/client-lambda");
5
5
  const aws_clients_1 = require("./aws-clients");
6
6
  const callLambda = async ({ functionName, type, payload, region, }) => {
7
7
  var _a;
8
- const res = await (0, aws_clients_1.getLambdaClient)(region).send(new client_lambda_1.InvokeCommand({
8
+ const res = await (0, aws_clients_1.getLambdaClient)(region).send(new client_lambda_1.InvokeWithResponseStreamCommand({
9
9
  FunctionName: functionName,
10
10
  // @ts-expect-error
11
11
  Payload: JSON.stringify({ type, ...payload }),
12
12
  }));
13
- const string = Buffer.from(res.Payload).toString();
14
- const json = JSON.parse(string);
15
- if (json === null) {
16
- throw new Error('Lambda function unexpectedly returned null: ' +
17
- JSON.stringify({
18
- payload,
19
- type,
20
- functionName,
21
- json,
22
- error: res.FunctionError,
23
- version: res.$metadata,
24
- }));
13
+ const events = res.EventStream;
14
+ let responsePayload = new Uint8Array();
15
+ for await (const event of events) {
16
+ // There are two types of events you can get on a stream.
17
+ // `PayloadChunk`: These contain the actual raw bytes of the chunk
18
+ // It has a single property: `Payload`
19
+ if (event.PayloadChunk) {
20
+ // Decode the raw bytes into a string a human can read
21
+ const decoded = new TextDecoder('utf-8').decode(event.PayloadChunk.Payload);
22
+ responsePayload = Buffer.concat([responsePayload, Buffer.from(decoded)]);
23
+ }
24
+ if (event.InvokeComplete) {
25
+ if (event.InvokeComplete.ErrorCode) {
26
+ throw new Error(`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}}`);
27
+ }
28
+ }
25
29
  }
30
+ const string = Buffer.from(responsePayload).toString();
31
+ const json = JSON.parse(string);
26
32
  if ('errorMessage' in json) {
27
33
  const err = new Error(json.errorMessage);
28
34
  err.name = json.errorType;
29
35
  err.stack = ((_a = json.trace) !== null && _a !== void 0 ? _a : []).join('\n');
30
36
  throw err;
31
37
  }
38
+ // Streaming: 3.3.96+
39
+ if ('statusCode' in json) {
40
+ if (json.statusCode !== 200) {
41
+ throw new Error(`Lambda function ${functionName} failed with status code ${json.statusCode}: ${json.body}`);
42
+ }
43
+ return JSON.parse(json.body);
44
+ }
45
+ // Non-streaming: 3.3.95 and below
32
46
  return json;
33
47
  };
34
48
  exports.callLambda = callLambda;
@@ -5,4 +5,4 @@ export declare const deserializeInputProps: ({ serialized, region, bucketName, e
5
5
  region: AwsRegion;
6
6
  bucketName: string;
7
7
  expectedBucketOwner: string;
8
- }) => Promise<object>;
8
+ }) => Promise<Record<string, unknown>>;
@@ -15,3 +15,8 @@ export interface LambdaReturnValues {
15
15
  [LambdaRoutines.still]: ReturnType<typeof stillHandler>;
16
16
  [LambdaRoutines.compositions]: ReturnType<typeof compositionsHandler>;
17
17
  }
18
+ export declare type StreamedResponse = {
19
+ statusCode: number;
20
+ headers: Record<string, string>;
21
+ body: string;
22
+ };
@@ -1,7 +1,7 @@
1
1
  import type { AwsRegion } from '../client';
2
2
  import type { SerializedInputProps } from './constants';
3
3
  export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
4
- inputProps: unknown;
4
+ inputProps: Record<string, unknown>;
5
5
  region: AwsRegion;
6
6
  type: 'still' | 'video-or-audio';
7
7
  userSpecifiedBucketName: string | null;
@@ -1,2 +1,2 @@
1
1
  import type { Privacy } from './constants';
2
- export declare function validatePrivacy(privacy: unknown): asserts privacy is Privacy;
2
+ export declare function validatePrivacy(privacy: unknown, allowPrivate: boolean): asserts privacy is Privacy;
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePrivacy = void 0;
4
- function validatePrivacy(privacy) {
4
+ function validatePrivacy(privacy, allowPrivate) {
5
5
  if (typeof privacy !== 'string') {
6
6
  throw new TypeError('Privacy must be a string');
7
7
  }
8
+ if (!allowPrivate && privacy === 'private') {
9
+ throw new TypeError('Privacy must be either "public" or "no-acl"');
10
+ }
8
11
  if (privacy !== 'private' && privacy !== 'public' && privacy !== 'no-acl') {
9
12
  throw new TypeError('Privacy must be either "private", "public" or "no-acl"');
10
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/lambda",
3
- "version": "4.0.0-alpha8",
3
+ "version": "4.0.0-alpha9",
4
4
  "description": "Distributed renderer for Remotion based on AWS Lambda",
5
5
  "main": "dist/index.js",
6
6
  "sideEffects": false,
@@ -13,30 +13,28 @@
13
13
  "url": "https://github.com/JonnyBurger/remotion"
14
14
  },
15
15
  "dependencies": {
16
- "@aws-sdk/abort-controller": "3.272.0",
17
- "@aws-sdk/client-cloudwatch-logs": "3.272.0",
18
- "@aws-sdk/client-iam": "3.272.0",
19
- "@aws-sdk/client-lambda": "3.272.0",
20
- "@aws-sdk/client-s3": "3.272.0",
21
- "@aws-sdk/client-service-quotas": "3.272.0",
22
- "@aws-sdk/client-sts": "3.272.0",
23
- "@aws-sdk/credential-providers": "3.272.0",
24
- "@aws-sdk/lib-storage": "3.272.0",
25
- "@aws-sdk/s3-request-presigner": "3.272.0",
26
- "@remotion/bundler": "4.0.0-alpha8",
27
- "@remotion/cli": "4.0.0-alpha8",
28
- "@remotion/renderer": "4.0.0-alpha8",
16
+ "@aws-sdk/abort-controller": "3.338.0",
17
+ "@aws-sdk/client-cloudwatch-logs": "3.338.0",
18
+ "@aws-sdk/client-iam": "3.338.0",
19
+ "@aws-sdk/client-lambda": "3.338.0",
20
+ "@aws-sdk/client-s3": "3.338.0",
21
+ "@aws-sdk/client-service-quotas": "3.338.0",
22
+ "@aws-sdk/client-sts": "3.338.0",
23
+ "@aws-sdk/credential-providers": "3.338.0",
24
+ "@aws-sdk/lib-storage": "3.338.0",
25
+ "@aws-sdk/s3-request-presigner": "3.338.0",
29
26
  "aws-policies": "^1.0.1",
30
27
  "mime-types": "2.1.34",
31
- "remotion": "4.0.0-alpha8"
28
+ "@remotion/bundler": "4.0.0-alpha9",
29
+ "@remotion/cli": "4.0.0-alpha9",
30
+ "@remotion/renderer": "4.0.0-alpha9",
31
+ "remotion": "4.0.0-alpha9"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@jonny/eslint-config": "3.0.266",
35
- "@remotion/bundler": "4.0.0-alpha8",
36
- "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha8",
37
35
  "@types/mime-types": "2.1.1",
38
36
  "@types/minimist": "1.2.2",
39
- "@types/node": "^18.16.0",
37
+ "@types/node": "18.14.6",
40
38
  "@types/prompt": "^1.1.0",
41
39
  "eslint": "8.25.0",
42
40
  "prettier": "^2.4.1",
@@ -44,10 +42,12 @@
44
42
  "ts-node": "^10.8.0",
45
43
  "typescript": "^4.7.0",
46
44
  "vitest": "^0.24.3",
47
- "zip-lib": "^0.7.2"
45
+ "zip-lib": "^0.7.2",
46
+ "@remotion/bundler": "4.0.0-alpha9",
47
+ "@remotion/compositor-linux-arm64-gnu": "4.0.0-alpha9"
48
48
  },
49
49
  "peerDependencies": {
50
- "@remotion/bundler": "4.0.0-alpha8"
50
+ "@remotion/bundler": "4.0.0-alpha9"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -78,6 +78,7 @@
78
78
  }
79
79
  },
80
80
  "scripts": {
81
+ "formatting": "prettier src --check",
81
82
  "testintegration": "vitest src/test/integration --run",
82
83
  "lint": "eslint src --ext ts,tsx",
83
84
  "test": "vitest src/test/unit --run",
Binary file
Binary file