@composurecdk/dynamodb 0.9.3 → 0.9.4
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/README.md +28 -0
- package/dist/commonjs/table-builder.d.ts +16 -3
- package/dist/commonjs/table-builder.d.ts.map +1 -1
- package/dist/commonjs/table-builder.js +6 -3
- package/dist/commonjs/table-builder.js.map +1 -1
- package/dist/commonjs/table-v2-builder.d.ts +25 -4
- package/dist/commonjs/table-v2-builder.d.ts.map +1 -1
- package/dist/commonjs/table-v2-builder.js +7 -3
- package/dist/commonjs/table-v2-builder.js.map +1 -1
- package/dist/esm/table-builder.d.ts +16 -3
- package/dist/esm/table-builder.d.ts.map +1 -1
- package/dist/esm/table-builder.js +7 -4
- package/dist/esm/table-builder.js.map +1 -1
- package/dist/esm/table-v2-builder.d.ts +25 -4
- package/dist/esm/table-v2-builder.d.ts.map +1 -1
- package/dist/esm/table-v2-builder.js +9 -5
- package/dist/esm/table-v2-builder.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,34 @@ The defaults are exported for visibility and testing:
|
|
|
66
66
|
import { TABLE_DEFAULTS, TABLE_V2_DEFAULTS } from "@composurecdk/dynamodb";
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
### Customer-managed encryption keys
|
|
70
|
+
|
|
71
|
+
Both builders accept a `Resolvable` for the key, so a key built by [`@composurecdk/kms`](../kms/README.md) can be a component of the same system rather than a construct created outside it.
|
|
72
|
+
|
|
73
|
+
`TableV2` takes the whole `TableEncryptionV2` — one prop that covers every mode, including per-replica key ARNs:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
compose(
|
|
77
|
+
{
|
|
78
|
+
tableKey: createKeyBuilder().description("Encrypts the Orders table at rest."),
|
|
79
|
+
orders: createTableV2Builder()
|
|
80
|
+
.partitionKey({ name: "orderId", type: AttributeType.STRING })
|
|
81
|
+
.encryption(
|
|
82
|
+
ref("tableKey", (r: KeyBuilderResult) => TableEncryptionV2.customerManagedKey(r.key)),
|
|
83
|
+
),
|
|
84
|
+
},
|
|
85
|
+
{ tableKey: [], orders: ["tableKey"] },
|
|
86
|
+
);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The classic `Table` takes the key directly on `.encryptionKey(...)`, which infers `TableEncryption.CUSTOMER_MANAGED` — the `AWS_MANAGED` default is mutually exclusive with a customer key, so it yields rather than making you set both ([ADR-0009](../../docs/adr/0009-defaults-yield-to-mutually-exclusive-siblings.md)):
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
createTableBuilder()
|
|
93
|
+
.partitionKey({ name: "orderId", type: AttributeType.STRING })
|
|
94
|
+
.encryptionKey(ref<KeyBuilderResult>("tableKey").get("key"));
|
|
95
|
+
```
|
|
96
|
+
|
|
69
97
|
## DynamoDB Streams
|
|
70
98
|
|
|
71
99
|
Enable a stream with `.dynamoStream(StreamViewType…)` (TableV2) or `.stream(StreamViewType…)` (classic). The build result surfaces the stream ARN so a downstream component can wire a consumer:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
2
|
import { type ITable, Table, type TableProps } from "aws-cdk-lib/aws-dynamodb";
|
|
3
|
+
import { type IKey } from "aws-cdk-lib/aws-kms";
|
|
3
4
|
import { type IConstruct } from "constructs";
|
|
4
|
-
import { COPY_STATE, type Lifecycle } from "@composurecdk/core";
|
|
5
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
6
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
7
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
8
|
import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
@@ -10,7 +11,19 @@ import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
|
10
11
|
*
|
|
11
12
|
* Extends the CDK {@link TableProps} with additional builder-specific options.
|
|
12
13
|
*/
|
|
13
|
-
export interface TableBuilderProps extends TableProps {
|
|
14
|
+
export interface TableBuilderProps extends Omit<TableProps, "encryptionKey"> {
|
|
15
|
+
/**
|
|
16
|
+
* The customer-managed KMS key used to encrypt the table at rest.
|
|
17
|
+
*
|
|
18
|
+
* Accepts a concrete {@link IKey} or a {@link Resolvable} — typically a
|
|
19
|
+
* {@link Ref} to a composed `@composurecdk/kms` key builder, so the key is a
|
|
20
|
+
* component of the system rather than a construct built outside it.
|
|
21
|
+
*
|
|
22
|
+
* Supplying a key implies `TableEncryption.CUSTOMER_MANAGED`: the
|
|
23
|
+
* `AWS_MANAGED` default is mutually exclusive with a customer key, so
|
|
24
|
+
* `build()` drops it rather than making you set both (ADR-0009).
|
|
25
|
+
*/
|
|
26
|
+
encryptionKey?: Resolvable<IKey>;
|
|
14
27
|
/**
|
|
15
28
|
* Configuration for AWS-recommended CloudWatch alarms.
|
|
16
29
|
*
|
|
@@ -89,7 +102,7 @@ declare class TableBuilder implements Lifecycle<TableBuilderResult> {
|
|
|
89
102
|
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<ITable>) => AlarmDefinitionBuilder<ITable>): this;
|
|
90
103
|
/** @internal — see ADR-0005. */
|
|
91
104
|
[COPY_STATE](target: TableBuilder): void;
|
|
92
|
-
build(scope: IConstruct, id: string): TableBuilderResult;
|
|
105
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): TableBuilderResult;
|
|
93
106
|
}
|
|
94
107
|
/**
|
|
95
108
|
* Creates a new {@link ITableBuilder} for configuring an AWS DynamoDB table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-builder.d.ts","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAmB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAA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MAAM,aAAa,GAAG,cAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAE5E,cAAM,YAAa,YAAW,SAAS,CAAC,kBAAkB,CAAC;;IACzD,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAM;IAGvC,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,GACnF,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIxC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,kBAAkB;CAc3F;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,IAAI,aAAa,CAElD"}
|
|
@@ -18,9 +18,12 @@ class TableBuilder {
|
|
|
18
18
|
[core_1.COPY_STATE](target) {
|
|
19
19
|
target.#customAlarms.push(...this.#customAlarms);
|
|
20
20
|
}
|
|
21
|
-
build(scope, id) {
|
|
22
|
-
const { recommendedAlarms: alarmConfig, ...tableProps } = this.props;
|
|
23
|
-
const mergedProps = mergeTableDefaults(
|
|
21
|
+
build(scope, id, context) {
|
|
22
|
+
const { recommendedAlarms: alarmConfig, encryptionKey, ...tableProps } = this.props;
|
|
23
|
+
const mergedProps = mergeTableDefaults({
|
|
24
|
+
...tableProps,
|
|
25
|
+
...(encryptionKey !== undefined ? { encryptionKey: (0, core_1.resolve)(encryptionKey, context) } : {}),
|
|
26
|
+
});
|
|
24
27
|
const table = new aws_dynamodb_1.Table(scope, id, mergedProps);
|
|
25
28
|
const alarms = (0, table_alarms_js_1.createTableAlarms)(scope, id, table, alarmConfig, this.#customAlarms);
|
|
26
29
|
return { table, tableStreamArn: table.tableStreamArn, alarms };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-builder.js","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"table-builder.js","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":";;AAsMA,gDAEC;AAvMD,2DAAgG;AAGhG,6CAA0F;AAC1F,iEAAkF;AAClF,yDAAkE;AAElE,uDAAsD;AACtD,+CAA+C;AAkG/C,MAAM,YAAY;IAChB,KAAK,GAA+B,EAAE,CAAC;IAC9B,aAAa,GAAqC,EAAE,CAAC;IAE9D,QAAQ,CACN,GAAW,EACX,SAAoF;QAEpF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,mCAAsB,CAAS,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,CAAC,iBAAU,CAAC,CAAC,MAAoB;QAC/B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEpF,MAAM,WAAW,GAAG,kBAAkB,CAAC;YACrC,GAAG,UAAU;YACb,GAAG,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAA,cAAO,EAAC,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3F,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG,IAAA,mCAAiB,EAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEpF,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IACjE,CAAC;CACF;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,KAA0B;IACpD,MAAM,MAAM,GAAG,EAAE,GAAG,4BAAc,EAAE,GAAG,KAAK,EAAE,CAAC;IAE/C,mEAAmE;IACnE,2EAA2E;IAC3E,4EAA4E;IAC5E,wCAAwC;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,CAAC;IAC9F,IAAI,eAAe,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,8EAA8E;IAC9E,4EAA4E;IAC5E,8EAA8E;IAC9E,iDAAiD;IACjD,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACxE,MAAM,CAAC,UAAU,GAAG,8BAAe,CAAC,gBAAgB,CAAC;IACvD,CAAC;IAED,0XAA0X;IAC1X,OAAO,MAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,kBAAkB;IAChC,OAAO,IAAA,8BAAa,EAAkC,YAAY,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
-
import { type ITable, TableV2, type TablePropsV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { type ITable, TableV2, type TableEncryptionV2, type TablePropsV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
3
3
|
import { type IConstruct } from "constructs";
|
|
4
|
-
import { COPY_STATE, type Lifecycle } from "@composurecdk/core";
|
|
4
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
5
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
6
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
7
|
import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
@@ -10,7 +10,28 @@ import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
|
10
10
|
*
|
|
11
11
|
* Extends the CDK {@link TablePropsV2} with additional builder-specific options.
|
|
12
12
|
*/
|
|
13
|
-
export interface TableV2BuilderProps extends TablePropsV2 {
|
|
13
|
+
export interface TableV2BuilderProps extends Omit<TablePropsV2, "encryption"> {
|
|
14
|
+
/**
|
|
15
|
+
* Server-side encryption for the table and its replicas.
|
|
16
|
+
*
|
|
17
|
+
* Accepts a concrete {@link TableEncryptionV2} or a {@link Resolvable} — so
|
|
18
|
+
* a customer-managed key produced by a composed `@composurecdk/kms` builder
|
|
19
|
+
* can be wired in with `ref()`:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* .encryption(ref("tableKey", (r: KeyBuilderResult) =>
|
|
23
|
+
* TableEncryptionV2.customerManagedKey(r.key),
|
|
24
|
+
* ))
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The `Resolvable` sits on the whole {@link TableEncryptionV2} rather than on
|
|
28
|
+
* a narrower `encryptionKey` prop, so every encryption mode — including a
|
|
29
|
+
* customer-managed key with per-replica key ARNs — is expressed the one way
|
|
30
|
+
* CDK expresses it.
|
|
31
|
+
*
|
|
32
|
+
* @default TableEncryptionV2.awsManagedKey()
|
|
33
|
+
*/
|
|
34
|
+
encryption?: Resolvable<TableEncryptionV2>;
|
|
14
35
|
/**
|
|
15
36
|
* Configuration for AWS-recommended CloudWatch alarms.
|
|
16
37
|
*
|
|
@@ -94,7 +115,7 @@ declare class TableV2Builder implements Lifecycle<TableV2BuilderResult> {
|
|
|
94
115
|
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<ITable>) => AlarmDefinitionBuilder<ITable>): this;
|
|
95
116
|
/** @internal — see ADR-0005. */
|
|
96
117
|
[COPY_STATE](target: TableV2Builder): void;
|
|
97
|
-
build(scope: IConstruct, id: string): TableV2BuilderResult;
|
|
118
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): TableV2BuilderResult;
|
|
98
119
|
}
|
|
99
120
|
/**
|
|
100
121
|
* Creates a new {@link ITableV2Builder} for configuring an AWS {@link TableV2}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-v2-builder.d.ts","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"table-v2-builder.d.ts","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,KAAK,MAAM,EACX,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;IAC3E;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE3C;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,KAAK,EAAE,OAAO,CAAC;IAEf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAElF,cAAM,cAAe,YAAW,SAAS,CAAC,oBAAoB,CAAC;;IAC7D,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAM;IAGzC,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,GACnF,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAI1C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB;CA0B7F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD"}
|
|
@@ -18,13 +18,17 @@ class TableV2Builder {
|
|
|
18
18
|
[core_1.COPY_STATE](target) {
|
|
19
19
|
target.#customAlarms.push(...this.#customAlarms);
|
|
20
20
|
}
|
|
21
|
-
build(scope, id) {
|
|
22
|
-
const { recommendedAlarms: alarmConfig, ...tableProps } = this.props;
|
|
21
|
+
build(scope, id, context) {
|
|
22
|
+
const { recommendedAlarms: alarmConfig, encryption, ...tableProps } = this.props;
|
|
23
23
|
// TableV2's billing and encryption defaults are single helper objects with
|
|
24
24
|
// no flat sibling props, so a same-key spread is sufficient — unlike the
|
|
25
25
|
// classic builder, there are no mutually-exclusive defaults to yield
|
|
26
26
|
// (ADR-0009).
|
|
27
|
-
const mergedProps = {
|
|
27
|
+
const mergedProps = {
|
|
28
|
+
...defaults_js_1.TABLE_V2_DEFAULTS,
|
|
29
|
+
...tableProps,
|
|
30
|
+
...(encryption !== undefined ? { encryption: (0, core_1.resolve)(encryption, context) } : {}),
|
|
31
|
+
};
|
|
28
32
|
const table = new aws_dynamodb_1.TableV2(scope, id, mergedProps);
|
|
29
33
|
const alarms = (0, table_alarms_js_1.createTableAlarms)(scope, id, table, alarmConfig, this.#customAlarms);
|
|
30
34
|
// Unlike the classic Table (whose getter is undefined without a stream),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-v2-builder.js","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"table-v2-builder.js","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":";;AAuMA,oDAEC;AAxMD,2DAKkC;AAElC,6CAA0F;AAC1F,iEAAkF;AAClF,yDAAkE;AAElE,uDAAsD;AACtD,+CAAkD;AAgHlD,MAAM,cAAc;IAClB,KAAK,GAAiC,EAAE,CAAC;IAChC,aAAa,GAAqC,EAAE,CAAC;IAE9D,QAAQ,CACN,GAAW,EACX,SAAoF;QAEpF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,mCAAsB,CAAS,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAgC;IAChC,CAAC,iBAAU,CAAC,CAAC,MAAsB;QACjC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,KAAiB,EAAE,EAAU,EAAE,OAAgC;QACnE,MAAM,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEjF,2EAA2E;QAC3E,yEAAyE;QACzE,qEAAqE;QACrE,cAAc;QACd,MAAM,WAAW,GAAG;YAClB,GAAG,+BAAiB;YACpB,GAAG,UAAU;YACb,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAA,cAAO,EAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClE,CAAC;QAElB,MAAM,KAAK,GAAG,IAAI,sBAAO,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QAElD,MAAM,MAAM,GAAG,IAAA,mCAAiB,EAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAEpF,yEAAyE;QACzE,6EAA6E;QAC7E,uEAAuE;QACvE,+DAA+D;QAC/D,6EAA6E;QAC7E,MAAM,cAAc,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC;QAEnF,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;IAC3C,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,oBAAoB;IAClC,OAAO,IAAA,8BAAa,EAAsC,cAAc,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
2
|
import { type ITable, Table, type TableProps } from "aws-cdk-lib/aws-dynamodb";
|
|
3
|
+
import { type IKey } from "aws-cdk-lib/aws-kms";
|
|
3
4
|
import { type IConstruct } from "constructs";
|
|
4
|
-
import { COPY_STATE, type Lifecycle } from "@composurecdk/core";
|
|
5
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
6
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
7
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
8
|
import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
@@ -10,7 +11,19 @@ import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
|
10
11
|
*
|
|
11
12
|
* Extends the CDK {@link TableProps} with additional builder-specific options.
|
|
12
13
|
*/
|
|
13
|
-
export interface TableBuilderProps extends TableProps {
|
|
14
|
+
export interface TableBuilderProps extends Omit<TableProps, "encryptionKey"> {
|
|
15
|
+
/**
|
|
16
|
+
* The customer-managed KMS key used to encrypt the table at rest.
|
|
17
|
+
*
|
|
18
|
+
* Accepts a concrete {@link IKey} or a {@link Resolvable} — typically a
|
|
19
|
+
* {@link Ref} to a composed `@composurecdk/kms` key builder, so the key is a
|
|
20
|
+
* component of the system rather than a construct built outside it.
|
|
21
|
+
*
|
|
22
|
+
* Supplying a key implies `TableEncryption.CUSTOMER_MANAGED`: the
|
|
23
|
+
* `AWS_MANAGED` default is mutually exclusive with a customer key, so
|
|
24
|
+
* `build()` drops it rather than making you set both (ADR-0009).
|
|
25
|
+
*/
|
|
26
|
+
encryptionKey?: Resolvable<IKey>;
|
|
14
27
|
/**
|
|
15
28
|
* Configuration for AWS-recommended CloudWatch alarms.
|
|
16
29
|
*
|
|
@@ -89,7 +102,7 @@ declare class TableBuilder implements Lifecycle<TableBuilderResult> {
|
|
|
89
102
|
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<ITable>) => AlarmDefinitionBuilder<ITable>): this;
|
|
90
103
|
/** @internal — see ADR-0005. */
|
|
91
104
|
[COPY_STATE](target: TableBuilder): void;
|
|
92
|
-
build(scope: IConstruct, id: string): TableBuilderResult;
|
|
105
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): TableBuilderResult;
|
|
93
106
|
}
|
|
94
107
|
/**
|
|
95
108
|
* Creates a new {@link ITableBuilder} for configuring an AWS DynamoDB table.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-builder.d.ts","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAmB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"table-builder.d.ts","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,EAAmB,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC;IAC1E;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAEjC;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,KAAK,EAAE,KAAK,CAAC;IAEb;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;AAE5E,cAAM,YAAa,YAAW,SAAS,CAAC,kBAAkB,CAAC;;IACzD,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAM;IAGvC,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,GACnF,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIxC,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,kBAAkB;CAc3F;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,IAAI,aAAa,CAElD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Table, TableEncryption } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
-
import { COPY_STATE } from "@composurecdk/core";
|
|
2
|
+
import { COPY_STATE, resolve } from "@composurecdk/core";
|
|
3
3
|
import { taggedBuilder } from "@composurecdk/cloudformation";
|
|
4
4
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
5
5
|
import { createTableAlarms } from "./table-alarms.js";
|
|
@@ -15,9 +15,12 @@ class TableBuilder {
|
|
|
15
15
|
[COPY_STATE](target) {
|
|
16
16
|
target.#customAlarms.push(...this.#customAlarms);
|
|
17
17
|
}
|
|
18
|
-
build(scope, id) {
|
|
19
|
-
const { recommendedAlarms: alarmConfig, ...tableProps } = this.props;
|
|
20
|
-
const mergedProps = mergeTableDefaults(
|
|
18
|
+
build(scope, id, context) {
|
|
19
|
+
const { recommendedAlarms: alarmConfig, encryptionKey, ...tableProps } = this.props;
|
|
20
|
+
const mergedProps = mergeTableDefaults({
|
|
21
|
+
...tableProps,
|
|
22
|
+
...(encryptionKey !== undefined ? { encryptionKey: resolve(encryptionKey, context) } : {}),
|
|
23
|
+
});
|
|
21
24
|
const table = new Table(scope, id, mergedProps);
|
|
22
25
|
const alarms = createTableAlarms(scope, id, table, alarmConfig, this.#customAlarms);
|
|
23
26
|
return { table, tableStreamArn: table.tableStreamArn, alarms };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-builder.js","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,EAAE,eAAe,EAAmB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"table-builder.js","sourceRoot":"","sources":["../../src/table-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,EAAE,eAAe,EAAmB,MAAM,0BAA0B,CAAC;AAGhG,OAAO,EAAE,UAAU,EAAkB,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAuB,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC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2E;IAC3E,4EAA4E;IAC5E,wCAAwC;IACxC,MAAM,eAAe,GAAG,KAAK,CAAC,YAAY,KAAK,SAAS,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,CAAC;IAC9F,IAAI,eAAe,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED,8EAA8E;IAC9E,4EAA4E;IAC5E,8EAA8E;IAC9E,iDAAiD;IACjD,IAAI,KAAK,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACxE,MAAM,CAAC,UAAU,GAAG,eAAe,CAAC,gBAAgB,CAAC;IACvD,CAAC;IAED,0XAA0X;IAC1X,OAAO,MAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,aAAa,CAAkC,YAAY,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
-
import { type ITable, TableV2, type TablePropsV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { type ITable, TableV2, type TableEncryptionV2, type TablePropsV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
3
3
|
import { type IConstruct } from "constructs";
|
|
4
|
-
import { COPY_STATE, type Lifecycle } from "@composurecdk/core";
|
|
4
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
5
5
|
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
6
6
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
7
7
|
import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
@@ -10,7 +10,28 @@ import type { TableAlarmConfig } from "./table-alarm-config.js";
|
|
|
10
10
|
*
|
|
11
11
|
* Extends the CDK {@link TablePropsV2} with additional builder-specific options.
|
|
12
12
|
*/
|
|
13
|
-
export interface TableV2BuilderProps extends TablePropsV2 {
|
|
13
|
+
export interface TableV2BuilderProps extends Omit<TablePropsV2, "encryption"> {
|
|
14
|
+
/**
|
|
15
|
+
* Server-side encryption for the table and its replicas.
|
|
16
|
+
*
|
|
17
|
+
* Accepts a concrete {@link TableEncryptionV2} or a {@link Resolvable} — so
|
|
18
|
+
* a customer-managed key produced by a composed `@composurecdk/kms` builder
|
|
19
|
+
* can be wired in with `ref()`:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* .encryption(ref("tableKey", (r: KeyBuilderResult) =>
|
|
23
|
+
* TableEncryptionV2.customerManagedKey(r.key),
|
|
24
|
+
* ))
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The `Resolvable` sits on the whole {@link TableEncryptionV2} rather than on
|
|
28
|
+
* a narrower `encryptionKey` prop, so every encryption mode — including a
|
|
29
|
+
* customer-managed key with per-replica key ARNs — is expressed the one way
|
|
30
|
+
* CDK expresses it.
|
|
31
|
+
*
|
|
32
|
+
* @default TableEncryptionV2.awsManagedKey()
|
|
33
|
+
*/
|
|
34
|
+
encryption?: Resolvable<TableEncryptionV2>;
|
|
14
35
|
/**
|
|
15
36
|
* Configuration for AWS-recommended CloudWatch alarms.
|
|
16
37
|
*
|
|
@@ -94,7 +115,7 @@ declare class TableV2Builder implements Lifecycle<TableV2BuilderResult> {
|
|
|
94
115
|
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<ITable>) => AlarmDefinitionBuilder<ITable>): this;
|
|
95
116
|
/** @internal — see ADR-0005. */
|
|
96
117
|
[COPY_STATE](target: TableV2Builder): void;
|
|
97
|
-
build(scope: IConstruct, id: string): TableV2BuilderResult;
|
|
118
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): TableV2BuilderResult;
|
|
98
119
|
}
|
|
99
120
|
/**
|
|
100
121
|
* Creates a new {@link ITableV2Builder} for configuring an AWS {@link TableV2}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-v2-builder.d.ts","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"table-v2-builder.d.ts","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,KAAK,MAAM,EACX,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAW,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;IAC3E;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE3C;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,gBAAgB,GAAG,KAAK,CAAC;CAC9C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,KAAK,EAAE,OAAO,CAAC;IAEf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAElF,cAAM,cAAe,YAAW,SAAS,CAAC,oBAAoB,CAAC;;IAC7D,KAAK,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAM;IAGzC,QAAQ,CACN,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,KAAK,sBAAsB,CAAC,MAAM,CAAC,GACnF,IAAI;IAKP,gCAAgC;IAChC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAI1C,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,oBAAoB;CA0B7F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TableV2 } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
-
import { COPY_STATE } from "@composurecdk/core";
|
|
1
|
+
import { TableV2, } from "aws-cdk-lib/aws-dynamodb";
|
|
2
|
+
import { COPY_STATE, resolve } from "@composurecdk/core";
|
|
3
3
|
import { taggedBuilder } from "@composurecdk/cloudformation";
|
|
4
4
|
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
5
5
|
import { createTableAlarms } from "./table-alarms.js";
|
|
@@ -15,13 +15,17 @@ class TableV2Builder {
|
|
|
15
15
|
[COPY_STATE](target) {
|
|
16
16
|
target.#customAlarms.push(...this.#customAlarms);
|
|
17
17
|
}
|
|
18
|
-
build(scope, id) {
|
|
19
|
-
const { recommendedAlarms: alarmConfig, ...tableProps } = this.props;
|
|
18
|
+
build(scope, id, context) {
|
|
19
|
+
const { recommendedAlarms: alarmConfig, encryption, ...tableProps } = this.props;
|
|
20
20
|
// TableV2's billing and encryption defaults are single helper objects with
|
|
21
21
|
// no flat sibling props, so a same-key spread is sufficient — unlike the
|
|
22
22
|
// classic builder, there are no mutually-exclusive defaults to yield
|
|
23
23
|
// (ADR-0009).
|
|
24
|
-
const mergedProps = {
|
|
24
|
+
const mergedProps = {
|
|
25
|
+
...TABLE_V2_DEFAULTS,
|
|
26
|
+
...tableProps,
|
|
27
|
+
...(encryption !== undefined ? { encryption: resolve(encryption, context) } : {}),
|
|
28
|
+
};
|
|
25
29
|
const table = new TableV2(scope, id, mergedProps);
|
|
26
30
|
const alarms = createTableAlarms(scope, id, table, alarmConfig, this.#customAlarms);
|
|
27
31
|
// Unlike the classic Table (whose getter is undefined without a stream),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-v2-builder.js","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"table-v2-builder.js","sourceRoot":"","sources":["../../src/table-v2-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,OAAO,GAGR,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,UAAU,EAAkB,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAuB,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAgHlD,MAAM,cAAc;IAClB,KAAK,GAAiC,EAAE,CAAC;IAChC,aAAa,GAAqC,EAAE,CAAC;IAE9D,QAAQ,CACN,GAAW,EACX,SAAoF;QAEpF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAA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