@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
|
@@ -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/cjs/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/cjs/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var awsEventsTargets = require('aws-cdk-lib/aws-events-targets');
|
|
|
22
22
|
var cloudfront = require('aws-cdk-lib/aws-cloudfront');
|
|
23
23
|
var origins = require('aws-cdk-lib/aws-cloudfront-origins');
|
|
24
24
|
var dynamodb = require('aws-cdk-lib/aws-dynamodb');
|
|
25
|
+
var fabric = require('@jaypie/fabric');
|
|
25
26
|
var cdkNextjsStandalone = require('cdk-nextjs-standalone');
|
|
26
27
|
var path = require('path');
|
|
27
28
|
var awsCloudtrail = require('aws-cdk-lib/aws-cloudtrail');
|
|
@@ -63,20 +64,6 @@ var origins__namespace = /*#__PURE__*/_interopNamespaceDefault(origins);
|
|
|
63
64
|
var dynamodb__namespace = /*#__PURE__*/_interopNamespaceDefault(dynamodb);
|
|
64
65
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
65
66
|
|
|
66
|
-
const LAMBDA_WEB_ADAPTER = {
|
|
67
|
-
ACCOUNT: "753240598075",
|
|
68
|
-
DEFAULT_PORT: 8000,
|
|
69
|
-
EXEC_WRAPPER: "/opt/bootstrap",
|
|
70
|
-
INVOKE_MODE: {
|
|
71
|
-
BUFFERED: "BUFFERED",
|
|
72
|
-
RESPONSE_STREAM: "RESPONSE_STREAM",
|
|
73
|
-
},
|
|
74
|
-
LAYER: {
|
|
75
|
-
ARM64: "LambdaAdapterLayerArm64",
|
|
76
|
-
X86: "LambdaAdapterLayerX86",
|
|
77
|
-
},
|
|
78
|
-
VERSION: 25,
|
|
79
|
-
};
|
|
80
67
|
const CDK$2 = {
|
|
81
68
|
ACCOUNT: {
|
|
82
69
|
DEVELOPMENT: "development",
|
|
@@ -782,7 +769,7 @@ function resolveDatadogLayers(scope, options = {}) {
|
|
|
782
769
|
}
|
|
783
770
|
const layerIdSuffix = uniqueId || process.env.PROJECT_NONCE || Date.now().toString();
|
|
784
771
|
// Create Datadog Node.js layer
|
|
785
|
-
const datadogNodeLayer = lambda__namespace.LayerVersion.fromLayerVersionArn(scope, `DatadogNodeLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-
|
|
772
|
+
const datadogNodeLayer = lambda__namespace.LayerVersion.fromLayerVersionArn(scope, `DatadogNodeLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-Node24-x:${CDK$2.DATADOG.LAYER.NODE}`);
|
|
786
773
|
// Create Datadog Extension layer
|
|
787
774
|
const datadogExtensionLayer = lambda__namespace.LayerVersion.fromLayerVersionArn(scope, `DatadogExtensionLayer-${layerIdSuffix}`, `arn:aws:lambda:${resolvedRegion}:464622532012:layer:Datadog-Extension:${CDK$2.DATADOG.LAYER.EXTENSION}`);
|
|
788
775
|
return [datadogNodeLayer, datadogExtensionLayer];
|
|
@@ -2416,7 +2403,7 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
2416
2403
|
// IFunction before IFunctionUrl (IFunction doesn't have functionUrlId)
|
|
2417
2404
|
let origin;
|
|
2418
2405
|
if (handler) {
|
|
2419
|
-
// Auto-detect invoke mode from handler
|
|
2406
|
+
// Auto-detect invoke mode from handler if it has an invokeMode property
|
|
2420
2407
|
// Explicit invokeMode prop takes precedence over auto-detection
|
|
2421
2408
|
const resolvedInvokeMode = invokeMode !== lambda__namespace.InvokeMode.BUFFERED
|
|
2422
2409
|
? invokeMode // Explicit non-default value, use it
|
|
@@ -2577,7 +2564,7 @@ class JaypieDistribution extends constructs.Construct {
|
|
|
2577
2564
|
!("url" in handler));
|
|
2578
2565
|
}
|
|
2579
2566
|
hasInvokeMode(handler) {
|
|
2580
|
-
// Check if handler has an invokeMode property
|
|
2567
|
+
// Check if handler has an invokeMode property for streaming support
|
|
2581
2568
|
return (typeof handler === "object" &&
|
|
2582
2569
|
handler !== null &&
|
|
2583
2570
|
"invokeMode" in handler &&
|
|
@@ -2715,69 +2702,40 @@ class JaypieDnsRecord extends constructs.Construct {
|
|
|
2715
2702
|
//
|
|
2716
2703
|
// Constants
|
|
2717
2704
|
//
|
|
2705
|
+
/** Composite key separator used in GSI partition keys */
|
|
2706
|
+
const SEPARATOR = "#";
|
|
2707
|
+
//
|
|
2708
|
+
//
|
|
2709
|
+
// Helper Functions
|
|
2710
|
+
//
|
|
2718
2711
|
/**
|
|
2719
|
-
*
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
CLASS: "indexClass",
|
|
2724
|
-
SCOPE: "indexScope",
|
|
2725
|
-
TYPE: "indexType",
|
|
2726
|
-
XID: "indexXid",
|
|
2727
|
-
};
|
|
2728
|
-
/**
|
|
2729
|
-
* Individual GSI definitions for Jaypie single-table design.
|
|
2730
|
-
* All GSIs use a string partition key and numeric sort key (sequence).
|
|
2731
|
-
*/
|
|
2732
|
-
const GlobalSecondaryIndex = {
|
|
2733
|
-
Alias: {
|
|
2734
|
-
indexName: GSI_NAMES.ALIAS,
|
|
2735
|
-
partitionKey: {
|
|
2736
|
-
name: GSI_NAMES.ALIAS,
|
|
2737
|
-
type: dynamodb__namespace.AttributeType.STRING,
|
|
2738
|
-
},
|
|
2739
|
-
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2740
|
-
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2741
|
-
},
|
|
2742
|
-
Class: {
|
|
2743
|
-
indexName: GSI_NAMES.CLASS,
|
|
2744
|
-
partitionKey: {
|
|
2745
|
-
name: GSI_NAMES.CLASS,
|
|
2746
|
-
type: dynamodb__namespace.AttributeType.STRING,
|
|
2747
|
-
},
|
|
2748
|
-
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2749
|
-
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2750
|
-
},
|
|
2751
|
-
Scope: {
|
|
2752
|
-
indexName: GSI_NAMES.SCOPE,
|
|
2753
|
-
partitionKey: { name: GSI_NAMES.SCOPE, type: dynamodb__namespace.AttributeType.STRING },
|
|
2754
|
-
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2755
|
-
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2756
|
-
},
|
|
2757
|
-
Type: {
|
|
2758
|
-
indexName: GSI_NAMES.TYPE,
|
|
2759
|
-
partitionKey: { name: GSI_NAMES.TYPE, type: dynamodb__namespace.AttributeType.STRING },
|
|
2760
|
-
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2761
|
-
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2762
|
-
},
|
|
2763
|
-
Xid: {
|
|
2764
|
-
indexName: GSI_NAMES.XID,
|
|
2765
|
-
partitionKey: { name: GSI_NAMES.XID, type: dynamodb__namespace.AttributeType.STRING },
|
|
2766
|
-
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2767
|
-
sortKey: { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER },
|
|
2768
|
-
},
|
|
2769
|
-
};
|
|
2770
|
-
/**
|
|
2771
|
-
* Array of all default Jaypie GSI definitions.
|
|
2772
|
-
* Used when no globalSecondaryIndexes are provided.
|
|
2712
|
+
* Convert IndexDefinition[] from @jaypie/fabric to CDK GlobalSecondaryIndexPropsV2[]
|
|
2713
|
+
*
|
|
2714
|
+
* @param indexes - Array of IndexDefinition from @jaypie/fabric
|
|
2715
|
+
* @returns Array of CDK GlobalSecondaryIndexPropsV2
|
|
2773
2716
|
*/
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2717
|
+
function indexesToGsi(indexes) {
|
|
2718
|
+
return indexes.map((index) => {
|
|
2719
|
+
// Generate index name from pk fields if not provided
|
|
2720
|
+
const indexName = index.name ?? fabric.generateIndexName(index.pk);
|
|
2721
|
+
// Sort key defaults to ["sequence"] if not provided
|
|
2722
|
+
const skFields = index.sk ?? fabric.DEFAULT_SORT_KEY;
|
|
2723
|
+
return {
|
|
2724
|
+
indexName,
|
|
2725
|
+
partitionKey: {
|
|
2726
|
+
name: indexName,
|
|
2727
|
+
type: dynamodb__namespace.AttributeType.STRING,
|
|
2728
|
+
},
|
|
2729
|
+
projectionType: dynamodb__namespace.ProjectionType.ALL,
|
|
2730
|
+
sortKey: skFields.length === 1 && skFields[0] === "sequence"
|
|
2731
|
+
? { name: "sequence", type: dynamodb__namespace.AttributeType.NUMBER }
|
|
2732
|
+
: {
|
|
2733
|
+
name: skFields.join(SEPARATOR),
|
|
2734
|
+
type: dynamodb__namespace.AttributeType.STRING,
|
|
2735
|
+
},
|
|
2736
|
+
};
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2781
2739
|
//
|
|
2782
2740
|
//
|
|
2783
2741
|
// Main
|
|
@@ -2790,55 +2748,51 @@ const GlobalSecondaryIndexes = [
|
|
|
2790
2748
|
* - Sort key: `id` (String)
|
|
2791
2749
|
* - Billing: PAY_PER_REQUEST (on-demand)
|
|
2792
2750
|
* - Removal policy: RETAIN in production, DESTROY otherwise
|
|
2793
|
-
* -
|
|
2751
|
+
* - No GSIs by default (use `indexes` prop to add them)
|
|
2752
|
+
* - Table name: CDK-generated (includes stack name and unique suffix)
|
|
2794
2753
|
*
|
|
2795
2754
|
* @example
|
|
2796
|
-
* // Shorthand:
|
|
2755
|
+
* // Shorthand: construct id is "JaypieDynamoDb-myApp", table name is CDK-generated
|
|
2797
2756
|
* const table = new JaypieDynamoDb(this, "myApp");
|
|
2798
2757
|
*
|
|
2799
2758
|
* @example
|
|
2800
|
-
* //
|
|
2801
|
-
* const table = new JaypieDynamoDb(this, "
|
|
2802
|
-
*
|
|
2803
|
-
* globalSecondaryIndexes: [], // Disable GSIs
|
|
2759
|
+
* // With default Jaypie indexes
|
|
2760
|
+
* const table = new JaypieDynamoDb(this, "myApp", {
|
|
2761
|
+
* indexes: JaypieDynamoDb.DEFAULT_INDEXES,
|
|
2804
2762
|
* });
|
|
2805
2763
|
*
|
|
2806
2764
|
* @example
|
|
2807
|
-
* //
|
|
2765
|
+
* // With explicit table name (overrides CDK-generated name)
|
|
2808
2766
|
* const table = new JaypieDynamoDb(this, "MyTable", {
|
|
2809
|
-
*
|
|
2810
|
-
*
|
|
2811
|
-
*
|
|
2767
|
+
* tableName: "custom-table-name",
|
|
2768
|
+
* indexes: [
|
|
2769
|
+
* { pk: ["scope", "model"] },
|
|
2770
|
+
* { pk: ["scope", "model", "type"], sparse: true },
|
|
2812
2771
|
* ],
|
|
2813
2772
|
* });
|
|
2814
2773
|
*/
|
|
2815
2774
|
class JaypieDynamoDb extends constructs.Construct {
|
|
2816
2775
|
constructor(scope, id, props = {}) {
|
|
2817
2776
|
// Determine if this is shorthand usage: new JaypieDynamoDb(this, "myApp")
|
|
2818
|
-
// In shorthand, id
|
|
2777
|
+
// In shorthand, construct id is prefixed for clarity; tableName left undefined
|
|
2778
|
+
// so CDK generates it with stack prefix (e.g., cdk-sponsor-project-env-nonce-app-JaypieDynamoDb-myApp-Table-XXXXX)
|
|
2819
2779
|
const isShorthand = !props.tableName && !id.includes("-");
|
|
2820
2780
|
const constructId = isShorthand ? `JaypieDynamoDb-${id}` : id;
|
|
2821
|
-
const tableName = props.tableName ?? (isShorthand ? id : undefined);
|
|
2822
2781
|
super(scope, constructId);
|
|
2823
|
-
const { billing = dynamodb__namespace.Billing.onDemand(),
|
|
2782
|
+
const { billing = dynamodb__namespace.Billing.onDemand(), indexes, partitionKey = {
|
|
2824
2783
|
name: "model",
|
|
2825
2784
|
type: dynamodb__namespace.AttributeType.STRING,
|
|
2826
2785
|
}, project, removalPolicy = isProductionEnv()
|
|
2827
2786
|
? cdk.RemovalPolicy.RETAIN
|
|
2828
2787
|
: cdk.RemovalPolicy.DESTROY, roleTag = CDK$2.ROLE.STORAGE, service, sortKey = { name: "id", type: dynamodb__namespace.AttributeType.STRING }, vendorTag, ...restProps } = props;
|
|
2829
|
-
//
|
|
2830
|
-
const globalSecondaryIndexes =
|
|
2831
|
-
? undefined
|
|
2832
|
-
: Array.isArray(gsiInput)
|
|
2833
|
-
? gsiInput
|
|
2834
|
-
: GlobalSecondaryIndexes;
|
|
2788
|
+
// Convert IndexDefinition[] to CDK GSI props
|
|
2789
|
+
const globalSecondaryIndexes = indexes ? indexesToGsi(indexes) : undefined;
|
|
2835
2790
|
this._table = new dynamodb__namespace.TableV2(this, "Table", {
|
|
2836
2791
|
billing,
|
|
2837
2792
|
globalSecondaryIndexes,
|
|
2838
2793
|
partitionKey,
|
|
2839
2794
|
removalPolicy,
|
|
2840
2795
|
sortKey,
|
|
2841
|
-
tableName,
|
|
2842
2796
|
...restProps,
|
|
2843
2797
|
});
|
|
2844
2798
|
// Apply tags
|
|
@@ -2944,13 +2898,10 @@ class JaypieDynamoDb extends constructs.Construct {
|
|
|
2944
2898
|
}
|
|
2945
2899
|
}
|
|
2946
2900
|
/**
|
|
2947
|
-
*
|
|
2901
|
+
* Default Jaypie GSI definitions from @jaypie/fabric.
|
|
2902
|
+
* Pass to `indexes` prop to create all standard GSIs.
|
|
2948
2903
|
*/
|
|
2949
|
-
JaypieDynamoDb.
|
|
2950
|
-
/**
|
|
2951
|
-
* Array of all default Jaypie GSI definitions
|
|
2952
|
-
*/
|
|
2953
|
-
JaypieDynamoDb.GlobalSecondaryIndexes = GlobalSecondaryIndexes;
|
|
2904
|
+
JaypieDynamoDb.DEFAULT_INDEXES = fabric.DEFAULT_INDEXES;
|
|
2954
2905
|
|
|
2955
2906
|
class JaypieEventsRule extends constructs.Construct {
|
|
2956
2907
|
/**
|
|
@@ -4166,75 +4117,6 @@ class JaypieStaticWebBucket extends JaypieWebDeploymentBucket {
|
|
|
4166
4117
|
}
|
|
4167
4118
|
}
|
|
4168
4119
|
|
|
4169
|
-
/**
|
|
4170
|
-
* A Lambda construct that uses AWS Lambda Web Adapter for streaming support.
|
|
4171
|
-
* This allows running web applications (Express, Fastify, etc.) with streaming responses.
|
|
4172
|
-
*
|
|
4173
|
-
* @example
|
|
4174
|
-
* ```typescript
|
|
4175
|
-
* const streamingLambda = new JaypieStreamingLambda(this, "StreamingApi", {
|
|
4176
|
-
* code: "dist/api",
|
|
4177
|
-
* handler: "run.sh",
|
|
4178
|
-
* streaming: true,
|
|
4179
|
-
* });
|
|
4180
|
-
*
|
|
4181
|
-
* // Use with JaypieDistribution
|
|
4182
|
-
* new JaypieDistribution(this, "Distribution", {
|
|
4183
|
-
* handler: streamingLambda,
|
|
4184
|
-
* invokeMode: streamingLambda.invokeMode,
|
|
4185
|
-
* });
|
|
4186
|
-
* ```
|
|
4187
|
-
*/
|
|
4188
|
-
class JaypieStreamingLambda extends JaypieLambda {
|
|
4189
|
-
constructor(scope, id, props) {
|
|
4190
|
-
const { architecture = lambda__namespace.Architecture.X86_64, environment: propsEnvironment, layers: propsLayers = [], port = LAMBDA_WEB_ADAPTER.DEFAULT_PORT, streaming = false, ...restProps } = props;
|
|
4191
|
-
// Determine the Lambda Web Adapter layer ARN based on architecture
|
|
4192
|
-
const region = cdk.Stack.of(scope).region;
|
|
4193
|
-
const layerArn = architecture === lambda__namespace.Architecture.ARM_64
|
|
4194
|
-
? `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.ARM64}:${LAMBDA_WEB_ADAPTER.VERSION}`
|
|
4195
|
-
: `arn:aws:lambda:${region}:${LAMBDA_WEB_ADAPTER.ACCOUNT}:layer:${LAMBDA_WEB_ADAPTER.LAYER.X86}:${LAMBDA_WEB_ADAPTER.VERSION}`;
|
|
4196
|
-
// Create the Lambda Web Adapter layer
|
|
4197
|
-
const webAdapterLayer = lambda__namespace.LayerVersion.fromLayerVersionArn(scope, `${id}WebAdapterLayer`, layerArn);
|
|
4198
|
-
// Build environment variables with Lambda Web Adapter configuration
|
|
4199
|
-
const lwaInvokeMode = streaming
|
|
4200
|
-
? LAMBDA_WEB_ADAPTER.INVOKE_MODE.RESPONSE_STREAM
|
|
4201
|
-
: LAMBDA_WEB_ADAPTER.INVOKE_MODE.BUFFERED;
|
|
4202
|
-
const webAdapterEnvironment = {
|
|
4203
|
-
AWS_LAMBDA_EXEC_WRAPPER: LAMBDA_WEB_ADAPTER.EXEC_WRAPPER,
|
|
4204
|
-
AWS_LWA_INVOKE_MODE: lwaInvokeMode,
|
|
4205
|
-
PORT: String(port),
|
|
4206
|
-
};
|
|
4207
|
-
// Merge environment variables - props environment takes precedence
|
|
4208
|
-
let mergedEnvironment;
|
|
4209
|
-
if (Array.isArray(propsEnvironment)) {
|
|
4210
|
-
// Array syntax: prepend our object to the array
|
|
4211
|
-
mergedEnvironment = [webAdapterEnvironment, ...propsEnvironment];
|
|
4212
|
-
}
|
|
4213
|
-
else if (propsEnvironment && typeof propsEnvironment === "object") {
|
|
4214
|
-
// Object syntax: merge objects
|
|
4215
|
-
mergedEnvironment = {
|
|
4216
|
-
...webAdapterEnvironment,
|
|
4217
|
-
...propsEnvironment,
|
|
4218
|
-
};
|
|
4219
|
-
}
|
|
4220
|
-
else {
|
|
4221
|
-
mergedEnvironment = webAdapterEnvironment;
|
|
4222
|
-
}
|
|
4223
|
-
super(scope, id, {
|
|
4224
|
-
architecture,
|
|
4225
|
-
environment: mergedEnvironment,
|
|
4226
|
-
layers: [webAdapterLayer, ...propsLayers],
|
|
4227
|
-
roleTag: CDK$2.ROLE.API,
|
|
4228
|
-
timeout: cdk.Duration.seconds(CDK$2.DURATION.EXPRESS_API),
|
|
4229
|
-
...restProps,
|
|
4230
|
-
});
|
|
4231
|
-
// Set invoke mode for use with JaypieDistribution
|
|
4232
|
-
this.invokeMode = streaming
|
|
4233
|
-
? lambda__namespace.InvokeMode.RESPONSE_STREAM
|
|
4234
|
-
: lambda__namespace.InvokeMode.BUFFERED;
|
|
4235
|
-
}
|
|
4236
|
-
}
|
|
4237
|
-
|
|
4238
4120
|
class JaypieTraceSigningKeySecret extends JaypieEnvSecret {
|
|
4239
4121
|
constructor(scope, id = "TraceSigningKey", props) {
|
|
4240
4122
|
const defaultProps = {
|
|
@@ -4275,10 +4157,8 @@ exports.JaypieSsoPermissions = JaypieSsoPermissions;
|
|
|
4275
4157
|
exports.JaypieSsoSyncApplication = JaypieSsoSyncApplication;
|
|
4276
4158
|
exports.JaypieStack = JaypieStack;
|
|
4277
4159
|
exports.JaypieStaticWebBucket = JaypieStaticWebBucket;
|
|
4278
|
-
exports.JaypieStreamingLambda = JaypieStreamingLambda;
|
|
4279
4160
|
exports.JaypieTraceSigningKeySecret = JaypieTraceSigningKeySecret;
|
|
4280
4161
|
exports.JaypieWebDeploymentBucket = JaypieWebDeploymentBucket;
|
|
4281
|
-
exports.LAMBDA_WEB_ADAPTER = LAMBDA_WEB_ADAPTER;
|
|
4282
4162
|
exports.addDatadogLayers = addDatadogLayers;
|
|
4283
4163
|
exports.clearAllCertificateCaches = clearAllCertificateCaches;
|
|
4284
4164
|
exports.clearAllSecretsCaches = clearAllSecretsCaches;
|