@flipboxlabs/aws-audit-cdk 1.1.5 → 1.3.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/README.md +4 -4
- package/dist/audit-config.d.ts +2 -2
- package/dist/audit-config.d.ts.map +1 -1
- package/dist/cloudwatch/construct.d.ts.map +1 -1
- package/dist/cloudwatch/subscription.handler.d.ts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/dynamodb/audit.d.ts.map +1 -1
- package/dist/dynamodb/audit.js +24 -25
- package/dist/dynamodb/construct.d.ts.map +1 -1
- package/dist/eventbridge/construct.d.ts.map +1 -1
- package/dist/lambda/construct.d.ts.map +1 -1
- package/dist/lambda/nodejs.function.d.ts.map +1 -1
- package/dist/rest-api/construct.d.ts.map +1 -1
- package/dist/rest-api/construct.js +1 -5
- package/dist/rest-api/http/response-validation.d.ts +3 -0
- package/dist/rest-api/http/response-validation.d.ts.map +1 -0
- package/dist/rest-api/http/response-validation.js +24 -0
- package/dist/rest-api/resources/app/construct.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/construct.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/construct.js +7 -1
- package/dist/rest-api/resources/app/resources/objects/handler.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/handler.js +25 -4
- package/dist/rest-api/resources/app/resources/objects/resources/rerun/construct.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/resources/rerun/handler.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/resources/rerun/handler.js +3 -3
- package/dist/rest-api/resources/app/resources/objects/resources/rerun/schema.d.ts +2 -2
- package/dist/rest-api/resources/app/resources/objects/schema.d.ts +59 -3
- package/dist/rest-api/resources/app/resources/objects/schema.d.ts.map +1 -1
- package/dist/rest-api/resources/app/resources/objects/schema.js +6 -2
- package/dist/rest-api/resources/construct.d.ts.map +1 -1
- package/dist/rest-api/resources/construct.js +2 -0
- package/dist/rest-api/resources/status/constants.d.ts +4 -0
- package/dist/rest-api/resources/status/constants.d.ts.map +1 -0
- package/dist/rest-api/resources/status/constants.js +3 -0
- package/dist/rest-api/resources/status/construct.d.ts +22 -0
- package/dist/rest-api/resources/status/construct.d.ts.map +1 -0
- package/dist/rest-api/resources/status/construct.js +34 -0
- package/dist/rest-api/resources/status/handler.d.ts +3 -0
- package/dist/rest-api/resources/status/handler.d.ts.map +1 -0
- package/dist/rest-api/resources/status/handler.js +42 -0
- package/dist/rest-api/resources/status/schema.d.ts +73 -0
- package/dist/rest-api/resources/status/schema.d.ts.map +1 -0
- package/dist/rest-api/resources/status/schema.js +15 -0
- package/dist/rest-api/resources/trace/construct.d.ts.map +1 -1
- package/dist/rest-api/resources/trace/construct.js +1 -6
- package/dist/rest-api/resources/trace/handler.d.ts.map +1 -1
- package/dist/rest-api/resources/trace/handler.js +4 -3
- package/dist/rest-api/resources/trace/schema.d.ts +4 -1
- package/dist/rest-api/resources/trace/schema.d.ts.map +1 -1
- package/dist/rest-api/resources/trace/schema.js +2 -2
- package/dist/rest-api/utils.d.ts.map +1 -1
- package/dist/test-config.d.ts +2 -2
- package/package.json +33 -40
package/README.md
CHANGED
|
@@ -100,12 +100,12 @@ The `CDKConfig` type defines the configuration passed to constructs:
|
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
102
|
type CDKConfig = {
|
|
103
|
-
env: string;
|
|
103
|
+
env: string; // Environment name (e.g., "prod", "staging")
|
|
104
104
|
aws: {
|
|
105
|
-
account: string;
|
|
106
|
-
region: string;
|
|
105
|
+
account: string; // AWS account ID
|
|
106
|
+
region: string; // AWS region
|
|
107
107
|
};
|
|
108
|
-
service?: string;
|
|
108
|
+
service?: string; // Optional service name
|
|
109
109
|
};
|
|
110
110
|
```
|
|
111
111
|
|
package/dist/audit-config.d.ts
CHANGED
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare const auditConfig: {
|
|
23
|
-
service: string | undefined;
|
|
24
|
-
} & {
|
|
25
23
|
readonly apps: readonly string[];
|
|
26
24
|
readonly resourceTypes: readonly string[];
|
|
27
25
|
} & {
|
|
26
|
+
ttlSeconds: number;
|
|
27
|
+
readonly service: string | undefined;
|
|
28
28
|
schemas: {
|
|
29
29
|
app: import("zod").ZodEnum<{
|
|
30
30
|
[x: string]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit-config.d.ts","sourceRoot":"","sources":["../src/audit-config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"audit-config.d.ts","sourceRoot":"","sources":["../src/audit-config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW;mBACR,SAAS,MAAM,EAAE;4BACC,SAAS,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;CACjD,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/cloudwatch/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/cloudwatch/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IAEF,kBAAkB,CAAC,EAAE;QACnB,kEAAkE;QAClE,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oGAAoG;QACpG,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CA+CvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.handler.d.ts","sourceRoot":"","sources":["../../src/cloudwatch/subscription.handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"subscription.handler.d.ts","sourceRoot":"","sources":["../../src/cloudwatch/subscription.handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA6CtD,eAAO,MAAM,OAAO;;EAEnB,CAAC"}
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE;QACH,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/dynamodb/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/dynamodb/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;IACpC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC;gBAG7B,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QACL,MAAM,EAAE,SAAS,CAAC;KACnB;CAiHJ"}
|
package/dist/dynamodb/audit.js
CHANGED
|
@@ -41,7 +41,7 @@ export default class extends Construct {
|
|
|
41
41
|
type: dynamodb.AttributeType.STRING,
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
|
-
// List by
|
|
44
|
+
// List by Trace Id
|
|
45
45
|
this.table.addGlobalSecondaryIndex({
|
|
46
46
|
indexName: DynamoDB.Indexes.GSI1_SN,
|
|
47
47
|
partitionKey: {
|
|
@@ -63,7 +63,7 @@ export default class extends Construct {
|
|
|
63
63
|
"createdAt",
|
|
64
64
|
],
|
|
65
65
|
});
|
|
66
|
-
// List by
|
|
66
|
+
// List by Resource
|
|
67
67
|
this.table.addGlobalSecondaryIndex({
|
|
68
68
|
indexName: DynamoDB.Indexes.GSI1_SS,
|
|
69
69
|
partitionKey: {
|
|
@@ -87,28 +87,27 @@ export default class extends Construct {
|
|
|
87
87
|
DynamoDB.Keys.GSI1_SN_SORT_KEY,
|
|
88
88
|
],
|
|
89
89
|
});
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// });
|
|
90
|
+
// List by Status (with date ordering)
|
|
91
|
+
this.table.addGlobalSecondaryIndex({
|
|
92
|
+
indexName: DynamoDB.Indexes.GSI2_SS,
|
|
93
|
+
partitionKey: {
|
|
94
|
+
name: DynamoDB.Keys.GSI2_SS_PARTITION_KEY,
|
|
95
|
+
type: dynamodb.AttributeType.STRING,
|
|
96
|
+
},
|
|
97
|
+
sortKey: {
|
|
98
|
+
name: DynamoDB.Keys.GSI2_SS_SORT_KEY,
|
|
99
|
+
type: dynamodb.AttributeType.STRING,
|
|
100
|
+
},
|
|
101
|
+
projectionType: dynamodb.ProjectionType.INCLUDE,
|
|
102
|
+
nonKeyAttributes: [
|
|
103
|
+
"operation",
|
|
104
|
+
"status",
|
|
105
|
+
"message",
|
|
106
|
+
"source",
|
|
107
|
+
"target",
|
|
108
|
+
"rerunable",
|
|
109
|
+
"createdAt",
|
|
110
|
+
],
|
|
111
|
+
});
|
|
113
112
|
}
|
|
114
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/dynamodb/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,qBAAa,iBAAkB,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/dynamodb/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,SAAgB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;gBAGrC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QACL,MAAM,EAAE,SAAS,CAAC;KACnB;CAQJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/eventbridge/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,oBAAqB,SAAQ,SAAS;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/eventbridge/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,SAAgB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;gBAGzC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QACL,MAAM,EAAE,SAAS,CAAC;KACnB;CASJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/lambda/construct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,qBAAqB;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/lambda/construct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,SAAgB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC;gBAE/B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;CAsBvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodejs.function.d.ts","sourceRoot":"","sources":["../../src/lambda/nodejs.function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAGnC,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"nodejs.function.d.ts","sourceRoot":"","sources":["../../src/lambda/nodejs.function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAGnC,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAExD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,GAChC,QAAQ,SAAS,MAAM,OAAO,SAAS,EAAE,IAAI,MAAM,EAAE,OAAO,MAAM,CAAC,mBAAmB,yCAyDtF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/rest-api/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/rest-api/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;CAC5C,CAAC;AAIF,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAgB,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;gBAEhC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAyBvD"}
|
|
@@ -7,11 +7,7 @@ export class RestApiConstruct extends Construct {
|
|
|
7
7
|
constructor(scope, id, props) {
|
|
8
8
|
super(scope, id);
|
|
9
9
|
this.restApi = new apigateway.RestApi(this, "RESTApi", {
|
|
10
|
-
restApiName: [
|
|
11
|
-
props.config.env.toUpperCase(),
|
|
12
|
-
props.config.service,
|
|
13
|
-
"Audit",
|
|
14
|
-
].join("-"),
|
|
10
|
+
restApiName: [props.config.env.toUpperCase(), props.config.service, "Audit"].join("-"),
|
|
15
11
|
disableExecuteApiEndpoint: false,
|
|
16
12
|
retainDeployments: true,
|
|
17
13
|
...props.restApi,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-validation.d.ts","sourceRoot":"","sources":["../../../src/rest-api/http/response-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,4CAA4C,CAAC;AAUpD,eAAO,MAAM,4BAA4B,QAAO,UAa/C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const ResponseValidationMiddleware = () => {
|
|
2
|
+
return async ({ reqCtx, next }) => {
|
|
3
|
+
// We only care about the resposne
|
|
4
|
+
await next();
|
|
5
|
+
if (hasValidatedResponseBody(reqCtx)) {
|
|
6
|
+
reqCtx.res = new Response(JSON.stringify(reqCtx.valid.res.body), {
|
|
7
|
+
status: reqCtx.res.status,
|
|
8
|
+
statusText: reqCtx.res.statusText,
|
|
9
|
+
headers: reqCtx.res.headers,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const hasValidatedResponseBody = (ctx) => {
|
|
15
|
+
if (!("valid" in ctx)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const valid = ctx.valid;
|
|
19
|
+
if (typeof valid !== "object" || valid === null || !("res" in valid)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const response = valid.res;
|
|
23
|
+
return typeof response === "object" && response !== null && "body" in response;
|
|
24
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/app/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/app/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;gBACxB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAevD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;gBACxB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CA4DvD"}
|
|
@@ -32,18 +32,24 @@ export default class extends Construct {
|
|
|
32
32
|
.addResource(API_RESOURCE.RESOURCE)
|
|
33
33
|
.addResource(`{${API_RESOURCE.RESOURCE_WILDCARD}}`);
|
|
34
34
|
const ITEM_RESOURCE = RESOURCE.addResource(`{${API_RESOURCE.RESOURCE_WILDCARD_ITEM}}`);
|
|
35
|
+
const AUDIT_RESOURCE = ITEM_RESOURCE.addResource(`{${API_RESOURCE.RESOURCE_WILDCARD_ITEM_AUDIT}}`);
|
|
35
36
|
// /apps/{app}/objects/{object}/{item}
|
|
36
37
|
ITEM_RESOURCE.addMethod("GET", integration, {
|
|
37
38
|
apiKeyRequired: true,
|
|
38
39
|
operationName: "List audit items for resource",
|
|
39
40
|
});
|
|
41
|
+
// /apps/{app}/objects/{object}/{item}/{audit}
|
|
42
|
+
AUDIT_RESOURCE.addMethod("GET", integration, {
|
|
43
|
+
apiKeyRequired: true,
|
|
44
|
+
operationName: "Get audit item detail",
|
|
45
|
+
});
|
|
40
46
|
new ReRun(this, "ReRun", {
|
|
41
47
|
config: props.config,
|
|
42
48
|
table: props.table,
|
|
43
49
|
eventBus: props.eventBus,
|
|
44
50
|
lambda: props.lambda,
|
|
45
51
|
restApi: {
|
|
46
|
-
resource:
|
|
52
|
+
resource: AUDIT_RESOURCE,
|
|
47
53
|
},
|
|
48
54
|
});
|
|
49
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAkG1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,CAAC"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Router } from "@aws-lambda-powertools/event-handler/http";
|
|
2
2
|
import { Logger } from "@aws-lambda-powertools/logger";
|
|
3
3
|
import { AuditService } from "@flipboxlabs/aws-audit-sdk";
|
|
4
|
-
import { auditConfig
|
|
4
|
+
import { auditConfig } from "../../../../../audit-config.js";
|
|
5
5
|
import { API_RESOURCE as BASE_API_RESOURCE } from "../../constants.js";
|
|
6
6
|
import { API_RESOURCE } from "./constants.js";
|
|
7
|
-
import { PathSchema, QuerySchema,
|
|
7
|
+
import { DetailPathSchema, ResponseDetailSchema, PathSchema, QuerySchema, ResponseCollectionSchema, } from "./schema.js";
|
|
8
|
+
import { ResponseValidationMiddleware } from "../../../../http/response-validation.js";
|
|
8
9
|
const logger = new Logger({
|
|
9
10
|
logRecordOrder: ["level", "message"],
|
|
10
11
|
});
|
|
11
12
|
const app = new Router();
|
|
13
|
+
app.use(ResponseValidationMiddleware());
|
|
12
14
|
const audits = new AuditService(logger, auditConfig);
|
|
13
15
|
app.get(`/${BASE_API_RESOURCE.RESOURCE}/:${BASE_API_RESOURCE.RESOURCE_WILDCARD}/${API_RESOURCE.RESOURCE}/:${API_RESOURCE.RESOURCE_WILDCARD}/:${API_RESOURCE.RESOURCE_WILDCARD_ITEM}`, async (reqCtx) => {
|
|
14
16
|
const { [BASE_API_RESOURCE.RESOURCE_WILDCARD]: appId, [API_RESOURCE.RESOURCE_WILDCARD]: objectType, [API_RESOURCE.RESOURCE_WILDCARD_ITEM]: itemId, } = reqCtx.valid.req.path;
|
|
@@ -19,13 +21,14 @@ app.get(`/${BASE_API_RESOURCE.RESOURCE}/:${BASE_API_RESOURCE.RESOURCE_WILDCARD}/
|
|
|
19
21
|
nextToken: query["pagination[nextToken]"],
|
|
20
22
|
}
|
|
21
23
|
: undefined;
|
|
22
|
-
|
|
24
|
+
const collection = await audits.listItems({
|
|
23
25
|
resource: {
|
|
24
26
|
type: objectType,
|
|
25
27
|
id: itemId,
|
|
26
28
|
},
|
|
27
29
|
app: appId,
|
|
28
30
|
}, pagination);
|
|
31
|
+
return Response.json(collection, { status: 200 });
|
|
29
32
|
}, {
|
|
30
33
|
validation: {
|
|
31
34
|
req: {
|
|
@@ -33,7 +36,25 @@ app.get(`/${BASE_API_RESOURCE.RESOURCE}/:${BASE_API_RESOURCE.RESOURCE_WILDCARD}/
|
|
|
33
36
|
query: QuerySchema,
|
|
34
37
|
},
|
|
35
38
|
res: {
|
|
36
|
-
body:
|
|
39
|
+
body: ResponseCollectionSchema,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
app.get(`/${BASE_API_RESOURCE.RESOURCE}/:${BASE_API_RESOURCE.RESOURCE_WILDCARD}/${API_RESOURCE.RESOURCE}/:${API_RESOURCE.RESOURCE_WILDCARD}/:${API_RESOURCE.RESOURCE_WILDCARD_ITEM}/:${API_RESOURCE.RESOURCE_WILDCARD_ITEM_AUDIT}`, async (reqCtx) => {
|
|
44
|
+
const { [BASE_API_RESOURCE.RESOURCE_WILDCARD]: appId, [API_RESOURCE.RESOURCE_WILDCARD]: objectType, [API_RESOURCE.RESOURCE_WILDCARD_ITEM_AUDIT]: auditId, } = reqCtx.valid.req.path;
|
|
45
|
+
const item = await audits.getItem({
|
|
46
|
+
app: appId,
|
|
47
|
+
resourceType: objectType,
|
|
48
|
+
id: auditId,
|
|
49
|
+
});
|
|
50
|
+
return Response.json(item, { status: 200 });
|
|
51
|
+
}, {
|
|
52
|
+
validation: {
|
|
53
|
+
req: {
|
|
54
|
+
path: DetailPathSchema,
|
|
55
|
+
},
|
|
56
|
+
res: {
|
|
57
|
+
body: ResponseDetailSchema,
|
|
37
58
|
},
|
|
38
59
|
},
|
|
39
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../../../../../src/rest-api/resources/app/resources/objects/resources/rerun/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../../../../../src/rest-api/resources/app/resources/objects/resources/rerun/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;gBACxB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAwCvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../../../../../src/rest-api/resources/app/resources/objects/resources/rerun/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../../../../../src/rest-api/resources/app/resources/objects/resources/rerun/handler.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAyD1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { BadRequestError, Router
|
|
1
|
+
import { BadRequestError, Router } from "@aws-lambda-powertools/event-handler/http";
|
|
2
2
|
import { Logger } from "@aws-lambda-powertools/logger";
|
|
3
3
|
import { EventBridgeClient } from "@aws-sdk/client-eventbridge";
|
|
4
|
-
import { AuditService, BatchHandler, EventBridge
|
|
5
|
-
import { auditConfig
|
|
4
|
+
import { AuditService, BatchHandler, EventBridge } from "@flipboxlabs/aws-audit-sdk";
|
|
5
|
+
import { auditConfig } from "../../../../../../../audit-config.js";
|
|
6
6
|
import { API_RESOURCE as BASE_API_RESOURCE } from "../../../../constants.js";
|
|
7
7
|
import { API_RESOURCE as ITEM_API_RESOURCE } from "../../constants.js";
|
|
8
8
|
import { API_RESOURCE } from "./constants.js";
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const PathSchema: z.ZodObject<{
|
|
3
|
-
[x: string]: z.ZodEnum<{
|
|
3
|
+
[x: string]: z.ZodString | z.ZodEnum<{
|
|
4
4
|
[x: string]: string;
|
|
5
|
-
}
|
|
5
|
+
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const DetailPathSchema: z.ZodObject<{
|
|
8
|
+
[x: string]: z.ZodString;
|
|
6
9
|
}, z.core.$strip>;
|
|
7
10
|
export declare const QuerySchema: z.ZodObject<{
|
|
8
11
|
"pagination[pageSize]": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
9
12
|
"pagination[nextToken]": z.ZodOptional<z.ZodString>;
|
|
10
13
|
}, z.core.$strip>;
|
|
11
|
-
export declare const
|
|
14
|
+
export declare const ResponseCollectionSchema: z.ZodObject<{
|
|
12
15
|
items: z.ZodArray<z.ZodObject<{
|
|
16
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
17
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
13
18
|
id: z.ZodString;
|
|
14
19
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
15
20
|
status: z.ZodEnum<{
|
|
@@ -61,4 +66,55 @@ export declare const ResponseSchema: z.ZodObject<{
|
|
|
61
66
|
nextToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
67
|
}, z.core.$strip>>;
|
|
63
68
|
}, z.core.$strip>;
|
|
69
|
+
export type ResponseCollection = z.output<typeof ResponseCollectionSchema>;
|
|
70
|
+
export declare const ResponseDetailSchema: z.ZodObject<{
|
|
71
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
72
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
status: z.ZodEnum<{
|
|
76
|
+
success: "success";
|
|
77
|
+
warn: "warn";
|
|
78
|
+
fail: "fail";
|
|
79
|
+
skip: "skip";
|
|
80
|
+
}>;
|
|
81
|
+
tier: z.ZodDefault<z.ZodNumber>;
|
|
82
|
+
target: z.ZodObject<{
|
|
83
|
+
app: z.ZodString;
|
|
84
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
85
|
+
type: z.ZodString;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
88
|
+
app: z.ZodString;
|
|
89
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
90
|
+
type: z.ZodString;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<string | number | boolean | {
|
|
93
|
+
[key: string]: string | number | boolean | /*elided*/ any;
|
|
94
|
+
}, unknown, z.core.$ZodTypeInternals<string | number | boolean | {
|
|
95
|
+
[key: string]: string | number | boolean | /*elided*/ any;
|
|
96
|
+
}, unknown>>>>;
|
|
97
|
+
operation: z.ZodString;
|
|
98
|
+
message: z.ZodOptional<z.ZodString>;
|
|
99
|
+
rerunable: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
trace: z.ZodOptional<z.ZodString>;
|
|
101
|
+
event: z.ZodOptional<z.ZodObject<{
|
|
102
|
+
source: z.ZodOptional<z.ZodString>;
|
|
103
|
+
"detail-type": z.ZodOptional<z.ZodString>;
|
|
104
|
+
detail: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>, z.ZodTransform<string | undefined, string | Record<string, any> | undefined>>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodPipe<z.ZodCustom<Error, Error>, z.ZodTransform<any, Error>>, z.ZodRecord<z.ZodAny, z.ZodAny>]>>;
|
|
107
|
+
attempts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
108
|
+
number: z.ZodNumber;
|
|
109
|
+
status: z.ZodEnum<{
|
|
110
|
+
success: "success";
|
|
111
|
+
warn: "warn";
|
|
112
|
+
fail: "fail";
|
|
113
|
+
skip: "skip";
|
|
114
|
+
}>;
|
|
115
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodPipe<z.ZodCustom<Error, Error>, z.ZodTransform<any, Error>>, z.ZodRecord<z.ZodAny, z.ZodAny>]>>;
|
|
116
|
+
at: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
117
|
+
}, z.core.$strip>>>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
export type ResponseDetail = z.output<typeof ResponseDetailSchema>;
|
|
64
120
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../../src/rest-api/resources/app/resources/objects/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;;;iBAIrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;iBAE3B,CAAC;AAGH,eAAO,MAAM,WAAW;;;iBAGtB,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE3E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAqB,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuditPayloadSchema, PaginationCollectionSchema
|
|
1
|
+
import { AuditPayloadSchema, PaginationCollectionSchema } from "@flipboxlabs/aws-audit-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { auditConfig } from "../../../../../audit-config.js";
|
|
4
4
|
import { API_RESOURCE as BASE_API_RESOURCE } from "../../constants.js";
|
|
@@ -8,9 +8,13 @@ export const PathSchema = z.object({
|
|
|
8
8
|
[API_RESOURCE.RESOURCE_WILDCARD]: auditConfig.schemas.resourceType,
|
|
9
9
|
[API_RESOURCE.RESOURCE_WILDCARD_ITEM]: z.string(),
|
|
10
10
|
});
|
|
11
|
+
export const DetailPathSchema = PathSchema.extend({
|
|
12
|
+
[API_RESOURCE.RESOURCE_WILDCARD_ITEM_AUDIT]: z.string(),
|
|
13
|
+
});
|
|
11
14
|
// Query params use flat keys matching API Gateway's bracket notation
|
|
12
15
|
export const QuerySchema = z.object({
|
|
13
16
|
"pagination[pageSize]": z.coerce.number().optional(),
|
|
14
17
|
"pagination[nextToken]": z.string().optional(),
|
|
15
18
|
});
|
|
16
|
-
export const
|
|
19
|
+
export const ResponseCollectionSchema = PaginationCollectionSchema(AuditPayloadSchema);
|
|
20
|
+
export const ResponseDetailSchema = AuditPayloadSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../src/rest-api/resources/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../src/rest-api/resources/construct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAC9D,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,UAAU,KAAK;IACb,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC;IAC3B,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAEhC,CAAC;CACH;AAED,qBAAa,yBAA0B,SAAQ,SAAS;gBAC1C,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CASvD"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import App from "./app/construct.js";
|
|
3
|
+
import Status from "./status/construct.js";
|
|
3
4
|
import Trace from "./trace/construct.js";
|
|
4
5
|
export class RestApiResourcesConstruct extends Construct {
|
|
5
6
|
constructor(scope, id, props) {
|
|
6
7
|
super(scope, id);
|
|
7
8
|
new Trace(this, "Trace", props);
|
|
8
9
|
new App(this, "App", props);
|
|
10
|
+
new Status(this, "Status", props);
|
|
9
11
|
}
|
|
10
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/status/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;CAExB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CDKConfig } from "@flipboxlabs/aws-audit-cdk";
|
|
2
|
+
import * as apigateway from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import type * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
4
|
+
import type * as lambda from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { Construct } from "constructs";
|
|
6
|
+
type Props = {
|
|
7
|
+
config: CDKConfig;
|
|
8
|
+
table: dynamodb.ITable;
|
|
9
|
+
/** Lambda configuration */
|
|
10
|
+
lambda: {
|
|
11
|
+
/** Lambda layers to attach to the function */
|
|
12
|
+
layers: lambda.ILayerVersion[];
|
|
13
|
+
};
|
|
14
|
+
restApi: {
|
|
15
|
+
resource: apigateway.IResource;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default class extends Construct {
|
|
19
|
+
constructor(scope: Construct, id: string, props: Props);
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=construct.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/status/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;gBACxB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAoCvD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as url from "node:url";
|
|
2
|
+
import * as apigateway from "aws-cdk-lib/aws-apigateway";
|
|
3
|
+
import { Construct } from "constructs";
|
|
4
|
+
import { ESMNodeFunctionFactory } from "../../../lambda/nodejs.function.js";
|
|
5
|
+
import { API_RESOURCE } from "./constants.js";
|
|
6
|
+
export default class extends Construct {
|
|
7
|
+
constructor(scope, id, props) {
|
|
8
|
+
super(scope, id);
|
|
9
|
+
const ref = [props.config.env.toUpperCase(), "REST-API", props.config.service, "Status"].join("-");
|
|
10
|
+
// Lambda
|
|
11
|
+
const lambdaFn = ESMNodeFunctionFactory(props.config)(this, "NodeFunction", {
|
|
12
|
+
functionName: ref,
|
|
13
|
+
entry: url.fileURLToPath(new URL("handler.js", import.meta.url).toString()),
|
|
14
|
+
layers: props.lambda.layers,
|
|
15
|
+
currentVersionOptions: {
|
|
16
|
+
retryAttempts: 1,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// Logger / Metrics / Tracing
|
|
20
|
+
lambdaFn.addEnvironment("POWERTOOLS_SERVICE_NAME", "Status");
|
|
21
|
+
// DynamoDB
|
|
22
|
+
props.table.grantReadData(lambdaFn);
|
|
23
|
+
// Integration
|
|
24
|
+
const integration = new apigateway.LambdaIntegration(lambdaFn);
|
|
25
|
+
const RESOURCE = props.restApi.resource
|
|
26
|
+
.addResource(API_RESOURCE.RESOURCE)
|
|
27
|
+
.addResource(`{${API_RESOURCE.RESOURCE}}`);
|
|
28
|
+
// /status/{status}
|
|
29
|
+
RESOURCE.addMethod("GET", integration, {
|
|
30
|
+
apiKeyRequired: true,
|
|
31
|
+
operationName: "Retrieve audit items by status",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/status/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAwD1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Router } from "@aws-lambda-powertools/event-handler/http";
|
|
2
|
+
import { Logger } from "@aws-lambda-powertools/logger";
|
|
3
|
+
import { AuditService } from "@flipboxlabs/aws-audit-sdk";
|
|
4
|
+
import { auditConfig } from "../../../audit-config.js";
|
|
5
|
+
import { API_RESOURCE } from "./constants.js";
|
|
6
|
+
import { PathSchema, QuerySchema, ResponseCollectionSchema } from "./schema.js";
|
|
7
|
+
import { ResponseValidationMiddleware } from "../../http/response-validation.js";
|
|
8
|
+
const logger = new Logger({
|
|
9
|
+
logRecordOrder: ["level", "message"],
|
|
10
|
+
});
|
|
11
|
+
const app = new Router();
|
|
12
|
+
app.use(ResponseValidationMiddleware());
|
|
13
|
+
const audits = new AuditService(logger, auditConfig);
|
|
14
|
+
app.get(`/${API_RESOURCE.RESOURCE}/:${API_RESOURCE.RESOURCE}`, async (reqCtx) => {
|
|
15
|
+
const { [API_RESOURCE.RESOURCE]: status } = reqCtx.valid.req.path;
|
|
16
|
+
const query = reqCtx.valid.req.query;
|
|
17
|
+
const pagination = query["pagination[pageSize]"] || query["pagination[nextToken]"]
|
|
18
|
+
? {
|
|
19
|
+
pageSize: query["pagination[pageSize]"],
|
|
20
|
+
nextToken: query["pagination[nextToken]"],
|
|
21
|
+
}
|
|
22
|
+
: undefined;
|
|
23
|
+
const collection = await audits.listByStatus({
|
|
24
|
+
status: status,
|
|
25
|
+
app: query["filter[app]"],
|
|
26
|
+
resource: query["filter[resourceType]"]
|
|
27
|
+
? { type: query["filter[resourceType]"] }
|
|
28
|
+
: undefined,
|
|
29
|
+
}, pagination);
|
|
30
|
+
return Response.json(collection, { status: 200 });
|
|
31
|
+
}, {
|
|
32
|
+
validation: {
|
|
33
|
+
req: {
|
|
34
|
+
path: PathSchema,
|
|
35
|
+
query: QuerySchema,
|
|
36
|
+
},
|
|
37
|
+
res: {
|
|
38
|
+
body: ResponseCollectionSchema,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
export const handler = async (event, context) => app.resolve(event, context);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const PathSchema: z.ZodObject<{
|
|
3
|
+
[x: string]: z.ZodEnum<{
|
|
4
|
+
[x: string]: string;
|
|
5
|
+
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const QuerySchema: z.ZodObject<{
|
|
8
|
+
"pagination[pageSize]": z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
9
|
+
"pagination[nextToken]": z.ZodOptional<z.ZodString>;
|
|
10
|
+
"filter[app]": z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
[x: string]: string;
|
|
12
|
+
}>>;
|
|
13
|
+
"filter[resourceType]": z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
[x: string]: string;
|
|
15
|
+
}>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export declare const ResponseCollectionSchema: z.ZodObject<{
|
|
18
|
+
items: z.ZodArray<z.ZodObject<{
|
|
19
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
20
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
status: z.ZodEnum<{
|
|
24
|
+
success: "success";
|
|
25
|
+
warn: "warn";
|
|
26
|
+
fail: "fail";
|
|
27
|
+
skip: "skip";
|
|
28
|
+
}>;
|
|
29
|
+
tier: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
target: z.ZodObject<{
|
|
31
|
+
app: z.ZodString;
|
|
32
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
33
|
+
type: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
app: z.ZodString;
|
|
37
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
38
|
+
type: z.ZodString;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<string | number | boolean | {
|
|
41
|
+
[key: string]: string | number | boolean | /*elided*/ any;
|
|
42
|
+
}, unknown, z.core.$ZodTypeInternals<string | number | boolean | {
|
|
43
|
+
[key: string]: string | number | boolean | /*elided*/ any;
|
|
44
|
+
}, unknown>>>>;
|
|
45
|
+
operation: z.ZodString;
|
|
46
|
+
message: z.ZodOptional<z.ZodString>;
|
|
47
|
+
rerunable: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
trace: z.ZodOptional<z.ZodString>;
|
|
49
|
+
event: z.ZodOptional<z.ZodObject<{
|
|
50
|
+
source: z.ZodOptional<z.ZodString>;
|
|
51
|
+
"detail-type": z.ZodOptional<z.ZodString>;
|
|
52
|
+
detail: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodAny>]>>, z.ZodTransform<string | undefined, string | Record<string, any> | undefined>>;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodPipe<z.ZodCustom<Error, Error>, z.ZodTransform<any, Error>>, z.ZodRecord<z.ZodAny, z.ZodAny>]>>;
|
|
55
|
+
attempts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
56
|
+
number: z.ZodNumber;
|
|
57
|
+
status: z.ZodEnum<{
|
|
58
|
+
success: "success";
|
|
59
|
+
warn: "warn";
|
|
60
|
+
fail: "fail";
|
|
61
|
+
skip: "skip";
|
|
62
|
+
}>;
|
|
63
|
+
error: z.ZodOptional<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<any, string>>, z.ZodPipe<z.ZodCustom<Error, Error>, z.ZodTransform<any, Error>>, z.ZodRecord<z.ZodAny, z.ZodAny>]>>;
|
|
64
|
+
at: z.ZodDefault<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
65
|
+
}, z.core.$strip>>>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
pagination: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
pageSize: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
69
|
+
nextToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type ResponseCollection = z.output<typeof ResponseCollectionSchema>;
|
|
73
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/status/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;iBAErB,CAAC;AAGH,eAAO,MAAM,WAAW;;;;;;;;;iBAKtB,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuditPayloadSchema, PaginationCollectionSchema, Status } from "@flipboxlabs/aws-audit-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { auditConfig } from "../../../audit-config.js";
|
|
4
|
+
import { API_RESOURCE } from "./constants.js";
|
|
5
|
+
export const PathSchema = z.object({
|
|
6
|
+
[API_RESOURCE.RESOURCE]: z.enum(Object.values(Status)),
|
|
7
|
+
});
|
|
8
|
+
// Query params use flat keys matching API Gateway's bracket notation
|
|
9
|
+
export const QuerySchema = z.object({
|
|
10
|
+
"pagination[pageSize]": z.coerce.number().optional(),
|
|
11
|
+
"pagination[nextToken]": z.string().optional(),
|
|
12
|
+
"filter[app]": auditConfig.schemas.app.optional(),
|
|
13
|
+
"filter[resourceType]": auditConfig.schemas.resourceType.optional(),
|
|
14
|
+
});
|
|
15
|
+
export const ResponseCollectionSchema = PaginationCollectionSchema(AuditPayloadSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/construct.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,KAAK,QAAQ,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IACvB,2BAA2B;IAC3B,MAAM,EAAE;QACN,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;KAChC,CAAC;IACF,OAAO,EAAE;QACP,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,CAAC,OAAO,MAAO,SAAQ,SAAS;gBACxB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAoCvD"}
|
|
@@ -6,12 +6,7 @@ import { API_RESOURCE } from "./constants.js";
|
|
|
6
6
|
export default class extends Construct {
|
|
7
7
|
constructor(scope, id, props) {
|
|
8
8
|
super(scope, id);
|
|
9
|
-
const ref = [
|
|
10
|
-
props.config.env.toUpperCase(),
|
|
11
|
-
"REST-API",
|
|
12
|
-
props.config.service,
|
|
13
|
-
"Trace",
|
|
14
|
-
].join("-");
|
|
9
|
+
const ref = [props.config.env.toUpperCase(), "REST-API", props.config.service, "Trace"].join("-");
|
|
15
10
|
// Lambda
|
|
16
11
|
const lambdaFn = ESMNodeFunctionFactory(props.config)(this, "NodeFunction", {
|
|
17
12
|
functionName: ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAuD1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { Logger } from "@aws-lambda-powertools/logger";
|
|
|
3
3
|
import { AuditService } from "@flipboxlabs/aws-audit-sdk";
|
|
4
4
|
import { auditConfig } from "../../../audit-config.js";
|
|
5
5
|
import { API_RESOURCE } from "./constants.js";
|
|
6
|
-
import { PathSchema, QuerySchema,
|
|
6
|
+
import { PathSchema, QuerySchema, ResponseCollectionSchema, } from "./schema.js";
|
|
7
7
|
const logger = new Logger({
|
|
8
8
|
logRecordOrder: ["level", "message"],
|
|
9
9
|
});
|
|
@@ -18,10 +18,11 @@ app.get(`/${API_RESOURCE.RESOURCE}/:${API_RESOURCE.RESOURCE}`, async (reqCtx) =>
|
|
|
18
18
|
nextToken: query["pagination[nextToken]"],
|
|
19
19
|
}
|
|
20
20
|
: undefined;
|
|
21
|
-
|
|
21
|
+
const collection = await audits.listTraceItems({
|
|
22
22
|
trace: traceId,
|
|
23
23
|
app: query["filter[app]"],
|
|
24
24
|
}, pagination);
|
|
25
|
+
return Response.json(collection, { status: 200 });
|
|
25
26
|
}, {
|
|
26
27
|
validation: {
|
|
27
28
|
req: {
|
|
@@ -29,7 +30,7 @@ app.get(`/${API_RESOURCE.RESOURCE}/:${API_RESOURCE.RESOURCE}`, async (reqCtx) =>
|
|
|
29
30
|
query: QuerySchema,
|
|
30
31
|
},
|
|
31
32
|
res: {
|
|
32
|
-
body:
|
|
33
|
+
body: ResponseCollectionSchema,
|
|
33
34
|
},
|
|
34
35
|
},
|
|
35
36
|
});
|
|
@@ -9,8 +9,10 @@ export declare const QuerySchema: z.ZodObject<{
|
|
|
9
9
|
[x: string]: string;
|
|
10
10
|
}>>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const ResponseCollectionSchema: z.ZodObject<{
|
|
13
13
|
items: z.ZodArray<z.ZodObject<{
|
|
14
|
+
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
15
|
+
createdAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodCustom<Date, Date>]>, z.ZodTransform<string, string | Date>>>;
|
|
14
16
|
id: z.ZodString;
|
|
15
17
|
tenantId: z.ZodOptional<z.ZodString>;
|
|
16
18
|
status: z.ZodEnum<{
|
|
@@ -62,4 +64,5 @@ export declare const ResponseSchema: z.ZodObject<{
|
|
|
62
64
|
nextToken: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
63
65
|
}, z.core.$strip>>;
|
|
64
66
|
}, z.core.$strip>;
|
|
67
|
+
export type ResponseCollection = z.output<typeof ResponseCollectionSchema>;
|
|
65
68
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;iBAErB,CAAC;AAGH,eAAO,MAAM,WAAW;;;;;;iBAItB,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuditPayloadSchema, PaginationCollectionSchema
|
|
1
|
+
import { AuditPayloadSchema, PaginationCollectionSchema } from "@flipboxlabs/aws-audit-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { auditConfig } from "../../../audit-config.js";
|
|
4
4
|
import { API_RESOURCE } from "./constants.js";
|
|
@@ -11,4 +11,4 @@ export const QuerySchema = z.object({
|
|
|
11
11
|
"pagination[nextToken]": z.string().optional(),
|
|
12
12
|
"filter[app]": auditConfig.schemas.app.optional(),
|
|
13
13
|
});
|
|
14
|
-
export const
|
|
14
|
+
export const ResponseCollectionSchema = PaginationCollectionSchema(AuditPayloadSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/rest-api/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,YAAY,CAAC;AAG5E,UAAU,QAAQ;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/rest-api/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yCAAyC,EAAE,MAAM,YAAY,CAAC;AAG5E,UAAU,QAAQ;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,QAAQ,GAAG,QAAQ,EAAE,CAAC;CAChF;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,yCAAyC,GAAG,IAAI,GACvD,QAAQ,GAAG,IAAI,CAMjB"}
|
package/dist/test-config.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Provides sample apps and resource types for testing.
|
|
4
4
|
*/
|
|
5
5
|
export declare const testConfig: {
|
|
6
|
-
service: string | undefined;
|
|
7
|
-
} & {
|
|
8
6
|
readonly apps: readonly ["App1", "TestApp"];
|
|
9
7
|
readonly resourceTypes: readonly ["Unknown", "User", "Order"];
|
|
10
8
|
} & {
|
|
9
|
+
ttlSeconds: number;
|
|
10
|
+
readonly service: string | undefined;
|
|
11
11
|
schemas: {
|
|
12
12
|
app: import("zod").ZodEnum<{
|
|
13
13
|
[x: string]: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flipboxlabs/aws-audit-cdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "AWS Audit CDK - CDK constructs for AWS audit infrastructure",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"audit",
|
|
7
|
+
"aws",
|
|
8
|
+
"cdk",
|
|
9
|
+
"cloudwatch",
|
|
10
|
+
"dynamodb",
|
|
11
|
+
"eventbridge",
|
|
12
|
+
"infrastructure",
|
|
13
|
+
"serverless"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/flipboxlabs/aws-audit#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/flipboxlabs/aws-audit/issues"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/flipboxlabs/aws-audit.git",
|
|
23
|
+
"directory": "cdk"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
5
29
|
"type": "module",
|
|
6
30
|
"main": "./dist/index.js",
|
|
7
31
|
"exports": {
|
|
@@ -30,10 +54,6 @@
|
|
|
30
54
|
"import": "./dist/rest-api/index.js"
|
|
31
55
|
}
|
|
32
56
|
},
|
|
33
|
-
"files": [
|
|
34
|
-
"dist",
|
|
35
|
-
"README.md"
|
|
36
|
-
],
|
|
37
57
|
"dependencies": {
|
|
38
58
|
"@aws-lambda-powertools/event-handler": "^2.32.0",
|
|
39
59
|
"@aws-lambda-powertools/jmespath": "^2.32.0",
|
|
@@ -42,59 +62,32 @@
|
|
|
42
62
|
"@middy/core": "^6.4.5",
|
|
43
63
|
"qs": "^6.14.0",
|
|
44
64
|
"zod": "^4.0.0",
|
|
45
|
-
"@flipboxlabs/aws-audit-sdk": "^1.
|
|
65
|
+
"@flipboxlabs/aws-audit-sdk": "^1.4.0"
|
|
46
66
|
},
|
|
47
67
|
"devDependencies": {
|
|
48
68
|
"@tsconfig/node22": "^22.0.1",
|
|
49
69
|
"@types/aws-lambda": "^8.10.156",
|
|
50
70
|
"@types/node": "^22.15.0",
|
|
51
71
|
"@types/qs": "^6.9.18",
|
|
52
|
-
"@vitest/coverage-v8": "^2.1.1",
|
|
53
72
|
"aws-cdk-lib": "2.135.0",
|
|
54
73
|
"constructs": "^10.3.0",
|
|
55
74
|
"esbuild": "^0.23.1",
|
|
56
75
|
"ts-node": "^10.9.2",
|
|
57
76
|
"typescript": "^5.9.3",
|
|
58
|
-
"
|
|
59
|
-
},
|
|
60
|
-
"engines": {
|
|
61
|
-
"node": ">=24"
|
|
62
|
-
},
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "git",
|
|
65
|
-
"url": "git+https://github.com/flipboxlabs/aws-audit.git",
|
|
66
|
-
"directory": "cdk"
|
|
77
|
+
"vite-plus": "latest"
|
|
67
78
|
},
|
|
68
|
-
"bugs": {
|
|
69
|
-
"url": "https://github.com/flipboxlabs/aws-audit/issues"
|
|
70
|
-
},
|
|
71
|
-
"homepage": "https://github.com/flipboxlabs/aws-audit#readme",
|
|
72
|
-
"license": "MIT",
|
|
73
|
-
"keywords": [
|
|
74
|
-
"aws",
|
|
75
|
-
"audit",
|
|
76
|
-
"cdk",
|
|
77
|
-
"infrastructure",
|
|
78
|
-
"cloudwatch",
|
|
79
|
-
"dynamodb",
|
|
80
|
-
"eventbridge",
|
|
81
|
-
"serverless"
|
|
82
|
-
],
|
|
83
79
|
"peerDependencies": {
|
|
84
80
|
"aws-cdk-lib": "^2.135.0",
|
|
85
81
|
"constructs": "^10.3.0"
|
|
86
82
|
},
|
|
83
|
+
"engines": {
|
|
84
|
+
"node": ">=24"
|
|
85
|
+
},
|
|
87
86
|
"scripts": {
|
|
88
87
|
"build": "tsc -p ./tsconfig.build.json",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"format": "npx biome format",
|
|
93
|
-
"format:fix": "npx biome format --fix",
|
|
94
|
-
"pre-commit": "pnpm run check-types && pnpm run format && pnpm run lint",
|
|
95
|
-
"test": "vitest run",
|
|
96
|
-
"test:watch": "vitest",
|
|
97
|
-
"test:coverage": "vitest run --coverage",
|
|
88
|
+
"test": "vp test run",
|
|
89
|
+
"test:watch": "vp test",
|
|
90
|
+
"test:coverage": "vp test run --coverage",
|
|
98
91
|
"cdk:synth": "cdk synth --app 'npx tsx bin/app.ts'",
|
|
99
92
|
"cdk:deploy": "cdk deploy --app 'npx tsx bin/app.ts' --require-approval never"
|
|
100
93
|
},
|