@remotion/lambda 4.0.23 → 4.0.25
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/make-lambda-payload.js +2 -0
- package/dist/api/render-media-on-lambda.d.ts +2 -5
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/commands/render/render.js +3 -0
- 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/helpers/validate.d.ts +4 -0
- package/dist/cli/helpers/validate.js +8 -0
- 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 +1 -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
|
@@ -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;
|
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,
|
|
@@ -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;
|
|
@@ -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/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;
|
|
@@ -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.25",
|
|
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/bundler": "4.0.
|
|
30
|
-
"remotion": "4.0.
|
|
31
|
-
"@remotion/renderer": "4.0.
|
|
32
|
-
"
|
|
29
|
+
"@remotion/bundler": "4.0.25",
|
|
30
|
+
"@remotion/cli": "4.0.25",
|
|
31
|
+
"@remotion/renderer": "4.0.25",
|
|
32
|
+
"remotion": "4.0.25"
|
|
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.25",
|
|
47
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.25"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@remotion/bundler": "4.0.
|
|
50
|
+
"@remotion/bundler": "4.0.25"
|
|
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;
|