@kensio/yulin 1.21.26 → 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 (74) hide show
  1. package/dist/service/eventbridge/bus/sim-event-bus-name.d.ts +4 -0
  2. package/dist/service/eventbridge/bus/sim-event-bus-name.js +17 -12
  3. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-creator.js +8 -1
  4. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.d.ts +5 -0
  5. package/dist/service/eventbridge/cfn/bus/sim-cfn-event-bus-properties.js +14 -1
  6. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-creator.js +2 -0
  7. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-target-delivery.d.ts +15 -0
  8. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-target-delivery.js +53 -0
  9. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-targets.d.ts +4 -0
  10. package/dist/service/eventbridge/cfn/rule/sim-cfn-event-rule-targets.js +7 -3
  11. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.d.ts +5 -0
  12. package/dist/service/eventbridge/command/authorize/sim-event-bridge-authorizer.js +7 -0
  13. package/dist/service/eventbridge/command/bus/sim-event-bridge-create-event-bus.d.ts +7 -1
  14. package/dist/service/eventbridge/command/bus/sim-event-bridge-create-event-bus.js +7 -1
  15. package/dist/service/eventbridge/command/bus/sim-event-bridge-partner-bus.d.ts +24 -0
  16. package/dist/service/eventbridge/command/bus/sim-event-bridge-partner-bus.js +44 -0
  17. package/dist/service/eventbridge/command/bus/sim-event-bridge-unsimulated-bus-input.js +0 -5
  18. package/dist/service/eventbridge/command/put-events/sim-event-bridge-authorized-entries.js +8 -0
  19. package/dist/service/eventbridge/command/sim-event-bridge-command.types.d.ts +1 -0
  20. package/dist/service/eventbridge/command/sim-event-bridge-commands.d.ts +6 -0
  21. package/dist/service/eventbridge/command/sim-event-bridge-commands.js +19 -1
  22. package/dist/service/eventbridge/command/source/sim-event-bridge-describe-event-source.d.ts +35 -0
  23. package/dist/service/eventbridge/command/source/sim-event-bridge-describe-event-source.js +46 -0
  24. package/dist/service/eventbridge/command/source/sim-event-bridge-put-partner-events.d.ts +41 -0
  25. package/dist/service/eventbridge/command/source/sim-event-bridge-put-partner-events.js +82 -0
  26. package/dist/service/eventbridge/command/source/source.command.d.ts +59 -0
  27. package/dist/service/eventbridge/command/source/source.command.js +1 -0
  28. package/dist/service/eventbridge/command/target/sim-event-bridge-target-commands.js +2 -0
  29. package/dist/service/eventbridge/command/target/sim-event-bridge-unsimulated-target-input.js +2 -12
  30. package/dist/service/eventbridge/command/target/target.command.d.ts +8 -5
  31. package/dist/service/eventbridge/delivery/sim-aws-event-bridge-delivery-targets.d.ts +6 -1
  32. package/dist/service/eventbridge/delivery/sim-aws-event-bridge-delivery-targets.js +16 -0
  33. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-attributes.d.ts +9 -0
  34. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-attributes.js +47 -0
  35. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-queue.d.ts +24 -0
  36. package/dist/service/eventbridge/delivery/sim-event-bridge-dead-letter-queue.js +28 -0
  37. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-attempt.d.ts +41 -0
  38. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-attempt.js +97 -0
  39. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-queue.js +7 -37
  40. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-retries.test-support.d.ts +25 -0
  41. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-retries.test-support.js +60 -0
  42. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery.d.ts +22 -0
  43. package/dist/service/eventbridge/delivery/sim-event-bridge-failing-targets.test-support.d.ts +23 -0
  44. package/dist/service/eventbridge/delivery/sim-event-bridge-failing-targets.test-support.js +28 -0
  45. package/dist/service/eventbridge/delivery/sim-event-bridge-no-delivery-targets.d.ts +5 -1
  46. package/dist/service/eventbridge/delivery/sim-event-bridge-no-delivery-targets.js +9 -0
  47. package/dist/service/eventbridge/delivery/sim-event-bridge-queue-message.d.ts +28 -0
  48. package/dist/service/eventbridge/delivery/sim-event-bridge-queue-message.js +45 -0
  49. package/dist/service/eventbridge/delivery/sim-event-bridge-target-delivery.d.ts +4 -1
  50. package/dist/service/eventbridge/delivery/sim-event-bridge-target-delivery.js +19 -14
  51. package/dist/service/eventbridge/index.d.ts +2 -0
  52. package/dist/service/eventbridge/index.js +2 -0
  53. package/dist/service/eventbridge/routing/sim-event-bridge-router.js +1 -0
  54. package/dist/service/eventbridge/sdk/sim-event-bridge-sdk-command-router.js +4 -0
  55. package/dist/service/eventbridge/sim-event-bridge-inspection.d.ts +10 -0
  56. package/dist/service/eventbridge/sim-event-bridge-inspection.js +9 -0
  57. package/dist/service/eventbridge/sim-event-bridge-partners.d.ts +38 -0
  58. package/dist/service/eventbridge/sim-event-bridge-partners.js +43 -0
  59. package/dist/service/eventbridge/sim-event-bridge.d.ts +12 -12
  60. package/dist/service/eventbridge/sim-event-bridge.js +14 -11
  61. package/dist/service/eventbridge/source/sim-partner-event-source-name.d.ts +28 -0
  62. package/dist/service/eventbridge/source/sim-partner-event-source-name.js +62 -0
  63. package/dist/service/eventbridge/source/sim-partner-event-source-store.d.ts +18 -0
  64. package/dist/service/eventbridge/source/sim-partner-event-source-store.js +29 -0
  65. package/dist/service/eventbridge/source/sim-partner-event-source.d.ts +46 -0
  66. package/dist/service/eventbridge/source/sim-partner-event-source.js +43 -0
  67. package/dist/service/eventbridge/target/sim-event-target-dead-letter-config.d.ts +28 -0
  68. package/dist/service/eventbridge/target/sim-event-target-dead-letter-config.js +42 -0
  69. package/dist/service/eventbridge/target/sim-event-target-retry-policy.d.ts +28 -0
  70. package/dist/service/eventbridge/target/sim-event-target-retry-policy.js +53 -0
  71. package/dist/service/eventbridge/target/sim-event-target.d.ts +17 -0
  72. package/dist/service/eventbridge/target/sim-event-target.js +19 -0
  73. package/docs/services/eventbridge/README.md +223 -6
  74. package/package.json +1 -1
@@ -29,6 +29,10 @@ export declare class SimEventBusName {
29
29
  * refuse.
30
30
  */
31
31
  static of(value: string): SimEventBusName;
32
+ /**
33
+ * Whether this is the name of a partner event bus.
34
+ */
35
+ get isPartner(): boolean;
32
36
  /**
33
37
  * Whether this is the name of the default event bus.
34
38
  */
@@ -1,4 +1,5 @@
1
- import { SimEventBridgeUnsimulatedInputException, SimEventBridgeValidationException, } from "../error/sim-event-bridge.error.js";
1
+ import { SimEventBridgeValidationException } from "../error/sim-event-bridge.error.js";
2
+ import { isPartnerEventSourceName } from "../source/sim-partner-event-source-name.js";
2
3
  /**
3
4
  * The name of the event bus every Account has without creating one.
4
5
  *
@@ -10,7 +11,8 @@ export const defaultEventBusName = "default";
10
11
  /**
11
12
  * Real EventBridge allows alphanumerics, full stops, hyphens and underscores,
12
13
  * up to 256 characters. The `/` character is in the API's own pattern but only
13
- * for partner event bus names, which take the form `aws.partner/...`.
14
+ * for partner event bus names, which take the name of their partner event
15
+ * source, `aws.partner/<partner>/<name>`.
14
16
  */
15
17
  const eventBusNamePattern = /^[.\-_A-Za-z0-9]{1,256}$/;
16
18
  const partnerNameSeparator = "/";
@@ -46,17 +48,20 @@ export class SimEventBusName {
46
48
  * refuse.
47
49
  */
48
50
  static of(value) {
49
- if (value.includes(partnerNameSeparator)) {
50
- throw new SimEventBridgeUnsimulatedInputException(`Event bus name '${value}' carries a '/', which only a partner event ` +
51
- `bus name does. Partner event buses are not simulated.`);
51
+ if (eventBusNamePattern.test(value) || isPartnerEventSourceName(value)) {
52
+ return new this(value);
52
53
  }
53
- if (!eventBusNamePattern.test(value)) {
54
- throw new SimEventBridgeValidationException(`Invalid parameter: Name Reason: '${value}' is not a valid event bus ` +
55
- `name. Event bus names are made up of only letters, numbers, full ` +
56
- `stops, hyphens and underscores, and are between 1 and 256 ` +
57
- `characters long.`);
58
- }
59
- return new this(value);
54
+ throw new SimEventBridgeValidationException(`Invalid parameter: Name Reason: '${value}' is not a valid event bus ` +
55
+ `name. Event bus names are made up of only letters, numbers, full ` +
56
+ `stops, hyphens and underscores, and are between 1 and 256 ` +
57
+ `characters long. Only a partner event bus name carries a '/', and ` +
58
+ `it takes the form aws.partner/<partner>/<name>.`);
59
+ }
60
+ /**
61
+ * Whether this is the name of a partner event bus.
62
+ */
63
+ get isPartner() {
64
+ return this.value.includes(partnerNameSeparator);
60
65
  }
61
66
  /**
62
67
  * Whether this is the name of the default event bus.
@@ -27,8 +27,15 @@ export class SimCfnEventBusCreator {
27
27
  busProperties.recordIgnoredProperties();
28
28
  const name = busProperties.name();
29
29
  const description = busProperties.description();
30
+ const eventSourceName = busProperties.eventSourceName();
30
31
  return await simCfnEventBridgeResourceCreation(eventBusResourceType, resource.logicalId, async () => {
31
- await this.eventBridge.createEventBus({ input: { Name: name, Description: description } }, options);
32
+ await this.eventBridge.createEventBus({
33
+ input: {
34
+ Name: name,
35
+ Description: description,
36
+ EventSourceName: eventSourceName,
37
+ },
38
+ }, options);
32
39
  const bus = this.eventBridge.findEventBus(name);
33
40
  assertDefined(bus, `sim EventBridge bus ${name} after CloudFormation creation`);
34
41
  return bus;
@@ -23,6 +23,11 @@ export declare class SimCfnEventBusProperties {
23
23
  * The bus description, which a template may leave out.
24
24
  */
25
25
  description(): string | undefined;
26
+ /**
27
+ * The partner event source a partner event bus is matched with, which a
28
+ * custom bus leaves out.
29
+ */
30
+ eventSourceName(): string | undefined;
26
31
  /**
27
32
  * Refuse what this simulation does not model, naming the property.
28
33
  */
@@ -16,7 +16,6 @@ const unsimulatedProperties = [
16
16
  "DeadLetterConfig",
17
17
  "an undeliverable event is recorded rather than sent on",
18
18
  ],
19
- ["EventSourceName", "partner event buses are not simulated"],
20
19
  ["KmsKeyIdentifier", "events are not encrypted with a customer managed key"],
21
20
  ["LogConfig", "event bus logging is not simulated"],
22
21
  ];
@@ -73,6 +72,20 @@ export class SimCfnEventBusProperties {
73
72
  }
74
73
  return description;
75
74
  }
75
+ /**
76
+ * The partner event source a partner event bus is matched with, which a
77
+ * custom bus leaves out.
78
+ */
79
+ eventSourceName() {
80
+ const eventSourceName = this.properties.get("EventSourceName");
81
+ if (eventSourceName === undefined) {
82
+ return undefined;
83
+ }
84
+ if (typeof eventSourceName !== "string") {
85
+ throw this.propertyError("EventSourceName must be a string");
86
+ }
87
+ return eventSourceName;
88
+ }
76
89
  /**
77
90
  * Refuse what this simulation does not model, naming the property.
78
91
  */
@@ -65,6 +65,8 @@ export class SimCfnEventRuleCreator {
65
65
  Id: target.Id,
66
66
  Arn: target.Arn,
67
67
  Input: target.Input,
68
+ DeadLetterConfig: target.DeadLetterConfig,
69
+ RetryPolicy: target.RetryPolicy,
68
70
  })),
69
71
  },
70
72
  }, options);
@@ -0,0 +1,15 @@
1
+ import type { SimEventTargetDeadLetterConfigInput } from "../../target/sim-event-target-dead-letter-config.js";
2
+ import type { SimEventTargetRetryPolicyInput } from "../../target/sim-event-target-retry-policy.js";
3
+ /**
4
+ * What a rule's target says about retrying a failed delivery, and where an
5
+ * undelivered event goes.
6
+ */
7
+ interface SimCfnEventRuleTargetDelivery {
8
+ readonly DeadLetterConfig: SimEventTargetDeadLetterConfigInput | undefined;
9
+ readonly RetryPolicy: SimEventTargetRetryPolicyInput | undefined;
10
+ }
11
+ /**
12
+ * Read a target's `DeadLetterConfig` and `RetryPolicy` from a template.
13
+ */
14
+ export declare function simCfnEventRuleTargetDelivery(target: Record<string, unknown>, refuse: (reason: string) => Error): SimCfnEventRuleTargetDelivery;
15
+ export {};
@@ -0,0 +1,53 @@
1
+ import { isRecord } from "../../../../util/type-guard/record.js";
2
+ /**
3
+ * Read a target's `DeadLetterConfig` and `RetryPolicy` from a template.
4
+ */
5
+ export function simCfnEventRuleTargetDelivery(target, refuse) {
6
+ return {
7
+ DeadLetterConfig: readDeadLetterConfig(target["DeadLetterConfig"], refuse),
8
+ RetryPolicy: readRetryPolicy(target["RetryPolicy"], refuse),
9
+ };
10
+ }
11
+ /**
12
+ * Read a target's `DeadLetterConfig`, whose `Arn` is a queue ARN.
13
+ *
14
+ * Whether the ARN names a standard queue is left to PutTargets, so a template
15
+ * and an SDK caller are refused the same way.
16
+ */
17
+ function readDeadLetterConfig(config, refuse) {
18
+ if (config === undefined) {
19
+ return undefined;
20
+ }
21
+ if (!isRecord(config) || typeof config["Arn"] !== "string") {
22
+ throw refuse("DeadLetterConfig needs an Arn");
23
+ }
24
+ return { Arn: config["Arn"] };
25
+ }
26
+ /**
27
+ * Read a target's `RetryPolicy`, whose two limits are numbers.
28
+ *
29
+ * Their ranges are left to PutTargets, so a template and an SDK caller are
30
+ * refused the same way.
31
+ */
32
+ function readRetryPolicy(policy, refuse) {
33
+ if (policy === undefined) {
34
+ return undefined;
35
+ }
36
+ if (!isRecord(policy)) {
37
+ throw refuse("RetryPolicy is an object");
38
+ }
39
+ return {
40
+ MaximumEventAgeInSeconds: readLimit(policy, "MaximumEventAgeInSeconds", refuse),
41
+ MaximumRetryAttempts: readLimit(policy, "MaximumRetryAttempts", refuse),
42
+ };
43
+ }
44
+ /**
45
+ * Read one numeric limit of a retry policy, which may be left out.
46
+ */
47
+ function readLimit(policy, name, refuse) {
48
+ const value = new Map(Object.entries(policy)).get(name);
49
+ if (value === undefined || typeof value === "number") {
50
+ return value;
51
+ }
52
+ throw refuse(`RetryPolicy ${name} must be a number`);
53
+ }
@@ -1,4 +1,6 @@
1
1
  import type { SimCfnTemplateValue } from "../../../cloudformation/template/value/sim-cfn-template-value.js";
2
+ import type { SimEventTargetDeadLetterConfigInput } from "../../target/sim-event-target-dead-letter-config.js";
3
+ import type { SimEventTargetRetryPolicyInput } from "../../target/sim-event-target-retry-policy.js";
2
4
  /**
3
5
  * One target of a rule, as this simulation takes it.
4
6
  */
@@ -6,6 +8,8 @@ export interface SimCfnEventRuleTarget {
6
8
  readonly Id: string;
7
9
  readonly Arn: string;
8
10
  readonly Input?: string | undefined;
11
+ readonly DeadLetterConfig?: SimEventTargetDeadLetterConfigInput | undefined;
12
+ readonly RetryPolicy?: SimEventTargetRetryPolicyInput | undefined;
9
13
  }
10
14
  /**
11
15
  * Read a rule's inline `Targets` list.
@@ -1,4 +1,5 @@
1
1
  import { isRecord } from "../../../../util/type-guard/record.js";
2
+ import { simCfnEventRuleTargetDelivery } from "./sim-cfn-event-rule-target-delivery.js";
2
3
  /**
3
4
  * What a template can say about a target that this simulation does not model.
4
5
  *
@@ -14,8 +15,6 @@ const unsimulatedTargetProperties = [
14
15
  "a rule reaches its target as the EventBridge service principal, and an " +
15
16
  "ECS target, which does carry a role, is written with PutTargets",
16
17
  ],
17
- ["DeadLetterConfig", "a failed delivery is recorded rather than sent on"],
18
- ["RetryPolicy", "a delivery is attempted once"],
19
18
  ["SqsParameters", "a FIFO queue target is not simulated"],
20
19
  ["KinesisParameters", "Kinesis is not a simulated target"],
21
20
  [
@@ -62,7 +61,12 @@ function readTarget(target, refuse) {
62
61
  if (input !== undefined && typeof input !== "string") {
63
62
  throw refuse(`target ${id} Input must be a string of JSON`);
64
63
  }
65
- return { Id: id, Arn: arn, Input: input };
64
+ return {
65
+ Id: id,
66
+ Arn: arn,
67
+ Input: input,
68
+ ...simCfnEventRuleTargetDelivery(target, (reason) => refuse(`target ${id} ${reason}`)),
69
+ };
66
70
  }
67
71
  /**
68
72
  * Read a rule's inline `Targets` list.
@@ -45,6 +45,11 @@ export declare class SimEventBridgeAuthorizer {
45
45
  * may well not be there.
46
46
  */
47
47
  authorizeBus(action: string, busArn: string, options?: SimEventBridgeRequestOptions): SimAwsResolvedCaller;
48
+ /**
49
+ * Ensure the caller may perform an action on a partner event source, named
50
+ * by its ARN.
51
+ */
52
+ authorizeEventSource(action: string, sourceArn: string, options?: SimEventBridgeRequestOptions): SimAwsResolvedCaller;
48
53
  /**
49
54
  * Ensure the caller may perform an action that names no particular bus.
50
55
  */
@@ -62,6 +62,13 @@ export class SimEventBridgeAuthorizer {
62
62
  authorizeBus(action, busArn, options) {
63
63
  return this.authorizeResource(action, busArn, options);
64
64
  }
65
+ /**
66
+ * Ensure the caller may perform an action on a partner event source, named
67
+ * by its ARN.
68
+ */
69
+ authorizeEventSource(action, sourceArn, options) {
70
+ return this.authorizeResource(action, sourceArn, options);
71
+ }
65
72
  /**
66
73
  * Ensure the caller may perform an action that names no particular bus.
67
74
  */
@@ -3,10 +3,12 @@ import type { SimAwsAccountRegionScope } from "../../../aws/sim-aws-account-regi
3
3
  import type { SimEventBusStore } from "../../bus/sim-event-bus-store.js";
4
4
  import type { SimEventBridgeRequestOptions } from "../sim-event-bridge-request-options.js";
5
5
  import type { SimEventBridgeBusAccess } from "./sim-event-bridge-bus-access.js";
6
+ import type { SimEventBridgePartnerBus } from "./sim-event-bridge-partner-bus.js";
6
7
  import type { SimCreateEventBusCommand, SimCreateEventBusCommandOutput } from "./bus.command.js";
7
8
  interface SimEventBridgeCreateEventBusProperties {
8
9
  readonly buses: SimEventBusStore;
9
10
  readonly access: SimEventBridgeBusAccess;
11
+ readonly partnerBus: SimEventBridgePartnerBus;
10
12
  readonly accountRegionScope: SimAwsAccountRegionScope;
11
13
  readonly clock: BackgroundScheduler;
12
14
  }
@@ -16,15 +18,19 @@ interface SimEventBridgeCreateEventBusProperties {
16
18
  * Unlike SNS CreateTopic this is not idempotent: a name already taken is
17
19
  * refused rather than answered with the existing bus. `default` is among those
18
20
  * names, since that bus is always there.
21
+ *
22
+ * A request carrying an `EventSourceName` creates a partner event bus, which
23
+ * activates the partner event source of the same name.
19
24
  */
20
25
  export declare class SimEventBridgeCreateEventBus {
21
26
  private readonly buses;
22
27
  private readonly access;
28
+ private readonly partnerBus;
23
29
  private readonly accountRegionScope;
24
30
  private readonly clock;
25
31
  constructor(properties: SimEventBridgeCreateEventBusProperties);
26
32
  /**
27
- * Create a custom event bus.
33
+ * Create a custom or partner event bus.
28
34
  *
29
35
  * The inputs are read before the name is looked for, so a request naming one
30
36
  * this simulation will not take is refused whether or not the name is free.
@@ -8,20 +8,25 @@ import { refuseUnsimulatedBusInput } from "./sim-event-bridge-unsimulated-bus-in
8
8
  * Unlike SNS CreateTopic this is not idempotent: a name already taken is
9
9
  * refused rather than answered with the existing bus. `default` is among those
10
10
  * names, since that bus is always there.
11
+ *
12
+ * A request carrying an `EventSourceName` creates a partner event bus, which
13
+ * activates the partner event source of the same name.
11
14
  */
12
15
  export class SimEventBridgeCreateEventBus {
13
16
  buses;
14
17
  access;
18
+ partnerBus;
15
19
  accountRegionScope;
16
20
  clock;
17
21
  constructor(properties) {
18
22
  this.buses = properties.buses;
19
23
  this.access = properties.access;
24
+ this.partnerBus = properties.partnerBus;
20
25
  this.accountRegionScope = properties.accountRegionScope;
21
26
  this.clock = properties.clock;
22
27
  }
23
28
  /**
24
- * Create a custom event bus.
29
+ * Create a custom or partner event bus.
25
30
  *
26
31
  * The inputs are read before the name is looked for, so a request naming one
27
32
  * this simulation will not take is refused whether or not the name is free.
@@ -34,6 +39,7 @@ export class SimEventBridgeCreateEventBus {
34
39
  if (this.buses.find(name.value) !== undefined) {
35
40
  throw new SimEventBridgeResourceAlreadyExistsException(`Event bus ${name.value} already exists.`);
36
41
  }
42
+ this.partnerBus.check(name, input.EventSourceName);
37
43
  const bus = this.created(name, input.Description);
38
44
  return {
39
45
  $metadata: {},
@@ -0,0 +1,24 @@
1
+ import type { SimEventBusName } from "../../bus/sim-event-bus-name.js";
2
+ import type { SimPartnerEventSourceStore } from "../../source/sim-partner-event-source-store.js";
3
+ /**
4
+ * Checks the name a bus is created under against the partner event source a
5
+ * CreateEventBus request names, if it names one.
6
+ *
7
+ * A partner event bus has to take the name of its source exactly, and only a
8
+ * partner event bus may carry a `/` in its name. The source has to exist
9
+ * already. A partner creates it from its own Account, and real EventBridge
10
+ * fails the request when there is no source to match.
11
+ */
12
+ export declare class SimEventBridgePartnerBus {
13
+ private readonly sources;
14
+ constructor(sources: SimPartnerEventSourceStore);
15
+ /**
16
+ * Refuse a bus name that does not fit the source the request names, or a
17
+ * source that is not there.
18
+ */
19
+ check(name: SimEventBusName, eventSourceName: string | undefined): void;
20
+ /**
21
+ * Refuse a partner bus name on a request that names no partner source.
22
+ */
23
+ private refusePartnerName;
24
+ }
@@ -0,0 +1,44 @@
1
+ import { SimEventBridgeValidationException } from "../../error/sim-event-bridge.error.js";
2
+ import { SimPartnerEventSourceName } from "../../source/sim-partner-event-source-name.js";
3
+ /**
4
+ * Checks the name a bus is created under against the partner event source a
5
+ * CreateEventBus request names, if it names one.
6
+ *
7
+ * A partner event bus has to take the name of its source exactly, and only a
8
+ * partner event bus may carry a `/` in its name. The source has to exist
9
+ * already. A partner creates it from its own Account, and real EventBridge
10
+ * fails the request when there is no source to match.
11
+ */
12
+ export class SimEventBridgePartnerBus {
13
+ sources;
14
+ constructor(sources) {
15
+ this.sources = sources;
16
+ }
17
+ /**
18
+ * Refuse a bus name that does not fit the source the request names, or a
19
+ * source that is not there.
20
+ */
21
+ check(name, eventSourceName) {
22
+ if (eventSourceName === undefined) {
23
+ this.refusePartnerName(name);
24
+ return;
25
+ }
26
+ const sourceName = SimPartnerEventSourceName.of(eventSourceName, "EventSourceName");
27
+ if (sourceName.value !== name.value) {
28
+ throw new SimEventBridgeValidationException(`Invalid parameter: Name Reason: a partner event bus takes the name ` +
29
+ `of its event source exactly, and '${name.value}' is not ` +
30
+ `'${sourceName.value}'.`);
31
+ }
32
+ this.sources.require(sourceName.value);
33
+ }
34
+ /**
35
+ * Refuse a partner bus name on a request that names no partner source.
36
+ */
37
+ refusePartnerName(name) {
38
+ if (name.isPartner) {
39
+ throw new SimEventBridgeValidationException(`Invalid parameter: Name Reason: custom event bus names cannot ` +
40
+ `contain the '/' character. '${name.value}' is a partner event bus ` +
41
+ `name, and a partner event bus is created with an EventSourceName.`);
42
+ }
43
+ }
44
+ }
@@ -7,11 +7,6 @@ const maximumDescriptionLength = 512;
7
7
  * What a CreateEventBus input carrying an unmodelled property is refused with.
8
8
  */
9
9
  const refusals = [
10
- [
11
- (input) => input.EventSourceName,
12
- "Partner event buses are not simulated, so CreateEventBus refuses an " +
13
- "EventSourceName rather than creating a bus no partner can reach",
14
- ],
15
10
  [
16
11
  (input) => input.KmsKeyIdentifier,
17
12
  "Event bus encryption with a customer managed key is not simulated, so " +
@@ -1,3 +1,4 @@
1
+ import { SimEventBridgeValidationException } from "../../error/sim-event-bridge.error.js";
1
2
  /**
2
3
  * Resolve and authorize the bus every entry names, before any of them is
3
4
  * delivered.
@@ -10,6 +11,13 @@
10
11
  export function authorizedEntries(entries, access, options) {
11
12
  return entries.map((entry) => {
12
13
  const busName = access.requestedName(entry.EventBusName);
14
+ // PutEvents takes no `/` in a bus name or ARN, so it cannot name a partner
15
+ // event bus. Only the partner that owns the bus's event source sends
16
+ // events to it.
17
+ if (busName.isPartner) {
18
+ throw new SimEventBridgeValidationException(`Invalid parameter: EventBusName Reason: '${busName.value}' is a ` +
19
+ `partner event bus, and only its partner sends events to it.`);
20
+ }
13
21
  access.authorizeName("events:PutEvents", busName, options);
14
22
  return { entry, busName: busName.value };
15
23
  });
@@ -2,3 +2,4 @@ export type { SimCreateEventBusCommand, SimCreateEventBusCommandInput, SimCreate
2
2
  export type { SimPutEventsCommand, SimPutEventsCommandInput, SimPutEventsCommandOutput, SimPutEventsRequestEntry, SimPutEventsResultEntry, } from "./put-events/put-events.command.js";
3
3
  export type { SimDeleteRuleCommand, SimDeleteRuleCommandInput, SimDeleteRuleCommandOutput, SimDescribeRuleCommand, SimDescribeRuleCommandInput, SimDescribeRuleCommandOutput, SimDisableRuleCommand, SimDisableRuleCommandInput, SimDisableRuleCommandOutput, SimEnableRuleCommand, SimEnableRuleCommandInput, SimEnableRuleCommandOutput, SimListedRule, SimListRulesCommand, SimListRulesCommandInput, SimListRulesCommandOutput, SimPutRuleCommand, SimPutRuleCommandInput, SimPutRuleCommandOutput, SimTestEventPatternCommand, SimTestEventPatternCommandInput, SimTestEventPatternCommandOutput, } from "./rule/rule.command.js";
4
4
  export type { SimEventBridgeTarget, SimEventBridgeTargetFailure, SimListRuleNamesByTargetCommand, SimListRuleNamesByTargetCommandInput, SimListRuleNamesByTargetCommandOutput, SimListTargetsByRuleCommand, SimListTargetsByRuleCommandInput, SimListTargetsByRuleCommandOutput, SimPutTargetsCommand, SimPutTargetsCommandInput, SimPutTargetsCommandOutput, SimRemoveTargetsCommand, SimRemoveTargetsCommandInput, SimRemoveTargetsCommandOutput, } from "./target/target.command.js";
5
+ export type { SimDescribeEventSourceCommand, SimDescribeEventSourceCommandInput, SimDescribeEventSourceCommandOutput, SimPutPartnerEventsCommand, SimPutPartnerEventsCommandInput, SimPutPartnerEventsCommandOutput, SimPutPartnerEventsRequestEntry, SimPutPartnerEventsResultEntry, } from "./source/source.command.js";
@@ -10,16 +10,20 @@ import { SimEventBridgeRuleSchedules } from "../schedule/sim-event-bridge-rule-s
10
10
  import { SimEventBridgeBusCommands } from "./bus/sim-event-bridge-bus-commands.js";
11
11
  import { SimEventBridgeCreateEventBus } from "./bus/sim-event-bridge-create-event-bus.js";
12
12
  import { SimEventBridgeDeleteEventBus } from "./bus/sim-event-bridge-delete-event-bus.js";
13
+ import type { SimPartnerEventSourceStore } from "../source/sim-partner-event-source-store.js";
13
14
  import { SimEventBridgePutEvents } from "./put-events/sim-event-bridge-put-events.js";
14
15
  import { SimEventBridgePutRule } from "./rule/sim-event-bridge-put-rule.js";
15
16
  import { SimEventBridgeRuleCommands } from "./rule/sim-event-bridge-rule-commands.js";
16
17
  import { SimEventBridgeTestEventPattern } from "./rule/sim-event-bridge-test-event-pattern.js";
18
+ import { SimEventBridgeDescribeEventSource } from "./source/sim-event-bridge-describe-event-source.js";
19
+ import { SimEventBridgePutPartnerEvents } from "./source/sim-event-bridge-put-partner-events.js";
17
20
  import { SimEventBridgePutTargets } from "./target/sim-event-bridge-put-targets.js";
18
21
  import { SimEventBridgeTargetCommands } from "./target/sim-event-bridge-target-commands.js";
19
22
  interface SimEventBridgeCommandsProperties {
20
23
  readonly buses: SimEventBusStore;
21
24
  readonly rules: SimEventRuleStore;
22
25
  readonly targets: SimEventTargetStore;
26
+ readonly partnerSources: SimPartnerEventSourceStore;
23
27
  readonly deliveryTargets?: SimEventBridgeDeliveryTargets | undefined;
24
28
  readonly iam: SimIamInterServiceAuthZ;
25
29
  readonly background: BackgroundScheduler;
@@ -38,6 +42,8 @@ export declare class SimEventBridgeCommands {
38
42
  readonly busDeletion: SimEventBridgeDeleteEventBus;
39
43
  readonly buses: SimEventBridgeBusCommands;
40
44
  readonly putEvents: SimEventBridgePutEvents;
45
+ readonly putPartnerEvents: SimEventBridgePutPartnerEvents;
46
+ readonly eventSources: SimEventBridgeDescribeEventSource;
41
47
  readonly ruleCreation: SimEventBridgePutRule;
42
48
  readonly rules: SimEventBridgeRuleCommands;
43
49
  readonly patternTest: SimEventBridgeTestEventPattern;
@@ -6,11 +6,14 @@ import { SimEventBridgeBusAccess } from "./bus/sim-event-bridge-bus-access.js";
6
6
  import { SimEventBridgeBusCommands } from "./bus/sim-event-bridge-bus-commands.js";
7
7
  import { SimEventBridgeCreateEventBus } from "./bus/sim-event-bridge-create-event-bus.js";
8
8
  import { SimEventBridgeDeleteEventBus } from "./bus/sim-event-bridge-delete-event-bus.js";
9
+ import { SimEventBridgePartnerBus } from "./bus/sim-event-bridge-partner-bus.js";
9
10
  import { SimEventBridgePutEvents } from "./put-events/sim-event-bridge-put-events.js";
10
11
  import { SimEventBridgePutRule } from "./rule/sim-event-bridge-put-rule.js";
11
12
  import { SimEventBridgeRuleAccess } from "./rule/sim-event-bridge-rule-access.js";
12
13
  import { SimEventBridgeRuleCommands } from "./rule/sim-event-bridge-rule-commands.js";
13
14
  import { SimEventBridgeTestEventPattern } from "./rule/sim-event-bridge-test-event-pattern.js";
15
+ import { SimEventBridgeDescribeEventSource } from "./source/sim-event-bridge-describe-event-source.js";
16
+ import { SimEventBridgePutPartnerEvents } from "./source/sim-event-bridge-put-partner-events.js";
14
17
  import { SimEventBridgePutTargets } from "./target/sim-event-bridge-put-targets.js";
15
18
  import { SimEventBridgeTargetCommands } from "./target/sim-event-bridge-target-commands.js";
16
19
  /**
@@ -26,6 +29,8 @@ export class SimEventBridgeCommands {
26
29
  busDeletion;
27
30
  buses;
28
31
  putEvents;
32
+ putPartnerEvents;
33
+ eventSources;
29
34
  ruleCreation;
30
35
  rules;
31
36
  patternTest;
@@ -34,7 +39,7 @@ export class SimEventBridgeCommands {
34
39
  router;
35
40
  schedules;
36
41
  constructor(properties) {
37
- const { buses, rules, targets, accountRegionScope, background } = properties;
42
+ const { buses, rules, targets, partnerSources, accountRegionScope, background, } = properties;
38
43
  const authorizer = new SimEventBridgeAuthorizer({ iam: properties.iam });
39
44
  const access = new SimEventBridgeBusAccess({
40
45
  buses,
@@ -50,6 +55,7 @@ export class SimEventBridgeCommands {
50
55
  this.busCreation = new SimEventBridgeCreateEventBus({
51
56
  buses,
52
57
  access,
58
+ partnerBus: new SimEventBridgePartnerBus(partnerSources),
53
59
  accountRegionScope,
54
60
  clock: background,
55
61
  });
@@ -80,6 +86,18 @@ export class SimEventBridgeCommands {
80
86
  clock: background,
81
87
  router: this.router,
82
88
  });
89
+ this.putPartnerEvents = new SimEventBridgePutPartnerEvents({
90
+ sources: partnerSources,
91
+ accountRegionScope,
92
+ clock: background,
93
+ router: this.router,
94
+ });
95
+ this.eventSources = new SimEventBridgeDescribeEventSource({
96
+ sources: partnerSources,
97
+ buses,
98
+ authorizer,
99
+ accountRegionScope,
100
+ });
83
101
  this.ruleCreation = new SimEventBridgePutRule({
84
102
  rules,
85
103
  access: ruleAccess,
@@ -0,0 +1,35 @@
1
+ import type { SimAwsAccountRegionScope } from "../../../aws/sim-aws-account-region-scope.js";
2
+ import type { SimEventBusStore } from "../../bus/sim-event-bus-store.js";
3
+ import type { SimPartnerEventSourceStore } from "../../source/sim-partner-event-source-store.js";
4
+ import type { SimEventBridgeAuthorizer } from "../authorize/sim-event-bridge-authorizer.js";
5
+ import type { SimEventBridgeRequestOptions } from "../sim-event-bridge-request-options.js";
6
+ import type { SimDescribeEventSourceCommand, SimDescribeEventSourceCommandOutput } from "./source.command.js";
7
+ interface SimEventBridgeDescribeEventSourceProperties {
8
+ readonly sources: SimPartnerEventSourceStore;
9
+ readonly buses: SimEventBusStore;
10
+ readonly authorizer: SimEventBridgeAuthorizer;
11
+ readonly accountRegionScope: SimAwsAccountRegionScope;
12
+ }
13
+ /**
14
+ * The DescribeEventSource command.
15
+ *
16
+ * The state is `ACTIVE` while a partner event bus of the source's name exists,
17
+ * and `PENDING` otherwise. `ExpirationTime` is left out, because a pending
18
+ * source never expires here.
19
+ */
20
+ export declare class SimEventBridgeDescribeEventSource {
21
+ private readonly sources;
22
+ private readonly buses;
23
+ private readonly authorizer;
24
+ private readonly accountRegionScope;
25
+ constructor(properties: SimEventBridgeDescribeEventSourceProperties);
26
+ /**
27
+ * Describe a partner event source shared with this Account and Region.
28
+ *
29
+ * The caller is authorized against the ARN the source would have before it
30
+ * is looked up, so a caller with no permission learns nothing about which
31
+ * sources exist.
32
+ */
33
+ handle(command: SimDescribeEventSourceCommand, options?: SimEventBridgeRequestOptions): SimDescribeEventSourceCommandOutput;
34
+ }
35
+ export {};
@@ -0,0 +1,46 @@
1
+ import { SimEventBridgeValidationException } from "../../error/sim-event-bridge.error.js";
2
+ import { SimPartnerEventSourceName } from "../../source/sim-partner-event-source-name.js";
3
+ import { partnerEventSourceArn } from "../../source/sim-partner-event-source.js";
4
+ /**
5
+ * The DescribeEventSource command.
6
+ *
7
+ * The state is `ACTIVE` while a partner event bus of the source's name exists,
8
+ * and `PENDING` otherwise. `ExpirationTime` is left out, because a pending
9
+ * source never expires here.
10
+ */
11
+ export class SimEventBridgeDescribeEventSource {
12
+ sources;
13
+ buses;
14
+ authorizer;
15
+ accountRegionScope;
16
+ constructor(properties) {
17
+ this.sources = properties.sources;
18
+ this.buses = properties.buses;
19
+ this.authorizer = properties.authorizer;
20
+ this.accountRegionScope = properties.accountRegionScope;
21
+ }
22
+ /**
23
+ * Describe a partner event source shared with this Account and Region.
24
+ *
25
+ * The caller is authorized against the ARN the source would have before it
26
+ * is looked up, so a caller with no permission learns nothing about which
27
+ * sources exist.
28
+ */
29
+ handle(command, options) {
30
+ const requested = command.input.Name;
31
+ if (requested === undefined) {
32
+ throw new SimEventBridgeValidationException("Invalid parameter: Name is required");
33
+ }
34
+ const name = SimPartnerEventSourceName.of(requested, "Name");
35
+ this.authorizer.authorizeEventSource("events:DescribeEventSource", partnerEventSourceArn(name, this.accountRegionScope), options);
36
+ const source = this.sources.require(name.value);
37
+ return {
38
+ $metadata: {},
39
+ Arn: source.arn,
40
+ CreatedBy: source.name.partner,
41
+ CreationTime: source.creationTime,
42
+ Name: source.name.value,
43
+ State: source.state(this.buses.find(source.name.value) !== undefined),
44
+ };
45
+ }
46
+ }