@fy-stack/event-construct 0.0.130 → 0.0.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/event-construct.d.ts.map +1 -1
- package/dist/lib/event-construct.js +28 -13
- package/dist/lib/types.d.ts +12 -14
- package/dist/lib/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { EventConstruct } from './lib/event-construct';
|
|
2
|
-
export type {
|
|
2
|
+
export type { AppMessage, AppSchedule, EventConstructProps, WebsocketConstructProps, } from './lib/types';
|
|
3
3
|
export { AuthProviderCapability } from './lib/types';
|
|
4
4
|
export { WebsocketConstruct } from './lib/websocket-construct';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EACV,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,YAAY,EACV,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-construct.d.ts","sourceRoot":"","sources":["../../src/lib/event-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,SAAU,YAAW,UAAU,EAAE,SAAS;IAC5E,SAAgB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC;gBAErB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"event-construct.d.ts","sourceRoot":"","sources":["../../src/lib/event-construct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,SAAU,YAAW,UAAU,EAAE,SAAS;IAC5E,SAAgB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC;gBAErB,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB;IA8DpE,UAAU;;;IAMV,SAAS,CAAC,KAAK,EAAE,UAAU;CAG5B"}
|
|
@@ -17,8 +17,8 @@ class EventConstruct extends constructs_1.Construct {
|
|
|
17
17
|
constructor(scope, id, props) {
|
|
18
18
|
super(scope, id);
|
|
19
19
|
this.topic = new sns.Topic(this, 'AppTopic');
|
|
20
|
-
for (const i in props
|
|
21
|
-
const appMessage = props
|
|
20
|
+
for (const i in props?.messages ?? []) {
|
|
21
|
+
const appMessage = props?.messages?.[i];
|
|
22
22
|
if (!appMessage)
|
|
23
23
|
continue;
|
|
24
24
|
const app = props.resources?.[appMessage.$resource];
|
|
@@ -33,21 +33,36 @@ class EventConstruct extends constructs_1.Construct {
|
|
|
33
33
|
};
|
|
34
34
|
this.topic.addSubscription(app.subscription(filterPolicy));
|
|
35
35
|
}
|
|
36
|
-
for (const i in props
|
|
37
|
-
const job = props.
|
|
36
|
+
for (const i in props?.schedule ?? []) {
|
|
37
|
+
const job = props.schedule?.[i];
|
|
38
38
|
if (!job)
|
|
39
39
|
continue;
|
|
40
40
|
for (const message of job.messages) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
message: events.RuleTargetInput.fromObject({
|
|
46
|
-
message,
|
|
47
|
-
}),
|
|
41
|
+
const targets = [
|
|
42
|
+
new eventsTarget.SnsTopic(this.topic, {
|
|
43
|
+
message: events.RuleTargetInput.fromObject({
|
|
44
|
+
message,
|
|
48
45
|
}),
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
}),
|
|
47
|
+
];
|
|
48
|
+
if (job.cron) {
|
|
49
|
+
new events.Rule(this, `ScheduleRuleCron${i}${message}`, {
|
|
50
|
+
schedule: events.Schedule.cron(job.cron),
|
|
51
|
+
targets,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (job.expression) {
|
|
55
|
+
new events.Rule(this, `ScheduleRuleExpression${i}${message}`, {
|
|
56
|
+
schedule: events.Schedule.expression(job.expression),
|
|
57
|
+
targets,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (job.rate) {
|
|
61
|
+
new events.Rule(this, `ScheduleRuleRate${i}${message}`, {
|
|
62
|
+
schedule: events.Schedule.rate(job.rate),
|
|
63
|
+
targets,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
68
|
}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -2,12 +2,15 @@ import type { EventResource, ResourceRef } from '@fy-stack/types';
|
|
|
2
2
|
import { AuthorizationType, CfnApiProps, LambdaAuthorizerConfig } from 'aws-cdk-lib/aws-appsync';
|
|
3
3
|
import { UserPool } from 'aws-cdk-lib/aws-cognito';
|
|
4
4
|
import type { CronOptions } from 'aws-cdk-lib/aws-events';
|
|
5
|
+
import type { Duration } from 'aws-cdk-lib/core';
|
|
5
6
|
export type AppMessage = ResourceRef & {
|
|
6
7
|
messages: string[];
|
|
7
8
|
};
|
|
8
|
-
export type
|
|
9
|
+
export type AppSchedule = {
|
|
9
10
|
messages: string[];
|
|
10
|
-
cron
|
|
11
|
+
cron?: CronOptions;
|
|
12
|
+
expression?: string;
|
|
13
|
+
rate?: Duration;
|
|
11
14
|
};
|
|
12
15
|
export interface EventConstructProps {
|
|
13
16
|
/**
|
|
@@ -16,18 +19,13 @@ export interface EventConstructProps {
|
|
|
16
19
|
*/
|
|
17
20
|
resources?: Record<string, EventResource>;
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* List of cron objects
|
|
28
|
-
* */
|
|
29
|
-
cron?: AppCron[];
|
|
30
|
-
};
|
|
22
|
+
* List of resource to messages mapping
|
|
23
|
+
* */
|
|
24
|
+
messages?: AppMessage[];
|
|
25
|
+
/**
|
|
26
|
+
* List of cron objects
|
|
27
|
+
* */
|
|
28
|
+
schedule?: AppSchedule[];
|
|
31
29
|
}
|
|
32
30
|
export declare enum AuthProviderCapability {
|
|
33
31
|
CONNECT = "CONNECT",
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EACL,iBA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;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;SAEK;IACL,aAAa,EAAE,CAAC,CACZ;QACE,qDAAqD;QACrD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;QAChC;;cAEM;QACN,OAAO,EAAE,MAAM,CAAC;KACjB,GACD;QACE;;aAEK;QACL,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC;QAClC,QAAQ,EAAE,QAAQ,CAAC;KACpB,GACD,CAAC;QACC;;aAEK;QACL,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC;KAChC,GAAG,sBAAsB,CAAC,CAC9B,GAAG;QACF;;aAEK;QACL,YAAY,EAAE,sBAAsB,EAAE,CAAC;KACxC,CAAC,EAAE,CAAC;CACN"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fy-stack/event-construct",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.131",
|
|
4
4
|
"repository": "https://github.com/festusyuma/fy-stack",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@fy-stack/types": "0.0.
|
|
6
|
+
"@fy-stack/types": "0.0.131",
|
|
7
7
|
"tslib": "^2.3.0"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|