@aws-amplify/api 5.4.6-api-v6-models.b3abc9b.0 → 6.0.0

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.
Files changed (52) hide show
  1. package/README.md +3 -0
  2. package/lib/.tsbuildinfo +3 -0
  3. package/lib/API.d.ts +3 -41
  4. package/lib/API.js +15 -131
  5. package/lib/API.js.map +1 -0
  6. package/lib/index.d.ts +4 -3
  7. package/lib/index.js +11 -6
  8. package/lib/index.js.map +1 -0
  9. package/lib/internals/InternalAPI.d.ts +4 -94
  10. package/lib/internals/InternalAPI.js +29 -144
  11. package/lib/internals/InternalAPI.js.map +1 -0
  12. package/lib/internals/index.js +3 -3
  13. package/lib/internals/index.js.map +1 -0
  14. package/lib/server.d.ts +14 -0
  15. package/lib/server.js +35 -0
  16. package/lib/server.js.map +1 -0
  17. package/lib/types/index.d.ts +1 -2
  18. package/lib/types/index.js +3 -4
  19. package/lib/types/index.js.map +1 -0
  20. package/lib-esm/.tsbuildinfo +3 -0
  21. package/lib-esm/API.d.ts +3 -41
  22. package/lib-esm/API.js +14 -130
  23. package/lib-esm/API.js.map +1 -0
  24. package/lib-esm/index.d.ts +4 -3
  25. package/lib-esm/index.js +4 -2
  26. package/lib-esm/index.js.map +1 -0
  27. package/lib-esm/internals/InternalAPI.d.ts +4 -94
  28. package/lib-esm/internals/InternalAPI.js +28 -143
  29. package/lib-esm/internals/InternalAPI.js.map +1 -0
  30. package/lib-esm/internals/index.js +1 -0
  31. package/lib-esm/internals/index.js.map +1 -0
  32. package/lib-esm/server.d.ts +14 -0
  33. package/lib-esm/server.js +25 -0
  34. package/lib-esm/server.js.map +1 -0
  35. package/lib-esm/types/index.d.ts +1 -2
  36. package/lib-esm/types/index.js +2 -1
  37. package/lib-esm/types/index.js.map +1 -0
  38. package/package.json +12 -32
  39. package/server/package.json +8 -0
  40. package/src/API.ts +16 -200
  41. package/src/index.ts +18 -6
  42. package/src/internals/InternalAPI.ts +15 -194
  43. package/src/server.ts +59 -0
  44. package/src/types/index.ts +0 -2
  45. package/index.v37.d.ts +0 -12
  46. package/lib/APIClient.d.ts +0 -55
  47. package/lib/APIClient.js +0 -404
  48. package/lib/tsconfig.build.tsbuildinfo +0 -1
  49. package/lib-esm/APIClient.d.ts +0 -55
  50. package/lib-esm/APIClient.js +0 -393
  51. package/lib-esm/tsconfig.build.tsbuildinfo +0 -1
  52. package/src/APIClient.ts +0 -534
package/package.json CHANGED
@@ -1,17 +1,10 @@
1
1
  {
2
2
  "name": "@aws-amplify/api",
3
- "version": "5.4.6-api-v6-models.b3abc9b.0+b3abc9b",
3
+ "version": "6.0.0",
4
4
  "description": "Api category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
7
7
  "typings": "./lib-esm/index.d.ts",
8
- "typesVersions": {
9
- "<3.8": {
10
- "lib-esm/index.d.ts": [
11
- "index.v37.d.ts"
12
- ]
13
- }
14
- },
15
8
  "react-native": {
16
9
  "./lib/index": "./lib-esm/index.js"
17
10
  },
@@ -24,18 +17,17 @@
24
17
  },
25
18
  "scripts": {
26
19
  "test": "npm run lint && jest -w 1 --coverage",
27
- "test:size": "size-limit",
28
20
  "build-with-test": "npm test && npm run build",
29
- "build:cjs": "rimraf lib && tsc -p ./tsconfig.build.json -m commonjs --outDir lib && webpack && webpack --config ./webpack.config.dev.js",
30
- "build:esm": "rimraf lib-esm && tsc -p ./tsconfig.build.json -m esnext --outDir lib-esm",
31
- "build:cjs:watch": "rimraf lib && tsc -p ./tsconfig.build.json -m commonjs --outDir lib --watch",
32
- "build:esm:watch": "rimraf lib-esm && tsc -p ./tsconfig.build.json -m esnext --outDir lib-esm --watch",
21
+ "build:cjs": "node ./build es5 && webpack && webpack --config ./webpack.config.dev.js",
22
+ "build:esm": "node ./build es6",
23
+ "build:cjs:watch": "node ./build es5 --watch",
24
+ "build:esm:watch": "node ./build es6 --watch",
33
25
  "build": "npm run clean && npm run build:esm && npm run build:cjs",
34
26
  "clean": "npm run clean:size && rimraf lib-esm lib dist",
35
27
  "clean:size": "rimraf dual-publish-tmp tmp*",
36
28
  "format": "echo \"Not implemented\"",
37
29
  "lint": "tslint 'src/**/*.ts' && npm run ts-coverage",
38
- "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 75"
30
+ "ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88"
39
31
  },
40
32
  "repository": {
41
33
  "type": "git",
@@ -48,7 +40,6 @@
48
40
  },
49
41
  "homepage": "https://aws-amplify.github.io/",
50
42
  "devDependencies": {
51
- "@types/zen-observable": "^0.8.0",
52
43
  "typescript": "5.1.6"
53
44
  },
54
45
  "files": [
@@ -56,22 +47,14 @@
56
47
  "lib-esm",
57
48
  "src",
58
49
  "index.*.d.ts",
59
- "internals"
50
+ "internals",
51
+ "server"
60
52
  ],
61
53
  "dependencies": {
62
- "@aws-amplify/amplify-api-next-types-alpha": "^0.1.2",
63
- "@aws-amplify/api-graphql": "3.4.12-api-v6-models.b3abc9b.0+b3abc9b",
64
- "@aws-amplify/api-rest": "3.5.6-api-v6-models.b3abc9b.0+b3abc9b",
65
- "tslib": "^2.6.1"
54
+ "@aws-amplify/api-graphql": "4.0.0",
55
+ "@aws-amplify/api-rest": "4.0.0",
56
+ "tslib": "^2.5.0"
66
57
  },
67
- "size-limit": [
68
- {
69
- "name": "API (top-level class)",
70
- "path": "./lib-esm/index.js",
71
- "import": "{ Amplify, API }",
72
- "limit": "93.82 kB"
73
- }
74
- ],
75
58
  "jest": {
76
59
  "globals": {
77
60
  "ts-jest": {
@@ -92,9 +75,6 @@
92
75
  "^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
93
76
  },
94
77
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
95
- "testPathIgnorePatterns": [
96
- "assets"
97
- ],
98
78
  "moduleFileExtensions": [
99
79
  "ts",
100
80
  "tsx",
@@ -119,5 +99,5 @@
119
99
  "lib-esm"
120
100
  ]
121
101
  },
122
- "gitHead": "b3abc9b75f6f1353f4c2fbc10cd3369be498e9fc"
102
+ "gitHead": "d505105326d7f6214f6bd1e06eb20be3a3651377"
123
103
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@aws-amplify/api/server",
3
+ "types": "../lib-esm/server.d.ts",
4
+ "main": "../lib/server.js",
5
+ "module": "../lib-esm/server.js",
6
+ "react-native": "../lib-esm/server.js",
7
+ "sideEffects": false
8
+ }
package/src/API.ts CHANGED
@@ -1,207 +1,23 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
3
+ import { __amplify, V6Client } from '@aws-amplify/api-graphql';
4
4
  import {
5
- GraphQLOptions,
6
- GraphQLResult,
7
- GraphQLQuery,
8
- GraphQLSubscription,
9
- } from '@aws-amplify/api-graphql';
10
- import { graphql as v6graphql } from '@aws-amplify/api-graphql/internals';
11
- import { Amplify, ConsoleLogger as Logger } from '@aws-amplify/core';
12
- import Observable from 'zen-observable-ts';
13
- import { InternalAPIClass } from './internals/InternalAPI';
14
- import {
15
- initializeModel,
16
- generateGraphQLDocument,
17
- buildGraphQLVariables,
18
- graphQLOperationsInfo,
19
- ModelOperation,
20
- flattenItems,
21
- } from './APIClient';
22
- import type { ModelTypes } from '@aws-amplify/amplify-api-next-types-alpha';
5
+ graphql as v6graphql,
6
+ cancel as v6cancel,
7
+ isCancelError as v6isCancelError,
8
+ } from '@aws-amplify/api-graphql/internals';
9
+ import { Amplify } from '@aws-amplify/core';
23
10
 
24
- const logger = new Logger('API');
25
11
  /**
26
- * @deprecated
27
- * Use RestApi or GraphQLAPI to reduce your application bundle size
28
- * Export Cloud Logic APIs
12
+ * Generates an API client that can work with models or raw GraphQL
29
13
  */
30
-
31
- export class APIClass extends InternalAPIClass {
32
- public getModuleName() {
33
- return 'API';
34
- }
35
-
36
- /**
37
- * Executes a GraphQL operation
38
- *
39
- * @param options - GraphQL Options
40
- * @param [additionalHeaders] - headers to merge in after any `graphql_headers` set in the config
41
- * @returns An Observable if queryType is 'subscription', else a promise of the graphql result from the query.
42
- */
43
- graphql<T>(
44
- options: GraphQLOptions,
45
- additionalHeaders?: { [key: string]: string }
46
- ): T extends GraphQLQuery<T>
47
- ? Promise<GraphQLResult<T>>
48
- : T extends GraphQLSubscription<T>
49
- ? Observable<{
50
- provider: AWSAppSyncRealTimeProvider;
51
- value: GraphQLResult<T>;
52
- }>
53
- : Promise<GraphQLResult<any>> | Observable<object>;
54
- graphql<T = any>(
55
- options: GraphQLOptions,
56
- additionalHeaders?: { [key: string]: string }
57
- ): Promise<GraphQLResult<any>> | Observable<object> {
58
- return super.graphql(options, additionalHeaders);
59
- }
60
-
61
- /**
62
- * Generates an API client that can work with models or raw GraphQL
63
- */
64
- generateClient<T extends Record<any, any> = never>(): V6Client<T> {
65
- const config = super.configure({});
66
-
67
- const { modelIntrospection } = config;
68
-
69
- const client: V6Client<any> = {
70
- graphql: v6graphql,
71
- models: {},
72
- };
73
-
74
- // TODO: refactor this to use separate methods for each CRUDL.
75
- // Doesn't make sense to gen the methods dynamically given the different args and return values
76
- for (const model of Object.values(modelIntrospection.models)) {
77
- const { name } = model as any;
78
-
79
- client.models[name] = {} as any;
80
-
81
- Object.entries(graphQLOperationsInfo).forEach(
82
- ([key, { operationPrefix }]) => {
83
- const operation = key as ModelOperation;
84
-
85
- if (operation === 'LIST') {
86
- client.models[name][operationPrefix] = async (args?: any) => {
87
- const query = generateGraphQLDocument(
88
- modelIntrospection.models,
89
- name,
90
- 'LIST',
91
- args
92
- );
93
- const variables = buildGraphQLVariables(
94
- model,
95
- 'LIST',
96
- args,
97
- modelIntrospection
98
- );
99
-
100
- console.log('API list', query, variables);
101
-
102
- const res = (await this.graphql({
103
- query,
104
- variables,
105
- })) as any;
106
-
107
- // flatten response
108
- if (res.data !== undefined) {
109
- const [key] = Object.keys(res.data);
110
-
111
- if (res.data[key].items) {
112
- const flattenedResult = flattenItems(res.data)[key];
113
-
114
- // don't init if custom selection set
115
- if (args?.selectionSet) {
116
- return flattenedResult;
117
- } else {
118
- const initialized = initializeModel(
119
- client,
120
- name,
121
- flattenedResult,
122
- modelIntrospection
123
- );
124
-
125
- console.log('initialized', initialized);
126
-
127
- return initialized;
128
- }
129
- }
130
-
131
- return res.data[key];
132
- }
133
-
134
- return res as any;
135
- };
136
- } else {
137
- client.models[name][operationPrefix] = async (
138
- arg?: any,
139
- options?: any
140
- ) => {
141
- const query = generateGraphQLDocument(
142
- modelIntrospection.models,
143
- name,
144
- operation,
145
- options
146
- );
147
- const variables = buildGraphQLVariables(
148
- model,
149
- operation,
150
- arg,
151
- modelIntrospection
152
- );
153
-
154
- console.log(`API ${operationPrefix}`, query, variables);
155
-
156
- const res = (await this.graphql({
157
- query,
158
- variables,
159
- })) as any;
160
-
161
- // flatten response
162
- if (res.data !== undefined) {
163
- const [key] = Object.keys(res.data);
164
- const flattenedResult = flattenItems(res.data)[key];
165
-
166
- if (options?.selectionSet) {
167
- return flattenedResult;
168
- } else {
169
- // TODO: refactor to avoid destructuring here
170
- const [initialized] = initializeModel(
171
- client,
172
- name,
173
- [flattenedResult],
174
- modelIntrospection
175
- );
176
-
177
- return initialized;
178
- }
179
- }
180
-
181
- return res;
182
- };
183
- }
184
- }
185
- );
186
- }
187
-
188
- return client as V6Client<T>;
189
- }
14
+ export function generateClient<
15
+ T extends Record<any, any> = never
16
+ >(): V6Client<T> {
17
+ return {
18
+ [__amplify]: Amplify,
19
+ graphql: v6graphql,
20
+ cancel: v6cancel,
21
+ isCancelError: v6isCancelError,
22
+ };
190
23
  }
191
-
192
- type FilteredKeys<T> = {
193
- [P in keyof T]: T[P] extends never ? never : P;
194
- }[keyof T];
195
-
196
- type ExcludeNeverFields<O> = {
197
- [K in FilteredKeys<O>]: O[K];
198
- };
199
-
200
- // If no T is passed, ExcludeNeverFields removes "models" from the client
201
- declare type V6Client<T extends Record<any, any> = never> = ExcludeNeverFields<{
202
- graphql: typeof v6graphql;
203
- models: ModelTypes<T>;
204
- }>;
205
-
206
- export const API = new APIClass(null);
207
- Amplify.register(API);
package/src/index.ts CHANGED
@@ -1,12 +1,24 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ // TODO(v6): revisit exports
5
+
4
6
  export { GraphQLQuery, GraphQLSubscription } from './types';
5
- export { API, APIClass } from './API';
6
- export {
7
- graphqlOperation,
8
- GraphQLAuthError,
9
- GRAPHQL_AUTH_MODE,
7
+ export { generateClient } from './API';
8
+
9
+ export { GraphQLAuthError } from '@aws-amplify/api-graphql';
10
+
11
+ export type {
12
+ GraphQLResult,
13
+ GraphQLReturnType,
10
14
  } from '@aws-amplify/api-graphql';
11
15
 
12
- export type { GraphQLResult } from '@aws-amplify/api-graphql';
16
+ export {
17
+ get,
18
+ put,
19
+ post,
20
+ del,
21
+ head,
22
+ patch,
23
+ isCancelError,
24
+ } from '@aws-amplify/api-rest';
@@ -1,6 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import {
4
+ AWSAppSyncRealTimeProvider,
4
5
  GraphQLOperation,
5
6
  GraphQLOptions,
6
7
  GraphQLResult,
@@ -9,21 +10,24 @@ import {
9
10
  GraphQLSubscription,
10
11
  } from '@aws-amplify/api-graphql';
11
12
  import { InternalGraphQLAPIClass } from '@aws-amplify/api-graphql/internals';
12
- import { RestAPIClass } from '@aws-amplify/api-rest';
13
- import { Auth } from '@aws-amplify/auth';
14
- import { Cache } from '@aws-amplify/cache';
13
+ import { Amplify, Cache, ConsoleLogger } from '@aws-amplify/core';
15
14
  import {
16
- Amplify,
17
15
  ApiAction,
18
16
  Category,
19
- Credentials,
20
17
  CustomUserAgentDetails,
21
- ConsoleLogger as Logger,
22
- } from '@aws-amplify/core';
23
- import { AWSAppSyncRealTimeProvider } from '@aws-amplify/pubsub';
24
- import Observable from 'zen-observable-ts';
18
+ } from '@aws-amplify/core/internals/utils';
19
+ import { Observable } from 'rxjs';
25
20
 
26
- const logger = new Logger('API');
21
+ /**
22
+ * NOTE!
23
+ *
24
+ * This is used only by DataStore.
25
+ *
26
+ * This can probably be pruned and/or removed. Just leaving it as much of the same
27
+ * state as possible for V6 to reduce number of potentially impactful changes to DataStore.
28
+ */
29
+
30
+ const logger = new ConsoleLogger('API');
27
31
  /**
28
32
  * @deprecated
29
33
  * Use RestApi or GraphQLAPI to reduce your application bundle size
@@ -35,12 +39,9 @@ export class InternalAPIClass {
35
39
  * @param {Object} options - Configuration object for API
36
40
  */
37
41
  private _options;
38
- private _restApi: RestAPIClass;
39
42
  private _graphqlApi: InternalGraphQLAPIClass;
40
43
 
41
- Auth = Auth;
42
44
  Cache = Cache;
43
- Credentials = Credentials;
44
45
 
45
46
  /**
46
47
  * Initialize API with AWS configuration
@@ -48,7 +49,6 @@ export class InternalAPIClass {
48
49
  */
49
50
  constructor(options) {
50
51
  this._options = options;
51
- this._restApi = new RestAPIClass(options);
52
52
  this._graphqlApi = new InternalGraphQLAPIClass(options);
53
53
  logger.debug('API Options', this._options);
54
54
  }
@@ -57,185 +57,6 @@ export class InternalAPIClass {
57
57
  return 'InternalAPI';
58
58
  }
59
59
 
60
- /**
61
- * Configure API part with aws configurations
62
- * @param {Object} config - Configuration of the API
63
- * @return {Object} - The current configuration
64
- */
65
- configure(options) {
66
- this._options = Object.assign({}, this._options, options);
67
-
68
- // Share Amplify instance with client for SSR
69
- this._restApi.Credentials = this.Credentials;
70
-
71
- this._graphqlApi.Auth = this.Auth;
72
- this._graphqlApi.Cache = this.Cache;
73
- this._graphqlApi.Credentials = this.Credentials;
74
-
75
- const restAPIConfig = this._restApi.configure(this._options);
76
- const graphQLAPIConfig = this._graphqlApi.configure(this._options);
77
-
78
- return { ...restAPIConfig, ...graphQLAPIConfig };
79
- }
80
-
81
- /**
82
- * Make a GET request
83
- * @param apiName - The api name of the request
84
- * @param path - The path of the request
85
- * @param [init] - Request extra params
86
- * @return A promise that resolves to an object with response status and JSON data, if successful.
87
- */
88
- get(
89
- apiName: string,
90
- path: string,
91
- init: { [key: string]: any }
92
- ): Promise<any> {
93
- return this._restApi.get(
94
- apiName,
95
- path,
96
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Get)
97
- );
98
- }
99
-
100
- /**
101
- * Make a POST request
102
- * @param apiName - The api name of the request
103
- * @param path - The path of the request
104
- * @param [init] - Request extra params
105
- * @return A promise that resolves to an object with response status and JSON data, if successful.
106
- */
107
- post(
108
- apiName: string,
109
- path: string,
110
- init: { [key: string]: any }
111
- ): Promise<any> {
112
- return this._restApi.post(
113
- apiName,
114
- path,
115
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Post)
116
- );
117
- }
118
-
119
- /**
120
- * Make a PUT request
121
- * @param apiName - The api name of the request
122
- * @param path - The path of the request
123
- * @param [init] - Request extra params
124
- * @return A promise that resolves to an object with response status and JSON data, if successful.
125
- */
126
- put(
127
- apiName: string,
128
- path: string,
129
- init: { [key: string]: any }
130
- ): Promise<any> {
131
- return this._restApi.put(
132
- apiName,
133
- path,
134
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Put)
135
- );
136
- }
137
-
138
- /**
139
- * Make a PATCH request
140
- * @param apiName - The api name of the request
141
- * @param path - The path of the request
142
- * @param [init] - Request extra params
143
- * @return A promise that resolves to an object with response status and JSON data, if successful.
144
- */
145
- patch(
146
- apiName: string,
147
- path: string,
148
- init: { [key: string]: any }
149
- ): Promise<any> {
150
- return this._restApi.patch(
151
- apiName,
152
- path,
153
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Patch)
154
- );
155
- }
156
-
157
- /**
158
- * Make a DEL request
159
- * @param apiName - The api name of the request
160
- * @param path - The path of the request
161
- * @param [init] - Request extra params
162
- * @return A promise that resolves to an object with response status and JSON data, if successful.
163
- */
164
- del(
165
- apiName: string,
166
- path: string,
167
- init: { [key: string]: any }
168
- ): Promise<any> {
169
- return this._restApi.del(
170
- apiName,
171
- path,
172
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Del)
173
- );
174
- }
175
-
176
- /**
177
- * Make a HEAD request
178
- * @param apiName - The api name of the request
179
- * @param path - The path of the request
180
- * @param [init] - Request extra params
181
- * @return A promise that resolves to an object with response status and JSON data, if successful.
182
- */
183
- head(
184
- apiName: string,
185
- path: string,
186
- init: { [key: string]: any }
187
- ): Promise<any> {
188
- return this._restApi.head(
189
- apiName,
190
- path,
191
- this.getInitWithCustomUserAgentDetails(init, ApiAction.Head)
192
- );
193
- }
194
-
195
- /**
196
- * Checks to see if an error thrown is from an api request cancellation
197
- * @param error - Any error
198
- * @return If the error was from an api request cancellation
199
- */
200
- isCancel(error: any): boolean {
201
- return this._restApi.isCancel(error);
202
- }
203
- /**
204
- * Cancels an inflight request for either a GraphQL request or a Rest API request.
205
- * @param request - request to cancel
206
- * @param [message] - custom error message
207
- * @return If the request was cancelled
208
- */
209
- cancel(request: Promise<any>, message?: string): boolean {
210
- if (this._restApi.hasCancelToken(request)) {
211
- return this._restApi.cancel(request, message);
212
- } else if (this._graphqlApi.hasCancelToken(request)) {
213
- return this._graphqlApi.cancel(request, message);
214
- }
215
- return false;
216
- }
217
-
218
- private getInitWithCustomUserAgentDetails(
219
- init: { [key: string]: any },
220
- action: ApiAction
221
- ) {
222
- const customUserAgentDetails: CustomUserAgentDetails = {
223
- category: Category.API,
224
- action,
225
- };
226
- const initParams = { ...init, customUserAgentDetails };
227
- return initParams;
228
- }
229
-
230
- /**
231
- * Getting endpoint for API
232
- * @param apiName - The name of the api
233
- * @return The endpoint of the api
234
- */
235
- async endpoint(apiName: string): Promise<string> {
236
- return this._restApi.endpoint(apiName);
237
- }
238
-
239
60
  /**
240
61
  * to get the operation type
241
62
  * @param operation
@@ -275,6 +96,7 @@ export class InternalAPIClass {
275
96
  };
276
97
 
277
98
  return this._graphqlApi.graphql(
99
+ Amplify,
278
100
  options,
279
101
  additionalHeaders,
280
102
  apiUserAgentDetails
@@ -283,4 +105,3 @@ export class InternalAPIClass {
283
105
  }
284
106
 
285
107
  export const InternalAPI = new InternalAPIClass(null);
286
- Amplify.register(InternalAPI);
package/src/server.ts ADDED
@@ -0,0 +1,59 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { GraphQLQuery, GraphQLSubscription } from './types';
5
+ import {
6
+ graphql,
7
+ cancel,
8
+ isCancelError,
9
+ } from '@aws-amplify/api-graphql/internals';
10
+ import {
11
+ AmplifyServer,
12
+ getAmplifyServerContext,
13
+ } from '@aws-amplify/core/internals/adapter-core';
14
+
15
+ import {
16
+ __amplify,
17
+ V6Client,
18
+ V6ClientSSR,
19
+ ServerClientGenerationParams,
20
+ } from '@aws-amplify/api-graphql';
21
+
22
+ export type {
23
+ GraphQLResult,
24
+ GraphQLReturnType,
25
+ } from '@aws-amplify/api-graphql';
26
+
27
+ /**
28
+ * @private
29
+ *
30
+ * Creates a client that can be used to make GraphQL requests, using a provided `AmplifyClassV6`
31
+ * compatible context object for config and auth fetching.
32
+ *
33
+ * @param params
34
+ * @returns
35
+ */
36
+ export function generateClient<
37
+ T extends Record<any, any> = never,
38
+ ClientType extends V6ClientSSR<T> | V6Client<T> = V6ClientSSR<T>
39
+ >(params: ServerClientGenerationParams): ClientType {
40
+ const client = {
41
+ [__amplify]: params.amplify,
42
+ graphql,
43
+ cancel,
44
+ isCancelError,
45
+ models: {},
46
+ } as any;
47
+
48
+ return client as ClientType;
49
+ }
50
+
51
+ export {
52
+ get,
53
+ put,
54
+ post,
55
+ del,
56
+ head,
57
+ patch,
58
+ isCancelError,
59
+ } from '@aws-amplify/api-rest/server';
@@ -10,8 +10,6 @@ export {
10
10
  graphqlOperation,
11
11
  GraphQLAuthError,
12
12
  GraphQLResult,
13
- GRAPHQL_AUTH_MODE,
14
13
  GraphQLQuery,
15
14
  GraphQLSubscription,
16
15
  } from '@aws-amplify/api-graphql';
17
- export { SelectionSet } from '@aws-amplify/amplify-api-next-types-alpha';
package/index.v37.d.ts DELETED
@@ -1,12 +0,0 @@
1
- // the original ts3.7 version declaration file, used by "typesVersions" field in package.json
2
- // https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#file-redirects
3
- // can consider using third-party tool like downlevel-dts in the build process to automate this.
4
- import { API } from './lib-esm/API';
5
- export { API, APIClass } from './lib-esm/API';
6
- export {
7
- graphqlOperation,
8
- GraphQLAuthError,
9
- GRAPHQL_AUTH_MODE,
10
- GraphQLResult,
11
- } from '@aws-amplify/api-graphql';
12
- export default API;