@remotion/lambda-client 4.0.363 → 4.0.365
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/cjs/app-router-webhook.d.ts +10 -0
- package/dist/cjs/apply-lifecycle.d.ts +8 -0
- package/dist/cjs/aws-clients.d.ts +12 -0
- package/dist/cjs/aws-provider.d.ts +27 -0
- package/dist/cjs/bucket-exists.d.ts +3 -0
- package/dist/cjs/call-lambda-async.d.ts +2 -0
- package/dist/cjs/call-lambda-streaming.d.ts +6 -0
- package/dist/cjs/call-lambda-sync.d.ts +2 -0
- package/dist/cjs/check-credentials.d.ts +1 -0
- package/dist/cjs/clean-items.d.ts +17 -0
- package/dist/cjs/constants.d.ts +25 -0
- package/dist/cjs/constants.js +75 -0
- package/dist/cjs/content-disposition-header.d.ts +2 -0
- package/dist/cjs/convert-to-serve-url.d.ts +6 -0
- package/dist/cjs/create-bucket.d.ts +3 -0
- package/dist/cjs/delete-file.d.ts +3 -0
- package/dist/cjs/delete-function.d.ts +7 -0
- package/dist/cjs/delete-render.d.ts +22 -0
- package/dist/cjs/encode-aws-url-params.d.ts +1 -0
- package/dist/cjs/estimate-price.d.ts +17 -0
- package/dist/cjs/express-webhook.d.ts +3 -0
- package/dist/cjs/get-account-id.d.ts +3 -0
- package/dist/cjs/get-aws-client.d.ts +32 -0
- package/dist/cjs/get-aws-urls.d.ts +25 -0
- package/dist/cjs/get-buckets.d.ts +9 -0
- package/dist/cjs/get-compositions-on-lambda.d.ts +20 -0
- package/dist/cjs/get-credentials.d.ts +9 -0
- package/dist/cjs/get-env-variable.d.ts +1 -0
- package/dist/cjs/get-function-name.d.ts +8 -0
- package/dist/cjs/get-function-version.d.ts +9 -0
- package/dist/cjs/get-functions.d.ts +10 -0
- package/dist/cjs/get-output-url-from-metadata.d.ts +3 -0
- package/dist/cjs/get-render-progress.d.ts +17 -0
- package/dist/cjs/get-s3-client.d.ts +11 -0
- package/dist/cjs/get-service-client.d.ts +25 -0
- package/dist/cjs/get-sites.d.ts +31 -0
- package/dist/cjs/head-file.d.ts +3 -0
- package/dist/cjs/index.d.ts +129 -0
- package/dist/cjs/index.js +72692 -0
- package/dist/cjs/is-cli.d.ts +2 -0
- package/dist/cjs/is-flaky-error.d.ts +1 -0
- package/dist/cjs/is-in-lambda.d.ts +1 -0
- package/dist/cjs/is-likely-to-have-aws-profile.d.ts +1 -0
- package/dist/cjs/lambda-version-string.d.ts +1 -0
- package/dist/cjs/lifecycle-rules.d.ts +12 -0
- package/dist/cjs/lifecycle.d.ts +7 -0
- package/dist/cjs/list-objects.d.ts +3 -0
- package/dist/cjs/make-lambda-payload.d.ts +59 -0
- package/dist/cjs/make-s3-url.d.ts +6 -0
- package/dist/cjs/p-limit.d.ts +1 -0
- package/dist/cjs/pages-router-webhook.d.ts +5 -0
- package/dist/cjs/parse-function-name.d.ts +8 -0
- package/dist/cjs/presign-url.d.ts +17 -0
- package/dist/cjs/price-per-1s.d.ts +37 -0
- package/dist/cjs/random-hash.d.ts +1 -0
- package/dist/cjs/read-file.d.ts +11 -0
- package/dist/cjs/regions.d.ts +3 -0
- package/dist/cjs/regions.js +80 -0
- package/dist/cjs/render-media-on-lambda.d.ts +66 -0
- package/dist/cjs/render-still-on-lambda.d.ts +61 -0
- package/dist/cjs/runtime-preference.d.ts +2 -0
- package/dist/cjs/speculate-function-name.d.ts +7 -0
- package/dist/cjs/types.d.ts +4 -0
- package/dist/cjs/validate-aws-region.d.ts +2 -0
- package/dist/cjs/validate-bucketname.d.ts +4 -0
- package/dist/cjs/validate-disk-size-in-mb.d.ts +1 -0
- package/dist/cjs/validate-lambda-codec.d.ts +2 -0
- package/dist/cjs/validate-memory-size.d.ts +1 -0
- package/dist/cjs/validate-presign-expiration.d.ts +1 -0
- package/dist/cjs/validate-serveurl.d.ts +1 -0
- package/dist/cjs/validate-webhook-signature.d.ts +5 -0
- package/dist/cjs/write-file.d.ts +5 -0
- package/dist/esm/index.mjs +64284 -13659
- package/package.json +15 -16
- package/.turbo/turbo-formatting.log +0 -4
- package/.turbo/turbo-lint.log +0 -25
- package/.turbo/turbo-make.log +0 -3
- package/bundle.ts +0 -24
- package/dist/test/concurrency-payload.test.d.ts +0 -1
- package/dist/test/concurrency-payload.test.js +0 -119
- package/dist/test/encode-aws-url.test.d.ts +0 -1
- package/dist/test/encode-aws-url.test.js +0 -8
- package/dist/test/price-calculation.test.d.ts +0 -1
- package/dist/test/price-calculation.test.js +0 -62
- package/dist/test/pricing.test.d.ts +0 -1
- package/dist/test/pricing.test.js +0 -27
- package/dist/test/request-handler.test.d.ts +0 -1
- package/dist/test/request-handler.test.js +0 -36
- package/dist/test/validate-disk-size-in-mb.test.d.ts +0 -1
- package/dist/test/validate-disk-size-in-mb.test.js +0 -14
- package/eslint.config.mjs +0 -5
- package/src/app-router-webhook.ts +0 -73
- package/src/apply-lifecycle.ts +0 -30
- package/src/aws-clients.ts +0 -75
- package/src/aws-provider.ts +0 -139
- package/src/bucket-exists.ts +0 -35
- package/src/call-lambda-async.ts +0 -43
- package/src/call-lambda-streaming.ts +0 -226
- package/src/call-lambda-sync.ts +0 -59
- package/src/check-credentials.ts +0 -51
- package/src/clean-items.ts +0 -50
- package/src/constants.ts +0 -38
- package/src/content-disposition-header.ts +0 -64
- package/src/convert-to-serve-url.ts +0 -24
- package/src/create-bucket.ts +0 -87
- package/src/delete-file.ts +0 -38
- package/src/delete-function.ts +0 -28
- package/src/delete-render.ts +0 -114
- package/src/encode-aws-url-params.ts +0 -3
- package/src/estimate-price.ts +0 -95
- package/src/express-webhook.ts +0 -57
- package/src/get-account-id.ts +0 -22
- package/src/get-aws-client.ts +0 -63
- package/src/get-aws-urls.ts +0 -85
- package/src/get-buckets.ts +0 -84
- package/src/get-compositions-on-lambda.ts +0 -111
- package/src/get-credentials.ts +0 -81
- package/src/get-env-variable.ts +0 -15
- package/src/get-function-name.ts +0 -24
- package/src/get-function-version.ts +0 -49
- package/src/get-functions.ts +0 -114
- package/src/get-output-url-from-metadata.ts +0 -23
- package/src/get-render-progress.ts +0 -66
- package/src/get-s3-client.ts +0 -26
- package/src/get-service-client.ts +0 -195
- package/src/get-sites.ts +0 -136
- package/src/head-file.ts +0 -30
- package/src/index.ts +0 -152
- package/src/is-cli.ts +0 -7
- package/src/is-flaky-error.ts +0 -104
- package/src/is-in-lambda.ts +0 -5
- package/src/is-likely-to-have-aws-profile.ts +0 -55
- package/src/lambda-version-string.ts +0 -5
- package/src/lifecycle-rules.ts +0 -119
- package/src/lifecycle.ts +0 -44
- package/src/list-objects.ts +0 -87
- package/src/make-lambda-payload.ts +0 -328
- package/src/make-s3-url.ts +0 -13
- package/src/p-limit.ts +0 -75
- package/src/pages-router-webhook.ts +0 -68
- package/src/parse-function-name.ts +0 -24
- package/src/presign-url.ts +0 -121
- package/src/price-per-1s.ts +0 -863
- package/src/random-hash.ts +0 -10
- package/src/read-file.ts +0 -35
- package/src/regions.ts +0 -48
- package/src/render-media-on-lambda.ts +0 -227
- package/src/render-still-on-lambda.ts +0 -209
- package/src/runtime-preference.ts +0 -7
- package/src/speculate-function-name.ts +0 -60
- package/src/test/concurrency-payload.test.ts +0 -121
- package/src/test/encode-aws-url.test.ts +0 -7
- package/src/test/price-calculation.test.ts +0 -62
- package/src/test/pricing.test.ts +0 -32
- package/src/test/request-handler.test.ts +0 -42
- package/src/test/validate-disk-size-in-mb.test.ts +0 -15
- package/src/types.ts +0 -7
- package/src/validate-aws-region.ts +0 -14
- package/src/validate-bucketname.ts +0 -24
- package/src/validate-disk-size-in-mb.ts +0 -37
- package/src/validate-lambda-codec.ts +0 -28
- package/src/validate-memory-size.ts +0 -31
- package/src/validate-presign-expiration.ts +0 -46
- package/src/validate-serveurl.ts +0 -9
- package/src/validate-webhook-signature.ts +0 -42
- package/src/write-file.ts +0 -108
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type {DownloadBehavior} from '@remotion/serverless-client';
|
|
2
|
-
|
|
3
|
-
// By setting the Content-Disposition header in an S3 object,
|
|
4
|
-
// you can control if the user downloads the item if you
|
|
5
|
-
// visit the link
|
|
6
|
-
|
|
7
|
-
const problematicCharacters = {
|
|
8
|
-
'%3A': ':',
|
|
9
|
-
'%2F': '/',
|
|
10
|
-
'%3F': '?',
|
|
11
|
-
'%23': '#',
|
|
12
|
-
'%5B': '[',
|
|
13
|
-
'%5D': ']',
|
|
14
|
-
'%40': '@',
|
|
15
|
-
'%21': '!',
|
|
16
|
-
'%24': '$',
|
|
17
|
-
'%26': '&',
|
|
18
|
-
'%27': "'",
|
|
19
|
-
'%28': '(',
|
|
20
|
-
'%29': ')',
|
|
21
|
-
'%2A': '*',
|
|
22
|
-
'%2B': '+',
|
|
23
|
-
'%2C': ',',
|
|
24
|
-
'%3B': ';',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type HexInfo = {
|
|
28
|
-
containsHex: boolean;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const includesHexOfUnsafeChar = (path: string): HexInfo => {
|
|
32
|
-
for (const key of Object.keys(
|
|
33
|
-
problematicCharacters,
|
|
34
|
-
) as (keyof typeof problematicCharacters)[]) {
|
|
35
|
-
if (path.includes(key)) {
|
|
36
|
-
return {containsHex: true};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {containsHex: false};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const getContentDispositionHeader = (
|
|
44
|
-
behavior: DownloadBehavior | null,
|
|
45
|
-
): string | undefined => {
|
|
46
|
-
if (behavior === null) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (behavior.type === 'play-in-browser') {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (behavior.fileName === null) {
|
|
55
|
-
return `attachment`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const {containsHex} = includesHexOfUnsafeChar(behavior.fileName);
|
|
59
|
-
if (containsHex) {
|
|
60
|
-
return `attachment; filename="${behavior.fileName}"`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return `attachment; filename="${encodeURIComponent(behavior.fileName)}"`;
|
|
64
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {DOCS_URL} from '@remotion/serverless-client';
|
|
2
|
-
import type {AwsRegion} from './regions';
|
|
3
|
-
|
|
4
|
-
export const convertToServeUrlImplementation = ({
|
|
5
|
-
urlOrId,
|
|
6
|
-
region,
|
|
7
|
-
bucketName,
|
|
8
|
-
}: {
|
|
9
|
-
urlOrId: string;
|
|
10
|
-
region: AwsRegion;
|
|
11
|
-
bucketName: string;
|
|
12
|
-
}) => {
|
|
13
|
-
if (urlOrId.startsWith('src/')) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`Remotion Lambda can only render based on a URL in the cloud. It seems like you passed a local file: ${urlOrId}. Read the setup guide for Remotion Lambda ${DOCS_URL}/docs/lambda/setup`,
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (urlOrId.startsWith('http://') || urlOrId.startsWith('https://')) {
|
|
20
|
-
return urlOrId;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return `https://${bucketName}.s3.${region}.amazonaws.com/sites/${urlOrId}/index.html`;
|
|
24
|
-
};
|
package/src/create-bucket.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateBucketCommand,
|
|
3
|
-
DeleteBucketOwnershipControlsCommand,
|
|
4
|
-
DeletePublicAccessBlockCommand,
|
|
5
|
-
PutBucketAclCommand,
|
|
6
|
-
} from '@aws-sdk/client-s3';
|
|
7
|
-
import type {ProviderSpecifics} from '@remotion/serverless-client';
|
|
8
|
-
import type {AwsProvider} from './aws-provider';
|
|
9
|
-
import {getS3Client} from './get-s3-client';
|
|
10
|
-
|
|
11
|
-
export const createBucket: ProviderSpecifics<AwsProvider>['createBucket'] =
|
|
12
|
-
async ({region, bucketName, forcePathStyle, requestHandler}) => {
|
|
13
|
-
await getS3Client({
|
|
14
|
-
region,
|
|
15
|
-
customCredentials: null,
|
|
16
|
-
forcePathStyle,
|
|
17
|
-
requestHandler,
|
|
18
|
-
}).send(
|
|
19
|
-
new CreateBucketCommand({
|
|
20
|
-
Bucket: bucketName,
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
await getS3Client({
|
|
26
|
-
region,
|
|
27
|
-
customCredentials: null,
|
|
28
|
-
forcePathStyle,
|
|
29
|
-
requestHandler,
|
|
30
|
-
}).send(
|
|
31
|
-
new DeleteBucketOwnershipControlsCommand({
|
|
32
|
-
Bucket: bucketName,
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
if ((err as Error).message.includes('Access Denied')) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
'Since April 2023, more AWS permissions are required to create an S3 bucket. You need to update your user policy to continue. See https://remotion.dev/docs/lambda/s3-public-access for instructions on how to resolve this issue.',
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
await getS3Client({
|
|
47
|
-
region,
|
|
48
|
-
customCredentials: null,
|
|
49
|
-
forcePathStyle,
|
|
50
|
-
requestHandler,
|
|
51
|
-
}).send(
|
|
52
|
-
new DeletePublicAccessBlockCommand({
|
|
53
|
-
Bucket: bucketName,
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
} catch (err) {
|
|
57
|
-
if ((err as Error).message.includes('Access Denied')) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
'PARTIAL SUCCESS: The s3:PutBucketOwnershipControls was found, but the s3:PutBucketPublicAccessBlock permission is not given. Since April 2023, more AWS permissions are required to create an S3 bucket. You need to update your user policy to continue. You need to update your user policy to continue. See https://remotion.dev/docs/lambda/s3-public-access for instructions on how to resolve this issue.',
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
throw err;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
await getS3Client({
|
|
68
|
-
region,
|
|
69
|
-
customCredentials: null,
|
|
70
|
-
forcePathStyle,
|
|
71
|
-
requestHandler,
|
|
72
|
-
}).send(
|
|
73
|
-
new PutBucketAclCommand({
|
|
74
|
-
Bucket: bucketName,
|
|
75
|
-
ACL: 'public-read',
|
|
76
|
-
}),
|
|
77
|
-
);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
if ((err as Error).message.includes('The bucket does not allow ACLs')) {
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Could not add an ACL to the bucket. This might have happened because the bucket was already successfully created before but then failed to configure correctly. We recommend to delete the bucket (${bucketName}) if it is empty and start over to fix the problem.`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
};
|
package/src/delete-file.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {DeleteObjectCommand} from '@aws-sdk/client-s3';
|
|
2
|
-
import type {
|
|
3
|
-
CustomCredentials,
|
|
4
|
-
ProviderSpecifics,
|
|
5
|
-
} from '@remotion/serverless-client';
|
|
6
|
-
import type {AwsProvider} from './aws-provider';
|
|
7
|
-
import {getS3Client} from './get-s3-client';
|
|
8
|
-
import type {AwsRegion} from './regions';
|
|
9
|
-
import type {RequestHandler} from './types';
|
|
10
|
-
|
|
11
|
-
export const lambdaDeleteFileImplementation: ProviderSpecifics<AwsProvider>['deleteFile'] =
|
|
12
|
-
async ({
|
|
13
|
-
bucketName,
|
|
14
|
-
key,
|
|
15
|
-
region,
|
|
16
|
-
customCredentials,
|
|
17
|
-
forcePathStyle,
|
|
18
|
-
requestHandler,
|
|
19
|
-
}: {
|
|
20
|
-
region: AwsRegion;
|
|
21
|
-
bucketName: string;
|
|
22
|
-
key: string;
|
|
23
|
-
customCredentials: CustomCredentials<AwsProvider> | null;
|
|
24
|
-
forcePathStyle: boolean;
|
|
25
|
-
requestHandler: RequestHandler | null;
|
|
26
|
-
}) => {
|
|
27
|
-
await getS3Client({
|
|
28
|
-
region,
|
|
29
|
-
customCredentials,
|
|
30
|
-
forcePathStyle,
|
|
31
|
-
requestHandler,
|
|
32
|
-
}).send(
|
|
33
|
-
new DeleteObjectCommand({
|
|
34
|
-
Bucket: bucketName,
|
|
35
|
-
Key: key,
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
};
|
package/src/delete-function.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {DeleteFunctionCommand} from '@aws-sdk/client-lambda';
|
|
2
|
-
import type {
|
|
3
|
-
DeleteFunction,
|
|
4
|
-
DeleteFunctionInput as GenericDeleteFunctionInput,
|
|
5
|
-
} from '@remotion/serverless-client';
|
|
6
|
-
import {getLambdaClient} from './aws-clients';
|
|
7
|
-
import type {AwsProvider} from './aws-provider';
|
|
8
|
-
import type {RequestHandler} from './types';
|
|
9
|
-
|
|
10
|
-
export type DeleteFunctionInput = GenericDeleteFunctionInput<AwsProvider> & {
|
|
11
|
-
requestHandler?: RequestHandler;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
* @description Deletes a deployed Lambda function based on its name.
|
|
16
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/deletefunction)
|
|
17
|
-
*/
|
|
18
|
-
export const deleteFunction: DeleteFunction<AwsProvider> = async ({
|
|
19
|
-
region,
|
|
20
|
-
functionName,
|
|
21
|
-
requestHandler,
|
|
22
|
-
}: DeleteFunctionInput): Promise<void> => {
|
|
23
|
-
await getLambdaClient(region, undefined, requestHandler ?? null).send(
|
|
24
|
-
new DeleteFunctionCommand({
|
|
25
|
-
FunctionName: functionName,
|
|
26
|
-
}),
|
|
27
|
-
);
|
|
28
|
-
};
|
package/src/delete-render.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type {ProviderSpecifics} from '@remotion/serverless-client';
|
|
2
|
-
import {
|
|
3
|
-
getExpectedOutName,
|
|
4
|
-
getOverallProgressFromStorage,
|
|
5
|
-
rendersPrefix,
|
|
6
|
-
type CustomCredentials,
|
|
7
|
-
} from '@remotion/serverless-client';
|
|
8
|
-
import type {AwsProvider} from './aws-provider';
|
|
9
|
-
import {awsImplementation} from './aws-provider';
|
|
10
|
-
import {cleanItems} from './clean-items';
|
|
11
|
-
import {REMOTION_BUCKET_PREFIX} from './constants';
|
|
12
|
-
import type {AwsRegion} from './regions';
|
|
13
|
-
import type {RequestHandler} from './types';
|
|
14
|
-
|
|
15
|
-
export type DeleteRenderInput = {
|
|
16
|
-
region: AwsRegion;
|
|
17
|
-
bucketName: string;
|
|
18
|
-
renderId: string;
|
|
19
|
-
customCredentials?: CustomCredentials<AwsProvider>;
|
|
20
|
-
forcePathStyle?: boolean;
|
|
21
|
-
requestHandler?: RequestHandler;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const internalDeleteRender = async (
|
|
25
|
-
input: DeleteRenderInput & {
|
|
26
|
-
providerSpecifics: ProviderSpecifics<AwsProvider>;
|
|
27
|
-
forcePathStyle: boolean;
|
|
28
|
-
},
|
|
29
|
-
) => {
|
|
30
|
-
const expectedBucketOwner = await input.providerSpecifics.getAccountId({
|
|
31
|
-
region: input.region,
|
|
32
|
-
});
|
|
33
|
-
const progress = await getOverallProgressFromStorage({
|
|
34
|
-
bucketName: input.bucketName,
|
|
35
|
-
expectedBucketOwner,
|
|
36
|
-
region: input.region,
|
|
37
|
-
renderId: input.renderId,
|
|
38
|
-
providerSpecifics: input.providerSpecifics,
|
|
39
|
-
forcePathStyle: input.forcePathStyle,
|
|
40
|
-
requestHandler: input.requestHandler,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Render did not start yet
|
|
44
|
-
if (progress.renderMetadata === null) {
|
|
45
|
-
return {freedBytes: 0};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const {key, renderBucketName, customCredentials} = getExpectedOutName({
|
|
49
|
-
renderMetadata: progress.renderMetadata,
|
|
50
|
-
bucketName: input.bucketName,
|
|
51
|
-
customCredentials: input.customCredentials ?? null,
|
|
52
|
-
bucketNamePrefix: REMOTION_BUCKET_PREFIX,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
await input.providerSpecifics.deleteFile({
|
|
56
|
-
bucketName: renderBucketName,
|
|
57
|
-
customCredentials,
|
|
58
|
-
key,
|
|
59
|
-
region: input.region,
|
|
60
|
-
forcePathStyle: input.forcePathStyle,
|
|
61
|
-
requestHandler: input.requestHandler,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
let files = await input.providerSpecifics.listObjects({
|
|
65
|
-
bucketName: input.bucketName,
|
|
66
|
-
prefix: rendersPrefix(input.renderId),
|
|
67
|
-
region: input.region,
|
|
68
|
-
expectedBucketOwner,
|
|
69
|
-
forcePathStyle: input.forcePathStyle,
|
|
70
|
-
requestHandler: input.requestHandler,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
let totalSize = 0;
|
|
74
|
-
|
|
75
|
-
while (files.length > 0) {
|
|
76
|
-
totalSize += files.reduce((a, b) => {
|
|
77
|
-
return a + (b.Size ?? 0);
|
|
78
|
-
}, 0);
|
|
79
|
-
await cleanItems({
|
|
80
|
-
list: files.map((f) => f.Key as string),
|
|
81
|
-
bucket: input.bucketName,
|
|
82
|
-
onAfterItemDeleted: () => undefined,
|
|
83
|
-
onBeforeItemDeleted: () => undefined,
|
|
84
|
-
region: input.region,
|
|
85
|
-
providerSpecifics: input.providerSpecifics,
|
|
86
|
-
forcePathStyle: input.forcePathStyle,
|
|
87
|
-
requestHandler: input.requestHandler,
|
|
88
|
-
});
|
|
89
|
-
files = await input.providerSpecifics.listObjects({
|
|
90
|
-
bucketName: input.bucketName,
|
|
91
|
-
prefix: rendersPrefix(input.renderId),
|
|
92
|
-
region: input.region,
|
|
93
|
-
expectedBucketOwner,
|
|
94
|
-
forcePathStyle: input.forcePathStyle,
|
|
95
|
-
requestHandler: input.requestHandler,
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
freedBytes: totalSize,
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/*
|
|
105
|
-
* @description Deletes a rendered video, audio or still and its associated metadata.
|
|
106
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/deleterender)
|
|
107
|
-
*/
|
|
108
|
-
export const deleteRender = (input: DeleteRenderInput) => {
|
|
109
|
-
return internalDeleteRender({
|
|
110
|
-
...input,
|
|
111
|
-
providerSpecifics: awsImplementation,
|
|
112
|
-
forcePathStyle: input.forcePathStyle ?? false,
|
|
113
|
-
});
|
|
114
|
-
};
|
package/src/estimate-price.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {MIN_EPHEMERAL_STORAGE_IN_MB} from './constants';
|
|
2
|
-
import {pricing} from './price-per-1s';
|
|
3
|
-
import type {AwsRegion} from './regions';
|
|
4
|
-
import {validateAwsRegion} from './validate-aws-region';
|
|
5
|
-
import {validateDiskSizeInMb} from './validate-disk-size-in-mb';
|
|
6
|
-
import {validateMemorySize} from './validate-memory-size';
|
|
7
|
-
|
|
8
|
-
type Miliseconds =
|
|
9
|
-
| {
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated Typo in property name. Use `durationInMilliseconds` instead.
|
|
12
|
-
*/
|
|
13
|
-
durationInMiliseconds: number;
|
|
14
|
-
}
|
|
15
|
-
| {
|
|
16
|
-
durationInMilliseconds: number;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type EstimatePriceInput = {
|
|
20
|
-
region: AwsRegion;
|
|
21
|
-
memorySizeInMb: number;
|
|
22
|
-
diskSizeInMb: number;
|
|
23
|
-
lambdasInvoked: number;
|
|
24
|
-
} & Miliseconds;
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
* @description Calculates the AWS costs incurred for AWS Lambda given the region, execution duration and memory size.
|
|
28
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/estimateprice)
|
|
29
|
-
*/
|
|
30
|
-
export const estimatePrice = ({
|
|
31
|
-
region,
|
|
32
|
-
memorySizeInMb,
|
|
33
|
-
diskSizeInMb,
|
|
34
|
-
lambdasInvoked,
|
|
35
|
-
...other
|
|
36
|
-
}: EstimatePriceInput): number => {
|
|
37
|
-
validateMemorySize(memorySizeInMb);
|
|
38
|
-
validateAwsRegion(region);
|
|
39
|
-
validateDiskSizeInMb(diskSizeInMb);
|
|
40
|
-
|
|
41
|
-
const durationInMilliseconds =
|
|
42
|
-
'durationInMiliseconds' in other
|
|
43
|
-
? other.durationInMiliseconds
|
|
44
|
-
: other.durationInMilliseconds;
|
|
45
|
-
|
|
46
|
-
if (typeof durationInMilliseconds !== 'number') {
|
|
47
|
-
throw new TypeError(
|
|
48
|
-
`Parameter 'durationInMilliseconds' must be a number but got ${typeof durationInMilliseconds}`,
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (Number.isNaN(durationInMilliseconds)) {
|
|
53
|
-
throw new TypeError(
|
|
54
|
-
`Parameter 'durationInMilliseconds' must not be NaN but it is.`,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!Number.isFinite(durationInMilliseconds)) {
|
|
59
|
-
throw new TypeError(
|
|
60
|
-
`Parameter 'durationInMilliseconds' must be finite but it is ${durationInMilliseconds}`,
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (durationInMilliseconds < 0) {
|
|
65
|
-
throw new TypeError(
|
|
66
|
-
`Parameter 'durationInMilliseconds' must be over 0 but it is ${durationInMilliseconds}.`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const durationPrice = pricing[region]['Lambda Duration-ARM'].price;
|
|
71
|
-
|
|
72
|
-
// In GB-second
|
|
73
|
-
const timeCostDollars =
|
|
74
|
-
Number(durationPrice) *
|
|
75
|
-
((memorySizeInMb * durationInMilliseconds) / 1000 / 1024);
|
|
76
|
-
|
|
77
|
-
const diskSizePrice = pricing[region]['Lambda Storage-Duration-ARM'].price;
|
|
78
|
-
|
|
79
|
-
const chargedDiskSize = Math.max(
|
|
80
|
-
0,
|
|
81
|
-
diskSizeInMb - MIN_EPHEMERAL_STORAGE_IN_MB,
|
|
82
|
-
);
|
|
83
|
-
// In GB-second
|
|
84
|
-
const diskSizeDollars =
|
|
85
|
-
chargedDiskSize *
|
|
86
|
-
Number(diskSizePrice) *
|
|
87
|
-
(durationInMilliseconds / 1000 / 1024);
|
|
88
|
-
|
|
89
|
-
const invocationCost =
|
|
90
|
-
Number(pricing[region]['Lambda Requests'].price) * lambdasInvoked;
|
|
91
|
-
|
|
92
|
-
return Number(
|
|
93
|
-
(timeCostDollars + diskSizeDollars + invocationCost).toFixed(5),
|
|
94
|
-
);
|
|
95
|
-
};
|
package/src/express-webhook.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type {Request, Response} from 'express';
|
|
2
|
-
import type {NextWebhookArgs} from './app-router-webhook';
|
|
3
|
-
import {addHeaders} from './pages-router-webhook';
|
|
4
|
-
import {validateWebhookSignature} from './validate-webhook-signature';
|
|
5
|
-
|
|
6
|
-
export const expressWebhook = (options: NextWebhookArgs) => {
|
|
7
|
-
const {testing, extraHeaders, secret, onSuccess, onTimeout, onError} =
|
|
8
|
-
options;
|
|
9
|
-
return async (req: Request, res: Response) => {
|
|
10
|
-
// add headers to enable testing
|
|
11
|
-
if (testing) {
|
|
12
|
-
const testingheaders = {
|
|
13
|
-
'Access-Control-Allow-Origin': 'https://www.remotion.dev',
|
|
14
|
-
'Access-Control-Allow-Headers':
|
|
15
|
-
'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, X-Remotion-Status, X-Remotion-Signature, X-Remotion-Mode',
|
|
16
|
-
'Access-Control-Allow-Methods': 'OPTIONS,POST',
|
|
17
|
-
};
|
|
18
|
-
addHeaders(res, testingheaders);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// add extra headers
|
|
22
|
-
addHeaders(res, extraHeaders || {});
|
|
23
|
-
|
|
24
|
-
// dont go forward if just testing
|
|
25
|
-
if (req.method === 'OPTIONS') {
|
|
26
|
-
res.status(200).end();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
// validate the webhook signature
|
|
32
|
-
validateWebhookSignature({
|
|
33
|
-
signatureHeader: req.header('X-Remotion-Signature') as string,
|
|
34
|
-
body: req.body,
|
|
35
|
-
secret,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// custom logic
|
|
39
|
-
const payload = req.body;
|
|
40
|
-
if (payload.type === 'success' && onSuccess) {
|
|
41
|
-
await onSuccess(payload);
|
|
42
|
-
} else if (payload.type === 'error' && onError) {
|
|
43
|
-
await onError(payload);
|
|
44
|
-
} else if (payload.type === 'timeout' && onTimeout) {
|
|
45
|
-
await onTimeout(payload);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// send response
|
|
49
|
-
res.status(200).json({success: true});
|
|
50
|
-
} catch (err) {
|
|
51
|
-
res.status(500).json({
|
|
52
|
-
success: false,
|
|
53
|
-
error: err instanceof Error ? err.message : String(err),
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
};
|
package/src/get-account-id.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {GetCallerIdentityCommand} from '@aws-sdk/client-sts';
|
|
2
|
-
import type {GetAccountId} from '@remotion/serverless-client';
|
|
3
|
-
import {getStsClient} from './aws-clients';
|
|
4
|
-
import type {AwsProvider} from './aws-provider';
|
|
5
|
-
import type {AwsRegion} from './regions';
|
|
6
|
-
import {validateAwsRegion} from './validate-aws-region';
|
|
7
|
-
|
|
8
|
-
export const getAccountIdImplementation: GetAccountId<
|
|
9
|
-
AwsProvider
|
|
10
|
-
> = async (options: {region: AwsRegion}) => {
|
|
11
|
-
validateAwsRegion(options.region);
|
|
12
|
-
|
|
13
|
-
const callerIdentity = await getStsClient(options.region, null).send(
|
|
14
|
-
new GetCallerIdentityCommand({}),
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
if (!callerIdentity.Account) {
|
|
18
|
-
throw new Error('Cannot get account ID');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return callerIdentity.Account;
|
|
22
|
-
};
|
package/src/get-aws-client.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as CloudWatchSDK from '@aws-sdk/client-cloudwatch-logs';
|
|
2
|
-
import * as IamSdk from '@aws-sdk/client-iam';
|
|
3
|
-
import * as LambdaSDK from '@aws-sdk/client-lambda';
|
|
4
|
-
import * as S3SDK from '@aws-sdk/client-s3';
|
|
5
|
-
import * as ServiceQuotasSDK from '@aws-sdk/client-service-quotas';
|
|
6
|
-
import * as StsSdk from '@aws-sdk/client-sts';
|
|
7
|
-
import type {CustomCredentials} from '@remotion/serverless-client';
|
|
8
|
-
import type {AwsProvider} from './aws-provider';
|
|
9
|
-
import {getServiceClient, type ServiceMapping} from './get-service-client';
|
|
10
|
-
import type {AwsRegion} from './regions';
|
|
11
|
-
import type {RequestHandler} from './types';
|
|
12
|
-
|
|
13
|
-
export type GetAwsClientInput<T extends keyof ServiceMapping> = {
|
|
14
|
-
region: AwsRegion;
|
|
15
|
-
service: T;
|
|
16
|
-
customCredentials?: CustomCredentials<AwsProvider> | null;
|
|
17
|
-
forcePathStyle?: boolean;
|
|
18
|
-
requestHandler?: RequestHandler;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type SdkMapping = {
|
|
22
|
-
s3: typeof S3SDK;
|
|
23
|
-
cloudwatch: typeof CloudWatchSDK;
|
|
24
|
-
iam: typeof IamSdk;
|
|
25
|
-
lambda: typeof LambdaSDK;
|
|
26
|
-
servicequotas: typeof ServiceQuotasSDK;
|
|
27
|
-
sts: typeof StsSdk;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type GetAwsClientOutput<T extends keyof ServiceMapping> = {
|
|
31
|
-
client: ServiceMapping[T];
|
|
32
|
-
sdk: SdkMapping[T];
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
* @description Exposes full access to the AWS SDK used by Remotion, allowing interaction with AWS infrastructure beyond provided functionalities.
|
|
37
|
-
* @see [Documentation](https://remotion.dev/docs/lambda/getawsclient)
|
|
38
|
-
*/
|
|
39
|
-
export const getAwsClient = <T extends keyof ServiceMapping>({
|
|
40
|
-
region,
|
|
41
|
-
service,
|
|
42
|
-
customCredentials,
|
|
43
|
-
forcePathStyle,
|
|
44
|
-
requestHandler,
|
|
45
|
-
}: GetAwsClientInput<T>): GetAwsClientOutput<T> => {
|
|
46
|
-
return {
|
|
47
|
-
client: getServiceClient({
|
|
48
|
-
region,
|
|
49
|
-
service,
|
|
50
|
-
customCredentials: customCredentials ?? null,
|
|
51
|
-
forcePathStyle: forcePathStyle ?? false,
|
|
52
|
-
requestHandler,
|
|
53
|
-
}),
|
|
54
|
-
sdk: {
|
|
55
|
-
lambda: LambdaSDK,
|
|
56
|
-
cloudwatch: CloudWatchSDK,
|
|
57
|
-
iam: IamSdk,
|
|
58
|
-
s3: S3SDK,
|
|
59
|
-
servicequotas: ServiceQuotasSDK,
|
|
60
|
-
sts: StsSdk,
|
|
61
|
-
}[service],
|
|
62
|
-
};
|
|
63
|
-
};
|
package/src/get-aws-urls.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
GetLoggingUrlForRendererFunction,
|
|
3
|
-
ServerlessRoutines,
|
|
4
|
-
} from '@remotion/serverless-client';
|
|
5
|
-
import type {AwsProvider} from './aws-provider';
|
|
6
|
-
import {encodeAwsUrlParams} from './encode-aws-url-params';
|
|
7
|
-
import type {AwsRegion} from './regions';
|
|
8
|
-
|
|
9
|
-
const cloudWatchUrlWithQuery = ({
|
|
10
|
-
region,
|
|
11
|
-
functionNameToUse,
|
|
12
|
-
query,
|
|
13
|
-
}: {
|
|
14
|
-
region: AwsRegion;
|
|
15
|
-
functionNameToUse: string;
|
|
16
|
-
query: string;
|
|
17
|
-
}) => {
|
|
18
|
-
return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:log-groups/log-group/$252Faws$252Flambda$252F${functionNameToUse}/log-events$3FfilterPattern$3D${encodeAwsUrlParams(
|
|
19
|
-
query,
|
|
20
|
-
)}`;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const getCloudwatchMethodUrl = ({
|
|
24
|
-
region,
|
|
25
|
-
functionName,
|
|
26
|
-
renderId,
|
|
27
|
-
rendererFunctionName,
|
|
28
|
-
method,
|
|
29
|
-
}: {
|
|
30
|
-
region: AwsRegion;
|
|
31
|
-
functionName: string;
|
|
32
|
-
method: ServerlessRoutines;
|
|
33
|
-
rendererFunctionName: string | null;
|
|
34
|
-
renderId: string;
|
|
35
|
-
}) => {
|
|
36
|
-
const functionNameToUse = rendererFunctionName ?? functionName;
|
|
37
|
-
const query = `"method=${method},renderId=${renderId}"`;
|
|
38
|
-
|
|
39
|
-
return cloudWatchUrlWithQuery({region, functionNameToUse, query});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getLambdaInsightsUrl = ({
|
|
43
|
-
region,
|
|
44
|
-
functionName,
|
|
45
|
-
}: {
|
|
46
|
-
region: AwsRegion;
|
|
47
|
-
functionName: string;
|
|
48
|
-
}) => {
|
|
49
|
-
return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#lambda-insights:functions/${functionName}`;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const getCloudwatchRendererUrl: GetLoggingUrlForRendererFunction<
|
|
53
|
-
AwsProvider
|
|
54
|
-
> = ({region, functionName, renderId, rendererFunctionName, chunk}) => {
|
|
55
|
-
const functionNameToUse = rendererFunctionName ?? functionName;
|
|
56
|
-
const query = `"method=renderer,renderId=${renderId}${
|
|
57
|
-
chunk === null ? '' : `,chunk=${chunk},`
|
|
58
|
-
}"`;
|
|
59
|
-
|
|
60
|
-
return cloudWatchUrlWithQuery({region, functionNameToUse, query});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const getS3RenderUrl = ({
|
|
64
|
-
renderId,
|
|
65
|
-
region,
|
|
66
|
-
bucketName,
|
|
67
|
-
}: {
|
|
68
|
-
renderId: string;
|
|
69
|
-
region: AwsRegion;
|
|
70
|
-
bucketName: string;
|
|
71
|
-
}) => {
|
|
72
|
-
return `https://s3.console.aws.amazon.com/s3/buckets/${bucketName}?region=${region}&prefix=renders/${renderId}/`;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const getProgressJsonUrl = ({
|
|
76
|
-
region,
|
|
77
|
-
bucketName,
|
|
78
|
-
renderId,
|
|
79
|
-
}: {
|
|
80
|
-
region: AwsRegion;
|
|
81
|
-
bucketName: string;
|
|
82
|
-
renderId: string;
|
|
83
|
-
}) => {
|
|
84
|
-
return `https://${region}.console.aws.amazon.com/s3/object/${bucketName}?region=${region}&bucketType=general&prefix=renders/${renderId}/progress.json`;
|
|
85
|
-
};
|