@aws/nx-plugin 0.26.0 → 0.28.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/package.json +1 -1
- package/src/api-connection/generator.js +0 -2
- package/src/api-connection/generator.js.map +1 -1
- package/src/api-connection/schema.d.ts +0 -1
- package/src/api-connection/schema.json +0 -7
- package/src/cloudscape-website/app/generator.js +1 -0
- package/src/cloudscape-website/app/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/infra/app/generator.js +1 -0
- package/src/infra/app/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +31 -30
- package/src/py/fast-api/generator.js +3 -0
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +68 -1
- package/src/py/fast-api/react/files/website/components/__apiNameClassName__Provider.tsx.template +27 -1
- package/src/py/fast-api/react/generator.js +7 -17
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/schema.d.ts +0 -1
- package/src/py/fast-api/react/schema.json +0 -7
- package/src/py/fast-api/schema.d.ts +1 -0
- package/src/py/fast-api/schema.json +9 -1
- package/src/py/project/generator.js +1 -0
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.json +7 -2
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +680 -84
- package/src/trpc/backend/files/backend/src/client/index.ts.template +22 -2
- package/src/trpc/backend/files/backend/src/middleware/index.ts.template +2 -3
- package/src/trpc/backend/files/backend/src/router.ts.template +2 -3
- package/src/trpc/backend/generator.js +21 -5
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +2 -1
- package/src/trpc/backend/schema.json +10 -2
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +186 -73
- package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +54 -0
- package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +2 -2
- package/src/trpc/react/generator.js +13 -69
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.d.ts +0 -1
- package/src/trpc/react/schema.json +0 -7
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/lib/generator.js +1 -0
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.json +7 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +3 -0
- package/src/ts/mcp-server/generator.js +1 -0
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.json +5 -0
- package/src/utils/api-constructs/api-constructs.d.ts +1 -0
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/app/apis/http/__apiNameKebabCase__.ts.template +53 -2
- package/src/utils/api-constructs/files/app/apis/rest/__apiNameKebabCase__.ts.template +57 -2
- package/src/utils/api-constructs/files/core/api/http/http-api.ts.template +1 -15
- package/src/utils/api-constructs/files/core/api/rest/rest-api.ts.template +0 -14
- package/src/utils/nx.d.ts +4 -0
- package/src/utils/nx.js +9 -1
- package/src/utils/nx.js.map +1 -1
- package/src/api-connection/README.md +0 -0
- package/src/cloudscape-website/app/README.md +0 -289
- package/src/cloudscape-website/cognito-auth/README.md +0 -193
- package/src/infra/app/README.md +0 -200
- package/src/license/README.md +0 -290
- package/src/trpc/backend/README.md +0 -571
- package/src/trpc/backend/files/backend/src/client/sigv4.ts.template +0 -9
- package/src/trpc/react/README.md +0 -330
- package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +0 -1
- package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +0 -10
- package/src/trpc/react/files/src/components/TrpcClients/TrpcProvider.tsx.template +0 -55
- package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +0 -5
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/backend/src/client/index.ts 1`] = `
|
|
4
4
|
"import { createTRPCClient, httpLink, HTTPLinkOptions } from '@trpc/client';
|
|
5
|
-
|
|
5
|
+
import { AwsClient } from 'aws4fetch';
|
|
6
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
6
7
|
import { AppRouter } from '../router.js';
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
const credentialProvider = fromNodeProviderChain();
|
|
10
|
+
|
|
11
|
+
const sigv4Fetch = (async (...args) => {
|
|
12
|
+
const client = new AwsClient(await credentialProvider());
|
|
13
|
+
return client.fetch(...args);
|
|
14
|
+
}) satisfies AwsClient['fetch'];
|
|
8
15
|
|
|
9
16
|
export interface TestApiClientConfig {
|
|
10
17
|
readonly url: string;
|
|
@@ -22,19 +29,6 @@ export const createTestApiClient = (config: TestApiClientConfig) => {
|
|
|
22
29
|
"
|
|
23
30
|
`;
|
|
24
31
|
|
|
25
|
-
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/backend/src/client/sigv4.ts 1`] = `
|
|
26
|
-
"import { AwsClient } from 'aws4fetch';
|
|
27
|
-
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
28
|
-
|
|
29
|
-
const credentialProvider = fromNodeProviderChain();
|
|
30
|
-
|
|
31
|
-
export const sigv4Fetch = (async (...args) => {
|
|
32
|
-
const client = new AwsClient(await credentialProvider());
|
|
33
|
-
return client.fetch(...args);
|
|
34
|
-
}) satisfies AwsClient['fetch'];
|
|
35
|
-
"
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
32
|
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/backend/src/index.ts 1`] = `
|
|
39
33
|
"export type { AppRouter } from './router.js';
|
|
40
34
|
export { appRouter } from './router.js';
|
|
@@ -264,65 +258,665 @@ exports[`trpc backend generator > should generate backend and schema projects >
|
|
|
264
258
|
"import { publicProcedure } from '../init.js';
|
|
265
259
|
import { EchoInputSchema, EchoOutputSchema } from ':proj/test-api-schema';
|
|
266
260
|
|
|
267
|
-
export const echo = publicProcedure
|
|
268
|
-
.input(EchoInputSchema)
|
|
269
|
-
.output(EchoOutputSchema)
|
|
270
|
-
.query((opts) => ({ result: opts.input.message }));
|
|
261
|
+
export const echo = publicProcedure
|
|
262
|
+
.input(EchoInputSchema)
|
|
263
|
+
.output(EchoOutputSchema)
|
|
264
|
+
.query((opts) => ({ result: opts.input.message }));
|
|
265
|
+
"
|
|
266
|
+
`;
|
|
267
|
+
|
|
268
|
+
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/backend/src/router.ts 1`] = `
|
|
269
|
+
"import {
|
|
270
|
+
awsLambdaRequestHandler,
|
|
271
|
+
CreateAWSLambdaContextOptions,
|
|
272
|
+
} from '@trpc/server/adapters/aws-lambda';
|
|
273
|
+
import { echo } from './procedures/echo.js';
|
|
274
|
+
import { t } from './init.js';
|
|
275
|
+
import type { APIGatewayProxyEventV2WithIAMAuthorizer } from 'aws-lambda';
|
|
276
|
+
|
|
277
|
+
export const router = t.router;
|
|
278
|
+
|
|
279
|
+
export const appRouter = router({
|
|
280
|
+
echo,
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
export const handler = awsLambdaRequestHandler({
|
|
284
|
+
router: appRouter,
|
|
285
|
+
createContext: (
|
|
286
|
+
ctx: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2WithIAMAuthorizer>,
|
|
287
|
+
) => ctx,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
export type AppRouter = typeof appRouter;
|
|
291
|
+
"
|
|
292
|
+
`;
|
|
293
|
+
|
|
294
|
+
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/schema/src/index.ts 1`] = `
|
|
295
|
+
"export * from './procedures/echo.js';
|
|
296
|
+
"
|
|
297
|
+
`;
|
|
298
|
+
|
|
299
|
+
exports[`trpc backend generator > should generate backend and schema projects > apps/test-api/schema/src/procedures/echo.ts 1`] = `
|
|
300
|
+
"import { z } from 'zod';
|
|
301
|
+
|
|
302
|
+
export const EchoInputSchema = z.object({
|
|
303
|
+
message: z.string(),
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
export type IEchoInput = z.TypeOf<typeof EchoInputSchema>;
|
|
307
|
+
|
|
308
|
+
export const EchoOutputSchema = z.object({
|
|
309
|
+
result: z.string(),
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
export type IEchoOutput = z.TypeOf<typeof EchoOutputSchema>;
|
|
313
|
+
"
|
|
314
|
+
`;
|
|
315
|
+
|
|
316
|
+
exports[`trpc backend generator > should generate with cognito auth for a REST API > apps/test-api/backend/src/client/index.ts 1`] = `
|
|
317
|
+
"import { createTRPCClient, httpLink, HTTPLinkOptions } from '@trpc/client';
|
|
318
|
+
import { AppRouter } from '../router.js';
|
|
319
|
+
|
|
320
|
+
export interface TestApiClientConfig {
|
|
321
|
+
readonly url: string;
|
|
322
|
+
readonly token: string;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export const createTestApiClient = (config: TestApiClientConfig) => {
|
|
326
|
+
const linkOptions: HTTPLinkOptions<any> = {
|
|
327
|
+
url: config.url,
|
|
328
|
+
headers: {
|
|
329
|
+
Authorization: \`Bearer \${config.token}\`,
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
return createTRPCClient<AppRouter>({
|
|
333
|
+
links: [httpLink(linkOptions)],
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
"
|
|
337
|
+
`;
|
|
338
|
+
|
|
339
|
+
exports[`trpc backend generator > should generate with cognito auth for a REST API > packages/common/constructs/src/app/apis/index.ts 1`] = `
|
|
340
|
+
"export * from './test-api.js';
|
|
341
|
+
"
|
|
342
|
+
`;
|
|
343
|
+
|
|
344
|
+
exports[`trpc backend generator > should generate with cognito auth for a REST API > packages/common/constructs/src/app/apis/test-api.ts 1`] = `
|
|
345
|
+
"import { Construct } from 'constructs';
|
|
346
|
+
import * as url from 'url';
|
|
347
|
+
import {
|
|
348
|
+
Code,
|
|
349
|
+
Runtime,
|
|
350
|
+
Function,
|
|
351
|
+
FunctionProps,
|
|
352
|
+
Tracing,
|
|
353
|
+
} from 'aws-cdk-lib/aws-lambda';
|
|
354
|
+
import {
|
|
355
|
+
AuthorizationType,
|
|
356
|
+
Cors,
|
|
357
|
+
LambdaIntegration,
|
|
358
|
+
CognitoUserPoolsAuthorizer,
|
|
359
|
+
} from 'aws-cdk-lib/aws-apigateway';
|
|
360
|
+
import { Duration } from 'aws-cdk-lib';
|
|
361
|
+
import {
|
|
362
|
+
PolicyDocument,
|
|
363
|
+
PolicyStatement,
|
|
364
|
+
Effect,
|
|
365
|
+
AnyPrincipal,
|
|
366
|
+
} from 'aws-cdk-lib/aws-iam';
|
|
367
|
+
import { IUserPool } from 'aws-cdk-lib/aws-cognito';
|
|
368
|
+
import {
|
|
369
|
+
IntegrationBuilder,
|
|
370
|
+
RestApiIntegration,
|
|
371
|
+
} from '../../core/api/utils.js';
|
|
372
|
+
import { RestApi } from '../../core/api/rest-api.js';
|
|
373
|
+
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
374
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
375
|
+
|
|
376
|
+
// String union type for all API operation names
|
|
377
|
+
type Operations = Procedures<AppRouter>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Properties for creating a TestApi construct
|
|
381
|
+
*
|
|
382
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
383
|
+
*/
|
|
384
|
+
export interface TestApiProps<
|
|
385
|
+
TIntegrations extends Record<Operations, RestApiIntegration>,
|
|
386
|
+
> {
|
|
387
|
+
/**
|
|
388
|
+
* Map of operation names to their API Gateway integrations
|
|
389
|
+
*/
|
|
390
|
+
integrations: TIntegrations;
|
|
391
|
+
/**
|
|
392
|
+
* User pool for Cognito authentication
|
|
393
|
+
*/
|
|
394
|
+
userPool: IUserPool;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* A CDK construct that creates and configures an AWS API Gateway REST API
|
|
399
|
+
* specifically for TestApi.
|
|
400
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
401
|
+
*/
|
|
402
|
+
export class TestApi<
|
|
403
|
+
TIntegrations extends Record<Operations, RestApiIntegration>,
|
|
404
|
+
> extends RestApi<Operations, TIntegrations> {
|
|
405
|
+
/**
|
|
406
|
+
* Creates default integrations for all operations, which implement each operation as
|
|
407
|
+
* its own individual lambda function.
|
|
408
|
+
*
|
|
409
|
+
* @param scope - The CDK construct scope
|
|
410
|
+
* @returns An IntegrationBuilder with default lambda integrations
|
|
411
|
+
*/
|
|
412
|
+
public static defaultIntegrations = (scope: Construct) => {
|
|
413
|
+
return IntegrationBuilder.rest({
|
|
414
|
+
operations: routerToOperations(appRouter),
|
|
415
|
+
defaultIntegrationOptions: {
|
|
416
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
417
|
+
handler: 'index.handler',
|
|
418
|
+
code: Code.fromAsset(
|
|
419
|
+
url.fileURLToPath(
|
|
420
|
+
new URL(
|
|
421
|
+
'../../../../../../dist/apps/test-api/backend/bundle',
|
|
422
|
+
import.meta.url,
|
|
423
|
+
),
|
|
424
|
+
),
|
|
425
|
+
),
|
|
426
|
+
timeout: Duration.seconds(30),
|
|
427
|
+
tracing: Tracing.ACTIVE,
|
|
428
|
+
environment: {
|
|
429
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
430
|
+
},
|
|
431
|
+
} satisfies FunctionProps,
|
|
432
|
+
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
433
|
+
const handler = new Function(scope, \`TestApi\${op}Handler\`, props);
|
|
434
|
+
return { handler, integration: new LambdaIntegration(handler) };
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
constructor(
|
|
440
|
+
scope: Construct,
|
|
441
|
+
id: string,
|
|
442
|
+
props: TestApiProps<TIntegrations>,
|
|
443
|
+
) {
|
|
444
|
+
super(scope, id, {
|
|
445
|
+
apiName: 'TestApi',
|
|
446
|
+
defaultMethodOptions: {
|
|
447
|
+
authorizationType: AuthorizationType.COGNITO,
|
|
448
|
+
authorizer: new CognitoUserPoolsAuthorizer(scope, 'TestApiAuthorizer', {
|
|
449
|
+
cognitoUserPools: [props.userPool],
|
|
450
|
+
}),
|
|
451
|
+
},
|
|
452
|
+
defaultCorsPreflightOptions: {
|
|
453
|
+
allowOrigins: Cors.ALL_ORIGINS,
|
|
454
|
+
allowMethods: Cors.ALL_METHODS,
|
|
455
|
+
},
|
|
456
|
+
policy: new PolicyDocument({
|
|
457
|
+
statements: [
|
|
458
|
+
// Allow all callers to invoke the API in the resource policy, since auth is handled by Cognito
|
|
459
|
+
new PolicyStatement({
|
|
460
|
+
effect: Effect.ALLOW,
|
|
461
|
+
principals: [new AnyPrincipal()],
|
|
462
|
+
actions: ['execute-api:Invoke'],
|
|
463
|
+
resources: ['execute-api:/*'],
|
|
464
|
+
}),
|
|
465
|
+
],
|
|
466
|
+
}),
|
|
467
|
+
operations: routerToOperations(appRouter),
|
|
468
|
+
...props,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
"
|
|
473
|
+
`;
|
|
474
|
+
|
|
475
|
+
exports[`trpc backend generator > should generate with cognito auth for an HTTP API > apps/test-api/backend/src/client/index.ts 1`] = `
|
|
476
|
+
"import { createTRPCClient, httpLink, HTTPLinkOptions } from '@trpc/client';
|
|
477
|
+
import { AppRouter } from '../router.js';
|
|
478
|
+
|
|
479
|
+
export interface TestApiClientConfig {
|
|
480
|
+
readonly url: string;
|
|
481
|
+
readonly token: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export const createTestApiClient = (config: TestApiClientConfig) => {
|
|
485
|
+
const linkOptions: HTTPLinkOptions<any> = {
|
|
486
|
+
url: config.url,
|
|
487
|
+
headers: {
|
|
488
|
+
Authorization: \`Bearer \${config.token}\`,
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
return createTRPCClient<AppRouter>({
|
|
492
|
+
links: [httpLink(linkOptions)],
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
"
|
|
496
|
+
`;
|
|
497
|
+
|
|
498
|
+
exports[`trpc backend generator > should generate with cognito auth for an HTTP API > packages/common/constructs/src/app/apis/index.ts 1`] = `
|
|
499
|
+
"export * from './test-api.js';
|
|
500
|
+
"
|
|
501
|
+
`;
|
|
502
|
+
|
|
503
|
+
exports[`trpc backend generator > should generate with cognito auth for an HTTP API > packages/common/constructs/src/app/apis/test-api.ts 1`] = `
|
|
504
|
+
"import { Construct } from 'constructs';
|
|
505
|
+
import * as url from 'url';
|
|
506
|
+
import {
|
|
507
|
+
Code,
|
|
508
|
+
Runtime,
|
|
509
|
+
Function,
|
|
510
|
+
FunctionProps,
|
|
511
|
+
Tracing,
|
|
512
|
+
} from 'aws-cdk-lib/aws-lambda';
|
|
513
|
+
import { Duration } from 'aws-cdk-lib';
|
|
514
|
+
import { CorsHttpMethod } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
515
|
+
import { HttpUserPoolAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
516
|
+
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
517
|
+
import { IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
518
|
+
import {
|
|
519
|
+
HttpApiIntegration,
|
|
520
|
+
IntegrationBuilder,
|
|
521
|
+
} from '../../core/api/utils.js';
|
|
522
|
+
import { HttpApi } from '../../core/api/http-api.js';
|
|
523
|
+
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
524
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
525
|
+
|
|
526
|
+
// String union type for all API operation names
|
|
527
|
+
type Operations = Procedures<AppRouter>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Properties for creating a TestApi construct
|
|
531
|
+
*
|
|
532
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
533
|
+
*/
|
|
534
|
+
export interface TestApiProps<
|
|
535
|
+
TIntegrations extends Record<Operations, HttpApiIntegration>,
|
|
536
|
+
> {
|
|
537
|
+
/**
|
|
538
|
+
* Map of operation names to their API Gateway integrations
|
|
539
|
+
*/
|
|
540
|
+
integrations: TIntegrations;
|
|
541
|
+
/**
|
|
542
|
+
* Identity details for Cognito Authentication
|
|
543
|
+
*/
|
|
544
|
+
identity: {
|
|
545
|
+
userPool: IUserPool;
|
|
546
|
+
userPoolClient: IUserPoolClient;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* A CDK construct that creates and configures an AWS API Gateway HTTP API
|
|
552
|
+
* specifically for TestApi.
|
|
553
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
554
|
+
*/
|
|
555
|
+
export class TestApi<
|
|
556
|
+
TIntegrations extends Record<Operations, HttpApiIntegration>,
|
|
557
|
+
> extends HttpApi<Operations, TIntegrations> {
|
|
558
|
+
/**
|
|
559
|
+
* Creates default integrations for all operations, which implement each operation as
|
|
560
|
+
* its own individual lambda function.
|
|
561
|
+
*
|
|
562
|
+
* @param scope - The CDK construct scope
|
|
563
|
+
* @returns An IntegrationBuilder with default lambda integrations
|
|
564
|
+
*/
|
|
565
|
+
public static defaultIntegrations = (scope: Construct) => {
|
|
566
|
+
return IntegrationBuilder.http({
|
|
567
|
+
operations: routerToOperations(appRouter),
|
|
568
|
+
defaultIntegrationOptions: {
|
|
569
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
570
|
+
handler: 'index.handler',
|
|
571
|
+
code: Code.fromAsset(
|
|
572
|
+
url.fileURLToPath(
|
|
573
|
+
new URL(
|
|
574
|
+
'../../../../../../dist/apps/test-api/backend/bundle',
|
|
575
|
+
import.meta.url,
|
|
576
|
+
),
|
|
577
|
+
),
|
|
578
|
+
),
|
|
579
|
+
timeout: Duration.seconds(30),
|
|
580
|
+
tracing: Tracing.ACTIVE,
|
|
581
|
+
environment: {
|
|
582
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
583
|
+
},
|
|
584
|
+
} satisfies FunctionProps,
|
|
585
|
+
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
586
|
+
const handler = new Function(scope, \`TestApi\${op}Handler\`, props);
|
|
587
|
+
return {
|
|
588
|
+
handler,
|
|
589
|
+
integration: new HttpLambdaIntegration(
|
|
590
|
+
\`TestApi\${op}Integration\`,
|
|
591
|
+
handler,
|
|
592
|
+
),
|
|
593
|
+
};
|
|
594
|
+
},
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
constructor(
|
|
599
|
+
scope: Construct,
|
|
600
|
+
id: string,
|
|
601
|
+
props: TestApiProps<TIntegrations>,
|
|
602
|
+
) {
|
|
603
|
+
super(scope, id, {
|
|
604
|
+
apiName: 'TestApi',
|
|
605
|
+
corsPreflight: {
|
|
606
|
+
allowOrigins: ['*'],
|
|
607
|
+
allowMethods: [CorsHttpMethod.ANY],
|
|
608
|
+
allowHeaders: [
|
|
609
|
+
'authorization',
|
|
610
|
+
'content-type',
|
|
611
|
+
'x-amz-content-sha256',
|
|
612
|
+
'x-amz-date',
|
|
613
|
+
'x-amz-security-token',
|
|
614
|
+
],
|
|
615
|
+
},
|
|
616
|
+
defaultAuthorizer: new HttpUserPoolAuthorizer(
|
|
617
|
+
'TestApiAuthorizer',
|
|
618
|
+
props.identity.userPool,
|
|
619
|
+
{
|
|
620
|
+
userPoolClients: [props.identity.userPoolClient],
|
|
621
|
+
},
|
|
622
|
+
),
|
|
623
|
+
operations: routerToOperations(appRouter),
|
|
624
|
+
...props,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
"
|
|
629
|
+
`;
|
|
630
|
+
|
|
631
|
+
exports[`trpc backend generator > should generate with no auth for a REST API > apps/test-api/backend/src/client/index.ts 1`] = `
|
|
632
|
+
"import { createTRPCClient, httpLink, HTTPLinkOptions } from '@trpc/client';
|
|
633
|
+
import { AppRouter } from '../router.js';
|
|
634
|
+
|
|
635
|
+
export interface TestApiClientConfig {
|
|
636
|
+
readonly url: string;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export const createTestApiClient = (config: TestApiClientConfig) => {
|
|
640
|
+
const linkOptions: HTTPLinkOptions<any> = {
|
|
641
|
+
url: config.url,
|
|
642
|
+
};
|
|
643
|
+
return createTRPCClient<AppRouter>({
|
|
644
|
+
links: [httpLink(linkOptions)],
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
"
|
|
648
|
+
`;
|
|
649
|
+
|
|
650
|
+
exports[`trpc backend generator > should generate with no auth for a REST API > packages/common/constructs/src/app/apis/index.ts 1`] = `
|
|
651
|
+
"export * from './test-api.js';
|
|
652
|
+
"
|
|
653
|
+
`;
|
|
654
|
+
|
|
655
|
+
exports[`trpc backend generator > should generate with no auth for a REST API > packages/common/constructs/src/app/apis/test-api.ts 1`] = `
|
|
656
|
+
"import { Construct } from 'constructs';
|
|
657
|
+
import * as url from 'url';
|
|
658
|
+
import {
|
|
659
|
+
Code,
|
|
660
|
+
Runtime,
|
|
661
|
+
Function,
|
|
662
|
+
FunctionProps,
|
|
663
|
+
Tracing,
|
|
664
|
+
} from 'aws-cdk-lib/aws-lambda';
|
|
665
|
+
import {
|
|
666
|
+
AuthorizationType,
|
|
667
|
+
Cors,
|
|
668
|
+
LambdaIntegration,
|
|
669
|
+
} from 'aws-cdk-lib/aws-apigateway';
|
|
670
|
+
import { Duration } from 'aws-cdk-lib';
|
|
671
|
+
import {
|
|
672
|
+
PolicyDocument,
|
|
673
|
+
PolicyStatement,
|
|
674
|
+
Effect,
|
|
675
|
+
AnyPrincipal,
|
|
676
|
+
} from 'aws-cdk-lib/aws-iam';
|
|
677
|
+
import {
|
|
678
|
+
IntegrationBuilder,
|
|
679
|
+
RestApiIntegration,
|
|
680
|
+
} from '../../core/api/utils.js';
|
|
681
|
+
import { RestApi } from '../../core/api/rest-api.js';
|
|
682
|
+
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
683
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
684
|
+
|
|
685
|
+
// String union type for all API operation names
|
|
686
|
+
type Operations = Procedures<AppRouter>;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Properties for creating a TestApi construct
|
|
690
|
+
*
|
|
691
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
692
|
+
*/
|
|
693
|
+
export interface TestApiProps<
|
|
694
|
+
TIntegrations extends Record<Operations, RestApiIntegration>,
|
|
695
|
+
> {
|
|
696
|
+
/**
|
|
697
|
+
* Map of operation names to their API Gateway integrations
|
|
698
|
+
*/
|
|
699
|
+
integrations: TIntegrations;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* A CDK construct that creates and configures an AWS API Gateway REST API
|
|
704
|
+
* specifically for TestApi.
|
|
705
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
706
|
+
*/
|
|
707
|
+
export class TestApi<
|
|
708
|
+
TIntegrations extends Record<Operations, RestApiIntegration>,
|
|
709
|
+
> extends RestApi<Operations, TIntegrations> {
|
|
710
|
+
/**
|
|
711
|
+
* Creates default integrations for all operations, which implement each operation as
|
|
712
|
+
* its own individual lambda function.
|
|
713
|
+
*
|
|
714
|
+
* @param scope - The CDK construct scope
|
|
715
|
+
* @returns An IntegrationBuilder with default lambda integrations
|
|
716
|
+
*/
|
|
717
|
+
public static defaultIntegrations = (scope: Construct) => {
|
|
718
|
+
return IntegrationBuilder.rest({
|
|
719
|
+
operations: routerToOperations(appRouter),
|
|
720
|
+
defaultIntegrationOptions: {
|
|
721
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
722
|
+
handler: 'index.handler',
|
|
723
|
+
code: Code.fromAsset(
|
|
724
|
+
url.fileURLToPath(
|
|
725
|
+
new URL(
|
|
726
|
+
'../../../../../../dist/apps/test-api/backend/bundle',
|
|
727
|
+
import.meta.url,
|
|
728
|
+
),
|
|
729
|
+
),
|
|
730
|
+
),
|
|
731
|
+
timeout: Duration.seconds(30),
|
|
732
|
+
tracing: Tracing.ACTIVE,
|
|
733
|
+
environment: {
|
|
734
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
735
|
+
},
|
|
736
|
+
} satisfies FunctionProps,
|
|
737
|
+
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
738
|
+
const handler = new Function(scope, \`TestApi\${op}Handler\`, props);
|
|
739
|
+
return { handler, integration: new LambdaIntegration(handler) };
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
|
|
744
|
+
constructor(
|
|
745
|
+
scope: Construct,
|
|
746
|
+
id: string,
|
|
747
|
+
props: TestApiProps<TIntegrations>,
|
|
748
|
+
) {
|
|
749
|
+
super(scope, id, {
|
|
750
|
+
apiName: 'TestApi',
|
|
751
|
+
defaultMethodOptions: {
|
|
752
|
+
authorizationType: AuthorizationType.NONE,
|
|
753
|
+
},
|
|
754
|
+
defaultCorsPreflightOptions: {
|
|
755
|
+
allowOrigins: Cors.ALL_ORIGINS,
|
|
756
|
+
allowMethods: Cors.ALL_METHODS,
|
|
757
|
+
},
|
|
758
|
+
policy: new PolicyDocument({
|
|
759
|
+
statements: [
|
|
760
|
+
// Allow all callers to invoke the API in the resource policy
|
|
761
|
+
new PolicyStatement({
|
|
762
|
+
effect: Effect.ALLOW,
|
|
763
|
+
principals: [new AnyPrincipal()],
|
|
764
|
+
actions: ['execute-api:Invoke'],
|
|
765
|
+
resources: ['execute-api:/*'],
|
|
766
|
+
}),
|
|
767
|
+
],
|
|
768
|
+
}),
|
|
769
|
+
operations: routerToOperations(appRouter),
|
|
770
|
+
...props,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
271
774
|
"
|
|
272
775
|
`;
|
|
273
776
|
|
|
274
|
-
exports[`trpc backend generator > should generate
|
|
275
|
-
"import {
|
|
276
|
-
|
|
277
|
-
CreateAWSLambdaContextOptions,
|
|
278
|
-
} from '@trpc/server/adapters/aws-lambda';
|
|
279
|
-
import { echo } from './procedures/echo.js';
|
|
280
|
-
import { t } from './init.js';
|
|
281
|
-
import type { APIGatewayProxyEventV2WithIAMAuthorizer } from 'aws-lambda';
|
|
282
|
-
|
|
283
|
-
export const router = t.router;
|
|
284
|
-
|
|
285
|
-
export const appRouter = router({
|
|
286
|
-
echo,
|
|
287
|
-
});
|
|
777
|
+
exports[`trpc backend generator > should generate with no auth for an HTTP API > apps/test-api/backend/src/client/index.ts 1`] = `
|
|
778
|
+
"import { createTRPCClient, httpLink, HTTPLinkOptions } from '@trpc/client';
|
|
779
|
+
import { AppRouter } from '../router.js';
|
|
288
780
|
|
|
289
|
-
export
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
ctx: CreateAWSLambdaContextOptions<APIGatewayProxyEventV2WithIAMAuthorizer>,
|
|
293
|
-
) => ctx,
|
|
294
|
-
});
|
|
781
|
+
export interface TestApiClientConfig {
|
|
782
|
+
readonly url: string;
|
|
783
|
+
}
|
|
295
784
|
|
|
296
|
-
export
|
|
785
|
+
export const createTestApiClient = (config: TestApiClientConfig) => {
|
|
786
|
+
const linkOptions: HTTPLinkOptions<any> = {
|
|
787
|
+
url: config.url,
|
|
788
|
+
};
|
|
789
|
+
return createTRPCClient<AppRouter>({
|
|
790
|
+
links: [httpLink(linkOptions)],
|
|
791
|
+
});
|
|
792
|
+
};
|
|
297
793
|
"
|
|
298
794
|
`;
|
|
299
795
|
|
|
300
|
-
exports[`trpc backend generator > should generate
|
|
301
|
-
"export * from './
|
|
796
|
+
exports[`trpc backend generator > should generate with no auth for an HTTP API > packages/common/constructs/src/app/apis/index.ts 1`] = `
|
|
797
|
+
"export * from './test-api.js';
|
|
302
798
|
"
|
|
303
799
|
`;
|
|
304
800
|
|
|
305
|
-
exports[`trpc backend generator > should generate
|
|
306
|
-
"import {
|
|
801
|
+
exports[`trpc backend generator > should generate with no auth for an HTTP API > packages/common/constructs/src/app/apis/test-api.ts 1`] = `
|
|
802
|
+
"import { Construct } from 'constructs';
|
|
803
|
+
import * as url from 'url';
|
|
804
|
+
import {
|
|
805
|
+
Code,
|
|
806
|
+
Runtime,
|
|
807
|
+
Function,
|
|
808
|
+
FunctionProps,
|
|
809
|
+
Tracing,
|
|
810
|
+
} from 'aws-cdk-lib/aws-lambda';
|
|
811
|
+
import { Duration } from 'aws-cdk-lib';
|
|
812
|
+
import {
|
|
813
|
+
CorsHttpMethod,
|
|
814
|
+
HttpNoneAuthorizer,
|
|
815
|
+
} from 'aws-cdk-lib/aws-apigatewayv2';
|
|
816
|
+
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
817
|
+
import {
|
|
818
|
+
HttpApiIntegration,
|
|
819
|
+
IntegrationBuilder,
|
|
820
|
+
} from '../../core/api/utils.js';
|
|
821
|
+
import { HttpApi } from '../../core/api/http-api.js';
|
|
822
|
+
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
823
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
307
824
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
});
|
|
825
|
+
// String union type for all API operation names
|
|
826
|
+
type Operations = Procedures<AppRouter>;
|
|
311
827
|
|
|
312
|
-
|
|
828
|
+
/**
|
|
829
|
+
* Properties for creating a TestApi construct
|
|
830
|
+
*
|
|
831
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
832
|
+
*/
|
|
833
|
+
export interface TestApiProps<
|
|
834
|
+
TIntegrations extends Record<Operations, HttpApiIntegration>,
|
|
835
|
+
> {
|
|
836
|
+
/**
|
|
837
|
+
* Map of operation names to their API Gateway integrations
|
|
838
|
+
*/
|
|
839
|
+
integrations: TIntegrations;
|
|
840
|
+
}
|
|
313
841
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
842
|
+
/**
|
|
843
|
+
* A CDK construct that creates and configures an AWS API Gateway HTTP API
|
|
844
|
+
* specifically for TestApi.
|
|
845
|
+
* @template TIntegrations - Map of operation names to their integrations
|
|
846
|
+
*/
|
|
847
|
+
export class TestApi<
|
|
848
|
+
TIntegrations extends Record<Operations, HttpApiIntegration>,
|
|
849
|
+
> extends HttpApi<Operations, TIntegrations> {
|
|
850
|
+
/**
|
|
851
|
+
* Creates default integrations for all operations, which implement each operation as
|
|
852
|
+
* its own individual lambda function.
|
|
853
|
+
*
|
|
854
|
+
* @param scope - The CDK construct scope
|
|
855
|
+
* @returns An IntegrationBuilder with default lambda integrations
|
|
856
|
+
*/
|
|
857
|
+
public static defaultIntegrations = (scope: Construct) => {
|
|
858
|
+
return IntegrationBuilder.http({
|
|
859
|
+
operations: routerToOperations(appRouter),
|
|
860
|
+
defaultIntegrationOptions: {
|
|
861
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
862
|
+
handler: 'index.handler',
|
|
863
|
+
code: Code.fromAsset(
|
|
864
|
+
url.fileURLToPath(
|
|
865
|
+
new URL(
|
|
866
|
+
'../../../../../../dist/apps/test-api/backend/bundle',
|
|
867
|
+
import.meta.url,
|
|
868
|
+
),
|
|
869
|
+
),
|
|
870
|
+
),
|
|
871
|
+
timeout: Duration.seconds(30),
|
|
872
|
+
tracing: Tracing.ACTIVE,
|
|
873
|
+
environment: {
|
|
874
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
875
|
+
},
|
|
876
|
+
} satisfies FunctionProps,
|
|
877
|
+
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
878
|
+
const handler = new Function(scope, \`TestApi\${op}Handler\`, props);
|
|
879
|
+
return {
|
|
880
|
+
handler,
|
|
881
|
+
integration: new HttpLambdaIntegration(
|
|
882
|
+
\`TestApi\${op}Integration\`,
|
|
883
|
+
handler,
|
|
884
|
+
),
|
|
885
|
+
};
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
};
|
|
317
889
|
|
|
318
|
-
|
|
890
|
+
constructor(
|
|
891
|
+
scope: Construct,
|
|
892
|
+
id: string,
|
|
893
|
+
props: TestApiProps<TIntegrations>,
|
|
894
|
+
) {
|
|
895
|
+
super(scope, id, {
|
|
896
|
+
apiName: 'TestApi',
|
|
897
|
+
corsPreflight: {
|
|
898
|
+
allowOrigins: ['*'],
|
|
899
|
+
allowMethods: [CorsHttpMethod.ANY],
|
|
900
|
+
allowHeaders: [
|
|
901
|
+
'authorization',
|
|
902
|
+
'content-type',
|
|
903
|
+
'x-amz-content-sha256',
|
|
904
|
+
'x-amz-date',
|
|
905
|
+
'x-amz-security-token',
|
|
906
|
+
],
|
|
907
|
+
},
|
|
908
|
+
defaultAuthorizer: new HttpNoneAuthorizer(),
|
|
909
|
+
operations: routerToOperations(appRouter),
|
|
910
|
+
...props,
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
}
|
|
319
914
|
"
|
|
320
915
|
`;
|
|
321
916
|
|
|
322
917
|
exports[`trpc backend generator > should set up shared constructs for http > http-api.ts 1`] = `
|
|
323
918
|
"import { Construct } from 'constructs';
|
|
324
919
|
import { RuntimeConfig } from '../runtime-config.js';
|
|
325
|
-
import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
326
920
|
import { HttpApiIntegration, OperationDetails } from './utils.js';
|
|
327
921
|
import { CfnOutput } from 'aws-cdk-lib';
|
|
328
922
|
import {
|
|
@@ -389,7 +983,7 @@ export class HttpApi<
|
|
|
389
983
|
super(scope, id);
|
|
390
984
|
this.integrations = integrations;
|
|
391
985
|
|
|
392
|
-
// Create the API Gateway REST API
|
|
986
|
+
// Create the API Gateway REST API
|
|
393
987
|
this.api = new _HttpApi(this, 'Api', {
|
|
394
988
|
...props,
|
|
395
989
|
});
|
|
@@ -418,19 +1012,6 @@ export class HttpApi<
|
|
|
418
1012
|
[apiName]: this.api.url!,
|
|
419
1013
|
};
|
|
420
1014
|
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Grants IAM permissions to invoke any method on this API.
|
|
424
|
-
*
|
|
425
|
-
* @param grantee - The IAM principal to grant permissions to
|
|
426
|
-
*/
|
|
427
|
-
public grantInvokeAccess(grantee: IGrantable) {
|
|
428
|
-
Grant.addToPrincipal({
|
|
429
|
-
grantee,
|
|
430
|
-
actions: ['execute-api:Invoke'],
|
|
431
|
-
resourceArns: [this.api.arnForExecuteApi('*', '/*', '*')],
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
1015
|
}
|
|
435
1016
|
"
|
|
436
1017
|
`;
|
|
@@ -449,13 +1030,14 @@ import { Duration } from 'aws-cdk-lib';
|
|
|
449
1030
|
import { CorsHttpMethod } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
450
1031
|
import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
451
1032
|
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
1033
|
+
import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
452
1034
|
import {
|
|
453
1035
|
HttpApiIntegration,
|
|
454
1036
|
IntegrationBuilder,
|
|
455
1037
|
} from '../../core/api/utils.js';
|
|
456
1038
|
import { HttpApi } from '../../core/api/http-api.js';
|
|
457
1039
|
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
458
|
-
import { AppRouter, appRouter } from ':proj/test-api
|
|
1040
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
459
1041
|
|
|
460
1042
|
// String union type for all API operation names
|
|
461
1043
|
type Operations = Procedures<AppRouter>;
|
|
@@ -545,6 +1127,19 @@ export class TestApi<
|
|
|
545
1127
|
...props,
|
|
546
1128
|
});
|
|
547
1129
|
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Grants IAM permissions to invoke any method on this API.
|
|
1133
|
+
*
|
|
1134
|
+
* @param grantee - The IAM principal to grant permissions to
|
|
1135
|
+
*/
|
|
1136
|
+
public grantInvokeAccess(grantee: IGrantable) {
|
|
1137
|
+
Grant.addToPrincipal({
|
|
1138
|
+
grantee,
|
|
1139
|
+
actions: ['execute-api:Invoke'],
|
|
1140
|
+
resourceArns: [this.api.arnForExecuteApi('*', '/*', '*')],
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
548
1143
|
}
|
|
549
1144
|
"
|
|
550
1145
|
`;
|
|
@@ -858,7 +1453,6 @@ import {
|
|
|
858
1453
|
IResource,
|
|
859
1454
|
} from 'aws-cdk-lib/aws-apigateway';
|
|
860
1455
|
import { RuntimeConfig } from '../runtime-config.js';
|
|
861
|
-
import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
862
1456
|
import { OperationDetails, RestApiIntegration } from './utils.js';
|
|
863
1457
|
|
|
864
1458
|
/**
|
|
@@ -965,19 +1559,6 @@ export class RestApi<
|
|
|
965
1559
|
resource.getResource(nextPathPart) ?? resource.addResource(nextPathPart);
|
|
966
1560
|
return this.getOrCreateResource(childResource, pathParts);
|
|
967
1561
|
}
|
|
968
|
-
|
|
969
|
-
/**
|
|
970
|
-
* Grants IAM permissions to invoke any method on this API.
|
|
971
|
-
*
|
|
972
|
-
* @param grantee - The IAM principal to grant permissions to
|
|
973
|
-
*/
|
|
974
|
-
public grantInvokeAccess(grantee: IGrantable) {
|
|
975
|
-
Grant.addToPrincipal({
|
|
976
|
-
grantee,
|
|
977
|
-
actions: ['execute-api:Invoke'],
|
|
978
|
-
resourceArns: [this.api.arnForExecuteApi('*', '/*', '*')],
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
1562
|
}
|
|
982
1563
|
"
|
|
983
1564
|
`;
|
|
@@ -1002,8 +1583,10 @@ import {
|
|
|
1002
1583
|
PolicyDocument,
|
|
1003
1584
|
PolicyStatement,
|
|
1004
1585
|
Effect,
|
|
1005
|
-
AccountPrincipal,
|
|
1006
1586
|
AnyPrincipal,
|
|
1587
|
+
AccountPrincipal,
|
|
1588
|
+
IGrantable,
|
|
1589
|
+
Grant,
|
|
1007
1590
|
} from 'aws-cdk-lib/aws-iam';
|
|
1008
1591
|
import {
|
|
1009
1592
|
IntegrationBuilder,
|
|
@@ -1011,7 +1594,7 @@ import {
|
|
|
1011
1594
|
} from '../../core/api/utils.js';
|
|
1012
1595
|
import { RestApi } from '../../core/api/rest-api.js';
|
|
1013
1596
|
import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
|
|
1014
|
-
import { AppRouter, appRouter } from ':proj/test-api
|
|
1597
|
+
import { AppRouter, appRouter } from ':proj/test-api';
|
|
1015
1598
|
|
|
1016
1599
|
// String union type for all API operation names
|
|
1017
1600
|
type Operations = Procedures<AppRouter>;
|
|
@@ -1110,6 +1693,19 @@ export class TestApi<
|
|
|
1110
1693
|
...props,
|
|
1111
1694
|
});
|
|
1112
1695
|
}
|
|
1696
|
+
|
|
1697
|
+
/**
|
|
1698
|
+
* Grants IAM permissions to invoke any method on this API.
|
|
1699
|
+
*
|
|
1700
|
+
* @param grantee - The IAM principal to grant permissions to
|
|
1701
|
+
*/
|
|
1702
|
+
public grantInvokeAccess(grantee: IGrantable) {
|
|
1703
|
+
Grant.addToPrincipal({
|
|
1704
|
+
grantee,
|
|
1705
|
+
actions: ['execute-api:Invoke'],
|
|
1706
|
+
resourceArns: [this.api.arnForExecuteApi('*', '/*', '*')],
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1113
1709
|
}
|
|
1114
1710
|
"
|
|
1115
1711
|
`;
|