@remotion/lambda 4.0.167 → 4.0.168
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-site.d.ts +3 -3
- package/dist/api/render-still-on-lambda.js +1 -1
- package/dist/functions/helpers/get-current-region.d.ts +1 -1
- package/dist/functions/helpers/streamify-response.d.ts +14 -7
- package/dist/functions/helpers/streamify-response.js +41 -29
- package/dist/functions/index.d.ts +4 -0
- package/dist/functions/index.js +3 -2
- package/dist/internals.d.ts +5 -5
- package/dist/shared/aws-clients.js +13 -8
- package/dist/shared/call-lambda.js +28 -3
- package/package.json +9 -9
- package/remotionlambda-arm64.zip +0 -0
- package/dist/functions/helpers/check-if-render-exists.d.ts +0 -3
- package/dist/functions/helpers/check-if-render-exists.js +0 -15
- package/dist/functions/helpers/delete-chunks.d.ts +0 -9
- package/dist/functions/helpers/delete-chunks.js +0 -25
- package/dist/functions/helpers/get-cleanup-progress.d.ts +0 -10
- package/dist/functions/helpers/get-cleanup-progress.js +0 -35
- package/dist/functions/helpers/get-encoding-metadata.d.ts +0 -7
- package/dist/functions/helpers/get-encoding-metadata.js +0 -15
- package/dist/functions/helpers/get-encoding-progress-step-size.d.ts +0 -1
- package/dist/functions/helpers/get-encoding-progress-step-size.js +0 -4
- package/dist/functions/helpers/get-files-to-delete.d.ts +0 -10
- package/dist/functions/helpers/get-files-to-delete.js +0 -52
- package/dist/functions/helpers/get-final-encoding-status.d.ts +0 -6
- package/dist/functions/helpers/get-final-encoding-status.js +0 -18
- package/dist/functions/helpers/get-folder-size.d.ts +0 -1
- package/dist/functions/helpers/get-folder-size.js +0 -8
- package/dist/functions/helpers/get-lambdas-invoked-stats.d.ts +0 -3
- package/dist/functions/helpers/get-lambdas-invoked-stats.js +0 -1
- package/dist/functions/helpers/get-post-render-data.d.ts +0 -8
- package/dist/functions/helpers/get-post-render-data.js +0 -22
- package/dist/functions/helpers/get-render-metadata.d.ts +0 -8
- package/dist/functions/helpers/get-render-metadata.js +0 -17
- package/dist/functions/helpers/get-rendered-frames-progress.d.ts +0 -8
- package/dist/functions/helpers/get-rendered-frames-progress.js +0 -37
- package/dist/functions/helpers/get-time-to-finish.d.ts +0 -5
- package/dist/functions/helpers/get-time-to-finish.js +0 -13
- package/dist/functions/helpers/streaming-payloads.d.ts +0 -19
- package/dist/functions/helpers/streaming-payloads.js +0 -25
- package/dist/functions/helpers/write-post-render-data.d.ts +0 -9
- package/dist/functions/helpers/write-post-render-data.js +0 -18
- package/dist/functions/merge.d.ts +0 -9
- package/dist/functions/merge.js +0 -61
- package/dist/shared/chunk-progress.d.ts +0 -9
- package/dist/shared/chunk-progress.js +0 -2034
- package/dist/shared/parse-chunk-key.d.ts +0 -5
- package/dist/shared/parse-chunk-key.js +0 -15
- package/dist/shared/parse-lambda-initialized-key.d.ts +0 -5
- package/dist/shared/parse-lambda-initialized-key.js +0 -15
|
@@ -59,11 +59,11 @@ export declare const internalDeploySite: (args_0: MandatoryParameters & {
|
|
|
59
59
|
getValue: ({ commandLine }: {
|
|
60
60
|
commandLine: Record<string, unknown>;
|
|
61
61
|
}) => {
|
|
62
|
-
value: "
|
|
62
|
+
value: "error" | "verbose" | "info" | "warn";
|
|
63
63
|
source: string;
|
|
64
64
|
};
|
|
65
|
-
setConfig: (newLogLevel: "
|
|
66
|
-
type: "
|
|
65
|
+
setConfig: (newLogLevel: "error" | "verbose" | "info" | "warn") => void;
|
|
66
|
+
type: "error" | "verbose" | "info" | "warn";
|
|
67
67
|
};
|
|
68
68
|
readonly throwIfSiteExists: {
|
|
69
69
|
cliFlag: string;
|
|
@@ -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";
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Writable } from 'stream';
|
|
4
|
+
type Chunk = {
|
|
5
|
+
PayloadChunk: {
|
|
6
|
+
Payload: string | Buffer | null;
|
|
7
|
+
};
|
|
8
|
+
InvokeComplete: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class ResponseStream extends Writable {
|
|
11
|
+
private queue;
|
|
12
|
+
private waitingResolve;
|
|
5
13
|
private response;
|
|
6
|
-
_contentType?: string;
|
|
7
|
-
_isBase64Encoded?: boolean;
|
|
8
14
|
constructor();
|
|
9
|
-
_write(chunk:
|
|
15
|
+
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
16
|
+
_finish(): void;
|
|
10
17
|
getBufferedData(): Buffer;
|
|
11
|
-
|
|
12
|
-
setIsBase64Encoded(isBase64Encoded: boolean): void;
|
|
18
|
+
[Symbol.asyncIterator](): AsyncGenerator<Chunk, void, void>;
|
|
13
19
|
}
|
|
14
20
|
export declare function streamifyResponse(handler: Function): Function;
|
|
21
|
+
export {};
|
|
@@ -2,33 +2,58 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.streamifyResponse = exports.ResponseStream = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
class ResponseStream extends stream_1.
|
|
5
|
+
class ResponseStream extends stream_1.Writable {
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
|
+
this.queue = [];
|
|
9
|
+
this.waitingResolve = [];
|
|
8
10
|
this.response = [];
|
|
9
11
|
}
|
|
10
12
|
_write(chunk, encoding, callback) {
|
|
13
|
+
const data = Buffer.from(chunk, encoding);
|
|
14
|
+
const resolve = this.waitingResolve.shift();
|
|
15
|
+
if (resolve) {
|
|
16
|
+
resolve({ PayloadChunk: { Payload: data }, InvokeComplete: false });
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.queue.push({ PayloadChunk: { Payload: data }, InvokeComplete: false });
|
|
20
|
+
}
|
|
11
21
|
this.response.push(Buffer.from(chunk, encoding));
|
|
12
22
|
callback();
|
|
13
23
|
}
|
|
24
|
+
_finish() {
|
|
25
|
+
const resolve = this.waitingResolve.shift();
|
|
26
|
+
if (resolve) {
|
|
27
|
+
resolve({ PayloadChunk: { Payload: null }, InvokeComplete: true });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.queue.push({ PayloadChunk: { Payload: null }, InvokeComplete: true });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
14
33
|
getBufferedData() {
|
|
15
34
|
return Buffer.concat(this.response);
|
|
16
35
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
36
|
+
async *[Symbol.asyncIterator]() {
|
|
37
|
+
while (true) {
|
|
38
|
+
if (this.queue.length > 0) {
|
|
39
|
+
yield this.queue.shift();
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Wait for new data to be written
|
|
43
|
+
yield new Promise((resolve) => {
|
|
44
|
+
this.waitingResolve.push((data) => {
|
|
45
|
+
Promise.resolve(data).then((d) => {
|
|
46
|
+
if (d) {
|
|
47
|
+
resolve(d);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
22
54
|
}
|
|
23
55
|
}
|
|
24
56
|
exports.ResponseStream = ResponseStream;
|
|
25
|
-
function patchArgs(argList) {
|
|
26
|
-
if (!(argList[1] instanceof ResponseStream)) {
|
|
27
|
-
const responseStream = new ResponseStream();
|
|
28
|
-
argList.splice(1, 0, responseStream);
|
|
29
|
-
}
|
|
30
|
-
return argList[1];
|
|
31
|
-
}
|
|
32
57
|
function streamifyResponse(handler) {
|
|
33
58
|
// Check if we are inside Lambda
|
|
34
59
|
if (process.env.AWS_LAMBDA_FUNCTION_VERSION &&
|
|
@@ -38,21 +63,8 @@ function streamifyResponse(handler) {
|
|
|
38
63
|
// @ts-expect-error
|
|
39
64
|
return awslambda.streamifyResponse(handler);
|
|
40
65
|
}
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await target(...argList);
|
|
45
|
-
return {
|
|
46
|
-
EventStream: [
|
|
47
|
-
{
|
|
48
|
-
PayloadChunk: {
|
|
49
|
-
Payload: responseStream.getBufferedData(),
|
|
50
|
-
},
|
|
51
|
-
InvokeComplete: true,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
});
|
|
66
|
+
return () => {
|
|
67
|
+
throw new Error('Lambda not detected');
|
|
68
|
+
};
|
|
57
69
|
}
|
|
58
70
|
exports.streamifyResponse = streamifyResponse;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { LambdaPayload } from '../shared/constants';
|
|
2
|
+
import type { RequestContext } from './helpers/request-context';
|
|
3
|
+
import type { ResponseStream } from './helpers/streamify-response';
|
|
1
4
|
export type OrError<T> = T | {
|
|
2
5
|
type: 'error';
|
|
3
6
|
message: string;
|
|
4
7
|
stack: string;
|
|
5
8
|
};
|
|
9
|
+
export declare const routine: (params: LambdaPayload, responseStream: ResponseStream, context: RequestContext) => Promise<void>;
|
|
6
10
|
export declare const handler: Function;
|
package/dist/functions/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handler = void 0;
|
|
3
|
+
exports.handler = exports.routine = void 0;
|
|
4
4
|
const renderer_1 = require("@remotion/renderer");
|
|
5
5
|
const constants_1 = require("../shared/constants");
|
|
6
6
|
const compositions_1 = require("./compositions");
|
|
@@ -183,4 +183,5 @@ const routine = async (params, responseStream, context) => {
|
|
|
183
183
|
await responseWriter.end();
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
|
-
exports.
|
|
186
|
+
exports.routine = routine;
|
|
187
|
+
exports.handler = (0, streamify_response_1.streamifyResponse)(exports.routine);
|
package/dist/internals.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const LambdaInternals: {
|
|
2
|
-
executeCommand: (args: string[], remotionRoot: string, logLevel: "
|
|
2
|
+
executeCommand: (args: string[], remotionRoot: string, logLevel: "error" | "verbose" | "info" | "warn") => Promise<void>;
|
|
3
3
|
makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, encodingMaxRate, encodingBufferSize, downloadBehavior, muted, overwrite, jpegQuality, offthreadVideoCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, }: import("./api/make-lambda-payload").InnerRenderMediaOnLambdaInput) => Promise<import("./defaults").LambdaStartPayload>;
|
|
4
4
|
getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, logLevel, }: import("./client").GetRenderProgressInput) => import("./defaults").LambdaStatusPayload;
|
|
5
5
|
makeLambdaRenderStillPayload: ({ serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, }: import("./api/render-still-on-lambda").RenderStillOnLambdaNonNullInput) => Promise<{
|
|
@@ -14,7 +14,7 @@ export declare const LambdaInternals: {
|
|
|
14
14
|
maxRetries: number;
|
|
15
15
|
frame: number;
|
|
16
16
|
privacy: import("./defaults").Privacy;
|
|
17
|
-
logLevel: "
|
|
17
|
+
logLevel: "error" | "verbose" | "info" | "warn";
|
|
18
18
|
outName: import("./defaults").OutNameInput | null;
|
|
19
19
|
timeoutInMilliseconds: number;
|
|
20
20
|
chromiumOptions: import("@remotion/renderer").ChromiumOptions;
|
|
@@ -57,11 +57,11 @@ export declare const LambdaInternals: {
|
|
|
57
57
|
getValue: ({ commandLine }: {
|
|
58
58
|
commandLine: Record<string, unknown>;
|
|
59
59
|
}) => {
|
|
60
|
-
value: "
|
|
60
|
+
value: "error" | "verbose" | "info" | "warn";
|
|
61
61
|
source: string;
|
|
62
62
|
};
|
|
63
|
-
setConfig: (newLogLevel: "
|
|
64
|
-
type: "
|
|
63
|
+
setConfig: (newLogLevel: "error" | "verbose" | "info" | "warn") => void;
|
|
64
|
+
type: "error" | "verbose" | "info" | "warn";
|
|
65
65
|
};
|
|
66
66
|
readonly throwIfSiteExists: {
|
|
67
67
|
cliFlag: string;
|
|
@@ -126,6 +126,13 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
|
|
|
126
126
|
});
|
|
127
127
|
if (!_clients[key]) {
|
|
128
128
|
(0, check_credentials_1.checkCredentials)();
|
|
129
|
+
const lambdaOptions = service === 'lambda'
|
|
130
|
+
? {
|
|
131
|
+
httpsAgent: {
|
|
132
|
+
maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER * 2,
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: undefined;
|
|
129
136
|
const client = customCredentials
|
|
130
137
|
? new Client({
|
|
131
138
|
region: (_a = customCredentials.region) !== null && _a !== void 0 ? _a : 'us-east-1',
|
|
@@ -136,19 +143,17 @@ const getServiceClient = ({ region, service, customCredentials, }) => {
|
|
|
136
143
|
}
|
|
137
144
|
: undefined,
|
|
138
145
|
endpoint: customCredentials.endpoint,
|
|
146
|
+
requestHandler: lambdaOptions,
|
|
139
147
|
})
|
|
140
148
|
: process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK
|
|
141
|
-
? new Client({
|
|
149
|
+
? new Client({
|
|
150
|
+
region,
|
|
151
|
+
requestHandler: lambdaOptions,
|
|
152
|
+
})
|
|
142
153
|
: new Client({
|
|
143
154
|
region,
|
|
144
155
|
credentials: getCredentials(),
|
|
145
|
-
requestHandler:
|
|
146
|
-
? {
|
|
147
|
-
httpsAgent: {
|
|
148
|
-
maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER + 50,
|
|
149
|
-
},
|
|
150
|
-
}
|
|
151
|
-
: undefined,
|
|
156
|
+
requestHandler: lambdaOptions,
|
|
152
157
|
});
|
|
153
158
|
if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {
|
|
154
159
|
return client;
|
|
@@ -37,7 +37,8 @@ const callLambdaWithStreaming = async (options) => {
|
|
|
37
37
|
if (options.retriesRemaining === 0) {
|
|
38
38
|
throw err;
|
|
39
39
|
}
|
|
40
|
-
if (!err.message.includes(INVALID_JSON_MESSAGE)
|
|
40
|
+
if (!err.message.includes(INVALID_JSON_MESSAGE) &&
|
|
41
|
+
!err.message.includes(LAMBDA_STREAM_STALL)) {
|
|
41
42
|
throw err;
|
|
42
43
|
}
|
|
43
44
|
return (0, exports.callLambdaWithStreaming)({
|
|
@@ -62,11 +63,34 @@ const callLambdaWithoutRetry = async ({ functionName, type, payload, region, tim
|
|
|
62
63
|
throw new Error(`Invalid JSON (${type}): ${JSON.stringify(decoded)}`);
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const STREAM_STALL_TIMEOUT = 7000;
|
|
67
|
+
const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
|
|
68
|
+
const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
|
|
69
|
+
const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
|
|
67
70
|
FunctionName: functionName,
|
|
68
71
|
Payload: JSON.stringify({ type, ...payload }),
|
|
69
72
|
}));
|
|
73
|
+
let cleanup = () => undefined;
|
|
74
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
75
|
+
const int = setTimeout(() => {
|
|
76
|
+
reject(new Error(LAMBDA_STREAM_STALL));
|
|
77
|
+
}, STREAM_STALL_TIMEOUT);
|
|
78
|
+
cleanup = () => {
|
|
79
|
+
clearTimeout(int);
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
const res = await Promise.race([resProm, timeout]);
|
|
83
|
+
cleanup();
|
|
84
|
+
return res;
|
|
85
|
+
};
|
|
86
|
+
const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
|
|
87
|
+
const res = await invokeStreamOrTimeout({
|
|
88
|
+
functionName,
|
|
89
|
+
payload,
|
|
90
|
+
region,
|
|
91
|
+
timeoutInTest,
|
|
92
|
+
type,
|
|
93
|
+
});
|
|
70
94
|
const { onData, clear } = (0, streaming_1.makeStreamer)((status, messageTypeId, data) => {
|
|
71
95
|
const messageType = (0, streaming_2.messageTypeIdToMessageType)(messageTypeId);
|
|
72
96
|
const innerPayload = streaming_2.formatMap[messageType] === 'json'
|
|
@@ -97,6 +121,7 @@ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload
|
|
|
97
121
|
}
|
|
98
122
|
throw new Error(`Lambda function ${functionName} failed with error code ${event.InvokeComplete.ErrorCode}: ${event.InvokeComplete.ErrorDetails}. See ${logs} to see the logs of this invocation.`);
|
|
99
123
|
}
|
|
124
|
+
break;
|
|
100
125
|
}
|
|
101
126
|
}
|
|
102
127
|
clear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/lambda",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.168",
|
|
4
4
|
"description": "Distributed renderer for Remotion based on AWS Lambda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"@aws-sdk/s3-request-presigner": "3.583.0",
|
|
23
23
|
"mime-types": "2.1.34",
|
|
24
24
|
"zod": "3.22.3",
|
|
25
|
-
"@remotion/bundler": "4.0.
|
|
26
|
-
"@remotion/
|
|
27
|
-
"@remotion/
|
|
28
|
-
"remotion": "4.0.
|
|
29
|
-
"
|
|
25
|
+
"@remotion/bundler": "4.0.168",
|
|
26
|
+
"@remotion/cli": "4.0.168",
|
|
27
|
+
"@remotion/streaming": "4.0.168",
|
|
28
|
+
"@remotion/renderer": "4.0.168",
|
|
29
|
+
"remotion": "4.0.168"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@jonny/eslint-config": "3.0.281",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"ts-node": "10.9.2",
|
|
43
43
|
"vitest": "0.31.1",
|
|
44
44
|
"zip-lib": "^0.7.2",
|
|
45
|
-
"@remotion/bundler": "4.0.
|
|
46
|
-
"@remotion/compositor-linux-arm64-gnu": "4.0.
|
|
45
|
+
"@remotion/bundler": "4.0.168",
|
|
46
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.168"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@remotion/bundler": "4.0.
|
|
49
|
+
"@remotion/bundler": "4.0.168"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
package/remotionlambda-arm64.zip
CHANGED
|
Binary file
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkIfRenderExists = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const checkIfRenderExists = (contents, renderId, bucketName, region) => {
|
|
6
|
-
const initializedExists = Boolean(contents.find((c) => {
|
|
7
|
-
var _a;
|
|
8
|
-
return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith((0, constants_1.initalizedMetadataKey)(renderId));
|
|
9
|
-
}));
|
|
10
|
-
if (!initializedExists) {
|
|
11
|
-
// ! Error message is checked in progress handler and will be retried. Make sure to update
|
|
12
|
-
throw new TypeError(`No render with ID "${renderId}" found in bucket ${bucketName} and region ${region}`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.checkIfRenderExists = checkIfRenderExists;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
3
|
-
import type { CleanupJob } from './get-files-to-delete';
|
|
4
|
-
export declare const cleanupFiles: ({ bucket, region, contents, jobs, }: {
|
|
5
|
-
bucket: string;
|
|
6
|
-
region: AwsRegion;
|
|
7
|
-
contents: _Object[];
|
|
8
|
-
jobs: CleanupJob[];
|
|
9
|
-
}) => Promise<number>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cleanupFiles = void 0;
|
|
4
|
-
const clean_items_1 = require("../../api/clean-items");
|
|
5
|
-
const cleanupFiles = async ({ bucket, region, contents, jobs, }) => {
|
|
6
|
-
const start = Date.now();
|
|
7
|
-
await (0, clean_items_1.cleanItems)({
|
|
8
|
-
bucket,
|
|
9
|
-
region,
|
|
10
|
-
list: jobs.map((item) => {
|
|
11
|
-
var _a;
|
|
12
|
-
if (item.type === 'exact') {
|
|
13
|
-
return item.name;
|
|
14
|
-
}
|
|
15
|
-
if (item.type === 'prefix') {
|
|
16
|
-
return (_a = contents.find((c) => { var _a; return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(item.name); })) === null || _a === void 0 ? void 0 : _a.Key;
|
|
17
|
-
}
|
|
18
|
-
throw new Error('unexpected in deleteChunks()');
|
|
19
|
-
}),
|
|
20
|
-
onAfterItemDeleted: () => undefined,
|
|
21
|
-
onBeforeItemDeleted: () => undefined,
|
|
22
|
-
});
|
|
23
|
-
return Date.now() - start;
|
|
24
|
-
};
|
|
25
|
-
exports.cleanupFiles = cleanupFiles;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { CleanupInfo } from '../../shared/constants';
|
|
3
|
-
export declare const getCleanupProgress: ({ contents, output, chunkCount, renderId, hasAudio, hasVideo, }: {
|
|
4
|
-
contents: _Object[];
|
|
5
|
-
output: string | null;
|
|
6
|
-
chunkCount: number;
|
|
7
|
-
renderId: string;
|
|
8
|
-
hasAudio: boolean;
|
|
9
|
-
hasVideo: boolean;
|
|
10
|
-
}) => null | CleanupInfo;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCleanupProgress = void 0;
|
|
4
|
-
const get_files_to_delete_1 = require("./get-files-to-delete");
|
|
5
|
-
const getCleanupProgress = ({ contents, output, chunkCount, renderId, hasAudio, hasVideo, }) => {
|
|
6
|
-
if (output === null) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const filesToDelete = (0, get_files_to_delete_1.getFilesToDelete)({
|
|
10
|
-
chunkCount,
|
|
11
|
-
renderId,
|
|
12
|
-
hasAudio,
|
|
13
|
-
hasVideo,
|
|
14
|
-
});
|
|
15
|
-
const filesStillThere = contents.filter((c) => {
|
|
16
|
-
return filesToDelete.find((f) => {
|
|
17
|
-
var _a;
|
|
18
|
-
if (f.type === 'exact') {
|
|
19
|
-
return f.name === c.Key;
|
|
20
|
-
}
|
|
21
|
-
if (f.type === 'prefix') {
|
|
22
|
-
return (_a = c.Key) === null || _a === void 0 ? void 0 : _a.startsWith(f.name);
|
|
23
|
-
}
|
|
24
|
-
throw new Error('Unexpected in getCleanupProgress');
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
const filesDeleted = Math.max(0, filesToDelete.length - filesStillThere.length);
|
|
28
|
-
return {
|
|
29
|
-
minFilesToDelete: filesToDelete.length,
|
|
30
|
-
filesDeleted,
|
|
31
|
-
// We don't know. Only if post render data is saved, we know the timing
|
|
32
|
-
doneIn: null,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
exports.getCleanupProgress = getCleanupProgress;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { _Object } from '@aws-sdk/client-s3';
|
|
2
|
-
import type { EncodingProgress } from '../../defaults';
|
|
3
|
-
export declare const getEncodingMetadata: ({ exists, frameCount, stepSize, }: {
|
|
4
|
-
exists: _Object | undefined;
|
|
5
|
-
frameCount: number;
|
|
6
|
-
stepSize: number;
|
|
7
|
-
}) => EncodingProgress | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEncodingMetadata = void 0;
|
|
4
|
-
const chunk_progress_1 = require("../../shared/chunk-progress");
|
|
5
|
-
const getEncodingMetadata = ({ exists, frameCount, stepSize, }) => {
|
|
6
|
-
if (!exists) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const framesEncoded = (0, chunk_progress_1.getProgressOfChunk)(exists.ETag);
|
|
10
|
-
// We only report every 100 frames encoded so that we are able to report up to 2000 * 100 ETags => 200000 frames
|
|
11
|
-
return {
|
|
12
|
-
framesEncoded: Math.min(frameCount, framesEncoded * stepSize),
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
exports.getEncodingMetadata = getEncodingMetadata;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const getEncodingProgressStepSize: (totalFrames: number) => number;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type CleanupJob = {
|
|
2
|
-
name: string;
|
|
3
|
-
type: 'exact' | 'prefix';
|
|
4
|
-
};
|
|
5
|
-
export declare const getFilesToDelete: ({ chunkCount, renderId, hasVideo, hasAudio, }: {
|
|
6
|
-
chunkCount: number;
|
|
7
|
-
renderId: string;
|
|
8
|
-
hasVideo: boolean;
|
|
9
|
-
hasAudio: boolean;
|
|
10
|
-
}) => CleanupJob[];
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFilesToDelete = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const getFilesToDelete = ({ chunkCount, renderId, hasVideo, hasAudio, }) => {
|
|
6
|
-
const videoChunks = hasVideo
|
|
7
|
-
? new Array(chunkCount).fill(true).map((_x, i) => (0, constants_1.chunkKeyForIndex)({
|
|
8
|
-
index: i,
|
|
9
|
-
renderId,
|
|
10
|
-
type: 'video',
|
|
11
|
-
}))
|
|
12
|
-
: [];
|
|
13
|
-
const audioChunks = hasAudio
|
|
14
|
-
? new Array(chunkCount).fill(true).map((_x, i) => (0, constants_1.chunkKeyForIndex)({
|
|
15
|
-
index: i,
|
|
16
|
-
renderId,
|
|
17
|
-
type: 'audio',
|
|
18
|
-
}))
|
|
19
|
-
: [];
|
|
20
|
-
const lambdaTimings = new Array(chunkCount)
|
|
21
|
-
.fill(true)
|
|
22
|
-
.map((_x, i) => (0, constants_1.lambdaTimingsPrefixForChunk)(renderId, i));
|
|
23
|
-
return [
|
|
24
|
-
{
|
|
25
|
-
name: (0, constants_1.lambdaChunkInitializedPrefix)(renderId),
|
|
26
|
-
type: 'prefix',
|
|
27
|
-
},
|
|
28
|
-
...videoChunks.map((i) => {
|
|
29
|
-
return {
|
|
30
|
-
name: i,
|
|
31
|
-
type: 'exact',
|
|
32
|
-
};
|
|
33
|
-
}),
|
|
34
|
-
...audioChunks.map((i) => {
|
|
35
|
-
return {
|
|
36
|
-
name: i,
|
|
37
|
-
type: 'exact',
|
|
38
|
-
};
|
|
39
|
-
}),
|
|
40
|
-
...lambdaTimings.map((i) => {
|
|
41
|
-
return {
|
|
42
|
-
name: i,
|
|
43
|
-
type: 'prefix',
|
|
44
|
-
};
|
|
45
|
-
}),
|
|
46
|
-
{
|
|
47
|
-
name: (0, constants_1.encodingProgressKey)(renderId),
|
|
48
|
-
type: 'exact',
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
};
|
|
52
|
-
exports.getFilesToDelete = getFilesToDelete;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EncodingProgress, RenderMetadata } from '../../shared/constants';
|
|
2
|
-
export declare const getFinalEncodingStatus: ({ encodingProgress, renderMetadata, outputFileExists, }: {
|
|
3
|
-
encodingProgress: EncodingProgress | null;
|
|
4
|
-
renderMetadata: RenderMetadata | null;
|
|
5
|
-
outputFileExists: boolean;
|
|
6
|
-
}) => EncodingProgress | null;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFinalEncodingStatus = void 0;
|
|
4
|
-
const getFinalEncodingStatus = ({ encodingProgress, renderMetadata, outputFileExists, }) => {
|
|
5
|
-
if (!renderMetadata) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
if (encodingProgress) {
|
|
9
|
-
return encodingProgress;
|
|
10
|
-
}
|
|
11
|
-
if (outputFileExists) {
|
|
12
|
-
return {
|
|
13
|
-
framesEncoded: renderMetadata.videoConfig.durationInFrames,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
|
-
exports.getFinalEncodingStatus = getFinalEncodingStatus;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getFolderSizeRecursively(folder: string): number;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFolderSizeRecursively = void 0;
|
|
4
|
-
const get_files_in_folder_1 = require("./get-files-in-folder");
|
|
5
|
-
function getFolderSizeRecursively(folder) {
|
|
6
|
-
return (0, get_files_in_folder_1.getFolderFiles)(folder).reduce((a, b) => a + b.size, 0);
|
|
7
|
-
}
|
|
8
|
-
exports.getFolderSizeRecursively = getFolderSizeRecursively;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { AwsRegion } from '../../pricing/aws-regions';
|
|
2
|
-
import type { PostRenderData } from '../../shared/constants';
|
|
3
|
-
export declare const getPostRenderData: ({ bucketName, renderId, region, expectedBucketOwner, }: {
|
|
4
|
-
bucketName: string;
|
|
5
|
-
renderId: string;
|
|
6
|
-
region: AwsRegion;
|
|
7
|
-
expectedBucketOwner: string;
|
|
8
|
-
}) => Promise<PostRenderData | null>;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPostRenderData = void 0;
|
|
4
|
-
const constants_1 = require("../../shared/constants");
|
|
5
|
-
const stream_to_string_1 = require("../../shared/stream-to-string");
|
|
6
|
-
const io_1 = require("./io");
|
|
7
|
-
const getPostRenderData = async ({ bucketName, renderId, region, expectedBucketOwner, }) => {
|
|
8
|
-
try {
|
|
9
|
-
const data = await (0, io_1.lambdaReadFile)({
|
|
10
|
-
bucketName,
|
|
11
|
-
key: (0, constants_1.postRenderDataKey)(renderId),
|
|
12
|
-
region,
|
|
13
|
-
expectedBucketOwner,
|
|
14
|
-
});
|
|
15
|
-
return JSON.parse(await (0, stream_to_string_1.streamToString)(data));
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
// Does not exist
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.getPostRenderData = getPostRenderData;
|