@remotion/lambda 4.0.244 → 4.0.246

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 (258) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/admin/make-layer-public.js +10 -11
  3. package/dist/api/app-router-webhook.d.ts +10 -0
  4. package/dist/api/app-router-webhook.js +43 -0
  5. package/dist/api/create-function.d.ts +1 -2
  6. package/dist/api/create-function.js +10 -10
  7. package/dist/api/delete-function.d.ts +4 -13
  8. package/dist/api/delete-function.js +2 -5
  9. package/dist/api/delete-render.d.ts +0 -8
  10. package/dist/api/delete-render.js +4 -10
  11. package/dist/api/delete-site.d.ts +0 -10
  12. package/dist/api/delete-site.js +4 -11
  13. package/dist/api/deploy-function.d.ts +8 -15
  14. package/dist/api/deploy-function.js +21 -27
  15. package/dist/api/deploy-site.d.ts +2 -11
  16. package/dist/api/deploy-site.js +14 -22
  17. package/dist/api/download-media.d.ts +0 -11
  18. package/dist/api/download-media.js +3 -12
  19. package/dist/api/estimate-price.d.ts +0 -6
  20. package/dist/api/estimate-price.js +1 -3
  21. package/dist/api/get-aws-client.d.ts +1 -9
  22. package/dist/api/get-aws-client.js +2 -6
  23. package/dist/api/get-compositions-on-lambda.d.ts +1 -14
  24. package/dist/api/get-compositions-on-lambda.js +12 -17
  25. package/dist/api/get-function-info.d.ts +1 -14
  26. package/dist/api/get-function-info.js +2 -5
  27. package/dist/api/get-functions.d.ts +1 -8
  28. package/dist/api/get-functions.js +2 -5
  29. package/dist/api/get-or-create-bucket.d.ts +0 -6
  30. package/dist/api/get-or-create-bucket.js +3 -5
  31. package/dist/api/get-regions.d.ts +0 -5
  32. package/dist/api/get-regions.js +3 -4
  33. package/dist/api/get-render-progress.d.ts +0 -10
  34. package/dist/api/get-render-progress.js +3 -11
  35. package/dist/api/get-sites.d.ts +0 -6
  36. package/dist/api/get-sites.js +4 -7
  37. package/dist/api/iam-validation/simulate.d.ts +0 -7
  38. package/dist/api/iam-validation/simulate.js +2 -5
  39. package/dist/api/iam-validation/suggested-policy.d.ts +0 -10
  40. package/dist/api/iam-validation/suggested-policy.js +2 -4
  41. package/dist/api/make-lambda-payload.d.ts +2 -1
  42. package/dist/api/make-lambda-payload.js +19 -13
  43. package/dist/api/pages-router-webhook.d.ts +3 -0
  44. package/dist/api/pages-router-webhook.js +47 -0
  45. package/dist/api/presign-url.d.ts +0 -10
  46. package/dist/api/presign-url.js +2 -8
  47. package/dist/api/render-media-on-lambda.d.ts +1 -20
  48. package/dist/api/render-media-on-lambda.js +4 -19
  49. package/dist/api/render-still-on-lambda.d.ts +2 -19
  50. package/dist/api/render-still-on-lambda.js +6 -17
  51. package/dist/api/speculate-function-name.d.ts +0 -8
  52. package/dist/api/speculate-function-name.js +3 -7
  53. package/dist/api/upload-dir.d.ts +1 -7
  54. package/dist/api/upload-dir.js +1 -5
  55. package/dist/api/validate-webhook-signature.d.ts +0 -8
  56. package/dist/api/validate-webhook-signature.js +3 -7
  57. package/dist/cli/args.d.ts +2 -1
  58. package/dist/cli/commands/compositions/index.d.ts +7 -1
  59. package/dist/cli/commands/compositions/index.js +2 -2
  60. package/dist/cli/commands/functions/deploy.d.ts +7 -1
  61. package/dist/cli/commands/functions/deploy.js +7 -2
  62. package/dist/cli/commands/functions/index.d.ts +8 -1
  63. package/dist/cli/commands/functions/index.js +8 -4
  64. package/dist/cli/commands/functions/ls.d.ts +6 -1
  65. package/dist/cli/commands/functions/ls.js +2 -3
  66. package/dist/cli/commands/functions/rmall.d.ts +6 -1
  67. package/dist/cli/commands/functions/rmall.js +2 -3
  68. package/dist/cli/commands/render/render.d.ts +6 -1
  69. package/dist/cli/commands/render/render.js +9 -7
  70. package/dist/cli/commands/sites/create.js +2 -0
  71. package/dist/cli/commands/sites/index.d.ts +1 -1
  72. package/dist/cli/commands/sites/index.js +4 -4
  73. package/dist/cli/commands/still.d.ts +2 -2
  74. package/dist/cli/commands/still.js +5 -5
  75. package/dist/cli/get-aws-region.js +0 -4
  76. package/dist/cli/helpers/find-function-name.d.ts +6 -1
  77. package/dist/cli/helpers/find-function-name.js +4 -5
  78. package/dist/cli/index.d.ts +2 -2
  79. package/dist/cli/index.js +36 -16
  80. package/dist/client.d.ts +17 -22
  81. package/dist/client.js +17 -13
  82. package/dist/functions/aws-implementation.d.ts +13 -1
  83. package/dist/functions/aws-implementation.js +46 -0
  84. package/dist/functions/aws-server-implementation.d.ts +2 -0
  85. package/dist/functions/aws-server-implementation.js +25 -0
  86. package/dist/functions/full-client-implementation.d.ts +3 -0
  87. package/dist/functions/full-client-implementation.js +16 -0
  88. package/dist/functions/helpers/clean-tmpdir.js +1 -3
  89. package/dist/functions/helpers/get-current-region.js +0 -4
  90. package/dist/functions/helpers/get-output-url-from-metadata.d.ts +3 -7
  91. package/dist/functions/helpers/get-output-url-from-metadata.js +1 -1
  92. package/dist/functions/helpers/lifecycle.d.ts +4 -2
  93. package/dist/functions/helpers/lifecycle.js +3 -18
  94. package/dist/functions/helpers/timer.d.ts +2 -4
  95. package/dist/functions/http-client.d.ts +7 -0
  96. package/dist/functions/http-client.js +22 -0
  97. package/dist/functions/index.d.ts +1 -8
  98. package/dist/functions/index.js +12 -235
  99. package/dist/index.d.ts +6 -6
  100. package/dist/index.js +27 -6
  101. package/dist/internals.d.ts +6 -5
  102. package/dist/pricing/price-per-1-s.js +102 -0
  103. package/dist/regions.d.ts +1 -1
  104. package/dist/regions.js +3 -0
  105. package/dist/shared/call-lambda-async.d.ts +3 -0
  106. package/dist/shared/call-lambda-async.js +20 -0
  107. package/dist/shared/call-lambda-streaming.d.ts +7 -0
  108. package/dist/shared/{call-lambda.js → call-lambda-streaming.js} +36 -61
  109. package/dist/shared/call-lambda-sync.d.ts +3 -0
  110. package/dist/shared/call-lambda-sync.js +30 -0
  111. package/dist/shared/check-credentials.js +2 -3
  112. package/dist/shared/constants.d.ts +2 -91
  113. package/dist/shared/constants.js +1 -8
  114. package/dist/shared/convert-to-serve-url.js +2 -2
  115. package/dist/shared/get-account-id.d.ts +3 -4
  116. package/dist/shared/get-account-id.js +3 -3
  117. package/dist/shared/get-aws-urls.d.ts +4 -8
  118. package/dist/shared/get-aws-urls.js +1 -1
  119. package/dist/shared/get-function-version.js +4 -4
  120. package/dist/shared/get-layers.d.ts +1 -2
  121. package/dist/shared/get-layers.js +2 -4
  122. package/dist/shared/get-s3-operations.d.ts +4 -1
  123. package/dist/shared/get-s3-operations.js +2 -3
  124. package/dist/shared/get-service-client.js +2 -2
  125. package/dist/shared/hosted-layers.d.ts +0 -1
  126. package/dist/shared/hosted-layers.js +139 -537
  127. package/dist/shared/lambda-insights-extensions.d.ts +1 -1
  128. package/dist/shared/lambda-insights-extensions.js +3 -0
  129. package/dist/shared/read-dir.d.ts +2 -10
  130. package/dist/shared/read-dir.js +5 -4
  131. package/dist/shared/validate-aws-region.js +1 -1
  132. package/dist/shared/validate-bucketname.d.ts +1 -1
  133. package/package.json +15 -15
  134. package/remotionlambda-arm64.zip +0 -0
  135. package/dist/api/__mocks__/clean-items.d.ts +0 -2
  136. package/dist/api/__mocks__/clean-items.js +0 -24
  137. package/dist/api/__mocks__/create-function.d.ts +0 -2
  138. package/dist/api/__mocks__/create-function.js +0 -21
  139. package/dist/api/__mocks__/delete-function.d.ts +0 -2
  140. package/dist/api/__mocks__/delete-function.js +0 -9
  141. package/dist/api/__mocks__/get-functions.d.ts +0 -2
  142. package/dist/api/__mocks__/get-functions.js +0 -9
  143. package/dist/api/__mocks__/upload-dir.d.ts +0 -3
  144. package/dist/api/__mocks__/upload-dir.js +0 -47
  145. package/dist/api/mock-functions.d.ts +0 -18
  146. package/dist/api/mock-functions.js +0 -36
  147. package/dist/cli/helpers/__mocks__/quit.d.ts +0 -1
  148. package/dist/cli/helpers/__mocks__/quit.js +0 -7
  149. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +0 -7
  150. package/dist/functions/chunk-optimization/plan-frame-ranges.js +0 -17
  151. package/dist/functions/chunk-optimization/types.d.ts +0 -8
  152. package/dist/functions/chunk-optimization/types.js +0 -2
  153. package/dist/functions/helpers/__mocks__/get-browser-instance.d.ts +0 -3
  154. package/dist/functions/helpers/__mocks__/get-browser-instance.js +0 -12
  155. package/dist/functions/helpers/__mocks__/leak-detection.d.ts +0 -4
  156. package/dist/functions/helpers/__mocks__/leak-detection.js +0 -9
  157. package/dist/functions/helpers/__mocks__/timer.d.ts +0 -2
  158. package/dist/functions/helpers/__mocks__/timer.js +0 -10
  159. package/dist/functions/helpers/best-frames-per-lambda-param.d.ts +0 -1
  160. package/dist/functions/helpers/best-frames-per-lambda-param.js +0 -17
  161. package/dist/functions/helpers/calculate-chunk-times.d.ts +0 -5
  162. package/dist/functions/helpers/calculate-chunk-times.js +0 -29
  163. package/dist/functions/helpers/calculate-price-from-bucket.d.ts +0 -15
  164. package/dist/functions/helpers/calculate-price-from-bucket.js +0 -30
  165. package/dist/functions/helpers/can-concat-seamlessly.d.ts +0 -3
  166. package/dist/functions/helpers/can-concat-seamlessly.js +0 -17
  167. package/dist/functions/helpers/cleanup-props.d.ts +0 -8
  168. package/dist/functions/helpers/cleanup-props.js +0 -23
  169. package/dist/functions/helpers/concat-videos.d.ts +0 -23
  170. package/dist/functions/helpers/concat-videos.js +0 -54
  171. package/dist/functions/helpers/create-post-render-data.d.ts +0 -17
  172. package/dist/functions/helpers/create-post-render-data.js +0 -67
  173. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +0 -14
  174. package/dist/functions/helpers/find-output-file-in-bucket.js +0 -38
  175. package/dist/functions/helpers/format-costs-info.d.ts +0 -2
  176. package/dist/functions/helpers/format-costs-info.js +0 -23
  177. package/dist/functions/helpers/get-overall-progress-s3.d.ts +0 -10
  178. package/dist/functions/helpers/get-overall-progress-s3.js +0 -24
  179. package/dist/functions/helpers/get-overall-progress.d.ts +0 -9
  180. package/dist/functions/helpers/get-overall-progress.js +0 -23
  181. package/dist/functions/helpers/get-progress.d.ts +0 -15
  182. package/dist/functions/helpers/get-progress.js +0 -254
  183. package/dist/functions/helpers/get-retry-stats.d.ts +0 -5
  184. package/dist/functions/helpers/get-retry-stats.js +0 -2
  185. package/dist/functions/helpers/inspect-errors.d.ts +0 -4
  186. package/dist/functions/helpers/inspect-errors.js +0 -39
  187. package/dist/functions/helpers/is-warm.d.ts +0 -2
  188. package/dist/functions/helpers/is-warm.js +0 -10
  189. package/dist/functions/helpers/leak-detection.d.ts +0 -4
  190. package/dist/functions/helpers/leak-detection.js +0 -40
  191. package/dist/functions/helpers/make-timeout-error.d.ts +0 -10
  192. package/dist/functions/helpers/make-timeout-error.js +0 -31
  193. package/dist/functions/helpers/make-timeout-message.d.ts +0 -10
  194. package/dist/functions/helpers/make-timeout-message.js +0 -75
  195. package/dist/functions/helpers/merge-chunks.d.ts +0 -36
  196. package/dist/functions/helpers/merge-chunks.js +0 -84
  197. package/dist/functions/helpers/min-max.d.ts +0 -2
  198. package/dist/functions/helpers/min-max.js +0 -33
  199. package/dist/functions/helpers/on-downloads-logger.d.ts +0 -2
  200. package/dist/functions/helpers/on-downloads-logger.js +0 -29
  201. package/dist/functions/helpers/overall-render-progress.d.ts +0 -59
  202. package/dist/functions/helpers/overall-render-progress.js +0 -180
  203. package/dist/functions/helpers/print-concurrency-curve.d.ts +0 -1
  204. package/dist/functions/helpers/print-concurrency-curve.js +0 -8
  205. package/dist/functions/helpers/print-logging-helper.d.ts +0 -4
  206. package/dist/functions/helpers/print-logging-helper.js +0 -12
  207. package/dist/functions/helpers/render-has-audio-video.d.ts +0 -6
  208. package/dist/functions/helpers/render-has-audio-video.js +0 -21
  209. package/dist/functions/helpers/request-context.d.ts +0 -5
  210. package/dist/functions/helpers/request-context.js +0 -2
  211. package/dist/functions/helpers/stream-renderer.d.ts +0 -17
  212. package/dist/functions/helpers/stream-renderer.js +0 -148
  213. package/dist/functions/launch.d.ts +0 -10
  214. package/dist/functions/launch.js +0 -596
  215. package/dist/functions/progress.d.ts +0 -11
  216. package/dist/functions/progress.js +0 -51
  217. package/dist/functions/renderer.d.ts +0 -17
  218. package/dist/functions/renderer.js +0 -341
  219. package/dist/functions/start.d.ts +0 -13
  220. package/dist/functions/start.js +0 -113
  221. package/dist/functions/still.d.ts +0 -19
  222. package/dist/functions/still.js +0 -330
  223. package/dist/shared/__mocks__/aws-clients.d.ts +0 -2
  224. package/dist/shared/__mocks__/aws-clients.js +0 -62
  225. package/dist/shared/__mocks__/bundle-site.d.ts +0 -2
  226. package/dist/shared/__mocks__/bundle-site.js +0 -32
  227. package/dist/shared/__mocks__/check-credentials.d.ts +0 -1
  228. package/dist/shared/__mocks__/check-credentials.js +0 -5
  229. package/dist/shared/__mocks__/get-account-id.d.ts +0 -2
  230. package/dist/shared/__mocks__/get-account-id.js +0 -11
  231. package/dist/shared/__mocks__/read-dir.d.ts +0 -2
  232. package/dist/shared/__mocks__/read-dir.js +0 -13
  233. package/dist/shared/call-lambda.d.ts +0 -16
  234. package/dist/shared/cleanup-serialized-input-props.d.ts +0 -14
  235. package/dist/shared/cleanup-serialized-input-props.js +0 -34
  236. package/dist/shared/docs-url.d.ts +0 -1
  237. package/dist/shared/docs-url.js +0 -4
  238. package/dist/shared/get-most-expensive-chunks.d.ts +0 -8
  239. package/dist/shared/get-most-expensive-chunks.js +0 -28
  240. package/dist/shared/invoke-webhook.d.ts +0 -48
  241. package/dist/shared/invoke-webhook.js +0 -140
  242. package/dist/shared/parse-lambda-timings-key.d.ts +0 -5
  243. package/dist/shared/parse-lambda-timings-key.js +0 -2
  244. package/dist/shared/return-values.d.ts +0 -16
  245. package/dist/shared/return-values.js +0 -2
  246. package/dist/shared/stackback.d.ts +0 -6
  247. package/dist/shared/stackback.js +0 -59
  248. package/dist/shared/validate-download-behavior.d.ts +0 -1
  249. package/dist/shared/validate-download-behavior.js +0 -21
  250. package/dist/shared/validate-frames-per-lambda.d.ts +0 -4
  251. package/dist/shared/validate-frames-per-lambda.js +0 -29
  252. package/dist/shared/validate-privacy.d.ts +0 -2
  253. package/dist/shared/validate-privacy.js +0 -14
  254. package/dist/shared/validate.d.ts +0 -4
  255. package/dist/shared/validate.js +0 -8
  256. package/dist/shared/why-is-node-running.d.ts +0 -15
  257. package/dist/shared/why-is-node-running.js +0 -88
  258. package/vitest.config.mts +0 -11
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.callLambdaWithStreaming = exports.callLambda = void 0;
3
+ exports.callFunctionWithStreamingImplementation = exports.parseJsonOrThrowSource = void 0;
4
4
  const client_lambda_1 = require("@aws-sdk/client-lambda");
5
5
  const client_1 = require("@remotion/serverless/client");
6
6
  const streaming_1 = require("@remotion/streaming");
7
7
  const aws_clients_1 = require("./aws-clients");
8
- const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
8
+ const STREAM_STALL_TIMEOUT = 30000;
9
+ const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
9
10
  const parseJsonOrThrowSource = (data, type) => {
10
11
  const asString = new TextDecoder('utf-8').decode(data);
11
12
  try {
@@ -15,64 +16,7 @@ const parseJsonOrThrowSource = (data, type) => {
15
16
  throw new Error(`Invalid JSON (${type}): ${asString}`);
16
17
  }
17
18
  };
18
- const callLambda = async (options) => {
19
- // Do not remove this await
20
- const res = await callLambdaWithoutRetry(options);
21
- if (res.type === 'error') {
22
- const err = new Error(res.message);
23
- err.stack = res.stack;
24
- throw err;
25
- }
26
- return res;
27
- };
28
- exports.callLambda = callLambda;
29
- const callLambdaWithStreaming = async (options) => {
30
- // As of August 2023, Lambda streaming sometimes misses parts of the JSON response.
31
- // Handling this for now by applying a retry mechanism.
32
- var _a;
33
- try {
34
- // Do not remove this await
35
- await callLambdaWithStreamingWithoutRetry(options);
36
- }
37
- catch (err) {
38
- if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('TooManyRequestsException')) {
39
- 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.`);
40
- }
41
- if (!err.message.includes(INVALID_JSON_MESSAGE) &&
42
- !err.message.includes(LAMBDA_STREAM_STALL) &&
43
- !err.message.includes('aborted')) {
44
- throw err;
45
- }
46
- console.error('Retries remaining:', options.retriesRemaining);
47
- if (options.retriesRemaining === 0) {
48
- console.error('Throwing error:');
49
- throw err;
50
- }
51
- console.error(err);
52
- return (0, exports.callLambdaWithStreaming)({
53
- ...options,
54
- retriesRemaining: options.retriesRemaining - 1,
55
- });
56
- }
57
- };
58
- exports.callLambdaWithStreaming = callLambdaWithStreaming;
59
- const callLambdaWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, }) => {
60
- const Payload = JSON.stringify({ type, ...payload });
61
- const res = await (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeCommand({
62
- FunctionName: functionName,
63
- Payload,
64
- InvocationType: 'RequestResponse',
65
- }));
66
- const decoded = new TextDecoder('utf-8').decode(res.Payload);
67
- try {
68
- return JSON.parse(decoded);
69
- }
70
- catch (_a) {
71
- throw new Error(`Invalid JSON (${type}): ${JSON.stringify(decoded)}`);
72
- }
73
- };
74
- const STREAM_STALL_TIMEOUT = 30000;
75
- const LAMBDA_STREAM_STALL = `AWS did not invoke Lambda in ${STREAM_STALL_TIMEOUT}ms`;
19
+ exports.parseJsonOrThrowSource = parseJsonOrThrowSource;
76
20
  const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type, payload, }) => {
77
21
  const resProm = (0, aws_clients_1.getLambdaClient)(region, timeoutInTest).send(new client_lambda_1.InvokeWithResponseStreamCommand({
78
22
  FunctionName: functionName,
@@ -91,6 +35,7 @@ const invokeStreamOrTimeout = async ({ region, timeoutInTest, functionName, type
91
35
  cleanup();
92
36
  return res;
93
37
  };
38
+ const INVALID_JSON_MESSAGE = 'Cannot parse Lambda response as JSON';
94
39
  const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload, region, timeoutInTest, receivedStreamingPayload, }) => {
95
40
  const res = await invokeStreamOrTimeout({
96
41
  functionName,
@@ -102,7 +47,7 @@ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload
102
47
  const { onData, clear } = (0, streaming_1.makeStreamer)((status, messageTypeId, data) => {
103
48
  const messageType = (0, client_1.messageTypeIdToMessageType)(messageTypeId);
104
49
  const innerPayload = client_1.formatMap[messageType] === 'json'
105
- ? parseJsonOrThrowSource(data, messageType)
50
+ ? (0, exports.parseJsonOrThrowSource)(data, messageType)
106
51
  : data;
107
52
  const message = {
108
53
  successType: status,
@@ -147,3 +92,33 @@ const callLambdaWithStreamingWithoutRetry = async ({ functionName, type, payload
147
92
  }
148
93
  clear();
149
94
  };
95
+ const callFunctionWithStreamingImplementation = async (options) => {
96
+ // As of August 2023, Lambda streaming sometimes misses parts of the JSON response.
97
+ // Handling this for now by applying a retry mechanism.
98
+ var _a;
99
+ try {
100
+ // Do not remove this await
101
+ await callLambdaWithStreamingWithoutRetry(options);
102
+ }
103
+ catch (err) {
104
+ if ((_a = err.stack) === null || _a === void 0 ? void 0 : _a.includes('TooManyRequestsException')) {
105
+ 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.`);
106
+ }
107
+ if (!err.message.includes(INVALID_JSON_MESSAGE) &&
108
+ !err.message.includes(LAMBDA_STREAM_STALL) &&
109
+ !err.message.includes('aborted')) {
110
+ throw err;
111
+ }
112
+ console.error('Retries remaining:', options.retriesRemaining);
113
+ if (options.retriesRemaining === 0) {
114
+ console.error('Throwing error:');
115
+ throw err;
116
+ }
117
+ console.error(err);
118
+ return (0, exports.callFunctionWithStreamingImplementation)({
119
+ ...options,
120
+ retriesRemaining: options.retriesRemaining - 1,
121
+ });
122
+ }
123
+ };
124
+ exports.callFunctionWithStreamingImplementation = callFunctionWithStreamingImplementation;
@@ -0,0 +1,3 @@
1
+ import type { CallFunctionOptions, CloudProvider, ServerlessReturnValues } from '@remotion/serverless';
2
+ import type { ServerlessRoutines } from '@remotion/serverless/client';
3
+ 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;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkCredentials = void 0;
4
4
  const client_1 = require("@remotion/serverless/client");
5
5
  const is_cli_1 = require("../cli/is-cli");
6
- const docs_url_1 = require("./docs-url");
7
6
  const is_likely_to_have_aws_profile_1 = require("./is-likely-to-have-aws-profile");
8
7
  const messageForVariable = (variable) => {
9
8
  return [
@@ -11,8 +10,8 @@ const messageForVariable = (variable) => {
11
10
  (0, is_cli_1.getIsCli)()
12
11
  ? null
13
12
  : `- 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 (${docs_url_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: ${docs_url_1.DOCS_URL}/docs/lambda/troubleshooting/permissions`,
13
+ `- Please refer to the Remotion Lambda docs (${client_1.DOCS_URL}/docs/lambda/setup) to see how to generate the credentials for your AWS account and then set the environment variables.`,
14
+ `- For more reasons see the troubleshooting page: ${client_1.DOCS_URL}/docs/lambda/troubleshooting/permissions`,
16
15
  ]
17
16
  .filter(client_1.truthy)
18
17
  .join('\n');
@@ -1,22 +1,17 @@
1
- import type { CloudProvider, EnhancedErrorInfo, ReceivedArtifact } from '@remotion/serverless';
2
- import { type DeleteAfter, type Privacy, type RenderMetadata } from '@remotion/serverless/client';
1
+ import type { GenericRenderProgress } from '@remotion/serverless';
2
+ import { type Privacy } from '@remotion/serverless/client';
3
3
  import type { AwsProvider } from '../functions/aws-implementation';
4
- import type { ChunkRetry } from '../functions/helpers/get-retry-stats';
5
4
  import type { AwsRegion } from '../regions';
6
- import type { ExpensiveChunk } from './get-most-expensive-chunks';
7
5
  export declare const MIN_MEMORY = 512;
8
6
  export declare const MAX_MEMORY = 10240;
9
7
  export declare const DEFAULT_MEMORY_SIZE = 2048;
10
8
  export declare const DEFAULT_TIMEOUT = 120;
11
9
  export declare const MIN_TIMEOUT = 15;
12
10
  export declare const MAX_TIMEOUT = 900;
13
- export declare const MINIMUM_FRAMES_PER_LAMBDA = 4;
14
11
  export declare const DEFAULT_FRAMES_PER_LAMBDA = 20;
15
12
  export declare const BINARY_NAME = "remotion lambda";
16
- export declare const COMMAND_NOT_FOUND = "Command not found";
17
13
  export declare const DEFAULT_REGION: AwsRegion;
18
14
  export declare const DEFAULT_MAX_RETRIES = 1;
19
- export declare const MAX_FUNCTIONS_PER_RENDER = 200;
20
15
  export declare const MAX_EPHEMERAL_STORAGE_IN_MB = 10240;
21
16
  export declare const DEFAULT_EPHEMERAL_STORAGE_IN_MB: number;
22
17
  export declare const MIN_EPHEMERAL_STORAGE_IN_MB = 512;
@@ -26,89 +21,5 @@ export declare const RENDER_FN_PREFIX = "remotion-render-";
26
21
  export declare const LOG_GROUP_PREFIX = "/aws/lambda/";
27
22
  export declare const LAMBDA_INSIGHTS_PREFIX = "/aws/lambda-insights";
28
23
  export declare const getSitesKey: (siteId: string) => string;
29
- export declare const RENDERER_PATH_TOKEN = "remotion-bucket";
30
- export declare const CONCAT_FOLDER_TOKEN = "remotion-concat";
31
- export declare const REMOTION_CONCATED_TOKEN = "remotion-concated-token";
32
- export declare const REMOTION_FILELIST_TOKEN = "remotion-filelist";
33
- export type AfterRenderCost = {
34
- estimatedCost: number;
35
- estimatedDisplayCost: string;
36
- currency: string;
37
- disclaimer: string;
38
- };
39
- export type PostRenderData<Provider extends CloudProvider> = {
40
- cost: AfterRenderCost;
41
- outputFile: string;
42
- outputSize: number;
43
- renderSize: number;
44
- timeToFinish: number;
45
- timeToRenderFrames: number;
46
- errors: EnhancedErrorInfo[];
47
- startTime: number;
48
- endTime: number;
49
- filesCleanedUp: number;
50
- timeToEncode: number;
51
- timeToCleanUp: number;
52
- timeToRenderChunks: number;
53
- retriesInfo: ChunkRetry[];
54
- mostExpensiveFrameRanges: ExpensiveChunk[] | undefined;
55
- estimatedBillingDurationInMilliseconds: number;
56
- deleteAfter: DeleteAfter | null;
57
- timeToCombine: number | null;
58
- artifactProgress: ReceivedArtifact<Provider>[];
59
- };
60
- export type CostsInfo = {
61
- accruedSoFar: number;
62
- displayCost: string;
63
- currency: string;
64
- disclaimer: string;
65
- };
66
- export type CleanupInfo = {
67
- doneIn: number | null;
68
- minFilesToDelete: number;
69
- filesDeleted: number;
70
- };
71
- type EncodingProgress = {
72
- framesEncoded: number;
73
- combinedFrames: number;
74
- timeToCombine: number | null;
75
- };
76
- export type GenericRenderProgress<Provider extends CloudProvider> = {
77
- chunks: number;
78
- done: boolean;
79
- encodingStatus: EncodingProgress | null;
80
- costs: CostsInfo;
81
- renderId: string;
82
- renderMetadata: RenderMetadata<Provider> | null;
83
- bucket: string;
84
- outputFile: string | null;
85
- outKey: string | null;
86
- outBucket: string | null;
87
- timeToFinish: number | null;
88
- errors: EnhancedErrorInfo[];
89
- fatalErrorEncountered: boolean;
90
- currentTime: number;
91
- renderSize: number;
92
- lambdasInvoked: number;
93
- cleanup: CleanupInfo | null;
94
- timeToFinishChunks: number | null;
95
- timeToRenderFrames: number | null;
96
- timeToEncode: number | null;
97
- overallProgress: number;
98
- retriesInfo: ChunkRetry[];
99
- mostExpensiveFrameRanges: ExpensiveChunk[] | null;
100
- framesRendered: number;
101
- outputSizeInBytes: number | null;
102
- type: 'success';
103
- estimatedBillingDurationInMilliseconds: number | null;
104
- combinedFrames: number;
105
- timeToCombine: number | null;
106
- timeoutTimestamp: number;
107
- functionLaunched: number;
108
- serveUrlOpened: number | null;
109
- compositionValidated: number | null;
110
- artifacts: ReceivedArtifact<Provider>[];
111
- };
112
24
  export type RenderProgress = GenericRenderProgress<AwsProvider>;
113
25
  export declare const LAMBDA_CONCURRENCY_LIMIT_QUOTA = "L-B99A9384";
114
- export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.REMOTION_FILELIST_TOKEN = exports.REMOTION_CONCATED_TOKEN = exports.CONCAT_FOLDER_TOKEN = exports.RENDERER_PATH_TOKEN = exports.getSitesKey = exports.LAMBDA_INSIGHTS_PREFIX = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.MAX_FUNCTIONS_PER_RENDER = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.COMMAND_NOT_FOUND = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MINIMUM_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
3
+ exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = exports.getSitesKey = exports.LAMBDA_INSIGHTS_PREFIX = exports.LOG_GROUP_PREFIX = exports.RENDER_FN_PREFIX = exports.DEFAULT_CLOUDWATCH_RETENTION_PERIOD = exports.DEFAULT_OUTPUT_PRIVACY = exports.MIN_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = exports.MAX_EPHEMERAL_STORAGE_IN_MB = exports.DEFAULT_MAX_RETRIES = exports.DEFAULT_REGION = exports.BINARY_NAME = exports.DEFAULT_FRAMES_PER_LAMBDA = exports.MAX_TIMEOUT = exports.MIN_TIMEOUT = exports.DEFAULT_TIMEOUT = exports.DEFAULT_MEMORY_SIZE = exports.MAX_MEMORY = exports.MIN_MEMORY = void 0;
4
4
  const no_react_1 = require("remotion/no-react");
5
5
  exports.MIN_MEMORY = 512;
6
6
  exports.MAX_MEMORY = 10240;
@@ -8,13 +8,10 @@ exports.DEFAULT_MEMORY_SIZE = 2048;
8
8
  exports.DEFAULT_TIMEOUT = 120;
9
9
  exports.MIN_TIMEOUT = 15;
10
10
  exports.MAX_TIMEOUT = 900;
11
- exports.MINIMUM_FRAMES_PER_LAMBDA = 4;
12
11
  exports.DEFAULT_FRAMES_PER_LAMBDA = 20;
13
12
  exports.BINARY_NAME = 'remotion lambda';
14
- exports.COMMAND_NOT_FOUND = 'Command not found';
15
13
  exports.DEFAULT_REGION = 'us-east-1';
16
14
  exports.DEFAULT_MAX_RETRIES = 1;
17
- exports.MAX_FUNCTIONS_PER_RENDER = 200;
18
15
  exports.MAX_EPHEMERAL_STORAGE_IN_MB = 10240;
19
16
  exports.DEFAULT_EPHEMERAL_STORAGE_IN_MB = no_react_1.NoReactInternals.ENABLE_V5_BREAKING_CHANGES
20
17
  ? exports.MAX_EPHEMERAL_STORAGE_IN_MB
@@ -27,8 +24,4 @@ exports.LOG_GROUP_PREFIX = '/aws/lambda/';
27
24
  exports.LAMBDA_INSIGHTS_PREFIX = '/aws/lambda-insights';
28
25
  const getSitesKey = (siteId) => `sites/${siteId}`;
29
26
  exports.getSitesKey = getSitesKey;
30
- exports.RENDERER_PATH_TOKEN = 'remotion-bucket';
31
- exports.CONCAT_FOLDER_TOKEN = 'remotion-concat';
32
- exports.REMOTION_CONCATED_TOKEN = 'remotion-concated-token';
33
- exports.REMOTION_FILELIST_TOKEN = 'remotion-filelist';
34
27
  exports.LAMBDA_CONCURRENCY_LIMIT_QUOTA = 'L-B99A9384';
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToServeUrlImplementation = void 0;
4
- const docs_url_1 = require("./docs-url");
4
+ const client_1 = require("@remotion/serverless/client");
5
5
  const convertToServeUrlImplementation = ({ urlOrId, region, bucketName, }) => {
6
6
  if (urlOrId.startsWith('src/')) {
7
- throw new Error(`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_1.DOCS_URL}/docs/lambda/setup`);
7
+ throw new Error(`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 ${client_1.DOCS_URL}/docs/lambda/setup`);
8
8
  }
9
9
  if (urlOrId.startsWith('http://') || urlOrId.startsWith('https://')) {
10
10
  return urlOrId;
@@ -1,4 +1,3 @@
1
- import type { AwsRegion } from '../regions';
2
- export declare const getAccountId: (options: {
3
- region: AwsRegion;
4
- }) => Promise<string>;
1
+ import type { GetAccountId } from '@remotion/serverless';
2
+ import type { AwsProvider } from '../functions/aws-implementation';
3
+ export declare const getAccountIdImplementation: GetAccountId<AwsProvider>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAccountId = void 0;
3
+ exports.getAccountIdImplementation = void 0;
4
4
  const client_sts_1 = require("@aws-sdk/client-sts");
5
5
  const aws_clients_1 = require("./aws-clients");
6
6
  const validate_aws_region_1 = require("./validate-aws-region");
7
- const getAccountId = async (options) => {
7
+ const getAccountIdImplementation = async (options) => {
8
8
  (0, validate_aws_region_1.validateAwsRegion)(options.region);
9
9
  const callerIdentity = await (0, aws_clients_1.getStsClient)(options.region).send(new client_sts_1.GetCallerIdentityCommand({}));
10
10
  if (!callerIdentity.Account) {
@@ -12,4 +12,4 @@ const getAccountId = async (options) => {
12
12
  }
13
13
  return callerIdentity.Account;
14
14
  };
15
- exports.getAccountId = getAccountId;
15
+ exports.getAccountIdImplementation = getAccountIdImplementation;
@@ -1,5 +1,7 @@
1
+ import type { GetLoggingUrlForRendererFunction } from '@remotion/serverless';
1
2
  import type { ServerlessRoutines } from '@remotion/serverless/client';
2
- import type { AwsRegion } from '../client';
3
+ import type { AwsProvider } from '../functions/aws-implementation';
4
+ import type { AwsRegion } from '../regions';
3
5
  export declare const getCloudwatchMethodUrl: ({ region, functionName, renderId, rendererFunctionName, method, }: {
4
6
  region: AwsRegion;
5
7
  functionName: string;
@@ -11,13 +13,7 @@ export declare const getLambdaInsightsUrl: ({ region, functionName, }: {
11
13
  region: AwsRegion;
12
14
  functionName: string;
13
15
  }) => string;
14
- export declare const getCloudwatchRendererUrl: ({ region, functionName, renderId, rendererFunctionName, chunk, }: {
15
- region: AwsRegion;
16
- functionName: string;
17
- rendererFunctionName: string | null;
18
- renderId: string;
19
- chunk: null | number;
20
- }) => string;
16
+ export declare const getCloudwatchRendererUrl: GetLoggingUrlForRendererFunction<AwsProvider>;
21
17
  export declare const getS3RenderUrl: ({ renderId, region, bucketName, }: {
22
18
  renderId: string;
23
19
  region: AwsRegion;
@@ -15,7 +15,7 @@ const getLambdaInsightsUrl = ({ region, functionName, }) => {
15
15
  return `https://${region}.console.aws.amazon.com/cloudwatch/home?region=${region}#lambda-insights:functions/${functionName}`;
16
16
  };
17
17
  exports.getLambdaInsightsUrl = getLambdaInsightsUrl;
18
- const getCloudwatchRendererUrl = ({ region, functionName, renderId, rendererFunctionName, chunk, }) => {
18
+ const getCloudwatchRendererUrl = ({ region, functionName, renderId, rendererFunctionName, chunk }) => {
19
19
  const functionNameToUse = rendererFunctionName !== null && rendererFunctionName !== void 0 ? rendererFunctionName : functionName;
20
20
  const query = `"method=renderer,renderId=${renderId}${chunk === null ? '' : `,chunk=${chunk},`}"`;
21
21
  return cloudWatchUrlWithQuery({ region, functionNameToUse, query });
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFunctionVersion = void 0;
4
4
  const client_1 = require("@remotion/serverless/client");
5
- const call_lambda_1 = require("./call-lambda");
6
- const constants_1 = require("./constants");
5
+ const aws_implementation_1 = require("../functions/aws-implementation");
7
6
  const getFunctionVersion = async ({ functionName, region, logLevel, }) => {
8
7
  try {
9
- const result = await (0, call_lambda_1.callLambda)({
8
+ const result = await aws_implementation_1.awsImplementation.callFunctionSync({
10
9
  functionName,
11
10
  payload: {
12
11
  logLevel,
12
+ type: client_1.ServerlessRoutines.info,
13
13
  },
14
14
  region,
15
15
  type: client_1.ServerlessRoutines.info,
@@ -19,7 +19,7 @@ const getFunctionVersion = async ({ functionName, region, logLevel, }) => {
19
19
  }
20
20
  catch (err) {
21
21
  // Prerelease versions had no info command
22
- if (err.message.includes(constants_1.COMMAND_NOT_FOUND)) {
22
+ if (err.message.includes(client_1.COMMAND_NOT_FOUND)) {
23
23
  return 'n/a';
24
24
  }
25
25
  // Bug in certain version of AWS S3 kit
@@ -3,9 +3,8 @@ import type { AwsLayer } from './hosted-layers';
3
3
  declare const runtimePreferenceOptions: readonly ["default", "apple-emojis", "cjk"];
4
4
  export type RuntimePreference = (typeof runtimePreferenceOptions)[number];
5
5
  export declare const validateRuntimePreference: (option: unknown) => void;
6
- export declare const getLayers: ({ option, region, enableV5Runtime, }: {
6
+ export declare const getLayers: ({ option, region, }: {
7
7
  option: RuntimePreference;
8
8
  region: AwsRegion;
9
- enableV5Runtime: boolean;
10
9
  }) => AwsLayer[];
11
10
  export {};
@@ -12,10 +12,8 @@ const validateRuntimePreference = (option) => {
12
12
  }
13
13
  };
14
14
  exports.validateRuntimePreference = validateRuntimePreference;
15
- const getLayers = ({ option, region, enableV5Runtime, }) => {
16
- const layers = enableV5Runtime
17
- ? hosted_layers_1.v5HostedLayers[region]
18
- : hosted_layers_1.hostedLayers[region];
15
+ const getLayers = ({ option, region, }) => {
16
+ const layers = hosted_layers_1.hostedLayers[region];
19
17
  return layers.filter((layer) => {
20
18
  if (layer.layerArn.includes('emoji-apple')) {
21
19
  return option === 'apple-emojis';
@@ -1,9 +1,12 @@
1
1
  import type { _Object } from '@aws-sdk/client-s3';
2
- export declare const getS3DiffOperations: ({ objects, bundle, prefix, onProgress, }: {
2
+ import type { FullClientSpecifics } from '@remotion/serverless';
3
+ import type { AwsProvider } from '../functions/aws-implementation';
4
+ export declare const getS3DiffOperations: ({ objects, bundle, prefix, onProgress, fullClientSpecifics, }: {
3
5
  objects: _Object[];
4
6
  bundle: string;
5
7
  prefix: string;
6
8
  onProgress: (bytes: number) => void;
9
+ fullClientSpecifics: FullClientSpecifics<AwsProvider>;
7
10
  }) => Promise<{
8
11
  toDelete: _Object[];
9
12
  toUpload: string[];
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getS3DiffOperations = void 0;
4
- const read_dir_1 = require("./read-dir");
5
- const getS3DiffOperations = async ({ objects, bundle, prefix, onProgress, }) => {
4
+ const getS3DiffOperations = async ({ objects, bundle, prefix, onProgress, fullClientSpecifics, }) => {
6
5
  var _a, _b, _c;
7
6
  let totalBytes = 0;
8
- const dir = (0, read_dir_1.readDirectory)({
7
+ const dir = fullClientSpecifics.readDirectory({
9
8
  dir: bundle,
10
9
  etags: {},
11
10
  originalDir: bundle,
@@ -7,9 +7,9 @@ const client_lambda_1 = require("@aws-sdk/client-lambda");
7
7
  const client_s3_1 = require("@aws-sdk/client-s3");
8
8
  const client_service_quotas_1 = require("@aws-sdk/client-service-quotas");
9
9
  const client_sts_1 = require("@aws-sdk/client-sts");
10
+ const client_1 = require("@remotion/serverless/client");
10
11
  const no_react_1 = require("remotion/no-react");
11
12
  const check_credentials_1 = require("./check-credentials");
12
- const constants_1 = require("./constants");
13
13
  const get_credentials_1 = require("./get-credentials");
14
14
  const getCredentialsHash = ({ customCredentials, region, service, forcePathStyle, }) => {
15
15
  const hashComponents = {};
@@ -83,7 +83,7 @@ const getServiceClient = ({ region, service, customCredentials, forcePathStyle,
83
83
  const lambdaOptions = service === 'lambda'
84
84
  ? {
85
85
  httpsAgent: {
86
- maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER * 2,
86
+ maxSockets: client_1.MAX_FUNCTIONS_PER_RENDER * 2,
87
87
  },
88
88
  }
89
89
  : undefined;
@@ -8,4 +8,3 @@ export type HostedLayers = {
8
8
  [region in AwsRegion]: AwsLayer[];
9
9
  };
10
10
  export declare const hostedLayers: HostedLayers;
11
- export declare const v5HostedLayers: HostedLayers;