Skip to content

Commit

Permalink
update naming
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Jul 21, 2023
1 parent fde3e2c commit 563f3cb
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions packages/backend-function/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { execaCommand } from 'execa';
import * as path from 'path';
import { getCallerDirectory } from './get_caller_directory.js';

export type AmplifyFunctionBaseProps = {
export type AmplifyFunctionFactoryBaseProps = {
/**
* A name for the function that is used to disambiguate it from other functions in the project
*/
name: string;
};

export type AmplifyFunctionBuildProps = AmplifyFunctionBaseProps &
export type AmplifyFunctionFactoryBuildProps = AmplifyFunctionFactoryBaseProps &
Omit<AmplifyFunctionProps, 'absoluteCodePath'> & {
/**
* The command to run that generates built function code.
Expand All @@ -33,17 +33,18 @@ export type AmplifyFunctionBuildProps = AmplifyFunctionBaseProps &
outDir: string;
};

export type AmplifyFunctionFromDirProps = AmplifyFunctionBaseProps &
Omit<AmplifyFunctionProps, 'absoluteCodePath'> & {
/**
* The location of the pre-built function code.
* Can be a directory or a .zip file.
* Can be a relative or absolute path. If relative, the absolute path is calculated based on the directory where this factory is called.
*/
codePath: string;
};

type AmplifyFunctionFactoryProps = AmplifyFunctionBaseProps &
export type AmplifyFunctionFactoryFromDirProps =
AmplifyFunctionFactoryBaseProps &
Omit<AmplifyFunctionProps, 'absoluteCodePath'> & {
/**
* The location of the pre-built function code.
* Can be a directory or a .zip file.
* Can be a relative or absolute path. If relative, the absolute path is calculated based on the directory where this factory is called.
*/
codePath: string;
};

type AmplifyFunctionFactoryProps = AmplifyFunctionFactoryBaseProps &
AmplifyFunctionProps;

/**
Expand All @@ -64,7 +65,9 @@ export class AmplifyFunctionFactory
/**
* Create a function from a directory that contains pre-built code
*/
static fromDir(props: AmplifyFunctionFromDirProps): AmplifyFunctionFactory {
static fromDir(
props: AmplifyFunctionFactoryFromDirProps
): AmplifyFunctionFactory {
const absoluteCodePath = path.isAbsolute(props.codePath)
? props.codePath
: path.resolve(getCallerDirectory(new Error().stack), props.codePath);
Expand All @@ -80,7 +83,7 @@ export class AmplifyFunctionFactory
* Create a function by executing a build command that places build artifacts at a specified location
*/
static async build(
props: AmplifyFunctionBuildProps
props: AmplifyFunctionFactoryBuildProps
): Promise<AmplifyFunctionFactory> {
const importPath = getCallerDirectory(new Error().stack);

Expand Down

0 comments on commit 563f3cb

Please sign in to comment.