@jaypie/constructs 1.2.13 → 1.2.15
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/dist/cjs/JaypieDistribution.d.ts +2 -3
- package/dist/cjs/JaypieDynamoDb.d.ts +40 -27
- package/dist/cjs/constants.d.ts +0 -14
- package/dist/cjs/index.cjs +55 -175
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/esm/JaypieDistribution.d.ts +2 -3
- package/dist/esm/JaypieDynamoDb.d.ts +40 -27
- package/dist/esm/constants.d.ts +0 -14
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +56 -174
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/cjs/JaypieStreamingLambda.d.ts +0 -44
- package/dist/cjs/__tests__/JaypieStreamingLambda.spec.d.ts +0 -1
- package/dist/esm/JaypieStreamingLambda.d.ts +0 -44
- package/dist/esm/__tests__/JaypieStreamingLambda.spec.d.ts +0 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CDK
|
|
1
|
+
export { CDK } from "./constants";
|
|
2
2
|
export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
|
|
3
3
|
export { JaypieApiGateway, JaypieApiGatewayProps, } from "./JaypieApiGateway";
|
|
4
4
|
export { JaypieAppStack } from "./JaypieAppStack";
|
|
@@ -10,6 +10,7 @@ export { JaypieDatadogSecret } from "./JaypieDatadogSecret";
|
|
|
10
10
|
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
11
11
|
export { JaypieDnsRecord, JaypieDnsRecordProps } from "./JaypieDnsRecord";
|
|
12
12
|
export { JaypieDynamoDb, JaypieDynamoDbProps } from "./JaypieDynamoDb";
|
|
13
|
+
export type { IndexDefinition } from "@jaypie/fabric";
|
|
13
14
|
export { JaypieEnvSecret } from "./JaypieEnvSecret";
|
|
14
15
|
export { JaypieEventsRule, JaypieEventsRuleProps } from "./JaypieEventsRule";
|
|
15
16
|
export { JaypieExpressLambda } from "./JaypieExpressLambda";
|
|
@@ -26,7 +27,6 @@ export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, }
|
|
|
26
27
|
export { JaypieSsoSyncApplication, JaypieSsoSyncApplicationProps, } from "./JaypieSsoSyncApplication";
|
|
27
28
|
export { JaypieStack, JaypieStackProps } from "./JaypieStack";
|
|
28
29
|
export { JaypieStaticWebBucket, JaypieStaticWebBucketProps, } from "./JaypieStaticWebBucket";
|
|
29
|
-
export { JaypieStreamingLambda, JaypieStreamingLambdaProps, } from "./JaypieStreamingLambda";
|
|
30
30
|
export { JaypieTraceSigningKeySecret } from "./JaypieTraceSigningKeySecret";
|
|
31
31
|
export { JaypieWebDeploymentBucket } from "./JaypieWebDeploymentBucket";
|
|
32
32
|
export * from "./helpers";
|
|
@@ -62,9 +62,8 @@ export interface JaypieDistributionProps extends Omit<cloudfront.DistributionPro
|
|
|
62
62
|
host?: string | HostConfig;
|
|
63
63
|
/**
|
|
64
64
|
* Invoke mode for Lambda Function URLs.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @default InvokeMode.BUFFERED (or auto-detected from handler)
|
|
65
|
+
* Use RESPONSE_STREAM for streaming responses with createLambdaStreamHandler.
|
|
66
|
+
* @default InvokeMode.BUFFERED
|
|
68
67
|
*/
|
|
69
68
|
invokeMode?: lambda.InvokeMode;
|
|
70
69
|
/**
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { RemovalPolicy } from "aws-cdk-lib";
|
|
3
3
|
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
4
|
+
import { type IndexDefinition } from "@jaypie/fabric";
|
|
4
5
|
export interface JaypieDynamoDbProps extends Omit<dynamodb.TablePropsV2, "globalSecondaryIndexes" | "partitionKey" | "sortKey"> {
|
|
5
6
|
/**
|
|
6
|
-
* Configure GSIs for the table.
|
|
7
|
-
* - `undefined
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
7
|
+
* Configure GSIs for the table using @jaypie/fabric IndexDefinition format.
|
|
8
|
+
* - `undefined`: No GSIs (default)
|
|
9
|
+
* - Array of IndexDefinition: Use the specified indexes
|
|
10
|
+
*
|
|
11
|
+
* Use `JaypieDynamoDb.DEFAULT_INDEXES` for the standard Jaypie GSIs.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // No GSIs (default)
|
|
15
|
+
* new JaypieDynamoDb(this, "myTable");
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // With default Jaypie indexes
|
|
19
|
+
* new JaypieDynamoDb(this, "myTable", {
|
|
20
|
+
* indexes: JaypieDynamoDb.DEFAULT_INDEXES,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // With custom indexes
|
|
25
|
+
* new JaypieDynamoDb(this, "myTable", {
|
|
26
|
+
* indexes: [
|
|
27
|
+
* { pk: ["scope", "model"], sk: ["sequence"] },
|
|
28
|
+
* { pk: ["scope", "model", "type"], sk: ["sequence"], sparse: true },
|
|
29
|
+
* ],
|
|
30
|
+
* });
|
|
10
31
|
*/
|
|
11
|
-
|
|
32
|
+
indexes?: IndexDefinition[];
|
|
12
33
|
/**
|
|
13
34
|
* Partition key attribute definition.
|
|
14
35
|
* @default { name: "model", type: AttributeType.STRING }
|
|
@@ -44,43 +65,35 @@ export interface JaypieDynamoDbProps extends Omit<dynamodb.TablePropsV2, "global
|
|
|
44
65
|
* - Sort key: `id` (String)
|
|
45
66
|
* - Billing: PAY_PER_REQUEST (on-demand)
|
|
46
67
|
* - Removal policy: RETAIN in production, DESTROY otherwise
|
|
47
|
-
* -
|
|
68
|
+
* - No GSIs by default (use `indexes` prop to add them)
|
|
69
|
+
* - Table name: CDK-generated (includes stack name and unique suffix)
|
|
48
70
|
*
|
|
49
71
|
* @example
|
|
50
|
-
* // Shorthand:
|
|
72
|
+
* // Shorthand: construct id is "JaypieDynamoDb-myApp", table name is CDK-generated
|
|
51
73
|
* const table = new JaypieDynamoDb(this, "myApp");
|
|
52
74
|
*
|
|
53
75
|
* @example
|
|
54
|
-
* //
|
|
55
|
-
* const table = new JaypieDynamoDb(this, "
|
|
56
|
-
*
|
|
57
|
-
* globalSecondaryIndexes: [], // Disable GSIs
|
|
76
|
+
* // With default Jaypie indexes
|
|
77
|
+
* const table = new JaypieDynamoDb(this, "myApp", {
|
|
78
|
+
* indexes: JaypieDynamoDb.DEFAULT_INDEXES,
|
|
58
79
|
* });
|
|
59
80
|
*
|
|
60
81
|
* @example
|
|
61
|
-
* //
|
|
82
|
+
* // With explicit table name (overrides CDK-generated name)
|
|
62
83
|
* const table = new JaypieDynamoDb(this, "MyTable", {
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
84
|
+
* tableName: "custom-table-name",
|
|
85
|
+
* indexes: [
|
|
86
|
+
* { pk: ["scope", "model"] },
|
|
87
|
+
* { pk: ["scope", "model", "type"], sparse: true },
|
|
66
88
|
* ],
|
|
67
89
|
* });
|
|
68
90
|
*/
|
|
69
91
|
export declare class JaypieDynamoDb extends Construct implements dynamodb.ITableV2 {
|
|
70
92
|
/**
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
static readonly GlobalSecondaryIndex: {
|
|
74
|
-
readonly Alias: dynamodb.GlobalSecondaryIndexPropsV2;
|
|
75
|
-
readonly Class: dynamodb.GlobalSecondaryIndexPropsV2;
|
|
76
|
-
readonly Scope: dynamodb.GlobalSecondaryIndexPropsV2;
|
|
77
|
-
readonly Type: dynamodb.GlobalSecondaryIndexPropsV2;
|
|
78
|
-
readonly Xid: dynamodb.GlobalSecondaryIndexPropsV2;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Array of all default Jaypie GSI definitions
|
|
93
|
+
* Default Jaypie GSI definitions from @jaypie/fabric.
|
|
94
|
+
* Pass to `indexes` prop to create all standard GSIs.
|
|
82
95
|
*/
|
|
83
|
-
static readonly
|
|
96
|
+
static readonly DEFAULT_INDEXES: any;
|
|
84
97
|
private readonly _table;
|
|
85
98
|
constructor(scope: Construct, id: string, props?: JaypieDynamoDbProps);
|
|
86
99
|
/**
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
export declare const LAMBDA_WEB_ADAPTER: {
|
|
2
|
-
ACCOUNT: string;
|
|
3
|
-
DEFAULT_PORT: number;
|
|
4
|
-
EXEC_WRAPPER: string;
|
|
5
|
-
INVOKE_MODE: {
|
|
6
|
-
BUFFERED: string;
|
|
7
|
-
RESPONSE_STREAM: string;
|
|
8
|
-
};
|
|
9
|
-
LAYER: {
|
|
10
|
-
ARM64: string;
|
|
11
|
-
X86: string;
|
|
12
|
-
};
|
|
13
|
-
VERSION: number;
|
|
14
|
-
};
|
|
15
1
|
export declare const CDK: {
|
|
16
2
|
ACCOUNT: {
|
|
17
3
|
DEVELOPMENT: string;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CDK
|
|
1
|
+
export { CDK } from "./constants";
|
|
2
2
|
export { JaypieAccountLoggingBucket, JaypieAccountLoggingBucketProps, } from "./JaypieAccountLoggingBucket";
|
|
3
3
|
export { JaypieApiGateway, JaypieApiGatewayProps, } from "./JaypieApiGateway";
|
|
4
4
|
export { JaypieAppStack } from "./JaypieAppStack";
|
|
@@ -10,6 +10,7 @@ export { JaypieDatadogSecret } from "./JaypieDatadogSecret";
|
|
|
10
10
|
export { JaypieDistribution, JaypieDistributionProps, } from "./JaypieDistribution";
|
|
11
11
|
export { JaypieDnsRecord, JaypieDnsRecordProps } from "./JaypieDnsRecord";
|
|
12
12
|
export { JaypieDynamoDb, JaypieDynamoDbProps } from "./JaypieDynamoDb";
|
|
13
|
+
export type { IndexDefinition } from "@jaypie/fabric";
|
|
13
14
|
export { JaypieEnvSecret } from "./JaypieEnvSecret";
|
|
14
15
|
export { JaypieEventsRule, JaypieEventsRuleProps } from "./JaypieEventsRule";
|
|
15
16
|
export { JaypieExpressLambda } from "./JaypieExpressLambda";
|
|
@@ -26,7 +27,6 @@ export { AccountAssignments, JaypieSsoPermissions, JaypieSsoPermissionsProps, }
|
|
|
26
27
|
export { JaypieSsoSyncApplication, JaypieSsoSyncApplicationProps, } from "./JaypieSsoSyncApplication";
|
|
27
28
|
export { JaypieStack, JaypieStackProps } from "./JaypieStack";
|
|
28
29
|
export { JaypieStaticWebBucket, JaypieStaticWebBucketProps, } from "./JaypieStaticWebBucket";
|
|
29
|
-
export { JaypieStreamingLambda, JaypieStreamingLambdaProps, } from "./JaypieStreamingLambda";
|
|
30
30
|
export { JaypieTraceSigningKeySecret } from "./JaypieTraceSigningKeySecret";
|
|
31
31
|
export { JaypieWebDeploymentBucket } from "./JaypieWebDeploymentBucket";
|
|
32
32
|
export * from "./helpers";
|
package/dist/esm/index.js
CHANGED
|
@@ -25,26 +25,13 @@ import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
|
|
|
25
25
|
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
|
|
26
26
|
import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
27
27
|
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
|
|
28
|
+
import { DEFAULT_INDEXES, generateIndexName, DEFAULT_SORT_KEY } from '@jaypie/fabric';
|
|
28
29
|
import { Nextjs } from 'cdk-nextjs-standalone';
|
|
29
30
|
import * as path from 'path';
|
|
30
31
|
import { Trail, ReadWriteType } from 'aws-cdk-lib/aws-cloudtrail';
|
|
31
32
|
import { CfnPermissionSet, CfnAssignment } from 'aws-cdk-lib/aws-sso';
|
|
32
33
|
import { CfnApplication } from 'aws-cdk-lib/aws-sam';
|
|
33
34
|
|
|
34
|
-
const LAMBDA_WEB_ADAPTER = {
|
|
35
|
-
ACCOUNT: "753240598075",
|
|
36
|
-
DEFAULT_PORT: 8000,
|
|
37
|
-
EXEC_WRAPPER: "/opt/bootstrap",
|
|
38
|
-
INVOKE_MODE: {
|
|
39
|
-
BUFFERED: "BUFFERED",
|
|
40
|
-
RESPONSE_STREAM: "RESPONSE_STREAM",
|
|
41
|
-
},
|
|
42
|
-
LAYER: {
|
|
43
|
-
ARM64: "LambdaAdapterLayerArm64",
|
|
44
|
-
X86: "LambdaAdapterLayerX86",
|
|
45
|
-
},
|
|
46
|
-
VERSION: 25,
|
|
47
|
-
};
|
|
48
35
|
const CDK$2 = {
|
|
49
36
|
ACCOUNT: {
|
|
50
37
|
DEVELOPMENT: "development",
|
|
@@ -750,7 +737,7 @@ function resolveDatadogLayers(scope, options = {}) {
|
|
|
750
737
|
}
|
|
751
738
|
const layerIdSuffix = uniqueId || process.env.PROJECT_NONCE || Date.now().toString();
|
|
752
739
|
// Create Datadog Node.js layer
|
|
753
|
-
const datadogNodeLayer = lambda.LayerVersion.fromLayerVersionArn(scope, `DatadogNodeLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-
|
|
740
|
+
const datadogNodeLayer = lambda.LayerVersion.fromLayerVersionArn(scope, `DatadogNodeLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-Node24-x:${CDK$2.DATADOG.LAYER.NODE}`);
|
|
754
741
|
// Create Datadog Extension layer
|
|
755
742
|
const datadogExtensionLayer = lambda.LayerVersion.fromLayerVersionArn(scope, `DatadogExtensionLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-Extension:${CDK$2.DATADOG.LAYER.EXTENSION}`);
|
|
756
743
|
return [datadogNodeLayer, datadogExtensionLayer];
|
|
@@ -2384,7 +2371,7 @@ class JaypieDistribution extends Construct {
|
|
|
2384
2371
|
// IFunction before IFunctionUrl (IFunction doesn't have functionUrlId)
|
|
2385
2372
|
let origin;
|
|
2386
2373
|
if (handler) {
|
|
2387
|
-
// Auto-detect invoke mode from handler
|
|
2374
|
+
// Auto-detect invoke mode from handler if it has an invokeMode property
|
|
2388
2375
|
// Explicit invokeMode prop takes precedence over auto-detection
|
|
2389
2376
|
const resolvedInvokeMode = invokeMode !== lambda.InvokeMode.BUFFERED
|
|
2390
2377
|
? invokeMode // Explicit non-default value, use it
|
|
@@ -2545,7 +2532,7 @@ class JaypieDistribution extends Construct {
|
|
|
2545
2532
|
!("url" in handler));
|
|
2546
2533
|
}
|
|
2547
2534
|
hasInvokeMode(handler) {
|
|
2548
|
-
// Check if handler has an invokeMode property
|
|
2535
|
+
// Check if handler has an invokeMode property for streaming support
|
|
2549
2536
|
return (typeof handler === "object" &&
|
|
2550
2537
|
handler !== null &&
|
|
2551
2538
|
"invokeMode" in handler &&
|
|
@@ -2683,69 +2670,40 @@ class JaypieDnsRecord extends Construct {
|
|
|
2683
2670
|
//
|
|
2684
2671
|
// Constants
|
|
2685
2672
|
//
|
|
2673
|
+
/** Composite key separator used in GSI partition keys */
|
|
2674
|
+
const SEPARATOR = "#";
|
|
2675
|
+
//
|
|
2676
|
+
//
|
|
2677
|
+
// Helper Functions
|
|
2678
|
+
//
|
|
2686
2679
|
/**
|
|
2687
|
-
*
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
CLASS: "indexClass",
|
|
2692
|
-
SCOPE: "indexScope",
|
|
2693
|
-
TYPE: "indexType",
|
|
2694
|
-
XID: "indexXid",
|
|
2695
|
-
};
|
|
2696
|
-
/**
|
|
2697
|
-
* Individual GSI definitions for Jaypie single-table design.
|
|
2698
|
-
* All GSIs use a string partition key and numeric sort key (sequence).
|
|
2699
|
-
*/
|
|
2700
|
-
const GlobalSecondaryIndex = {
|
|
2701
|
-
Alias: {
|
|
2702
|
-
indexName: GSI_NAMES.ALIAS,
|
|
2703
|
-
partitionKey: {
|
|
2704
|
-
name: GSI_NAMES.ALIAS,
|
|
2705
|
-
type: dynamodb.AttributeType.STRING,
|
|
2706
|
-
},
|
|
2707
|
-
projectionType: dynamodb.ProjectionType.ALL,
|
|
2708
|
-
sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
|
|
2709
|
-
},
|
|
2710
|
-
Class: {
|
|
2711
|
-
indexName: GSI_NAMES.CLASS,
|
|
2712
|
-
partitionKey: {
|
|
2713
|
-
name: GSI_NAMES.CLASS,
|
|
2714
|
-
type: dynamodb.AttributeType.STRING,
|
|
2715
|
-
},
|
|
2716
|
-
projectionType: dynamodb.ProjectionType.ALL,
|
|
2717
|
-
sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
|
|
2718
|
-
},
|
|
2719
|
-
Scope: {
|
|
2720
|
-
indexName: GSI_NAMES.SCOPE,
|
|
2721
|
-
partitionKey: { name: GSI_NAMES.SCOPE, type: dynamodb.AttributeType.STRING },
|
|
2722
|
-
projectionType: dynamodb.ProjectionType.ALL,
|
|
2723
|
-
sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
|
|
2724
|
-
},
|
|
2725
|
-
Type: {
|
|
2726
|
-
indexName: GSI_NAMES.TYPE,
|
|
2727
|
-
partitionKey: { name: GSI_NAMES.TYPE, type: dynamodb.AttributeType.STRING },
|
|
2728
|
-
projectionType: dynamodb.ProjectionType.ALL,
|
|
2729
|
-
sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
|
|
2730
|
-
},
|
|
2731
|
-
Xid: {
|
|
2732
|
-
indexName: GSI_NAMES.XID,
|
|
2733
|
-
partitionKey: { name: GSI_NAMES.XID, type: dynamodb.AttributeType.STRING },
|
|
2734
|
-
projectionType: dynamodb.ProjectionType.ALL,
|
|
2735
|
-
sortKey: { name: "sequence", type: dynamodb.AttributeType.NUMBER },
|
|
2736
|
-
},
|
|
2737
|
-
};
|
|
2738
|
-
/**
|
|
2739
|
-
* Array of all default Jaypie GSI definitions.
|
|
2740
|
-
* Used when no globalSecondaryIndexes are provided.
|
|
2680
|
+
* Convert IndexDefinition[] from @jaypie/fabric to CDK GlobalSecondaryIndexPropsV2[]
|
|
2681
|
+
*
|
|
2682
|
+
* @param indexes - Array of IndexDefinition from @jaypie/fabric
|
|
2683
|
+
* @returns Array of CDK GlobalSecondaryIndexPropsV2
|
|
2741
2684
|
*/
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2685
|
+
function indexesToGsi(indexes) {
|
|
2686
|
+
return indexes.map((index) => {
|
|
2687
|
+
// Generate index name from pk fields if not provided
|
|
2688
|
+
const indexName = index.name ?? generateIndexName(index.pk);
|
|
2689
|
+
// Sort key defaults to ["sequence"] if not provided
|
|
2690
|
+
const skFields = index.sk ?? DEFAULT_SORT_KEY;
|
|
2691
|
+
return {
|
|
2692
|
+
indexName,
|
|
2693
|
+
partitionKey: {
|
|
2694
|
+
name: indexName,
|
|
2695
|
+
type: dynamodb.AttributeType.STRING,
|
|
2696
|
+
},
|
|
2697
|
+
projectionType: dynamodb.ProjectionType.ALL,
|
|
2698
|
+
sortKey: skFields.length === 1 && skFields[0] === "sequence"
|
|
2699
|
+
? { name: "sequence", type: dynamodb.AttributeType.NUMBER }
|
|
2700
|
+
: {
|
|
2701
|
+
name: skFields.join(SEPARATOR),
|
|
2702
|
+
type: dynamodb.AttributeType.STRING,
|
|
2703
|
+
},
|
|
2704
|
+
};
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2749
2707
|
//
|
|
2750
2708
|
//
|
|
2751
2709
|
// Main
|
|
@@ -2758,55 +2716,51 @@ const GlobalSecondaryIndexes = [
|
|
|
2758
2716
|
* - Sort key: `id` (String)
|
|
2759
2717
|
* - Billing: PAY_PER_REQUEST (on-demand)
|
|
2760
2718
|
* - Removal policy: RETAIN in production, DESTROY otherwise
|
|
2761
|
-
* -
|
|
2719
|
+
* - No GSIs by default (use `indexes` prop to add them)
|
|
2720
|
+
* - Table name: CDK-generated (includes stack name and unique suffix)
|
|
2762
2721
|
*
|
|
2763
2722
|
* @example
|
|
2764
|
-
* // Shorthand:
|
|
2723
|
+
* // Shorthand: construct id is "JaypieDynamoDb-myApp", table name is CDK-generated
|
|
2765
2724
|
* const table = new JaypieDynamoDb(this, "myApp");
|
|
2766
2725
|
*
|
|
2767
2726
|
* @example
|
|
2768
|
-
* //
|
|
2769
|
-
* const table = new JaypieDynamoDb(this, "
|
|
2770
|
-
*
|
|
2771
|
-
* globalSecondaryIndexes: [], // Disable GSIs
|
|
2727
|
+
* // With default Jaypie indexes
|
|
2728
|
+
* const table = new JaypieDynamoDb(this, "myApp", {
|
|
2729
|
+
* indexes: JaypieDynamoDb.DEFAULT_INDEXES,
|
|
2772
2730
|
* });
|
|
2773
2731
|
*
|
|
2774
2732
|
* @example
|
|
2775
|
-
* //
|
|
2733
|
+
* // With explicit table name (overrides CDK-generated name)
|
|
2776
2734
|
* const table = new JaypieDynamoDb(this, "MyTable", {
|
|
2777
|
-
*
|
|
2778
|
-
*
|
|
2779
|
-
*
|
|
2735
|
+
* tableName: "custom-table-name",
|
|
2736
|
+
* indexes: [
|
|
2737
|
+
* { pk: ["scope", "model"] },
|
|
2738
|
+
* { pk: ["scope", "model", "type"], sparse: true },
|
|
2780
2739
|
* ],
|
|
2781
2740
|
* });
|
|
2782
2741
|
*/
|
|
2783
2742
|
class JaypieDynamoDb extends Construct {
|
|
2784
2743
|
constructor(scope, id, props = {}) {
|
|
2785
2744
|
// Determine if this is shorthand usage: new JaypieDynamoDb(this, "myApp")
|
|
2786
|
-
// In shorthand, id
|
|
2745
|
+
// In shorthand, construct id is prefixed for clarity; tableName left undefined
|
|
2746
|
+
// so CDK generates it with stack prefix (e.g., cdk-sponsor-project-env-nonce-app-JaypieDynamoDb-myApp-Table-XXXXX)
|
|
2787
2747
|
const isShorthand = !props.tableName && !id.includes("-");
|
|
2788
2748
|
const constructId = isShorthand ? `JaypieDynamoDb-${id}` : id;
|
|
2789
|
-
const tableName = props.tableName ?? (isShorthand ? id : undefined);
|
|
2790
2749
|
super(scope, constructId);
|
|
2791
|
-
const { billing = dynamodb.Billing.onDemand(),
|
|
2750
|
+
const { billing = dynamodb.Billing.onDemand(), indexes, partitionKey = {
|
|
2792
2751
|
name: "model",
|
|
2793
2752
|
type: dynamodb.AttributeType.STRING,
|
|
2794
2753
|
}, project, removalPolicy = isProductionEnv()
|
|
2795
2754
|
? RemovalPolicy.RETAIN
|
|
2796
2755
|
: RemovalPolicy.DESTROY, roleTag = CDK$2.ROLE.STORAGE, service, sortKey = { name: "id", type: dynamodb.AttributeType.STRING }, vendorTag, ...restProps } = props;
|
|
2797
|
-
//
|
|
2798
|
-
const globalSecondaryIndexes =
|
|
2799
|
-
? undefined
|
|
2800
|
-
: Array.isArray(gsiInput)
|
|
2801
|
-
? gsiInput
|
|
2802
|
-
: GlobalSecondaryIndexes;
|
|
2756
|
+
// Convert IndexDefinition[] to CDK GSI props
|
|
2757
|
+
const globalSecondaryIndexes = indexes ? indexesToGsi(indexes) : undefined;
|
|
2803
2758
|
this._table = new dynamodb.TableV2(this, "Table", {
|
|
2804
2759
|
billing,
|
|
2805
2760
|
globalSecondaryIndexes,
|
|
2806
2761
|
partitionKey,
|
|
2807
2762
|
removalPolicy,
|
|
2808
2763
|
sortKey,
|
|
2809
|
-
tableName,
|
|
2810
2764
|
...restProps,
|
|
2811
2765
|
});
|
|
2812
2766
|
// Apply tags
|
|
@@ -2912,13 +2866,10 @@ class JaypieDynamoDb extends Construct {
|
|
|
2912
2866
|
}
|
|
2913
2867
|
}
|
|
2914
2868
|
/**
|
|
2915
|
-
*
|
|
2869
|
+
* Default Jaypie GSI definitions from @jaypie/fabric.
|
|
2870
|
+
* Pass to `indexes` prop to create all standard GSIs.
|
|
2916
2871
|
*/
|
|
2917
|
-
JaypieDynamoDb.
|
|
2918
|
-
/**
|
|
2919
|
-
* Array of all default Jaypie GSI definitions
|
|
2920
|
-
*/
|
|
2921
|
-
JaypieDynamoDb.GlobalSecondaryIndexes = GlobalSecondaryIndexes;
|
|
2872
|
+
JaypieDynamoDb.DEFAULT_INDEXES = DEFAULT_INDEXES;
|
|
2922
2873
|
|
|
2923
2874
|
class JaypieEventsRule extends Construct {
|
|
2924
2875
|
/**
|
|
@@ -4134,75 +4085,6 @@ class JaypieStaticWebBucket extends JaypieWebDeploymentBucket {
|
|
|
4134
4085
|
}
|
|
4135
4086
|
}
|
|
4136
4087
|
|
|
4137
|
-
/**
|
|
4138
|
-
* A Lambda construct that uses AWS Lambda Web Adapter for streaming support.
|
|
4139
|
-
* This allows running web applications (Express, Fastify, etc.) with streaming responses.
|
|
4140
|
-
*
|
|
4141
|
-
* @example
|
|
4142
|
-
* ```typescript
|
|
4143
|
-
* const streamingLambda = new JaypieStreamingLambda(this, "StreamingApi", {
|
|
4144
|
-
* code: "dist/api",
|
|
4145
|
-
* handler: "run.sh",
|
|
4146
|
-
* streaming: true,
|
|
4147
|
-
* });
|
|
4148
|
-
*
|
|
4149
|
-
* // Use with JaypieDistribution
|
|
4150
|
-
* new JaypieDistribution(this, "Distribution", {
|
|
4151
|
-
* handler: streamingLambda,
|
|
4152
|
-
* invokeMode: streamingLambda.invokeMode,
|
|
4153
|
-
* });
|
|
4154
|
-
* ```
|
|
4155
|
-
*/
|
|
4156
|
-
class JaypieStreamingLambda extends JaypieLambda {
|
|
4157
|
-
constructor(scope, id, props) {
|
|
4158
|
-
const { architecture = lambda.Architecture.X86_64, environment: propsEnvironment, layers: propsLayers = [], port = LAMBDA_WEB_ADAPTER.DEFAULT_PORT, streaming = false, ...restProps } = props;
|
|
4159
|
-
// Determine the Lambda Web Adapter layer ARN based on architecture
|
|
4160
|
-
const region = Stack.of(scope).region;
|
|
4161
|
-
const layerArn = architecture === lambda.Architecture.ARM_64
|
|
4162
|
-
? `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.ARM64}:${LAMBDA_WEB_ADAPTER.VERSION}`
|
|
4163
|
-
: `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.X86}:${LAMBDA_WEB_ADAPTER.VERSION}`;
|
|
4164
|
-
// Create the Lambda Web Adapter layer
|
|
4165
|
-
const webAdapterLayer = lambda.LayerVersion.fromLayerVersionArn(scope, `${id}WebAdapterLayer`, layerArn);
|
|
4166
|
-
// Build environment variables with Lambda Web Adapter configuration
|
|
4167
|
-
const lwaInvokeMode = streaming
|
|
4168
|
-
? LAMBDA_WEB_ADAPTER.INVOKE_MODE.RESPONSE_STREAM
|
|
4169
|
-
: LAMBDA_WEB_ADAPTER.INVOKE_MODE.BUFFERED;
|
|
4170
|
-
const webAdapterEnvironment = {
|
|
4171
|
-
AWS_LAMBDA_EXEC_WRAPPER: LAMBDA_WEB_ADAPTER.EXEC_WRAPPER,
|
|
4172
|
-
AWS_LWA_INVOKE_MODE: lwaInvokeMode,
|
|
4173
|
-
PORT: String(port),
|
|
4174
|
-
};
|
|
4175
|
-
// Merge environment variables - props environment takes precedence
|
|
4176
|
-
let mergedEnvironment;
|
|
4177
|
-
if (Array.isArray(propsEnvironment)) {
|
|
4178
|
-
// Array syntax: prepend our object to the array
|
|
4179
|
-
mergedEnvironment = [webAdapterEnvironment, ...propsEnvironment];
|
|
4180
|
-
}
|
|
4181
|
-
else if (propsEnvironment && typeof propsEnvironment === "object") {
|
|
4182
|
-
// Object syntax: merge objects
|
|
4183
|
-
mergedEnvironment = {
|
|
4184
|
-
...webAdapterEnvironment,
|
|
4185
|
-
...propsEnvironment,
|
|
4186
|
-
};
|
|
4187
|
-
}
|
|
4188
|
-
else {
|
|
4189
|
-
mergedEnvironment = webAdapterEnvironment;
|
|
4190
|
-
}
|
|
4191
|
-
super(scope, id, {
|
|
4192
|
-
architecture,
|
|
4193
|
-
environment: mergedEnvironment,
|
|
4194
|
-
layers: [webAdapterLayer, ...propsLayers],
|
|
4195
|
-
roleTag: CDK$2.ROLE.API,
|
|
4196
|
-
timeout: Duration.seconds(CDK$2.DURATION.EXPRESS_API),
|
|
4197
|
-
...restProps,
|
|
4198
|
-
});
|
|
4199
|
-
// Set invoke mode for use with JaypieDistribution
|
|
4200
|
-
this.invokeMode = streaming
|
|
4201
|
-
? lambda.InvokeMode.RESPONSE_STREAM
|
|
4202
|
-
: lambda.InvokeMode.BUFFERED;
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
|
-
|
|
4206
4088
|
class JaypieTraceSigningKeySecret extends JaypieEnvSecret {
|
|
4207
4089
|
constructor(scope, id = "TraceSigningKey", props) {
|
|
4208
4090
|
const defaultProps = {
|
|
@@ -4215,5 +4097,5 @@ class JaypieTraceSigningKeySecret extends JaypieEnvSecret {
|
|
|
4215
4097
|
}
|
|
4216
4098
|
}
|
|
4217
4099
|
|
|
4218
|
-
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieCertificate, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket,
|
|
4100
|
+
export { CDK$2 as CDK, JaypieAccountLoggingBucket, JaypieApiGateway, JaypieAppStack, JaypieBucketQueuedLambda, JaypieCertificate, JaypieDatadogBucket, JaypieDatadogForwarder, JaypieDatadogSecret, JaypieDistribution, JaypieDnsRecord, JaypieDynamoDb, JaypieEnvSecret, JaypieEventsRule, JaypieExpressLambda, JaypieGitHubDeployRole, JaypieHostedZone, JaypieInfrastructureStack, JaypieLambda, JaypieMongoDbSecret, JaypieNextJs, JaypieOpenAiSecret, JaypieOrganizationTrail, JaypieQueuedLambda, JaypieSsoPermissions, JaypieSsoSyncApplication, JaypieStack, JaypieStaticWebBucket, JaypieTraceSigningKeySecret, JaypieWebDeploymentBucket, addDatadogLayers, clearAllCertificateCaches, clearAllSecretsCaches, clearCertificateCache, clearSecretsCache, constructEnvName, constructStackName, constructTagger, envHostname, extendDatadogRole, isEnv, isProductionEnv, isSandboxEnv, isValidHostname$1 as isValidHostname, isValidSubdomain, jaypieLambdaEnv, mergeDomain, resolveCertificate, resolveDatadogForwarderFunction, resolveDatadogLayers, resolveDatadogLoggingDestination, resolveEnvironment, resolveHostedZone, resolveParamsAndSecrets, resolveSecrets };
|
|
4219
4101
|
//# sourceMappingURL=index.js.map
|