aws-service-stack 0.18.307 → 0.18.308
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.
|
@@ -7,10 +7,10 @@ export declare abstract class ControllerStream<T extends StreamService<any>> {
|
|
|
7
7
|
protected config: EntityConfig;
|
|
8
8
|
protected constructor(baseService: T, config: EntityConfig);
|
|
9
9
|
resolveStreamEvent(event: DynamoDBStreamEvent): Promise<void>;
|
|
10
|
-
|
|
10
|
+
processStreamEventPre(oldItem: T, newItem: T, event: ActionDynamoDB, tableName: string): Promise<{
|
|
11
11
|
oldItem: T;
|
|
12
12
|
newItem: T;
|
|
13
13
|
}>;
|
|
14
|
-
|
|
14
|
+
processStreamEventPost(oldItem: T, newItem: T, event: ActionDynamoDB, tableName: string): Promise<void>;
|
|
15
15
|
private processEventRecord;
|
|
16
16
|
}
|
|
@@ -23,6 +23,10 @@ class ControllerStream {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
async processStreamEventPre(oldItem, newItem, event, tableName) {
|
|
27
|
+
return { oldItem, newItem };
|
|
28
|
+
}
|
|
29
|
+
async processStreamEventPost(oldItem, newItem, event, tableName) { }
|
|
26
30
|
async processEventRecord(record) {
|
|
27
31
|
const oldItem = (0, index_1.parseImage)(record.dynamodb.OldImage);
|
|
28
32
|
const newItem = (0, index_1.parseImage)(record.dynamodb.NewImage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller-stream.js","sourceRoot":"","sources":["../../src/controller/controller-stream.ts"],"names":[],"mappings":";;;AAAA,oCAAwF;AAKxF,MAAsB,gBAAgB;IACjB,OAAO,CAAI;IAEpB,MAAM,CAAe;IAE/B,YAAsB,WAAc,EAAE,MAAoB;QACxD,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;QAE3B,qCAAqC;QACrC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,KAA0B;QACjD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACnC,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;
|
|
1
|
+
{"version":3,"file":"controller-stream.js","sourceRoot":"","sources":["../../src/controller/controller-stream.ts"],"names":[],"mappings":";;;AAAA,oCAAwF;AAKxF,MAAsB,gBAAgB;IACjB,OAAO,CAAI;IAEpB,MAAM,CAAe;IAE/B,YAAsB,WAAc,EAAE,MAAoB;QACxD,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;QAE3B,qCAAqC;QACrC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,KAA0B;QACjD,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YACnC,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,qBAAqB,CACzB,OAAU,EACV,OAAU,EACV,KAAqB,EACrB,SAAiB;QAEjB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC9B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DC","sourcesContent":["import { ActionDynamoDB, getTableName, parseEventToAction, parseImage } from \"../index\";\nimport { DynamoDBRecord, DynamoDBStreamEvent } from \"aws-lambda\";\nimport { EntityConfig } from \"@chinggis/types\";\nimport { StreamService } from \"../service/stream.service.interface\";\n\nexport abstract class ControllerStream<T extends StreamService<any>> {\n protected readonly service: T;\n\n protected config: EntityConfig;\n\n protected constructor(baseService: T, config: EntityConfig) {\n this.service = baseService;\n\n // Store config for use in subclasses\n if (!config) return;\n\n this.config = config;\n\n this.service.setConfig(config);\n }\n\n async resolveStreamEvent(event: DynamoDBStreamEvent): Promise<void> {\n for (const record of event.Records) {\n try {\n await this.processEventRecord(record);\n } catch (error) {\n log.error(\"[CORE] Error handling request event:\", error);\n }\n }\n }\n\n async processStreamEventPre(\n oldItem: T,\n newItem: T,\n event: ActionDynamoDB,\n tableName: string,\n ): Promise<{ oldItem: T; newItem: T }> {\n return { oldItem, newItem };\n }\n\n async processStreamEventPost(oldItem: T, newItem: T, event: ActionDynamoDB, tableName: string): Promise<void> {}\n\n private async processEventRecord(record: DynamoDBRecord): Promise<any> {\n const oldItem = parseImage(record.dynamodb.OldImage) as T;\n const newItem = parseImage(record.dynamodb.NewImage) as T;\n const event = parseEventToAction(record.eventName);\n const tableName = getTableName(record.eventSourceARN);\n\n await this.processStreamEventPre(oldItem, newItem, event, tableName);\n\n if (event === ActionDynamoDB.INSERT) {\n await this.service.processInsertion(newItem, tableName);\n } else if (event === ActionDynamoDB.MODIFY) {\n await this.service.processModification(oldItem, newItem, tableName);\n } else if (event === ActionDynamoDB.REMOVE) {\n await this.service.processDeletion(oldItem, newItem, tableName);\n } else {\n throw new Error(`[CORE] Unsupported event type: ${event}`);\n }\n\n await this.processStreamEventPost(oldItem, newItem, event, tableName);\n }\n}\n"]}
|