@kensio/yulin 1.21.25 → 1.21.27

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 (112) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/sdk/error/sim-sdk.error.d.ts +18 -0
  4. package/dist/sdk/error/sim-sdk.error.js +41 -0
  5. package/dist/sdk/index.d.ts +1 -1
  6. package/dist/sdk/index.js +1 -1
  7. package/dist/sdk/send-abort.d.ts +28 -0
  8. package/dist/sdk/send-abort.js +112 -0
  9. package/dist/sdk/send-patch.js +3 -1
  10. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +1 -0
  11. package/dist/service/aws/sim-aws-properties.d.ts +8 -0
  12. package/dist/service/aws/sim-aws.d.ts +5 -0
  13. package/dist/service/aws/sim-aws.js +7 -1
  14. package/dist/service/eventbridge/bus/sim-event-bus-name.d.ts +4 -0
  15. package/dist/service/eventbridge/bus/sim-event-bus-name.js +17 -12
  16. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-creator.js +8 -1
  17. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.d.ts +5 -0
  18. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.js +14 -1
  19. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-creator.js +2 -0
  20. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-target-delivery.d.ts +15 -0
  21. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-target-delivery.js +53 -0
  22. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-targets.d.ts +4 -0
  23. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-targets.js +7 -3
  24. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.d.ts +5 -0
  25. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.js +7 -0
  26. package/dist/service/eventbridge/command/bus/sim-event-bridge-create-event-bus.d.ts +7 -1
  27. package/dist/service/eventbridge/command/bus/sim-event-bridge-create-event-bus.js +7 -1
  28. package/dist/service/eventbridge/command/bus/sim-event-bridge-partner-bus.d.ts +24 -0
  29. package/dist/service/eventbridge/command/bus/sim-event-bridge-partner-bus.js +44 -0
  30. package/dist/service/eventbridge/command/bus/sim-event-bridge-unsimulated-bus-input.js +0 -5
  31. package/dist/service/eventbridge/command/put-events/sim-event-bridge-authorized-entries.js +8 -0
  32. package/dist/service/eventbridge/command/sim-event-bridge-command.types.d.ts +1 -0
  33. package/dist/service/eventbridge/command/sim-event-bridge-commands.d.ts +6 -0
  34. package/dist/service/eventbridge/command/sim-event-bridge-commands.js +19 -1
  35. package/dist/service/eventbridge/command/source/sim-event-bridge-describe-event-source.d.ts +35 -0
  36. package/dist/service/eventbridge/command/source/sim-event-bridge-describe-event-source.js +46 -0
  37. package/dist/service/eventbridge/command/source/sim-event-bridge-put-partner-events.d.ts +41 -0
  38. package/dist/service/eventbridge/command/source/sim-event-bridge-put-partner-events.js +82 -0
  39. package/dist/service/eventbridge/command/source/source.command.d.ts +59 -0
  40. package/dist/service/eventbridge/command/source/source.command.js +1 -0
  41. package/dist/service/eventbridge/command/target/sim-event-bridge-target-commands.js +2 -0
  42. package/dist/service/eventbridge/command/target/sim-event-bridge-unsimulated-target-input.js +2 -12
  43. package/dist/service/eventbridge/command/target/target.command.d.ts +8 -5
  44. package/dist/service/eventbridge/delivery/sim-aws-event-bridge-delivery-targets.d.ts +6 -1
  45. package/dist/service/eventbridge/delivery/sim-aws-event-bridge-delivery-targets.js +16 -0
  46. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-attributes.d.ts +9 -0
  47. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-attributes.js +47 -0
  48. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-queue.d.ts +24 -0
  49. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-queue.js +28 -0
  50. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-attempt.d.ts +41 -0
  51. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-attempt.js +97 -0
  52. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-queue.js +7 -37
  53. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-retries.test-support.d.ts +25 -0
  54. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-retries.test-support.js +60 -0
  55. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery.d.ts +22 -0
  56. package/dist/service/eventbridge/delivery/sim-event-bridge-failing-targets.test-support.d.ts +23 -0
  57. package/dist/service/eventbridge/delivery/sim-event-bridge-failing-targets.test-support.js +28 -0
  58. package/dist/service/eventbridge/delivery/sim-event-bridge-no-delivery-targets.d.ts +5 -1
  59. package/dist/service/eventbridge/delivery/sim-event-bridge-no-delivery-targets.js +9 -0
  60. package/dist/service/eventbridge/delivery/sim-event-bridge-queue-message.d.ts +28 -0
  61. package/dist/service/eventbridge/delivery/sim-event-bridge-queue-message.js +45 -0
  62. package/dist/service/eventbridge/delivery/sim-event-bridge-target-delivery.d.ts +4 -1
  63. package/dist/service/eventbridge/delivery/sim-event-bridge-target-delivery.js +19 -14
  64. package/dist/service/eventbridge/index.d.ts +2 -0
  65. package/dist/service/eventbridge/index.js +2 -0
  66. package/dist/service/eventbridge/routing/sim-event-bridge-router.js +1 -0
  67. package/dist/service/eventbridge/sdk/sim-event-bridge-sdk-command-router.js +4 -0
  68. package/dist/service/eventbridge/sim-event-bridge-inspection.d.ts +10 -0
  69. package/dist/service/eventbridge/sim-event-bridge-inspection.js +9 -0
  70. package/dist/service/eventbridge/sim-event-bridge-partners.d.ts +38 -0
  71. package/dist/service/eventbridge/sim-event-bridge-partners.js +43 -0
  72. package/dist/service/eventbridge/sim-event-bridge.d.ts +12 -12
  73. package/dist/service/eventbridge/sim-event-bridge.js +14 -11
  74. package/dist/service/eventbridge/source/sim-partner-event-source-name.d.ts +28 -0
  75. package/dist/service/eventbridge/source/sim-partner-event-source-name.js +62 -0
  76. package/dist/service/eventbridge/source/sim-partner-event-source-store.d.ts +18 -0
  77. package/dist/service/eventbridge/source/sim-partner-event-source-store.js +29 -0
  78. package/dist/service/eventbridge/source/sim-partner-event-source.d.ts +46 -0
  79. package/dist/service/eventbridge/source/sim-partner-event-source.js +43 -0
  80. package/dist/service/eventbridge/target/sim-event-target-dead-letter-config.d.ts +28 -0
  81. package/dist/service/eventbridge/target/sim-event-target-dead-letter-config.js +42 -0
  82. package/dist/service/eventbridge/target/sim-event-target-retry-policy.d.ts +28 -0
  83. package/dist/service/eventbridge/target/sim-event-target-retry-policy.js +53 -0
  84. package/dist/service/eventbridge/target/sim-event-target.d.ts +17 -0
  85. package/dist/service/eventbridge/target/sim-event-target.js +19 -0
  86. package/dist/service/scheduler/cfn/sim-cfn-schedule-properties.d.ts +0 -4
  87. package/dist/service/scheduler/cfn/sim-cfn-schedule-properties.js +2 -19
  88. package/dist/service/scheduler/cfn/sim-cfn-schedule-time-window.d.ts +10 -0
  89. package/dist/service/scheduler/cfn/sim-cfn-schedule-time-window.js +37 -0
  90. package/dist/service/scheduler/command/schedule/sim-scheduler-described-schedule.d.ts +1 -2
  91. package/dist/service/scheduler/command/schedule/sim-scheduler-described-schedule.js +2 -3
  92. package/dist/service/scheduler/command/schedule/sim-scheduler-schedule-writer.js +3 -0
  93. package/dist/service/scheduler/command/schedule/sim-scheduler-unsimulated-input.js +0 -25
  94. package/dist/service/scheduler/command/sim-scheduler-commands.d.ts +2 -0
  95. package/dist/service/scheduler/command/sim-scheduler-commands.js +1 -0
  96. package/dist/service/scheduler/schedule/sim-scheduler-pending-occurrences.d.ts +23 -0
  97. package/dist/service/scheduler/schedule/sim-scheduler-pending-occurrences.js +36 -0
  98. package/dist/service/scheduler/schedule/sim-scheduler-schedule.d.ts +7 -0
  99. package/dist/service/scheduler/schedule/sim-scheduler-schedule.js +5 -0
  100. package/dist/service/scheduler/schedule/sim-scheduler-schedules.d.ts +27 -1
  101. package/dist/service/scheduler/schedule/sim-scheduler-schedules.js +52 -8
  102. package/dist/service/scheduler/schedule/sim-scheduler-time-window.d.ts +33 -0
  103. package/dist/service/scheduler/schedule/sim-scheduler-time-window.js +93 -0
  104. package/dist/service/scheduler/sim-scheduler.d.ts +6 -0
  105. package/dist/service/scheduler/sim-scheduler.js +3 -1
  106. package/dist/util/random/sim-random.d.ts +35 -0
  107. package/dist/util/random/sim-random.js +33 -0
  108. package/docs/sdk/README.md +23 -0
  109. package/docs/services/eventbridge/README.md +223 -6
  110. package/docs/services/scheduler/README.md +68 -5
  111. package/docs/time/README.md +18 -0
  112. package/package.json +2 -2
@@ -1,6 +1,7 @@
1
+ import { SimEventBridgeDeliveryAttempt } from "./sim-event-bridge-delivery-attempt.js";
1
2
  import { SimEventBridgeDeliveryFailures } from "./sim-event-bridge-delivery-failures.js";
2
3
  /**
3
- * Makes one delivery and keeps whatever went wrong.
4
+ * Makes one delivery, with its retries, and keeps whatever went wrong.
4
5
  *
5
6
  * A failure is recorded rather than thrown, because these run as background
6
7
  * tasks and one left rejected would fail an unrelated
@@ -10,9 +11,11 @@ import { SimEventBridgeDeliveryFailures } from "./sim-event-bridge-delivery-fail
10
11
  */
11
12
  export class SimEventBridgeTargetDelivery {
12
13
  endpoints;
14
+ background;
13
15
  failures = new SimEventBridgeDeliveryFailures();
14
16
  constructor(properties) {
15
17
  this.endpoints = properties.endpoints;
18
+ this.background = properties.background;
16
19
  }
17
20
  /**
18
21
  * Every delivery that could not be made.
@@ -24,18 +27,20 @@ export class SimEventBridgeTargetDelivery {
24
27
  * Send one event to one target.
25
28
  */
26
29
  async deliver(request) {
27
- try {
28
- await this.endpoints.deliver(request);
29
- }
30
- catch (error) {
31
- this.failures.record({
32
- ruleName: request.ruleName,
33
- ruleArn: request.ruleArn,
34
- targetId: request.target.id,
35
- targetArn: request.target.arn.value,
36
- eventId: request.event.id,
37
- error,
38
- });
39
- }
30
+ await new SimEventBridgeDeliveryAttempt({
31
+ request,
32
+ endpoints: this.endpoints,
33
+ background: this.background,
34
+ record: (error) => {
35
+ this.failures.record({
36
+ ruleName: request.ruleName,
37
+ ruleArn: request.ruleArn,
38
+ targetId: request.target.id,
39
+ targetArn: request.target.arn.value,
40
+ eventId: request.event.id,
41
+ error,
42
+ });
43
+ },
44
+ }).start();
40
45
  }
41
46
  }
@@ -12,4 +12,6 @@ export { SimEventRuleName } from "./rule/sim-event-rule-name.js";
12
12
  export { SimEventRuleState } from "./rule/sim-event-rule-state.js";
13
13
  export { SimEventPattern } from "./pattern/sim-event-pattern.js";
14
14
  export type { SimEventBusReceipt } from "./bus/sim-event-bus.js";
15
+ export { partnerEventSourceArn, SimPartnerEventSource, type SimPartnerEventSourceState, } from "./source/sim-partner-event-source.js";
16
+ export { isPartnerEventSourceName, SimPartnerEventSourceName, } from "./source/sim-partner-event-source-name.js";
15
17
  export { SimEventBridgeAccessDeniedException, SimEventBridgeError, SimEventBridgeInvalidEventPatternException, SimEventBridgeResourceAlreadyExistsException, SimEventBridgeResourceNotFoundException, SimEventBridgeUnsimulatedInputException, SimEventBridgeValidationException, } from "./error/sim-event-bridge.error.js";
@@ -10,4 +10,6 @@ export { eventRuleArn } from "./rule/sim-event-rule-arn.js";
10
10
  export { SimEventRuleName } from "./rule/sim-event-rule-name.js";
11
11
  export { SimEventRuleState } from "./rule/sim-event-rule-state.js";
12
12
  export { SimEventPattern } from "./pattern/sim-event-pattern.js";
13
+ export { partnerEventSourceArn, SimPartnerEventSource, } from "./source/sim-partner-event-source.js";
14
+ export { isPartnerEventSourceName, SimPartnerEventSourceName, } from "./source/sim-partner-event-source-name.js";
13
15
  export { SimEventBridgeAccessDeniedException, SimEventBridgeError, SimEventBridgeInvalidEventPatternException, SimEventBridgeResourceAlreadyExistsException, SimEventBridgeResourceNotFoundException, SimEventBridgeUnsimulatedInputException, SimEventBridgeValidationException, } from "./error/sim-event-bridge.error.js";
@@ -26,6 +26,7 @@ export class SimEventBridgeRouter {
26
26
  this.accountId = properties.accountId;
27
27
  this.delivery = new SimEventBridgeTargetDelivery({
28
28
  endpoints: properties.endpoints,
29
+ background: properties.background,
29
30
  });
30
31
  }
31
32
  /**
@@ -22,6 +22,10 @@ export class SimEventBridgeSdkCommandRouter {
22
22
  "ListEventBusesCommand",
23
23
  async (command, context) => await simEventBridge.listEventBuses(command, simSdkCallerOptions(context)),
24
24
  ],
25
+ [
26
+ "DescribeEventSourceCommand",
27
+ async (command, context) => await simEventBridge.describeEventSource(command, simSdkCallerOptions(context)),
28
+ ],
25
29
  [
26
30
  "PutEventsCommand",
27
31
  async (command, context) => await simEventBridge.putEvents(command, simSdkCallerOptions(context)),
@@ -1,4 +1,6 @@
1
1
  import type { SimEventBusStore } from "./bus/sim-event-bus-store.js";
2
+ import type { SimEventBridgeCommands } from "./command/sim-event-bridge-commands.js";
3
+ import type { SimEventBridgeDeliveryFailure } from "./delivery/sim-event-bridge-delivery-failures.js";
2
4
  import type { SimEventBusReceipt } from "./bus/sim-event-bus.js";
3
5
  import type { SimEventBus } from "./bus/sim-event-bus.js";
4
6
  import type { SimEventBridgeEvent } from "./event/sim-event-bridge-event.js";
@@ -20,6 +22,14 @@ export declare abstract class SimEventBridgeInspection {
20
22
  protected abstract readonly buses: SimEventBusStore;
21
23
  protected abstract readonly rules: SimEventRuleStore;
22
24
  protected abstract readonly targets: SimEventTargetStore;
25
+ protected abstract readonly commands: SimEventBridgeCommands;
26
+ /**
27
+ * Every event this scope's rules could not get to a target.
28
+ *
29
+ * Real EventBridge tells the caller nothing about a failed delivery, and
30
+ * neither does this. A target that is unexpectedly empty is explained here.
31
+ */
32
+ get deliveryFailures(): readonly SimEventBridgeDeliveryFailure[];
23
33
  /**
24
34
  * Find an event bus by name.
25
35
  *
@@ -10,6 +10,15 @@ import { defaultEventBusName } from "./bus/sim-event-bus-name.js";
10
10
  * job that happens to live on the same object.
11
11
  */
12
12
  export class SimEventBridgeInspection {
13
+ /**
14
+ * Every event this scope's rules could not get to a target.
15
+ *
16
+ * Real EventBridge tells the caller nothing about a failed delivery, and
17
+ * neither does this. A target that is unexpectedly empty is explained here.
18
+ */
19
+ get deliveryFailures() {
20
+ return this.commands.router.deliveryFailures;
21
+ }
13
22
  /**
14
23
  * Find an event bus by name.
15
24
  *
@@ -0,0 +1,38 @@
1
+ import type { BackgroundScheduler } from "../../util/background/background.js";
2
+ import type { SimAwsAccountRegionScope } from "../aws/sim-aws-account-region-scope.js";
3
+ import type { SimPutPartnerEventsCommand, SimPutPartnerEventsCommandOutput } from "./command/source/source.command.js";
4
+ import { SimEventBridgeInspection } from "./sim-event-bridge-inspection.js";
5
+ import { SimPartnerEventSource } from "./source/sim-partner-event-source.js";
6
+ import type { SimPartnerEventSourceStore } from "./source/sim-partner-event-source-store.js";
7
+ /**
8
+ * What a test does as a SaaS partner sending events to a simulated Account.
9
+ *
10
+ * A partner such as Stripe works from its own Account, which is outside the
11
+ * simulation. It creates a partner event source shared with the receiving
12
+ * Account, and puts events onto it. Both are simulator accessors here rather
13
+ * than SDK commands, because the receiving Account's own clients never send
14
+ * either request.
15
+ */
16
+ export declare abstract class SimEventBridgePartners extends SimEventBridgeInspection {
17
+ protected abstract readonly partnerSources: SimPartnerEventSourceStore;
18
+ protected abstract readonly background: BackgroundScheduler;
19
+ protected abstract readonly accountRegionScope: SimAwsAccountRegionScope;
20
+ /**
21
+ * Share a partner event source with this Account and Region, as the
22
+ * partner's CreatePartnerEventSource does.
23
+ *
24
+ * The source starts pending. Creating a bus with the same `Name` and
25
+ * `EventSourceName` activates it, and that bus then receives what
26
+ * `putPartnerEvents` sends.
27
+ */
28
+ addPartnerEventSource(name: string): SimPartnerEventSource;
29
+ /**
30
+ * Put events onto partner event buses as their partner would, taking the
31
+ * shape of the partner's PutPartnerEvents request.
32
+ *
33
+ * Each entry's `Source` has to name a source `addPartnerEventSource` shared
34
+ * with this scope. The event goes to the bus of the same name, or nowhere if
35
+ * that bus has not been created yet.
36
+ */
37
+ putPartnerEvents(command: SimPutPartnerEventsCommand): Promise<SimPutPartnerEventsCommandOutput>;
38
+ }
@@ -0,0 +1,43 @@
1
+ import { SimEventBridgeInspection } from "./sim-event-bridge-inspection.js";
2
+ import { SimPartnerEventSource } from "./source/sim-partner-event-source.js";
3
+ import { SimPartnerEventSourceName } from "./source/sim-partner-event-source-name.js";
4
+ /**
5
+ * What a test does as a SaaS partner sending events to a simulated Account.
6
+ *
7
+ * A partner such as Stripe works from its own Account, which is outside the
8
+ * simulation. It creates a partner event source shared with the receiving
9
+ * Account, and puts events onto it. Both are simulator accessors here rather
10
+ * than SDK commands, because the receiving Account's own clients never send
11
+ * either request.
12
+ */
13
+ export class SimEventBridgePartners extends SimEventBridgeInspection {
14
+ /**
15
+ * Share a partner event source with this Account and Region, as the
16
+ * partner's CreatePartnerEventSource does.
17
+ *
18
+ * The source starts pending. Creating a bus with the same `Name` and
19
+ * `EventSourceName` activates it, and that bus then receives what
20
+ * `putPartnerEvents` sends.
21
+ */
22
+ addPartnerEventSource(name) {
23
+ const source = new SimPartnerEventSource({
24
+ name: SimPartnerEventSourceName.of(name, "Name"),
25
+ accountRegionScope: this.accountRegionScope,
26
+ createdAt: this.background.now(),
27
+ });
28
+ this.partnerSources.add(source);
29
+ return source;
30
+ }
31
+ /**
32
+ * Put events onto partner event buses as their partner would, taking the
33
+ * shape of the partner's PutPartnerEvents request.
34
+ *
35
+ * Each entry's `Source` has to name a source `addPartnerEventSource` shared
36
+ * with this scope. The event goes to the bus of the same name, or nowhere if
37
+ * that bus has not been created yet.
38
+ */
39
+ async putPartnerEvents(command) {
40
+ await this.background.sequence();
41
+ return this.commands.putPartnerEvents.handle(command);
42
+ }
43
+ }
@@ -4,13 +4,14 @@ import type { SimAwsAccountRegionScope } from "../aws/sim-aws-account-region-sco
4
4
  import type { SimIamInterServiceAuthZ } from "../iam/authorize/sim-iam-inter-service-auth-z.js";
5
5
  import { SimEventBusStore } from "./bus/sim-event-bus-store.js";
6
6
  import type * as simEventBridgeCommands from "./command/sim-event-bridge-command.types.js";
7
+ import { SimEventBridgeCommands } from "./command/sim-event-bridge-commands.js";
7
8
  import type { SimEventBridgeRequestOptions } from "./command/sim-event-bridge-request-options.js";
8
9
  import { SimEventRuleStore } from "./rule/sim-event-rule-store.js";
9
10
  import { SimEventTargetStore } from "./target/sim-event-target-store.js";
10
11
  import type { SimEventBridgeDeliveryTargets } from "./delivery/sim-event-bridge-delivery.js";
11
- import type { SimEventBridgeDeliveryFailure } from "./delivery/sim-event-bridge-delivery-failures.js";
12
12
  import { SimEventBridgeCfnResourceFactory } from "./cfn/sim-event-bridge-cfn-resource-factory.js";
13
- import { SimEventBridgeInspection } from "./sim-event-bridge-inspection.js";
13
+ import { SimEventBridgePartners } from "./sim-event-bridge-partners.js";
14
+ import { SimPartnerEventSourceStore } from "./source/sim-partner-event-source-store.js";
14
15
  interface SimEventBridgeProperties {
15
16
  readonly accountRegionScope?: SimAwsAccountRegionScope;
16
17
  readonly iam?: SimIamInterServiceAuthZ;
@@ -36,22 +37,17 @@ interface SimEventBridgeProperties {
36
37
  * matches nothing is gone. A rule carrying a schedule instead fires on the
37
38
  * simulation's own clock, so advancing time is what sends its event.
38
39
  */
39
- export declare class SimEventBridge extends SimEventBridgeInspection {
40
+ export declare class SimEventBridge extends SimEventBridgePartners {
40
41
  protected readonly buses: SimEventBusStore;
41
42
  protected readonly rules: SimEventRuleStore;
42
43
  protected readonly targets: SimEventTargetStore;
43
- private readonly commands;
44
- private readonly background;
44
+ protected readonly partnerSources: SimPartnerEventSourceStore;
45
+ protected readonly commands: SimEventBridgeCommands;
46
+ protected readonly background: BackgroundScheduler;
47
+ protected readonly accountRegionScope: SimAwsAccountRegionScope;
45
48
  private readonly sdkRouter;
46
49
  private readonly cfnFactory;
47
50
  constructor(properties?: SimEventBridgeProperties);
48
- /**
49
- * Every event this scope's rules could not get to a target.
50
- *
51
- * Real EventBridge tells the caller nothing about a failed delivery, and
52
- * neither does this. A target that is unexpectedly empty is explained here.
53
- */
54
- get deliveryFailures(): readonly SimEventBridgeDeliveryFailure[];
55
51
  /**
56
52
  * Handle a CreateEventBus Command from the SDK.
57
53
  */
@@ -68,6 +64,10 @@ export declare class SimEventBridge extends SimEventBridgeInspection {
68
64
  * Handle a ListEventBuses Command from the SDK.
69
65
  */
70
66
  listEventBuses(command: simEventBridgeCommands.SimListEventBusesCommand, options?: SimEventBridgeRequestOptions): Promise<simEventBridgeCommands.SimListEventBusesCommandOutput>;
67
+ /**
68
+ * Handle a DescribeEventSource Command from the SDK.
69
+ */
70
+ describeEventSource(command: simEventBridgeCommands.SimDescribeEventSourceCommand, options?: SimEventBridgeRequestOptions): Promise<simEventBridgeCommands.SimDescribeEventSourceCommandOutput>;
71
71
  /**
72
72
  * Handle a PutEvents Command from the SDK.
73
73
  */
@@ -8,7 +8,8 @@ import { SimEventRuleStore } from "./rule/sim-event-rule-store.js";
8
8
  import { SimEventTargetStore } from "./target/sim-event-target-store.js";
9
9
  import { SimEventBridgeCfnResourceFactory } from "./cfn/sim-event-bridge-cfn-resource-factory.js";
10
10
  import { SimEventBridgeSdkCommandRouter } from "./sdk/sim-event-bridge-sdk-command-router.js";
11
- import { SimEventBridgeInspection } from "./sim-event-bridge-inspection.js";
11
+ import { SimEventBridgePartners } from "./sim-event-bridge-partners.js";
12
+ import { SimPartnerEventSourceStore } from "./source/sim-partner-event-source-store.js";
12
13
  /**
13
14
  * Simulated EventBridge. Handles SDK commands. Emulates AWS behaviour and
14
15
  * state.
@@ -22,12 +23,14 @@ import { SimEventBridgeInspection } from "./sim-event-bridge-inspection.js";
22
23
  * matches nothing is gone. A rule carrying a schedule instead fires on the
23
24
  * simulation's own clock, so advancing time is what sends its event.
24
25
  */
25
- export class SimEventBridge extends SimEventBridgeInspection {
26
+ export class SimEventBridge extends SimEventBridgePartners {
26
27
  buses;
27
28
  rules = new SimEventRuleStore();
28
29
  targets = new SimEventTargetStore();
30
+ partnerSources = new SimPartnerEventSourceStore();
29
31
  commands;
30
32
  background;
33
+ accountRegionScope;
31
34
  sdkRouter = new SimEventBridgeSdkCommandRouter(this);
32
35
  cfnFactory = new SimEventBridgeCfnResourceFactory({
33
36
  eventBridge: this,
@@ -37,26 +40,19 @@ export class SimEventBridge extends SimEventBridgeInspection {
37
40
  const { accountRegionScope = simAwsAccountRegionScopeFactory.make(), background = new BackgroundTasks(), } = properties;
38
41
  const iam = simIamInRegion(properties.iam, accountRegionScope.regionName);
39
42
  this.background = background;
43
+ this.accountRegionScope = accountRegionScope;
40
44
  this.buses = new SimEventBusStore(SimEventBus.default({ accountRegionScope, createdAt: background.now() }));
41
45
  this.commands = new SimEventBridgeCommands({
42
46
  buses: this.buses,
43
47
  rules: this.rules,
44
48
  targets: this.targets,
49
+ partnerSources: this.partnerSources,
45
50
  deliveryTargets: properties.deliveryTargets,
46
51
  iam,
47
52
  background,
48
53
  accountRegionScope,
49
54
  });
50
55
  }
51
- /**
52
- * Every event this scope's rules could not get to a target.
53
- *
54
- * Real EventBridge tells the caller nothing about a failed delivery, and
55
- * neither does this. A target that is unexpectedly empty is explained here.
56
- */
57
- get deliveryFailures() {
58
- return this.commands.router.deliveryFailures;
59
- }
60
56
  /**
61
57
  * Handle a CreateEventBus Command from the SDK.
62
58
  */
@@ -85,6 +81,13 @@ export class SimEventBridge extends SimEventBridgeInspection {
85
81
  await this.background.sequence();
86
82
  return this.commands.buses.listEventBuses(command, options);
87
83
  }
84
+ /**
85
+ * Handle a DescribeEventSource Command from the SDK.
86
+ */
87
+ async describeEventSource(command, options) {
88
+ await this.background.sequence();
89
+ return this.commands.eventSources.handle(command, options);
90
+ }
88
91
  /**
89
92
  * Handle a PutEvents Command from the SDK.
90
93
  */
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Whether a string has the shape of a partner event source name.
3
+ *
4
+ * A partner event bus takes the name of its source, so this is also the one
5
+ * shape of bus name that may carry a `/`.
6
+ */
7
+ export declare function isPartnerEventSourceName(value: string): boolean;
8
+ /**
9
+ * The name of one partner event source.
10
+ *
11
+ * A SaaS partner names the source when it creates it, in the form
12
+ * `aws.partner/<partner>/<name>`. The receiving Account never chooses the
13
+ * name. It creates a bus under the same one.
14
+ */
15
+ export declare class SimPartnerEventSourceName {
16
+ readonly value: string;
17
+ private constructor();
18
+ /**
19
+ * Read a partner event source name from request input, refusing one real
20
+ * EventBridge would refuse.
21
+ */
22
+ static of(value: string, parameterName: string): SimPartnerEventSourceName;
23
+ /**
24
+ * The partner that created the source, which is the segment after
25
+ * `aws.partner`.
26
+ */
27
+ get partner(): string;
28
+ }
@@ -0,0 +1,62 @@
1
+ import { SimEventBridgeValidationException } from "../error/sim-event-bridge.error.js";
2
+ const partnerPrefix = "aws.partner/";
3
+ /**
4
+ * The characters one segment of a partner event source name may carry.
5
+ */
6
+ const partnerSegmentPattern = /^[.\-_A-Za-z0-9]+$/;
7
+ /**
8
+ * Real EventBridge wants the partner's own name and at least one more segment
9
+ * after the prefix, such as `aws.partner/stripe.com/ed_test`.
10
+ */
11
+ const minimumPartnerSegments = 2;
12
+ const maximumPartnerEventSourceNameLength = 256;
13
+ const partnerSegmentStart = partnerPrefix.length;
14
+ /**
15
+ * Whether a string has the shape of a partner event source name.
16
+ *
17
+ * A partner event bus takes the name of its source, so this is also the one
18
+ * shape of bus name that may carry a `/`.
19
+ */
20
+ export function isPartnerEventSourceName(value) {
21
+ // Read segment by segment, which is the API's own pattern
22
+ // `aws\.partner(/[\.\-_A-Za-z0-9]+){2,}` without the nested repetition.
23
+ const segments = value.slice(partnerSegmentStart).split("/");
24
+ return (value.length <= maximumPartnerEventSourceNameLength &&
25
+ value.startsWith(partnerPrefix) &&
26
+ segments.length >= minimumPartnerSegments &&
27
+ segments.every((segment) => partnerSegmentPattern.test(segment)));
28
+ }
29
+ /**
30
+ * The name of one partner event source.
31
+ *
32
+ * A SaaS partner names the source when it creates it, in the form
33
+ * `aws.partner/<partner>/<name>`. The receiving Account never chooses the
34
+ * name. It creates a bus under the same one.
35
+ */
36
+ export class SimPartnerEventSourceName {
37
+ value;
38
+ constructor(value) {
39
+ this.value = value;
40
+ }
41
+ /**
42
+ * Read a partner event source name from request input, refusing one real
43
+ * EventBridge would refuse.
44
+ */
45
+ static of(value, parameterName) {
46
+ if (!isPartnerEventSourceName(value)) {
47
+ throw new SimEventBridgeValidationException(`Invalid parameter: ${parameterName} Reason: '${value}' is not a ` +
48
+ `partner event source name, which takes the form ` +
49
+ `aws.partner/<partner>/<name> and is at most ` +
50
+ `${String(maximumPartnerEventSourceNameLength)} characters long.`);
51
+ }
52
+ return new this(value);
53
+ }
54
+ /**
55
+ * The partner that created the source, which is the segment after
56
+ * `aws.partner`.
57
+ */
58
+ get partner() {
59
+ // The pattern guarantees a `/` after the partner segment.
60
+ return this.value.slice(partnerSegmentStart, this.value.indexOf("/", partnerSegmentStart));
61
+ }
62
+ }
@@ -0,0 +1,18 @@
1
+ import type { SimPartnerEventSource } from "./sim-partner-event-source.js";
2
+ /**
3
+ * The partner event sources shared with one simulated EventBridge scope.
4
+ *
5
+ * Sources are keyed by name. A partner names each one uniquely across every
6
+ * Account it serves, so a name is enough to find one.
7
+ */
8
+ export declare class SimPartnerEventSourceStore {
9
+ private readonly sources;
10
+ /**
11
+ * Store a newly created source, refusing a name already taken.
12
+ */
13
+ add(source: SimPartnerEventSource): void;
14
+ /**
15
+ * Resolve a source by name, or refuse.
16
+ */
17
+ require(name: string): SimPartnerEventSource;
18
+ }
@@ -0,0 +1,29 @@
1
+ import { SimEventBridgeResourceAlreadyExistsException, SimEventBridgeResourceNotFoundException, } from "../error/sim-event-bridge.error.js";
2
+ /**
3
+ * The partner event sources shared with one simulated EventBridge scope.
4
+ *
5
+ * Sources are keyed by name. A partner names each one uniquely across every
6
+ * Account it serves, so a name is enough to find one.
7
+ */
8
+ export class SimPartnerEventSourceStore {
9
+ sources = new Map();
10
+ /**
11
+ * Store a newly created source, refusing a name already taken.
12
+ */
13
+ add(source) {
14
+ if (this.sources.has(source.name.value)) {
15
+ throw new SimEventBridgeResourceAlreadyExistsException(`Event source ${source.name.value} already exists.`);
16
+ }
17
+ this.sources.set(source.name.value, source);
18
+ }
19
+ /**
20
+ * Resolve a source by name, or refuse.
21
+ */
22
+ require(name) {
23
+ const found = this.sources.get(name);
24
+ if (found === undefined) {
25
+ throw new SimEventBridgeResourceNotFoundException(`Event source ${name} does not exist.`);
26
+ }
27
+ return found;
28
+ }
29
+ }
@@ -0,0 +1,46 @@
1
+ import type { SimAwsAccountRegionScope } from "../../aws/sim-aws-account-region-scope.js";
2
+ import type { SimPartnerEventSourceName } from "./sim-partner-event-source-name.js";
3
+ /**
4
+ * The states a partner event source reports.
5
+ *
6
+ * `DELETED` is absent. It belongs to a source the partner deleted while its
7
+ * bus was still there, and nothing here deletes a source.
8
+ */
9
+ export type SimPartnerEventSourceState = "ACTIVE" | "PENDING";
10
+ /**
11
+ * The ARN of a partner event source, which a request authorizes against
12
+ * before the source is looked up.
13
+ *
14
+ * The ARN carries no Account. The source is the partner's resource, shared
15
+ * with the receiving Account, and real EventBridge writes it with an empty
16
+ * Account field, as the `resources` of a Stripe event show.
17
+ */
18
+ export declare function partnerEventSourceArn(name: SimPartnerEventSourceName, accountRegionScope: SimAwsAccountRegionScope): string;
19
+ interface SimPartnerEventSourceProperties {
20
+ readonly name: SimPartnerEventSourceName;
21
+ readonly accountRegionScope: SimAwsAccountRegionScope;
22
+ readonly createdAt: Date;
23
+ }
24
+ /**
25
+ * One partner event source, shared with a receiving Account and Region.
26
+ *
27
+ * A SaaS partner creates the source from its own Account, naming the Account
28
+ * that may receive from it. The receiving Account activates it by creating a
29
+ * partner event bus under the same name, and the partner's events then land
30
+ * on that bus.
31
+ *
32
+ * The state is worked out from whether that bus exists rather than stored
33
+ * here. Creating the bus is what activates a source on real AWS, and deleting
34
+ * the bus puts it back to pending.
35
+ */
36
+ export declare class SimPartnerEventSource {
37
+ readonly name: SimPartnerEventSourceName;
38
+ readonly arn: string;
39
+ readonly creationTime: Date;
40
+ constructor(properties: SimPartnerEventSourceProperties);
41
+ /**
42
+ * The source's state, given whether a bus of its name exists.
43
+ */
44
+ state(hasBus: boolean): SimPartnerEventSourceState;
45
+ }
46
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The ARN of a partner event source, which a request authorizes against
3
+ * before the source is looked up.
4
+ *
5
+ * The ARN carries no Account. The source is the partner's resource, shared
6
+ * with the receiving Account, and real EventBridge writes it with an empty
7
+ * Account field, as the `resources` of a Stripe event show.
8
+ */
9
+ export function partnerEventSourceArn(name, accountRegionScope) {
10
+ return `arn:aws:events:${accountRegionScope.regionName}::event-source/${name.value}`;
11
+ }
12
+ /**
13
+ * One partner event source, shared with a receiving Account and Region.
14
+ *
15
+ * A SaaS partner creates the source from its own Account, naming the Account
16
+ * that may receive from it. The receiving Account activates it by creating a
17
+ * partner event bus under the same name, and the partner's events then land
18
+ * on that bus.
19
+ *
20
+ * The state is worked out from whether that bus exists rather than stored
21
+ * here. Creating the bus is what activates a source on real AWS, and deleting
22
+ * the bus puts it back to pending.
23
+ */
24
+ export class SimPartnerEventSource {
25
+ name;
26
+ arn;
27
+ creationTime;
28
+ constructor(properties) {
29
+ const { name, accountRegionScope } = properties;
30
+ this.name = name;
31
+ this.arn = partnerEventSourceArn(name, accountRegionScope);
32
+ this.creationTime = properties.createdAt;
33
+ }
34
+ /**
35
+ * The source's state, given whether a bus of its name exists.
36
+ */
37
+ state(hasBus) {
38
+ if (hasBus) {
39
+ return "ACTIVE";
40
+ }
41
+ return "PENDING";
42
+ }
43
+ }
@@ -0,0 +1,28 @@
1
+ import { type SimSqsQueueLocation } from "../../sqs/queue/sim-sqs-queue-arn.js";
2
+ /**
3
+ * A target's `DeadLetterConfig`, as a request or a template carries it.
4
+ */
5
+ export interface SimEventTargetDeadLetterConfigInput {
6
+ readonly Arn?: string | undefined;
7
+ }
8
+ /**
9
+ * The standard SQS queue a target sends an event to once EventBridge gives up
10
+ * delivering it.
11
+ */
12
+ export declare class SimEventTargetDeadLetterConfig {
13
+ readonly declared: SimEventTargetDeadLetterConfigInput;
14
+ readonly arn: string;
15
+ readonly queue: SimSqsQueueLocation;
16
+ private constructor();
17
+ /**
18
+ * Read the dead-letter configuration a target may leave out.
19
+ */
20
+ static optional(config: SimEventTargetDeadLetterConfigInput | undefined): SimEventTargetDeadLetterConfig | undefined;
21
+ /**
22
+ * Read a dead-letter configuration, refusing anything but a standard queue.
23
+ *
24
+ * Real EventBridge takes only a standard queue here. A FIFO queue is refused
25
+ * by its name, which always ends `.fifo`.
26
+ */
27
+ static of(config: SimEventTargetDeadLetterConfigInput): SimEventTargetDeadLetterConfig;
28
+ }
@@ -0,0 +1,42 @@
1
+ import { parseSqsQueueArn, } from "../../sqs/queue/sim-sqs-queue-arn.js";
2
+ import { SimEventBridgeValidationException } from "../error/sim-event-bridge.error.js";
3
+ const fifoQueueSuffix = ".fifo";
4
+ /**
5
+ * The standard SQS queue a target sends an event to once EventBridge gives up
6
+ * delivering it.
7
+ */
8
+ export class SimEventTargetDeadLetterConfig {
9
+ declared;
10
+ arn;
11
+ queue;
12
+ constructor(declared, arn, queue) {
13
+ this.declared = { ...declared };
14
+ this.arn = arn;
15
+ this.queue = queue;
16
+ }
17
+ /**
18
+ * Read the dead-letter configuration a target may leave out.
19
+ */
20
+ static optional(config) {
21
+ if (config === undefined) {
22
+ return undefined;
23
+ }
24
+ return this.of(config);
25
+ }
26
+ /**
27
+ * Read a dead-letter configuration, refusing anything but a standard queue.
28
+ *
29
+ * Real EventBridge takes only a standard queue here. A FIFO queue is refused
30
+ * by its name, which always ends `.fifo`.
31
+ */
32
+ static of(config) {
33
+ const arn = config.Arn ?? "";
34
+ const queue = parseSqsQueueArn(arn);
35
+ if (queue === undefined || queue.name.endsWith(fifoQueueSuffix)) {
36
+ throw new SimEventBridgeValidationException(`Invalid parameter: Target DeadLetterConfig Arn Reason: '${arn}' is ` +
37
+ `not a standard SQS queue ARN. One is ` +
38
+ `arn:aws:sqs:<region>:<account-id>:<queue-name>.`);
39
+ }
40
+ return new this(config, arn, queue);
41
+ }
42
+ }