@graphql-mesh/openapi 1.0.0-alpha-20220804093904-8e2e41f7f → 1.0.0-alpha-20230420181317-a95037648

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,122 +0,0 @@
1
- /**
2
- * Type definitions for the objects created during preprocessing for every
3
- * operation in the OAS.
4
- */
5
- import { Oas3, LinkObject, ParameterObject, ServerObject, SchemaObject } from './oas3';
6
- import { GraphQLOperationType } from './graphql';
7
- import { GraphQLScalarType, GraphQLObjectType, GraphQLInputObjectType, GraphQLList, GraphQLEnumType, GraphQLUnionType } from 'graphql';
8
- import { HTTP_METHODS } from '../oas_3_tools';
9
- export declare type DataDefinition = {
10
- preferredName: string;
11
- schema: SchemaObject;
12
- /**
13
- * Similar to the required property in object schemas but because of certain
14
- * keywords to combine schemas, e.g. "allOf", this resolves the required
15
- * property in all member schemas
16
- */
17
- required: string[];
18
- targetGraphQLType: string;
19
- links: {
20
- [key: string]: LinkObject;
21
- };
22
- /**
23
- * Data definitions of subschemas in the schema
24
- *
25
- * I.e. If the dataDef is a list type, the subDefinition is a reference to the
26
- * list item type
27
- *
28
- * Or if the dataDef is an object type, the subDefinitions are references to
29
- * the field types
30
- *
31
- * Or if the dataDef is a union type, the subDefinitions are references to
32
- * the member types
33
- */
34
- subDefinitions: DataDefinition | {
35
- [fieldName: string]: DataDefinition;
36
- } | DataDefinition[];
37
- graphQLTypeName: string;
38
- graphQLInputObjectTypeName: string;
39
- graphQLType?: GraphQLObjectType | GraphQLList<any> | GraphQLUnionType | GraphQLEnumType | GraphQLScalarType;
40
- graphQLInputObjectType?: GraphQLInputObjectType | GraphQLList<any>;
41
- };
42
- export declare type Operation = {
43
- /**
44
- * Identifier of the operation - may be created by concatenating method & path
45
- */
46
- operationId: string;
47
- /**
48
- * A combination of the operation method and path (and the title of the OAS
49
- * where the operation originates from if multiple OASs are provided) in the
50
- * form of:
51
- *
52
- * {title of OAS (if applicable)} {method in ALL_CAPS} {path}
53
- *
54
- * Used for documentation and logging
55
- */
56
- operationString: string;
57
- /**
58
- * Human-readable description of the operation
59
- */
60
- description: string;
61
- /**
62
- * URL path of this operation
63
- */
64
- path: string;
65
- /**
66
- * HTTP method for this operation
67
- */
68
- method: HTTP_METHODS;
69
- /**
70
- * Content-type of the request payload
71
- */
72
- payloadContentType?: string;
73
- /**
74
- * Information about the request payload (if any)
75
- */
76
- payloadDefinition?: DataDefinition;
77
- /**
78
- * Determines wheter request payload is required for the request
79
- */
80
- payloadRequired: boolean;
81
- /**
82
- * Content-type of the request payload
83
- */
84
- responseContentType?: string;
85
- /**
86
- * Information about the response payload
87
- */
88
- responseDefinition: DataDefinition;
89
- /**
90
- * List of parameters of the operation
91
- */
92
- parameters: ParameterObject[];
93
- /**
94
- * List of keys of security schemes required by this operation
95
- *
96
- * NOTE: Keys are sanitized
97
- * NOTE: Does not contain OAuth 2.0-related security schemes
98
- */
99
- securityRequirements: string[];
100
- /**
101
- * (Local) server definitions of the operation.
102
- */
103
- servers: ServerObject[];
104
- /**
105
- * Whether this operation should be placed in an authentication viewer
106
- * (cannot be true if "viewer" option passed to OpenAPI-to-GraphQL is false).
107
- */
108
- inViewer: boolean;
109
- /**
110
- * Type of root operation type, i.e. whether the generated field should be
111
- * added to the Query, Mutation, or Subscription root operation
112
- */
113
- operationType: GraphQLOperationType;
114
- /**
115
- * The success HTTP code, 200-299, destined to become a GraphQL object type
116
- */
117
- statusCode: string;
118
- /**
119
- * The OAS which this operation originated from
120
- */
121
- oas: Oas3;
122
- };
@@ -1,251 +0,0 @@
1
- import { GraphQLOperationType, SubscriptionContext } from './graphql';
2
- import { GraphQLFieldResolver, GraphQLResolveInfo } from 'graphql';
3
- import { ResolverMiddleware } from '../resolver_builder';
4
- import { Logger, MeshPubSub } from '@graphql-mesh/types';
5
- /**
6
- * Type definition of the options that users can pass to OpenAPI-to-GraphQL.
7
- */
8
- export declare type Warning = {
9
- type: string;
10
- message: string;
11
- mitigation: string;
12
- path?: string[];
13
- };
14
- export declare type Report = {
15
- warnings: Warning[];
16
- numOps: number;
17
- numOpsQuery: number;
18
- numOpsMutation: number;
19
- numOpsSubscription: number;
20
- numQueriesCreated: number;
21
- numMutationsCreated: number;
22
- numSubscriptionsCreated: number;
23
- };
24
- export declare type ConnectOptions = {
25
- [key: string]: boolean | number | string;
26
- };
27
- export declare type OasTitlePathMethodObject<T> = {
28
- [title: string]: {
29
- [path: string]: {
30
- [method: string]: T;
31
- };
32
- };
33
- };
34
- export declare type Headers = {
35
- [key: string]: string;
36
- };
37
- /**
38
- * Given a set parameters corresponding to a specific operation in the OAS,
39
- * provide the appropriate headers
40
- */
41
- export declare type RequestHeadersFunction<TSource, TContext, TArgs> = (method: string, path: string, title: string, resolverParams?: {
42
- source: TSource;
43
- args: TArgs;
44
- context: TContext;
45
- info: GraphQLResolveInfo;
46
- }) => Headers;
47
- export declare type RequestOptions<TSource, TContext, TArgs> = RequestInit;
48
- export declare type Options<TSource, TContext, TArgs> = Partial<InternalOptions<TSource, TContext, TArgs>>;
49
- export declare type InternalOptions<TSource, TContext, TArgs> = {
50
- strict: boolean;
51
- /**
52
- * Holds information about the GraphQL schema generation process
53
- */
54
- report: Report;
55
- /**
56
- * Field names can only be sanitized operationIds
57
- *
58
- * By default, query field names are based on the return type type name and
59
- * mutation field names are based on the operationId, which may be generated
60
- * if it does not exist.
61
- *
62
- * This option forces OpenAPI-to-GraphQL to only create field names based on the
63
- * operationId.
64
- */
65
- operationIdFieldNames: boolean;
66
- /**
67
- * Under certain circumstances (such as response code 204), some RESTful
68
- * operations should not return any data. However, GraphQL objects must have
69
- * a data structure. Normally, these operations would be ignored but for the
70
- * sake of completeness, the following option will give these operations a
71
- * placeholder data structure. Even though the data structure will not have
72
- * any practical use, at least the operations will show up in the schema.
73
- */
74
- fillEmptyResponses: boolean;
75
- /**
76
- * Auto-generate a 'limit' argument for all fields that return lists of
77
- * objects, including ones produced by links
78
- *
79
- * Allows to constrain the return size of lists of objects
80
- *
81
- * Returns the first n number of elements in the list
82
- */
83
- addLimitArgument: boolean;
84
- /**
85
- * If a schema is of type string and has format UUID, it will be translated
86
- * into a GraphQL ID type. To allow for more customzation, this option allows
87
- * users to specify other formats that should be interpreted as ID types.
88
- */
89
- idFormats?: string[];
90
- /**
91
- * Allows to define the root operation type (Query or Mutation type) of any
92
- * OAS operation explicitly.
93
- *
94
- * OpenAPI-to-GraphQL will by default make all GET operations Query fields and all other
95
- * operations into Mutation fields.
96
- *
97
- * The field is identifed first by the title of the OAS, then the path of the
98
- * operation, and lastly the method of the operation.
99
- */
100
- selectQueryOrMutationField?: OasTitlePathMethodObject<GraphQLOperationType>;
101
- /**
102
- * Sets argument name for the payload of a mutation to 'requestBody'
103
- */
104
- genericPayloadArgName: boolean;
105
- /**
106
- * By default, field names are sanitized to conform with GraphQL conventions,
107
- * i.e. types should be in PascalCase, fields should be in camelCase, and
108
- * enum values should be in ALL_CAPS.
109
- *
110
- * This option will prevent OpenAPI-to-GraphQL from enforcing camelCase field names and
111
- * PascalCase type names, only removing illegal characters and staying as true
112
- * to the provided names in the OAS as possible.
113
- */
114
- simpleNames: boolean;
115
- /**
116
- * Experimental feature that will try to create more meaningful names from
117
- * the operation path than the response object by leveraging common
118
- * conventions.
119
- *
120
- * For example, given the operation 'GET /users/{userId}/car', OpenAPI-to-GraphQL will
121
- * create a Query field 'userCar'. Note that because 'users' is followed by
122
- * the parameter 'userId', it insinuates that this operation will get the car
123
- * that belongs to a singular user. Hence, the name 'userCar' is more fitting
124
- * than 'usersCar' so the pluralizing 's' is dropped.
125
- *
126
- * This option will also consider irregular plural forms.
127
- */
128
- singularNames: boolean;
129
- /**
130
- * Custom headers to send with every request made by a resolve function.
131
- */
132
- headers?: Headers | RequestHeadersFunction<TSource, TContext, TArgs>;
133
- /**
134
- * Custom query parameters to send with every reqeust by a resolve function.
135
- */
136
- qs?: {
137
- [key: string]: string;
138
- };
139
- /**
140
- * Allows to override or add options to the node's request object used to make
141
- * calls to the API backend.
142
- * e.g. Setup the web proxy to use.
143
- */
144
- requestOptions?: RequestOptions<TSource, TContext, TArgs>;
145
- /**
146
- * Allows to override or add options to the PubSub connect object used to make
147
- * publish/subscribe to the API backend.
148
- * e.g. Setup the web proxy to use.
149
- */
150
- connectOptions?: ConnectOptions;
151
- /**
152
- * Specifies the URL on which all paths will be based on.
153
- * Overrides the server object in the OAS.
154
- */
155
- baseUrl?: string;
156
- /**
157
- * Allows to define custom resolvers for fields on the Query/Mutation root
158
- * operation type.
159
- *
160
- * In other words, instead of resolving on an operation (REST call) defined in
161
- * the OAS, the field will resolve on the custom resolver. Note that this will
162
- * also affect the behavior of links.
163
- *
164
- * The field is identifed first by the title of the OAS, then the path of the
165
- * operation, and lastly the method of the operation.
166
- *
167
- * Use cases include the resolution of complex relationships between types,
168
- * implementing performance improvements like caching, or dealing with
169
- * non-standard authentication requirements.
170
- */
171
- customResolvers?: OasTitlePathMethodObject<GraphQLFieldResolver<TSource, TContext, TArgs>>;
172
- /**
173
- * Allows to define custom resolvers and subscribe functions for fields on the
174
- * Subscription root operation type.
175
- *
176
- * In other words, instead of resolving on an operation (REST call) defined in
177
- * the OAS, the field will resolve on the custom resolver. Note that this will
178
- * also affect the behavior of links.
179
- *
180
- * The field is identifed first by the title of the OAS, then the path of the
181
- * operation, and lastly the method of the operation.
182
- *
183
- * Use cases include the resolution of complex relationships between types,
184
- * implementing performance improvements like caching, or dealing with
185
- * non-standard authentication requirements.
186
- *
187
- * Note: Subscription fields will only be generated if the
188
- * createSubscriptionsFromCallbacks option is enabled.
189
- */
190
- customSubscriptionResolvers?: OasTitlePathMethodObject<{
191
- subscribe: GraphQLFieldResolver<TSource, SubscriptionContext, TArgs>;
192
- resolve: GraphQLFieldResolver<TSource, TContext, TArgs>;
193
- }>;
194
- /**
195
- * Determines whether OpenAPI-to-GraphQL should create viewers that allow users to pass
196
- * basic auth and API key credentials.
197
- */
198
- viewer: boolean;
199
- /**
200
- * JSON path to OAuth 2 token contained in GraphQL context. Tokens will per
201
- * default be sent in "Authorization" header.
202
- */
203
- tokenJSONpath?: string;
204
- /**
205
- * Determines whether to send OAuth 2 token as query parameter instead of in
206
- * header.
207
- */
208
- sendOAuthTokenInQuery: boolean;
209
- /**
210
- * The error extensions is part of the GraphQLErrors that will be returned if
211
- * the query cannot be fulfilled. It provides information about the failed
212
- * REST call(e.g. the method, path, status code, response
213
- * headers, and response body). It can be useful for debugging but may
214
- * unintentionally leak information.
215
- *
216
- * This option prevents the extensions from being created.
217
- */
218
- provideErrorExtensions: boolean;
219
- /**
220
- * Appends a small statement to the end of field description that clarifies
221
- * the operation that the field will trigger.
222
- *
223
- * Will affect query and mutation fields as well as fields created from links
224
- *
225
- * In the form of: 'Equivalent to {title of OAS} {method in ALL_CAPS} {path}'
226
- * Will forgo the title is only one OAS is provided
227
- */
228
- equivalentToMessages: boolean;
229
- /**
230
- * Custom fetch implementation
231
- */
232
- fetch: typeof import('@whatwg-node/fetch').fetch;
233
- /**
234
- * Middlewares for Resolver Factory
235
- */
236
- resolverMiddleware: ResolverMiddleware<TSource, TContext, TArgs>;
237
- /**
238
- * Includes HTTP Details to the result object
239
- */
240
- includeHttpDetails?: boolean;
241
- pubsub: MeshPubSub;
242
- logger: Logger;
243
- /**
244
- * Allow processing to continue if the swagger schema is missing a schema $ref.
245
- */
246
- allowUndefinedSchemaRefTags?: boolean;
247
- /**
248
- * Object type to use for missing swagger schemas refs default is object.
249
- */
250
- defaultUndefinedSchemaType?: 'string' | 'number' | 'object' | 'array' | 'boolean' | 'integer';
251
- };
@@ -1,71 +0,0 @@
1
- /**
2
- * Type definitions for the data created during preprocessing.
3
- */
4
- import { Operation, DataDefinition } from './operation';
5
- import { InternalOptions } from './options';
6
- import { SecuritySchemeObject, SchemaObject, Oas3 } from './oas3';
7
- export declare type ProcessedSecurityScheme = {
8
- rawName: string;
9
- def: SecuritySchemeObject;
10
- /**
11
- * Stores the names of the authentication credentials
12
- * NOTE: Structure depends on the type of the protocol (basic, API key...)
13
- * NOTE: Mainly used for the AnyAuth viewers
14
- */
15
- parameters: {
16
- [key: string]: string;
17
- };
18
- /**
19
- * JSON schema to create the viewer for this security scheme from.
20
- */
21
- schema: SchemaObject;
22
- /**
23
- * The OAS which this operation originated from
24
- */
25
- oas: Oas3;
26
- };
27
- export declare type PreprocessingData<TSource, TContext, TArgs> = {
28
- /**
29
- * List of operation objects
30
- */
31
- operations: {
32
- [key: string]: Operation;
33
- };
34
- /**
35
- * List of Operation objects
36
- */
37
- callbackOperations: {
38
- [key: string]: Operation;
39
- };
40
- /**
41
- * List of all the used object names to avoid collision
42
- */
43
- usedTypeNames: string[];
44
- /**
45
- * List of data definitions for JSON schemas already used.
46
- */
47
- defs: DataDefinition[];
48
- /**
49
- * The security definitions contained in the OAS. References are resolved.
50
- *
51
- * NOTE: Keys are sanitized
52
- * NOTE: Does not contain OAuth 2.0-related security schemes
53
- */
54
- security: {
55
- [key: string]: ProcessedSecurityScheme;
56
- };
57
- /**
58
- * Mapping between sanitized strings and their original ones
59
- */
60
- saneMap: {
61
- [key: string]: string;
62
- };
63
- /**
64
- * Options passed to OpenAPI-to-GraphQL by the user
65
- */
66
- options: InternalOptions<TSource, TContext, TArgs>;
67
- /**
68
- * All of the provided OASs
69
- */
70
- oass: Oas3[];
71
- };
@@ -1,61 +0,0 @@
1
- import { PreprocessingData, ProcessedSecurityScheme } from './types/preprocessing_data';
2
- import { Logger } from '@graphql-mesh/types';
3
- export declare enum MitigationTypes {
4
- /**
5
- * Problems with the OAS
6
- *
7
- * Should be caught by the module oas-validator
8
- */
9
- INVALID_OAS = "INVALID_OAS",
10
- UNNAMED_PARAMETER = "UNNAMED_PARAMETER",
11
- AMBIGUOUS_UNION_MEMBERS = "AMBIGUOUS_UNION_MEMBERS",
12
- CANNOT_GET_FIELD_TYPE = "CANNOT_GET_FIELD_TYPE",
13
- COMBINE_SCHEMAS = "COMBINE_SCHEMAS",
14
- DUPLICATE_FIELD_NAME = "DUPLICATE_FIELD_NAME",
15
- DUPLICATE_LINK_KEY = "DUPLICATE_LINK_KEY",
16
- INVALID_HTTP_METHOD = "INVALID_HTTP_METHOD",
17
- INPUT_UNION = "INPUT_UNION",
18
- MISSING_RESPONSE_SCHEMA = "MISSING_RESPONSE_SCHEMA",
19
- MISSING_SCHEMA = "MISSING_SCHEMA",
20
- MULTIPLE_RESPONSES = "MULTIPLE_RESPONSES",
21
- NON_APPLICATION_JSON_SCHEMA = "NON_APPLICATION_JSON_SCHEMA",
22
- OBJECT_MISSING_PROPERTIES = "OBJECT_MISSING_PROPERTIES",
23
- UNKNOWN_TARGET_TYPE = "UNKNOWN_TARGET_TYPE",
24
- UNRESOLVABLE_SCHEMA = "UNRESOLVABLE_SCHEMA",
25
- UNSUPPORTED_HTTP_SECURITY_SCHEME = "UNSUPPORTED_HTTP_SECURITY_SCHEME",
26
- UNSUPPORTED_JSON_SCHEMA_KEYWORD = "UNSUPPORTED_JSON_SCHEMA_KEYWORD",
27
- CALLBACKS_MULTIPLE_OPERATION_OBJECTS = "CALLBACKS_MULTIPLE_OPERATION_OBJECTS",
28
- AMBIGUOUS_LINK = "AMBIGUOUS_LINK",
29
- LINK_NAME_COLLISION = "LINK_NAME_COLLISION",
30
- UNRESOLVABLE_LINK = "UNRESOLVABLE_LINK",
31
- DUPLICATE_OPERATIONID = "DUPLICATE_OPERATIONID",
32
- DUPLICATE_SECURITY_SCHEME = "DUPLICATE_SECURITY_SCHEME",
33
- MULTIPLE_OAS_SAME_TITLE = "MULTIPLE_OAS_SAME_TITLE",
34
- CUSTOM_RESOLVER_UNKNOWN_OAS = "CUSTOM_RESOLVER_UNKNOWN_OAS",
35
- CUSTOM_RESOLVER_UNKNOWN_PATH_METHOD = "CUSTOM_RESOLVER_UNKNOWN_PATH_METHOD",
36
- LIMIT_ARGUMENT_NAME_COLLISION = "LIMIT_ARGUMENT_NAME_COLLISION",
37
- OAUTH_SECURITY_SCHEME = "OAUTH_SECURITY_SCHEME"
38
- }
39
- export declare const mitigations: {
40
- [mitigationType in MitigationTypes]: string;
41
- };
42
- /**
43
- * Utilities that are specific to OpenAPI-to-GraphQL
44
- */
45
- export declare function handleWarning<TSource, TContext, TArgs>({ mitigationType, message, mitigationAddendum, path, data, logger, }: {
46
- mitigationType: MitigationTypes;
47
- message: string;
48
- mitigationAddendum?: string;
49
- path?: string[];
50
- data: PreprocessingData<TSource, TContext, TArgs>;
51
- logger: Logger;
52
- }): void;
53
- export declare function sortObject<T>(o: T): T;
54
- /**
55
- * Finds the common property names between two objects
56
- */
57
- export declare function getCommonPropertyNames(object1: {
58
- [key: string]: ProcessedSecurityScheme;
59
- }, object2: {
60
- [key: string]: ProcessedSecurityScheme;
61
- }): (string | number)[];