@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,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeLambdaRenderStillPayload = exports.getRenderProgressPayload = exports.makeLambdaRenderMediaPayload = void 0;
4
+ const serverless_client_1 = require("@remotion/serverless-client");
5
+ const aws_provider_1 = require("./aws-provider");
6
+ const serverless_client_2 = require("@remotion/serverless-client");
7
+ const validate_lambda_codec_1 = require("./validate-lambda-codec");
8
+ const validate_serveurl_1 = require("./validate-serveurl");
9
+ const makeLambdaRenderMediaPayload = async ({ rendererFunctionName, frameRange, framesPerLambda, forceBucketName: bucketName, codec, composition, serveUrl, imageFormat, inputProps, region, crf, envVariables, pixelFormat, proResProfile, x264Preset, maxRetries, privacy, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, everyNthFrame, numberOfGifLoops, audioBitrate, concurrencyPerLambda, audioCodec, forceHeight, forceWidth, webhook, videoBitrate, encodingMaxRate, encodingBufferSize, downloadBehavior, muted, overwrite, jpegQuality, offthreadVideoCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, forcePathStyle, metadata, apiKey, }) => {
10
+ const actualCodec = (0, validate_lambda_codec_1.validateLambdaCodec)(codec);
11
+ (0, validate_serveurl_1.validateServeUrl)(serveUrl);
12
+ (0, serverless_client_1.validateFramesPerFunction)({
13
+ framesPerFunction: framesPerLambda !== null && framesPerLambda !== void 0 ? framesPerLambda : null,
14
+ durationInFrames: 1,
15
+ });
16
+ (0, serverless_client_1.validateDownloadBehavior)(downloadBehavior);
17
+ (0, serverless_client_2.validateWebhook)(webhook);
18
+ const stringifiedInputProps = (0, serverless_client_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
19
+ const serialized = await (0, serverless_client_1.compressInputProps)({
20
+ stringifiedInputProps,
21
+ region,
22
+ needsToUpload: (0, serverless_client_1.getNeedsToUpload)({
23
+ type: 'video-or-audio',
24
+ sizes: [
25
+ stringifiedInputProps.length,
26
+ JSON.stringify(envVariables).length,
27
+ ],
28
+ providerSpecifics: aws_provider_1.awsImplementation,
29
+ }),
30
+ userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
31
+ propsType: 'input-props',
32
+ providerSpecifics: aws_provider_1.awsImplementation,
33
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
34
+ skipPutAcl: privacy === 'no-acl',
35
+ });
36
+ return {
37
+ rendererFunctionName,
38
+ framesPerLambda,
39
+ composition,
40
+ serveUrl,
41
+ inputProps: serialized,
42
+ codec: actualCodec,
43
+ imageFormat,
44
+ crf: crf !== null && crf !== void 0 ? crf : null,
45
+ envVariables,
46
+ pixelFormat: pixelFormat !== null && pixelFormat !== void 0 ? pixelFormat : null,
47
+ proResProfile: proResProfile !== null && proResProfile !== void 0 ? proResProfile : null,
48
+ x264Preset,
49
+ jpegQuality,
50
+ maxRetries,
51
+ privacy,
52
+ logLevel,
53
+ frameRange,
54
+ outName,
55
+ timeoutInMilliseconds,
56
+ chromiumOptions,
57
+ scale,
58
+ everyNthFrame,
59
+ numberOfGifLoops,
60
+ concurrencyPerLambda,
61
+ downloadBehavior,
62
+ muted,
63
+ version: serverless_client_1.VERSION,
64
+ overwrite: overwrite !== null && overwrite !== void 0 ? overwrite : serverless_client_1.ENABLE_V5_BREAKING_CHANGES,
65
+ audioBitrate: audioBitrate !== null && audioBitrate !== void 0 ? audioBitrate : null,
66
+ videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
67
+ encodingBufferSize: encodingBufferSize !== null && encodingBufferSize !== void 0 ? encodingBufferSize : null,
68
+ encodingMaxRate: encodingMaxRate !== null && encodingMaxRate !== void 0 ? encodingMaxRate : null,
69
+ webhook: webhook !== null && webhook !== void 0 ? webhook : null,
70
+ forceHeight: forceHeight !== null && forceHeight !== void 0 ? forceHeight : null,
71
+ forceWidth: forceWidth !== null && forceWidth !== void 0 ? forceWidth : null,
72
+ bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
73
+ audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
74
+ type: serverless_client_1.ServerlessRoutines.start,
75
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
76
+ deleteAfter: deleteAfter !== null && deleteAfter !== void 0 ? deleteAfter : null,
77
+ colorSpace: colorSpace !== null && colorSpace !== void 0 ? colorSpace : null,
78
+ preferLossless: preferLossless !== null && preferLossless !== void 0 ? preferLossless : false,
79
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
80
+ metadata: metadata !== null && metadata !== void 0 ? metadata : null,
81
+ apiKey: apiKey !== null && apiKey !== void 0 ? apiKey : null,
82
+ };
83
+ };
84
+ exports.makeLambdaRenderMediaPayload = makeLambdaRenderMediaPayload;
85
+ const getRenderProgressPayload = ({ bucketName, renderId, s3OutputProvider, logLevel, forcePathStyle, }) => {
86
+ return {
87
+ type: serverless_client_1.ServerlessRoutines.status,
88
+ bucketName,
89
+ renderId,
90
+ version: serverless_client_1.VERSION,
91
+ s3OutputProvider: s3OutputProvider !== null && s3OutputProvider !== void 0 ? s3OutputProvider : null,
92
+ logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
93
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
94
+ };
95
+ };
96
+ exports.getRenderProgressPayload = getRenderProgressPayload;
97
+ const makeLambdaRenderStillPayload = async ({ serveUrl, inputProps, imageFormat, envVariables, quality, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, forcePathStyle, apiKey, }) => {
98
+ if (quality) {
99
+ throw new Error('The `quality` option is deprecated. Use `jpegQuality` instead.');
100
+ }
101
+ const stringifiedInputProps = (0, serverless_client_1.serializeOrThrow)(inputProps, 'input-props');
102
+ const serializedInputProps = await (0, serverless_client_1.compressInputProps)({
103
+ stringifiedInputProps,
104
+ region,
105
+ needsToUpload: (0, serverless_client_1.getNeedsToUpload)({
106
+ type: 'still',
107
+ sizes: [
108
+ stringifiedInputProps.length,
109
+ JSON.stringify(envVariables).length,
110
+ ],
111
+ providerSpecifics: aws_provider_1.awsImplementation,
112
+ }),
113
+ userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
114
+ propsType: 'input-props',
115
+ providerSpecifics: aws_provider_1.awsImplementation,
116
+ forcePathStyle,
117
+ skipPutAcl: privacy === 'no-acl',
118
+ });
119
+ return {
120
+ composition,
121
+ serveUrl,
122
+ inputProps: serializedInputProps,
123
+ imageFormat,
124
+ envVariables,
125
+ jpegQuality,
126
+ maxRetries,
127
+ frame,
128
+ privacy,
129
+ attempt: 1,
130
+ logLevel,
131
+ outName,
132
+ timeoutInMilliseconds,
133
+ chromiumOptions,
134
+ scale,
135
+ downloadBehavior,
136
+ version: serverless_client_1.VERSION,
137
+ forceHeight,
138
+ forceWidth,
139
+ bucketName: forceBucketName,
140
+ offthreadVideoCacheSizeInBytes,
141
+ deleteAfter,
142
+ type: serverless_client_1.ServerlessRoutines.still,
143
+ streamed: true,
144
+ forcePathStyle,
145
+ apiKey: apiKey !== null && apiKey !== void 0 ? apiKey : null,
146
+ };
147
+ };
148
+ exports.makeLambdaRenderStillPayload = makeLambdaRenderStillPayload;
@@ -0,0 +1,6 @@
1
+ import type { AwsRegion } from './regions';
2
+ export declare const makeS3ServeUrl: ({ bucketName, subFolder, region, }: {
3
+ bucketName: string;
4
+ subFolder: string;
5
+ region: AwsRegion;
6
+ }) => string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeS3ServeUrl = void 0;
4
+ const makeS3ServeUrl = ({ bucketName, subFolder, region, }) => {
5
+ return `https://${bucketName}.s3.${region}.amazonaws.com/${subFolder}/index.html`;
6
+ };
7
+ exports.makeS3ServeUrl = makeS3ServeUrl;
@@ -0,0 +1 @@
1
+ export declare const pLimit: (concurrency: number) => <Arguments extends unknown[], ReturnType>(fn: (..._arguments: Arguments) => PromiseLike<ReturnType> | ReturnType, ...args: Arguments) => Promise<ReturnType>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pLimit = void 0;
4
+ const pLimit = (concurrency) => {
5
+ const queue = [];
6
+ let activeCount = 0;
7
+ const next = () => {
8
+ var _a;
9
+ activeCount--;
10
+ if (queue.length > 0) {
11
+ (_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
12
+ }
13
+ };
14
+ const run = async (fn, resolve, ...args) => {
15
+ activeCount++;
16
+ // eslint-disable-next-line require-await
17
+ const result = (async () => fn(...args))();
18
+ resolve(result);
19
+ try {
20
+ await result;
21
+ }
22
+ catch (_a) { }
23
+ next();
24
+ };
25
+ const enqueue = (fn, resolve, ...args) => {
26
+ queue.push(() => run(fn, resolve, ...args));
27
+ (async () => {
28
+ var _a;
29
+ // This function needs to wait until the next microtask before comparing
30
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
31
+ // when the run function is dequeued and called. The comparison in the if-statement
32
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
33
+ await Promise.resolve();
34
+ if (activeCount < concurrency && queue.length > 0) {
35
+ (_a = queue.shift()) === null || _a === void 0 ? void 0 : _a();
36
+ }
37
+ })();
38
+ };
39
+ const generator = (fn, ...args) => new Promise((resolve) => {
40
+ enqueue(fn, resolve, ...args);
41
+ });
42
+ Object.defineProperties(generator, {
43
+ activeCount: {
44
+ get: () => activeCount,
45
+ },
46
+ pendingCount: {
47
+ get: () => queue.length,
48
+ },
49
+ clearQueue: {
50
+ value: () => {
51
+ queue.length = 0;
52
+ },
53
+ },
54
+ });
55
+ return generator;
56
+ };
57
+ exports.pLimit = pLimit;
@@ -0,0 +1,5 @@
1
+ import type { Response } from 'express';
2
+ import type { NextApiRequest, NextApiResponse } from 'next';
3
+ import type { NextWebhookArgs } from './app-router-webhook';
4
+ export declare const addHeaders: (res: NextApiResponse | Response, headers: Record<string, string>) => void;
5
+ export declare const pagesRouterWebhook: (options: NextWebhookArgs) => (req: NextApiRequest, res: NextApiResponse) => void;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pagesRouterWebhook = exports.addHeaders = void 0;
4
+ const validate_webhook_signature_1 = require("./validate-webhook-signature");
5
+ const addHeaders = (res, headers) => {
6
+ Object.entries(headers).forEach(([key, value]) => {
7
+ res.setHeader(key, value);
8
+ });
9
+ };
10
+ exports.addHeaders = addHeaders;
11
+ const pagesRouterWebhook = (options) => {
12
+ const { testing, extraHeaders, secret, onSuccess, onTimeout, onError } = options;
13
+ return function (req, res) {
14
+ (0, exports.addHeaders)(res, extraHeaders || {});
15
+ if (testing) {
16
+ const testingheaders = {
17
+ 'Access-Control-Allow-Origin': 'https://www.remotion.dev',
18
+ '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',
19
+ 'Access-Control-Allow-Methods': 'OPTIONS,POST',
20
+ };
21
+ (0, exports.addHeaders)(res, testingheaders);
22
+ }
23
+ if (req.method === 'OPTIONS') {
24
+ res.status(200).end();
25
+ return;
26
+ }
27
+ (0, validate_webhook_signature_1.validateWebhookSignature)({
28
+ secret,
29
+ body: req.body,
30
+ signatureHeader: req.headers['x-remotion-signature'],
31
+ });
32
+ // If code reaches this path, the webhook is authentic.
33
+ const payload = req.body;
34
+ if (payload.type === 'success' && onSuccess) {
35
+ onSuccess(payload);
36
+ }
37
+ else if (payload.type === 'timeout' && onTimeout) {
38
+ onTimeout(payload);
39
+ }
40
+ else if (payload.type === 'error' && onError) {
41
+ onError(payload);
42
+ }
43
+ res.status(200).json({
44
+ success: true,
45
+ });
46
+ };
47
+ };
48
+ exports.pagesRouterWebhook = pagesRouterWebhook;
@@ -0,0 +1,8 @@
1
+ type ReturnType = {
2
+ version: string;
3
+ memorySizeInMb: number;
4
+ diskSizeInMb: number;
5
+ timeoutInSeconds: number;
6
+ };
7
+ export declare const parseFunctionName: (functionName: string) => ReturnType | null;
8
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFunctionName = void 0;
4
+ const constants_1 = require("./constants");
5
+ const parseFunctionName = (functionName) => {
6
+ const match = functionName.match(new RegExp(constants_1.RENDER_FN_PREFIX + '(.*)-mem(\\d+)mb-disk(\\d+)mb-(\\d+)sec$'));
7
+ if (!match) {
8
+ return null;
9
+ }
10
+ return {
11
+ version: match[1],
12
+ memorySizeInMb: parseInt(match[2], 10),
13
+ diskSizeInMb: parseInt(match[3], 10),
14
+ timeoutInSeconds: parseInt(match[4], 10),
15
+ };
16
+ };
17
+ exports.parseFunctionName = parseFunctionName;
@@ -0,0 +1,14 @@
1
+ import type { AwsRegion } from './regions';
2
+ type MandatoryParameters = {
3
+ region: AwsRegion;
4
+ bucketName: string;
5
+ objectKey: string;
6
+ expiresInSeconds: number;
7
+ };
8
+ type OptionalParameters<CheckIfObjectExists extends boolean> = {
9
+ checkIfObjectExists: CheckIfObjectExists;
10
+ forcePathStyle: boolean;
11
+ };
12
+ export type PresignUrlInput<CheckIfObjectExists extends boolean = boolean> = MandatoryParameters & Partial<OptionalParameters<CheckIfObjectExists>>;
13
+ export declare const presignUrl: <CheckIfObjectExists extends boolean = false>({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, }: PresignUrlInput<CheckIfObjectExists>) => Promise<CheckIfObjectExists extends true ? string | null : string>;
14
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.presignUrl = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
6
+ const serverless_client_1 = require("@remotion/serverless-client");
7
+ const constants_1 = require("./constants");
8
+ const get_s3_client_1 = require("./get-s3-client");
9
+ const validate_presign_expiration_1 = require("./validate-presign-expiration");
10
+ const internalPresignUrl = async ({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, }) => {
11
+ (0, serverless_client_1.validateBucketName)({
12
+ bucketName,
13
+ bucketNamePrefix: constants_1.REMOTION_BUCKET_PREFIX,
14
+ options: { mustStartWithRemotion: false },
15
+ });
16
+ (0, validate_presign_expiration_1.validatePresignExpiration)(expiresInSeconds);
17
+ const s3Client = (0, get_s3_client_1.getS3Client)({
18
+ region,
19
+ customCredentials: null,
20
+ forcePathStyle,
21
+ });
22
+ if (checkIfObjectExists === true) {
23
+ try {
24
+ await s3Client.send(new client_s3_1.HeadObjectCommand({
25
+ Bucket: bucketName,
26
+ Key: objectKey,
27
+ }));
28
+ }
29
+ catch (err) {
30
+ if (err.name === 'NotFound') {
31
+ return null;
32
+ }
33
+ if (err.message === 'UnknownError' ||
34
+ err.$metadata
35
+ .httpStatusCode === 403) {
36
+ throw new Error(`Unable to access item "${objectKey}" from bucket "${bucketName}". You must have permission for both "s3:GetObject" and "s3:ListBucket" actions.`);
37
+ }
38
+ throw err;
39
+ }
40
+ }
41
+ const objCommand = new client_s3_1.GetObjectCommand({
42
+ Bucket: bucketName,
43
+ Key: objectKey,
44
+ });
45
+ const publicUrl = await (0, s3_request_presigner_1.getSignedUrl)(s3Client, objCommand, {
46
+ expiresIn: expiresInSeconds,
47
+ });
48
+ return publicUrl;
49
+ };
50
+ /*
51
+ * @description Takes a private S3 object and turns it into a public URL by signing it with your AWS credentials.
52
+ * @see [Documentation](https://remotion.dev/docs/lambda/presignurl)
53
+ */
54
+ const presignUrl = ({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, }) => {
55
+ return internalPresignUrl({
56
+ region,
57
+ bucketName,
58
+ objectKey,
59
+ checkIfObjectExists: checkIfObjectExists !== null && checkIfObjectExists !== void 0 ? checkIfObjectExists : false,
60
+ expiresInSeconds,
61
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
62
+ });
63
+ };
64
+ exports.presignUrl = presignUrl;
@@ -0,0 +1,37 @@
1
+ import type { AwsRegion } from './regions';
2
+ export declare const pricing: {
3
+ [key in AwsRegion]: {
4
+ 'Lambda Duration': {
5
+ rateCode: string;
6
+ price: string;
7
+ };
8
+ 'Lambda Duration-Provisioned': {
9
+ rateCode: string;
10
+ price: string;
11
+ };
12
+ 'Lambda Provisioned-Concurrency': {
13
+ rateCode: string;
14
+ price: string;
15
+ };
16
+ 'Lambda Requests': {
17
+ rateCode: string;
18
+ price: string;
19
+ };
20
+ 'Lambda Duration-ARM': {
21
+ rateCode: string;
22
+ price: string;
23
+ };
24
+ 'Lambda Requests-ARM': {
25
+ rateCode: string;
26
+ price: string;
27
+ };
28
+ 'Lambda Storage-Duration': {
29
+ rateCode: string;
30
+ price: string;
31
+ };
32
+ 'Lambda Storage-Duration-ARM': {
33
+ rateCode: string;
34
+ price: string;
35
+ };
36
+ };
37
+ };