@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
package/src/lifecycle-rules.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DeleteBucketLifecycleCommand,
|
|
3
|
-
PutBucketLifecycleConfigurationCommand,
|
|
4
|
-
} from '@aws-sdk/client-s3';
|
|
5
|
-
import type {CustomCredentials} from '@remotion/serverless-client';
|
|
6
|
-
import {createLifeCycleInput, deleteLifeCycleInput} from './apply-lifecycle';
|
|
7
|
-
import type {AwsProvider} from './aws-provider';
|
|
8
|
-
import {getS3Client} from './get-s3-client';
|
|
9
|
-
import {getLifeCycleRules} from './lifecycle';
|
|
10
|
-
import type {AwsRegion} from './regions';
|
|
11
|
-
import type {RequestHandler} from './types';
|
|
12
|
-
|
|
13
|
-
const createLCRules = async ({
|
|
14
|
-
bucketName,
|
|
15
|
-
region,
|
|
16
|
-
customCredentials,
|
|
17
|
-
forcePathStyle,
|
|
18
|
-
requestHandler,
|
|
19
|
-
}: {
|
|
20
|
-
bucketName: string;
|
|
21
|
-
region: AwsRegion;
|
|
22
|
-
customCredentials: CustomCredentials<AwsProvider> | null;
|
|
23
|
-
forcePathStyle: boolean;
|
|
24
|
-
requestHandler: RequestHandler | null;
|
|
25
|
-
}) => {
|
|
26
|
-
const lcRules = getLifeCycleRules();
|
|
27
|
-
// create the lifecyle rules
|
|
28
|
-
const createCommandInput = createLifeCycleInput({
|
|
29
|
-
bucketName,
|
|
30
|
-
lcRules,
|
|
31
|
-
});
|
|
32
|
-
const createCommand = new PutBucketLifecycleConfigurationCommand(
|
|
33
|
-
createCommandInput,
|
|
34
|
-
);
|
|
35
|
-
try {
|
|
36
|
-
await getS3Client({
|
|
37
|
-
region,
|
|
38
|
-
customCredentials,
|
|
39
|
-
forcePathStyle,
|
|
40
|
-
requestHandler,
|
|
41
|
-
}).send(createCommand);
|
|
42
|
-
} catch (err) {
|
|
43
|
-
if ((err as Error).stack?.includes('AccessDenied')) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
`You don't have the required permissions to create lifecycle rules on the bucket "${bucketName}", but the "enableFolderExpiry" was set to true. Ensure that your user has the "s3:PutLifecycleConfiguration" permission.`,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const deleteLCRules = async ({
|
|
52
|
-
bucketName,
|
|
53
|
-
region,
|
|
54
|
-
customCredentials,
|
|
55
|
-
forcePathStyle,
|
|
56
|
-
requestHandler,
|
|
57
|
-
}: {
|
|
58
|
-
bucketName: string;
|
|
59
|
-
region: AwsRegion;
|
|
60
|
-
customCredentials: CustomCredentials<AwsProvider> | null;
|
|
61
|
-
forcePathStyle: boolean;
|
|
62
|
-
requestHandler: RequestHandler | null;
|
|
63
|
-
}) => {
|
|
64
|
-
const deleteCommandInput = deleteLifeCycleInput({
|
|
65
|
-
bucketName,
|
|
66
|
-
});
|
|
67
|
-
try {
|
|
68
|
-
await getS3Client({
|
|
69
|
-
region,
|
|
70
|
-
customCredentials,
|
|
71
|
-
forcePathStyle,
|
|
72
|
-
requestHandler,
|
|
73
|
-
}).send(new DeleteBucketLifecycleCommand(deleteCommandInput));
|
|
74
|
-
} catch (err) {
|
|
75
|
-
if ((err as Error).stack?.includes('AccessDenied')) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
`You don't have the required permissions to delete lifecycle rules on the bucket "${bucketName}", but the "enableFolderExpiry" option was set to "false". Ensure that your user has the "s3:PutLifecycleConfiguration" permission. Set "enableFolderExpiry" to "null" to not overwrite any existing lifecycle rules.`,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const applyLifeCyleOperation = async ({
|
|
84
|
-
enableFolderExpiry,
|
|
85
|
-
bucketName,
|
|
86
|
-
region,
|
|
87
|
-
customCredentials,
|
|
88
|
-
forcePathStyle,
|
|
89
|
-
requestHandler,
|
|
90
|
-
}: {
|
|
91
|
-
enableFolderExpiry: boolean | null;
|
|
92
|
-
bucketName: string;
|
|
93
|
-
region: AwsRegion;
|
|
94
|
-
customCredentials: CustomCredentials<AwsProvider> | null;
|
|
95
|
-
forcePathStyle: boolean;
|
|
96
|
-
requestHandler: RequestHandler | null;
|
|
97
|
-
}) => {
|
|
98
|
-
if (enableFolderExpiry === null) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (enableFolderExpiry === true) {
|
|
103
|
-
await createLCRules({
|
|
104
|
-
bucketName,
|
|
105
|
-
region,
|
|
106
|
-
customCredentials,
|
|
107
|
-
forcePathStyle,
|
|
108
|
-
requestHandler,
|
|
109
|
-
});
|
|
110
|
-
} else {
|
|
111
|
-
await deleteLCRules({
|
|
112
|
-
bucketName,
|
|
113
|
-
region,
|
|
114
|
-
customCredentials,
|
|
115
|
-
forcePathStyle,
|
|
116
|
-
requestHandler,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
};
|
package/src/lifecycle.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type {LifecycleRule} from '@aws-sdk/client-s3';
|
|
2
|
-
import type {
|
|
3
|
-
CloudProvider,
|
|
4
|
-
DeleteAfter,
|
|
5
|
-
ProviderSpecifics,
|
|
6
|
-
} from '@remotion/serverless-client';
|
|
7
|
-
import {expiryDays, truthy} from '@remotion/serverless-client';
|
|
8
|
-
|
|
9
|
-
const getEnabledLifeCycleRule = ({
|
|
10
|
-
key,
|
|
11
|
-
value,
|
|
12
|
-
}: {
|
|
13
|
-
key: string;
|
|
14
|
-
value: number;
|
|
15
|
-
}): LifecycleRule => {
|
|
16
|
-
return {
|
|
17
|
-
Expiration: {
|
|
18
|
-
Days: value,
|
|
19
|
-
},
|
|
20
|
-
Filter: {
|
|
21
|
-
Prefix: `renders/${key}`,
|
|
22
|
-
},
|
|
23
|
-
ID: `delete-after-${key}`,
|
|
24
|
-
Status: 'Enabled',
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getLifeCycleRules = (): LifecycleRule[] => {
|
|
29
|
-
return Object.entries(expiryDays).map(([key, value]) =>
|
|
30
|
-
getEnabledLifeCycleRule({key, value}),
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const generateRandomHashWithLifeCycleRule = <
|
|
35
|
-
Provider extends CloudProvider,
|
|
36
|
-
>({
|
|
37
|
-
deleteAfter,
|
|
38
|
-
randomHashFn,
|
|
39
|
-
}: {
|
|
40
|
-
deleteAfter: DeleteAfter | null;
|
|
41
|
-
randomHashFn: ProviderSpecifics<Provider>['randomHash'];
|
|
42
|
-
}) => {
|
|
43
|
-
return [deleteAfter, randomHashFn()].filter(truthy).join('-');
|
|
44
|
-
};
|
package/src/list-objects.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {ListObjectsV2Command} from '@aws-sdk/client-s3';
|
|
2
|
-
import type {ProviderSpecifics} from '@remotion/serverless-client';
|
|
3
|
-
import type {AwsProvider} from './aws-provider';
|
|
4
|
-
import {getS3Client} from './get-s3-client';
|
|
5
|
-
|
|
6
|
-
export const lambdaLsImplementation: ProviderSpecifics<AwsProvider>['listObjects'] =
|
|
7
|
-
async ({
|
|
8
|
-
bucketName,
|
|
9
|
-
prefix,
|
|
10
|
-
region,
|
|
11
|
-
expectedBucketOwner,
|
|
12
|
-
continuationToken,
|
|
13
|
-
forcePathStyle,
|
|
14
|
-
requestHandler,
|
|
15
|
-
}) => {
|
|
16
|
-
try {
|
|
17
|
-
const list = await getS3Client({
|
|
18
|
-
region,
|
|
19
|
-
customCredentials: null,
|
|
20
|
-
forcePathStyle,
|
|
21
|
-
requestHandler,
|
|
22
|
-
}).send(
|
|
23
|
-
new ListObjectsV2Command({
|
|
24
|
-
Bucket: bucketName,
|
|
25
|
-
Prefix: prefix,
|
|
26
|
-
ExpectedBucketOwner: expectedBucketOwner ?? undefined,
|
|
27
|
-
ContinuationToken: continuationToken,
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
30
|
-
if (list.NextContinuationToken) {
|
|
31
|
-
return [
|
|
32
|
-
...(list.Contents ?? []).map((o) => {
|
|
33
|
-
return {
|
|
34
|
-
Key: o.Key as string,
|
|
35
|
-
LastModified: o.LastModified as Date,
|
|
36
|
-
ETag: o.ETag as string,
|
|
37
|
-
Size: o.Size as number,
|
|
38
|
-
};
|
|
39
|
-
}),
|
|
40
|
-
...(await lambdaLsImplementation({
|
|
41
|
-
bucketName,
|
|
42
|
-
prefix,
|
|
43
|
-
expectedBucketOwner,
|
|
44
|
-
region,
|
|
45
|
-
continuationToken: list.NextContinuationToken,
|
|
46
|
-
forcePathStyle,
|
|
47
|
-
requestHandler,
|
|
48
|
-
})),
|
|
49
|
-
];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
(list.Contents || [])?.map((o) => {
|
|
54
|
-
return {
|
|
55
|
-
Key: o.Key as string,
|
|
56
|
-
LastModified: o.LastModified as Date,
|
|
57
|
-
ETag: o.ETag as string,
|
|
58
|
-
Size: o.Size as number,
|
|
59
|
-
};
|
|
60
|
-
}) ?? []
|
|
61
|
-
);
|
|
62
|
-
} catch (err) {
|
|
63
|
-
if (!expectedBucketOwner) {
|
|
64
|
-
throw err;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Prevent from accessing a foreign bucket, retry without ExpectedBucketOwner and see if it works. If it works then it's an owner mismatch.
|
|
68
|
-
if ((err as Error).stack?.includes('AccessDenied')) {
|
|
69
|
-
await getS3Client({
|
|
70
|
-
region,
|
|
71
|
-
customCredentials: null,
|
|
72
|
-
forcePathStyle,
|
|
73
|
-
requestHandler,
|
|
74
|
-
}).send(
|
|
75
|
-
new ListObjectsV2Command({
|
|
76
|
-
Bucket: bucketName,
|
|
77
|
-
Prefix: prefix,
|
|
78
|
-
}),
|
|
79
|
-
);
|
|
80
|
-
throw new Error(
|
|
81
|
-
`Bucket owner mismatch: Expected the bucket ${bucketName} to be owned by you (AWS Account ID: ${expectedBucketOwner}) but it's not the case. Did you accidentially specify the wrong bucket?`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
};
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
AudioCodec,
|
|
3
|
-
BrowserSafeApis,
|
|
4
|
-
ChromiumOptions,
|
|
5
|
-
ColorSpace,
|
|
6
|
-
DeleteAfter,
|
|
7
|
-
DownloadBehavior,
|
|
8
|
-
FrameRange,
|
|
9
|
-
LogLevel,
|
|
10
|
-
OutNameInput,
|
|
11
|
-
PixelFormat,
|
|
12
|
-
Privacy,
|
|
13
|
-
ProResProfile,
|
|
14
|
-
ServerlessCodec,
|
|
15
|
-
ServerlessPayloads,
|
|
16
|
-
ServerlessStartPayload,
|
|
17
|
-
ServerlessStatusPayload,
|
|
18
|
-
ToOptions,
|
|
19
|
-
VideoImageFormat,
|
|
20
|
-
WebhookOption,
|
|
21
|
-
X264Preset,
|
|
22
|
-
} from '@remotion/serverless-client';
|
|
23
|
-
import {
|
|
24
|
-
ENABLE_V5_BREAKING_CHANGES,
|
|
25
|
-
ServerlessRoutines,
|
|
26
|
-
VERSION,
|
|
27
|
-
compressInputProps,
|
|
28
|
-
getNeedsToUpload,
|
|
29
|
-
serializeOrThrow,
|
|
30
|
-
validateDownloadBehavior,
|
|
31
|
-
} from '@remotion/serverless-client';
|
|
32
|
-
import type {AwsProvider} from './aws-provider';
|
|
33
|
-
import {awsImplementation} from './aws-provider';
|
|
34
|
-
|
|
35
|
-
import type {StorageClass} from '@aws-sdk/client-s3';
|
|
36
|
-
import {validateWebhook} from '@remotion/serverless-client';
|
|
37
|
-
import type {GetRenderProgressInput} from './get-render-progress';
|
|
38
|
-
import type {AwsRegion} from './regions';
|
|
39
|
-
import type {RenderStillOnLambdaNonNullInput} from './render-still-on-lambda';
|
|
40
|
-
import type {RequestHandler} from './types';
|
|
41
|
-
import {validateLambdaCodec} from './validate-lambda-codec';
|
|
42
|
-
import {validateServeUrl} from './validate-serveurl';
|
|
43
|
-
|
|
44
|
-
export type InnerRenderMediaOnLambdaInput = {
|
|
45
|
-
region: AwsRegion;
|
|
46
|
-
functionName: string;
|
|
47
|
-
serveUrl: string;
|
|
48
|
-
composition: string;
|
|
49
|
-
inputProps: Record<string, unknown>;
|
|
50
|
-
codec: ServerlessCodec;
|
|
51
|
-
imageFormat: VideoImageFormat;
|
|
52
|
-
crf: number | undefined;
|
|
53
|
-
envVariables: Record<string, string>;
|
|
54
|
-
pixelFormat: PixelFormat | undefined;
|
|
55
|
-
proResProfile: ProResProfile | undefined;
|
|
56
|
-
x264Preset: X264Preset | null;
|
|
57
|
-
privacy: Privacy;
|
|
58
|
-
jpegQuality: number;
|
|
59
|
-
maxRetries: number;
|
|
60
|
-
framesPerLambda: number | null;
|
|
61
|
-
concurrency: number | null;
|
|
62
|
-
logLevel: LogLevel;
|
|
63
|
-
frameRange: FrameRange | null;
|
|
64
|
-
outName: OutNameInput<AwsProvider> | null;
|
|
65
|
-
timeoutInMilliseconds: number;
|
|
66
|
-
chromiumOptions: ChromiumOptions;
|
|
67
|
-
scale: number;
|
|
68
|
-
everyNthFrame: number;
|
|
69
|
-
numberOfGifLoops: number | null;
|
|
70
|
-
concurrencyPerLambda: number;
|
|
71
|
-
downloadBehavior: DownloadBehavior;
|
|
72
|
-
muted: boolean;
|
|
73
|
-
overwrite: boolean;
|
|
74
|
-
audioBitrate: string | null;
|
|
75
|
-
videoBitrate: string | null;
|
|
76
|
-
encodingMaxRate: string | null;
|
|
77
|
-
encodingBufferSize: string | null;
|
|
78
|
-
webhook: WebhookOption | null;
|
|
79
|
-
forceWidth: number | null;
|
|
80
|
-
forceHeight: number | null;
|
|
81
|
-
rendererFunctionName: string | null;
|
|
82
|
-
forceBucketName: string | null;
|
|
83
|
-
audioCodec: AudioCodec | null;
|
|
84
|
-
colorSpace: ColorSpace | null;
|
|
85
|
-
deleteAfter: DeleteAfter | null;
|
|
86
|
-
indent: boolean;
|
|
87
|
-
forcePathStyle: boolean;
|
|
88
|
-
metadata: Record<string, string> | null;
|
|
89
|
-
storageClass: StorageClass | null;
|
|
90
|
-
requestHandler: RequestHandler | null;
|
|
91
|
-
} & ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>;
|
|
92
|
-
|
|
93
|
-
export const makeLambdaRenderMediaPayload = async ({
|
|
94
|
-
rendererFunctionName,
|
|
95
|
-
frameRange,
|
|
96
|
-
framesPerLambda,
|
|
97
|
-
concurrency,
|
|
98
|
-
forceBucketName: bucketName,
|
|
99
|
-
codec,
|
|
100
|
-
composition,
|
|
101
|
-
serveUrl,
|
|
102
|
-
imageFormat,
|
|
103
|
-
inputProps,
|
|
104
|
-
region,
|
|
105
|
-
crf,
|
|
106
|
-
envVariables,
|
|
107
|
-
pixelFormat,
|
|
108
|
-
proResProfile,
|
|
109
|
-
x264Preset,
|
|
110
|
-
maxRetries,
|
|
111
|
-
privacy,
|
|
112
|
-
logLevel,
|
|
113
|
-
outName,
|
|
114
|
-
timeoutInMilliseconds,
|
|
115
|
-
chromiumOptions,
|
|
116
|
-
scale,
|
|
117
|
-
everyNthFrame,
|
|
118
|
-
numberOfGifLoops,
|
|
119
|
-
audioBitrate,
|
|
120
|
-
concurrencyPerLambda,
|
|
121
|
-
audioCodec,
|
|
122
|
-
forceHeight,
|
|
123
|
-
forceWidth,
|
|
124
|
-
webhook,
|
|
125
|
-
videoBitrate,
|
|
126
|
-
encodingMaxRate,
|
|
127
|
-
encodingBufferSize,
|
|
128
|
-
downloadBehavior,
|
|
129
|
-
muted,
|
|
130
|
-
overwrite,
|
|
131
|
-
jpegQuality,
|
|
132
|
-
offthreadVideoCacheSizeInBytes,
|
|
133
|
-
mediaCacheSizeInBytes,
|
|
134
|
-
deleteAfter,
|
|
135
|
-
colorSpace,
|
|
136
|
-
preferLossless,
|
|
137
|
-
forcePathStyle,
|
|
138
|
-
metadata,
|
|
139
|
-
apiKey,
|
|
140
|
-
offthreadVideoThreads,
|
|
141
|
-
storageClass,
|
|
142
|
-
requestHandler,
|
|
143
|
-
}: InnerRenderMediaOnLambdaInput): Promise<
|
|
144
|
-
ServerlessStartPayload<AwsProvider>
|
|
145
|
-
> => {
|
|
146
|
-
const actualCodec = validateLambdaCodec(codec);
|
|
147
|
-
validateServeUrl(serveUrl);
|
|
148
|
-
validateDownloadBehavior(downloadBehavior);
|
|
149
|
-
validateWebhook(webhook);
|
|
150
|
-
|
|
151
|
-
const stringifiedInputProps = serializeOrThrow(
|
|
152
|
-
inputProps ?? {},
|
|
153
|
-
'input-props',
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const serialized = await compressInputProps({
|
|
157
|
-
stringifiedInputProps,
|
|
158
|
-
region,
|
|
159
|
-
needsToUpload: getNeedsToUpload({
|
|
160
|
-
type: 'video-or-audio',
|
|
161
|
-
sizes: [
|
|
162
|
-
stringifiedInputProps.length,
|
|
163
|
-
JSON.stringify(envVariables).length,
|
|
164
|
-
],
|
|
165
|
-
providerSpecifics: awsImplementation,
|
|
166
|
-
}),
|
|
167
|
-
userSpecifiedBucketName: bucketName ?? null,
|
|
168
|
-
propsType: 'input-props',
|
|
169
|
-
providerSpecifics: awsImplementation,
|
|
170
|
-
forcePathStyle: forcePathStyle ?? false,
|
|
171
|
-
skipPutAcl: privacy === 'no-acl',
|
|
172
|
-
requestHandler: requestHandler ?? null,
|
|
173
|
-
});
|
|
174
|
-
return {
|
|
175
|
-
rendererFunctionName,
|
|
176
|
-
framesPerLambda,
|
|
177
|
-
concurrency,
|
|
178
|
-
composition,
|
|
179
|
-
serveUrl,
|
|
180
|
-
inputProps: serialized,
|
|
181
|
-
codec: actualCodec,
|
|
182
|
-
imageFormat,
|
|
183
|
-
crf: crf ?? null,
|
|
184
|
-
envVariables,
|
|
185
|
-
pixelFormat: pixelFormat ?? null,
|
|
186
|
-
proResProfile: proResProfile ?? null,
|
|
187
|
-
x264Preset,
|
|
188
|
-
jpegQuality,
|
|
189
|
-
maxRetries,
|
|
190
|
-
privacy,
|
|
191
|
-
logLevel,
|
|
192
|
-
frameRange,
|
|
193
|
-
outName,
|
|
194
|
-
timeoutInMilliseconds,
|
|
195
|
-
chromiumOptions,
|
|
196
|
-
scale,
|
|
197
|
-
everyNthFrame,
|
|
198
|
-
numberOfGifLoops,
|
|
199
|
-
concurrencyPerLambda,
|
|
200
|
-
downloadBehavior,
|
|
201
|
-
muted,
|
|
202
|
-
version: VERSION,
|
|
203
|
-
overwrite: overwrite ?? ENABLE_V5_BREAKING_CHANGES,
|
|
204
|
-
audioBitrate: audioBitrate ?? null,
|
|
205
|
-
videoBitrate: videoBitrate ?? null,
|
|
206
|
-
encodingBufferSize: encodingBufferSize ?? null,
|
|
207
|
-
encodingMaxRate: encodingMaxRate ?? null,
|
|
208
|
-
webhook: webhook ?? null,
|
|
209
|
-
forceHeight: forceHeight ?? null,
|
|
210
|
-
forceWidth: forceWidth ?? null,
|
|
211
|
-
bucketName: bucketName ?? null,
|
|
212
|
-
audioCodec: audioCodec ?? null,
|
|
213
|
-
type: ServerlessRoutines.start,
|
|
214
|
-
offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes ?? null,
|
|
215
|
-
deleteAfter: deleteAfter ?? null,
|
|
216
|
-
colorSpace: colorSpace ?? null,
|
|
217
|
-
preferLossless: preferLossless ?? false,
|
|
218
|
-
forcePathStyle: forcePathStyle ?? false,
|
|
219
|
-
metadata: metadata ?? null,
|
|
220
|
-
apiKey: apiKey ?? null,
|
|
221
|
-
offthreadVideoThreads: offthreadVideoThreads ?? null,
|
|
222
|
-
mediaCacheSizeInBytes: mediaCacheSizeInBytes ?? null,
|
|
223
|
-
storageClass: storageClass ?? null,
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export const getRenderProgressPayload = ({
|
|
228
|
-
bucketName,
|
|
229
|
-
renderId,
|
|
230
|
-
s3OutputProvider,
|
|
231
|
-
logLevel,
|
|
232
|
-
forcePathStyle,
|
|
233
|
-
}: GetRenderProgressInput): ServerlessStatusPayload<AwsProvider> => {
|
|
234
|
-
return {
|
|
235
|
-
type: ServerlessRoutines.status,
|
|
236
|
-
bucketName,
|
|
237
|
-
renderId,
|
|
238
|
-
version: VERSION,
|
|
239
|
-
s3OutputProvider: s3OutputProvider ?? null,
|
|
240
|
-
logLevel: logLevel ?? 'info',
|
|
241
|
-
forcePathStyle: forcePathStyle ?? false,
|
|
242
|
-
};
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export const makeLambdaRenderStillPayload = async ({
|
|
246
|
-
serveUrl,
|
|
247
|
-
inputProps,
|
|
248
|
-
imageFormat,
|
|
249
|
-
envVariables,
|
|
250
|
-
jpegQuality,
|
|
251
|
-
region,
|
|
252
|
-
maxRetries,
|
|
253
|
-
composition,
|
|
254
|
-
privacy,
|
|
255
|
-
frame,
|
|
256
|
-
logLevel,
|
|
257
|
-
outName,
|
|
258
|
-
timeoutInMilliseconds,
|
|
259
|
-
chromiumOptions,
|
|
260
|
-
scale,
|
|
261
|
-
downloadBehavior,
|
|
262
|
-
forceHeight,
|
|
263
|
-
forceWidth,
|
|
264
|
-
forceBucketName,
|
|
265
|
-
offthreadVideoCacheSizeInBytes,
|
|
266
|
-
deleteAfter,
|
|
267
|
-
forcePathStyle,
|
|
268
|
-
apiKey,
|
|
269
|
-
storageClass,
|
|
270
|
-
requestHandler,
|
|
271
|
-
offthreadVideoThreads,
|
|
272
|
-
mediaCacheSizeInBytes,
|
|
273
|
-
}: RenderStillOnLambdaNonNullInput): Promise<
|
|
274
|
-
ServerlessPayloads<AwsProvider>[ServerlessRoutines.still]
|
|
275
|
-
> => {
|
|
276
|
-
const stringifiedInputProps = serializeOrThrow(inputProps, 'input-props');
|
|
277
|
-
|
|
278
|
-
const serializedInputProps = await compressInputProps({
|
|
279
|
-
stringifiedInputProps,
|
|
280
|
-
region,
|
|
281
|
-
needsToUpload: getNeedsToUpload({
|
|
282
|
-
type: 'still',
|
|
283
|
-
sizes: [
|
|
284
|
-
stringifiedInputProps.length,
|
|
285
|
-
JSON.stringify(envVariables).length,
|
|
286
|
-
],
|
|
287
|
-
providerSpecifics: awsImplementation,
|
|
288
|
-
}),
|
|
289
|
-
userSpecifiedBucketName: forceBucketName ?? null,
|
|
290
|
-
propsType: 'input-props',
|
|
291
|
-
providerSpecifics: awsImplementation,
|
|
292
|
-
forcePathStyle,
|
|
293
|
-
skipPutAcl: privacy === 'no-acl',
|
|
294
|
-
requestHandler,
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
return {
|
|
298
|
-
composition,
|
|
299
|
-
serveUrl,
|
|
300
|
-
inputProps: serializedInputProps,
|
|
301
|
-
imageFormat,
|
|
302
|
-
envVariables,
|
|
303
|
-
jpegQuality,
|
|
304
|
-
maxRetries,
|
|
305
|
-
frame,
|
|
306
|
-
privacy,
|
|
307
|
-
attempt: 1,
|
|
308
|
-
logLevel,
|
|
309
|
-
outName,
|
|
310
|
-
timeoutInMilliseconds,
|
|
311
|
-
chromiumOptions,
|
|
312
|
-
scale,
|
|
313
|
-
downloadBehavior,
|
|
314
|
-
version: VERSION,
|
|
315
|
-
forceHeight,
|
|
316
|
-
forceWidth,
|
|
317
|
-
bucketName: forceBucketName,
|
|
318
|
-
offthreadVideoCacheSizeInBytes,
|
|
319
|
-
deleteAfter,
|
|
320
|
-
type: ServerlessRoutines.still,
|
|
321
|
-
streamed: true,
|
|
322
|
-
forcePathStyle,
|
|
323
|
-
apiKey: apiKey ?? null,
|
|
324
|
-
offthreadVideoThreads: offthreadVideoThreads ?? null,
|
|
325
|
-
mediaCacheSizeInBytes: mediaCacheSizeInBytes ?? null,
|
|
326
|
-
storageClass: storageClass ?? null,
|
|
327
|
-
};
|
|
328
|
-
};
|
package/src/make-s3-url.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type {AwsRegion} from './regions';
|
|
2
|
-
|
|
3
|
-
export const makeS3ServeUrl = ({
|
|
4
|
-
bucketName,
|
|
5
|
-
subFolder,
|
|
6
|
-
region,
|
|
7
|
-
}: {
|
|
8
|
-
bucketName: string;
|
|
9
|
-
subFolder: string;
|
|
10
|
-
region: AwsRegion;
|
|
11
|
-
}): string => {
|
|
12
|
-
return `https://${bucketName}.s3.${region}.amazonaws.com/${subFolder}/index.html`;
|
|
13
|
-
};
|
package/src/p-limit.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export const pLimit = (concurrency: number) => {
|
|
2
|
-
const queue: Function[] = [];
|
|
3
|
-
let activeCount = 0;
|
|
4
|
-
|
|
5
|
-
const next = () => {
|
|
6
|
-
activeCount--;
|
|
7
|
-
|
|
8
|
-
if (queue.length > 0) {
|
|
9
|
-
queue.shift()?.();
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const run = async <Arguments extends unknown[], ReturnType>(
|
|
14
|
-
fn: (..._arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
|
|
15
|
-
resolve: (res: Promise<ReturnType>) => void,
|
|
16
|
-
...args: Arguments
|
|
17
|
-
) => {
|
|
18
|
-
activeCount++;
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line require-await
|
|
21
|
-
const result = (async () => fn(...args))();
|
|
22
|
-
|
|
23
|
-
resolve(result);
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
await result;
|
|
27
|
-
} catch {}
|
|
28
|
-
|
|
29
|
-
next();
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const enqueue = <Arguments extends unknown[], ReturnType>(
|
|
33
|
-
fn: (..._arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
|
|
34
|
-
resolve: (res: Promise<ReturnType>) => void,
|
|
35
|
-
...args: Arguments
|
|
36
|
-
) => {
|
|
37
|
-
queue.push(() => run(fn, resolve, ...args));
|
|
38
|
-
|
|
39
|
-
(async () => {
|
|
40
|
-
// This function needs to wait until the next microtask before comparing
|
|
41
|
-
// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
|
|
42
|
-
// when the run function is dequeued and called. The comparison in the if-statement
|
|
43
|
-
// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
|
|
44
|
-
await Promise.resolve();
|
|
45
|
-
|
|
46
|
-
if (activeCount < concurrency && queue.length > 0) {
|
|
47
|
-
queue.shift()?.();
|
|
48
|
-
}
|
|
49
|
-
})();
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const generator = <Arguments extends unknown[], ReturnType>(
|
|
53
|
-
fn: (..._arguments: Arguments) => PromiseLike<ReturnType> | ReturnType,
|
|
54
|
-
...args: Arguments
|
|
55
|
-
) =>
|
|
56
|
-
new Promise<ReturnType>((resolve) => {
|
|
57
|
-
enqueue(fn, resolve, ...args);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
Object.defineProperties(generator, {
|
|
61
|
-
activeCount: {
|
|
62
|
-
get: () => activeCount,
|
|
63
|
-
},
|
|
64
|
-
pendingCount: {
|
|
65
|
-
get: () => queue.length,
|
|
66
|
-
},
|
|
67
|
-
clearQueue: {
|
|
68
|
-
value: () => {
|
|
69
|
-
queue.length = 0;
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return generator;
|
|
75
|
-
};
|