🎥 Make videos programmatically with React
privacy public / private
Jonny Burger6d9241674b67
diff --git a/packages/docs/docs/lambda-changelog.md b/packages/docs/docs/lambda-changelog.mdindex 589e6be032..a8c933f585 100644--- a/packages/docs/docs/lambda-changelog.md+++ b/packages/docs/docs/lambda-changelog.md@@ -17,6 +17,7 @@ Keep track of changes to the APIs of Remotion Lambda here.## Unreleased- The default number of max retries is now 1 (previously 3). A new CLI flag `--max-retries` was introduced which can be used for `npx remotion lambda render` and `npx remotion lambda still`+- You can now pass `--privacy=public` or `--privacy=private` in the CLi to determine if the output video should be publicly accessible. The default is and was `public`.## November 12th, 2021diff --git a/packages/lambda/src/cli/args.ts b/packages/lambda/src/cli/args.tsindex 5c66921cfd..b4fb0cccb8 100644--- a/packages/lambda/src/cli/args.ts+++ b/packages/lambda/src/cli/args.ts@@ -1,6 +1,7 @@import {CliInternals} from '@remotion/cli';import minimist from 'minimist';import {AwsRegion} from '../pricing/aws-regions';+import {Privacy} from '../shared/constants';type LambdaCommandLineOptions = {help: boolean;@@ -18,6 +19,7 @@ type LambdaCommandLineOptions = {['save-browser-logs']: boolean;['disable-cloudwatch']: boolean;['max-retries']: number;+ privacy: Privacy;};export const parsedLambdaCli = minimist<LambdaCommandLineOptions>(diff --git a/packages/lambda/src/cli/commands/still.ts b/packages/lambda/src/cli/commands/still.tsindex db1bcb39e0..84c1248171 100644--- a/packages/lambda/src/cli/commands/still.ts+++ b/packages/lambda/src/cli/commands/still.ts@@ -1,7 +1,13 @@import {CliInternals} from '@remotion/cli';import {StillImageFormat} from 'remotion';import {renderStillOnLambda} from '../../api/render-still-on-lambda';-import {BINARY_NAME, DEFAULT_MAX_RETRIES} from '../../shared/constants';+import {+ BINARY_NAME,+ DEFAULT_MAX_RETRIES,+ DEFAULT_OUTPUT_PRIVACY,+} from '../../shared/constants';+import {validatePrivacy} from '../../shared/validate-privacy';+import {validateMaxRetries} from '../../shared/validate-retries';import {parsedLambdaCli} from '../args';import {getAwsRegion} from '../get-aws-region';import {findFunctionName} from '../helpers/find-function-name';@@ -40,9 +46,10 @@ export const stillCommand = async (args: string[]) => {const functionName = await findFunctionName();const maxRetries = parsedLambdaCli['max-retries'] ?? DEFAULT_MAX_RETRIES;- if (typeof maxRetries !== 'number') {- throw new TypeError('max retries should be a number, but is ' + maxRetries);- }+ validateMaxRetries(maxRetries);++ const privacy = parsedLambdaCli.privacy ?? DEFAULT_OUTPUT_PRIVACY;+ validatePrivacy(privacy);const res = await renderStillOnLambda({functionName,@@ -50,8 +57,7 @@ export const stillCommand = async (args: string[]) => {inputProps: cliOptions.inputProps,imageFormat: cliOptions.imageFormat as StillImageFormat,composition,- // TODO: Make configurable- privacy: 'public',+ privacy,region: getAwsRegion(),maxRetries,envVariables: cliOptions.envVariables,diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.tsindex 6fed4def2e..77334a8848 100644--- a/packages/lambda/src/shared/constants.ts+++ b/packages/lambda/src/shared/constants.ts@@ -26,6 +26,8 @@ export const COMMAND_NOT_FOUND = 'Command not found';export const DEFAULT_REGION: AwsRegion = 'us-east-1';export const DEFAULT_MAX_RETRIES = 1;+export const DEFAULT_OUTPUT_PRIVACY: Privacy = 'public';+export const DEFAULT_CLOUDWATCH_RETENTION_PERIOD = 14;// TODO: Rename other buckets in Jonnys accoudn firstdiff --git a/packages/lambda/src/shared/validate-retries.ts b/packages/lambda/src/shared/validate-retries.tsnew file mode 100644index 0000000000..10d1557b18--- /dev/null+++ b/packages/lambda/src/shared/validate-retries.ts@@ -0,0 +1,27 @@+export function validateMaxRetries(+ maxRetries: unknown+): asserts maxRetries is number {+ if (typeof maxRetries !== 'number') {+ throw new TypeError(+ 'maxRetries must be a number, but is ' + JSON.stringify(maxRetries)+ );+ }++ if (!Number.isFinite(maxRetries)) {+ throw new TypeError('maxRetries must be finite, but is ' + maxRetries);+ }++ if (Number.isNaN(maxRetries)) {+ throw new TypeError('maxRetries is NaN');+ }++ if (maxRetries < 0) {+ throw new TypeError(`maxRetries cannot be negative but is ${maxRetries}`);+ }++ if (maxRetries % 1 !== 0) {+ throw new TypeError(+ `maxRetries should be an integer, but is ${maxRetries}.`+ );+ }+}