asyncapi: 2.6.0
info:
  title: App Registry Service Events
  version: 2.0.0
  description: >
    Kafka event topics for the App Registry Service.
    All events follow CloudEvents 1.0 specification and are partitioned by tenant_id.
  contact:
    name: EventZR Platform Team
    email: platform@eventzr.com
  license:
    name: Proprietary

servers:
  staging:
    url: boot-gpm4u49z.c2.kafka-serverless.us-east-1.amazonaws.com:9098
    protocol: kafka-secure
    description: Amazon MSK Serverless (Staging)
    security:
      - saslIam: []

defaultContentType: application/cloudevents+json

channels:
  # ─── App Events (12 published) ───────────────────────────────────────

  eventzr.app-registry.app.created.v1:
    description: Emitted when a new app is registered by a developer
    publish:
      operationId: onAppCreated
      summary: App created
      message:
        $ref: '#/components/messages/AppCreatedEvent'

  eventzr.app-registry.app.updated.v1:
    description: Emitted when an app's metadata is updated
    publish:
      operationId: onAppUpdated
      summary: App updated
      message:
        $ref: '#/components/messages/AppUpdatedEvent'

  eventzr.app-registry.app.submitted.v1:
    description: Emitted when a developer submits an app for review
    publish:
      operationId: onAppSubmitted
      summary: App submitted for review
      message:
        $ref: '#/components/messages/AppSubmittedEvent'

  eventzr.app-registry.app.approved.v1:
    description: Emitted when an admin approves an app
    publish:
      operationId: onAppApproved
      summary: App approved
      message:
        $ref: '#/components/messages/AppApprovedEvent'

  eventzr.app-registry.app.rejected.v1:
    description: Emitted when an admin rejects an app
    publish:
      operationId: onAppRejected
      summary: App rejected
      message:
        $ref: '#/components/messages/AppRejectedEvent'

  eventzr.app-registry.app.published.v1:
    description: Emitted when an app is published to the marketplace
    publish:
      operationId: onAppPublished
      summary: App published
      message:
        $ref: '#/components/messages/AppPublishedEvent'

  eventzr.app-registry.app.unpublished.v1:
    description: Emitted when an app is removed from the marketplace
    publish:
      operationId: onAppUnpublished
      summary: App unpublished
      message:
        $ref: '#/components/messages/AppUnpublishedEvent'

  eventzr.app-registry.app.suspended.v1:
    description: Emitted when an app is suspended by an admin
    publish:
      operationId: onAppSuspended
      summary: App suspended
      message:
        $ref: '#/components/messages/AppSuspendedEvent'

  eventzr.app-registry.app.reinstated.v1:
    description: Emitted when a suspended app is reinstated by an admin
    publish:
      operationId: onAppReinstated
      summary: App reinstated
      message:
        $ref: '#/components/messages/AppReinstatedEvent'

  eventzr.app-registry.app.deprecated.v1:
    description: Emitted when an app is deprecated (no new installs, existing remain)
    publish:
      operationId: onAppDeprecated
      summary: App deprecated
      message:
        $ref: '#/components/messages/AppDeprecatedEvent'

  eventzr.app-registry.app.deleted.v1:
    description: Emitted when an app is soft-deleted
    publish:
      operationId: onAppDeleted
      summary: App deleted
      message:
        $ref: '#/components/messages/AppDeletedEvent'

  eventzr.app-registry.app.version-published.v1:
    description: Emitted when a new app version is published
    publish:
      operationId: onAppVersionPublished
      summary: App version published
      message:
        $ref: '#/components/messages/AppVersionPublishedEvent'

  # ─── Installation Events (3 published) ──────────────────────────────

  eventzr.app-registry.installation.installed.v1:
    description: Emitted when an app is installed by a tenant/organizer
    publish:
      operationId: onAppInstalled
      summary: App installed
      message:
        $ref: '#/components/messages/InstallationInstalledEvent'

  eventzr.app-registry.installation.uninstalled.v1:
    description: Emitted when an app is uninstalled
    publish:
      operationId: onAppUninstalled
      summary: App uninstalled
      message:
        $ref: '#/components/messages/InstallationUninstalledEvent'

  eventzr.app-registry.installation.configured.v1:
    description: Emitted when an installation's configuration is updated
    publish:
      operationId: onInstallationConfigured
      summary: Installation configured
      message:
        $ref: '#/components/messages/InstallationConfiguredEvent'

  # ─── Developer Events (8 published) ─────────────────────────────────

  eventzr.app-registry.developer.registered.v1:
    description: Emitted when a new developer account is created
    publish:
      operationId: onDeveloperRegistered
      summary: Developer registered
      message:
        $ref: '#/components/messages/DeveloperRegisteredEvent'

  eventzr.app-registry.developer.verified.v1:
    description: Emitted when a developer account is verified
    publish:
      operationId: onDeveloperVerified
      summary: Developer verified
      message:
        $ref: '#/components/messages/DeveloperVerifiedEvent'

  eventzr.app-registry.developer.suspended.v1:
    description: Emitted when a developer account is suspended
    publish:
      operationId: onDeveloperSuspended
      summary: Developer suspended
      message:
        $ref: '#/components/messages/DeveloperSuspendedEvent'

  eventzr.app-registry.developer.tier-upgraded.v1:
    description: Emitted when a developer is upgraded to a higher tier
    publish:
      operationId: onDeveloperTierUpgraded
      summary: Developer tier upgraded
      message:
        $ref: '#/components/messages/DeveloperTierChangedEvent'

  eventzr.app-registry.developer.tier-downgraded.v1:
    description: Emitted when a developer is downgraded to a lower tier
    publish:
      operationId: onDeveloperTierDowngraded
      summary: Developer tier downgraded
      message:
        $ref: '#/components/messages/DeveloperTierChangedEvent'

  eventzr.app-registry.developer.tier-changed.v1:
    description: Generic tier change event (covers both upgrades and downgrades)
    publish:
      operationId: onDeveloperTierChanged
      summary: Developer tier changed
      message:
        $ref: '#/components/messages/DeveloperTierChangedEvent'

  eventzr.app-registry.developer.data-exported.v1:
    description: Emitted when a developer's data export is completed (GDPR)
    publish:
      operationId: onDeveloperDataExported
      summary: Developer data exported
      message:
        $ref: '#/components/messages/DeveloperDataEvent'

  eventzr.app-registry.developer.data-deleted.v1:
    description: Emitted when a developer's data is deleted (GDPR right to erasure)
    publish:
      operationId: onDeveloperDataDeleted
      summary: Developer data deleted
      message:
        $ref: '#/components/messages/DeveloperDataEvent'

  # ─── Webhook Events (7 published) ───────────────────────────────────

  eventzr.app-registry.webhook.subscribed.v1:
    description: Emitted when a new webhook subscription is created
    publish:
      operationId: onWebhookSubscribed
      summary: Webhook subscribed
      message:
        $ref: '#/components/messages/WebhookSubscribedEvent'

  eventzr.app-registry.webhook.unsubscribed.v1:
    description: Emitted when a webhook subscription is deleted
    publish:
      operationId: onWebhookUnsubscribed
      summary: Webhook unsubscribed
      message:
        $ref: '#/components/messages/WebhookUnsubscribedEvent'

  eventzr.app-registry.webhook.suspended.v1:
    description: Emitted when a webhook is auto-suspended due to repeated failures
    publish:
      operationId: onWebhookSuspended
      summary: Webhook suspended
      message:
        $ref: '#/components/messages/WebhookSuspendedEvent'

  eventzr.app-registry.webhook.delivery-requested.v1:
    description: Emitted to trigger a webhook delivery attempt
    publish:
      operationId: onWebhookDeliveryRequested
      summary: Webhook delivery requested
      message:
        $ref: '#/components/messages/WebhookDeliveryRequestedEvent'

  eventzr.app-registry.webhook.delivery-succeeded.v1:
    description: Emitted when a webhook delivery succeeds
    publish:
      operationId: onWebhookDeliverySucceeded
      summary: Webhook delivery succeeded
      message:
        $ref: '#/components/messages/WebhookDeliveryResultEvent'

  eventzr.app-registry.webhook.delivery-failed.v1:
    description: Emitted when a webhook delivery fails (may retry)
    publish:
      operationId: onWebhookDeliveryFailed
      summary: Webhook delivery failed
      message:
        $ref: '#/components/messages/WebhookDeliveryResultEvent'

  eventzr.app-registry.webhook.delivery-exhausted.v1:
    description: Emitted when all retry attempts are exhausted (moved to dead letter)
    publish:
      operationId: onWebhookDeliveryExhausted
      summary: Webhook delivery exhausted
      message:
        $ref: '#/components/messages/WebhookDeliveryExhaustedEvent'

  # ─── Analytics Events (1 published) ─────────────────────────────────

  eventzr.app-registry.analytics.snapshot.v1:
    description: Periodic analytics snapshot for an app (daily aggregation)
    publish:
      operationId: onAnalyticsSnapshot
      summary: Analytics snapshot
      message:
        $ref: '#/components/messages/AnalyticsSnapshotEvent'

  # ─── Consumed Events (6) ────────────────────────────────────────────

  eventzr.reviews.app-rating-updated.v1:
    description: Consumed from reviews-svc to update app rating aggregates
    subscribe:
      operationId: handleAppRatingUpdated
      summary: App rating updated (from reviews-svc)
      message:
        $ref: '#/components/messages/AppRatingUpdatedEvent'

  eventzr.wallet.payout-completed.v1:
    description: Consumed from wallet-svc to update developer payout records
    subscribe:
      operationId: handlePayoutCompleted
      summary: Payout completed (from wallet-svc)
      message:
        $ref: '#/components/messages/PayoutCompletedEvent'

  eventzr.taxonomy.category-updated.v1:
    description: Consumed from taxonomy-svc to refresh category mappings
    subscribe:
      operationId: handleCategoryUpdated
      summary: Category updated (from taxonomy-svc)
      message:
        $ref: '#/components/messages/CategoryUpdatedEvent'

  eventzr.notify.notification-sent.v1:
    description: Consumed from notify-svc for delivery confirmation tracking
    subscribe:
      operationId: handleNotificationSent
      summary: Notification sent (from notify-svc)
      message:
        $ref: '#/components/messages/NotificationSentEvent'

  eventzr.webhook.delivery-requested.v1:
    description: Internal consumer -- triggers the webhook delivery worker
    subscribe:
      operationId: handleWebhookDeliveryRequested
      summary: Webhook delivery requested (internal consumer)
      message:
        $ref: '#/components/messages/WebhookDeliveryRequestedEvent'

  eventzr.app-registry.app.install-count-updated.v1:
    description: Internal consumer -- updates cached install counts
    subscribe:
      operationId: handleInstallCountUpdated
      summary: Install count updated (internal)
      message:
        $ref: '#/components/messages/InstallCountUpdatedEvent'

components:
  securitySchemes:
    saslIam:
      type: scramSha256
      description: AWS MSK IAM authentication (SASL mechanism via AWS SDK)

  messageTraits:
    CloudEventHeaders:
      headers:
        type: object
        required:
          - ce_specversion
          - ce_type
          - ce_source
          - ce_id
          - ce_time
          - ce_tenantid
        properties:
          ce_specversion:
            type: string
            const: '1.0'
            description: CloudEvents specification version
          ce_type:
            type: string
            description: 'Event type (e.g., eventzr.app-registry.app.created.v1)'
          ce_source:
            type: string
            const: '/eventzr/app-registry-svc'
            description: Event source URI
          ce_id:
            type: string
            format: uuid
            description: Unique event identifier
          ce_time:
            type: string
            format: date-time
            description: Event timestamp (ISO 8601)
          ce_datacontenttype:
            type: string
            const: application/json
          ce_tenantid:
            type: string
            format: uuid
            description: Tenant ID (Kafka partition key)

  messages:
    # ─── App Messages ─────────────────────────────────────────────────

    AppCreatedEvent:
      name: AppCreatedEvent
      title: App Created
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppEventPayload'

    AppUpdatedEvent:
      name: AppUpdatedEvent
      title: App Updated
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppEventPayload'

    AppSubmittedEvent:
      name: AppSubmittedEvent
      title: App Submitted for Review
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppApprovedEvent:
      name: AppApprovedEvent
      title: App Approved
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppRejectedEvent:
      name: AppRejectedEvent
      title: App Rejected
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppRejectedEventPayload'

    AppPublishedEvent:
      name: AppPublishedEvent
      title: App Published
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppUnpublishedEvent:
      name: AppUnpublishedEvent
      title: App Unpublished
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppSuspendedEvent:
      name: AppSuspendedEvent
      title: App Suspended
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppSuspendedEventPayload'

    AppReinstatedEvent:
      name: AppReinstatedEvent
      title: App Reinstated
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppDeprecatedEvent:
      name: AppDeprecatedEvent
      title: App Deprecated
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppLifecycleEventPayload'

    AppDeletedEvent:
      name: AppDeletedEvent
      title: App Deleted
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppDeletedEventPayload'

    AppVersionPublishedEvent:
      name: AppVersionPublishedEvent
      title: App Version Published
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppVersionEventPayload'

    # ─── Installation Messages ────────────────────────────────────────

    InstallationInstalledEvent:
      name: InstallationInstalledEvent
      title: App Installed
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/InstallationEventPayload'

    InstallationUninstalledEvent:
      name: InstallationUninstalledEvent
      title: App Uninstalled
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/InstallationUninstalledEventPayload'

    InstallationConfiguredEvent:
      name: InstallationConfiguredEvent
      title: Installation Configured
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/InstallationConfiguredEventPayload'

    # ─── Developer Messages ───────────────────────────────────────────

    DeveloperRegisteredEvent:
      name: DeveloperRegisteredEvent
      title: Developer Registered
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeveloperEventPayload'

    DeveloperVerifiedEvent:
      name: DeveloperVerifiedEvent
      title: Developer Verified
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeveloperEventPayload'

    DeveloperSuspendedEvent:
      name: DeveloperSuspendedEvent
      title: Developer Suspended
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeveloperSuspendedEventPayload'

    DeveloperTierChangedEvent:
      name: DeveloperTierChangedEvent
      title: Developer Tier Changed
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeveloperTierChangedEventPayload'

    DeveloperDataEvent:
      name: DeveloperDataEvent
      title: Developer Data Export/Delete
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/DeveloperDataEventPayload'

    # ─── Webhook Messages ─────────────────────────────────────────────

    WebhookSubscribedEvent:
      name: WebhookSubscribedEvent
      title: Webhook Subscribed
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookSubscriptionEventPayload'

    WebhookUnsubscribedEvent:
      name: WebhookUnsubscribedEvent
      title: Webhook Unsubscribed
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookSubscriptionEventPayload'

    WebhookSuspendedEvent:
      name: WebhookSuspendedEvent
      title: Webhook Suspended
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookSuspendedEventPayload'

    WebhookDeliveryRequestedEvent:
      name: WebhookDeliveryRequestedEvent
      title: Webhook Delivery Requested
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookDeliveryRequestedEventPayload'

    WebhookDeliveryResultEvent:
      name: WebhookDeliveryResultEvent
      title: Webhook Delivery Result
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookDeliveryResultEventPayload'

    WebhookDeliveryExhaustedEvent:
      name: WebhookDeliveryExhaustedEvent
      title: Webhook Delivery Exhausted
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/WebhookDeliveryExhaustedEventPayload'

    # ─── Analytics Messages ───────────────────────────────────────────

    AnalyticsSnapshotEvent:
      name: AnalyticsSnapshotEvent
      title: Analytics Snapshot
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AnalyticsSnapshotEventPayload'

    # ─── Consumed Messages ────────────────────────────────────────────

    AppRatingUpdatedEvent:
      name: AppRatingUpdatedEvent
      title: App Rating Updated (from reviews-svc)
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/AppRatingUpdatedPayload'

    PayoutCompletedEvent:
      name: PayoutCompletedEvent
      title: Payout Completed (from wallet-svc)
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/PayoutCompletedPayload'

    CategoryUpdatedEvent:
      name: CategoryUpdatedEvent
      title: Category Updated (from taxonomy-svc)
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/CategoryUpdatedPayload'

    NotificationSentEvent:
      name: NotificationSentEvent
      title: Notification Sent (from notify-svc)
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/NotificationSentPayload'

    InstallCountUpdatedEvent:
      name: InstallCountUpdatedEvent
      title: Install Count Updated (internal)
      contentType: application/cloudevents+json
      traits:
        - $ref: '#/components/messageTraits/CloudEventHeaders'
      payload:
        $ref: '#/components/schemas/InstallCountUpdatedPayload'

  schemas:
    # ─── App Event Schemas ────────────────────────────────────────────

    AppEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.app.created.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, developerId, name, status, pricingModel]
          properties:
            appId:
              type: string
              example: app_01JR80
            developerId:
              type: string
              example: dev_01JR80
            name:
              type: string
              example: Payment Gateway Pro
            slug:
              type: string
              example: payment-gateway-pro
            status:
              type: string
              enum: [draft, submitted, under_review, approved, published, rejected, suspended, deprecated]
            pricingModel:
              type: string
              enum: [free, one_time, subscription, usage_based]
            appType:
              type: string
              enum: [mobile_app, web_app, integration, plugin]
            categoryIds:
              type: array
              items:
                type: string
            tags:
              type: array
              items:
                type: string

    AppLifecycleEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.app.published.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, previousStatus, newStatus]
          properties:
            appId:
              type: string
            developerId:
              type: string
            name:
              type: string
            previousStatus:
              type: string
            newStatus:
              type: string
            triggeredBy:
              type: string
              description: User ID who triggered the transition

    AppRejectedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.app.rejected.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, reason]
          properties:
            appId:
              type: string
            developerId:
              type: string
            name:
              type: string
            reason:
              type: string
              description: Rejection reason
            rejectedBy:
              type: string
              description: Admin user ID

    AppSuspendedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.app.suspended.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId]
          properties:
            appId:
              type: string
            developerId:
              type: string
            name:
              type: string
            reason:
              type: string
            suspendedBy:
              type: string
            activeInstallations:
              type: integer
              description: Number of active installations affected

    AppDeletedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.app.deleted.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, developerId]
          properties:
            appId:
              type: string
            developerId:
              type: string
            name:
              type: string
            deletedBy:
              type: string

    AppVersionEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.app.version-published.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, versionId, version]
          properties:
            appId:
              type: string
            versionId:
              type: string
            version:
              type: string
              example: '1.2.0'
            changelog:
              type: string
            isLatest:
              type: boolean

    # ─── Installation Event Schemas ───────────────────────────────────

    InstallationEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.installation.installed.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [installationId, appId, organizerId, installedBy]
          properties:
            installationId:
              type: string
            appId:
              type: string
            versionId:
              type: string
            organizerId:
              type: string
            installedBy:
              type: string
            appName:
              type: string
            pricingModel:
              type: string

    InstallationUninstalledEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.installation.uninstalled.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [installationId, appId, organizerId]
          properties:
            installationId:
              type: string
            appId:
              type: string
            organizerId:
              type: string
            reason:
              type: string
            deleteData:
              type: boolean
            uninstalledBy:
              type: string

    InstallationConfiguredEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.installation.configured.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [installationId, appId]
          properties:
            installationId:
              type: string
            appId:
              type: string
            organizerId:
              type: string
            configuredBy:
              type: string
            changedKeys:
              type: array
              items:
                type: string
              description: List of configuration keys that were changed

    # ─── Developer Event Schemas ──────────────────────────────────────

    DeveloperEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.developer.registered.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [developerId, userId, developerName, email]
          properties:
            developerId:
              type: string
            userId:
              type: string
            developerName:
              type: string
            email:
              type: string
            companyName:
              type: string
            programTier:
              type: string
              enum: [free, pro, enterprise]

    DeveloperSuspendedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.developer.suspended.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [developerId, userId]
          properties:
            developerId:
              type: string
            userId:
              type: string
            developerName:
              type: string
            reason:
              type: string
            suspendedBy:
              type: string
            affectedApps:
              type: integer
              description: Number of apps affected by suspension

    DeveloperTierChangedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.developer.tier-changed.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [developerId, previousTier, newTier]
          properties:
            developerId:
              type: string
            userId:
              type: string
            developerName:
              type: string
            previousTier:
              type: string
              enum: [free, pro, enterprise]
            newTier:
              type: string
              enum: [free, pro, enterprise]
            tierExpiresAt:
              type: string
              format: date-time

    DeveloperDataEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.developer.data-exported.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [developerId, userId, action]
          properties:
            developerId:
              type: string
            userId:
              type: string
            action:
              type: string
              enum: [export, delete]
            downloadUrl:
              type: string
              description: Presigned S3 URL for data export (export action only)
            expiresAt:
              type: string
              format: date-time
              description: Download URL expiration (export action only)

    # ─── Webhook Event Schemas ────────────────────────────────────────

    WebhookSubscriptionEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.webhook.subscribed.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [webhookId, appId, targetUrl, eventTypes]
          properties:
            webhookId:
              type: string
            appId:
              type: string
            targetUrl:
              type: string
              format: uri
            eventTypes:
              type: array
              items:
                type: string

    WebhookSuspendedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.webhook.suspended.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [webhookId, appId, reason]
          properties:
            webhookId:
              type: string
            appId:
              type: string
            targetUrl:
              type: string
              format: uri
            reason:
              type: string
              example: Consecutive delivery failures exceeded threshold
            failureCount:
              type: integer
            lastFailureAt:
              type: string
              format: date-time

    WebhookDeliveryRequestedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.webhook.delivery-requested.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [deliveryId, webhookId, targetUrl, eventType, payload]
          properties:
            deliveryId:
              type: string
            webhookId:
              type: string
            targetUrl:
              type: string
              format: uri
            eventType:
              type: string
            payload:
              type: object
              description: The event payload to deliver
            webhookSecret:
              type: string
              description: Secret for HMAC signature generation
            attemptNumber:
              type: integer
              default: 1

    WebhookDeliveryResultEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          example: eventzr.app-registry.webhook.delivery-succeeded.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [deliveryId, webhookId, status]
          properties:
            deliveryId:
              type: string
            webhookId:
              type: string
            eventType:
              type: string
            status:
              type: string
              enum: [success, failed]
            httpStatusCode:
              type: integer
            responseTimeMs:
              type: number
            attemptNumber:
              type: integer
            errorMessage:
              type: string
              description: Error message (for failed deliveries)

    WebhookDeliveryExhaustedEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.webhook.delivery-exhausted.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [deliveryId, webhookId, deadLetterId, totalAttempts]
          properties:
            deliveryId:
              type: string
            webhookId:
              type: string
            deadLetterId:
              type: string
              description: ID of the dead letter record
            eventType:
              type: string
            totalAttempts:
              type: integer
            lastHttpStatusCode:
              type: integer
            lastErrorMessage:
              type: string

    # ─── Analytics Event Schemas ──────────────────────────────────────

    AnalyticsSnapshotEventPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.analytics.snapshot.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, date]
          properties:
            appId:
              type: string
            developerId:
              type: string
            date:
              type: string
              format: date
              description: Snapshot date (YYYY-MM-DD)
            totalInstalls:
              type: integer
            activeInstalls:
              type: integer
            newInstalls:
              type: integer
            uninstalls:
              type: integer
            revenue:
              type: number
            apiCalls:
              type: integer
            averageRating:
              type: number
            totalReviews:
              type: integer

    # ─── Consumed Event Schemas ───────────────────────────────────────

    AppRatingUpdatedPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.reviews.app-rating-updated.v1
        source:
          type: string
          const: /eventzr/reviews-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, averageRating, totalReviews]
          properties:
            appId:
              type: string
            averageRating:
              type: number
            totalReviews:
              type: integer
            ratingDistribution:
              type: object
              properties:
                '1':
                  type: integer
                '2':
                  type: integer
                '3':
                  type: integer
                '4':
                  type: integer
                '5':
                  type: integer

    PayoutCompletedPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.wallet.payout-completed.v1
        source:
          type: string
          const: /eventzr/wallet-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [payoutId, developerId, amount, currency]
          properties:
            payoutId:
              type: string
            developerId:
              type: string
            amount:
              type: number
            currency:
              type: string
            status:
              type: string
              enum: [completed, failed]

    CategoryUpdatedPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.taxonomy.category-updated.v1
        source:
          type: string
          const: /eventzr/taxonomy-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [categoryId]
          properties:
            categoryId:
              type: string
            name:
              type: string
            parentId:
              type: string
            action:
              type: string
              enum: [updated, deleted, merged]

    NotificationSentPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.notify.notification-sent.v1
        source:
          type: string
          const: /eventzr/notify-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [notificationId, channel, status]
          properties:
            notificationId:
              type: string
            channel:
              type: string
              enum: [email, sms, push, whatsapp, in_app]
            recipientId:
              type: string
            status:
              type: string
              enum: [sent, delivered, failed]
            templateId:
              type: string

    InstallCountUpdatedPayload:
      type: object
      required: [specversion, type, source, id, time, datacontenttype, tenantid, data]
      properties:
        specversion:
          type: string
          const: '1.0'
        type:
          type: string
          const: eventzr.app-registry.app.install-count-updated.v1
        source:
          type: string
          const: /eventzr/app-registry-svc
        id:
          type: string
          format: uuid
        time:
          type: string
          format: date-time
        datacontenttype:
          type: string
          const: application/json
        tenantid:
          type: string
          format: uuid
        data:
          type: object
          required: [appId, installCount, activeInstallCount]
          properties:
            appId:
              type: string
            installCount:
              type: integer
            activeInstallCount:
              type: integer
