|
| 1 | +export interface AmplifyComputeConfig { |
| 2 | + /** |
| 3 | + * The name property dictates the name of the provisioned compute resource. It is also the name |
| 4 | + * of the sub-directory in the `compute` folder in the deployment bundle. |
| 5 | + */ |
| 6 | + name: string; |
| 7 | + /** |
| 8 | + * The runtime property dictates the runtime of the provisioned compute resource. |
| 9 | + * Values are subset of https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html |
| 10 | + */ |
| 11 | + runtime: "nodejs16.x" | "nodejs18.x"; |
| 12 | + |
| 13 | + /** |
| 14 | + * Specifies the starting file from which code will run for the given compute resource. |
| 15 | + * The specified file should exist inside the given sub-directory that represents a compute resource. |
| 16 | + * |
| 17 | + * @example `"entrypoint.js"` |
| 18 | + */ |
| 19 | + entrypoint: string; |
| 20 | +} |
| 21 | + |
| 22 | +export type AmplifyRouteTarget = |
| 23 | + | { kind: "Static"; cacheControl?: string } |
| 24 | + | { kind: "ImageOptimization"; cacheControl?: string } |
| 25 | + | { |
| 26 | + kind: "Compute"; |
| 27 | + /** |
| 28 | + * A string that indicates the name of the sub-directory in the given deployment bundle that |
| 29 | + * contains the primitive's executable code. Valid and required only for the Compute primitive. |
| 30 | + * The value here should point to one of the compute resources present in the given |
| 31 | + * deployment bundle. The only supported value for this field is default. |
| 32 | + */ |
| 33 | + src: string; |
| 34 | + }; |
| 35 | + |
| 36 | +export type AmplifyRoute = { |
| 37 | + /** |
| 38 | + * The path defines a glob pattern that matches incoming request paths (excluding querystring). |
| 39 | + * The first match in a given list of rules determines which routing rule is applied to the incoming request. |
| 40 | + * Only the following wilcard characters are supported as far as pattern matching is concerned: `*` (matches 0 or more characters) |
| 41 | + * |
| 42 | + * _Note_: The "/*" pattern is called a catch-all pattern and will match all incoming requests. |
| 43 | + * It is special because fallback routing is only supported for catch-all routes. |
| 44 | + * |
| 45 | + */ |
| 46 | + path: string; |
| 47 | + |
| 48 | + /** |
| 49 | + * An object that dictates the target to route the matched request to. |
| 50 | + */ |
| 51 | + target: AmplifyRouteTarget; |
| 52 | + |
| 53 | + /** An object that dictates the target to fallback to if the original target returns a 404. */ |
| 54 | + fallback?: AmplifyRouteTarget; |
| 55 | +}; |
| 56 | + |
| 57 | +export type AmplifyImageSettings = { |
| 58 | + /** Array of supported image widths */ |
| 59 | + sizes: number[]; |
| 60 | + |
| 61 | + /** |
| 62 | + * Array of allowed external domains that can use Image Optimization. |
| 63 | + * Leave empty for only allowing the deployment domain to use Image Optimization. |
| 64 | + */ |
| 65 | + domains: string[]; |
| 66 | + |
| 67 | + /** |
| 68 | + * Array of allowed external patterns that can use Image Optimization. |
| 69 | + * Similar to `domains` but provides more control with RegExp. |
| 70 | + */ |
| 71 | + remotePatterns: { |
| 72 | + /** The protocol of the allowed remote pattern. Can be `http` or `https`. */ |
| 73 | + protocol?: "http" | "https"; |
| 74 | + /** |
| 75 | + * The hostname of the allowed remote pattern. |
| 76 | + * Can be literal or wildcard. Single `*` matches a single subdomain. |
| 77 | + * Double `**` matches any number of subdomains. |
| 78 | + * We will disallow blanket wildcards of `**` with nothing else. |
| 79 | + */ |
| 80 | + hostname: string; |
| 81 | + /** The port of the allowed remote pattern. */ |
| 82 | + port?: string; |
| 83 | + /** The pathname of the allowed remote pattern. */ |
| 84 | + pathname?: string; |
| 85 | + }[]; |
| 86 | + |
| 87 | + /** Array of allowed output image formats. */ |
| 88 | + formats?: ( |
| 89 | + | "image/avif" |
| 90 | + | "image/webp" |
| 91 | + | "image/gif" |
| 92 | + | "image/png" |
| 93 | + | "image/jpeg" |
| 94 | + )[]; |
| 95 | + |
| 96 | + /** Cache duration (in seconds) for the optimized images. */ |
| 97 | + minimumCacheTTL?: number; |
| 98 | + |
| 99 | + /** Allow SVG input image URLs. This is disabled by default for security purposes. */ |
| 100 | + dangerouslyAllowSVG?: boolean; |
| 101 | +}; |
| 102 | + |
| 103 | +export interface AmplifyDeployManifest { |
| 104 | + /** The `version` property dictates the version of the Deployment Specification that has been implemented */ |
| 105 | + version: 1; |
| 106 | + |
| 107 | + /** |
| 108 | + * The routes property allows framework authors to leverage the routing rules primitive. |
| 109 | + * Routing rules provide a mechanism by which incoming request paths can be routed to a specific target |
| 110 | + * in the deployment bundle. Routing rules only dictate the destination of an incoming request and they are |
| 111 | + * applied after rewrite/redirect rules have already transformed the request. |
| 112 | + * |
| 113 | + * Limits for routing rules: |
| 114 | + * - A limit of 25 rules will be enforced on the routes array |
| 115 | + */ |
| 116 | + routes?: AmplifyRoute[]; |
| 117 | + |
| 118 | + /** |
| 119 | + * The imageSettings property allows framework authors to customize the behavior of the image optimization primitive, |
| 120 | + * which provides on-demand optimization of images at runtime. |
| 121 | + */ |
| 122 | + imageSettings?: AmplifyImageSettings; |
| 123 | + /** |
| 124 | + * Metadata about the provisioned compute resource(s). Each item in the array is an object that contains metadata |
| 125 | + * about that compute resource. |
| 126 | + * |
| 127 | + * For example, given the following directory structure: |
| 128 | + * ``` |
| 129 | + * .amplify |
| 130 | + * └── compute |
| 131 | + * └── default |
| 132 | + * └── index.js |
| 133 | + * ``` |
| 134 | + * The `computeResources` property would look like: |
| 135 | + * ``` |
| 136 | + * [ |
| 137 | + * { |
| 138 | + * name: 'default', |
| 139 | + * runtime: 'nodejs16.x', |
| 140 | + * entrypoint: 'index.js', |
| 141 | + * } |
| 142 | + * ] |
| 143 | + * ``` |
| 144 | + */ |
| 145 | + computeResources?: AmplifyComputeConfig[]; |
| 146 | + |
| 147 | + // Framework Metadata |
| 148 | + framework: { |
| 149 | + name: string; |
| 150 | + version: string; |
| 151 | + }; |
| 152 | +} |
| 153 | + |
| 154 | +export interface AWSAmplifyOptions { |
| 155 | + imageOptimization?: { |
| 156 | + path?: string; |
| 157 | + cacheControl?: string; |
| 158 | + }; |
| 159 | + imageSettings?: AmplifyImageSettings; |
| 160 | +} |
0 commit comments