@remotion/lambda 4.0.24 → 4.0.26
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.
- package/dist/api/deploy-function.js +15 -14
- package/dist/api/deploy-site.js +12 -11
- package/dist/api/make-lambda-payload.js +2 -0
- package/dist/api/render-media-on-lambda.d.ts +2 -5
- package/dist/api/render-media-on-lambda.js +22 -21
- package/dist/api/render-still-on-lambda.js +19 -18
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/commands/render/render.js +4 -1
- package/dist/cli/helpers/get-webhook-custom-data.d.ts +1 -0
- package/dist/cli/helpers/get-webhook-custom-data.js +41 -0
- package/dist/cli/index.js +2 -2
- package/dist/cli/log.d.ts +4 -4
- package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +1 -4
- package/dist/functions/helpers/get-current-region.d.ts +1 -1
- package/dist/functions/helpers/streaming-payloads.d.ts +3 -3
- package/dist/functions/launch.js +10 -5
- package/dist/shared/compress-props.js +2 -1
- package/dist/shared/constants.d.ts +7 -3
- package/dist/shared/invoke-webhook.d.ts +3 -0
- package/dist/shared/validate-webhook.d.ts +3 -0
- package/dist/shared/validate-webhook.js +16 -0
- package/dist/shared/validate.d.ts +4 -0
- package/dist/shared/validate.js +8 -0
- package/package.json +8 -8
- package/remotionlambda-arm64.zip +0 -0
- package/dist/shared/deserialize-input-props.d.ts +0 -8
- package/dist/shared/deserialize-input-props.js +0 -26
- package/dist/shared/serialize-input-props.d.ts +0 -14
- package/dist/shared/serialize-input-props.js +0 -63
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deployFunction = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
4
5
|
const version_1 = require("remotion/version");
|
|
5
6
|
const get_functions_1 = require("../api/get-functions");
|
|
6
7
|
const constants_1 = require("../shared/constants");
|
|
@@ -14,19 +15,7 @@ const validate_memory_size_1 = require("../shared/validate-memory-size");
|
|
|
14
15
|
const validate_retention_period_1 = require("../shared/validate-retention-period");
|
|
15
16
|
const validate_timeout_1 = require("../shared/validate-timeout");
|
|
16
17
|
const create_function_1 = require("./create-function");
|
|
17
|
-
|
|
18
|
-
* @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
|
|
19
|
-
* @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
|
|
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.
|
|
27
|
-
* @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
|
|
28
|
-
*/
|
|
29
|
-
const deployFunction = async (params) => {
|
|
18
|
+
const deployFunctionRaw = async (params) => {
|
|
30
19
|
var _a, _b;
|
|
31
20
|
const diskSizeInMb = (_a = params.diskSizeInMb) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_EPHEMERAL_STORAGE_IN_MB;
|
|
32
21
|
(0, validate_memory_size_1.validateMemorySize)(params.memorySizeInMb);
|
|
@@ -71,4 +60,16 @@ const deployFunction = async (params) => {
|
|
|
71
60
|
alreadyExisted: Boolean(alreadyDeployed),
|
|
72
61
|
};
|
|
73
62
|
};
|
|
74
|
-
|
|
63
|
+
/**
|
|
64
|
+
* @description Creates an AWS Lambda function in your account that will be able to render a video in the cloud.
|
|
65
|
+
* @see [Documentation](https://www.remotion.dev/docs/lambda/deployfunction)
|
|
66
|
+
* @param params.createCloudWatchLogGroup Whether you'd like to create a CloudWatch Log Group to store the logs for this function.
|
|
67
|
+
* @param params.cloudWatchLogRetentionPeriodInDays (optional) The number of days to retain the CloudWatch logs for this function. Default is 14 days.
|
|
68
|
+
* @param params.region The region you want to deploy your function to.
|
|
69
|
+
* @param params.timeoutInSeconds After how many seconds the lambda function should be killed if it does not end itself.
|
|
70
|
+
* @param params.memorySizeInMb How much memory should be allocated to the Lambda function.
|
|
71
|
+
* @param params.architecture The architecture Lambda should run on. One of x86_64 and x64
|
|
72
|
+
* @param params.diskSizeInMb The amount of storage the function should be allocated. The higher, the longer videos you can render. Default 512.
|
|
73
|
+
* @returns {Promise<DeployFunctionOutput>} An object that contains the `functionName` property
|
|
74
|
+
*/
|
|
75
|
+
exports.deployFunction = pure_1.PureJSAPIs.wrapWithErrorHandling(deployFunctionRaw);
|
package/dist/api/deploy-site.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.deploySite = void 0;
|
|
7
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
7
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
9
|
const io_1 = require("../functions/helpers/io");
|
|
9
10
|
const bundle_site_1 = require("../shared/bundle-site");
|
|
@@ -18,16 +19,7 @@ const validate_privacy_1 = require("../shared/validate-privacy");
|
|
|
18
19
|
const validate_site_name_1 = require("../shared/validate-site-name");
|
|
19
20
|
const bucket_exists_1 = require("./bucket-exists");
|
|
20
21
|
const upload_dir_1 = require("./upload-dir");
|
|
21
|
-
|
|
22
|
-
* @description Deploys a Remotion project to an S3 bucket to prepare it for rendering on AWS Lambda.
|
|
23
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/deploysite)
|
|
24
|
-
* @param {AwsRegion} params.region The region in which the S3 bucket resides in.
|
|
25
|
-
* @param {string} params.entryPoint An absolute path to the entry file of your Remotion project.
|
|
26
|
-
* @param {string} params.bucketName The name of the bucket to deploy your project into.
|
|
27
|
-
* @param {string} params.siteName The name of the folder in which the project gets deployed to.
|
|
28
|
-
* @param {object} params.options Further options, see documentation page for this function.
|
|
29
|
-
*/
|
|
30
|
-
const deploySite = async ({ bucketName, entryPoint, siteName, options, region, privacy: passedPrivacy, }) => {
|
|
22
|
+
const deploySiteRaw = async ({ bucketName, entryPoint, siteName, options, region, privacy: passedPrivacy, }) => {
|
|
31
23
|
var _a, _b, _c, _d;
|
|
32
24
|
(0, validate_aws_region_1.validateAwsRegion)(region);
|
|
33
25
|
(0, validate_bucketname_1.validateBucketName)(bucketName, {
|
|
@@ -105,4 +97,13 @@ const deploySite = async ({ bucketName, entryPoint, siteName, options, region, p
|
|
|
105
97
|
},
|
|
106
98
|
};
|
|
107
99
|
};
|
|
108
|
-
|
|
100
|
+
/**
|
|
101
|
+
* @description Deploys a Remotion project to an S3 bucket to prepare it for rendering on AWS Lambda.
|
|
102
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/deploysite)
|
|
103
|
+
* @param {AwsRegion} params.region The region in which the S3 bucket resides in.
|
|
104
|
+
* @param {string} params.entryPoint An absolute path to the entry file of your Remotion project.
|
|
105
|
+
* @param {string} params.bucketName The name of the bucket to deploy your project into.
|
|
106
|
+
* @param {string} params.siteName The name of the folder in which the project gets deployed to.
|
|
107
|
+
* @param {object} params.options Further options, see documentation page for this function.
|
|
108
|
+
*/
|
|
109
|
+
exports.deploySite = pure_1.PureJSAPIs.wrapWithErrorHandling(deploySiteRaw);
|
|
@@ -8,6 +8,7 @@ const validate_download_behavior_1 = require("../shared/validate-download-behavi
|
|
|
8
8
|
const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
|
|
9
9
|
const validate_lambda_codec_1 = require("../shared/validate-lambda-codec");
|
|
10
10
|
const validate_serveurl_1 = require("../shared/validate-serveurl");
|
|
11
|
+
const validate_webhook_1 = require("../shared/validate-webhook");
|
|
11
12
|
const makeLambdaRenderMediaPayload = async ({ 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, downloadBehavior, muted, overwrite, dumpBrowserLogs, jpegQuality, quality, offthreadVideoCacheSizeInBytes, }) => {
|
|
12
13
|
if (quality) {
|
|
13
14
|
throw new Error('quality has been renamed to jpegQuality. Please rename the option.');
|
|
@@ -19,6 +20,7 @@ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange,
|
|
|
19
20
|
durationInFrames: 1,
|
|
20
21
|
});
|
|
21
22
|
(0, validate_download_behavior_1.validateDownloadBehavior)(downloadBehavior);
|
|
23
|
+
(0, validate_webhook_1.validateWebhook)(webhook);
|
|
22
24
|
const stringifiedInputProps = (0, compress_props_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
|
|
23
25
|
const serialized = await (0, compress_props_1.compressInputProps)({
|
|
24
26
|
stringifiedInputProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AudioCodec, ChromiumOptions, FrameRange, LogLevel, PixelFormat, ProResProfile, ToOptions, VideoImageFormat, X264Preset } from '@remotion/renderer';
|
|
2
2
|
import type { BrowserSafeApis } from '@remotion/renderer/client';
|
|
3
3
|
import type { AwsRegion } from '../pricing/aws-regions';
|
|
4
|
-
import type { OutNameInput, Privacy } from '../shared/constants';
|
|
4
|
+
import type { OutNameInput, Privacy, WebhookOption } from '../shared/constants';
|
|
5
5
|
import type { DownloadBehavior } from '../shared/content-disposition-header';
|
|
6
6
|
import type { LambdaCodec } from '../shared/validate-lambda-codec';
|
|
7
7
|
export type RenderMediaOnLambdaInput = {
|
|
@@ -39,10 +39,7 @@ export type RenderMediaOnLambdaInput = {
|
|
|
39
39
|
overwrite?: boolean;
|
|
40
40
|
audioBitrate?: string | null;
|
|
41
41
|
videoBitrate?: string | null;
|
|
42
|
-
webhook?:
|
|
43
|
-
url: string;
|
|
44
|
-
secret: string | null;
|
|
45
|
-
};
|
|
42
|
+
webhook?: WebhookOption | null;
|
|
46
43
|
forceWidth?: number | null;
|
|
47
44
|
forceHeight?: number | null;
|
|
48
45
|
rendererFunctionName?: string | null;
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderVideoOnLambda = exports.renderMediaOnLambda = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
4
5
|
const call_lambda_1 = require("../shared/call-lambda");
|
|
5
6
|
const constants_1 = require("../shared/constants");
|
|
6
7
|
const get_aws_urls_1 = require("../shared/get-aws-urls");
|
|
7
8
|
const make_lambda_payload_1 = require("./make-lambda-payload");
|
|
8
|
-
|
|
9
|
-
* @description Triggers a render on a lambda given a composition and a lambda function.
|
|
10
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)
|
|
11
|
-
* @param params.functionName The name of the Lambda function that should be used
|
|
12
|
-
* @param params.serveUrl The URL of the deployed project
|
|
13
|
-
* @param params.composition The ID of the composition which should be rendered.
|
|
14
|
-
* @param params.inputProps The input props that should be passed to the composition.
|
|
15
|
-
* @param params.codec The media codec which should be used for encoding.
|
|
16
|
-
* @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
|
|
17
|
-
* @param params.crf The constant rate factor to be used during encoding.
|
|
18
|
-
* @param params.envVariables Object containing environment variables to be inserted into the video environment
|
|
19
|
-
* @param params.proResProfile The ProRes profile if rendering a ProRes video
|
|
20
|
-
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
21
|
-
* @param params.region The AWS region in which the media should be rendered.
|
|
22
|
-
* @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
|
|
23
|
-
* @param params.logLevel Level of logging that Lambda function should perform. Default "info".
|
|
24
|
-
* @param params.webhook Configuration for webhook called upon completion or timeout of the render.
|
|
25
|
-
* @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
|
|
26
|
-
*/
|
|
27
|
-
const renderMediaOnLambda = async (input) => {
|
|
9
|
+
const renderMediaOnLambdaRaw = async (input) => {
|
|
28
10
|
var _a;
|
|
29
11
|
const { functionName, region, rendererFunctionName } = input;
|
|
30
12
|
try {
|
|
@@ -61,7 +43,26 @@ const renderMediaOnLambda = async (input) => {
|
|
|
61
43
|
throw err;
|
|
62
44
|
}
|
|
63
45
|
};
|
|
64
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @description Triggers a render on a lambda given a composition and a lambda function.
|
|
48
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/rendermediaonlambda)
|
|
49
|
+
* @param params.functionName The name of the Lambda function that should be used
|
|
50
|
+
* @param params.serveUrl The URL of the deployed project
|
|
51
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
52
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
53
|
+
* @param params.codec The media codec which should be used for encoding.
|
|
54
|
+
* @param params.imageFormat In which image format the frames should be rendered. Default "jpeg"
|
|
55
|
+
* @param params.crf The constant rate factor to be used during encoding.
|
|
56
|
+
* @param params.envVariables Object containing environment variables to be inserted into the video environment
|
|
57
|
+
* @param params.proResProfile The ProRes profile if rendering a ProRes video
|
|
58
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
59
|
+
* @param params.region The AWS region in which the media should be rendered.
|
|
60
|
+
* @param params.maxRetries How often rendering a chunk may fail before the media render gets aborted. Default "1"
|
|
61
|
+
* @param params.logLevel Level of logging that Lambda function should perform. Default "info".
|
|
62
|
+
* @param params.webhook Configuration for webhook called upon completion or timeout of the render.
|
|
63
|
+
* @returns {Promise<RenderMediaOnLambdaOutput>} See documentation for detailed structure
|
|
64
|
+
*/
|
|
65
|
+
exports.renderMediaOnLambda = pure_1.PureJSAPIs.wrapWithErrorHandling(renderMediaOnLambdaRaw);
|
|
65
66
|
/**
|
|
66
67
|
* @deprecated Renamed to renderMediaOnLambda()
|
|
67
68
|
*/
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.renderStillOnLambda = void 0;
|
|
4
|
+
const pure_1 = require("@remotion/renderer/pure");
|
|
4
5
|
const version_1 = require("remotion/version");
|
|
5
6
|
const call_lambda_1 = require("../shared/call-lambda");
|
|
6
7
|
const compress_props_1 = require("../shared/compress-props");
|
|
7
8
|
const constants_1 = require("../shared/constants");
|
|
8
9
|
const get_aws_urls_1 = require("../shared/get-aws-urls");
|
|
9
|
-
|
|
10
|
-
* @description Renders a still frame on Lambda
|
|
11
|
-
* @link https://remotion.dev/docs/lambda/renderstillonlambda
|
|
12
|
-
* @param params.functionName The name of the Lambda function that should be used
|
|
13
|
-
* @param params.serveUrl The URL of the deployed project
|
|
14
|
-
* @param params.composition The ID of the composition which should be rendered.
|
|
15
|
-
* @param params.inputProps The input props that should be passed to the composition.
|
|
16
|
-
* @param params.imageFormat In which image format the frames should be rendered.
|
|
17
|
-
* @param params.envVariables Object containing environment variables to be inserted into the video environment
|
|
18
|
-
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
19
|
-
* @param params.region The AWS region in which the video should be rendered.
|
|
20
|
-
* @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
|
|
21
|
-
* @param params.frame Which frame should be used for the still image. Default 0.
|
|
22
|
-
* @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
|
|
23
|
-
* @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
|
|
24
|
-
*/
|
|
25
|
-
const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, offthreadVideoCacheSizeInBytes, }) => {
|
|
10
|
+
const renderStillOnLambdaRaw = async ({ functionName, serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, dumpBrowserLogs, onInit, offthreadVideoCacheSizeInBytes, }) => {
|
|
26
11
|
var _a;
|
|
27
12
|
if (quality) {
|
|
28
13
|
throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
|
|
@@ -102,4 +87,20 @@ const renderStillOnLambda = async ({ functionName, serveUrl, inputProps, imageFo
|
|
|
102
87
|
throw err;
|
|
103
88
|
}
|
|
104
89
|
};
|
|
105
|
-
|
|
90
|
+
/**
|
|
91
|
+
* @description Renders a still frame on Lambda
|
|
92
|
+
* @link https://remotion.dev/docs/lambda/renderstillonlambda
|
|
93
|
+
* @param params.functionName The name of the Lambda function that should be used
|
|
94
|
+
* @param params.serveUrl The URL of the deployed project
|
|
95
|
+
* @param params.composition The ID of the composition which should be rendered.
|
|
96
|
+
* @param params.inputProps The input props that should be passed to the composition.
|
|
97
|
+
* @param params.imageFormat In which image format the frames should be rendered.
|
|
98
|
+
* @param params.envVariables Object containing environment variables to be inserted into the video environment
|
|
99
|
+
* @param params.jpegQuality JPEG quality if JPEG was selected as the image format.
|
|
100
|
+
* @param params.region The AWS region in which the video should be rendered.
|
|
101
|
+
* @param params.maxRetries How often rendering a chunk may fail before the video render gets aborted.
|
|
102
|
+
* @param params.frame Which frame should be used for the still image. Default 0.
|
|
103
|
+
* @param params.privacy Whether the item in the S3 bucket should be public. Possible values: `"private"` and `"public"`
|
|
104
|
+
* @returns {Promise<RenderStillOnLambdaOutput>} See documentation for exact response structure.
|
|
105
|
+
*/
|
|
106
|
+
exports.renderStillOnLambda = pure_1.PureJSAPIs.wrapWithErrorHandling(renderStillOnLambdaRaw);
|
package/dist/cli/args.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="minimist" />
|
|
2
|
+
import type { BrowserSafeApis } from '@remotion/renderer/client';
|
|
2
3
|
import type { AwsRegion } from '../pricing/aws-regions';
|
|
3
4
|
import type { Privacy } from '../shared/constants';
|
|
4
5
|
type LambdaCommandLineOptions = {
|
|
@@ -25,6 +26,7 @@ type LambdaCommandLineOptions = {
|
|
|
25
26
|
privacy: Privacy;
|
|
26
27
|
webhook: string | undefined;
|
|
27
28
|
['webhook-secret']: string | undefined;
|
|
29
|
+
[BrowserSafeApis.options.webhookCustomDataOption.cliFlag]: string | undefined;
|
|
28
30
|
['renderer-function-name']: string | undefined;
|
|
29
31
|
['function-name']: string | undefined;
|
|
30
32
|
['force-bucket-name']: string | undefined;
|
|
@@ -17,6 +17,7 @@ const validate_serveurl_1 = require("../../../shared/validate-serveurl");
|
|
|
17
17
|
const args_1 = require("../../args");
|
|
18
18
|
const get_aws_region_1 = require("../../get-aws-region");
|
|
19
19
|
const find_function_name_1 = require("../../helpers/find-function-name");
|
|
20
|
+
const get_webhook_custom_data_1 = require("../../helpers/get-webhook-custom-data");
|
|
20
21
|
const quit_1 = require("../../helpers/quit");
|
|
21
22
|
const log_1 = require("../../log");
|
|
22
23
|
const progress_1 = require("./progress");
|
|
@@ -97,6 +98,7 @@ const renderCommand = async (args, remotionRoot) => {
|
|
|
97
98
|
(0, validate_privacy_1.validatePrivacy)(privacy, true);
|
|
98
99
|
const framesPerLambda = (_e = args_1.parsedLambdaCli['frames-per-lambda']) !== null && _e !== void 0 ? _e : undefined;
|
|
99
100
|
(0, validate_frames_per_lambda_1.validateFramesPerLambda)({ framesPerLambda, durationInFrames: 1 });
|
|
101
|
+
const webhookCustomData = (0, get_webhook_custom_data_1.getWebhookCustomData)();
|
|
100
102
|
const res = await (0, render_media_on_lambda_1.renderMediaOnLambda)({
|
|
101
103
|
functionName,
|
|
102
104
|
serveUrl,
|
|
@@ -132,6 +134,7 @@ const renderCommand = async (args, remotionRoot) => {
|
|
|
132
134
|
? {
|
|
133
135
|
url: args_1.parsedLambdaCli.webhook,
|
|
134
136
|
secret: (_f = args_1.parsedLambdaCli['webhook-secret']) !== null && _f !== void 0 ? _f : null,
|
|
137
|
+
customData: webhookCustomData,
|
|
135
138
|
}
|
|
136
139
|
: undefined,
|
|
137
140
|
rendererFunctionName: (_g = args_1.parsedLambdaCli['renderer-function-name']) !== null && _g !== void 0 ? _g : null,
|
|
@@ -281,7 +284,7 @@ const renderCommand = async (args, remotionRoot) => {
|
|
|
281
284
|
stack: err.stack,
|
|
282
285
|
stackFrame: frames,
|
|
283
286
|
});
|
|
284
|
-
await cli_1.CliInternals.
|
|
287
|
+
await cli_1.CliInternals.printError(errorWithStackFrame, logLevel);
|
|
285
288
|
}
|
|
286
289
|
log_1.Log.info();
|
|
287
290
|
log_1.Log.info(`Accrued costs until error was thrown: ${newStatus.costs.displayCost}.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getWebhookCustomData: () => Record<string, unknown> | null;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getWebhookCustomData = void 0;
|
|
7
|
+
const client_1 = require("@remotion/renderer/client");
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const args_1 = require("../args");
|
|
12
|
+
const log_1 = require("../log");
|
|
13
|
+
const getWebhookCustomData = () => {
|
|
14
|
+
const flagName = client_1.BrowserSafeApis.options.webhookCustomDataOption.cliFlag;
|
|
15
|
+
const webhookFlag = args_1.parsedLambdaCli[flagName];
|
|
16
|
+
if (!webhookFlag) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const jsonFile = node_path_1.default.resolve(process.cwd(), webhookFlag);
|
|
20
|
+
try {
|
|
21
|
+
if (node_fs_1.default.existsSync(jsonFile)) {
|
|
22
|
+
const rawJsonData = node_fs_1.default.readFileSync(jsonFile, 'utf-8');
|
|
23
|
+
return JSON.parse(rawJsonData);
|
|
24
|
+
}
|
|
25
|
+
return JSON.parse(webhookFlag);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
log_1.Log.error(`You passed --${flagName} but it was neither valid JSON nor a file path to a valid JSON file. Provided value: ${webhookFlag}`);
|
|
29
|
+
log_1.Log.info('Got the following value:', webhookFlag);
|
|
30
|
+
log_1.Log.error('Check that your input is parseable using `JSON.parse` and try again.');
|
|
31
|
+
if (node_os_1.default.platform() === 'win32') {
|
|
32
|
+
log_1.Log.warn('Note: Windows handles escaping of quotes very weirdly in the command line.');
|
|
33
|
+
log_1.Log.warn('This might have led to you having this problem.');
|
|
34
|
+
log_1.Log.warn('Consider using the alternative API for --props which is to pass');
|
|
35
|
+
log_1.Log.warn('a path to a JSON file:');
|
|
36
|
+
log_1.Log.warn(` --${flagName}=path/to/props.json`);
|
|
37
|
+
}
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.getWebhookCustomData = getWebhookCustomData;
|
package/dist/cli/index.js
CHANGED
|
@@ -139,7 +139,7 @@ AWS returned an error message "The security token included in the request is inv
|
|
|
139
139
|
`);
|
|
140
140
|
}
|
|
141
141
|
if (error instanceof renderer_1.RenderInternals.SymbolicateableError) {
|
|
142
|
-
await cli_1.CliInternals.
|
|
142
|
+
await cli_1.CliInternals.printError(error, config_1.ConfigInternals.Logging.getLogLevel());
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
145
145
|
const frames = renderer_1.RenderInternals.parseStack((_e = (_d = error.stack) === null || _d === void 0 ? void 0 : _d.split('\n')) !== null && _e !== void 0 ? _e : []);
|
|
@@ -150,7 +150,7 @@ AWS returned an error message "The security token included in the request is inv
|
|
|
150
150
|
stack: error.stack,
|
|
151
151
|
stackFrame: frames,
|
|
152
152
|
});
|
|
153
|
-
await cli_1.CliInternals.
|
|
153
|
+
await cli_1.CliInternals.printError(errorWithStackFrame, config_1.ConfigInternals.Logging.getLogLevel());
|
|
154
154
|
}
|
|
155
155
|
(0, quit_1.quit)(1);
|
|
156
156
|
}
|
package/dist/cli/log.d.ts
CHANGED
|
@@ -2,24 +2,24 @@ export declare const Log: {
|
|
|
2
2
|
verbose: (message?: any, ...optionalParams: any[]) => void;
|
|
3
3
|
verboseAdvanced: (options: {
|
|
4
4
|
indent: boolean;
|
|
5
|
-
logLevel: "
|
|
5
|
+
logLevel: "error" | "verbose" | "info" | "warn";
|
|
6
6
|
} & {
|
|
7
7
|
tag?: string | undefined;
|
|
8
8
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
9
9
|
info: (message?: any, ...optionalParams: any[]) => void;
|
|
10
10
|
infoAdvanced: (options: {
|
|
11
11
|
indent: boolean;
|
|
12
|
-
logLevel: "
|
|
12
|
+
logLevel: "error" | "verbose" | "info" | "warn";
|
|
13
13
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
14
14
|
warn: (message?: any, ...optionalParams: any[]) => void;
|
|
15
15
|
warnAdvanced: (options: {
|
|
16
16
|
indent: boolean;
|
|
17
|
-
logLevel: "
|
|
17
|
+
logLevel: "error" | "verbose" | "info" | "warn";
|
|
18
18
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
19
19
|
error: (message?: any, ...optionalParams: any[]) => void;
|
|
20
20
|
errorAdvanced: (options: {
|
|
21
21
|
indent: boolean;
|
|
22
|
-
logLevel: "
|
|
22
|
+
logLevel: "error" | "verbose" | "info" | "warn";
|
|
23
23
|
} & {
|
|
24
24
|
tag?: string | undefined;
|
|
25
25
|
}, message?: any, ...optionalParams: any[]) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getCurrentRegionInFunction: () => "eu-central-1" | "eu-west-1" | "eu-west-2" | "eu-west-3" | "eu-
|
|
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 {};
|
package/dist/functions/launch.js
CHANGED
|
@@ -28,7 +28,6 @@ const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
|
28
28
|
const renderer_1 = require("@remotion/renderer");
|
|
29
29
|
const node_fs_1 = __importStar(require("node:fs"));
|
|
30
30
|
const node_path_1 = require("node:path");
|
|
31
|
-
const remotion_1 = require("remotion");
|
|
32
31
|
const version_1 = require("remotion/version");
|
|
33
32
|
const aws_clients_1 = require("../shared/aws-clients");
|
|
34
33
|
const cleanup_serialized_input_props_1 = require("../shared/cleanup-serialized-input-props");
|
|
@@ -36,6 +35,7 @@ const compress_props_1 = require("../shared/compress-props");
|
|
|
36
35
|
const constants_1 = require("../shared/constants");
|
|
37
36
|
const docs_url_1 = require("../shared/docs-url");
|
|
38
37
|
const invoke_webhook_1 = require("../shared/invoke-webhook");
|
|
38
|
+
const validate_1 = require("../shared/validate");
|
|
39
39
|
const validate_frames_per_lambda_1 = require("../shared/validate-frames-per-lambda");
|
|
40
40
|
const validate_outname_1 = require("../shared/validate-outname");
|
|
41
41
|
const validate_privacy_1 = require("../shared/validate-privacy");
|
|
@@ -115,13 +115,13 @@ const innerLaunchHandler = async (params, options) => {
|
|
|
115
115
|
offthreadVideoCacheSizeInBytes: params.offthreadVideoCacheSizeInBytes,
|
|
116
116
|
});
|
|
117
117
|
renderer_1.RenderInternals.Log.info('Composition validated, resolved props', comp.props);
|
|
118
|
-
|
|
118
|
+
(0, validate_1.validateDurationInFrames)(comp.durationInFrames, {
|
|
119
119
|
component: 'passed to a Lambda render',
|
|
120
120
|
allowFloats: false,
|
|
121
121
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
(0, validate_1.validateFps)(comp.fps, 'passed to a Lambda render', false);
|
|
123
|
+
(0, validate_1.validateDimension)(comp.height, 'height', 'passed to a Lambda render');
|
|
124
|
+
(0, validate_1.validateDimension)(comp.width, 'width', 'passed to a Lambda render');
|
|
125
125
|
renderer_1.RenderInternals.validateBitrate(params.audioBitrate, 'audioBitrate');
|
|
126
126
|
renderer_1.RenderInternals.validateBitrate(params.videoBitrate, 'videoBitrate');
|
|
127
127
|
renderer_1.RenderInternals.validateConcurrency(params.concurrencyPerLambda, 'concurrencyPerLambda');
|
|
@@ -442,11 +442,13 @@ const innerLaunchHandler = async (params, options) => {
|
|
|
442
442
|
return postRenderData;
|
|
443
443
|
};
|
|
444
444
|
const launchHandler = async (params, options) => {
|
|
445
|
+
var _a, _b;
|
|
445
446
|
if (params.type !== constants_1.LambdaRoutines.launch) {
|
|
446
447
|
throw new Error('Expected launch type');
|
|
447
448
|
}
|
|
448
449
|
let webhookInvoked = false;
|
|
449
450
|
const webhookDueToTimeout = setTimeout(async () => {
|
|
451
|
+
var _a;
|
|
450
452
|
if (params.webhook && !webhookInvoked) {
|
|
451
453
|
try {
|
|
452
454
|
await (0, invoke_webhook_1.invokeWebhook)({
|
|
@@ -457,6 +459,7 @@ const launchHandler = async (params, options) => {
|
|
|
457
459
|
renderId: params.renderId,
|
|
458
460
|
expectedBucketOwner: options.expectedBucketOwner,
|
|
459
461
|
bucketName: params.bucketName,
|
|
462
|
+
customData: (_a = params.webhook.customData) !== null && _a !== void 0 ? _a : null,
|
|
460
463
|
},
|
|
461
464
|
});
|
|
462
465
|
webhookInvoked = true;
|
|
@@ -502,6 +505,7 @@ const launchHandler = async (params, options) => {
|
|
|
502
505
|
renderId: params.renderId,
|
|
503
506
|
expectedBucketOwner: options.expectedBucketOwner,
|
|
504
507
|
bucketName: params.bucketName,
|
|
508
|
+
customData: (_a = params.webhook.customData) !== null && _a !== void 0 ? _a : null,
|
|
505
509
|
outputUrl: postRenderData.outputFile,
|
|
506
510
|
lambdaErrors: postRenderData.errors,
|
|
507
511
|
outputFile: postRenderData.outputFile,
|
|
@@ -575,6 +579,7 @@ const launchHandler = async (params, options) => {
|
|
|
575
579
|
renderId: params.renderId,
|
|
576
580
|
expectedBucketOwner: options.expectedBucketOwner,
|
|
577
581
|
bucketName: params.bucketName,
|
|
582
|
+
customData: (_b = params.webhook.customData) !== null && _b !== void 0 ? _b : null,
|
|
578
583
|
errors: [err].map((e) => ({
|
|
579
584
|
message: e.message,
|
|
580
585
|
name: e.name,
|
|
@@ -7,6 +7,7 @@ const constants_1 = require("./constants");
|
|
|
7
7
|
const random_hash_1 = require("./random-hash");
|
|
8
8
|
const serialize_props_1 = require("./serialize-props");
|
|
9
9
|
const stream_to_string_1 = require("./stream-to-string");
|
|
10
|
+
const validate_webhook_1 = require("./validate-webhook");
|
|
10
11
|
const serializeOrThrow = (inputProps, propsType) => {
|
|
11
12
|
try {
|
|
12
13
|
const payload = (0, serialize_props_1.serializeJSONWithDate)({
|
|
@@ -22,7 +23,7 @@ const serializeOrThrow = (inputProps, propsType) => {
|
|
|
22
23
|
};
|
|
23
24
|
exports.serializeOrThrow = serializeOrThrow;
|
|
24
25
|
const getNeedsToUpload = (type, sizes) => {
|
|
25
|
-
const MARGIN = 5000;
|
|
26
|
+
const MARGIN = 5000 + validate_webhook_1.MAX_WEBHOOK_CUSTOM_DATA_SIZE;
|
|
26
27
|
const MAX_INLINE_PAYLOAD_SIZE = (type === 'still' ? 5000000 : 200000) - MARGIN;
|
|
27
28
|
const sizesAlreadyUsed = sizes.reduce((a, b) => a + b);
|
|
28
29
|
if (sizesAlreadyUsed > MAX_INLINE_PAYLOAD_SIZE) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AudioCodec, ChromiumOptions, Codec, FrameRange, LogLevel, PixelFormat, ProResProfile, StillImageFormat, VideoImageFormat, X264Preset } from '@remotion/renderer';
|
|
1
|
+
import type { AudioCodec, ChromiumOptions, Codec, FrameRange, LogLevel, PixelFormat, ProResProfile, StillImageFormat, ToOptions, VideoImageFormat, X264Preset } from '@remotion/renderer';
|
|
2
|
+
import type { BrowserSafeApis } from '@remotion/renderer/client';
|
|
2
3
|
import type { VideoConfig } from 'remotion';
|
|
3
4
|
import type { ChunkRetry } from '../functions/helpers/get-retry-stats';
|
|
4
5
|
import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
|
|
@@ -95,10 +96,13 @@ export declare enum LambdaRoutines {
|
|
|
95
96
|
still = "still",
|
|
96
97
|
compositions = "compositions"
|
|
97
98
|
}
|
|
98
|
-
type
|
|
99
|
+
type Prettify<T> = {
|
|
100
|
+
[K in keyof T]: T[K];
|
|
101
|
+
} & {};
|
|
102
|
+
export type WebhookOption = Prettify<null | ({
|
|
99
103
|
url: string;
|
|
100
104
|
secret: string | null;
|
|
101
|
-
}
|
|
105
|
+
} & Partial<ToOptions<[typeof BrowserSafeApis.options.webhookCustomDataOption]>>)>;
|
|
102
106
|
export type SerializedInputProps = {
|
|
103
107
|
type: 'bucket-url';
|
|
104
108
|
hash: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import https from 'https';
|
|
2
4
|
import http from 'node:http';
|
|
3
5
|
import type { EnhancedErrorInfo } from '../functions/helpers/write-lambda-error';
|
|
@@ -31,6 +33,7 @@ export type WebhookPayload = {
|
|
|
31
33
|
renderId: string;
|
|
32
34
|
expectedBucketOwner: string;
|
|
33
35
|
bucketName: string;
|
|
36
|
+
customData: Record<string, unknown> | null;
|
|
34
37
|
} & DynamicWebhookPayload;
|
|
35
38
|
export declare const mockableHttpClients: {
|
|
36
39
|
http: typeof http.request;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateWebhook = exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE = void 0;
|
|
4
|
+
exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE = 1024;
|
|
5
|
+
const validateWebhook = (webhook) => {
|
|
6
|
+
if (typeof webhook === 'undefined' || webhook === null) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (webhook.customData) {
|
|
10
|
+
const size = JSON.stringify(webhook.customData).length;
|
|
11
|
+
if (size > exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE) {
|
|
12
|
+
throw new Error(`Webhook "customData" must be less than ${exports.MAX_WEBHOOK_CUSTOM_DATA_SIZE} bytes. Current size: ${size} bytes.`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.validateWebhook = validateWebhook;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateDurationInFrames = exports.validateDimension = exports.validateFps = void 0;
|
|
4
|
+
/* eslint-disable prefer-destructuring */
|
|
5
|
+
const remotion_1 = require("remotion");
|
|
6
|
+
exports.validateFps = remotion_1.Internals.validateFps;
|
|
7
|
+
exports.validateDimension = remotion_1.Internals.validateDimension;
|
|
8
|
+
exports.validateDurationInFrames = remotion_1.Internals.validateDurationInFrames;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.26",
|
|
4
4
|
"description": "Distributed renderer for Remotion based on AWS Lambda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"aws-policies": "^1.0.1",
|
|
27
27
|
"mime-types": "2.1.34",
|
|
28
28
|
"zod": "3.21.4",
|
|
29
|
-
"@remotion/
|
|
30
|
-
"@remotion/
|
|
31
|
-
"
|
|
32
|
-
"remotion": "4.0.
|
|
29
|
+
"@remotion/bundler": "4.0.26",
|
|
30
|
+
"@remotion/cli": "4.0.26",
|
|
31
|
+
"remotion": "4.0.26",
|
|
32
|
+
"@remotion/renderer": "4.0.26"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@jonny/eslint-config": "3.0.266",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"ts-node": "^10.8.0",
|
|
44
44
|
"vitest": "0.31.1",
|
|
45
45
|
"zip-lib": "^0.7.2",
|
|
46
|
-
"@remotion/bundler": "4.0.
|
|
47
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
46
|
+
"@remotion/bundler": "4.0.26",
|
|
47
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.26"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@remotion/bundler": "4.0.
|
|
50
|
+
"@remotion/bundler": "4.0.26"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
Binary file
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AwsRegion } from '../client';
|
|
2
|
-
import type { SerializedInputProps } from './constants';
|
|
3
|
-
export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
|
|
4
|
-
serialized: SerializedInputProps;
|
|
5
|
-
region: AwsRegion;
|
|
6
|
-
bucketName: string;
|
|
7
|
-
expectedBucketOwner: string;
|
|
8
|
-
}) => Promise<Record<string, unknown>>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeInputProps = void 0;
|
|
4
|
-
const io_1 = require("../functions/helpers/io");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
const stream_to_string_1 = require("./stream-to-string");
|
|
7
|
-
const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
|
|
8
|
-
if (serialized.type === 'payload') {
|
|
9
|
-
return JSON.parse(serialized.payload);
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
const response = await (0, io_1.lambdaReadFile)({
|
|
13
|
-
bucketName,
|
|
14
|
-
expectedBucketOwner,
|
|
15
|
-
key: (0, constants_1.inputPropsKey)(serialized.hash),
|
|
16
|
-
region,
|
|
17
|
-
});
|
|
18
|
-
const body = await (0, stream_to_string_1.streamToString)(response);
|
|
19
|
-
const payload = JSON.parse(body);
|
|
20
|
-
return payload;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
exports.deserializeInputProps = deserializeInputProps;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { AwsRegion } from '../client';
|
|
2
|
-
import type { SerializedInputProps } from './constants';
|
|
3
|
-
export declare const serializeInputProps: ({ inputProps, region, type, userSpecifiedBucketName, }: {
|
|
4
|
-
inputProps: Record<string, unknown>;
|
|
5
|
-
region: AwsRegion;
|
|
6
|
-
type: 'still' | 'video-or-audio';
|
|
7
|
-
userSpecifiedBucketName: string | null;
|
|
8
|
-
}) => Promise<SerializedInputProps>;
|
|
9
|
-
export declare const deserializeInputProps: ({ serialized, region, bucketName, expectedBucketOwner, }: {
|
|
10
|
-
serialized: SerializedInputProps;
|
|
11
|
-
region: AwsRegion;
|
|
12
|
-
bucketName: string;
|
|
13
|
-
expectedBucketOwner: string;
|
|
14
|
-
}) => Promise<Record<string, unknown>>;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeInputProps = exports.serializeInputProps = void 0;
|
|
4
|
-
const get_or_create_bucket_1 = require("../api/get-or-create-bucket");
|
|
5
|
-
const io_1 = require("../functions/helpers/io");
|
|
6
|
-
const constants_1 = require("./constants");
|
|
7
|
-
const random_hash_1 = require("./random-hash");
|
|
8
|
-
const stream_to_string_1 = require("./stream-to-string");
|
|
9
|
-
const serializeInputProps = async ({ inputProps, region, type, userSpecifiedBucketName, }) => {
|
|
10
|
-
try {
|
|
11
|
-
const payload = JSON.stringify(inputProps);
|
|
12
|
-
const hash = (0, random_hash_1.randomHash)();
|
|
13
|
-
const MAX_INLINE_PAYLOAD_SIZE = type === 'still' ? 5000000 : 200000;
|
|
14
|
-
if (payload.length > MAX_INLINE_PAYLOAD_SIZE) {
|
|
15
|
-
console.warn(`Warning: inputProps are over ${Math.round(MAX_INLINE_PAYLOAD_SIZE / 1000)}KB (${Math.ceil(payload.length / 1024)}KB) in size. Uploading them to S3 to circumvent AWS Lambda payload size.`);
|
|
16
|
-
const bucketName = userSpecifiedBucketName !== null && userSpecifiedBucketName !== void 0 ? userSpecifiedBucketName : (await (0, get_or_create_bucket_1.getOrCreateBucket)({
|
|
17
|
-
region,
|
|
18
|
-
})).bucketName;
|
|
19
|
-
await (0, io_1.lambdaWriteFile)({
|
|
20
|
-
body: payload,
|
|
21
|
-
bucketName,
|
|
22
|
-
region,
|
|
23
|
-
customCredentials: null,
|
|
24
|
-
downloadBehavior: null,
|
|
25
|
-
expectedBucketOwner: null,
|
|
26
|
-
key: (0, constants_1.inputPropsKey)(hash),
|
|
27
|
-
privacy: 'public',
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
type: 'bucket-url',
|
|
31
|
-
hash,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
type: 'payload',
|
|
36
|
-
payload,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
throw new Error('Error serializing inputProps. Check it has no circular references or reduce the size if the object is big.');
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
exports.serializeInputProps = serializeInputProps;
|
|
44
|
-
const deserializeInputProps = async ({ serialized, region, bucketName, expectedBucketOwner, }) => {
|
|
45
|
-
if (serialized.type === 'payload') {
|
|
46
|
-
return JSON.parse(serialized.payload);
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const response = await (0, io_1.lambdaReadFile)({
|
|
50
|
-
bucketName,
|
|
51
|
-
expectedBucketOwner,
|
|
52
|
-
key: (0, constants_1.inputPropsKey)(serialized.hash),
|
|
53
|
-
region,
|
|
54
|
-
});
|
|
55
|
-
const body = await (0, stream_to_string_1.streamToString)(response);
|
|
56
|
-
const payload = JSON.parse(body);
|
|
57
|
-
return payload;
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
throw new Error(`Failed to parse input props that were serialized: ${err.stack}`);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
exports.deserializeInputProps = deserializeInputProps;
|