@remotion/lambda-client 4.0.261

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.
Files changed (227) hide show
  1. package/.turbo/turbo-make.log +6 -0
  2. package/LICENSE.md +49 -0
  3. package/README.md +5 -0
  4. package/bundle.ts +20 -0
  5. package/dist/app-router-webhook.d.ts +10 -0
  6. package/dist/app-router-webhook.js +43 -0
  7. package/dist/apply-lifecycle.d.ts +8 -0
  8. package/dist/apply-lifecycle.js +18 -0
  9. package/dist/aws-clients.d.ts +11 -0
  10. package/dist/aws-clients.js +51 -0
  11. package/dist/aws-provider.d.ts +23 -0
  12. package/dist/aws-provider.js +94 -0
  13. package/dist/bucket-exists.d.ts +3 -0
  14. package/dist/bucket-exists.js +26 -0
  15. package/dist/call-lambda-async.d.ts +2 -0
  16. package/dist/call-lambda-async.js +20 -0
  17. package/dist/call-lambda-streaming.d.ts +6 -0
  18. package/dist/call-lambda-streaming.js +125 -0
  19. package/dist/call-lambda-sync.d.ts +2 -0
  20. package/dist/call-lambda-sync.js +30 -0
  21. package/dist/check-credentials.d.ts +1 -0
  22. package/dist/check-credentials.js +39 -0
  23. package/dist/clean-items.d.ts +16 -0
  24. package/dist/clean-items.js +25 -0
  25. package/dist/constants.d.ts +25 -0
  26. package/dist/constants.js +26 -0
  27. package/dist/content-disposition-header.d.ts +2 -0
  28. package/dist/content-disposition-header.js +50 -0
  29. package/dist/convert-to-serve-url.d.ts +6 -0
  30. package/dist/convert-to-serve-url.js +14 -0
  31. package/dist/create-bucket.d.ts +3 -0
  32. package/dist/create-bucket.js +45 -0
  33. package/dist/delete-file.d.ts +3 -0
  34. package/dist/delete-file.js +12 -0
  35. package/dist/delete-function.d.ts +4 -0
  36. package/dist/delete-function.js +15 -0
  37. package/dist/delete-render.d.ts +20 -0
  38. package/dist/delete-render.js +84 -0
  39. package/dist/encode-aws-url-params.d.ts +1 -0
  40. package/dist/encode-aws-url-params.js +7 -0
  41. package/dist/esm/constants.mjs +45 -0
  42. package/dist/esm/index.mjs +6516 -0
  43. package/dist/esm/regions.mjs +50 -0
  44. package/dist/estimate-price.d.ts +17 -0
  45. package/dist/estimate-price.js +45 -0
  46. package/dist/express-webhook.d.ts +3 -0
  47. package/dist/express-webhook.js +46 -0
  48. package/dist/get-account-id.d.ts +3 -0
  49. package/dist/get-account-id.js +15 -0
  50. package/dist/get-aws-client.d.ts +30 -0
  51. package/dist/get-aws-client.js +56 -0
  52. package/dist/get-aws-urls.d.ts +25 -0
  53. package/dist/get-aws-urls.js +31 -0
  54. package/dist/get-buckets.d.ts +9 -0
  55. package/dist/get-buckets.js +62 -0
  56. package/dist/get-compositions-on-lambda.d.ts +18 -0
  57. package/dist/get-compositions-on-lambda.js +59 -0
  58. package/dist/get-credentials.d.ts +9 -0
  59. package/dist/get-credentials.js +55 -0
  60. package/dist/get-env-variable.d.ts +1 -0
  61. package/dist/get-env-variable.js +15 -0
  62. package/dist/get-function-name.d.ts +8 -0
  63. package/dist/get-function-name.js +17 -0
  64. package/dist/get-function-version.d.ts +7 -0
  65. package/dist/get-function-version.js +32 -0
  66. package/dist/get-functions.d.ts +8 -0
  67. package/dist/get-functions.js +77 -0
  68. package/dist/get-output-url-from-metadata.d.ts +3 -0
  69. package/dist/get-output-url-from-metadata.js +18 -0
  70. package/dist/get-render-progress.d.ts +15 -0
  71. package/dist/get-render-progress.js +45 -0
  72. package/dist/get-s3-client.d.ts +9 -0
  73. package/dist/get-s3-client.js +14 -0
  74. package/dist/get-service-client.d.ts +23 -0
  75. package/dist/get-service-client.js +120 -0
  76. package/dist/get-sites.d.ts +29 -0
  77. package/dist/get-sites.js +79 -0
  78. package/dist/head-file.d.ts +3 -0
  79. package/dist/head-file.js +17 -0
  80. package/dist/index.d.ts +123 -0
  81. package/dist/index.js +104 -0
  82. package/dist/is-cli.d.ts +2 -0
  83. package/dist/is-cli.js +10 -0
  84. package/dist/is-flaky-error.d.ts +1 -0
  85. package/dist/is-flaky-error.js +77 -0
  86. package/dist/is-in-lambda.d.ts +1 -0
  87. package/dist/is-in-lambda.js +9 -0
  88. package/dist/is-likely-to-have-aws-profile.d.ts +1 -0
  89. package/dist/is-likely-to-have-aws-profile.js +50 -0
  90. package/dist/lambda-version-string.d.ts +1 -0
  91. package/dist/lambda-version-string.js +7 -0
  92. package/dist/lifecycle-rules.d.ts +10 -0
  93. package/dist/lifecycle-rules.js +61 -0
  94. package/dist/lifecycle.d.ts +7 -0
  95. package/dist/lifecycle.js +24 -0
  96. package/dist/list-objects.d.ts +3 -0
  97. package/dist/list-objects.js +67 -0
  98. package/dist/make-lambda-payload.d.ts +54 -0
  99. package/dist/make-lambda-payload.js +148 -0
  100. package/dist/make-s3-url.d.ts +6 -0
  101. package/dist/make-s3-url.js +7 -0
  102. package/dist/p-limit.d.ts +1 -0
  103. package/dist/p-limit.js +57 -0
  104. package/dist/pages-router-webhook.d.ts +5 -0
  105. package/dist/pages-router-webhook.js +48 -0
  106. package/dist/parse-function-name.d.ts +8 -0
  107. package/dist/parse-function-name.js +17 -0
  108. package/dist/presign-url.d.ts +14 -0
  109. package/dist/presign-url.js +64 -0
  110. package/dist/price-per-1s.d.ts +37 -0
  111. package/dist/price-per-1s.js +822 -0
  112. package/dist/random-hash.d.ts +1 -0
  113. package/dist/random-hash.js +13 -0
  114. package/dist/read-file.d.ts +9 -0
  115. package/dist/read-file.js +18 -0
  116. package/dist/regions.d.ts +3 -0
  117. package/dist/regions.js +48 -0
  118. package/dist/render-media-on-lambda.d.ts +61 -0
  119. package/dist/render-media-on-lambda.js +127 -0
  120. package/dist/render-still-on-lambda.d.ts +53 -0
  121. package/dist/render-still-on-lambda.js +118 -0
  122. package/dist/runtime-preference.d.ts +2 -0
  123. package/dist/runtime-preference.js +8 -0
  124. package/dist/speculate-function-name.d.ts +6 -0
  125. package/dist/speculate-function-name.js +20 -0
  126. package/dist/test/encode-aws-url.test.d.ts +1 -0
  127. package/dist/test/encode-aws-url.test.js +8 -0
  128. package/dist/test/price-calculation.test.d.ts +1 -0
  129. package/dist/test/price-calculation.test.js +61 -0
  130. package/dist/test/pricing.test.d.ts +1 -0
  131. package/dist/test/pricing.test.js +27 -0
  132. package/dist/test/validate-disk-size-in-mb.test.d.ts +1 -0
  133. package/dist/test/validate-disk-size-in-mb.test.js +14 -0
  134. package/dist/validate-aws-region.d.ts +2 -0
  135. package/dist/validate-aws-region.js +9 -0
  136. package/dist/validate-bucketname.d.ts +4 -0
  137. package/dist/validate-bucketname.js +15 -0
  138. package/dist/validate-disk-size-in-mb.d.ts +1 -0
  139. package/dist/validate-disk-size-in-mb.js +23 -0
  140. package/dist/validate-lambda-codec.d.ts +2 -0
  141. package/dist/validate-lambda-codec.js +21 -0
  142. package/dist/validate-memory-size.d.ts +1 -0
  143. package/dist/validate-memory-size.js +22 -0
  144. package/dist/validate-presign-expiration.d.ts +1 -0
  145. package/dist/validate-presign-expiration.js +29 -0
  146. package/dist/validate-serveurl.d.ts +1 -0
  147. package/dist/validate-serveurl.js +9 -0
  148. package/dist/validate-webhook-signature.d.ts +5 -0
  149. package/dist/validate-webhook-signature.js +28 -0
  150. package/dist/write-file.d.ts +5 -0
  151. package/dist/write-file.js +56 -0
  152. package/eslint.config.mjs +5 -0
  153. package/package.json +71 -0
  154. package/src/app-router-webhook.ts +64 -0
  155. package/src/apply-lifecycle.ts +30 -0
  156. package/src/aws-clients.ts +60 -0
  157. package/src/aws-provider.ts +135 -0
  158. package/src/bucket-exists.ts +28 -0
  159. package/src/call-lambda-async.ts +39 -0
  160. package/src/call-lambda-streaming.ts +219 -0
  161. package/src/call-lambda-sync.ts +55 -0
  162. package/src/check-credentials.ts +51 -0
  163. package/src/clean-items.ts +47 -0
  164. package/src/constants.ts +38 -0
  165. package/src/content-disposition-header.ts +64 -0
  166. package/src/convert-to-serve-url.ts +24 -0
  167. package/src/create-bucket.ts +67 -0
  168. package/src/delete-file.ts +30 -0
  169. package/src/delete-function.ts +24 -0
  170. package/src/delete-render.ts +107 -0
  171. package/src/encode-aws-url-params.ts +3 -0
  172. package/src/estimate-price.ts +95 -0
  173. package/src/express-webhook.ts +50 -0
  174. package/src/get-account-id.ts +22 -0
  175. package/src/get-aws-client.ts +59 -0
  176. package/src/get-aws-urls.ts +85 -0
  177. package/src/get-buckets.ts +81 -0
  178. package/src/get-compositions-on-lambda.ts +104 -0
  179. package/src/get-credentials.ts +81 -0
  180. package/src/get-env-variable.ts +15 -0
  181. package/src/get-function-name.ts +24 -0
  182. package/src/get-function-version.ts +43 -0
  183. package/src/get-functions.ts +103 -0
  184. package/src/get-output-url-from-metadata.ts +23 -0
  185. package/src/get-render-progress.ts +62 -0
  186. package/src/get-s3-client.ts +22 -0
  187. package/src/get-service-client.ts +178 -0
  188. package/src/get-sites.ts +128 -0
  189. package/src/head-file.ts +28 -0
  190. package/src/index.ts +147 -0
  191. package/src/is-cli.ts +7 -0
  192. package/src/is-flaky-error.ts +101 -0
  193. package/src/is-in-lambda.ts +5 -0
  194. package/src/is-likely-to-have-aws-profile.ts +55 -0
  195. package/src/lambda-version-string.ts +5 -0
  196. package/src/lifecycle-rules.ts +104 -0
  197. package/src/lifecycle.ts +44 -0
  198. package/src/list-objects.ts +83 -0
  199. package/src/make-lambda-payload.ts +317 -0
  200. package/src/make-s3-url.ts +13 -0
  201. package/src/p-limit.ts +75 -0
  202. package/src/pages-router-webhook.ts +58 -0
  203. package/src/parse-function-name.ts +24 -0
  204. package/src/presign-url.ts +110 -0
  205. package/src/price-per-1s.ts +863 -0
  206. package/src/random-hash.ts +10 -0
  207. package/src/read-file.ts +31 -0
  208. package/src/regions.ts +48 -0
  209. package/src/render-media-on-lambda.ts +216 -0
  210. package/src/render-still-on-lambda.ts +195 -0
  211. package/src/runtime-preference.ts +7 -0
  212. package/src/speculate-function-name.ts +27 -0
  213. package/src/test/encode-aws-url.test.ts +7 -0
  214. package/src/test/price-calculation.test.ts +61 -0
  215. package/src/test/pricing.test.ts +32 -0
  216. package/src/test/validate-disk-size-in-mb.test.ts +15 -0
  217. package/src/validate-aws-region.ts +14 -0
  218. package/src/validate-bucketname.ts +24 -0
  219. package/src/validate-disk-size-in-mb.ts +37 -0
  220. package/src/validate-lambda-codec.ts +28 -0
  221. package/src/validate-memory-size.ts +31 -0
  222. package/src/validate-presign-expiration.ts +46 -0
  223. package/src/validate-serveurl.ts +9 -0
  224. package/src/validate-webhook-signature.ts +42 -0
  225. package/src/write-file.ts +74 -0
  226. package/tsconfig.json +9 -0
  227. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,6 @@
1
+
2
+ 
3
+ > @remotion/lambda-client@4.0.261 make /Users/jonathanburger/remotion/packages/lambda-client
4
+ > tsc -d && bun --env-file=../.env.bundle bundle.ts
5
+
6
+ [19.74ms] Generated.
package/LICENSE.md ADDED
@@ -0,0 +1,49 @@
1
+ # Remotion License
2
+
3
+ In Remotion 5.0, the license will slightly change. [View the changes here](https://github.com/remotion-dev/remotion/pull/3750).
4
+
5
+ ---
6
+
7
+ Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
8
+
9
+ - [Free license](#free-license)
10
+ - [Company license](#company-license)
11
+
12
+ ## Free license
13
+
14
+ Copyright © 2025 [Remotion](https://www.remotion.dev)
15
+
16
+ ### Eligibility
17
+
18
+ You are eligible to use Remotion for free if you are:
19
+
20
+ - an individual
21
+ - a for-profit organization with up to 3 employees
22
+ - a non-profit or not-for-profit organization
23
+ - evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
24
+
25
+ ### Allowed use cases
26
+
27
+ Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
28
+
29
+ ### Disallowed use cases
30
+
31
+ It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
32
+
33
+ ### Warranty notice
34
+
35
+ The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
36
+
37
+ ### Support
38
+
39
+ Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
40
+
41
+ ## Company license
42
+
43
+ You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](https://www.remotion.dev/docs/support)).
44
+
45
+ Visit [remotion.pro](https://www.remotion.pro/license) for pricing and to buy a license.
46
+
47
+ ### FAQs
48
+
49
+ Are you not sure whether you need a company license because of an edge case? Here are some [frequently asked questions](https://www.remotion.pro/faq).
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @remotion/lambda-client
2
+
3
+ ## Usage
4
+
5
+ This is an internal package and has no documentation.
package/bundle.ts ADDED
@@ -0,0 +1,20 @@
1
+ import {buildPackage} from '../.monorepo/builder';
2
+
3
+ await buildPackage({
4
+ formats: {
5
+ cjs: 'use-tsc',
6
+ esm: 'build',
7
+ },
8
+ external: 'dependencies',
9
+ entrypoints: [
10
+ {
11
+ path: 'src/index.ts',
12
+ target: 'node',
13
+ },
14
+ {
15
+ path: 'src/constants.ts',
16
+ target: 'browser',
17
+ },
18
+ {path: 'src/regions.ts', target: 'browser'},
19
+ ],
20
+ });
@@ -0,0 +1,10 @@
1
+ import type { WebhookErrorPayload, WebhookSuccessPayload, WebhookTimeoutPayload } from '@remotion/serverless-client';
2
+ export type NextWebhookArgs = {
3
+ testing?: boolean;
4
+ extraHeaders?: Record<string, string>;
5
+ secret: string;
6
+ onSuccess?: (payload: WebhookSuccessPayload) => void;
7
+ onTimeout?: (payload: WebhookTimeoutPayload) => void;
8
+ onError?: (payload: WebhookErrorPayload) => void;
9
+ };
10
+ export declare const appRouterWebhook: (options: NextWebhookArgs) => ((req: Request) => Promise<Response>);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appRouterWebhook = void 0;
4
+ const validate_webhook_signature_1 = require("./validate-webhook-signature");
5
+ const appRouterWebhook = (options) => {
6
+ const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
7
+ return async function (req) {
8
+ let headers = extraHeaders || {};
9
+ if (testing) {
10
+ const testingheaders = {
11
+ 'Access-Control-Allow-Origin': 'https://www.remotion.dev',
12
+ 'Access-Control-Allow-Headers': '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',
13
+ 'Access-Control-Allow-Methods': 'OPTIONS,POST',
14
+ };
15
+ headers = { ...headers, ...testingheaders };
16
+ }
17
+ if (req.method === 'OPTIONS') {
18
+ // do we have any use of the OPTIONS method other than the tester on webhooks page ? if so we can add a condition here to only return this if testing mode enabled
19
+ return new Response(null, {
20
+ headers,
21
+ });
22
+ }
23
+ // Parse the body properly
24
+ const body = await req.json();
25
+ (0, validate_webhook_signature_1.validateWebhookSignature)({
26
+ secret,
27
+ body,
28
+ signatureHeader: req.headers.get('X-Remotion-Signature'),
29
+ });
30
+ const payload = body;
31
+ if (payload.type === 'success' && onSuccess) {
32
+ onSuccess(payload);
33
+ }
34
+ else if (payload.type === 'timeout' && onTimeout) {
35
+ onTimeout(payload);
36
+ }
37
+ else if (payload.type === 'error' && onError) {
38
+ onError(payload);
39
+ }
40
+ return new Response(JSON.stringify({ success: true }), { headers });
41
+ };
42
+ };
43
+ exports.appRouterWebhook = appRouterWebhook;
@@ -0,0 +1,8 @@
1
+ import type { DeleteBucketLifecycleCommandInput, LifecycleRule, PutBucketLifecycleConfigurationCommandInput } from '@aws-sdk/client-s3';
2
+ export declare const deleteLifeCycleInput: ({ bucketName, }: {
3
+ bucketName: string;
4
+ }) => DeleteBucketLifecycleCommandInput;
5
+ export declare const createLifeCycleInput: ({ bucketName, lcRules, }: {
6
+ bucketName: string;
7
+ lcRules: LifecycleRule[];
8
+ }) => PutBucketLifecycleConfigurationCommandInput;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLifeCycleInput = exports.deleteLifeCycleInput = void 0;
4
+ const deleteLifeCycleInput = ({ bucketName, }) => {
5
+ return {
6
+ Bucket: bucketName,
7
+ };
8
+ };
9
+ exports.deleteLifeCycleInput = deleteLifeCycleInput;
10
+ const createLifeCycleInput = ({ bucketName, lcRules, }) => {
11
+ return {
12
+ Bucket: bucketName,
13
+ LifecycleConfiguration: {
14
+ Rules: lcRules,
15
+ },
16
+ };
17
+ };
18
+ exports.createLifeCycleInput = createLifeCycleInput;
@@ -0,0 +1,11 @@
1
+ import type { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import type { IAMClient } from '@aws-sdk/client-iam';
3
+ import type { LambdaClient } from '@aws-sdk/client-lambda';
4
+ import type { ServiceQuotasClient } from '@aws-sdk/client-service-quotas';
5
+ import type { STSClient } from '@aws-sdk/client-sts';
6
+ import type { AwsRegion } from './regions';
7
+ export declare const getCloudWatchLogsClient: (region: AwsRegion) => CloudWatchLogsClient;
8
+ export declare const getLambdaClient: (region: AwsRegion, _timeoutInTest?: number) => LambdaClient;
9
+ export declare const getIamClient: (region: AwsRegion) => IAMClient;
10
+ export declare const getServiceQuotasClient: (region: AwsRegion) => ServiceQuotasClient;
11
+ export declare const getStsClient: (region: AwsRegion) => STSClient;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStsClient = exports.getServiceQuotasClient = exports.getIamClient = exports.getLambdaClient = exports.getCloudWatchLogsClient = void 0;
4
+ const get_service_client_1 = require("./get-service-client");
5
+ const getCloudWatchLogsClient = (region) => {
6
+ return (0, get_service_client_1.getServiceClient)({
7
+ region,
8
+ service: 'cloudwatch',
9
+ customCredentials: null,
10
+ forcePathStyle: false,
11
+ });
12
+ };
13
+ exports.getCloudWatchLogsClient = getCloudWatchLogsClient;
14
+ const getLambdaClient = (region,
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ _timeoutInTest) => {
17
+ return (0, get_service_client_1.getServiceClient)({
18
+ region,
19
+ service: 'lambda',
20
+ customCredentials: null,
21
+ forcePathStyle: false,
22
+ });
23
+ };
24
+ exports.getLambdaClient = getLambdaClient;
25
+ const getIamClient = (region) => {
26
+ return (0, get_service_client_1.getServiceClient)({
27
+ region,
28
+ service: 'iam',
29
+ customCredentials: null,
30
+ forcePathStyle: false,
31
+ });
32
+ };
33
+ exports.getIamClient = getIamClient;
34
+ const getServiceQuotasClient = (region) => {
35
+ return (0, get_service_client_1.getServiceClient)({
36
+ region,
37
+ service: 'servicequotas',
38
+ customCredentials: null,
39
+ forcePathStyle: false,
40
+ });
41
+ };
42
+ exports.getServiceQuotasClient = getServiceQuotasClient;
43
+ const getStsClient = (region) => {
44
+ return (0, get_service_client_1.getServiceClient)({
45
+ region,
46
+ service: 'sts',
47
+ customCredentials: null,
48
+ forcePathStyle: false,
49
+ });
50
+ };
51
+ exports.getStsClient = getStsClient;
@@ -0,0 +1,23 @@
1
+ import type { AwsRegion } from './regions';
2
+ export type AwsProvider = {
3
+ type: 'aws';
4
+ region: AwsRegion;
5
+ receivedArtifactType: {
6
+ s3Key: string;
7
+ s3Url: string;
8
+ };
9
+ creationFunctionOptions: {
10
+ createCloudWatchLogGroup: boolean;
11
+ accountId: string;
12
+ alreadyCreated: boolean;
13
+ retentionInDays: number;
14
+ customRoleArn: string;
15
+ enableLambdaInsights: boolean;
16
+ vpcSubnetIds: string;
17
+ vpcSecurityGroupIds: string;
18
+ runtimePreference: RuntimePreference;
19
+ };
20
+ };
21
+ import type { ProviderSpecifics } from '@remotion/serverless-client';
22
+ import type { RuntimePreference } from './runtime-preference';
23
+ export declare const awsImplementation: ProviderSpecifics<AwsProvider>;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.awsImplementation = void 0;
5
+ const serverless_client_1 = require("@remotion/serverless-client");
6
+ const node_events_1 = require("node:events");
7
+ const bucket_exists_1 = require("./bucket-exists");
8
+ const call_lambda_async_1 = require("./call-lambda-async");
9
+ const call_lambda_streaming_1 = require("./call-lambda-streaming");
10
+ const call_lambda_sync_1 = require("./call-lambda-sync");
11
+ const check_credentials_1 = require("./check-credentials");
12
+ const constants_1 = require("./constants");
13
+ const convert_to_serve_url_1 = require("./convert-to-serve-url");
14
+ const create_bucket_1 = require("./create-bucket");
15
+ const delete_file_1 = require("./delete-file");
16
+ const delete_function_1 = require("./delete-function");
17
+ const estimate_price_1 = require("./estimate-price");
18
+ const get_account_id_1 = require("./get-account-id");
19
+ const get_aws_urls_1 = require("./get-aws-urls");
20
+ const get_buckets_1 = require("./get-buckets");
21
+ const get_functions_1 = require("./get-functions");
22
+ const get_output_url_from_metadata_1 = require("./get-output-url-from-metadata");
23
+ const head_file_1 = require("./head-file");
24
+ const is_flaky_error_1 = require("./is-flaky-error");
25
+ const lifecycle_rules_1 = require("./lifecycle-rules");
26
+ const list_objects_1 = require("./list-objects");
27
+ const parse_function_name_1 = require("./parse-function-name");
28
+ const random_hash_1 = require("./random-hash");
29
+ const read_file_1 = require("./read-file");
30
+ const write_file_1 = require("./write-file");
31
+ if (/^AWS_Lambda_nodejs(?:18|20)[.]x$/.test((_a = process.env.AWS_EXECUTION_ENV) !== null && _a !== void 0 ? _a : '') === true) {
32
+ process.env.FONTCONFIG_PATH = '/opt';
33
+ process.env.FONTCONFIG_FILE = '/opt/fonts.conf';
34
+ process.env.DISABLE_FROM_SURFACE = '1';
35
+ process.env.NO_COLOR = '1';
36
+ // @ts-expect-error
37
+ globalThis._dumpUnreleasedBuffers = new node_events_1.EventEmitter();
38
+ // @ts-expect-error
39
+ globalThis._dumpUnreleasedBuffers.setMaxListeners(201);
40
+ }
41
+ const validateDeleteAfter = (lifeCycleValue) => {
42
+ if (lifeCycleValue === null) {
43
+ return;
44
+ }
45
+ if (lifeCycleValue === undefined) {
46
+ return;
47
+ }
48
+ if (typeof lifeCycleValue !== 'string') {
49
+ throw new TypeError(`Expected life cycle value to be a string, got ${JSON.stringify(lifeCycleValue)}`);
50
+ }
51
+ if (!(lifeCycleValue in serverless_client_1.expiryDays)) {
52
+ throw new TypeError(`Expected deleteAfter value to be one of ${Object.keys(serverless_client_1.expiryDays).join(', ')}, got ${lifeCycleValue}`);
53
+ }
54
+ };
55
+ exports.awsImplementation = {
56
+ getChromiumPath() {
57
+ return '/opt/bin/chromium';
58
+ },
59
+ getBuckets: get_buckets_1.getRemotionBuckets,
60
+ createBucket: create_bucket_1.createBucket,
61
+ applyLifeCycle: lifecycle_rules_1.applyLifeCyleOperation,
62
+ listObjects: list_objects_1.lambdaLsImplementation,
63
+ deleteFile: delete_file_1.lambdaDeleteFileImplementation,
64
+ bucketExists: bucket_exists_1.bucketExistsInRegionImplementation,
65
+ randomHash: random_hash_1.randomHashImplementation,
66
+ readFile: read_file_1.lambdaReadFileImplementation,
67
+ writeFile: write_file_1.lambdaWriteFileImplementation,
68
+ headFile: head_file_1.lambdaHeadFileImplementation,
69
+ convertToServeUrl: convert_to_serve_url_1.convertToServeUrlImplementation,
70
+ printLoggingHelper: true,
71
+ validateDeleteAfter,
72
+ callFunctionAsync: call_lambda_async_1.callFunctionAsyncImplementation,
73
+ callFunctionStreaming: call_lambda_streaming_1.callFunctionWithStreamingImplementation,
74
+ callFunctionSync: call_lambda_sync_1.callFunctionSyncImplementation,
75
+ getEphemeralStorageForPriceCalculation() {
76
+ // We cannot determine the ephemeral storage size, so we
77
+ // overestimate the price, but will only have a miniscule effect (~0.2%)
78
+ return constants_1.MAX_EPHEMERAL_STORAGE_IN_MB;
79
+ },
80
+ estimatePrice: estimate_price_1.estimatePrice,
81
+ getLoggingUrlForMethod: get_aws_urls_1.getCloudwatchMethodUrl,
82
+ getLoggingUrlForRendererFunction: get_aws_urls_1.getCloudwatchRendererUrl,
83
+ isFlakyError: is_flaky_error_1.isFlakyError,
84
+ getOutputUrl: get_output_url_from_metadata_1.getOutputUrlFromMetadata,
85
+ serverStorageProductName: () => 'S3',
86
+ getMaxStillInlinePayloadSize: () => 5000000,
87
+ getMaxNonInlinePayloadSizePerFunction: () => 200000,
88
+ getAccountId: get_account_id_1.getAccountIdImplementation,
89
+ deleteFunction: delete_function_1.deleteFunction,
90
+ getFunctions: get_functions_1.getFunctions,
91
+ parseFunctionName: parse_function_name_1.parseFunctionName,
92
+ checkCredentials: check_credentials_1.checkCredentials,
93
+ getBucketPrefix: () => constants_1.REMOTION_BUCKET_PREFIX,
94
+ };
@@ -0,0 +1,3 @@
1
+ import type { ProviderSpecifics } from '@remotion/serverless-client';
2
+ import type { AwsProvider } from './aws-provider';
3
+ export declare const bucketExistsInRegionImplementation: ProviderSpecifics<AwsProvider>['bucketExists'];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bucketExistsInRegionImplementation = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const get_s3_client_1 = require("./get-s3-client");
6
+ const bucketExistsInRegionImplementation = async ({ bucketName, region, expectedBucketOwner, forcePathStyle }) => {
7
+ var _a;
8
+ try {
9
+ const bucket = await (0, get_s3_client_1.getS3Client)({
10
+ region,
11
+ customCredentials: null,
12
+ forcePathStyle,
13
+ }).send(new client_s3_1.GetBucketLocationCommand({
14
+ Bucket: bucketName,
15
+ ExpectedBucketOwner: expectedBucketOwner !== null && expectedBucketOwner !== void 0 ? expectedBucketOwner : undefined,
16
+ }));
17
+ return ((_a = bucket.LocationConstraint) !== null && _a !== void 0 ? _a : 'us-east-1') === region;
18
+ }
19
+ catch (err) {
20
+ if (err.Code === 'NoSuchBucket') {
21
+ return false;
22
+ }
23
+ throw err;
24
+ }
25
+ };
26
+ exports.bucketExistsInRegionImplementation = bucketExistsInRegionImplementation;
@@ -0,0 +1,2 @@
1
+ import type { CallFunctionOptions, CloudProvider, ServerlessRoutines } from '@remotion/serverless-client';
2
+ export declare const callFunctionAsyncImplementation: <T extends ServerlessRoutines, Provider extends CloudProvider>({ functionName, payload, region, timeoutInTest, }: CallFunctionOptions<T, Provider>) => Promise<void>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callFunctionAsyncImplementation = void 0;
4
+ const client_lambda_1 = require("@aws-sdk/client-lambda");
5
+ const aws_clients_1 = require("./aws-clients");
6
+ const callFunctionAsyncImplementation = async ({ functionName, payload, region, timeoutInTest, }) => {
7
+ const stringifiedPayload = JSON.stringify(payload);
8
+ if (stringifiedPayload.length > 256 * 1024) {
9
+ throw new Error(`Payload is too big: ${stringifiedPayload.length} bytes. Maximum size is 256 KB. This should not happen, please report this to the Remotion team. Payload: ${stringifiedPayload}`);
10
+ }
11
+ const result = await (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeCommand({
12
+ FunctionName: functionName,
13
+ Payload: stringifiedPayload,
14
+ InvocationType: 'Event',
15
+ }));
16
+ if (result.FunctionError) {
17
+ throw new Error(`Lambda function returned error: ${result.FunctionError} ${result.LogResult}`);
18
+ }
19
+ };
20
+ exports.callFunctionAsyncImplementation = callFunctionAsyncImplementation;
@@ -0,0 +1,6 @@
1
+ import type { CallFunctionOptions, CloudProvider, OnMessage, ServerlessRoutines } from '@remotion/serverless-client';
2
+ export declare const parseJsonOrThrowSource: (data: Uint8Array, type: string) => any;
3
+ export declare const callFunctionWithStreamingImplementation: <Provider extends CloudProvider, T extends ServerlessRoutines>(options: CallFunctionOptions<T, Provider> & {
4
+ receivedStreamingPayload: OnMessage<Provider>;
5
+ retriesRemaining: number;
6
+ }) => Promise<void>;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callFunctionWithStreamingImplementation = exports.parseJsonOrThrowSource = void 0;
4
+ const client_lambda_1 = require("@aws-sdk/client-lambda");
5
+ const serverless_client_1 = require("@remotion/serverless-client");
6
+ const aws_clients_1 = require("./aws-clients");
7
+ const STREAM_STALL_TIMEOUT = 30000;
8
+ const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
9
+ const parseJsonOrThrowSource = (data, type) => {
10
+ const asString = new TextDecoder('utf-8').decode(data);
11
+ try {
12
+ return JSON.parse(asString);
13
+ }
14
+ catch (_a) {
15
+ throw new Error(`Invalid JSON (${type}): ${asString}`);
16
+ }
17
+ };
18
+ exports.parseJsonOrThrowSource = parseJsonOrThrowSource;
19
+ const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
20
+ const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
21
+ FunctionName: functionName,
22
+ Payload: JSON.stringify({ type, ...payload }),
23
+ }));
24
+ let cleanup = () => undefined;
25
+ const timeout = new Promise((_resolve, reject) => {
26
+ const int = setTimeout(() => {
27
+ reject(new Error(LAMBDA_STREAM_STALL));
28
+ }, STREAM_STALL_TIMEOUT);
29
+ cleanup = () => {
30
+ clearTimeout(int);
31
+ };
32
+ });
33
+ const res = await Promise.race([resProm, timeout]);
34
+ cleanup();
35
+ return res;
36
+ };
37
+ const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
38
+ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
39
+ const res = await invokeStreamOrTimeout({
40
+ functionName,
41
+ payload,
42
+ region,
43
+ timeoutInTest,
44
+ type,
45
+ });
46
+ const { onData, clear } = (0, serverless_client_1.makeStreamer)((status, messageTypeId, data) => {
47
+ const messageType = (0, serverless_client_1.messageTypeIdToMessageType)(messageTypeId);
48
+ const innerPayload = serverless_client_1.formatMap[messageType] === 'json'
49
+ ? (0, exports.parseJsonOrThrowSource)(data, messageType)
50
+ : data;
51
+ const message = {
52
+ successType: status,
53
+ message: {
54
+ type: messageType,
55
+ payload: innerPayload,
56
+ },
57
+ };
58
+ receivedStreamingPayload(message);
59
+ });
60
+ const dumpBuffers = () => {
61
+ clear();
62
+ };
63
+ // @ts-expect-error - We are adding a listener to a global variable
64
+ if (globalThis._dumpUnreleasedBuffers) {
65
+ // @ts-expect-error - We are adding a listener to a global variable
66
+ globalThis._dumpUnreleasedBuffers.addListener('dump-unreleased-buffers', dumpBuffers);
67
+ }
68
+ const events = res.EventStream;
69
+ for await (const event of events) {
70
+ // There are two types of events you can get on a stream.
71
+ // `PayloadChunk`: These contain the actual raw bytes of the chunk
72
+ // It has a single property: `Payload`
73
+ if (event.PayloadChunk && event.PayloadChunk.Payload) {
74
+ onData(event.PayloadChunk.Payload);
75
+ }
76
+ if (event.InvokeComplete) {
77
+ if (event.InvokeComplete.ErrorCode) {
78
+ const logs = `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#logsV2:logs-insights$3FqueryDetail$3D~(end~0~start~-3600~timeType~'RELATIVE~unit~'seconds~editorString~'fields*20*40timestamp*2c*20*40requestId*2c*20*40message*0a*7c*20filter*20*40requestId*20like*20*${res.$metadata.requestId}*22*0a*7c*20sort*20*40timestamp*20asc~source~(~'*2faws*2flambda*2f${functionName}))`;
79
+ if (event.InvokeComplete.ErrorCode === 'Unhandled') {
80
+ throw new Error(`Lambda function ${functionName} failed with an unhandled error: ${event.InvokeComplete.ErrorDetails} See ${logs} to see the logs of this invocation.`);
81
+ }
82
+ 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.`);
83
+ }
84
+ }
85
+ // Don't put a `break` statement here, as it will cause the socket to not properly exit.
86
+ }
87
+ // @ts-expect-error - We are adding a listener to a global variable
88
+ if (globalThis._dumpUnreleasedBuffers) {
89
+ // @ts-expect-error - We are adding a listener to a global variable
90
+ globalThis._dumpUnreleasedBuffers.removeListener('dump-unreleased-buffers', dumpBuffers);
91
+ }
92
+ clear();
93
+ };
94
+ const callFunctionWithStreamingImplementation = async (options) => {
95
+ // As of August 2023, Lambda streaming sometimes misses parts of the JSON response.
96
+ // Handling this for now by applying a retry mechanism.
97
+ var _a;
98
+ try {
99
+ // Do not remove this await
100
+ await callLambdaWithStreamingWithoutRetry(options);
101
+ }
102
+ catch (err) {
103
+ if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('TooManyRequestsException')) {
104
+ throw new Error(`AWS Concurrency limit reached (Original Error: ${err.message}). See https://www.remotion.dev/docs/lambda/troubleshooting/rate-limit for tips to fix this.`);
105
+ }
106
+ if (!err.message.includes(INVALID_JSON_MESSAGE) &&
107
+ !err.message.includes(LAMBDA_STREAM_STALL) &&
108
+ // https://discord.com/channels/809501355504959528/1332166561242288220/1332166561242288220
109
+ !err.message.includes('Runtime.TruncatedResponse') &&
110
+ !err.message.includes('aborted')) {
111
+ throw err;
112
+ }
113
+ console.error('Retries remaining:', options.retriesRemaining);
114
+ if (options.retriesRemaining === 0) {
115
+ console.error('Throwing error:');
116
+ throw err;
117
+ }
118
+ console.error(err);
119
+ return (0, exports.callFunctionWithStreamingImplementation)({
120
+ ...options,
121
+ retriesRemaining: options.retriesRemaining - 1,
122
+ });
123
+ }
124
+ };
125
+ exports.callFunctionWithStreamingImplementation = callFunctionWithStreamingImplementation;
@@ -0,0 +1,2 @@
1
+ import type { CallFunctionOptions, CloudProvider, ServerlessReturnValues, ServerlessRoutines } from '@remotion/serverless-client';
2
+ export declare const callFunctionSyncImplementation: <Provider extends CloudProvider, T extends ServerlessRoutines>(options: CallFunctionOptions<T, Provider>) => Promise<ServerlessReturnValues<Provider>[T]>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.callFunctionSyncImplementation = void 0;
4
+ const client_lambda_1 = require("@aws-sdk/client-lambda");
5
+ const aws_clients_1 = require("./aws-clients");
6
+ const callLambdaSyncWithoutRetry = async ({ functionName, payload, region, timeoutInTest, }) => {
7
+ const Payload = JSON.stringify(payload);
8
+ const res = await (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeCommand({
9
+ FunctionName: functionName,
10
+ Payload,
11
+ InvocationType: 'RequestResponse',
12
+ }));
13
+ const decoded = new TextDecoder('utf-8').decode(res.Payload);
14
+ try {
15
+ return JSON.parse(decoded);
16
+ }
17
+ catch (_a) {
18
+ throw new Error(`Invalid JSON: ${JSON.stringify(decoded)}`);
19
+ }
20
+ };
21
+ const callFunctionSyncImplementation = async (options) => {
22
+ const res = await callLambdaSyncWithoutRetry(options);
23
+ if (res.type === 'error') {
24
+ const err = new Error(res.message);
25
+ err.stack = res.stack;
26
+ throw err;
27
+ }
28
+ return res;
29
+ };
30
+ exports.callFunctionSyncImplementation = callFunctionSyncImplementation;
@@ -0,0 +1 @@
1
+ export declare const checkCredentials: () => void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkCredentials = void 0;
4
+ const serverless_client_1 = require("@remotion/serverless-client");
5
+ const get_env_variable_1 = require("./get-env-variable");
6
+ const is_cli_1 = require("./is-cli");
7
+ const is_likely_to_have_aws_profile_1 = require("./is-likely-to-have-aws-profile");
8
+ const messageForVariable = (variable) => {
9
+ return [
10
+ `You have tried to call a Remotion Lambda function, but have not set the environment variable ${variable}.`,
11
+ (0, is_cli_1.getIsCli)()
12
+ ? null
13
+ : `- Environment variables from a '.env' file are not automatically read if you are calling the Node.JS APIs, in that case you need to load the file yourself or set the environment variables manually.`,
14
+ `- Please refer to the Remotion Lambda docs (${serverless_client_1.DOCS_URL}/docs/lambda/setup) to see how to generate the credentials for your AWS account and then set the environment variables.`,
15
+ `- For more reasons see the troubleshooting page: ${serverless_client_1.DOCS_URL}/docs/lambda/troubleshooting/permissions`,
16
+ ]
17
+ .filter(serverless_client_1.truthy)
18
+ .join('\n');
19
+ };
20
+ const checkCredentials = () => {
21
+ if ((0, get_env_variable_1.getEnvVariable)('REMOTION_SKIP_AWS_CREDENTIALS_CHECK')) {
22
+ return;
23
+ }
24
+ if ((0, get_env_variable_1.getEnvVariable)('REMOTION_AWS_PROFILE') || (0, get_env_variable_1.getEnvVariable)('AWS_PROFILE')) {
25
+ return;
26
+ }
27
+ if ((0, is_likely_to_have_aws_profile_1.isLikelyToHaveAwsProfile)()) {
28
+ return;
29
+ }
30
+ if (!(0, get_env_variable_1.getEnvVariable)('AWS_ACCESS_KEY_ID') &&
31
+ !(0, get_env_variable_1.getEnvVariable)('REMOTION_AWS_ACCESS_KEY_ID')) {
32
+ throw new Error(messageForVariable('AWS_ACCESS_KEY_ID or REMOTION_AWS_ACCESS_KEY_ID'));
33
+ }
34
+ if (!(0, get_env_variable_1.getEnvVariable)('AWS_SECRET_ACCESS_KEY') &&
35
+ !(0, get_env_variable_1.getEnvVariable)('REMOTION_AWS_SECRET_ACCESS_KEY')) {
36
+ throw new Error(messageForVariable('AWS_SECRET_ACCESS_KEY or REMOTION_AWS_SECRET_ACCESS_KEY'));
37
+ }
38
+ };
39
+ exports.checkCredentials = checkCredentials;
@@ -0,0 +1,16 @@
1
+ import type { CloudProvider, ProviderSpecifics } from '@remotion/serverless-client';
2
+ export declare const cleanItems: <Provider extends CloudProvider>({ bucket, onAfterItemDeleted, onBeforeItemDeleted, region, list, providerSpecifics, forcePathStyle, }: {
3
+ bucket: string;
4
+ region: Provider["region"];
5
+ list: string[];
6
+ onBeforeItemDeleted: (data: {
7
+ bucketName: string;
8
+ itemName: string;
9
+ }) => void;
10
+ onAfterItemDeleted: (data: {
11
+ bucketName: string;
12
+ itemName: string;
13
+ }) => void;
14
+ providerSpecifics: ProviderSpecifics<Provider>;
15
+ forcePathStyle: boolean;
16
+ }) => Promise<void[]>;