import { z } from 'zod';

// src/cloud/marketplace.zod.ts
var PublisherVerificationSchema = z.enum([
  "unverified",
  // Not yet verified
  "pending",
  // Verification in progress
  "verified",
  // Identity verified by platform
  "trusted",
  // Trusted publisher (track record of quality)
  "partner"
  // Official platform partner
]).describe("Publisher verification status");
var PublisherSchema = z.object({
  /** Publisher unique identifier */
  id: z.string().describe("Publisher ID"),
  /** Display name */
  name: z.string().describe("Publisher display name"),
  /** Publisher type */
  type: z.enum(["individual", "organization"]).describe("Publisher type"),
  /** Verification status */
  verification: PublisherVerificationSchema.default("unverified").describe("Publisher verification status"),
  /** Contact email */
  email: z.string().email().optional().describe("Contact email"),
  /** Website URL */
  website: z.string().url().optional().describe("Publisher website"),
  /** Organization logo URL */
  logoUrl: z.string().url().optional().describe("Publisher logo URL"),
  /** Short description/bio */
  description: z.string().optional().describe("Publisher description"),
  /** Registration date */
  registeredAt: z.string().datetime().optional().describe("Publisher registration timestamp")
}).describe("Developer or organization that publishes packages");
var ArtifactReferenceSchema = z.object({
  /** Artifact download URL */
  url: z.string().url().describe("Artifact download URL"),
  /** SHA256 integrity checksum */
  sha256: z.string().regex(/^[a-f0-9]{64}$/).describe("SHA256 checksum"),
  /** File size in bytes */
  size: z.number().int().positive().describe("Artifact size in bytes"),
  /** Artifact format */
  format: z.enum(["tgz", "zip"]).default("tgz").describe("Artifact format"),
  /** Upload timestamp */
  uploadedAt: z.string().datetime().describe("Upload timestamp")
}).describe("Reference to a downloadable package artifact");
var ArtifactDownloadResponseSchema = z.object({
  /** Pre-signed or direct download URL */
  downloadUrl: z.string().url().describe("Artifact download URL (may be pre-signed)"),
  /** SHA256 checksum for download verification */
  sha256: z.string().regex(/^[a-f0-9]{64}$/).describe("SHA256 checksum for verification"),
  /** File size in bytes */
  size: z.number().int().positive().describe("Artifact size in bytes"),
  /** Artifact format */
  format: z.enum(["tgz", "zip"]).describe("Artifact format"),
  /** URL expiration time (for pre-signed URLs) */
  expiresAt: z.string().datetime().optional().describe("URL expiration timestamp for pre-signed URLs")
}).describe("Artifact download response with integrity metadata");
var MarketplaceCategorySchema = z.enum([
  "crm",
  // Customer Relationship Management
  "erp",
  // Enterprise Resource Planning
  "hr",
  // Human Resources
  "finance",
  // Finance & Accounting
  "project",
  // Project Management
  "collaboration",
  // Collaboration & Communication
  "analytics",
  // Analytics & Reporting
  "integration",
  // Integrations & Connectors
  "automation",
  // Automation & Workflows
  "ai",
  // AI & Machine Learning
  "security",
  // Security & Compliance
  "developer-tools",
  // Developer Tools
  "ui-theme",
  // UI Themes & Appearance
  "storage",
  // Storage & Drivers
  "other"
  // Other / Uncategorized
]).describe("Marketplace package category");
var ListingStatusSchema = z.enum([
  "draft",
  // Not yet submitted
  "submitted",
  // Submitted for review
  "in-review",
  // Under review
  "approved",
  // Approved, ready to publish
  "published",
  // Live on marketplace
  "rejected",
  // Review rejected
  "suspended",
  // Suspended by platform (policy violation)
  "deprecated",
  // Deprecated by publisher
  "unlisted"
  // Available by direct link only
]).describe("Marketplace listing status");
var PricingModelSchema = z.enum([
  "free",
  // Free to install
  "freemium",
  // Free with paid premium features
  "paid",
  // Requires purchase
  "subscription",
  // Recurring subscription
  "usage-based",
  // Pay per usage
  "contact-sales"
  // Enterprise pricing, contact for quote
]).describe("Package pricing model");
var MarketplaceListingSchema = z.object({
  /** Listing ID (matches package ID) */
  id: z.string().describe("Listing ID (matches package manifest ID)"),
  /** Package ID (reverse domain notation) */
  packageId: z.string().describe("Package identifier"),
  /** Publisher information */
  publisherId: z.string().describe("Publisher ID"),
  /** Current listing status */
  status: ListingStatusSchema.default("draft").describe("Publication state: draft, published, under-review, suspended, deprecated, or unlisted"),
  /** Display name */
  name: z.string().describe("Display name"),
  /** Tagline (short description for cards/search results) */
  tagline: z.string().max(120).optional().describe("Short tagline (max 120 chars)"),
  /** Full description (supports Markdown) */
  description: z.string().optional().describe("Full description (Markdown)"),
  /** Category */
  category: MarketplaceCategorySchema.describe("Package category"),
  /** Additional tags for search discovery */
  tags: z.array(z.string()).optional().describe("Search tags"),
  /** Icon/logo URL */
  iconUrl: z.string().url().optional().describe("Package icon URL"),
  /** Screenshot URLs */
  screenshots: z.array(z.object({
    url: z.string().url(),
    caption: z.string().optional()
  })).optional().describe("Screenshots"),
  /** Documentation URL */
  documentationUrl: z.string().url().optional().describe("Documentation URL"),
  /** Support URL */
  supportUrl: z.string().url().optional().describe("Support URL"),
  /** Source repository URL (if open source) */
  repositoryUrl: z.string().url().optional().describe("Source repository URL"),
  /** Pricing model */
  pricing: PricingModelSchema.default("free").describe("Pricing model"),
  /** Price in cents (if paid) */
  priceInCents: z.number().int().min(0).optional().describe("Price in cents (e.g. 999 = $9.99)"),
  /** Latest published version */
  latestVersion: z.string().describe("Latest published version"),
  /** Minimum platform version required */
  minPlatformVersion: z.string().optional().describe("Minimum ObjectStack platform version"),
  /** Available versions for installation */
  versions: z.array(z.object({
    version: z.string().describe("Version string"),
    releaseDate: z.string().datetime().describe("Release date"),
    releaseNotes: z.string().optional().describe("Release notes"),
    minPlatformVersion: z.string().optional().describe("Minimum platform version"),
    deprecated: z.boolean().default(false).describe("Whether this version is deprecated"),
    /** Artifact reference for this version */
    artifact: ArtifactReferenceSchema.optional().describe("Downloadable artifact for this version")
  })).optional().describe("Published versions"),
  /** Aggregate statistics */
  stats: z.object({
    totalInstalls: z.number().int().min(0).default(0).describe("Total installs"),
    activeInstalls: z.number().int().min(0).default(0).describe("Active installs"),
    averageRating: z.number().min(0).max(5).optional().describe("Average user rating (0-5)"),
    totalRatings: z.number().int().min(0).default(0).describe("Total ratings count"),
    totalReviews: z.number().int().min(0).default(0).describe("Total reviews count")
  }).optional().describe("Aggregate marketplace statistics"),
  /** First published date */
  publishedAt: z.string().datetime().optional().describe("First published timestamp"),
  /** Last updated date */
  updatedAt: z.string().datetime().optional().describe("Last updated timestamp")
}).describe("Public-facing package listing on the marketplace");
var PackageSubmissionSchema = z.object({
  /** Submission ID */
  id: z.string().describe("Submission ID"),
  /** Package ID */
  packageId: z.string().describe("Package identifier"),
  /** Version being submitted */
  version: z.string().describe("Version being submitted"),
  /** Publisher ID */
  publisherId: z.string().describe("Publisher submitting"),
  /** Submission status */
  status: z.enum([
    "pending",
    // Awaiting review
    "scanning",
    // Automated scan in progress
    "in-review",
    // Under manual review
    "changes-requested",
    // Reviewer requests changes
    "approved",
    // Approved for publishing
    "rejected"
    // Rejected
  ]).default("pending").describe("Review status"),
  /**
   * Package artifact URL or reference.
   * Points to the built package bundle for review.
   */
  artifactUrl: z.string().describe("Package artifact URL for review"),
  /** Release notes for this version */
  releaseNotes: z.string().optional().describe("Release notes for this version"),
  /** Whether this is the first submission (new listing) vs version update */
  isNewListing: z.boolean().default(false).describe("Whether this is a new listing submission"),
  /** Automated scan results */
  scanResults: z.object({
    /** Whether automated scan passed */
    passed: z.boolean(),
    /** Security scan score (0-100) */
    securityScore: z.number().min(0).max(100).optional(),
    /** Compatibility check passed */
    compatibilityCheck: z.boolean().optional(),
    /** Issues found during scan */
    issues: z.array(z.object({
      severity: z.enum(["critical", "high", "medium", "low", "info"]),
      message: z.string(),
      file: z.string().optional(),
      line: z.number().optional()
    })).optional()
  }).optional().describe("Automated scan results"),
  /** Reviewer notes (from platform reviewer) */
  reviewerNotes: z.string().optional().describe("Notes from the platform reviewer"),
  /** Submitted timestamp */
  submittedAt: z.string().datetime().optional().describe("Submission timestamp"),
  /** Review completed timestamp */
  reviewedAt: z.string().datetime().optional().describe("Review completion timestamp")
}).describe("Developer submission of a package version for review");
var MarketplaceSearchRequestSchema = z.object({
  /** Search query string */
  query: z.string().optional().describe("Full-text search query"),
  /** Filter by category */
  category: MarketplaceCategorySchema.optional().describe("Filter by category"),
  /** Filter by tags */
  tags: z.array(z.string()).optional().describe("Filter by tags"),
  /** Filter by pricing model */
  pricing: PricingModelSchema.optional().describe("Filter by pricing model"),
  /** Filter by publisher verification level */
  publisherVerification: PublisherVerificationSchema.optional().describe("Filter by publisher verification level"),
  /** Sort by */
  sortBy: z.enum([
    "relevance",
    // Best match (default for search)
    "popularity",
    // Most installs
    "rating",
    // Highest rated
    "newest",
    // Most recently published
    "updated",
    // Most recently updated
    "name"
    // Alphabetical
  ]).default("relevance").describe("Sort field"),
  /** Sort direction */
  sortDirection: z.enum(["asc", "desc"]).default("desc").describe("Sort direction"),
  /** Pagination: page number */
  page: z.number().int().min(1).default(1).describe("Page number"),
  /** Pagination: items per page */
  pageSize: z.number().int().min(1).max(100).default(20).describe("Items per page"),
  /** Filter by minimum platform version compatibility */
  platformVersion: z.string().optional().describe("Filter by platform version compatibility")
}).describe("Marketplace search request");
var MarketplaceSearchResponseSchema = z.object({
  /** Search results */
  items: z.array(MarketplaceListingSchema).describe("Search result listings"),
  /** Total count (for pagination) */
  total: z.number().int().min(0).describe("Total matching results"),
  /** Current page */
  page: z.number().int().min(1).describe("Current page number"),
  /** Items per page */
  pageSize: z.number().int().min(1).describe("Items per page"),
  /** Facets for filtering */
  facets: z.object({
    categories: z.array(z.object({
      category: MarketplaceCategorySchema,
      count: z.number().int().min(0)
    })).optional(),
    pricing: z.array(z.object({
      model: PricingModelSchema,
      count: z.number().int().min(0)
    })).optional()
  }).optional().describe("Aggregation facets for refining search")
}).describe("Marketplace search response");
var MarketplaceInstallRequestSchema = z.object({
  /** Listing ID to install */
  listingId: z.string().describe("Marketplace listing ID"),
  /** Specific version to install (defaults to latest) */
  version: z.string().optional().describe("Version to install"),
  /** License key (for paid packages) */
  licenseKey: z.string().optional().describe("License key for paid packages"),
  /** User-provided settings at install time */
  settings: z.record(z.string(), z.unknown()).optional().describe("User-provided settings at install time"),
  /** Whether to enable immediately after install */
  enableOnInstall: z.boolean().default(true).describe("Whether to enable immediately after install"),
  /** Artifact reference (resolved from listing version, or provided directly) */
  artifactRef: ArtifactReferenceSchema.optional().describe("Artifact reference for direct installation"),
  /** Tenant ID */
  tenantId: z.string().optional().describe("Tenant identifier")
}).describe("Install from marketplace request");
var MarketplaceInstallResponseSchema = z.object({
  /** Whether installation was successful */
  success: z.boolean().describe("Whether installation succeeded"),
  /** Installed package ID */
  packageId: z.string().optional().describe("Installed package identifier"),
  /** Installed version */
  version: z.string().optional().describe("Installed version"),
  /** Human-readable message */
  message: z.string().optional().describe("Installation status message")
}).describe("Install from marketplace response");
var PublisherProfileSchema = z.object({
  /** Organization ID (references Identity.Organization.id) */
  organizationId: z.string().describe("Identity Organization ID"),
  /** Publisher ID (marketplace-assigned identifier) */
  publisherId: z.string().describe("Marketplace publisher ID"),
  /** Verification level (marketplace trust tier) */
  verification: PublisherVerificationSchema.default("unverified"),
  /** Accepted developer program agreement version */
  agreementVersion: z.string().optional().describe("Accepted developer agreement version"),
  /** Publisher-specific website (may differ from org) */
  website: z.string().url().optional().describe("Publisher website"),
  /** Publisher-specific support email */
  supportEmail: z.string().email().optional().describe("Publisher support email"),
  /** Registration timestamp (when org became a publisher) */
  registeredAt: z.string().datetime()
});
var ReleaseChannelSchema = z.enum([
  "alpha",
  // Early development, unstable
  "beta",
  // Feature-complete, testing phase
  "rc",
  // Release candidate, final testing
  "stable"
  // Production-ready, general availability
]);
var VersionReleaseSchema = z.object({
  /** Semver version string */
  version: z.string().describe("Semver version (e.g., 2.1.0-beta.1)"),
  /** Release channel */
  channel: ReleaseChannelSchema.default("stable"),
  /** Release notes (Markdown) */
  releaseNotes: z.string().optional().describe("Release notes (Markdown)"),
  /** Changelog entries (structured) */
  changelog: z.array(z.object({
    type: z.enum(["added", "changed", "fixed", "removed", "deprecated", "security"]),
    description: z.string()
  })).optional().describe("Structured changelog entries"),
  /** Minimum platform version required */
  minPlatformVersion: z.string().optional(),
  /** Build artifact URL */
  artifactUrl: z.string().optional().describe("Built package artifact URL"),
  /** Artifact checksum (integrity) */
  artifactChecksum: z.string().optional().describe("SHA-256 checksum"),
  /** Whether this version is deprecated */
  deprecated: z.boolean().default(false),
  /** Deprecation message (if deprecated) */
  deprecationMessage: z.string().optional(),
  /** Release timestamp */
  releasedAt: z.string().datetime().optional()
});
var CreateListingRequestSchema = z.object({
  /** Package ID (reverse domain, e.g., com.acme.crm) */
  packageId: z.string().describe("Package identifier"),
  /** Display name */
  name: z.string().describe("App display name"),
  /** Short tagline (max 120 chars) */
  tagline: z.string().max(120).optional(),
  /** Full description (Markdown) */
  description: z.string().optional(),
  /** Category */
  category: z.string().describe("Marketplace category"),
  /** Additional tags */
  tags: z.array(z.string()).optional(),
  /** Icon URL */
  iconUrl: z.string().url().optional(),
  /** Screenshots */
  screenshots: z.array(z.object({
    url: z.string().url(),
    caption: z.string().optional()
  })).optional(),
  /** Documentation URL */
  documentationUrl: z.string().url().optional(),
  /** Support URL */
  supportUrl: z.string().url().optional(),
  /** Source repository URL */
  repositoryUrl: z.string().url().optional(),
  /** Pricing model */
  pricing: z.enum([
    "free",
    "freemium",
    "paid",
    "subscription",
    "usage-based",
    "contact-sales"
  ]).default("free"),
  /** Price in cents (if paid) */
  priceInCents: z.number().int().min(0).optional()
});
var UpdateListingRequestSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Listing ID to update"),
  /** Updatable fields (all optional, partial update) */
  name: z.string().optional(),
  tagline: z.string().max(120).optional(),
  description: z.string().optional(),
  category: z.string().optional(),
  tags: z.array(z.string()).optional(),
  iconUrl: z.string().url().optional(),
  screenshots: z.array(z.object({
    url: z.string().url(),
    caption: z.string().optional()
  })).optional(),
  documentationUrl: z.string().url().optional(),
  supportUrl: z.string().url().optional(),
  repositoryUrl: z.string().url().optional(),
  pricing: z.enum([
    "free",
    "freemium",
    "paid",
    "subscription",
    "usage-based",
    "contact-sales"
  ]).optional(),
  priceInCents: z.number().int().min(0).optional()
});
var ListingActionRequestSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Listing ID"),
  /** Action to perform */
  action: z.enum([
    "submit",
    // Submit for review
    "unlist",
    // Remove from public search (keep accessible by direct link)
    "deprecate",
    // Mark as deprecated
    "reactivate"
    // Reactivate unlisted/deprecated listing
  ]).describe("Action to perform on listing"),
  /** Reason for action (e.g., deprecation message) */
  reason: z.string().optional()
});
var AnalyticsTimeRangeSchema = z.enum([
  "last_7d",
  "last_30d",
  "last_90d",
  "last_365d",
  "all_time"
]);
var PublishingAnalyticsRequestSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Listing to get analytics for"),
  /** Time range */
  timeRange: AnalyticsTimeRangeSchema.default("last_30d"),
  /** Metrics to include */
  metrics: z.array(z.enum([
    "installs",
    // Install count over time
    "uninstalls",
    // Uninstall count over time
    "active_installs",
    // Active install trend
    "ratings",
    // Rating distribution
    "revenue",
    // Revenue (for paid apps)
    "page_views"
    // Listing page views
  ])).optional().describe("Metrics to include (default: all)")
});
var TimeSeriesPointSchema = z.object({
  /** ISO date string (day granularity) */
  date: z.string(),
  /** Metric value */
  value: z.number()
});
var PublishingAnalyticsResponseSchema = z.object({
  /** Listing ID */
  listingId: z.string(),
  /** Time range */
  timeRange: AnalyticsTimeRangeSchema,
  /** Summary statistics */
  summary: z.object({
    totalInstalls: z.number().int().min(0),
    activeInstalls: z.number().int().min(0),
    totalUninstalls: z.number().int().min(0),
    averageRating: z.number().min(0).max(5).optional(),
    totalRatings: z.number().int().min(0),
    totalRevenue: z.number().min(0).optional().describe("Revenue in cents"),
    pageViews: z.number().int().min(0)
  }),
  /** Time series data by metric */
  timeSeries: z.record(z.string(), z.array(TimeSeriesPointSchema)).optional().describe("Time series keyed by metric name"),
  /** Rating distribution (1-5 stars) */
  ratingDistribution: z.object({
    1: z.number().int().min(0).default(0),
    2: z.number().int().min(0).default(0),
    3: z.number().int().min(0).default(0),
    4: z.number().int().min(0).default(0),
    5: z.number().int().min(0).default(0)
  }).optional()
});
var ReviewCriterionSchema = z.object({
  /** Criterion identifier */
  id: z.string().describe("Criterion ID"),
  /** Category of criterion */
  category: z.enum([
    "security",
    // Security best practices
    "performance",
    // Performance / resource usage
    "quality",
    // Code quality / best practices
    "ux",
    // User experience standards
    "documentation",
    // Documentation completeness
    "policy",
    // Policy compliance (no malware, GDPR, etc.)
    "compatibility"
    // Platform compatibility
  ]),
  /** Description of what to check */
  description: z.string(),
  /** Whether this criterion must pass for approval */
  required: z.boolean().default(true),
  /** Pass/fail result */
  passed: z.boolean().optional(),
  /** Reviewer notes for this criterion */
  notes: z.string().optional()
});
var ReviewDecisionSchema = z.enum([
  "approved",
  // Approved for publishing
  "rejected",
  // Rejected (with reasons)
  "changes-requested"
  // Needs changes before re-review
]);
var RejectionReasonSchema = z.enum([
  "security-vulnerability",
  // Security issues found
  "policy-violation",
  // Violates marketplace policy
  "quality-below-standard",
  // Does not meet quality bar
  "misleading-metadata",
  // Listing info doesn't match functionality
  "incompatible",
  // Incompatible with current platform
  "duplicate",
  // Duplicate of existing listing
  "insufficient-documentation",
  // Inadequate documentation
  "other"
  // Other reason (see notes)
]);
var SubmissionReviewSchema = z.object({
  /** Review ID */
  id: z.string().describe("Review ID"),
  /** Submission ID being reviewed */
  submissionId: z.string().describe("Submission being reviewed"),
  /** Reviewer user ID */
  reviewerId: z.string().describe("Platform reviewer ID"),
  /** Review decision */
  decision: ReviewDecisionSchema.optional().describe("Final decision"),
  /** Review criteria checklist */
  criteria: z.array(ReviewCriterionSchema).optional().describe("Review checklist results"),
  /** Rejection reasons (if rejected) */
  rejectionReasons: z.array(RejectionReasonSchema).optional(),
  /** Detailed feedback for the developer */
  feedback: z.string().optional().describe("Detailed review feedback (Markdown)"),
  /** Internal notes (not visible to developer) */
  internalNotes: z.string().optional().describe("Internal reviewer notes"),
  /** Review started timestamp */
  startedAt: z.string().datetime().optional(),
  /** Review completed timestamp */
  completedAt: z.string().datetime().optional()
});
var FeaturedListingSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Featured listing ID"),
  /** Featured position/priority (lower = higher priority) */
  priority: z.number().int().min(0).default(0),
  /** Featured banner image URL */
  bannerUrl: z.string().url().optional(),
  /** Featured reason / editorial note */
  editorialNote: z.string().optional(),
  /** Start date for featured period */
  startDate: z.string().datetime(),
  /** End date for featured period */
  endDate: z.string().datetime().optional(),
  /** Whether currently active */
  active: z.boolean().default(true)
});
var CuratedCollectionSchema = z.object({
  /** Collection unique identifier */
  id: z.string().describe("Collection ID"),
  /** Collection display name */
  name: z.string().describe("Collection name"),
  /** Collection description */
  description: z.string().optional(),
  /** Cover image URL */
  coverImageUrl: z.string().url().optional(),
  /** Listing IDs in this collection (ordered) */
  listingIds: z.array(z.string()).min(1).describe("Ordered listing IDs"),
  /** Whether publicly visible */
  published: z.boolean().default(false),
  /** Sort order for display among collections */
  sortOrder: z.number().int().min(0).default(0),
  /** Created by (admin user ID) */
  createdBy: z.string().optional(),
  /** Created at */
  createdAt: z.string().datetime().optional(),
  /** Updated at */
  updatedAt: z.string().datetime().optional()
});
var PolicyViolationTypeSchema = z.enum([
  "malware",
  // Malicious software
  "data-harvesting",
  // Unauthorized data collection
  "spam",
  // Spammy or misleading content
  "copyright",
  // Copyright/IP infringement
  "inappropriate-content",
  // Inappropriate or offensive content
  "terms-of-service",
  // General ToS violation
  "security-risk",
  // Unresolved critical security issues
  "abandoned"
  // Abandoned / no longer maintained
]);
var PolicyActionSchema = z.object({
  /** Action ID */
  id: z.string().describe("Action ID"),
  /** Listing ID */
  listingId: z.string().describe("Target listing ID"),
  /** Violation type */
  violationType: PolicyViolationTypeSchema,
  /** Action taken */
  action: z.enum([
    "warning",
    // Warning to publisher
    "suspend",
    // Temporarily suspend listing
    "takedown",
    // Permanently remove listing
    "restrict"
    // Restrict new installs (existing users keep access)
  ]),
  /** Detailed reason */
  reason: z.string().describe("Explanation of the violation"),
  /** Admin user who took the action */
  actionBy: z.string().describe("Admin user ID"),
  /** Timestamp */
  actionAt: z.string().datetime(),
  /** Resolution notes (if resolved) */
  resolution: z.string().optional(),
  /** Whether resolved */
  resolved: z.boolean().default(false)
});
var MarketplaceHealthMetricsSchema = z.object({
  /** Total number of published listings */
  totalListings: z.number().int().min(0),
  /** Listings by status breakdown (partial — only non-zero statuses) */
  listingsByStatus: z.record(z.string(), z.number().int().min(0)).optional(),
  /** Listings by category breakdown (partial — only non-zero categories) */
  listingsByCategory: z.record(z.string(), z.number().int().min(0)).optional(),
  /** Total registered publishers */
  totalPublishers: z.number().int().min(0),
  /** Verified publishers count */
  verifiedPublishers: z.number().int().min(0),
  /** Total installs across all listings (all time) */
  totalInstalls: z.number().int().min(0),
  /** Average time from submission to review completion (hours) */
  averageReviewTime: z.number().min(0).optional(),
  /** Pending review queue size */
  pendingReviews: z.number().int().min(0),
  /** Listings by pricing model (partial — only non-zero models) */
  listingsByPricing: z.record(z.string(), z.number().int().min(0)).optional(),
  /** Snapshot timestamp */
  snapshotAt: z.string().datetime()
});
var TrendingListingSchema = z.object({
  /** Listing ID */
  listingId: z.string(),
  /** Trending rank (1 = most trending) */
  rank: z.number().int().min(1),
  /** Trend score (computed from velocity of installs, ratings, page views) */
  trendScore: z.number().min(0),
  /** Install velocity (installs per day over measurement period) */
  installVelocity: z.number().min(0),
  /** Measurement period (e.g., "7d", "30d") */
  period: z.string()
});
var ReviewModerationStatusSchema = z.enum([
  "pending",
  // Awaiting moderation
  "approved",
  // Approved and visible
  "flagged",
  // Flagged for review
  "rejected"
  // Rejected (spam, inappropriate)
]);
var UserReviewSchema = z.object({
  /** Review ID */
  id: z.string().describe("Review ID"),
  /** Listing ID being reviewed */
  listingId: z.string().describe("Listing being reviewed"),
  /** Reviewer user ID */
  userId: z.string().describe("Review author user ID"),
  /** Reviewer display name */
  displayName: z.string().optional().describe("Reviewer display name"),
  /** Star rating (1-5) */
  rating: z.number().int().min(1).max(5).describe("Star rating (1-5)"),
  /** Review title */
  title: z.string().max(200).optional().describe("Review title"),
  /** Review body text */
  body: z.string().max(5e3).optional().describe("Review text"),
  /** Version the reviewer is using */
  appVersion: z.string().optional().describe("App version being reviewed"),
  /** Moderation status */
  moderationStatus: ReviewModerationStatusSchema.default("pending"),
  /** Number of "helpful" votes from other users */
  helpfulCount: z.number().int().min(0).default(0),
  /** Publisher's response to this review */
  publisherResponse: z.object({
    body: z.string(),
    respondedAt: z.string().datetime()
  }).optional().describe("Publisher response to review"),
  /** Submitted timestamp */
  submittedAt: z.string().datetime(),
  /** Updated timestamp */
  updatedAt: z.string().datetime().optional()
});
var SubmitReviewRequestSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Listing to review"),
  /** Star rating (1-5) */
  rating: z.number().int().min(1).max(5).describe("Star rating"),
  /** Review title */
  title: z.string().max(200).optional(),
  /** Review body */
  body: z.string().max(5e3).optional()
});
var ListReviewsRequestSchema = z.object({
  /** Listing ID */
  listingId: z.string().describe("Listing to get reviews for"),
  /** Sort by */
  sortBy: z.enum(["newest", "oldest", "highest", "lowest", "most-helpful"]).default("newest"),
  /** Filter by rating */
  rating: z.number().int().min(1).max(5).optional(),
  /** Pagination */
  page: z.number().int().min(1).default(1),
  pageSize: z.number().int().min(1).max(50).default(10)
});
var ListReviewsResponseSchema = z.object({
  /** Reviews */
  items: z.array(UserReviewSchema),
  /** Total count */
  total: z.number().int().min(0),
  /** Pagination */
  page: z.number().int().min(1),
  pageSize: z.number().int().min(1),
  /** Rating summary */
  ratingSummary: z.object({
    averageRating: z.number().min(0).max(5),
    totalRatings: z.number().int().min(0),
    distribution: z.object({
      1: z.number().int().min(0).default(0),
      2: z.number().int().min(0).default(0),
      3: z.number().int().min(0).default(0),
      4: z.number().int().min(0).default(0),
      5: z.number().int().min(0).default(0)
    })
  }).optional()
});
var RecommendationReasonSchema = z.enum([
  "popular-in-category",
  // Popular in your industry/category
  "similar-users",
  // Used by similar organizations
  "complements-installed",
  // Complements apps you already use
  "trending",
  // Currently trending
  "new-release",
  // Recently released / major update
  "editor-pick"
  // Editorial/curated recommendation
]);
var RecommendedAppSchema = z.object({
  /** Listing ID */
  listingId: z.string(),
  /** App name */
  name: z.string(),
  /** Short tagline */
  tagline: z.string().optional(),
  /** Icon URL */
  iconUrl: z.string().url().optional(),
  /** Category */
  category: MarketplaceCategorySchema,
  /** Pricing */
  pricing: PricingModelSchema,
  /** Average rating */
  averageRating: z.number().min(0).max(5).optional(),
  /** Active installs */
  activeInstalls: z.number().int().min(0).optional(),
  /** Why this is recommended */
  reason: RecommendationReasonSchema
});
var AppDiscoveryRequestSchema = z.object({
  /** Tenant ID for personalization */
  tenantId: z.string().optional(),
  /** Categories the customer is interested in */
  categories: z.array(MarketplaceCategorySchema).optional(),
  /** Platform version for compatibility filtering */
  platformVersion: z.string().optional(),
  /** Max number of items per section */
  limit: z.number().int().min(1).max(50).default(10)
});
var AppDiscoveryResponseSchema = z.object({
  /** Featured apps (editorial picks) */
  featured: z.array(RecommendedAppSchema).optional(),
  /** Personalized recommendations */
  recommended: z.array(RecommendedAppSchema).optional(),
  /** Trending apps */
  trending: z.array(RecommendedAppSchema).optional(),
  /** Recently added */
  newArrivals: z.array(RecommendedAppSchema).optional(),
  /** Curated collections */
  collections: z.array(z.object({
    id: z.string(),
    name: z.string(),
    description: z.string().optional(),
    coverImageUrl: z.string().url().optional(),
    apps: z.array(RecommendedAppSchema)
  })).optional()
});
var SubscriptionStatusSchema = z.enum([
  "active",
  // Active and paid
  "trialing",
  // Free trial period
  "past-due",
  // Payment overdue
  "cancelled",
  // Cancelled (still active until period ends)
  "expired"
  // Expired / ended
]);
var AppSubscriptionSchema = z.object({
  /** Subscription ID */
  id: z.string().describe("Subscription ID"),
  /** Listing ID */
  listingId: z.string().describe("App listing ID"),
  /** Tenant ID */
  tenantId: z.string().describe("Customer tenant ID"),
  /** Subscription status */
  status: SubscriptionStatusSchema,
  /** License key */
  licenseKey: z.string().optional(),
  /** Plan/tier name (if multiple plans) */
  plan: z.string().optional().describe("Subscription plan name"),
  /** Billing cycle */
  billingCycle: z.enum(["monthly", "annual"]).optional(),
  /** Price per billing cycle (in cents) */
  priceInCents: z.number().int().min(0).optional(),
  /** Current period start */
  currentPeriodStart: z.string().datetime().optional(),
  /** Current period end */
  currentPeriodEnd: z.string().datetime().optional(),
  /** Trial end date (if trialing) */
  trialEndDate: z.string().datetime().optional(),
  /** Whether auto-renew is on */
  autoRenew: z.boolean().default(true),
  /** Created timestamp */
  createdAt: z.string().datetime()
});
var InstalledAppSummarySchema = z.object({
  /** Listing ID */
  listingId: z.string(),
  /** Package ID */
  packageId: z.string(),
  /** Display name */
  name: z.string(),
  /** Icon URL */
  iconUrl: z.string().url().optional(),
  /** Installed version */
  installedVersion: z.string(),
  /** Latest available version */
  latestVersion: z.string().optional(),
  /** Whether an update is available */
  updateAvailable: z.boolean().default(false),
  /** Whether the app is currently enabled */
  enabled: z.boolean().default(true),
  /** Subscription status (for paid apps) */
  subscriptionStatus: SubscriptionStatusSchema.optional(),
  /** Installed timestamp */
  installedAt: z.string().datetime()
});
var ListInstalledAppsRequestSchema = z.object({
  /** Tenant ID */
  tenantId: z.string().optional(),
  /** Filter by enabled/disabled */
  enabled: z.boolean().optional(),
  /** Filter by update availability */
  updateAvailable: z.boolean().optional(),
  /** Sort by */
  sortBy: z.enum(["name", "installed-date", "updated-date"]).default("name"),
  /** Pagination */
  page: z.number().int().min(1).default(1),
  pageSize: z.number().int().min(1).max(100).default(20)
});
var ListInstalledAppsResponseSchema = z.object({
  /** Installed apps */
  items: z.array(InstalledAppSummarySchema),
  /** Total count */
  total: z.number().int().min(0),
  /** Pagination */
  page: z.number().int().min(1),
  pageSize: z.number().int().min(1)
});

export { AnalyticsTimeRangeSchema, AppDiscoveryRequestSchema, AppDiscoveryResponseSchema, AppSubscriptionSchema, ArtifactDownloadResponseSchema, ArtifactReferenceSchema, CreateListingRequestSchema, CuratedCollectionSchema, FeaturedListingSchema, InstalledAppSummarySchema, ListInstalledAppsRequestSchema, ListInstalledAppsResponseSchema, ListReviewsRequestSchema, ListReviewsResponseSchema, ListingActionRequestSchema, ListingStatusSchema, MarketplaceCategorySchema, MarketplaceHealthMetricsSchema, MarketplaceInstallRequestSchema, MarketplaceInstallResponseSchema, MarketplaceListingSchema, MarketplaceSearchRequestSchema, MarketplaceSearchResponseSchema, PackageSubmissionSchema, PolicyActionSchema, PolicyViolationTypeSchema, PricingModelSchema, PublisherProfileSchema, PublisherSchema, PublisherVerificationSchema, PublishingAnalyticsRequestSchema, PublishingAnalyticsResponseSchema, RecommendationReasonSchema, RecommendedAppSchema, RejectionReasonSchema, ReleaseChannelSchema, ReviewCriterionSchema, ReviewDecisionSchema, ReviewModerationStatusSchema, SubmissionReviewSchema, SubmitReviewRequestSchema, SubscriptionStatusSchema, TimeSeriesPointSchema, TrendingListingSchema, UpdateListingRequestSchema, UserReviewSchema, VersionReleaseSchema };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map