@remotion/lambda 4.0.186 → 4.0.188

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 (230) hide show
  1. package/dist/api/__mocks__/clean-items.d.ts +2 -0
  2. package/dist/api/__mocks__/clean-items.js +24 -0
  3. package/dist/api/__mocks__/create-function.d.ts +2 -0
  4. package/dist/api/__mocks__/create-function.js +21 -0
  5. package/dist/api/__mocks__/delete-function.d.ts +2 -0
  6. package/dist/api/__mocks__/delete-function.js +9 -0
  7. package/dist/api/__mocks__/get-functions.d.ts +2 -0
  8. package/dist/api/__mocks__/get-functions.js +9 -0
  9. package/dist/api/__mocks__/upload-dir.d.ts +3 -0
  10. package/dist/api/__mocks__/upload-dir.js +47 -0
  11. package/dist/api/bucket-exists.d.ts +3 -6
  12. package/dist/api/bucket-exists.js +5 -5
  13. package/dist/api/clean-items.d.ts +4 -3
  14. package/dist/api/clean-items.js +7 -7
  15. package/dist/api/create-bucket.d.ts +3 -5
  16. package/dist/api/create-bucket.js +6 -6
  17. package/dist/api/create-function.d.ts +1 -1
  18. package/dist/api/delete-function.d.ts +1 -1
  19. package/dist/api/delete-render.d.ts +10 -3
  20. package/dist/api/delete-render.js +27 -19
  21. package/dist/api/delete-site.d.ts +7 -2
  22. package/dist/api/delete-site.js +23 -15
  23. package/dist/api/deploy-function.d.ts +1 -1
  24. package/dist/api/deploy-function.js +2 -2
  25. package/dist/api/deploy-site.d.ts +9 -5
  26. package/dist/api/deploy-site.js +11 -12
  27. package/dist/api/download-media.d.ts +8 -3
  28. package/dist/api/download-media.js +24 -15
  29. package/dist/api/estimate-price.d.ts +1 -1
  30. package/dist/api/get-aws-client.d.ts +4 -2
  31. package/dist/api/get-aws-client.js +2 -2
  32. package/dist/api/get-buckets.d.ts +4 -4
  33. package/dist/api/get-buckets.js +12 -14
  34. package/dist/api/get-compositions-on-lambda.js +7 -6
  35. package/dist/api/get-function-info.d.ts +1 -1
  36. package/dist/api/get-functions.d.ts +1 -1
  37. package/dist/api/get-or-create-bucket.d.ts +3 -19
  38. package/dist/api/get-or-create-bucket.js +5 -39
  39. package/dist/api/get-regions.d.ts +1 -1
  40. package/dist/api/get-regions.js +1 -2
  41. package/dist/api/get-render-progress.d.ts +4 -3
  42. package/dist/api/get-render-progress.js +2 -2
  43. package/dist/api/get-sites.d.ts +6 -1
  44. package/dist/api/get-sites.js +21 -14
  45. package/dist/api/iam-validation/role-permissions.js +2 -1
  46. package/dist/api/iam-validation/simulate-rule.d.ts +1 -1
  47. package/dist/api/iam-validation/simulate.d.ts +1 -1
  48. package/dist/api/iam-validation/user-permissions.js +2 -1
  49. package/dist/api/make-lambda-payload.d.ts +8 -9
  50. package/dist/api/make-lambda-payload.js +15 -13
  51. package/dist/api/mock-functions.d.ts +1 -1
  52. package/dist/api/presign-url.d.ts +1 -1
  53. package/dist/api/presign-url.js +4 -4
  54. package/dist/api/render-media-on-lambda.d.ts +5 -6
  55. package/dist/api/render-media-on-lambda.js +5 -5
  56. package/dist/api/render-still-on-lambda.d.ts +8 -6
  57. package/dist/api/render-still-on-lambda.js +6 -5
  58. package/dist/api/upload-dir.d.ts +2 -2
  59. package/dist/api/upload-dir.js +2 -2
  60. package/dist/cli/args.d.ts +2 -3
  61. package/dist/cli/commands/render/progress.d.ts +2 -2
  62. package/dist/cli/commands/render/progress.js +6 -5
  63. package/dist/cli/commands/render/render.d.ts +3 -1
  64. package/dist/cli/commands/render/render.js +3 -2
  65. package/dist/cli/commands/sites/create.d.ts +3 -1
  66. package/dist/cli/commands/sites/create.js +6 -5
  67. package/dist/cli/commands/sites/index.d.ts +3 -1
  68. package/dist/cli/commands/sites/index.js +4 -4
  69. package/dist/cli/commands/sites/rm.d.ts +3 -1
  70. package/dist/cli/commands/sites/rm.js +4 -3
  71. package/dist/cli/commands/sites/rmall.d.ts +3 -1
  72. package/dist/cli/commands/sites/rmall.js +4 -3
  73. package/dist/cli/commands/still.d.ts +3 -1
  74. package/dist/cli/commands/still.js +3 -2
  75. package/dist/cli/get-aws-region.d.ts +1 -1
  76. package/dist/cli/helpers/__mocks__/quit.d.ts +1 -0
  77. package/dist/cli/helpers/__mocks__/quit.js +7 -0
  78. package/dist/cli/index.d.ts +3 -1
  79. package/dist/cli/index.js +8 -7
  80. package/dist/client.d.ts +4 -5
  81. package/dist/functions/aws-implementation.d.ts +11 -0
  82. package/dist/functions/aws-implementation.js +49 -0
  83. package/dist/functions/chunk-optimization/plan-frame-ranges.d.ts +4 -1
  84. package/dist/functions/compositions.d.ts +3 -2
  85. package/dist/functions/compositions.js +18 -15
  86. package/dist/functions/helpers/__mocks__/get-browser-instance.d.ts +3 -0
  87. package/dist/functions/helpers/__mocks__/get-browser-instance.js +12 -0
  88. package/dist/functions/helpers/__mocks__/leak-detection.d.ts +4 -0
  89. package/dist/functions/helpers/__mocks__/leak-detection.js +9 -0
  90. package/dist/functions/helpers/__mocks__/timer.d.ts +2 -0
  91. package/dist/functions/helpers/__mocks__/timer.js +10 -0
  92. package/dist/functions/helpers/calculate-price-from-bucket.d.ts +5 -3
  93. package/dist/functions/helpers/calculate-price-from-bucket.js +2 -3
  94. package/dist/functions/helpers/cleanup-props.d.ts +4 -2
  95. package/dist/functions/helpers/cleanup-props.js +5 -4
  96. package/dist/functions/helpers/concat-videos.d.ts +2 -2
  97. package/dist/functions/helpers/create-post-render-data.d.ts +8 -8
  98. package/dist/functions/helpers/create-post-render-data.js +1 -1
  99. package/dist/functions/helpers/expected-out-name.d.ts +4 -4
  100. package/dist/functions/helpers/find-output-file-in-bucket.d.ts +8 -7
  101. package/dist/functions/helpers/find-output-file-in-bucket.js +5 -6
  102. package/dist/functions/helpers/get-browser-instance.d.ts +3 -2
  103. package/dist/functions/helpers/get-browser-instance.js +3 -4
  104. package/dist/functions/helpers/get-current-region.d.ts +1 -1
  105. package/dist/functions/helpers/get-current-region.js +3 -3
  106. package/dist/functions/helpers/get-custom-out-name.d.ts +5 -5
  107. package/dist/functions/helpers/get-folder-files.d.ts +2 -0
  108. package/dist/functions/helpers/get-folder-files.js +38 -0
  109. package/dist/functions/helpers/get-output-url-from-metadata.d.ts +4 -3
  110. package/dist/functions/helpers/get-output-url-from-metadata.js +4 -5
  111. package/dist/functions/helpers/get-overall-progress-s3.d.ts +5 -4
  112. package/dist/functions/helpers/get-overall-progress-s3.js +5 -7
  113. package/dist/functions/helpers/get-progress.d.ts +8 -7
  114. package/dist/functions/helpers/get-progress.js +7 -5
  115. package/dist/functions/helpers/inspect-errors.d.ts +1 -1
  116. package/dist/functions/helpers/inspect-errors.js +4 -4
  117. package/dist/functions/helpers/io.d.ts +3 -36
  118. package/dist/functions/helpers/io.js +3 -104
  119. package/dist/functions/helpers/lifecycle.d.ts +3 -9
  120. package/dist/functions/helpers/lifecycle.js +6 -16
  121. package/dist/functions/helpers/make-aws-artifact.d.ts +3 -0
  122. package/dist/functions/helpers/make-aws-artifact.js +12 -0
  123. package/dist/functions/helpers/make-timeout-error.d.ts +5 -4
  124. package/dist/functions/helpers/make-timeout-error.js +2 -1
  125. package/dist/functions/helpers/make-timeout-message.d.ts +5 -3
  126. package/dist/functions/helpers/make-timeout-message.js +8 -9
  127. package/dist/functions/helpers/merge-chunks.d.ts +10 -10
  128. package/dist/functions/helpers/merge-chunks.js +7 -8
  129. package/dist/functions/helpers/overall-render-progress.d.ts +18 -23
  130. package/dist/functions/helpers/overall-render-progress.js +5 -5
  131. package/dist/functions/helpers/print-cloudwatch-helper.d.ts +2 -2
  132. package/dist/functions/helpers/print-logging-helper.d.ts +4 -0
  133. package/dist/functions/helpers/print-logging-helper.js +12 -0
  134. package/dist/functions/helpers/read-with-progress.d.ts +4 -3
  135. package/dist/functions/helpers/read-with-progress.js +2 -2
  136. package/dist/functions/helpers/render-has-audio-video.d.ts +3 -2
  137. package/dist/functions/helpers/stream-renderer.d.ts +7 -4
  138. package/dist/functions/helpers/stream-renderer.js +11 -10
  139. package/dist/functions/helpers/streamify-response.d.ts +0 -20
  140. package/dist/functions/helpers/streamify-response.js +1 -62
  141. package/dist/functions/helpers/validate-composition.d.ts +5 -3
  142. package/dist/functions/helpers/validate-composition.js +2 -3
  143. package/dist/functions/index.d.ts +5 -3
  144. package/dist/functions/index.js +98 -72
  145. package/dist/functions/info.d.ts +1 -1
  146. package/dist/functions/info.js +2 -2
  147. package/dist/functions/launch.d.ts +3 -2
  148. package/dist/functions/launch.js +54 -41
  149. package/dist/functions/progress.d.ts +6 -3
  150. package/dist/functions/progress.js +5 -4
  151. package/dist/functions/provider-implementation.d.ts +0 -0
  152. package/dist/functions/provider-implementation.js +1 -0
  153. package/dist/functions/renderer.d.ts +9 -3
  154. package/dist/functions/renderer.js +30 -22
  155. package/dist/functions/start.d.ts +3 -2
  156. package/dist/functions/start.js +13 -16
  157. package/dist/functions/still.d.ts +8 -18
  158. package/dist/functions/still.js +47 -46
  159. package/dist/index.d.ts +4 -6
  160. package/dist/internals.d.ts +15 -13
  161. package/dist/io/delete-file.d.ts +3 -0
  162. package/dist/io/delete-file.js +12 -0
  163. package/dist/io/head-file.d.ts +3 -0
  164. package/dist/io/head-file.js +13 -0
  165. package/dist/io/list-objects.d.ts +3 -0
  166. package/dist/io/list-objects.js +58 -0
  167. package/dist/io/read-file.d.ts +9 -0
  168. package/dist/io/read-file.js +14 -0
  169. package/dist/io/write-file.d.ts +5 -0
  170. package/dist/io/write-file.js +51 -0
  171. package/dist/pricing/aws-regions.d.ts +0 -3
  172. package/dist/pricing/aws-regions.js +0 -44
  173. package/dist/pricing/price-per-1-s.d.ts +1 -1
  174. package/dist/regions.d.ts +3 -2
  175. package/dist/regions.js +43 -3
  176. package/dist/shared/__mocks__/aws-clients.d.ts +2 -0
  177. package/dist/shared/__mocks__/aws-clients.js +62 -0
  178. package/dist/shared/__mocks__/bundle-site.d.ts +2 -0
  179. package/dist/shared/__mocks__/bundle-site.js +32 -0
  180. package/dist/shared/__mocks__/check-credentials.d.ts +1 -0
  181. package/dist/shared/__mocks__/check-credentials.js +5 -0
  182. package/dist/shared/__mocks__/get-account-id.d.ts +2 -0
  183. package/dist/shared/__mocks__/get-account-id.js +11 -0
  184. package/dist/shared/__mocks__/read-dir.d.ts +2 -0
  185. package/dist/shared/__mocks__/read-dir.js +13 -0
  186. package/dist/shared/aws-clients.d.ts +6 -29
  187. package/dist/shared/aws-clients.js +7 -177
  188. package/dist/shared/call-lambda.d.ts +8 -9
  189. package/dist/shared/call-lambda.js +16 -3
  190. package/dist/shared/check-credentials.js +2 -2
  191. package/dist/shared/cleanup-serialized-input-props.d.ts +8 -6
  192. package/dist/shared/cleanup-serialized-input-props.js +7 -8
  193. package/dist/shared/compress-props.d.ts +8 -6
  194. package/dist/shared/compress-props.js +11 -14
  195. package/dist/shared/constants.d.ts +10 -288
  196. package/dist/shared/constants.js +1 -46
  197. package/dist/shared/content-disposition-header.d.ts +1 -6
  198. package/dist/shared/content-disposition-header.js +2 -2
  199. package/dist/shared/convert-to-serve-url.d.ts +2 -2
  200. package/dist/shared/convert-to-serve-url.js +3 -3
  201. package/dist/shared/get-account-id.d.ts +1 -1
  202. package/dist/shared/get-aws-urls.d.ts +2 -2
  203. package/dist/shared/get-credentials.d.ts +9 -0
  204. package/dist/shared/get-credentials.js +53 -0
  205. package/dist/shared/get-function-version.d.ts +1 -1
  206. package/dist/shared/get-function-version.js +2 -1
  207. package/dist/shared/get-s3-client.d.ts +5 -0
  208. package/dist/shared/get-s3-client.js +13 -0
  209. package/dist/shared/get-service-client.d.ts +22 -0
  210. package/dist/shared/get-service-client.js +117 -0
  211. package/dist/shared/hosted-layers.d.ts +1 -1
  212. package/dist/shared/invoke-webhook.d.ts +1 -1
  213. package/dist/shared/lambda-insights-extensions.d.ts +1 -1
  214. package/dist/shared/lifecycle-rules.d.ts +4 -3
  215. package/dist/shared/lifecycle-rules.js +3 -3
  216. package/dist/shared/make-s3-url.d.ts +1 -1
  217. package/dist/shared/random-hash.d.ts +1 -3
  218. package/dist/shared/random-hash.js +3 -4
  219. package/dist/shared/return-values.d.ts +10 -11
  220. package/dist/shared/validate-aws-region.d.ts +1 -1
  221. package/dist/shared/validate-aws-region.js +3 -3
  222. package/dist/shared/validate-bucketname.d.ts +0 -4
  223. package/dist/shared/validate-bucketname.js +3 -23
  224. package/dist/shared/validate-lambda-codec.d.ts +2 -4
  225. package/dist/shared/validate-lambda-codec.js +3 -13
  226. package/dist/shared/validate-outname.js +2 -2
  227. package/dist/shared/validate-privacy.d.ts +1 -1
  228. package/dist/shared/validate-webhook.d.ts +1 -1
  229. package/package.json +11 -9
  230. package/remotionlambda-arm64.zip +0 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdaLsImplementation = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const get_s3_client_1 = require("../shared/get-s3-client");
6
+ const lambdaLsImplementation = async ({ bucketName, prefix, region, expectedBucketOwner, continuationToken, }) => {
7
+ var _a, _b, _c, _d;
8
+ try {
9
+ const list = await (0, get_s3_client_1.getS3Client)(region, null).send(new client_s3_1.ListObjectsV2Command({
10
+ Bucket: bucketName,
11
+ Prefix: prefix,
12
+ ExpectedBucketOwner: expectedBucketOwner !== null && expectedBucketOwner !== void 0 ? expectedBucketOwner : undefined,
13
+ ContinuationToken: continuationToken,
14
+ }));
15
+ if (list.NextContinuationToken) {
16
+ return [
17
+ ...((_a = list.Contents) !== null && _a !== void 0 ? _a : []).map((o) => {
18
+ return {
19
+ Key: o.Key,
20
+ LastModified: o.LastModified,
21
+ ETag: o.ETag,
22
+ Size: o.Size,
23
+ };
24
+ }),
25
+ ...(await (0, exports.lambdaLsImplementation)({
26
+ bucketName,
27
+ prefix,
28
+ expectedBucketOwner,
29
+ region,
30
+ continuationToken: list.NextContinuationToken,
31
+ })),
32
+ ];
33
+ }
34
+ return ((_c = (_b = (list.Contents || [])) === null || _b === void 0 ? void 0 : _b.map((o) => {
35
+ return {
36
+ Key: o.Key,
37
+ LastModified: o.LastModified,
38
+ ETag: o.ETag,
39
+ Size: o.Size,
40
+ };
41
+ })) !== null && _c !== void 0 ? _c : []);
42
+ }
43
+ catch (err) {
44
+ if (!expectedBucketOwner) {
45
+ throw err;
46
+ }
47
+ // Prevent from accessing a foreign bucket, retry without ExpectedBucketOwner and see if it works. If it works then it's an owner mismatch.
48
+ if ((_d = err.stack) === null || _d === void 0 ? void 0 : _d.includes('AccessDenied')) {
49
+ await (0, get_s3_client_1.getS3Client)(region, null).send(new client_s3_1.ListObjectsV2Command({
50
+ Bucket: bucketName,
51
+ Prefix: prefix,
52
+ }));
53
+ throw new Error(`Bucket owner mismatch: Expected the bucket ${bucketName} to be owned by you (AWS Account ID: ${expectedBucketOwner}) but it's not the case. Did you accidentially specify the wrong bucket?`);
54
+ }
55
+ throw err;
56
+ }
57
+ };
58
+ exports.lambdaLsImplementation = lambdaLsImplementation;
@@ -0,0 +1,9 @@
1
+ /// <reference types="node" />
2
+ import type { Readable } from 'stream';
3
+ import type { AwsRegion } from '../regions';
4
+ export declare const lambdaReadFileImplementation: ({ bucketName, key, region, expectedBucketOwner, }: {
5
+ bucketName: string;
6
+ key: string;
7
+ region: AwsRegion;
8
+ expectedBucketOwner: string;
9
+ }) => Promise<Readable>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lambdaReadFileImplementation = void 0;
4
+ const client_s3_1 = require("@aws-sdk/client-s3");
5
+ const get_s3_client_1 = require("../shared/get-s3-client");
6
+ const lambdaReadFileImplementation = async ({ bucketName, key, region, expectedBucketOwner, }) => {
7
+ const { Body } = await (0, get_s3_client_1.getS3Client)(region, null).send(new client_s3_1.GetObjectCommand({
8
+ Bucket: bucketName,
9
+ Key: key,
10
+ ExpectedBucketOwner: expectedBucketOwner,
11
+ }));
12
+ return Body;
13
+ };
14
+ exports.lambdaReadFileImplementation = lambdaReadFileImplementation;
@@ -0,0 +1,5 @@
1
+ import type { WriteFileInput } from '@remotion/serverless';
2
+ import type { AwsProvider } from '../functions/aws-implementation';
3
+ export declare const lambdaWriteFileImplementation: (params: WriteFileInput<AwsProvider> & {
4
+ retries?: number;
5
+ }) => Promise<void>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.lambdaWriteFileImplementation = void 0;
7
+ const client_s3_1 = require("@aws-sdk/client-s3");
8
+ const mime_types_1 = __importDefault(require("mime-types"));
9
+ const content_disposition_header_1 = require("../shared/content-disposition-header");
10
+ const get_s3_client_1 = require("../shared/get-s3-client");
11
+ const tryLambdaWriteFile = async ({ bucketName, key, body, region, privacy, expectedBucketOwner, downloadBehavior, customCredentials, }) => {
12
+ await (0, get_s3_client_1.getS3Client)(region, customCredentials).send(new client_s3_1.PutObjectCommand({
13
+ Bucket: bucketName,
14
+ Key: key,
15
+ Body: body,
16
+ ACL: privacy === 'no-acl'
17
+ ? undefined
18
+ : privacy === 'private'
19
+ ? 'private'
20
+ : 'public-read',
21
+ ExpectedBucketOwner: customCredentials
22
+ ? undefined
23
+ : expectedBucketOwner !== null && expectedBucketOwner !== void 0 ? expectedBucketOwner : undefined,
24
+ ContentType: mime_types_1.default.lookup(key) || 'application/octet-stream',
25
+ ContentDisposition: (0, content_disposition_header_1.getContentDispositionHeader)(downloadBehavior),
26
+ }));
27
+ };
28
+ const lambdaWriteFileImplementation = async (params) => {
29
+ var _a;
30
+ const remainingRetries = (_a = params.retries) !== null && _a !== void 0 ? _a : 2;
31
+ try {
32
+ await tryLambdaWriteFile(params);
33
+ }
34
+ catch (err) {
35
+ if (remainingRetries === 0) {
36
+ throw err;
37
+ }
38
+ const backoff = 2 ** (2 - remainingRetries) * 2000;
39
+ await new Promise((resolve) => {
40
+ setTimeout(resolve, backoff);
41
+ });
42
+ console.warn('Failed to write file to Lambda:');
43
+ console.warn(err);
44
+ console.warn(`Retrying (${remainingRetries} retries remaining)...`);
45
+ return (0, exports.lambdaWriteFileImplementation)({
46
+ ...params,
47
+ retries: remainingRetries - 1,
48
+ });
49
+ }
50
+ };
51
+ exports.lambdaWriteFileImplementation = lambdaWriteFileImplementation;
@@ -1,3 +0,0 @@
1
- export declare const DEFAULT_AWS_REGIONS: readonly ["eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ca-central-1", "sa-east-1"];
2
- export declare const AWS_REGIONS: readonly ["eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-south-1", "eu-north-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "af-south-1", "ap-south-1", "ap-east-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ca-central-1", "me-south-1", "sa-east-1"];
3
- export type AwsRegion = (typeof AWS_REGIONS)[number];
@@ -1,45 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AWS_REGIONS = exports.DEFAULT_AWS_REGIONS = void 0;
4
- exports.DEFAULT_AWS_REGIONS = [
5
- 'eu-central-1',
6
- 'eu-west-1',
7
- 'eu-west-2',
8
- 'eu-west-3',
9
- 'eu-north-1',
10
- 'us-east-1', // N. Virginia
11
- 'us-east-2', // Ohio;
12
- 'us-west-1',
13
- 'us-west-2', // Oregon
14
- 'ap-south-1',
15
- 'ap-southeast-1',
16
- 'ap-southeast-2',
17
- 'ap-northeast-1',
18
- 'ap-northeast-2',
19
- 'ap-northeast-3',
20
- 'ca-central-1',
21
- 'sa-east-1',
22
- ];
23
- exports.AWS_REGIONS = [
24
- 'eu-central-1',
25
- 'eu-west-1',
26
- 'eu-west-2',
27
- 'eu-west-3',
28
- 'eu-south-1',
29
- 'eu-north-1',
30
- 'us-east-1', // N. Virginia
31
- 'us-east-2', // Ohio;
32
- 'us-west-1',
33
- 'us-west-2', // Oregon
34
- 'af-south-1',
35
- 'ap-south-1',
36
- 'ap-east-1',
37
- 'ap-southeast-1',
38
- 'ap-southeast-2',
39
- 'ap-northeast-1',
40
- 'ap-northeast-2',
41
- 'ap-northeast-3',
42
- 'ca-central-1',
43
- 'me-south-1',
44
- 'sa-east-1',
45
- ];
@@ -1,4 +1,4 @@
1
- import type { AwsRegion } from './aws-regions';
1
+ import type { AwsRegion } from '../regions';
2
2
  export declare const pricing: {
3
3
  [key in AwsRegion]: {
4
4
  'Lambda Duration': {
package/dist/regions.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { AWS_REGIONS } from './pricing/aws-regions';
2
- export { AWS_REGIONS };
1
+ export declare const DEFAULT_AWS_REGIONS: readonly ["eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ca-central-1", "sa-east-1"];
2
+ export declare const AWS_REGIONS: readonly ["eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-south-1", "eu-north-1", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "af-south-1", "ap-south-1", "ap-east-1", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ap-northeast-2", "ap-northeast-3", "ca-central-1", "me-south-1", "sa-east-1"];
3
+ export type AwsRegion = (typeof AWS_REGIONS)[number];
package/dist/regions.js CHANGED
@@ -1,5 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AWS_REGIONS = void 0;
4
- const aws_regions_1 = require("./pricing/aws-regions");
5
- Object.defineProperty(exports, "AWS_REGIONS", { enumerable: true, get: function () { return aws_regions_1.AWS_REGIONS; } });
3
+ exports.AWS_REGIONS = exports.DEFAULT_AWS_REGIONS = void 0;
4
+ exports.DEFAULT_AWS_REGIONS = [
5
+ 'eu-central-1',
6
+ 'eu-west-1',
7
+ 'eu-west-2',
8
+ 'eu-west-3',
9
+ 'eu-north-1',
10
+ 'us-east-1', // N. Virginia
11
+ 'us-east-2', // Ohio;
12
+ 'us-west-1',
13
+ 'us-west-2', // Oregon
14
+ 'ap-south-1',
15
+ 'ap-southeast-1',
16
+ 'ap-southeast-2',
17
+ 'ap-northeast-1',
18
+ 'ap-northeast-2',
19
+ 'ap-northeast-3',
20
+ 'ca-central-1',
21
+ 'sa-east-1',
22
+ ];
23
+ exports.AWS_REGIONS = [
24
+ 'eu-central-1',
25
+ 'eu-west-1',
26
+ 'eu-west-2',
27
+ 'eu-west-3',
28
+ 'eu-south-1',
29
+ 'eu-north-1',
30
+ 'us-east-1', // N. Virginia
31
+ 'us-east-2', // Ohio;
32
+ 'us-west-1',
33
+ 'us-west-2', // Oregon
34
+ 'af-south-1',
35
+ 'ap-south-1',
36
+ 'ap-east-1',
37
+ 'ap-southeast-1',
38
+ 'ap-southeast-2',
39
+ 'ap-northeast-1',
40
+ 'ap-northeast-2',
41
+ 'ap-northeast-3',
42
+ 'ca-central-1',
43
+ 'me-south-1',
44
+ 'sa-east-1',
45
+ ];
@@ -0,0 +1,2 @@
1
+ import type { getLambdaClient as original } from '../../shared/aws-clients';
2
+ export declare const getLambdaClient: typeof original;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.getLambdaClient = void 0;
27
+ const serverless_1 = require("@remotion/serverless");
28
+ const mock_implementation_1 = require("../../test/mock-implementation");
29
+ const getLambdaClient = (_region, timeoutInTest) => {
30
+ return {
31
+ config: {
32
+ requestHandler: {},
33
+ apiVersion: 'fake',
34
+ },
35
+ destroy: () => undefined,
36
+ middlewareStack: undefined,
37
+ send: async (params) => {
38
+ const payload = JSON.parse(params.input.Payload);
39
+ const { innerRoutine } = await Promise.resolve().then(() => __importStar(require('../../functions/index')));
40
+ const responseStream = new serverless_1.ResponseStream();
41
+ const prom = innerRoutine(payload, responseStream, {
42
+ invokedFunctionArn: 'arn:fake',
43
+ getRemainingTimeInMillis: () => timeoutInTest !== null && timeoutInTest !== void 0 ? timeoutInTest : 120000,
44
+ awsRequestId: 'fake',
45
+ }, mock_implementation_1.mockImplementation);
46
+ if (params.input.InvocationType === 'RequestResponse' ||
47
+ params.input.InvocationType === 'Event') {
48
+ await prom;
49
+ return { Payload: responseStream.getBufferedData() };
50
+ }
51
+ prom.then(() => {
52
+ responseStream._finish();
53
+ responseStream.end();
54
+ });
55
+ // When streaming, we should not consume the response
56
+ return {
57
+ EventStream: responseStream,
58
+ };
59
+ },
60
+ };
61
+ };
62
+ exports.getLambdaClient = getLambdaClient;
@@ -0,0 +1,2 @@
1
+ import type { bundle } from '@remotion/bundler';
2
+ export declare const bundleSite: typeof bundle;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bundleSite = void 0;
4
+ const convertArgumentsIntoOptions = (args) => {
5
+ var _a;
6
+ if (args.length === 0) {
7
+ throw new TypeError('bundle() was called without arguments');
8
+ }
9
+ const firstArg = args[0];
10
+ if (typeof firstArg === 'string') {
11
+ return {
12
+ entryPoint: firstArg,
13
+ onProgress: args[1],
14
+ ...((_a = args[2]) !== null && _a !== void 0 ? _a : {}),
15
+ };
16
+ }
17
+ if (typeof firstArg.entryPoint !== 'string') {
18
+ throw new TypeError('bundle() was called without the `entryPoint` option');
19
+ }
20
+ return firstArg;
21
+ };
22
+ const bundleSite = (...args) => {
23
+ const { entryPoint } = convertArgumentsIntoOptions(args);
24
+ if (entryPoint === 'first') {
25
+ return Promise.resolve('/path/to/bundle-1');
26
+ }
27
+ if (entryPoint === 'second') {
28
+ return Promise.resolve('/path/to/bundle-2');
29
+ }
30
+ throw new Error('unknown entry');
31
+ };
32
+ exports.bundleSite = bundleSite;
@@ -0,0 +1 @@
1
+ export declare const checkCredentials: () => undefined;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkCredentials = void 0;
4
+ const checkCredentials = () => undefined;
5
+ exports.checkCredentials = checkCredentials;
@@ -0,0 +1,2 @@
1
+ import type { getAccountId as original } from '../get-account-id';
2
+ export declare const getAccountId: typeof original;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAccountId = void 0;
4
+ const getAccountId = () => {
5
+ const accountId = 'aws:iam::123456789'.match(/aws:iam::([0-9]+)/);
6
+ if (!accountId) {
7
+ throw new Error('Cannot get account ID');
8
+ }
9
+ return Promise.resolve(accountId[1]);
10
+ };
11
+ exports.getAccountId = getAccountId;
@@ -0,0 +1,2 @@
1
+ import type { readDirectory as original } from '../../shared/read-dir';
2
+ export declare const readDirectory: typeof original;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readDirectory = void 0;
4
+ const upload_dir_1 = require("../../api/__mocks__/upload-dir");
5
+ const readDirectory = ({ dir }) => {
6
+ const files = (0, upload_dir_1.getDirFiles)(dir);
7
+ const obj = {};
8
+ for (const file of files) {
9
+ obj[file.name] = 'etag';
10
+ }
11
+ return Promise.resolve(obj);
12
+ };
13
+ exports.readDirectory = readDirectory;
@@ -1,33 +1,10 @@
1
- import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
- import { IAMClient } from '@aws-sdk/client-iam';
3
- import { LambdaClient } from '@aws-sdk/client-lambda';
4
- import { S3Client } from '@aws-sdk/client-s3';
5
- import { ServiceQuotasClient } from '@aws-sdk/client-service-quotas';
6
- import { STSClient } from '@aws-sdk/client-sts';
7
- import type { AwsRegion } from '../pricing/aws-regions';
8
- export type ServiceMapping = {
9
- s3: S3Client;
10
- cloudwatch: CloudWatchLogsClient;
11
- iam: IAMClient;
12
- lambda: LambdaClient;
13
- servicequotas: ServiceQuotasClient;
14
- sts: STSClient;
15
- };
16
- export type CustomCredentialsWithoutSensitiveData = {
17
- endpoint: string;
18
- };
19
- export type CustomCredentials = CustomCredentialsWithoutSensitiveData & {
20
- accessKeyId: string | null;
21
- secretAccessKey: string | null;
22
- region?: AwsRegion;
23
- };
24
- export declare const getServiceClient: <T extends keyof ServiceMapping>({ region, service, customCredentials, }: {
25
- region: AwsRegion;
26
- service: T;
27
- customCredentials: CustomCredentials | null;
28
- }) => ServiceMapping[T];
1
+ import type { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
2
+ import type { IAMClient } from '@aws-sdk/client-iam';
3
+ import type { LambdaClient } from '@aws-sdk/client-lambda';
4
+ import type { ServiceQuotasClient } from '@aws-sdk/client-service-quotas';
5
+ import type { STSClient } from '@aws-sdk/client-sts';
6
+ import type { AwsRegion } from '../regions';
29
7
  export declare const getCloudWatchLogsClient: (region: AwsRegion) => CloudWatchLogsClient;
30
- export declare const getS3Client: (region: AwsRegion, customCredentials: CustomCredentials | null) => S3Client;
31
8
  export declare const getLambdaClient: (region: AwsRegion, _timeoutInTest?: number) => LambdaClient;
32
9
  export declare const getIamClient: (region: AwsRegion) => IAMClient;
33
10
  export declare const getServiceQuotasClient: (region: AwsRegion) => ServiceQuotasClient;
@@ -1,189 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStsClient = exports.getServiceQuotasClient = exports.getIamClient = exports.getLambdaClient = exports.getS3Client = exports.getCloudWatchLogsClient = exports.getServiceClient = void 0;
4
- const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
5
- const client_iam_1 = require("@aws-sdk/client-iam");
6
- const client_lambda_1 = require("@aws-sdk/client-lambda");
7
- const client_s3_1 = require("@aws-sdk/client-s3");
8
- const client_service_quotas_1 = require("@aws-sdk/client-service-quotas");
9
- const client_sts_1 = require("@aws-sdk/client-sts");
10
- const credential_providers_1 = require("@aws-sdk/credential-providers");
11
- const no_react_1 = require("remotion/no-react");
12
- const check_credentials_1 = require("./check-credentials");
13
- const constants_1 = require("./constants");
14
- const is_in_lambda_1 = require("./is-in-lambda");
15
- const _clients = {};
16
- const getCredentials = () => {
17
- if ((0, is_in_lambda_1.isInsideLambda)()) {
18
- return undefined;
19
- }
20
- if (process.env.REMOTION_AWS_PROFILE) {
21
- return (0, credential_providers_1.fromIni)({
22
- profile: process.env.REMOTION_AWS_PROFILE,
23
- });
24
- }
25
- if (process.env.REMOTION_AWS_ACCESS_KEY_ID &&
26
- process.env.REMOTION_AWS_SECRET_ACCESS_KEY &&
27
- process.env.REMOTION_AWS_SESSION_TOKEN) {
28
- return {
29
- accessKeyId: process.env.REMOTION_AWS_ACCESS_KEY_ID,
30
- secretAccessKey: process.env.REMOTION_AWS_SECRET_ACCESS_KEY,
31
- sessionToken: process.env.REMOTION_AWS_SESSION_TOKEN,
32
- };
33
- }
34
- if (process.env.REMOTION_AWS_ACCESS_KEY_ID &&
35
- process.env.REMOTION_AWS_SECRET_ACCESS_KEY) {
36
- return {
37
- accessKeyId: process.env.REMOTION_AWS_ACCESS_KEY_ID,
38
- secretAccessKey: process.env.REMOTION_AWS_SECRET_ACCESS_KEY,
39
- };
40
- }
41
- if (process.env.AWS_PROFILE) {
42
- return (0, credential_providers_1.fromIni)({
43
- profile: process.env.AWS_PROFILE,
44
- });
45
- }
46
- if (process.env.AWS_ACCESS_KEY_ID &&
47
- process.env.AWS_SECRET_ACCESS_KEY &&
48
- process.env.AWS_SESSION_TOKEN) {
49
- return {
50
- accessKeyId: process.env.AWS_ACCESS_KEY_ID,
51
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
52
- sessionToken: process.env.AWS_SESSION_TOKEN,
53
- };
54
- }
55
- if (process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY) {
56
- return {
57
- accessKeyId: process.env.AWS_ACCESS_KEY_ID,
58
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
59
- };
60
- }
61
- return undefined;
62
- };
63
- const getCredentialsHash = ({ customCredentials, region, service, }) => {
64
- const hashComponents = {};
65
- if (process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK) {
66
- hashComponents.credentials = {
67
- credentialsSkipped: true,
68
- };
69
- }
70
- else if (process.env.REMOTION_AWS_PROFILE) {
71
- hashComponents.credentials = {
72
- awsProfile: process.env.REMOTION_AWS_PROFILE,
73
- };
74
- }
75
- else if (process.env.REMOTION_AWS_ACCESS_KEY_ID &&
76
- process.env.REMOTION_AWS_SECRET_ACCESS_KEY) {
77
- hashComponents.credentials = {
78
- accessKeyId: process.env.REMOTION_AWS_ACCESS_KEY_ID,
79
- secretAccessKey: process.env.REMOTION_AWS_SECRET_ACCESS_KEY,
80
- };
81
- }
82
- else if (process.env.AWS_PROFILE) {
83
- hashComponents.credentials = {
84
- awsProfile: process.env.AWS_PROFILE,
85
- };
86
- }
87
- else if (process.env.AWS_ACCESS_KEY_ID &&
88
- process.env.AWS_SECRET_ACCESS_KEY) {
89
- hashComponents.credentials = {
90
- accessKeyId: process.env.AWS_ACCESS_KEY_ID,
91
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
92
- };
93
- }
94
- hashComponents.customCredentials = customCredentials;
95
- hashComponents.region = region;
96
- hashComponents.service = service;
97
- return (0, no_react_1.random)(JSON.stringify(hashComponents)).toString().replace('0.', '');
98
- };
99
- const getServiceClient = ({ region, service, customCredentials, }) => {
100
- var _a;
101
- const Client = (() => {
102
- if (service === 'cloudwatch') {
103
- return client_cloudwatch_logs_1.CloudWatchLogsClient;
104
- }
105
- if (service === 'lambda') {
106
- return client_lambda_1.LambdaClient;
107
- }
108
- if (service === 's3') {
109
- return client_s3_1.S3Client;
110
- }
111
- if (service === 'iam') {
112
- return client_iam_1.IAMClient;
113
- }
114
- if (service === 'servicequotas') {
115
- return client_service_quotas_1.ServiceQuotasClient;
116
- }
117
- if (service === 'sts') {
118
- return client_sts_1.STSClient;
119
- }
120
- throw new TypeError('unknown client ' + service);
121
- })();
122
- const key = getCredentialsHash({
123
- region,
124
- customCredentials,
125
- service,
126
- });
127
- if (!_clients[key]) {
128
- (0, check_credentials_1.checkCredentials)();
129
- const lambdaOptions = service === 'lambda'
130
- ? {
131
- httpsAgent: {
132
- maxSockets: constants_1.MAX_FUNCTIONS_PER_RENDER * 2,
133
- },
134
- }
135
- : undefined;
136
- const client = customCredentials
137
- ? new Client({
138
- region: (_a = customCredentials.region) !== null && _a !== void 0 ? _a : 'us-east-1',
139
- credentials: customCredentials.accessKeyId && customCredentials.secretAccessKey
140
- ? {
141
- accessKeyId: customCredentials.accessKeyId,
142
- secretAccessKey: customCredentials.secretAccessKey,
143
- }
144
- : undefined,
145
- endpoint: customCredentials.endpoint,
146
- requestHandler: lambdaOptions,
147
- })
148
- : process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK
149
- ? new Client({
150
- region,
151
- requestHandler: lambdaOptions,
152
- })
153
- : new Client({
154
- region,
155
- credentials: getCredentials(),
156
- requestHandler: lambdaOptions,
157
- });
158
- if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {
159
- return client;
160
- }
161
- _clients[key] = client;
162
- }
163
- return _clients[key];
164
- };
165
- exports.getServiceClient = getServiceClient;
3
+ exports.getStsClient = exports.getServiceQuotasClient = exports.getIamClient = exports.getLambdaClient = exports.getCloudWatchLogsClient = void 0;
4
+ const get_service_client_1 = require("./get-service-client");
166
5
  const getCloudWatchLogsClient = (region) => {
167
- return (0, exports.getServiceClient)({
6
+ return (0, get_service_client_1.getServiceClient)({
168
7
  region,
169
8
  service: 'cloudwatch',
170
9
  customCredentials: null,
171
10
  });
172
11
  };
173
12
  exports.getCloudWatchLogsClient = getCloudWatchLogsClient;
174
- const getS3Client = (region, customCredentials) => {
175
- var _a;
176
- return (0, exports.getServiceClient)({
177
- region: (_a = customCredentials === null || customCredentials === void 0 ? void 0 : customCredentials.region) !== null && _a !== void 0 ? _a : region,
178
- service: 's3',
179
- customCredentials,
180
- });
181
- };
182
- exports.getS3Client = getS3Client;
183
13
  const getLambdaClient = (region,
184
14
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
185
15
  _timeoutInTest) => {
186
- return (0, exports.getServiceClient)({
16
+ return (0, get_service_client_1.getServiceClient)({
187
17
  region,
188
18
  service: 'lambda',
189
19
  customCredentials: null,
@@ -191,11 +21,11 @@ _timeoutInTest) => {
191
21
  };
192
22
  exports.getLambdaClient = getLambdaClient;
193
23
  const getIamClient = (region) => {
194
- return (0, exports.getServiceClient)({ region, service: 'iam', customCredentials: null });
24
+ return (0, get_service_client_1.getServiceClient)({ region, service: 'iam', customCredentials: null });
195
25
  };
196
26
  exports.getIamClient = getIamClient;
197
27
  const getServiceQuotasClient = (region) => {
198
- return (0, exports.getServiceClient)({
28
+ return (0, get_service_client_1.getServiceClient)({
199
29
  region,
200
30
  service: 'servicequotas',
201
31
  customCredentials: null,
@@ -203,6 +33,6 @@ const getServiceQuotasClient = (region) => {
203
33
  };
204
34
  exports.getServiceQuotasClient = getServiceQuotasClient;
205
35
  const getStsClient = (region) => {
206
- return (0, exports.getServiceClient)({ region, service: 'sts', customCredentials: null });
36
+ return (0, get_service_client_1.getServiceClient)({ region, service: 'sts', customCredentials: null });
207
37
  };
208
38
  exports.getStsClient = getStsClient;