@aws/nx-plugin 0.77.0 → 0.79.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.
- package/LICENSE-THIRD-PARTY +36 -8
- package/package.json +2 -2
- package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +401 -0
- package/src/open-api/ts-client/files/client.gen.ts.template +27 -4
- package/src/open-api/utils/codegen-data/types.d.ts +4 -0
- package/src/open-api/utils/codegen-data/types.js +8 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +21 -1
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +42 -30
- package/src/py/fast-api/files/app/__name__/init.py.template +23 -17
- package/src/py/fast-api/files/app/__name__/main.py.template +2 -0
- package/src/py/fast-api/files/app/tests/test_main.py +1 -0
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +16 -9
- package/src/py/strands-agent/files/app/agentcore_mcp_client.py.template +4 -12
- package/src/py/strands-agent/files/app/init.py.template +51 -1
- package/src/py/strands-agent/files/app/main.py.template +16 -9
- package/src/smithy/react-connection/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +23 -17
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +60 -34
- package/src/trpc/backend/files/src/handler.ts.template +48 -0
- package/src/trpc/backend/files/src/index.ts.template +1 -1
- package/src/trpc/backend/files/src/router.ts.template +0 -38
- package/src/trpc/backend/files/src/schema/z-async-iterable.ts.template +115 -0
- package/src/trpc/backend/generator.js +6 -2
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +274 -27
- package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +57 -1
- package/src/trpc/react/generator.js +11 -1
- package/src/trpc/react/generator.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +13 -1
- package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +3 -3
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +8 -3
- package/src/utils/api-constructs/files/terraform/core/api/rest/rest-api/rest-api.tf.template +1 -1
- package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +1 -1
- package/src/utils/files/website/hooks/sigv4/useSigV4.tsx.template +81 -33
- package/src/utils/versions.d.ts +3 -1
- package/src/utils/versions.js +2 -0
- package/src/utils/versions.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;;AAsCA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;;AAsCA,gDAiIC;;AAvKD;;;GAGG;AACH,uCASoB;AAEpB,qEAA0E;AAC1E,+EAAwD;AACxD,qDAAwE;AACxE,mDAAoD;AACpD,6CAA2D;AAC3D,+CAA0D;AAC1D,+CAAoD;AACpD,uCAMwB;AACxB,iDAAsE;AACtE,8EAA+E;AAC/E,2CAA8C;AAC9C,yCAAqD;AACrD,sDAAsE;AAEzD,QAAA,2BAA2B,GACtC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B,SAAsB,kBAAkB,CACtC,IAAU,EACV,OAAiC;;QAEjC,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAExE,MAAM,IAAA,6CAAyB,EAAC,IAAI,EAAE;YACpC,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAA,6BAAiB,EAAC,IAAI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2
2
|
|
|
3
|
+
exports[`trpc react generator > REST API (ServerlessApiGatewayRestApi) > should generate REST API client provider with splitLink for Cognito auth > TestApiClientProvider-REST-Cognito.tsx 1`] = `
|
|
4
|
+
"import { AppRouter } from 'backend';
|
|
5
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
6
|
+
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
7
|
+
import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
8
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
9
|
+
import {
|
|
10
|
+
TRPCClient,
|
|
11
|
+
createTRPCClient,
|
|
12
|
+
httpLink,
|
|
13
|
+
httpSubscriptionLink,
|
|
14
|
+
splitLink,
|
|
15
|
+
} from '@trpc/client';
|
|
16
|
+
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
17
|
+
import { useAuth } from 'react-oidc-context';
|
|
18
|
+
|
|
19
|
+
interface TestApiTRPCContextValue {
|
|
20
|
+
optionsProxy: ReturnType<typeof createTRPCOptionsProxy<AppRouter>>;
|
|
21
|
+
client: TRPCClient<AppRouter>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const TestApiTRPCContext = createContext<TestApiTRPCContextValue | null>(
|
|
25
|
+
null,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const TestApiClientProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
const runtimeConfig = useRuntimeConfig();
|
|
31
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
32
|
+
const auth = useAuth();
|
|
33
|
+
const user = auth?.user;
|
|
34
|
+
|
|
35
|
+
const container = useMemo<TestApiTRPCContextValue>(() => {
|
|
36
|
+
const client = createTRPCClient<AppRouter>({
|
|
37
|
+
links: [
|
|
38
|
+
splitLink({
|
|
39
|
+
condition: (op) => op.type === 'subscription',
|
|
40
|
+
true: httpSubscriptionLink({
|
|
41
|
+
url: apiUrl,
|
|
42
|
+
EventSource: EventSourcePolyfill,
|
|
43
|
+
eventSourceOptions: async ({ op }) => {
|
|
44
|
+
return {
|
|
45
|
+
headers: {
|
|
46
|
+
Authorization: \`Bearer \${user?.id_token}\`,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
false: httpLink({
|
|
52
|
+
url: apiUrl,
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: \`Bearer \${user?.id_token}\`,
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const optionsProxy = createTRPCOptionsProxy<AppRouter>({
|
|
62
|
+
client,
|
|
63
|
+
queryClient,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return { optionsProxy, client };
|
|
67
|
+
}, [apiUrl, queryClient, user]);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<TestApiTRPCContext.Provider value={container}>
|
|
71
|
+
{children}
|
|
72
|
+
</TestApiTRPCContext.Provider>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default TestApiClientProvider;
|
|
77
|
+
"
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
exports[`trpc react generator > REST API (ServerlessApiGatewayRestApi) > should generate REST API client provider with splitLink for IAM auth > TestApiClientProvider-REST-IAM.tsx 1`] = `
|
|
81
|
+
"import { AppRouter } from 'backend';
|
|
82
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
83
|
+
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
84
|
+
import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
85
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
86
|
+
import {
|
|
87
|
+
TRPCClient,
|
|
88
|
+
createTRPCClient,
|
|
89
|
+
httpLink,
|
|
90
|
+
httpSubscriptionLink,
|
|
91
|
+
splitLink,
|
|
92
|
+
} from '@trpc/client';
|
|
93
|
+
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
94
|
+
import { useSigV4 } from '../hooks/useSigV4';
|
|
95
|
+
|
|
96
|
+
interface TestApiTRPCContextValue {
|
|
97
|
+
optionsProxy: ReturnType<typeof createTRPCOptionsProxy<AppRouter>>;
|
|
98
|
+
client: TRPCClient<AppRouter>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const TestApiTRPCContext = createContext<TestApiTRPCContextValue | null>(
|
|
102
|
+
null,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export const TestApiClientProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
106
|
+
const queryClient = useQueryClient();
|
|
107
|
+
const runtimeConfig = useRuntimeConfig();
|
|
108
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
109
|
+
const sigv4Client = useSigV4();
|
|
110
|
+
|
|
111
|
+
const container = useMemo<TestApiTRPCContextValue>(() => {
|
|
112
|
+
const client = createTRPCClient<AppRouter>({
|
|
113
|
+
links: [
|
|
114
|
+
splitLink({
|
|
115
|
+
condition: (op) => op.type === 'subscription',
|
|
116
|
+
true: httpSubscriptionLink({
|
|
117
|
+
url: apiUrl,
|
|
118
|
+
EventSource: EventSourcePolyfill,
|
|
119
|
+
eventSourceOptions: async ({ op }) => {
|
|
120
|
+
const url =
|
|
121
|
+
\`\${apiUrl.replace(/\\/$/, '')}/\${op.path}\` +
|
|
122
|
+
(op.input !== undefined
|
|
123
|
+
? \`?input=\${encodeURIComponent(JSON.stringify(op.input))}\`
|
|
124
|
+
: '');
|
|
125
|
+
const signed = await sigv4Client.sign(url, { method: 'GET' });
|
|
126
|
+
const headers: Record<string, string> = {};
|
|
127
|
+
signed.headers.forEach((v, k) => {
|
|
128
|
+
headers[k] = v;
|
|
129
|
+
});
|
|
130
|
+
return { headers };
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
false: httpLink({
|
|
134
|
+
url: apiUrl,
|
|
135
|
+
fetch: sigv4Client.fetch,
|
|
136
|
+
}),
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const optionsProxy = createTRPCOptionsProxy<AppRouter>({
|
|
142
|
+
client,
|
|
143
|
+
queryClient,
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return { optionsProxy, client };
|
|
147
|
+
}, [apiUrl, queryClient, sigv4Client]);
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<TestApiTRPCContext.Provider value={container}>
|
|
151
|
+
{children}
|
|
152
|
+
</TestApiTRPCContext.Provider>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default TestApiClientProvider;
|
|
157
|
+
"
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
exports[`trpc react generator > REST API (ServerlessApiGatewayRestApi) > should generate REST API client provider with splitLink for None auth > TestApiClientProvider-REST-None.tsx 1`] = `
|
|
161
|
+
"import { AppRouter } from 'backend';
|
|
162
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
163
|
+
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
|
|
164
|
+
import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
165
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
166
|
+
import {
|
|
167
|
+
TRPCClient,
|
|
168
|
+
createTRPCClient,
|
|
169
|
+
httpLink,
|
|
170
|
+
httpSubscriptionLink,
|
|
171
|
+
splitLink,
|
|
172
|
+
} from '@trpc/client';
|
|
173
|
+
|
|
174
|
+
interface TestApiTRPCContextValue {
|
|
175
|
+
optionsProxy: ReturnType<typeof createTRPCOptionsProxy<AppRouter>>;
|
|
176
|
+
client: TRPCClient<AppRouter>;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export const TestApiTRPCContext = createContext<TestApiTRPCContextValue | null>(
|
|
180
|
+
null,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
export const TestApiClientProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
184
|
+
const queryClient = useQueryClient();
|
|
185
|
+
const runtimeConfig = useRuntimeConfig();
|
|
186
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
187
|
+
|
|
188
|
+
const container = useMemo<TestApiTRPCContextValue>(() => {
|
|
189
|
+
const client = createTRPCClient<AppRouter>({
|
|
190
|
+
links: [
|
|
191
|
+
splitLink({
|
|
192
|
+
condition: (op) => op.type === 'subscription',
|
|
193
|
+
true: httpSubscriptionLink({
|
|
194
|
+
url: apiUrl,
|
|
195
|
+
}),
|
|
196
|
+
false: httpLink({
|
|
197
|
+
url: apiUrl,
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const optionsProxy = createTRPCOptionsProxy<AppRouter>({
|
|
204
|
+
client,
|
|
205
|
+
queryClient,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return { optionsProxy, client };
|
|
209
|
+
}, [apiUrl, queryClient]);
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<TestApiTRPCContext.Provider value={container}>
|
|
213
|
+
{children}
|
|
214
|
+
</TestApiTRPCContext.Provider>
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export default TestApiClientProvider;
|
|
219
|
+
"
|
|
220
|
+
`;
|
|
221
|
+
|
|
3
222
|
exports[`trpc react generator > should generate trpc react files > TestApiClientProvider.tsx 1`] = `
|
|
4
223
|
"import { AppRouter } from 'backend';
|
|
5
224
|
import { useQueryClient } from '@tanstack/react-query';
|
|
@@ -172,7 +391,7 @@ export const TestApiClientProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
|
172
391
|
const container = useMemo<TestApiTRPCContextValue>(() => {
|
|
173
392
|
const linkOptions: HTTPLinkOptions<any> = {
|
|
174
393
|
url: apiUrl,
|
|
175
|
-
fetch: sigv4Client,
|
|
394
|
+
fetch: sigv4Client.fetch,
|
|
176
395
|
};
|
|
177
396
|
|
|
178
397
|
const client = createTRPCClient<AppRouter>({
|
|
@@ -213,7 +432,17 @@ import {
|
|
|
213
432
|
// Credential expiration grace time before considering credentials as expired
|
|
214
433
|
const CREDENTIAL_EXPIRY_OFFSET_MILLIS = 30 * 1000;
|
|
215
434
|
|
|
216
|
-
|
|
435
|
+
type AwsSignInput = Parameters<AwsClient['sign']>[0];
|
|
436
|
+
type AwsSignInit = Parameters<AwsClient['sign']>[1];
|
|
437
|
+
|
|
438
|
+
export interface SigV4Client {
|
|
439
|
+
/** A SigV4-signing fetch drop-in replacement. */
|
|
440
|
+
fetch: typeof globalThis.fetch;
|
|
441
|
+
/** Signs a request. Same parameters as AwsClient.sign(). Returns an unsigned Request when signing is skipped. */
|
|
442
|
+
sign: AwsClient['sign'];
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export const useSigV4 = (): SigV4Client => {
|
|
217
446
|
const { cognitoProps } = useRuntimeConfig();
|
|
218
447
|
const auth = useAuth();
|
|
219
448
|
const user = auth?.user;
|
|
@@ -222,6 +451,8 @@ export const useSigV4 = () => {
|
|
|
222
451
|
{},
|
|
223
452
|
);
|
|
224
453
|
|
|
454
|
+
const skipSigning = !cognitoProps && import.meta.env.MODE === 'serve-local';
|
|
455
|
+
|
|
225
456
|
const withCachedCredentials = useCallback(
|
|
226
457
|
async (
|
|
227
458
|
provider: AwsCredentialIdentityProvider,
|
|
@@ -244,37 +475,53 @@ export const useSigV4 = () => {
|
|
|
244
475
|
[],
|
|
245
476
|
);
|
|
246
477
|
|
|
247
|
-
|
|
478
|
+
const getAwsClient = useCallback(async (): Promise<AwsClient> => {
|
|
479
|
+
if (!cognitoProps) {
|
|
480
|
+
throw new Error('cognitoProps is undefined!');
|
|
481
|
+
}
|
|
482
|
+
if (!user?.id_token) {
|
|
483
|
+
throw new Error('user.id_token is undefined!');
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
const credentialsFromCognitoIdentityPool = fromCognitoIdentityPool({
|
|
487
|
+
client: new CognitoIdentityClient({ region: cognitoProps.region }),
|
|
488
|
+
identityPoolId: cognitoProps.identityPoolId,
|
|
489
|
+
logins: {
|
|
490
|
+
[\`cognito-idp.\${cognitoProps.region}.amazonaws.com/\${cognitoProps.userPoolId}\`]:
|
|
491
|
+
user.id_token,
|
|
492
|
+
},
|
|
493
|
+
});
|
|
494
|
+
const credential = await withCachedCredentials(
|
|
495
|
+
credentialsFromCognitoIdentityPool,
|
|
496
|
+
cognitoProps.identityPoolId,
|
|
497
|
+
user.profile.sub,
|
|
498
|
+
);
|
|
499
|
+
return new AwsClient(credential);
|
|
500
|
+
}, [cognitoProps, user?.id_token, user?.profile.sub, withCachedCredentials]);
|
|
501
|
+
|
|
502
|
+
const sigv4Fetch: typeof globalThis.fetch = useCallback(
|
|
248
503
|
async (input: RequestInfo | URL, init?: RequestInit | undefined) => {
|
|
249
|
-
if (
|
|
250
|
-
// Skip request signing in serve-local mode when cognitoProps are not set
|
|
504
|
+
if (skipSigning) {
|
|
251
505
|
return fetch(input, init);
|
|
252
506
|
}
|
|
253
|
-
|
|
254
|
-
throw new Error('cognitoProps is undefined!');
|
|
255
|
-
}
|
|
256
|
-
if (!user?.id_token) {
|
|
257
|
-
throw new Error('user.id_token is undefined!');
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
const credentialsFromCognitoIdentityPool = fromCognitoIdentityPool({
|
|
261
|
-
client: new CognitoIdentityClient({ region: cognitoProps.region }),
|
|
262
|
-
identityPoolId: cognitoProps.identityPoolId,
|
|
263
|
-
logins: {
|
|
264
|
-
[\`cognito-idp.\${cognitoProps.region}.amazonaws.com/\${cognitoProps.userPoolId}\`]:
|
|
265
|
-
user.id_token,
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
const credential = await withCachedCredentials(
|
|
269
|
-
credentialsFromCognitoIdentityPool,
|
|
270
|
-
cognitoProps.identityPoolId,
|
|
271
|
-
user.profile.sub,
|
|
272
|
-
);
|
|
273
|
-
const awsClient = new AwsClient(credential);
|
|
507
|
+
const awsClient = await getAwsClient();
|
|
274
508
|
return awsClient.fetch(input, init);
|
|
275
509
|
},
|
|
276
|
-
[
|
|
510
|
+
[skipSigning, getAwsClient],
|
|
277
511
|
);
|
|
512
|
+
|
|
513
|
+
const sign = useCallback(
|
|
514
|
+
async (input: AwsSignInput, init?: AwsSignInit): Promise<Request> => {
|
|
515
|
+
if (skipSigning) {
|
|
516
|
+
return new Request(input.toString(), init ?? undefined);
|
|
517
|
+
}
|
|
518
|
+
const awsClient = await getAwsClient();
|
|
519
|
+
return awsClient.sign(input, init);
|
|
520
|
+
},
|
|
521
|
+
[skipSigning, getAwsClient],
|
|
522
|
+
);
|
|
523
|
+
|
|
524
|
+
return { fetch: sigv4Fetch, sign };
|
|
278
525
|
};
|
|
279
526
|
"
|
|
280
527
|
`;
|
|
@@ -3,7 +3,14 @@ import { useQueryClient } from "@tanstack/react-query";
|
|
|
3
3
|
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
|
|
4
4
|
import { createContext, FC, PropsWithChildren, useMemo } from "react";
|
|
5
5
|
import { useRuntimeConfig } from "../hooks/useRuntimeConfig";
|
|
6
|
+
<%_ if (isRestApi) { _%>
|
|
7
|
+
import { TRPCClient, createTRPCClient, httpLink, httpSubscriptionLink, splitLink } from "@trpc/client";
|
|
8
|
+
<%_ if (auth !== 'None') { _%>
|
|
9
|
+
import { EventSourcePolyfill } from "event-source-polyfill";
|
|
10
|
+
<%_ } _%>
|
|
11
|
+
<%_ } else { _%>
|
|
6
12
|
import { HTTPLinkOptions, TRPCClient, createTRPCClient, httpLink } from "@trpc/client";
|
|
13
|
+
<%_ } _%>
|
|
7
14
|
<%_ if (auth === 'IAM') { _%>
|
|
8
15
|
import { useSigV4 } from "../hooks/useSigV4";
|
|
9
16
|
<%_ } else if (auth === 'Cognito') { _%>
|
|
@@ -31,10 +38,58 @@ export const <%= apiNameClassName %>ClientProvider: FC<PropsWithChildren> = ({
|
|
|
31
38
|
<%_ } _%>
|
|
32
39
|
|
|
33
40
|
const container = useMemo<<%= apiNameClassName %>TRPCContextValue>(() => {
|
|
41
|
+
<%_ if (isRestApi) { _%>
|
|
42
|
+
const client = createTRPCClient<AppRouter>({
|
|
43
|
+
links: [
|
|
44
|
+
splitLink({
|
|
45
|
+
condition: (op) => op.type === 'subscription',
|
|
46
|
+
true: httpSubscriptionLink({
|
|
47
|
+
url: apiUrl,
|
|
48
|
+
<%_ if (auth !== 'None') { _%>
|
|
49
|
+
EventSource: EventSourcePolyfill,
|
|
50
|
+
eventSourceOptions: async ({ op }) => {
|
|
51
|
+
<%_ if (auth === 'IAM') { _%>
|
|
52
|
+
const url =
|
|
53
|
+
`${apiUrl.replace(/\/$/, '')}/${op.path}` +
|
|
54
|
+
(op.input !== undefined
|
|
55
|
+
? `?input=${encodeURIComponent(JSON.stringify(op.input))}`
|
|
56
|
+
: '');
|
|
57
|
+
const signed = await sigv4Client.sign(url, { method: 'GET' });
|
|
58
|
+
const headers: Record<string, string> = {};
|
|
59
|
+
signed.headers.forEach((v, k) => {
|
|
60
|
+
headers[k] = v;
|
|
61
|
+
});
|
|
62
|
+
return { headers };
|
|
63
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
64
|
+
return {
|
|
65
|
+
headers: {
|
|
66
|
+
Authorization: `Bearer ${user?.id_token}`,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
<%_ } else { _%>
|
|
70
|
+
return {};
|
|
71
|
+
<%_ } _%>
|
|
72
|
+
},
|
|
73
|
+
<%_ } _%>
|
|
74
|
+
}),
|
|
75
|
+
false: httpLink({
|
|
76
|
+
url: apiUrl,
|
|
77
|
+
<%_ if (auth === 'IAM') { _%>
|
|
78
|
+
fetch: sigv4Client.fetch,
|
|
79
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
80
|
+
headers: {
|
|
81
|
+
Authorization: `Bearer ${user?.id_token}`,
|
|
82
|
+
},
|
|
83
|
+
<%_ } _%>
|
|
84
|
+
}),
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
<%_ } else { _%>
|
|
34
89
|
const linkOptions: HTTPLinkOptions<any> = {
|
|
35
90
|
url: apiUrl,
|
|
36
91
|
<%_ if (auth === 'IAM') { _%>
|
|
37
|
-
fetch: sigv4Client,
|
|
92
|
+
fetch: sigv4Client.fetch,
|
|
38
93
|
<%_ } else if (auth === 'Cognito') { _%>
|
|
39
94
|
headers: {
|
|
40
95
|
Authorization: `Bearer ${user?.id_token}`,
|
|
@@ -45,6 +100,7 @@ export const <%= apiNameClassName %>ClientProvider: FC<PropsWithChildren> = ({
|
|
|
45
100
|
const client = createTRPCClient<AppRouter>({
|
|
46
101
|
links: [httpLink(linkOptions)],
|
|
47
102
|
});
|
|
103
|
+
<%_ } _%>
|
|
48
104
|
|
|
49
105
|
const optionsProxy = createTRPCOptionsProxy<AppRouter>({
|
|
50
106
|
client,
|
|
@@ -28,9 +28,11 @@ function reactGenerator(tree, options) {
|
|
|
28
28
|
const apiName = metadata.apiName;
|
|
29
29
|
const auth = (_a = metadata.auth) !== null && _a !== void 0 ? _a : 'IAM';
|
|
30
30
|
const port = (_d = (_b = metadata.port) !== null && _b !== void 0 ? _b : (_c = metadata.ports) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 2022;
|
|
31
|
+
const isRestApi = metadata.computeType === 'ServerlessApiGatewayRestApi';
|
|
31
32
|
const apiNameClassName = (0, names_1.toClassName)(apiName);
|
|
32
33
|
const backendProjectAlias = (0, npm_scope_1.toScopeAlias)(backendProjectConfig.name);
|
|
33
34
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), frontendProjectConfig.root, Object.assign(Object.assign({ apiName, apiNameClassName: (0, names_1.toClassName)(apiName) }, options), { auth,
|
|
35
|
+
isRestApi,
|
|
34
36
|
backendProjectAlias }), {
|
|
35
37
|
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
36
38
|
});
|
|
@@ -70,6 +72,9 @@ function reactGenerator(tree, options) {
|
|
|
70
72
|
'@trpc/tanstack-react-query',
|
|
71
73
|
'@tanstack/react-query',
|
|
72
74
|
'@tanstack/react-query-devtools',
|
|
75
|
+
...(isRestApi && auth !== 'None'
|
|
76
|
+
? ['event-source-polyfill']
|
|
77
|
+
: []),
|
|
73
78
|
...(auth === 'IAM'
|
|
74
79
|
? [
|
|
75
80
|
'oidc-client-ts',
|
|
@@ -80,7 +85,12 @@ function reactGenerator(tree, options) {
|
|
|
80
85
|
]
|
|
81
86
|
: []),
|
|
82
87
|
...(auth === 'Cognito' ? ['react-oidc-context'] : []),
|
|
83
|
-
]), (0, versions_1.withVersions)([
|
|
88
|
+
]), (0, versions_1.withVersions)([
|
|
89
|
+
'@smithy/types',
|
|
90
|
+
...(isRestApi && auth !== 'None'
|
|
91
|
+
? ['@types/event-source-polyfill']
|
|
92
|
+
: []),
|
|
93
|
+
]));
|
|
84
94
|
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.TRPC_REACT_GENERATOR_INFO]);
|
|
85
95
|
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
86
96
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;;AAoCA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;;AAoCA,wCAwKC;;AA5MD;;;GAGG;AACH,uCAOoB;AAGpB,+EAAyF;AACzF,qDAAqD;AACrD,mDAAoD;AACpD,yCAKyB;AACzB,6CAAgD;AAChD,+CAA0D;AAC1D,uCAIwB;AACxB,iDAAsE;AACtE,8DAAqE;AAExD,QAAA,yBAAyB,GACpC,IAAA,qBAAgB,EAAC,UAAU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IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,cAAc,CAAC"}
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
AuthorizationType,
|
|
13
13
|
Cors,
|
|
14
14
|
LambdaIntegration,
|
|
15
|
+
<%_ if (backend.type === 'trpc') { _%>
|
|
16
|
+
ResponseTransferMode,
|
|
17
|
+
<%_ } _%>
|
|
15
18
|
<%_ if (auth === 'Cognito') { _%>
|
|
16
19
|
CognitoUserPoolsAuthorizer,
|
|
17
20
|
<%_ } _%>
|
|
@@ -124,7 +127,16 @@ export class <%= apiNameClassName %><
|
|
|
124
127
|
} satisfies FunctionProps,
|
|
125
128
|
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
126
129
|
const handler = new Function(scope, `<%= apiNameClassName %>${op}Handler`, props);
|
|
127
|
-
return {
|
|
130
|
+
return {
|
|
131
|
+
handler,
|
|
132
|
+
<%_ if (backend.type === 'trpc') { _%>
|
|
133
|
+
integration: new LambdaIntegration(handler, {
|
|
134
|
+
responseTransferMode: ResponseTransferMode.STREAM,
|
|
135
|
+
}),
|
|
136
|
+
<%_ } else { _%>
|
|
137
|
+
integration: new LambdaIntegration(handler),
|
|
138
|
+
<%_ } _%>
|
|
139
|
+
};
|
|
128
140
|
},
|
|
129
141
|
});
|
|
130
142
|
};
|
|
@@ -55,9 +55,9 @@ export const routerToOperations = <TRouter extends AnyTRPCRouter>(
|
|
|
55
55
|
{
|
|
56
56
|
path: fullPath,
|
|
57
57
|
method:
|
|
58
|
-
procedureOrRouter._def.type === '
|
|
59
|
-
? HttpMethod.
|
|
60
|
-
: HttpMethod.
|
|
58
|
+
procedureOrRouter._def.type === 'mutation'
|
|
59
|
+
? HttpMethod.POST
|
|
60
|
+
: HttpMethod.GET,
|
|
61
61
|
},
|
|
62
62
|
],
|
|
63
63
|
];
|
|
@@ -4,7 +4,7 @@ terraform {
|
|
|
4
4
|
required_providers {
|
|
5
5
|
aws = {
|
|
6
6
|
source = "hashicorp/aws"
|
|
7
|
-
version = "~> 6.
|
|
7
|
+
version = "~> 6.33"
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -210,8 +210,13 @@ resource "aws_api_gateway_integration" "lambda_integration" {
|
|
|
210
210
|
http_method = aws_api_gateway_method.proxy_method.http_method
|
|
211
211
|
|
|
212
212
|
integration_http_method = "POST"
|
|
213
|
-
type
|
|
214
|
-
|
|
213
|
+
type = "AWS_PROXY"
|
|
214
|
+
<%_ if (backend.type === 'trpc') { _%>
|
|
215
|
+
uri = aws_lambda_function.api_lambda.response_streaming_invoke_arn
|
|
216
|
+
response_transfer_mode = "STREAM"
|
|
217
|
+
<%_ } else { _%>
|
|
218
|
+
uri = aws_lambda_function.api_lambda.invoke_arn
|
|
219
|
+
<%_ } _%>
|
|
215
220
|
|
|
216
221
|
depends_on = [aws_lambda_function.api_lambda]
|
|
217
222
|
}
|
package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template
CHANGED
|
@@ -42,7 +42,7 @@ const useCreate<%- apiNameClassName %>Client = (): <%- apiNameClassName %> => {
|
|
|
42
42
|
return useMemo(() => new <%- apiNameClassName %>({
|
|
43
43
|
url: apiUrl,
|
|
44
44
|
<%_ if(auth === 'IAM') { _%>
|
|
45
|
-
fetch: sigv4Client,
|
|
45
|
+
fetch: sigv4Client.fetch,
|
|
46
46
|
<%_ } else if(auth === 'Cognito') { _%>
|
|
47
47
|
fetch: cognitoClient,
|
|
48
48
|
<%_ } _%>
|