1 | import { Headers } from '../../clients';
|
2 | import { AtLeastOne } from '../types';
|
3 | export interface LibraryAPIOptions {
|
4 | GraphQL?: {
|
5 | headers?(options?: {
|
6 | query?: string;
|
7 | variables?: Record<string, DocumentType>;
|
8 | }): Promise<Headers | Record<string, unknown>>;
|
9 | withCredentials?: boolean;
|
10 | };
|
11 | REST?: {
|
12 | headers?(options: {
|
13 | apiName: string;
|
14 | }): Promise<Headers>;
|
15 | };
|
16 | }
|
17 | export interface APIGraphQLConfig {
|
18 | |
19 |
|
20 |
|
21 | endpoint: string;
|
22 | |
23 |
|
24 |
|
25 | region?: string;
|
26 | |
27 |
|
28 |
|
29 | apiKey?: string;
|
30 | |
31 |
|
32 |
|
33 | customEndpoint?: string;
|
34 | |
35 |
|
36 |
|
37 |
|
38 | customEndpointRegion?: string;
|
39 | |
40 |
|
41 |
|
42 | defaultAuthMode: GraphQLAuthMode;
|
43 | modelIntrospection?: ModelIntrospectionSchema;
|
44 | }
|
45 |
|
46 |
|
47 |
|
48 | export interface APIEventsConfig {
|
49 | |
50 |
|
51 |
|
52 | endpoint: string;
|
53 | |
54 |
|
55 |
|
56 | region?: string;
|
57 | |
58 |
|
59 |
|
60 | apiKey?: string;
|
61 | |
62 |
|
63 |
|
64 | customEndpoint?: string;
|
65 | |
66 |
|
67 |
|
68 |
|
69 | customEndpointRegion?: string;
|
70 | |
71 |
|
72 |
|
73 | defaultAuthMode: GraphQLAuthMode;
|
74 | }
|
75 | export interface APIRestConfig {
|
76 | |
77 |
|
78 |
|
79 | endpoint: string;
|
80 | |
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | region?: string;
|
87 | |
88 |
|
89 |
|
90 |
|
91 |
|
92 | service?: string;
|
93 | }
|
94 | export interface RESTProviderConfig {
|
95 | REST: Record<string, APIRestConfig>;
|
96 | }
|
97 | export interface GraphQLProviderConfig {
|
98 | GraphQL: APIGraphQLConfig;
|
99 | }
|
100 | export interface EventsProviderConfig {
|
101 | Events: APIEventsConfig;
|
102 | }
|
103 | export type APIConfig = AtLeastOne<RESTProviderConfig & GraphQLProviderConfig & EventsProviderConfig>;
|
104 | export type GraphQLAuthMode = 'apiKey' | 'oidc' | 'userPool' | 'iam' | 'identityPool' | 'lambda' | 'none';
|
105 |
|
106 |
|
107 |
|
108 | export type DocumentType = null | boolean | number | string | DocumentType[] | {
|
109 | [prop: string]: DocumentType;
|
110 | };
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 | export interface ModelIntrospectionSchema {
|
117 | version: 1;
|
118 | models: SchemaModels;
|
119 | nonModels: SchemaNonModels;
|
120 | enums: SchemaEnums;
|
121 | queries?: CustomOperations;
|
122 | mutations?: CustomOperations;
|
123 | subscriptions?: CustomOperations;
|
124 | conversations?: SchemaConversationRoutes;
|
125 | generations?: SchemaGenerationRoutes;
|
126 | }
|
127 |
|
128 |
|
129 |
|
130 | export type SchemaModels = Record<string, SchemaModel>;
|
131 | export type SchemaNonModels = Record<string, SchemaNonModel>;
|
132 | export type SchemaEnums = Record<string, SchemaEnum>;
|
133 | export type CustomOperations = Record<string, CustomOperation>;
|
134 | type SchemaConversationRoutes = Record<string, SchemaConversationRoute>;
|
135 | type SchemaGenerationRoutes = Record<string, CustomOperation>;
|
136 | interface SchemaConversationRoute {
|
137 | name: string;
|
138 | models: SchemaModels;
|
139 | nonModels: SchemaNonModels;
|
140 | enums: SchemaEnums;
|
141 | conversation: SchemaConversation;
|
142 | message: SchemaConversationMessage;
|
143 | }
|
144 | interface SchemaConversation {
|
145 | modelName: string;
|
146 | }
|
147 | interface SchemaConversationMessage {
|
148 | modelName: string;
|
149 | subscribe: CustomOperation;
|
150 | send: CustomOperation;
|
151 | }
|
152 | export interface SchemaModel {
|
153 | name: string;
|
154 | attributes?: ModelAttribute[];
|
155 | fields: Fields;
|
156 | pluralName: string;
|
157 | syncable?: boolean;
|
158 | primaryKeyInfo: PrimaryKeyInfo;
|
159 | }
|
160 | export interface SchemaNonModel {
|
161 | name: string;
|
162 | fields: Fields;
|
163 | }
|
164 | export interface SchemaEnum {
|
165 | name: string;
|
166 | values: string[];
|
167 | }
|
168 | export interface ModelAttribute {
|
169 | type: string;
|
170 | properties?: Record<string, any>;
|
171 | }
|
172 | export interface SecondaryIndexAttribute {
|
173 | type: 'key';
|
174 | properties: {
|
175 | name: string;
|
176 | queryField: string;
|
177 | fields: string[];
|
178 | };
|
179 | }
|
180 | export interface CustomOperation {
|
181 | name: string;
|
182 | type: FieldType;
|
183 | isArray: boolean;
|
184 | isRequired: boolean;
|
185 | arguments?: CustomOperationArguments;
|
186 | }
|
187 | export type CustomOperationArguments = Record<string, CustomOperationArgument>;
|
188 | export interface CustomOperationArgument {
|
189 | name: string;
|
190 | type: InputFieldType;
|
191 | isArray: boolean;
|
192 | isRequired: boolean;
|
193 | isArrayNullable?: boolean;
|
194 | }
|
195 |
|
196 |
|
197 |
|
198 | export type Fields = Record<string, Field>;
|
199 | export interface Field {
|
200 | name: string;
|
201 | type: FieldType;
|
202 | isArray: boolean;
|
203 | isRequired: boolean;
|
204 | isReadOnly?: boolean;
|
205 | isArrayNullable?: boolean;
|
206 | attributes?: FieldAttribute[];
|
207 | association?: AssociationType;
|
208 | }
|
209 | export interface ModelFieldType {
|
210 | model: string;
|
211 | }
|
212 | export interface NonModelFieldType {
|
213 | nonModel: string;
|
214 | }
|
215 | interface EnumType {
|
216 | enum: string;
|
217 | }
|
218 | interface InputType {
|
219 | input: string;
|
220 | }
|
221 | type ScalarType = 'ID' | 'String' | 'Int' | 'Float' | 'AWSDate' | 'AWSTime' | 'AWSDateTime' | 'AWSTimestamp' | 'AWSEmail' | 'AWSURL' | 'AWSIPAddress' | 'Boolean' | 'AWSJSON' | 'AWSPhone';
|
222 | type FieldType = ScalarType | EnumType | ModelFieldType | NonModelFieldType;
|
223 | type InputFieldType = ScalarType | EnumType | InputType;
|
224 | export type FieldAttribute = ModelAttribute;
|
225 |
|
226 |
|
227 |
|
228 | export declare enum CodeGenConnectionType {
|
229 | HAS_ONE = "HAS_ONE",
|
230 | BELONGS_TO = "BELONGS_TO",
|
231 | HAS_MANY = "HAS_MANY"
|
232 | }
|
233 | export interface AssociationBaseType {
|
234 | connectionType: CodeGenConnectionType;
|
235 | }
|
236 | export type AssociationHasMany = AssociationBaseType & {
|
237 | connectionType: CodeGenConnectionType.HAS_MANY;
|
238 | associatedWith: string[];
|
239 | };
|
240 | export type AssociationHasOne = AssociationBaseType & {
|
241 | connectionType: CodeGenConnectionType.HAS_ONE;
|
242 | associatedWith: string[];
|
243 | targetNames: string[];
|
244 | };
|
245 | export type AssociationBelongsTo = AssociationBaseType & {
|
246 | connectionType: CodeGenConnectionType.BELONGS_TO;
|
247 | targetNames: string[];
|
248 | };
|
249 | export type AssociationType = AssociationHasMany | AssociationHasOne | AssociationBelongsTo;
|
250 | export interface PrimaryKeyInfo {
|
251 | isCustomPrimaryKey: boolean;
|
252 | primaryKeyFieldName: string;
|
253 | sortKeyFieldNames: string[];
|
254 | }
|
255 | export {};
|