@remotion/lambda-client 4.0.394 → 4.0.396

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 (141) hide show
  1. package/dist/app-router-webhook.d.ts +10 -0
  2. package/dist/app-router-webhook.js +43 -0
  3. package/dist/apply-lifecycle.d.ts +8 -0
  4. package/dist/apply-lifecycle.js +18 -0
  5. package/dist/aws-clients.d.ts +12 -0
  6. package/dist/aws-clients.js +56 -0
  7. package/dist/aws-provider.d.ts +27 -0
  8. package/dist/aws-provider.js +94 -0
  9. package/dist/bucket-exists.d.ts +3 -0
  10. package/dist/bucket-exists.js +27 -0
  11. package/dist/call-lambda-async.d.ts +2 -0
  12. package/dist/call-lambda-async.js +20 -0
  13. package/dist/call-lambda-streaming.d.ts +6 -0
  14. package/dist/call-lambda-streaming.js +126 -0
  15. package/dist/call-lambda-sync.d.ts +2 -0
  16. package/dist/call-lambda-sync.js +30 -0
  17. package/dist/check-credentials.d.ts +1 -0
  18. package/dist/check-credentials.js +39 -0
  19. package/dist/cjs/index.js +33 -33
  20. package/dist/clean-items.d.ts +17 -0
  21. package/dist/clean-items.js +26 -0
  22. package/dist/constants.d.ts +25 -0
  23. package/dist/constants.js +26 -0
  24. package/dist/content-disposition-header.d.ts +2 -0
  25. package/dist/content-disposition-header.js +50 -0
  26. package/dist/convert-to-serve-url.d.ts +6 -0
  27. package/dist/convert-to-serve-url.js +14 -0
  28. package/dist/create-bucket.d.ts +3 -0
  29. package/dist/create-bucket.js +65 -0
  30. package/dist/delete-file.d.ts +3 -0
  31. package/dist/delete-file.js +17 -0
  32. package/dist/delete-function.d.ts +7 -0
  33. package/dist/delete-function.js +15 -0
  34. package/dist/delete-render.d.ts +22 -0
  35. package/dist/delete-render.js +90 -0
  36. package/dist/encode-aws-url-params.d.ts +1 -0
  37. package/dist/encode-aws-url-params.js +7 -0
  38. package/dist/esm/index.mjs +20 -20
  39. package/dist/estimate-price.d.ts +17 -0
  40. package/dist/estimate-price.js +45 -0
  41. package/dist/express-webhook.d.ts +3 -0
  42. package/dist/express-webhook.js +46 -0
  43. package/dist/get-account-id.d.ts +3 -0
  44. package/dist/get-account-id.js +15 -0
  45. package/dist/get-aws-client.d.ts +32 -0
  46. package/dist/get-aws-client.js +67 -0
  47. package/dist/get-aws-urls.d.ts +25 -0
  48. package/dist/get-aws-urls.js +31 -0
  49. package/dist/get-buckets.d.ts +9 -0
  50. package/dist/get-buckets.js +64 -0
  51. package/dist/get-compositions-on-lambda.d.ts +20 -0
  52. package/dist/get-compositions-on-lambda.js +62 -0
  53. package/dist/get-credentials.d.ts +9 -0
  54. package/dist/get-credentials.js +55 -0
  55. package/dist/get-env-variable.d.ts +1 -0
  56. package/dist/get-env-variable.js +15 -0
  57. package/dist/get-function-name.d.ts +8 -0
  58. package/dist/get-function-name.js +17 -0
  59. package/dist/get-function-version.d.ts +9 -0
  60. package/dist/get-function-version.js +35 -0
  61. package/dist/get-functions.d.ts +10 -0
  62. package/dist/get-functions.js +80 -0
  63. package/dist/get-output-url-from-metadata.d.ts +3 -0
  64. package/dist/get-output-url-from-metadata.js +18 -0
  65. package/dist/get-render-progress.d.ts +17 -0
  66. package/dist/get-render-progress.js +47 -0
  67. package/dist/get-s3-client.d.ts +11 -0
  68. package/dist/get-s3-client.js +15 -0
  69. package/dist/get-service-client.d.ts +25 -0
  70. package/dist/get-service-client.js +131 -0
  71. package/dist/get-sites.d.ts +31 -0
  72. package/dist/get-sites.js +83 -0
  73. package/dist/head-file.d.ts +3 -0
  74. package/dist/head-file.js +18 -0
  75. package/dist/index.d.ts +129 -0
  76. package/dist/index.js +108 -0
  77. package/dist/is-cli.d.ts +2 -0
  78. package/dist/is-cli.js +10 -0
  79. package/dist/is-flaky-error.d.ts +1 -0
  80. package/dist/is-flaky-error.js +78 -0
  81. package/dist/is-in-lambda.d.ts +1 -0
  82. package/dist/is-in-lambda.js +9 -0
  83. package/dist/is-likely-to-have-aws-profile.d.ts +1 -0
  84. package/dist/is-likely-to-have-aws-profile.js +50 -0
  85. package/dist/lambda-version-string.d.ts +1 -0
  86. package/dist/lambda-version-string.js +7 -0
  87. package/dist/lifecycle-rules.d.ts +12 -0
  88. package/dist/lifecycle-rules.js +73 -0
  89. package/dist/lifecycle.d.ts +7 -0
  90. package/dist/lifecycle.js +24 -0
  91. package/dist/list-objects.d.ts +3 -0
  92. package/dist/list-objects.js +70 -0
  93. package/dist/make-lambda-payload.d.ts +59 -0
  94. package/dist/make-lambda-payload.js +150 -0
  95. package/dist/make-s3-url.d.ts +6 -0
  96. package/dist/make-s3-url.js +7 -0
  97. package/dist/p-limit.d.ts +1 -0
  98. package/dist/p-limit.js +57 -0
  99. package/dist/pages-router-webhook.d.ts +5 -0
  100. package/dist/pages-router-webhook.js +48 -0
  101. package/dist/parse-function-name.d.ts +8 -0
  102. package/dist/parse-function-name.js +17 -0
  103. package/dist/presign-url.d.ts +17 -0
  104. package/dist/presign-url.js +66 -0
  105. package/dist/price-per-1s.d.ts +37 -0
  106. package/dist/price-per-1s.js +822 -0
  107. package/dist/random-hash.d.ts +1 -0
  108. package/dist/random-hash.js +13 -0
  109. package/dist/read-file.d.ts +11 -0
  110. package/dist/read-file.js +19 -0
  111. package/dist/regions.d.ts +3 -0
  112. package/dist/regions.js +48 -0
  113. package/dist/render-media-on-lambda.d.ts +66 -0
  114. package/dist/render-media-on-lambda.js +133 -0
  115. package/dist/render-still-on-lambda.d.ts +61 -0
  116. package/dist/render-still-on-lambda.js +121 -0
  117. package/dist/runtime-preference.d.ts +2 -0
  118. package/dist/runtime-preference.js +8 -0
  119. package/dist/speculate-function-name.d.ts +7 -0
  120. package/dist/speculate-function-name.js +39 -0
  121. package/dist/types.d.ts +4 -0
  122. package/dist/types.js +2 -0
  123. package/dist/validate-aws-region.d.ts +2 -0
  124. package/dist/validate-aws-region.js +9 -0
  125. package/dist/validate-bucketname.d.ts +4 -0
  126. package/dist/validate-bucketname.js +15 -0
  127. package/dist/validate-disk-size-in-mb.d.ts +1 -0
  128. package/dist/validate-disk-size-in-mb.js +23 -0
  129. package/dist/validate-lambda-codec.d.ts +2 -0
  130. package/dist/validate-lambda-codec.js +21 -0
  131. package/dist/validate-memory-size.d.ts +1 -0
  132. package/dist/validate-memory-size.js +22 -0
  133. package/dist/validate-presign-expiration.d.ts +1 -0
  134. package/dist/validate-presign-expiration.js +29 -0
  135. package/dist/validate-serveurl.d.ts +1 -0
  136. package/dist/validate-serveurl.js +9 -0
  137. package/dist/validate-webhook-signature.d.ts +5 -0
  138. package/dist/validate-webhook-signature.js +28 -0
  139. package/dist/write-file.d.ts +5 -0
  140. package/dist/write-file.js +83 -0
  141. package/package.json +3 -3
@@ -0,0 +1,59 @@
1
+ import type { AudioCodec, BrowserSafeApis, ChromiumOptions, ColorSpace, DeleteAfter, DownloadBehavior, FrameRange, LogLevel, OutNameInput, PixelFormat, Privacy, ProResProfile, ServerlessCodec, ServerlessPayloads, ServerlessStartPayload, ServerlessStatusPayload, ToOptions, VideoImageFormat, WebhookOption, X264Preset } from '@remotion/serverless-client';
2
+ import { ServerlessRoutines } from '@remotion/serverless-client';
3
+ import type { AwsProvider } from './aws-provider';
4
+ import type { StorageClass } from '@aws-sdk/client-s3';
5
+ import type { GetRenderProgressInput } from './get-render-progress';
6
+ import type { AwsRegion } from './regions';
7
+ import type { RenderStillOnLambdaNonNullInput } from './render-still-on-lambda';
8
+ import type { RequestHandler } from './types';
9
+ export type InnerRenderMediaOnLambdaInput = {
10
+ region: AwsRegion;
11
+ functionName: string;
12
+ serveUrl: string;
13
+ composition: string;
14
+ inputProps: Record<string, unknown>;
15
+ codec: ServerlessCodec;
16
+ imageFormat: VideoImageFormat;
17
+ crf: number | undefined;
18
+ envVariables: Record<string, string>;
19
+ pixelFormat: PixelFormat | undefined;
20
+ proResProfile: ProResProfile | undefined;
21
+ x264Preset: X264Preset | null;
22
+ privacy: Privacy;
23
+ jpegQuality: number;
24
+ maxRetries: number;
25
+ framesPerLambda: number | null;
26
+ concurrency: number | null;
27
+ logLevel: LogLevel;
28
+ frameRange: FrameRange | null;
29
+ outName: OutNameInput<AwsProvider> | null;
30
+ timeoutInMilliseconds: number;
31
+ chromiumOptions: ChromiumOptions;
32
+ scale: number;
33
+ everyNthFrame: number;
34
+ numberOfGifLoops: number | null;
35
+ concurrencyPerLambda: number;
36
+ downloadBehavior: DownloadBehavior;
37
+ muted: boolean;
38
+ overwrite: boolean;
39
+ audioBitrate: string | null;
40
+ videoBitrate: string | null;
41
+ encodingMaxRate: string | null;
42
+ encodingBufferSize: string | null;
43
+ webhook: WebhookOption | null;
44
+ forceWidth: number | null;
45
+ forceHeight: number | null;
46
+ rendererFunctionName: string | null;
47
+ forceBucketName: string | null;
48
+ audioCodec: AudioCodec | null;
49
+ colorSpace: ColorSpace | null;
50
+ deleteAfter: DeleteAfter | null;
51
+ indent: boolean;
52
+ forcePathStyle: boolean;
53
+ metadata: Record<string, string> | null;
54
+ storageClass: StorageClass | null;
55
+ requestHandler: RequestHandler | null;
56
+ } & ToOptions<typeof BrowserSafeApis.optionsMap.renderMediaOnLambda>;
57
+ export declare const makeLambdaRenderMediaPayload: ({ rendererFunctionName, frameRange, framesPerLambda, concurrency, 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, mediaCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, forcePathStyle, metadata, apiKey, offthreadVideoThreads, storageClass, requestHandler, }: InnerRenderMediaOnLambdaInput) => Promise<ServerlessStartPayload<AwsProvider>>;
58
+ export declare const getRenderProgressPayload: ({ bucketName, renderId, s3OutputProvider, logLevel, forcePathStyle, }: GetRenderProgressInput) => ServerlessStatusPayload<AwsProvider>;
59
+ export declare const makeLambdaRenderStillPayload: ({ serveUrl, inputProps, imageFormat, envVariables, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, forcePathStyle, apiKey, storageClass, requestHandler, offthreadVideoThreads, mediaCacheSizeInBytes, }: RenderStillOnLambdaNonNullInput) => Promise<ServerlessPayloads<AwsProvider>[ServerlessRoutines.still]>;
@@ -0,0 +1,150 @@
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, concurrency, 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, mediaCacheSizeInBytes, deleteAfter, colorSpace, preferLossless, forcePathStyle, metadata, apiKey, offthreadVideoThreads, storageClass, requestHandler, }) => {
10
+ const actualCodec = (0, validate_lambda_codec_1.validateLambdaCodec)(codec);
11
+ (0, validate_serveurl_1.validateServeUrl)(serveUrl);
12
+ (0, serverless_client_1.validateDownloadBehavior)(downloadBehavior);
13
+ (0, serverless_client_2.validateWebhook)(webhook);
14
+ const stringifiedInputProps = (0, serverless_client_1.serializeOrThrow)(inputProps !== null && inputProps !== void 0 ? inputProps : {}, 'input-props');
15
+ const serialized = await (0, serverless_client_1.compressInputProps)({
16
+ stringifiedInputProps,
17
+ region,
18
+ needsToUpload: (0, serverless_client_1.getNeedsToUpload)({
19
+ type: 'video-or-audio',
20
+ sizes: [
21
+ stringifiedInputProps.length,
22
+ JSON.stringify(envVariables).length,
23
+ ],
24
+ providerSpecifics: aws_provider_1.awsImplementation,
25
+ }),
26
+ userSpecifiedBucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
27
+ propsType: 'input-props',
28
+ providerSpecifics: aws_provider_1.awsImplementation,
29
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
30
+ skipPutAcl: privacy === 'no-acl',
31
+ requestHandler: requestHandler !== null && requestHandler !== void 0 ? requestHandler : null,
32
+ });
33
+ return {
34
+ rendererFunctionName,
35
+ framesPerLambda,
36
+ concurrency,
37
+ composition,
38
+ serveUrl,
39
+ inputProps: serialized,
40
+ codec: actualCodec,
41
+ imageFormat,
42
+ crf: crf !== null && crf !== void 0 ? crf : null,
43
+ envVariables,
44
+ pixelFormat: pixelFormat !== null && pixelFormat !== void 0 ? pixelFormat : null,
45
+ proResProfile: proResProfile !== null && proResProfile !== void 0 ? proResProfile : null,
46
+ x264Preset,
47
+ jpegQuality,
48
+ maxRetries,
49
+ privacy,
50
+ logLevel,
51
+ frameRange,
52
+ outName,
53
+ timeoutInMilliseconds,
54
+ chromiumOptions,
55
+ scale,
56
+ everyNthFrame,
57
+ numberOfGifLoops,
58
+ concurrencyPerLambda,
59
+ downloadBehavior,
60
+ muted,
61
+ version: serverless_client_1.VERSION,
62
+ overwrite: overwrite !== null && overwrite !== void 0 ? overwrite : serverless_client_1.ENABLE_V5_BREAKING_CHANGES,
63
+ audioBitrate: audioBitrate !== null && audioBitrate !== void 0 ? audioBitrate : null,
64
+ videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
65
+ encodingBufferSize: encodingBufferSize !== null && encodingBufferSize !== void 0 ? encodingBufferSize : null,
66
+ encodingMaxRate: encodingMaxRate !== null && encodingMaxRate !== void 0 ? encodingMaxRate : null,
67
+ webhook: webhook !== null && webhook !== void 0 ? webhook : null,
68
+ forceHeight: forceHeight !== null && forceHeight !== void 0 ? forceHeight : null,
69
+ forceWidth: forceWidth !== null && forceWidth !== void 0 ? forceWidth : null,
70
+ bucketName: bucketName !== null && bucketName !== void 0 ? bucketName : null,
71
+ audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
72
+ type: serverless_client_1.ServerlessRoutines.start,
73
+ offthreadVideoCacheSizeInBytes: offthreadVideoCacheSizeInBytes !== null && offthreadVideoCacheSizeInBytes !== void 0 ? offthreadVideoCacheSizeInBytes : null,
74
+ deleteAfter: deleteAfter !== null && deleteAfter !== void 0 ? deleteAfter : null,
75
+ colorSpace: colorSpace !== null && colorSpace !== void 0 ? colorSpace : null,
76
+ preferLossless: preferLossless !== null && preferLossless !== void 0 ? preferLossless : false,
77
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
78
+ metadata: metadata !== null && metadata !== void 0 ? metadata : null,
79
+ apiKey: apiKey !== null && apiKey !== void 0 ? apiKey : null,
80
+ offthreadVideoThreads: offthreadVideoThreads !== null && offthreadVideoThreads !== void 0 ? offthreadVideoThreads : null,
81
+ mediaCacheSizeInBytes: mediaCacheSizeInBytes !== null && mediaCacheSizeInBytes !== void 0 ? mediaCacheSizeInBytes : null,
82
+ storageClass: storageClass !== null && storageClass !== void 0 ? storageClass : null,
83
+ };
84
+ };
85
+ exports.makeLambdaRenderMediaPayload = makeLambdaRenderMediaPayload;
86
+ const getRenderProgressPayload = ({ bucketName, renderId, s3OutputProvider, logLevel, forcePathStyle, }) => {
87
+ return {
88
+ type: serverless_client_1.ServerlessRoutines.status,
89
+ bucketName,
90
+ renderId,
91
+ version: serverless_client_1.VERSION,
92
+ s3OutputProvider: s3OutputProvider !== null && s3OutputProvider !== void 0 ? s3OutputProvider : null,
93
+ logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
94
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
95
+ };
96
+ };
97
+ exports.getRenderProgressPayload = getRenderProgressPayload;
98
+ const makeLambdaRenderStillPayload = async ({ serveUrl, inputProps, imageFormat, envVariables, jpegQuality, region, maxRetries, composition, privacy, frame, logLevel, outName, timeoutInMilliseconds, chromiumOptions, scale, downloadBehavior, forceHeight, forceWidth, forceBucketName, offthreadVideoCacheSizeInBytes, deleteAfter, forcePathStyle, apiKey, storageClass, requestHandler, offthreadVideoThreads, mediaCacheSizeInBytes, }) => {
99
+ const stringifiedInputProps = (0, serverless_client_1.serializeOrThrow)(inputProps, 'input-props');
100
+ const serializedInputProps = await (0, serverless_client_1.compressInputProps)({
101
+ stringifiedInputProps,
102
+ region,
103
+ needsToUpload: (0, serverless_client_1.getNeedsToUpload)({
104
+ type: 'still',
105
+ sizes: [
106
+ stringifiedInputProps.length,
107
+ JSON.stringify(envVariables).length,
108
+ ],
109
+ providerSpecifics: aws_provider_1.awsImplementation,
110
+ }),
111
+ userSpecifiedBucketName: forceBucketName !== null && forceBucketName !== void 0 ? forceBucketName : null,
112
+ propsType: 'input-props',
113
+ providerSpecifics: aws_provider_1.awsImplementation,
114
+ forcePathStyle,
115
+ skipPutAcl: privacy === 'no-acl',
116
+ requestHandler,
117
+ });
118
+ return {
119
+ composition,
120
+ serveUrl,
121
+ inputProps: serializedInputProps,
122
+ imageFormat,
123
+ envVariables,
124
+ jpegQuality,
125
+ maxRetries,
126
+ frame,
127
+ privacy,
128
+ attempt: 1,
129
+ logLevel,
130
+ outName,
131
+ timeoutInMilliseconds,
132
+ chromiumOptions,
133
+ scale,
134
+ downloadBehavior,
135
+ version: serverless_client_1.VERSION,
136
+ forceHeight,
137
+ forceWidth,
138
+ bucketName: forceBucketName,
139
+ offthreadVideoCacheSizeInBytes,
140
+ deleteAfter,
141
+ type: serverless_client_1.ServerlessRoutines.still,
142
+ streamed: true,
143
+ forcePathStyle,
144
+ apiKey: apiKey !== null && apiKey !== void 0 ? apiKey : null,
145
+ offthreadVideoThreads: offthreadVideoThreads !== null && offthreadVideoThreads !== void 0 ? offthreadVideoThreads : null,
146
+ mediaCacheSizeInBytes: mediaCacheSizeInBytes !== null && mediaCacheSizeInBytes !== void 0 ? mediaCacheSizeInBytes : null,
147
+ storageClass: storageClass !== null && storageClass !== void 0 ? storageClass : null,
148
+ };
149
+ };
150
+ 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,17 @@
1
+ import type { AwsRegion } from './regions';
2
+ import type { RequestHandler } from './types';
3
+ type MandatoryParameters = {
4
+ region: AwsRegion;
5
+ bucketName: string;
6
+ objectKey: string;
7
+ expiresInSeconds: number;
8
+ };
9
+ type OptionalParameters<CheckIfObjectExists extends boolean> = {
10
+ checkIfObjectExists: CheckIfObjectExists;
11
+ forcePathStyle: boolean;
12
+ };
13
+ export type PresignUrlInput<CheckIfObjectExists extends boolean = boolean> = MandatoryParameters & Partial<OptionalParameters<CheckIfObjectExists>> & {
14
+ requestHandler?: RequestHandler;
15
+ };
16
+ export declare const presignUrl: <CheckIfObjectExists extends boolean = false>({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, requestHandler, }: PresignUrlInput<CheckIfObjectExists>) => Promise<CheckIfObjectExists extends true ? string | null : string>;
17
+ export {};
@@ -0,0 +1,66 @@
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, requestHandler, }) => {
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
+ requestHandler: requestHandler !== null && requestHandler !== void 0 ? requestHandler : null,
22
+ });
23
+ if (checkIfObjectExists === true) {
24
+ try {
25
+ await s3Client.send(new client_s3_1.HeadObjectCommand({
26
+ Bucket: bucketName,
27
+ Key: objectKey,
28
+ }));
29
+ }
30
+ catch (err) {
31
+ if (err.name === 'NotFound') {
32
+ return null;
33
+ }
34
+ if (err.message === 'UnknownError' ||
35
+ err.$metadata
36
+ .httpStatusCode === 403) {
37
+ throw new Error(`Unable to access item "${objectKey}" from bucket "${bucketName}". You must have permission for both "s3:GetObject" and "s3:ListBucket" actions.`);
38
+ }
39
+ throw err;
40
+ }
41
+ }
42
+ const objCommand = new client_s3_1.GetObjectCommand({
43
+ Bucket: bucketName,
44
+ Key: objectKey,
45
+ });
46
+ const publicUrl = await (0, s3_request_presigner_1.getSignedUrl)(s3Client, objCommand, {
47
+ expiresIn: expiresInSeconds,
48
+ });
49
+ return publicUrl;
50
+ };
51
+ /*
52
+ * @description Takes a private S3 object and turns it into a public URL by signing it with your AWS credentials.
53
+ * @see [Documentation](https://remotion.dev/docs/lambda/presignurl)
54
+ */
55
+ const presignUrl = ({ region, bucketName, objectKey, checkIfObjectExists, expiresInSeconds, forcePathStyle, requestHandler, }) => {
56
+ return internalPresignUrl({
57
+ region,
58
+ bucketName,
59
+ objectKey,
60
+ checkIfObjectExists: checkIfObjectExists !== null && checkIfObjectExists !== void 0 ? checkIfObjectExists : false,
61
+ expiresInSeconds,
62
+ forcePathStyle: forcePathStyle !== null && forcePathStyle !== void 0 ? forcePathStyle : false,
63
+ requestHandler,
64
+ });
65
+ };
66
+ 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
+ };