@flipboxlabs/aws-audit-cdk 1.2.0 → 1.3.1

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.
Files changed (35) hide show
  1. package/dist/audit-config.d.ts +2 -2
  2. package/dist/audit-config.d.ts.map +1 -1
  3. package/dist/dynamodb/audit.d.ts.map +1 -1
  4. package/dist/dynamodb/audit.js +22 -23
  5. package/dist/rest-api/http/response-validation.d.ts +3 -0
  6. package/dist/rest-api/http/response-validation.d.ts.map +1 -0
  7. package/dist/rest-api/http/response-validation.js +24 -0
  8. package/dist/rest-api/resources/app/resources/objects/construct.d.ts.map +1 -1
  9. package/dist/rest-api/resources/app/resources/objects/construct.js +7 -1
  10. package/dist/rest-api/resources/app/resources/objects/handler.d.ts.map +1 -1
  11. package/dist/rest-api/resources/app/resources/objects/handler.js +24 -3
  12. package/dist/rest-api/resources/app/resources/objects/schema.d.ts +58 -2
  13. package/dist/rest-api/resources/app/resources/objects/schema.d.ts.map +1 -1
  14. package/dist/rest-api/resources/app/resources/objects/schema.js +5 -1
  15. package/dist/rest-api/resources/construct.d.ts.map +1 -1
  16. package/dist/rest-api/resources/construct.js +2 -0
  17. package/dist/rest-api/resources/status/constants.d.ts +4 -0
  18. package/dist/rest-api/resources/status/constants.d.ts.map +1 -0
  19. package/dist/rest-api/resources/status/constants.js +3 -0
  20. package/dist/rest-api/resources/status/construct.d.ts +22 -0
  21. package/dist/rest-api/resources/status/construct.d.ts.map +1 -0
  22. package/dist/rest-api/resources/status/construct.js +34 -0
  23. package/dist/rest-api/resources/status/handler.d.ts +3 -0
  24. package/dist/rest-api/resources/status/handler.d.ts.map +1 -0
  25. package/dist/rest-api/resources/status/handler.js +42 -0
  26. package/dist/rest-api/resources/status/schema.d.ts +73 -0
  27. package/dist/rest-api/resources/status/schema.d.ts.map +1 -0
  28. package/dist/rest-api/resources/status/schema.js +15 -0
  29. package/dist/rest-api/resources/trace/handler.d.ts.map +1 -1
  30. package/dist/rest-api/resources/trace/handler.js +4 -3
  31. package/dist/rest-api/resources/trace/schema.d.ts +5 -2
  32. package/dist/rest-api/resources/trace/schema.d.ts.map +1 -1
  33. package/dist/rest-api/resources/trace/schema.js +1 -1
  34. package/dist/test-config.d.ts +2 -2
  35. package/package.json +2 -2
@@ -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;;;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
+ {"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":"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;CAkHJ"}
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"}
@@ -87,28 +87,27 @@ export default class extends Construct {
87
87
  DynamoDB.Keys.GSI1_SN_SORT_KEY,
88
88
  ],
89
89
  });
90
- // this.table.addGlobalSecondaryIndex({
91
- // indexName: Indexes.GSI2_SS,
92
- // partitionKey: {
93
- // name: Keys.GSI2_SS_PARTITION_KEY,
94
- // type: dynamodb.AttributeType.STRING,
95
- // },
96
- // sortKey: {
97
- // name: Keys.GSI2_SS_SORT_KEY,
98
- // type: dynamodb.AttributeType.STRING,
99
- // },
100
- // projectionType: dynamodb.ProjectionType.INCLUDE,
101
- // nonKeyAttributes: [
102
- // "operation",
103
- // "status",
104
- // "message",
105
- // "result",
106
- // "error",
107
- // "source",
108
- // "target",
109
- // "rerunable",
110
- // "_createdAt",
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
  }
@@ -0,0 +1,3 @@
1
+ import type { Middleware } from "@aws-lambda-powertools/event-handler/types";
2
+ export declare const ResponseValidationMiddleware: () => Middleware;
3
+ //# sourceMappingURL=response-validation.d.ts.map
@@ -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/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;CAmDvD"}
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: ITEM_RESOURCE.addResource(`{${API_RESOURCE.RESOURCE_WILDCARD_ITEM_AUDIT}}`),
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;AAwD1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,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"}
@@ -4,11 +4,13 @@ import { AuditService } from "@flipboxlabs/aws-audit-sdk";
4
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, ResponseSchema } from "./schema.js";
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
- return audits.listItems({
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: ResponseSchema,
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
  });
@@ -4,12 +4,17 @@ export declare const PathSchema: z.ZodObject<{
4
4
  [x: string]: string;
5
5
  }>;
6
6
  }, z.core.$strip>;
7
+ export declare const DetailPathSchema: z.ZodObject<{
8
+ [x: string]: z.ZodString;
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 ResponseSchema: z.ZodObject<{
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<{
@@ -35,7 +40,7 @@ export declare const ResponseSchema: z.ZodObject<{
35
40
  [key: string]: string | number | boolean | /*elided*/ any;
36
41
  }, unknown>>>>;
37
42
  operation: z.ZodString;
38
- message: z.ZodOptional<z.ZodString>;
43
+ message: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>, z.ZodTransform<string | undefined, string | null | undefined>>;
39
44
  rerunable: z.ZodOptional<z.ZodBoolean>;
40
45
  trace: z.ZodOptional<z.ZodString>;
41
46
  event: z.ZodOptional<z.ZodObject<{
@@ -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.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>, z.ZodTransform<string | undefined, string | null | undefined>>;
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":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;;;iBAIrB,CAAC;AAGH,eAAO,MAAM,WAAW;;;iBAGtB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAC"}
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"}
@@ -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 ResponseSchema = PaginationCollectionSchema(AuditPayloadSchema);
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;AAIvC,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;CAOvD"}
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,4 @@
1
+ export declare const API_RESOURCE: {
2
+ RESOURCE: string;
3
+ };
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -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,3 @@
1
+ export const API_RESOURCE = {
2
+ RESOURCE: "status",
3
+ };
@@ -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,3 @@
1
+ import type { Context } from "aws-lambda";
2
+ export declare const handler: (event: unknown, context: Context) => Promise<unknown>;
3
+ //# sourceMappingURL=handler.d.ts.map
@@ -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.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>, z.ZodTransform<string | undefined, string | null | undefined>>;
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":"handler.d.ts","sourceRoot":"","sources":["../../../../src/rest-api/resources/trace/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAgD1C,eAAO,MAAM,OAAO,GAAU,OAAO,OAAO,EAAE,SAAS,OAAO,KAAG,OAAO,CAAC,OAAO,CACnD,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, ResponseSchema } from "./schema.js";
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
- return audits.listTraceItems({
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: ResponseSchema,
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 ResponseSchema: z.ZodObject<{
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<{
@@ -36,7 +38,7 @@ export declare const ResponseSchema: z.ZodObject<{
36
38
  [key: string]: string | number | boolean | /*elided*/ any;
37
39
  }, unknown>>>>;
38
40
  operation: z.ZodString;
39
- message: z.ZodOptional<z.ZodString>;
41
+ message: z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>, z.ZodTransform<string | undefined, string | null | undefined>>;
40
42
  rerunable: z.ZodOptional<z.ZodBoolean>;
41
43
  trace: z.ZodOptional<z.ZodString>;
42
44
  event: z.ZodOptional<z.ZodObject<{
@@ -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":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;iBAErB,CAAC;AAGH,eAAO,MAAM,WAAW;;;;;;iBAItB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAC"}
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"}
@@ -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 ResponseSchema = PaginationCollectionSchema(AuditPayloadSchema);
14
+ export const ResponseCollectionSchema = PaginationCollectionSchema(AuditPayloadSchema);
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipboxlabs/aws-audit-cdk",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "AWS Audit CDK - CDK constructs for AWS audit infrastructure",
5
5
  "keywords": [
6
6
  "audit",
@@ -62,7 +62,7 @@
62
62
  "@middy/core": "^6.4.5",
63
63
  "qs": "^6.14.0",
64
64
  "zod": "^4.0.0",
65
- "@flipboxlabs/aws-audit-sdk": "^1.2.0"
65
+ "@flipboxlabs/aws-audit-sdk": "^1.4.1"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@tsconfig/node22": "^22.0.1",