Skip to content

Commit e0a8db3

Browse files
committed
Update internal exports
1 parent a06066c commit e0a8db3

File tree

4 files changed

+109
-45
lines changed

4 files changed

+109
-45
lines changed

packages/backend-function/API.md

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,40 @@
44
55
```ts
66

7+
import { BackendSecret } from '@aws-amplify/plugin-types';
8+
import { ConstructFactory } from '@aws-amplify/plugin-types';
9+
import { FunctionResources } from '@aws-amplify/plugin-types';
10+
import { ResourceAccessAcceptorFactory } from '@aws-amplify/plugin-types';
11+
import { ResourceProvider } from '@aws-amplify/plugin-types';
712
import { S3Client } from '@aws-sdk/client-s3';
13+
import { StackProvider } from '@aws-amplify/plugin-types';
814

9-
declare namespace __export__get_amplify_clients_configuration {
15+
declare namespace __export__runtime {
1016
export {
17+
getAmplifyDataClientConfig,
18+
DataClientConfig,
1119
DataClientEnv,
12-
getResourceConfig,
13-
getLibraryOptions,
14-
InvalidConfig,
1520
DataClientError,
16-
DataClientConfig,
1721
DataClientReturn,
18-
getAmplifyDataClientConfig
19-
}
20-
}
21-
export { __export__get_amplify_clients_configuration }
22-
23-
declare namespace __export__runtime {
24-
export {
25-
getAmplifyDataClientConfig
22+
InvalidConfig,
23+
LibraryOptions,
24+
ResourceConfig
2625
}
2726
}
2827
export { __export__runtime }
2928

29+
// @public (undocumented)
30+
export type AddEnvironmentFactory = {
31+
addEnvironment: (key: string, value: string | BackendSecret) => void;
32+
};
33+
34+
// @public (undocumented)
35+
export type CronSchedule = `${string} ${string} ${string} ${string} ${string}` | `${string} ${string} ${string} ${string} ${string} ${string}`;
36+
3037
// @public (undocumented)
3138
type DataClientConfig = {
32-
resourceConfig: ReturnType<typeof getResourceConfig>;
33-
libraryOptions: ReturnType<typeof getLibraryOptions>;
39+
resourceConfig: ResourceConfig;
40+
libraryOptions: LibraryOptions;
3441
};
3542

3643
// @public (undocumented)
@@ -54,10 +61,39 @@ type DataClientError = {
5461
type DataClientReturn<T> = T extends DataClientEnv ? DataClientConfig : DataClientError;
5562

5663
// @public
57-
const getAmplifyDataClientConfig: <T>(env: T, s3Client?: S3Client) => Promise<DataClientReturn<T>>;
64+
export const defineFunction: (props?: FunctionProps) => ConstructFactory<ResourceProvider<FunctionResources> & ResourceAccessAcceptorFactory & AddEnvironmentFactory & StackProvider>;
65+
66+
// @public (undocumented)
67+
export type FunctionBundlingOptions = {
68+
minify?: boolean;
69+
};
70+
71+
// @public (undocumented)
72+
export type FunctionProps = {
73+
name?: string;
74+
entry?: string;
75+
timeoutSeconds?: number;
76+
memoryMB?: number;
77+
environment?: Record<string, string | BackendSecret>;
78+
runtime?: NodeVersion;
79+
schedule?: FunctionSchedule | FunctionSchedule[];
80+
layers?: Record<string, string>;
81+
bundling?: FunctionBundlingOptions;
82+
};
83+
84+
// @public (undocumented)
85+
export type FunctionSchedule = TimeInterval | CronSchedule;
5886

5987
// @public
60-
const getLibraryOptions: (env: DataClientEnv) => {
88+
const getAmplifyDataClientConfig: <T>(env: T, s3Client?: S3Client) => Promise<DataClientReturn<T>>;
89+
90+
// @public (undocumented)
91+
type InvalidConfig = unknown & {
92+
invalidType: 'This function needs to be granted `authorization((allow) => [allow.resource(fcn)])` on the data schema.';
93+
};
94+
95+
// @public (undocumented)
96+
type LibraryOptions = {
6197
Auth: {
6298
credentialsProvider: {
6399
getCredentialsAndIdentityId: () => Promise<{
@@ -72,22 +108,23 @@ const getLibraryOptions: (env: DataClientEnv) => {
72108
};
73109
};
74110

75-
// @public
76-
const getResourceConfig: (env: DataClientEnv, modelIntrospectionSchema: object) => {
111+
// @public (undocumented)
112+
export type NodeVersion = 16 | 18 | 20;
113+
114+
// @public (undocumented)
115+
type ResourceConfig = {
77116
API: {
78117
GraphQL: {
79118
endpoint: string;
80119
region: string;
81-
defaultAuthMode: "iam";
120+
defaultAuthMode: string;
82121
modelIntrospection: any;
83122
};
84123
};
85124
};
86125

87126
// @public (undocumented)
88-
type InvalidConfig = unknown & {
89-
invalidType: 'This function needs to be granted `authorization((allow) => [allow.resource(fcn)])` on the data schema.';
90-
};
127+
export type TimeInterval = `every ${number}m` | `every ${number}h` | `every day` | `every week` | `every month` | `every year`;
91128

92129
// (No @packageDocumentation comment for this package)
93130

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
export * from './index.js';
12
// eslint-disable-next-line @typescript-eslint/naming-convention
23
import * as __export__runtime from './runtime/index.js';
3-
// eslint-disable-next-line @typescript-eslint/naming-convention
4-
import * as __export__get_amplify_clients_configuration from './runtime/get_amplify_clients_configuration.js';
54

65
/*
76
Api-extractor does not ([yet](https://github.com/microsoft/rushstack/issues/1596)) support multiple package entry points
87
Because this package has a submodule export, we are working around this issue by including that export here and directing api-extract to this entry point instead
98
This allows api-extractor to pick up the submodule exports in its analysis
109
*/
11-
export { __export__runtime, __export__get_amplify_clients_configuration };
10+
export { __export__runtime };

packages/backend-function/src/runtime/get_amplify_clients_configuration.ts

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,54 @@ const isDataClientEnv = (env: unknown): env is DataClientEnv => {
3939
);
4040
};
4141

42-
/**
43-
* Fill in the resourceConfig for the data client
44-
* @param env The environment variables for the data client
45-
* @param modelIntrospectionSchema The introspection schema to use
46-
* @returns The resourceConfig for the data client
47-
*/
48-
export const getResourceConfig = (
42+
/* eslint-disable @typescript-eslint/naming-convention */
43+
export type ResourceConfig = {
44+
API: {
45+
GraphQL: {
46+
endpoint: string;
47+
region: string;
48+
defaultAuthMode: string;
49+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
50+
modelIntrospection: any;
51+
};
52+
};
53+
};
54+
/* eslint-enable @typescript-eslint/naming-convention */
55+
56+
const getResourceConfig = (
4957
env: DataClientEnv,
5058
modelIntrospectionSchema: object
51-
) => {
59+
): ResourceConfig => {
5260
return {
5361
API: {
5462
GraphQL: {
5563
endpoint: env.AMPLIFY_DATA_GRAPHQL_ENDPOINT,
5664
region: env.AWS_REGION,
5765
defaultAuthMode: 'iam' as const,
58-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
59-
modelIntrospection: modelIntrospectionSchema as any,
66+
67+
modelIntrospection: modelIntrospectionSchema,
6068
},
6169
},
6270
};
6371
};
6472

65-
/**
66-
* Fill in the libraryOptions for the data client
67-
* @param env The environment variables for the data client
68-
* @returns The libraryOptions for the data client
69-
*/
70-
export const getLibraryOptions = (env: DataClientEnv) => {
73+
export type LibraryOptions = {
74+
/* eslint-disable-next-line @typescript-eslint/naming-convention */
75+
Auth: {
76+
credentialsProvider: {
77+
getCredentialsAndIdentityId: () => Promise<{
78+
credentials: {
79+
accessKeyId: string;
80+
secretAccessKey: string;
81+
sessionToken: string;
82+
};
83+
}>;
84+
clearCredentialsAndIdentityId: () => void;
85+
};
86+
};
87+
};
88+
89+
const getLibraryOptions = (env: DataClientEnv): LibraryOptions => {
7190
return {
7291
Auth: {
7392
credentialsProvider: {
@@ -96,8 +115,8 @@ export type DataClientError = {
96115
};
97116

98117
export type DataClientConfig = {
99-
resourceConfig: ReturnType<typeof getResourceConfig>;
100-
libraryOptions: ReturnType<typeof getLibraryOptions>;
118+
resourceConfig: ResourceConfig;
119+
libraryOptions: LibraryOptions;
101120
};
102121

103122
export type DataClientReturn<T> = T extends DataClientEnv
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
export { getAmplifyDataClientConfig } from './get_amplify_clients_configuration.js';
1+
export {
2+
getAmplifyDataClientConfig,
3+
DataClientConfig,
4+
DataClientEnv,
5+
DataClientError,
6+
DataClientReturn,
7+
InvalidConfig,
8+
LibraryOptions,
9+
ResourceConfig,
10+
} from './get_amplify_clients_configuration.js';

0 commit comments

Comments
 (0)