import { z } from 'zod';

// src/integration/connector.zod.ts
z.string().min(2, { message: "System identifier must be at least 2 characters" }).regex(/^[a-z][a-z0-9_.]*$/, {
  message: 'System identifier must be lowercase, starting with a letter, and may contain letters, numbers, underscores, or dots (e.g., "user_profile" or "order.created")'
}).describe("System identifier (lowercase with underscores or dots)");
var SnakeCaseIdentifierSchema = z.string().min(2, { message: "Identifier must be at least 2 characters" }).regex(/^[a-z][a-z0-9_]*$/, {
  message: 'Identifier must be lowercase snake_case, starting with a letter, and may contain only letters, numbers, and underscores (e.g., "user_profile")'
}).describe("Snake case identifier (lowercase with underscores only)");
z.string().min(3, { message: "Event name must be at least 3 characters" }).regex(/^[a-z][a-z0-9_.]*$/, {
  message: 'Event name must be lowercase with dots for namespacing (e.g., "user.created", "order.paid")'
}).describe("Event name (lowercase with dot notation for namespacing)");

// src/automation/webhook.zod.ts
var WebhookTriggerType = z.enum([
  "create",
  "update",
  "delete",
  "undelete",
  "api"
  // Manually triggered
]);
var WebhookSchema = z.object({
  name: SnakeCaseIdentifierSchema.describe("Webhook unique name (lowercase snake_case)"),
  label: z.string().optional().describe("Human-readable webhook label"),
  /** Scope */
  object: z.string().optional().describe("Object to listen to (optional for manual webhooks)"),
  triggers: z.array(WebhookTriggerType).optional().describe("Events that trigger execution"),
  /** Target */
  url: z.string().url().describe("External webhook endpoint URL"),
  method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).default("POST").describe("HTTP method"),
  /** Headers */
  headers: z.record(z.string(), z.string()).optional().describe("Custom HTTP headers"),
  /** Body/Payload */
  body: z.unknown().optional().describe("Request body payload (if not using default record data)"),
  /** Payload Configuration */
  payloadFields: z.array(z.string()).optional().describe("Fields to include. Empty = All"),
  includeSession: z.boolean().default(false).describe("Include user session info"),
  /** Authentication */
  authentication: z.object({
    type: z.enum(["none", "bearer", "basic", "api-key"]).describe("Authentication type"),
    credentials: z.record(z.string(), z.string()).optional().describe("Authentication credentials")
  }).optional().describe("Authentication configuration"),
  /** Retry Policy */
  retryPolicy: z.object({
    maxRetries: z.number().int().min(0).max(10).default(3).describe("Maximum retry attempts"),
    backoffStrategy: z.enum(["exponential", "linear", "fixed"]).default("exponential").describe("Backoff strategy"),
    initialDelayMs: z.number().int().min(100).default(1e3).describe("Initial retry delay in milliseconds"),
    maxDelayMs: z.number().int().min(1e3).default(6e4).describe("Maximum retry delay in milliseconds")
  }).optional().describe("Retry policy configuration"),
  /** Timeout */
  timeoutMs: z.number().int().min(1e3).max(3e5).default(3e4).describe("Request timeout in milliseconds"),
  /** Security */
  secret: z.string().optional().describe("Signing secret for HMAC signature verification"),
  /** Status */
  isActive: z.boolean().default(true).describe("Whether webhook is active"),
  /** Metadata */
  description: z.string().optional().describe("Webhook description"),
  tags: z.array(z.string()).optional().describe("Tags for organization")
});
z.object({
  name: SnakeCaseIdentifierSchema.describe("Webhook receiver unique name (lowercase snake_case)"),
  path: z.string().describe("URL Path (e.g. /webhooks/stripe)"),
  /** Verification */
  verificationType: z.enum(["none", "header_token", "hmac", "ip_whitelist"]).default("none"),
  verificationParams: z.object({
    header: z.string().optional(),
    secret: z.string().optional(),
    ips: z.array(z.string()).optional()
  }).optional(),
  /** Action */
  action: z.enum(["trigger_flow", "script", "upsert_record"]).default("trigger_flow"),
  target: z.string().describe("Flow ID or Script name")
});
var ConnectorOAuth2Schema = z.object({
  type: z.literal("oauth2"),
  authorizationUrl: z.string().url().describe("OAuth2 authorization endpoint"),
  tokenUrl: z.string().url().describe("OAuth2 token endpoint"),
  clientId: z.string().describe("OAuth2 client ID"),
  clientSecret: z.string().describe("OAuth2 client secret (typically from ENV)"),
  scopes: z.array(z.string()).optional().describe("Requested OAuth2 scopes"),
  redirectUri: z.string().url().optional().describe("OAuth2 redirect URI"),
  refreshToken: z.string().optional().describe("Refresh token for token renewal"),
  tokenExpiry: z.number().optional().describe("Token expiry timestamp")
});
var ConnectorAPIKeySchema = z.object({
  type: z.literal("api-key"),
  key: z.string().describe("API key value"),
  headerName: z.string().default("X-API-Key").describe("HTTP header name for API key"),
  paramName: z.string().optional().describe("Query parameter name (alternative to header)")
});
var ConnectorBasicAuthSchema = z.object({
  type: z.literal("basic"),
  username: z.string().describe("Username"),
  password: z.string().describe("Password")
});
var ConnectorBearerAuthSchema = z.object({
  type: z.literal("bearer"),
  token: z.string().describe("Bearer token")
});
var ConnectorNoAuthSchema = z.object({
  type: z.literal("none")
});
var ConnectorAuthConfigSchema = z.discriminatedUnion("type", [
  ConnectorOAuth2Schema,
  ConnectorAPIKeySchema,
  ConnectorBasicAuthSchema,
  ConnectorBearerAuthSchema,
  ConnectorNoAuthSchema
]);
var TransformTypeSchema = z.discriminatedUnion("type", [
  z.object({
    type: z.literal("constant"),
    value: z.unknown().describe("Constant value to use")
  }).describe("Set a constant value"),
  z.object({
    type: z.literal("cast"),
    targetType: z.enum(["string", "number", "boolean", "date"]).describe("Target data type")
  }).describe("Cast to a specific data type"),
  z.object({
    type: z.literal("lookup"),
    table: z.string().describe("Lookup table name"),
    keyField: z.string().describe("Field to match on"),
    valueField: z.string().describe("Field to retrieve")
  }).describe("Lookup value from another table"),
  z.object({
    type: z.literal("javascript"),
    expression: z.string().describe('JavaScript expression (e.g., "value.toUpperCase()")')
  }).describe("Custom JavaScript transformation"),
  z.object({
    type: z.literal("map"),
    mappings: z.record(z.string(), z.unknown()).describe('Value mappings (e.g., {"Active": "active"})')
  }).describe("Map values using a dictionary")
]);
var FieldMappingSchema = z.object({
  /**
   * Source field name
   */
  source: z.string().describe("Source field name"),
  /**
   * Target field name (should be snake_case for ObjectStack)
   */
  target: z.string().describe("Target field name"),
  /**
   * Transformation to apply
   */
  transform: TransformTypeSchema.optional().describe("Transformation to apply"),
  /**
   * Default value if source is null/undefined
   */
  defaultValue: z.unknown().optional().describe("Default if source is null/undefined")
});

// src/integration/connector.zod.ts
var FieldMappingSchema2 = FieldMappingSchema.extend({
  /**
   * Data type mapping (connector-specific)
   */
  dataType: z.enum([
    "string",
    "number",
    "boolean",
    "date",
    "datetime",
    "json",
    "array"
  ]).optional().describe("Target data type"),
  /**
   * Is this field required?
   */
  required: z.boolean().default(false).describe("Field is required"),
  /**
   * Bidirectional sync mode (connector-specific)
   */
  syncMode: z.enum([
    "read_only",
    // Only sync from external to ObjectStack
    "write_only",
    // Only sync from ObjectStack to external
    "bidirectional"
    // Sync both ways
  ]).default("bidirectional").describe("Sync mode")
});
var SyncStrategySchema = z.enum([
  "full",
  // Full refresh (delete all and re-import)
  "incremental",
  // Only sync changes since last sync
  "upsert",
  // Insert new, update existing
  "append_only"
  // Only insert new records
]).describe("Synchronization strategy");
var ConflictResolutionSchema = z.enum([
  "source_wins",
  // External system data takes precedence
  "target_wins",
  // ObjectStack data takes precedence
  "latest_wins",
  // Most recently modified wins
  "manual"
  // Flag for manual resolution
]).describe("Conflict resolution strategy");
var DataSyncConfigSchema = z.object({
  /**
   * Sync strategy
   */
  strategy: SyncStrategySchema.optional().default("incremental"),
  /**
   * Sync direction
   */
  direction: z.enum([
    "import",
    // External → ObjectStack
    "export",
    // ObjectStack → External
    "bidirectional"
    // Both ways
  ]).optional().default("import").describe("Sync direction"),
  /**
   * Sync frequency (cron expression)
   */
  schedule: z.string().optional().describe("Cron expression for scheduled sync"),
  /**
   * Enable real-time sync via webhooks
   */
  realtimeSync: z.boolean().optional().default(false).describe("Enable real-time sync"),
  /**
   * Field to track last sync timestamp
   */
  timestampField: z.string().optional().describe("Field to track last modification time"),
  /**
   * Conflict resolution strategy
   */
  conflictResolution: ConflictResolutionSchema.optional().default("latest_wins"),
  /**
   * Batch size for bulk operations
   */
  batchSize: z.number().min(1).max(1e4).optional().default(1e3).describe("Records per batch"),
  /**
   * Delete handling
   */
  deleteMode: z.enum([
    "hard_delete",
    // Permanently delete
    "soft_delete",
    // Mark as deleted
    "ignore"
    // Don't sync deletions
  ]).optional().default("soft_delete").describe("Delete handling mode"),
  /**
   * Filter criteria for selective sync
   */
  filters: z.record(z.string(), z.unknown()).optional().describe("Filter criteria for selective sync")
});
var WebhookEventSchema = z.enum([
  "record.created",
  "record.updated",
  "record.deleted",
  "sync.started",
  "sync.completed",
  "sync.failed",
  "auth.expired",
  "rate_limit.exceeded"
]).describe("Webhook event type");
var WebhookSignatureAlgorithmSchema = z.enum([
  "hmac_sha256",
  "hmac_sha512",
  "none"
]).describe("Webhook signature algorithm");
var WebhookConfigSchema = WebhookSchema.extend({
  /**
   * Events to listen for
   * Connector-specific events like sync completion, auth expiry, etc.
   */
  events: z.array(WebhookEventSchema).optional().describe("Connector events to subscribe to"),
  /**
   * Signature algorithm for webhook security
   */
  signatureAlgorithm: WebhookSignatureAlgorithmSchema.optional().default("hmac_sha256")
});
var RateLimitStrategySchema = z.enum([
  "fixed_window",
  // Fixed time window
  "sliding_window",
  // Sliding time window
  "token_bucket",
  // Token bucket algorithm
  "leaky_bucket"
  // Leaky bucket algorithm
]).describe("Rate limiting strategy");
var RateLimitConfigSchema = z.object({
  /**
   * Rate limiting strategy
   */
  strategy: RateLimitStrategySchema.optional().default("token_bucket"),
  /**
   * Maximum requests per window
   */
  maxRequests: z.number().min(1).describe("Maximum requests per window"),
  /**
   * Time window in seconds
   */
  windowSeconds: z.number().min(1).describe("Time window in seconds"),
  /**
   * Burst capacity (for token bucket)
   */
  burstCapacity: z.number().min(1).optional().describe("Burst capacity"),
  /**
   * Respect external system rate limits
   */
  respectUpstreamLimits: z.boolean().optional().default(true).describe("Respect external rate limit headers"),
  /**
   * Custom rate limit headers to check
   */
  rateLimitHeaders: z.object({
    remaining: z.string().optional().default("X-RateLimit-Remaining").describe("Header for remaining requests"),
    limit: z.string().optional().default("X-RateLimit-Limit").describe("Header for rate limit"),
    reset: z.string().optional().default("X-RateLimit-Reset").describe("Header for reset time")
  }).optional().describe("Custom rate limit headers")
});
var RetryStrategySchema = z.enum([
  "exponential_backoff",
  "linear_backoff",
  "fixed_delay",
  "no_retry"
]).describe("Retry strategy");
var RetryConfigSchema = z.object({
  /**
   * Retry strategy
   */
  strategy: RetryStrategySchema.optional().default("exponential_backoff"),
  /**
   * Maximum retry attempts
   */
  maxAttempts: z.number().min(0).max(10).optional().default(3).describe("Maximum retry attempts"),
  /**
   * Initial delay in milliseconds
   */
  initialDelayMs: z.number().min(100).optional().default(1e3).describe("Initial retry delay in ms"),
  /**
   * Maximum delay in milliseconds
   */
  maxDelayMs: z.number().min(1e3).optional().default(6e4).describe("Maximum retry delay in ms"),
  /**
   * Backoff multiplier (for exponential backoff)
   */
  backoffMultiplier: z.number().min(1).optional().default(2).describe("Exponential backoff multiplier"),
  /**
   * HTTP status codes to retry
   */
  retryableStatusCodes: z.array(z.number()).optional().default([408, 429, 500, 502, 503, 504]).describe("HTTP status codes to retry"),
  /**
   * Retry on network errors
   */
  retryOnNetworkError: z.boolean().optional().default(true).describe("Retry on network errors"),
  /**
   * Jitter to add randomness to retry delays
   */
  jitter: z.boolean().optional().default(true).describe("Add jitter to retry delays")
});
var ErrorCategorySchema = z.enum([
  "validation",
  "authorization",
  "not_found",
  "conflict",
  "rate_limit",
  "timeout",
  "server_error",
  "integration_error"
]).describe("Standard error category");
var ErrorMappingRuleSchema = z.object({
  sourceCode: z.union([z.string(), z.number()]).describe("External system error code"),
  sourceMessage: z.string().optional().describe("Pattern to match against error message"),
  targetCode: z.string().describe("ObjectStack standard error code"),
  targetCategory: ErrorCategorySchema.describe("Error category"),
  severity: z.enum(["low", "medium", "high", "critical"]).describe("Error severity level"),
  retryable: z.boolean().describe("Whether the error is retryable"),
  userMessage: z.string().optional().describe("Human-readable message to show users")
}).describe("Error mapping rule");
var ErrorMappingConfigSchema = z.object({
  rules: z.array(ErrorMappingRuleSchema).describe("Error mapping rules"),
  defaultCategory: ErrorCategorySchema.optional().default("integration_error").describe("Default category for unmapped errors"),
  unmappedBehavior: z.enum(["passthrough", "generic_error", "throw"]).describe("What to do with unmapped errors"),
  logUnmapped: z.boolean().optional().default(true).describe("Log unmapped errors")
}).describe("Error mapping configuration");
var HealthCheckConfigSchema = z.object({
  enabled: z.boolean().describe("Enable health checks"),
  intervalMs: z.number().optional().default(6e4).describe("Health check interval in milliseconds"),
  timeoutMs: z.number().optional().default(5e3).describe("Health check timeout in milliseconds"),
  endpoint: z.string().optional().describe("Health check endpoint path"),
  method: z.enum(["GET", "HEAD", "OPTIONS"]).optional().describe("HTTP method for health check"),
  expectedStatus: z.number().optional().default(200).describe("Expected HTTP status code"),
  unhealthyThreshold: z.number().optional().default(3).describe("Consecutive failures before marking unhealthy"),
  healthyThreshold: z.number().optional().default(1).describe("Consecutive successes before marking healthy")
}).describe("Health check configuration");
var CircuitBreakerConfigSchema = z.object({
  enabled: z.boolean().describe("Enable circuit breaker"),
  failureThreshold: z.number().optional().default(5).describe("Failures before opening circuit"),
  resetTimeoutMs: z.number().optional().default(3e4).describe("Time in open state before half-open"),
  halfOpenMaxRequests: z.number().optional().default(1).describe("Requests allowed in half-open state"),
  monitoringWindow: z.number().optional().default(6e4).describe("Rolling window for failure count in ms"),
  fallbackStrategy: z.enum(["cache", "default_value", "error", "queue"]).optional().describe("Fallback strategy when circuit is open")
}).describe("Circuit breaker configuration");
var ConnectorHealthSchema = z.object({
  healthCheck: HealthCheckConfigSchema.optional().describe("Health check configuration"),
  circuitBreaker: CircuitBreakerConfigSchema.optional().describe("Circuit breaker configuration")
}).describe("Connector health configuration");
var ConnectorTypeSchema = z.enum([
  "saas",
  // SaaS application connector
  "database",
  // Database connector
  "file_storage",
  // File storage connector
  "message_queue",
  // Message queue connector
  "api",
  // Generic REST/GraphQL API
  "custom"
  // Custom connector
]).describe("Connector type");
var ConnectorStatusSchema = z.enum([
  "active",
  // Connector is active and syncing
  "inactive",
  // Connector is configured but disabled
  "error",
  // Connector has errors
  "configuring"
  // Connector is being set up
]).describe("Connector status");
var ConnectorActionSchema = z.object({
  key: z.string().describe("Action key (machine name)"),
  label: z.string().describe("Human readable label"),
  description: z.string().optional(),
  inputSchema: z.record(z.string(), z.unknown()).optional().describe("Input parameters schema (JSON Schema)"),
  outputSchema: z.record(z.string(), z.unknown()).optional().describe("Output schema (JSON Schema)")
});
var ConnectorTriggerSchema = z.object({
  key: z.string().describe("Trigger key"),
  label: z.string().describe("Trigger label"),
  description: z.string().optional(),
  type: z.enum(["polling", "webhook"]).describe("Trigger type"),
  interval: z.number().optional().describe("Polling interval in seconds")
});
var ConnectorSchema = z.object({
  /**
   * Machine name (snake_case)
   */
  name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe("Unique connector identifier"),
  /**
   * Human-readable label
   */
  label: z.string().describe("Display label"),
  /**
   * Connector type
   */
  type: ConnectorTypeSchema.describe("Connector type"),
  /**
   * Description
   */
  description: z.string().optional().describe("Connector description"),
  /**
   * Icon identifier
   */
  icon: z.string().optional().describe("Icon identifier"),
  /**
   * Authentication configuration
   */
  authentication: ConnectorAuthConfigSchema.describe("Authentication configuration"),
  /** Zapier-style Capabilities */
  actions: z.array(ConnectorActionSchema).optional(),
  triggers: z.array(ConnectorTriggerSchema).optional(),
  /**
   * Data synchronization configuration
   */
  syncConfig: DataSyncConfigSchema.optional().describe("Data sync configuration"),
  /**
   * Field mappings
   */
  fieldMappings: z.array(FieldMappingSchema2).optional().describe("Field mapping rules"),
  /**
   * Webhook configuration
   */
  webhooks: z.array(WebhookConfigSchema).optional().describe("Webhook configurations"),
  /**
   * Rate limiting configuration
   */
  rateLimitConfig: RateLimitConfigSchema.optional().describe("Rate limiting configuration"),
  /**
   * Retry configuration
   */
  retryConfig: RetryConfigSchema.optional().describe("Retry configuration"),
  /**
   * Connection timeout in milliseconds
   */
  connectionTimeoutMs: z.number().min(1e3).max(3e5).optional().default(3e4).describe("Connection timeout in ms"),
  /**
   * Request timeout in milliseconds
   */
  requestTimeoutMs: z.number().min(1e3).max(3e5).optional().default(3e4).describe("Request timeout in ms"),
  /**
   * Connector status
   */
  status: ConnectorStatusSchema.optional().default("inactive").describe("Connector status"),
  /**
   * Enable connector
   */
  enabled: z.boolean().optional().default(true).describe("Enable connector"),
  /**
   * Error mapping configuration
   */
  errorMapping: ErrorMappingConfigSchema.optional().describe("Error mapping configuration"),
  /**
   * Health check and circuit breaker configuration
   */
  health: ConnectorHealthSchema.optional().describe("Health and resilience configuration"),
  /**
   * Custom metadata
   */
  metadata: z.record(z.string(), z.unknown()).optional().describe("Custom connector metadata")
});
var SaasProviderSchema = z.enum([
  "salesforce",
  "hubspot",
  "stripe",
  "shopify",
  "zendesk",
  "intercom",
  "mailchimp",
  "slack",
  "microsoft_dynamics",
  "servicenow",
  "netsuite",
  "custom"
]).describe("SaaS provider type");
var ApiVersionConfigSchema = z.object({
  version: z.string().describe('API version (e.g., "v2", "2023-10-01")'),
  isDefault: z.boolean().default(false).describe("Is this the default version"),
  deprecationDate: z.string().optional().describe("API version deprecation date (ISO 8601)"),
  sunsetDate: z.string().optional().describe("API version sunset date (ISO 8601)")
});
var SaasObjectTypeSchema = z.object({
  name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe("Object type name (snake_case)"),
  label: z.string().describe("Display label"),
  apiName: z.string().describe("API name in external system"),
  enabled: z.boolean().default(true).describe("Enable sync for this object"),
  supportsCreate: z.boolean().default(true).describe("Supports record creation"),
  supportsUpdate: z.boolean().default(true).describe("Supports record updates"),
  supportsDelete: z.boolean().default(true).describe("Supports record deletion"),
  fieldMappings: z.array(FieldMappingSchema2).optional().describe("Object-specific field mappings")
});
var SaasConnectorSchema = ConnectorSchema.extend({
  type: z.literal("saas"),
  /**
   * SaaS provider
   */
  provider: SaasProviderSchema.describe("SaaS provider type"),
  /**
   * Base URL for API requests
   */
  baseUrl: z.string().url().describe("API base URL"),
  /**
   * API version configuration
   */
  apiVersion: ApiVersionConfigSchema.optional().describe("API version configuration"),
  /**
   * Supported object types to sync
   */
  objectTypes: z.array(SaasObjectTypeSchema).describe("Syncable object types"),
  /**
   * OAuth-specific settings
   */
  oauthSettings: z.object({
    scopes: z.array(z.string()).describe("Required OAuth scopes"),
    refreshTokenUrl: z.string().url().optional().describe("Token refresh endpoint"),
    revokeTokenUrl: z.string().url().optional().describe("Token revocation endpoint"),
    autoRefresh: z.boolean().default(true).describe("Automatically refresh expired tokens")
  }).optional().describe("OAuth-specific configuration"),
  /**
   * Pagination settings
   */
  paginationConfig: z.object({
    type: z.enum(["cursor", "offset", "page"]).default("cursor").describe("Pagination type"),
    defaultPageSize: z.number().min(1).max(1e3).default(100).describe("Default page size"),
    maxPageSize: z.number().min(1).max(1e4).default(1e3).describe("Maximum page size")
  }).optional().describe("Pagination configuration"),
  /**
   * Sandbox/test environment settings
   */
  sandboxConfig: z.object({
    enabled: z.boolean().default(false).describe("Use sandbox environment"),
    baseUrl: z.string().url().optional().describe("Sandbox API base URL")
  }).optional().describe("Sandbox environment configuration"),
  /**
   * Custom request headers
   */
  customHeaders: z.record(z.string(), z.string()).optional().describe("Custom HTTP headers for all requests")
});
var salesforceConnectorExample = {
  name: "salesforce_production",
  label: "Salesforce Production",
  type: "saas",
  provider: "salesforce",
  baseUrl: "https://example.my.salesforce.com",
  apiVersion: {
    version: "v59.0",
    isDefault: true
  },
  authentication: {
    type: "oauth2",
    clientId: "${SALESFORCE_CLIENT_ID}",
    clientSecret: "${SALESFORCE_CLIENT_SECRET}",
    authorizationUrl: "https://login.salesforce.com/services/oauth2/authorize",
    tokenUrl: "https://login.salesforce.com/services/oauth2/token",
    grantType: "authorization_code",
    scopes: ["api", "refresh_token", "offline_access"]
  },
  objectTypes: [
    {
      name: "account",
      label: "Account",
      apiName: "Account",
      enabled: true,
      supportsCreate: true,
      supportsUpdate: true,
      supportsDelete: true
    },
    {
      name: "contact",
      label: "Contact",
      apiName: "Contact",
      enabled: true,
      supportsCreate: true,
      supportsUpdate: true,
      supportsDelete: true
    }
  ],
  syncConfig: {
    strategy: "incremental",
    direction: "bidirectional",
    schedule: "0 */6 * * *",
    // Every 6 hours
    realtimeSync: true,
    conflictResolution: "latest_wins",
    batchSize: 200,
    deleteMode: "soft_delete"
  },
  rateLimitConfig: {
    strategy: "token_bucket",
    maxRequests: 100,
    windowSeconds: 20,
    respectUpstreamLimits: true
  },
  retryConfig: {
    strategy: "exponential_backoff",
    maxAttempts: 3,
    initialDelayMs: 1e3,
    maxDelayMs: 3e4,
    backoffMultiplier: 2,
    retryableStatusCodes: [408, 429, 500, 502, 503, 504],
    retryOnNetworkError: true,
    jitter: true
  },
  status: "active",
  enabled: true
};
var hubspotConnectorExample = {
  name: "hubspot_crm",
  label: "HubSpot CRM",
  type: "saas",
  provider: "hubspot",
  baseUrl: "https://api.hubapi.com",
  authentication: {
    type: "api_key",
    apiKey: "${HUBSPOT_API_KEY}",
    headerName: "Authorization"
  },
  objectTypes: [
    {
      name: "company",
      label: "Company",
      apiName: "companies",
      enabled: true,
      supportsCreate: true,
      supportsUpdate: true,
      supportsDelete: true
    },
    {
      name: "deal",
      label: "Deal",
      apiName: "deals",
      enabled: true,
      supportsCreate: true,
      supportsUpdate: true,
      supportsDelete: true
    }
  ],
  syncConfig: {
    strategy: "incremental",
    direction: "import",
    schedule: "0 */4 * * *",
    // Every 4 hours
    conflictResolution: "source_wins",
    batchSize: 100
  },
  rateLimitConfig: {
    strategy: "token_bucket",
    maxRequests: 100,
    windowSeconds: 10
  },
  status: "active",
  enabled: true
};
var DatabaseProviderSchema = z.enum([
  "postgresql",
  "mysql",
  "mariadb",
  "mssql",
  "oracle",
  "mongodb",
  "redis",
  "cassandra",
  "snowflake",
  "bigquery",
  "redshift",
  "custom"
]).describe("Database provider type");
var DatabasePoolConfigSchema = z.object({
  min: z.number().min(0).default(2).describe("Minimum connections in pool"),
  max: z.number().min(1).default(10).describe("Maximum connections in pool"),
  idleTimeoutMs: z.number().min(1e3).default(3e4).describe("Idle connection timeout in ms"),
  connectionTimeoutMs: z.number().min(1e3).default(1e4).describe("Connection establishment timeout in ms"),
  acquireTimeoutMs: z.number().min(1e3).default(3e4).describe("Connection acquisition timeout in ms"),
  evictionRunIntervalMs: z.number().min(1e3).default(3e4).describe("Connection eviction check interval in ms"),
  testOnBorrow: z.boolean().default(true).describe("Test connection before use")
});
var SslConfigSchema = z.object({
  enabled: z.boolean().default(false).describe("Enable SSL/TLS"),
  rejectUnauthorized: z.boolean().default(true).describe("Reject unauthorized certificates"),
  ca: z.string().optional().describe("Certificate Authority certificate"),
  cert: z.string().optional().describe("Client certificate"),
  key: z.string().optional().describe("Client private key")
});
var CdcConfigSchema = z.object({
  enabled: z.boolean().default(false).describe("Enable CDC"),
  method: z.enum([
    "log_based",
    // Transaction log parsing (e.g., PostgreSQL logical replication)
    "trigger_based",
    // Database triggers for change tracking
    "query_based",
    // Timestamp-based queries
    "custom"
    // Custom CDC implementation
  ]).describe("CDC method"),
  slotName: z.string().optional().describe("Replication slot name (for log-based CDC)"),
  publicationName: z.string().optional().describe("Publication name (for PostgreSQL)"),
  startPosition: z.string().optional().describe("Starting position/LSN for CDC stream"),
  batchSize: z.number().min(1).max(1e4).default(1e3).describe("CDC batch size"),
  pollIntervalMs: z.number().min(100).default(1e3).describe("CDC polling interval in ms")
});
var DatabaseTableSchema = z.object({
  name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe("Table name in ObjectStack (snake_case)"),
  label: z.string().describe("Display label"),
  schema: z.string().optional().describe("Database schema name"),
  tableName: z.string().describe("Actual table name in database"),
  primaryKey: z.string().describe("Primary key column"),
  enabled: z.boolean().default(true).describe("Enable sync for this table"),
  fieldMappings: z.array(FieldMappingSchema2).optional().describe("Table-specific field mappings"),
  whereClause: z.string().optional().describe("SQL WHERE clause for filtering")
});
var DatabaseConnectorSchema = ConnectorSchema.extend({
  type: z.literal("database"),
  /**
   * Database provider
   */
  provider: DatabaseProviderSchema.describe("Database provider type"),
  /**
   * Connection configuration
   */
  connectionConfig: z.object({
    host: z.string().describe("Database host"),
    port: z.number().min(1).max(65535).describe("Database port"),
    database: z.string().describe("Database name"),
    username: z.string().describe("Database username"),
    password: z.string().describe("Database password (typically from ENV)"),
    options: z.record(z.string(), z.unknown()).optional().describe("Driver-specific connection options")
  }).describe("Database connection configuration"),
  /**
   * Connection pool configuration
   */
  poolConfig: DatabasePoolConfigSchema.optional().describe("Connection pool configuration"),
  /**
   * SSL/TLS configuration
   */
  sslConfig: SslConfigSchema.optional().describe("SSL/TLS configuration"),
  /**
   * Tables to sync
   */
  tables: z.array(DatabaseTableSchema).describe("Tables to sync"),
  /**
   * Change Data Capture configuration
   */
  cdcConfig: CdcConfigSchema.optional().describe("CDC configuration"),
  /**
   * Read replica configuration
   */
  readReplicaConfig: z.object({
    enabled: z.boolean().default(false).describe("Use read replicas"),
    hosts: z.array(z.object({
      host: z.string().describe("Replica host"),
      port: z.number().min(1).max(65535).describe("Replica port"),
      weight: z.number().min(0).max(1).default(1).describe("Load balancing weight")
    })).describe("Read replica hosts")
  }).optional().describe("Read replica configuration"),
  /**
   * Query timeout
   */
  queryTimeoutMs: z.number().min(1e3).max(3e5).optional().default(3e4).describe("Query timeout in ms"),
  /**
   * Enable query logging
   */
  enableQueryLogging: z.boolean().optional().default(false).describe("Enable SQL query logging")
});
var postgresConnectorExample = {
  name: "postgres_production",
  label: "Production PostgreSQL",
  type: "database",
  provider: "postgresql",
  authentication: {
    type: "basic",
    username: "${DB_USERNAME}",
    password: "${DB_PASSWORD}"
  },
  connectionConfig: {
    host: "db.example.com",
    port: 5432,
    database: "production",
    username: "${DB_USERNAME}",
    password: "${DB_PASSWORD}"
  },
  poolConfig: {
    min: 2,
    max: 20,
    idleTimeoutMs: 3e4,
    connectionTimeoutMs: 1e4,
    acquireTimeoutMs: 3e4,
    evictionRunIntervalMs: 3e4,
    testOnBorrow: true
  },
  sslConfig: {
    enabled: true,
    rejectUnauthorized: true
  },
  tables: [
    {
      name: "customer",
      label: "Customer",
      schema: "public",
      tableName: "customers",
      primaryKey: "id",
      enabled: true
    },
    {
      name: "order",
      label: "Order",
      schema: "public",
      tableName: "orders",
      primaryKey: "id",
      enabled: true,
      whereClause: "status != 'archived'"
    }
  ],
  cdcConfig: {
    enabled: true,
    method: "log_based",
    slotName: "objectstack_replication_slot",
    publicationName: "objectstack_publication",
    batchSize: 1e3,
    pollIntervalMs: 1e3
  },
  syncConfig: {
    strategy: "incremental",
    direction: "bidirectional",
    realtimeSync: true,
    conflictResolution: "latest_wins",
    batchSize: 1e3,
    deleteMode: "soft_delete"
  },
  status: "active",
  enabled: true
};
var mongoConnectorExample = {
  name: "mongodb_analytics",
  label: "MongoDB Analytics",
  type: "database",
  provider: "mongodb",
  authentication: {
    type: "basic",
    username: "${MONGO_USERNAME}",
    password: "${MONGO_PASSWORD}"
  },
  connectionConfig: {
    host: "mongodb.example.com",
    port: 27017,
    database: "analytics",
    username: "${MONGO_USERNAME}",
    password: "${MONGO_PASSWORD}",
    options: {
      authSource: "admin",
      replicaSet: "rs0"
    }
  },
  tables: [
    {
      name: "event",
      label: "Event",
      tableName: "events",
      primaryKey: "_id",
      enabled: true
    }
  ],
  cdcConfig: {
    enabled: true,
    method: "log_based",
    batchSize: 1e3,
    pollIntervalMs: 500
  },
  syncConfig: {
    strategy: "incremental",
    direction: "import",
    batchSize: 1e3
  },
  status: "active",
  enabled: true
};
var snowflakeConnectorExample = {
  name: "snowflake_warehouse",
  label: "Snowflake Data Warehouse",
  type: "database",
  provider: "snowflake",
  authentication: {
    type: "basic",
    username: "${SNOWFLAKE_USERNAME}",
    password: "${SNOWFLAKE_PASSWORD}"
  },
  connectionConfig: {
    host: "account.snowflakecomputing.com",
    port: 443,
    database: "ANALYTICS_DB",
    username: "${SNOWFLAKE_USERNAME}",
    password: "${SNOWFLAKE_PASSWORD}",
    options: {
      warehouse: "COMPUTE_WH",
      schema: "PUBLIC",
      role: "ANALYST"
    }
  },
  tables: [
    {
      name: "sales_summary",
      label: "Sales Summary",
      schema: "PUBLIC",
      tableName: "SALES_SUMMARY",
      primaryKey: "ID",
      enabled: true
    }
  ],
  syncConfig: {
    strategy: "full",
    direction: "import",
    schedule: "0 2 * * *",
    // Daily at 2 AM
    batchSize: 5e3
  },
  queryTimeoutMs: 6e4,
  status: "active",
  enabled: true
};
var FileStorageProviderSchema = z.enum([
  "s3",
  // Amazon S3
  "azure_blob",
  // Azure Blob Storage
  "gcs",
  // Google Cloud Storage
  "dropbox",
  // Dropbox
  "box",
  // Box
  "onedrive",
  // Microsoft OneDrive
  "google_drive",
  // Google Drive
  "sharepoint",
  // SharePoint
  "ftp",
  // FTP/SFTP
  "local",
  // Local file system
  "custom"
  // Custom file storage
]).describe("File storage provider type");
var FileAccessPatternSchema = z.enum([
  "public_read",
  // Public read access
  "private",
  // Private access
  "authenticated_read",
  // Requires authentication
  "bucket_owner_read",
  // Bucket owner has read access
  "bucket_owner_full"
  // Bucket owner has full control
]).describe("File access pattern");
var FileMetadataConfigSchema = z.object({
  extractMetadata: z.boolean().default(true).describe("Extract file metadata"),
  metadataFields: z.array(z.enum([
    "content_type",
    "file_size",
    "last_modified",
    "etag",
    "checksum",
    "creator",
    "created_at",
    "custom"
  ])).optional().describe("Metadata fields to extract"),
  customMetadata: z.record(z.string(), z.string()).optional().describe("Custom metadata key-value pairs")
});
var MultipartUploadConfigSchema = z.object({
  enabled: z.boolean().default(true).describe("Enable multipart uploads"),
  partSize: z.number().min(5 * 1024 * 1024).default(5 * 1024 * 1024).describe("Part size in bytes (min 5MB)"),
  maxConcurrentParts: z.number().min(1).max(10).default(5).describe("Maximum concurrent part uploads"),
  threshold: z.number().min(5 * 1024 * 1024).default(100 * 1024 * 1024).describe("File size threshold for multipart upload in bytes")
});
var FileVersioningConfigSchema = z.object({
  enabled: z.boolean().default(false).describe("Enable file versioning"),
  maxVersions: z.number().min(1).max(100).optional().describe("Maximum versions to retain"),
  retentionDays: z.number().min(1).optional().describe("Version retention period in days")
});
var FileFilterConfigSchema = z.object({
  includePatterns: z.array(z.string()).optional().describe("File patterns to include (glob)"),
  excludePatterns: z.array(z.string()).optional().describe("File patterns to exclude (glob)"),
  minFileSize: z.number().min(0).optional().describe("Minimum file size in bytes"),
  maxFileSize: z.number().min(1).optional().describe("Maximum file size in bytes"),
  allowedExtensions: z.array(z.string()).optional().describe("Allowed file extensions"),
  blockedExtensions: z.array(z.string()).optional().describe("Blocked file extensions")
});
var StorageBucketSchema = z.object({
  name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe("Bucket identifier in ObjectStack (snake_case)"),
  label: z.string().describe("Display label"),
  bucketName: z.string().describe("Actual bucket/container name in storage system"),
  region: z.string().optional().describe("Storage region"),
  enabled: z.boolean().default(true).describe("Enable sync for this bucket"),
  prefix: z.string().optional().describe("Prefix/path within bucket"),
  accessPattern: FileAccessPatternSchema.optional().describe("Access pattern"),
  fileFilters: FileFilterConfigSchema.optional().describe("File filter configuration")
});
var FileStorageConnectorSchema = ConnectorSchema.extend({
  type: z.literal("file_storage"),
  /**
   * File storage provider
   */
  provider: FileStorageProviderSchema.describe("File storage provider type"),
  /**
   * Storage configuration
   */
  storageConfig: z.object({
    endpoint: z.string().url().optional().describe("Custom endpoint URL"),
    region: z.string().optional().describe("Default region"),
    pathStyle: z.boolean().optional().default(false).describe("Use path-style URLs (for S3-compatible)")
  }).optional().describe("Storage configuration"),
  /**
   * Buckets/containers to sync
   */
  buckets: z.array(StorageBucketSchema).describe("Buckets/containers to sync"),
  /**
   * File metadata configuration
   */
  metadataConfig: FileMetadataConfigSchema.optional().describe("Metadata extraction configuration"),
  /**
   * Multipart upload configuration
   */
  multipartConfig: MultipartUploadConfigSchema.optional().describe("Multipart upload configuration"),
  /**
   * File versioning configuration
   */
  versioningConfig: FileVersioningConfigSchema.optional().describe("File versioning configuration"),
  /**
   * Enable server-side encryption
   */
  encryption: z.object({
    enabled: z.boolean().default(false).describe("Enable server-side encryption"),
    algorithm: z.enum(["AES256", "aws:kms", "custom"]).optional().describe("Encryption algorithm"),
    kmsKeyId: z.string().optional().describe("KMS key ID (for aws:kms)")
  }).optional().describe("Encryption configuration"),
  /**
   * Lifecycle policy
   */
  lifecyclePolicy: z.object({
    enabled: z.boolean().default(false).describe("Enable lifecycle policy"),
    deleteAfterDays: z.number().min(1).optional().describe("Delete files after N days"),
    archiveAfterDays: z.number().min(1).optional().describe("Archive files after N days")
  }).optional().describe("Lifecycle policy"),
  /**
   * Content processing configuration
   */
  contentProcessing: z.object({
    extractText: z.boolean().default(false).describe("Extract text from documents"),
    generateThumbnails: z.boolean().default(false).describe("Generate image thumbnails"),
    thumbnailSizes: z.array(z.object({
      width: z.number().min(1),
      height: z.number().min(1)
    })).optional().describe("Thumbnail sizes"),
    virusScan: z.boolean().default(false).describe("Scan for viruses")
  }).optional().describe("Content processing configuration"),
  /**
   * Download/upload buffer size
   */
  bufferSize: z.number().min(1024).default(64 * 1024).describe("Buffer size in bytes"),
  /**
   * Enable transfer acceleration (for supported providers)
   */
  transferAcceleration: z.boolean().default(false).describe("Enable transfer acceleration")
});
var s3ConnectorExample = {
  name: "s3_production_assets",
  label: "Production S3 Assets",
  type: "file_storage",
  provider: "s3",
  authentication: {
    type: "api_key",
    apiKey: "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}",
    headerName: "Authorization"
  },
  storageConfig: {
    region: "us-east-1",
    pathStyle: false
  },
  buckets: [
    {
      name: "product_images",
      label: "Product Images",
      bucketName: "my-company-product-images",
      region: "us-east-1",
      enabled: true,
      prefix: "products/",
      accessPattern: "public_read",
      fileFilters: {
        allowedExtensions: [".jpg", ".jpeg", ".png", ".webp"],
        maxFileSize: 10 * 1024 * 1024
        // 10MB
      }
    },
    {
      name: "customer_documents",
      label: "Customer Documents",
      bucketName: "my-company-customer-docs",
      region: "us-east-1",
      enabled: true,
      accessPattern: "private",
      fileFilters: {
        allowedExtensions: [".pdf", ".docx", ".xlsx"],
        maxFileSize: 50 * 1024 * 1024
        // 50MB
      }
    }
  ],
  metadataConfig: {
    extractMetadata: true,
    metadataFields: ["content_type", "file_size", "last_modified", "etag"]
  },
  multipartConfig: {
    enabled: true,
    partSize: 5 * 1024 * 1024,
    // 5MB
    maxConcurrentParts: 5,
    threshold: 100 * 1024 * 1024
    // 100MB
  },
  versioningConfig: {
    enabled: true,
    maxVersions: 10
  },
  encryption: {
    enabled: true,
    algorithm: "aws:kms",
    kmsKeyId: "${AWS_KMS_KEY_ID}"
  },
  contentProcessing: {
    extractText: true,
    generateThumbnails: true,
    thumbnailSizes: [
      { width: 150, height: 150 },
      { width: 300, height: 300 },
      { width: 600, height: 600 }
    ],
    virusScan: true
  },
  syncConfig: {
    strategy: "incremental",
    direction: "bidirectional",
    realtimeSync: true,
    conflictResolution: "latest_wins",
    batchSize: 100
  },
  transferAcceleration: true,
  status: "active",
  enabled: true
};
var googleDriveConnectorExample = {
  name: "google_drive_team",
  label: "Google Drive Team Folder",
  type: "file_storage",
  provider: "google_drive",
  authentication: {
    type: "oauth2",
    clientId: "${GOOGLE_CLIENT_ID}",
    clientSecret: "${GOOGLE_CLIENT_SECRET}",
    authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
    tokenUrl: "https://oauth2.googleapis.com/token",
    grantType: "authorization_code",
    scopes: ["https://www.googleapis.com/auth/drive.file"]
  },
  buckets: [
    {
      name: "team_drive",
      label: "Team Drive",
      bucketName: "shared-team-drive",
      enabled: true,
      fileFilters: {
        excludePatterns: ["*.tmp", "~$*"]
      }
    }
  ],
  metadataConfig: {
    extractMetadata: true,
    metadataFields: ["content_type", "file_size", "last_modified", "creator", "created_at"]
  },
  versioningConfig: {
    enabled: true,
    maxVersions: 5
  },
  syncConfig: {
    strategy: "incremental",
    direction: "bidirectional",
    realtimeSync: true,
    conflictResolution: "latest_wins",
    batchSize: 50
  },
  status: "active",
  enabled: true
};
var azureBlobConnectorExample = {
  name: "azure_blob_storage",
  label: "Azure Blob Storage",
  type: "file_storage",
  provider: "azure_blob",
  authentication: {
    type: "api_key",
    apiKey: "${AZURE_STORAGE_ACCOUNT_KEY}",
    headerName: "x-ms-blob-type"
  },
  storageConfig: {
    endpoint: "https://myaccount.blob.core.windows.net"
  },
  buckets: [
    {
      name: "archive_container",
      label: "Archive Container",
      bucketName: "archive",
      enabled: true,
      accessPattern: "private"
    }
  ],
  metadataConfig: {
    extractMetadata: true,
    metadataFields: ["content_type", "file_size", "last_modified", "etag"]
  },
  encryption: {
    enabled: true,
    algorithm: "AES256"
  },
  lifecyclePolicy: {
    enabled: true,
    archiveAfterDays: 90,
    deleteAfterDays: 365
  },
  syncConfig: {
    strategy: "incremental",
    direction: "import",
    schedule: "0 1 * * *",
    // Daily at 1 AM
    batchSize: 200
  },
  status: "active",
  enabled: true
};
var MessageQueueProviderSchema = z.enum([
  "rabbitmq",
  // RabbitMQ
  "kafka",
  // Apache Kafka
  "redis_pubsub",
  // Redis Pub/Sub
  "redis_streams",
  // Redis Streams
  "aws_sqs",
  // Amazon SQS
  "aws_sns",
  // Amazon SNS
  "google_pubsub",
  // Google Cloud Pub/Sub
  "azure_service_bus",
  // Azure Service Bus
  "azure_event_hubs",
  // Azure Event Hubs
  "nats",
  // NATS
  "pulsar",
  // Apache Pulsar
  "activemq",
  // Apache ActiveMQ
  "custom"
  // Custom message queue
]).describe("Message queue provider type");
var MessageFormatSchema = z.enum([
  "json",
  "xml",
  "protobuf",
  "avro",
  "text",
  "binary"
]).describe("Message format/serialization");
var AckModeSchema = z.enum([
  "auto",
  // Auto-acknowledge
  "manual",
  // Manual acknowledge after processing
  "client"
  // Client-controlled acknowledge
]).describe("Message acknowledgment mode");
var DeliveryGuaranteeSchema = z.enum([
  "at_most_once",
  // Fire and forget
  "at_least_once",
  // May deliver duplicates
  "exactly_once"
  // Guaranteed exactly once delivery
]).describe("Message delivery guarantee");
var ConsumerConfigSchema = z.object({
  enabled: z.boolean().optional().default(true).describe("Enable consumer"),
  consumerGroup: z.string().optional().describe("Consumer group ID"),
  concurrency: z.number().min(1).max(100).optional().default(1).describe("Number of concurrent consumers"),
  prefetchCount: z.number().min(1).max(1e3).optional().default(10).describe("Prefetch count"),
  ackMode: AckModeSchema.optional().default("manual"),
  autoCommit: z.boolean().optional().default(false).describe("Auto-commit offsets"),
  autoCommitIntervalMs: z.number().min(100).optional().default(5e3).describe("Auto-commit interval in ms"),
  sessionTimeoutMs: z.number().min(1e3).optional().default(3e4).describe("Session timeout in ms"),
  rebalanceTimeoutMs: z.number().min(1e3).optional().describe("Rebalance timeout in ms")
});
var ProducerConfigSchema = z.object({
  enabled: z.boolean().optional().default(true).describe("Enable producer"),
  acks: z.enum(["0", "1", "all"]).optional().default("all").describe("Acknowledgment level"),
  compressionType: z.enum(["none", "gzip", "snappy", "lz4", "zstd"]).optional().default("none").describe("Compression type"),
  batchSize: z.number().min(1).optional().default(16384).describe("Batch size in bytes"),
  lingerMs: z.number().min(0).optional().default(0).describe("Linger time in ms"),
  maxInFlightRequests: z.number().min(1).optional().default(5).describe("Max in-flight requests"),
  idempotence: z.boolean().optional().default(true).describe("Enable idempotent producer"),
  transactional: z.boolean().optional().default(false).describe("Enable transactional producer"),
  transactionTimeoutMs: z.number().min(1e3).optional().describe("Transaction timeout in ms")
});
var DlqConfigSchema = z.object({
  enabled: z.boolean().optional().default(false).describe("Enable DLQ"),
  queueName: z.string().describe("Dead letter queue/topic name"),
  maxRetries: z.number().min(0).max(100).optional().default(3).describe("Max retries before DLQ"),
  retryDelayMs: z.number().min(0).optional().default(6e4).describe("Retry delay in ms")
});
var TopicQueueSchema = z.object({
  name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe("Topic/queue identifier in ObjectStack (snake_case)"),
  label: z.string().describe("Display label"),
  topicName: z.string().describe("Actual topic/queue name in message queue system"),
  enabled: z.boolean().optional().default(true).describe("Enable sync for this topic/queue"),
  /**
   * Consumer or Producer
   */
  mode: z.enum(["consumer", "producer", "both"]).optional().default("both").describe("Consumer, producer, or both"),
  /**
   * Message format
   */
  messageFormat: MessageFormatSchema.optional().default("json"),
  /**
   * Partition/shard configuration
   */
  partitions: z.number().min(1).optional().describe("Number of partitions (for Kafka)"),
  /**
   * Replication factor
   */
  replicationFactor: z.number().min(1).optional().describe("Replication factor (for Kafka)"),
  /**
   * Consumer configuration
   */
  consumerConfig: ConsumerConfigSchema.optional().describe("Consumer-specific configuration"),
  /**
   * Producer configuration
   */
  producerConfig: ProducerConfigSchema.optional().describe("Producer-specific configuration"),
  /**
   * Dead letter queue configuration
   */
  dlqConfig: DlqConfigSchema.optional().describe("Dead letter queue configuration"),
  /**
   * Message routing key (for RabbitMQ)
   */
  routingKey: z.string().optional().describe("Routing key pattern"),
  /**
   * Message filter
   */
  messageFilter: z.object({
    headers: z.record(z.string(), z.string()).optional().describe("Filter by message headers"),
    attributes: z.record(z.string(), z.unknown()).optional().describe("Filter by message attributes")
  }).optional().describe("Message filter criteria")
});
var MessageQueueConnectorSchema = ConnectorSchema.extend({
  type: z.literal("message_queue"),
  /**
   * Message queue provider
   */
  provider: MessageQueueProviderSchema.describe("Message queue provider type"),
  /**
   * Broker configuration
   */
  brokerConfig: z.object({
    brokers: z.array(z.string()).describe("Broker addresses (host:port)"),
    clientId: z.string().optional().describe("Client ID"),
    connectionTimeoutMs: z.number().min(1e3).optional().default(3e4).describe("Connection timeout in ms"),
    requestTimeoutMs: z.number().min(1e3).optional().default(3e4).describe("Request timeout in ms")
  }).describe("Broker connection configuration"),
  /**
   * Topics/queues to sync
   */
  topics: z.array(TopicQueueSchema).describe("Topics/queues to sync"),
  /**
   * Delivery guarantee
   */
  deliveryGuarantee: DeliveryGuaranteeSchema.optional().default("at_least_once"),
  /**
   * SSL/TLS configuration
   */
  sslConfig: z.object({
    enabled: z.boolean().optional().default(false).describe("Enable SSL/TLS"),
    rejectUnauthorized: z.boolean().optional().default(true).describe("Reject unauthorized certificates"),
    ca: z.string().optional().describe("CA certificate"),
    cert: z.string().optional().describe("Client certificate"),
    key: z.string().optional().describe("Client private key")
  }).optional().describe("SSL/TLS configuration"),
  /**
   * SASL authentication (for Kafka)
   */
  saslConfig: z.object({
    mechanism: z.enum(["plain", "scram-sha-256", "scram-sha-512", "aws"]).describe("SASL mechanism"),
    username: z.string().optional().describe("SASL username"),
    password: z.string().optional().describe("SASL password")
  }).optional().describe("SASL authentication configuration"),
  /**
   * Schema registry configuration (for Kafka/Avro)
   */
  schemaRegistry: z.object({
    url: z.string().url().describe("Schema registry URL"),
    auth: z.object({
      username: z.string().optional(),
      password: z.string().optional()
    }).optional()
  }).optional().describe("Schema registry configuration"),
  /**
   * Message ordering
   */
  preserveOrder: z.boolean().optional().default(true).describe("Preserve message ordering"),
  /**
   * Enable metrics
   */
  enableMetrics: z.boolean().optional().default(true).describe("Enable message queue metrics"),
  /**
   * Enable distributed tracing
   */
  enableTracing: z.boolean().optional().default(false).describe("Enable distributed tracing")
});
var kafkaConnectorExample = {
  name: "kafka_production",
  label: "Production Kafka Cluster",
  type: "message_queue",
  provider: "kafka",
  authentication: {
    type: "none"
  },
  brokerConfig: {
    brokers: ["kafka-1.example.com:9092", "kafka-2.example.com:9092", "kafka-3.example.com:9092"],
    clientId: "objectstack-client",
    connectionTimeoutMs: 3e4,
    requestTimeoutMs: 3e4
  },
  topics: [
    {
      name: "order_events",
      label: "Order Events",
      topicName: "orders",
      enabled: true,
      mode: "consumer",
      messageFormat: "json",
      partitions: 10,
      replicationFactor: 3,
      consumerConfig: {
        enabled: true,
        consumerGroup: "objectstack-consumer-group",
        concurrency: 5,
        prefetchCount: 100,
        ackMode: "manual",
        autoCommit: false,
        sessionTimeoutMs: 3e4
      },
      dlqConfig: {
        enabled: true,
        queueName: "orders-dlq",
        maxRetries: 3,
        retryDelayMs: 6e4
      }
    },
    {
      name: "user_activity",
      label: "User Activity",
      topicName: "user-activity",
      enabled: true,
      mode: "producer",
      messageFormat: "json",
      partitions: 5,
      replicationFactor: 3,
      producerConfig: {
        enabled: true,
        acks: "all",
        compressionType: "snappy",
        batchSize: 16384,
        lingerMs: 10,
        maxInFlightRequests: 5,
        idempotence: true
      }
    }
  ],
  deliveryGuarantee: "at_least_once",
  saslConfig: {
    mechanism: "scram-sha-256",
    username: "${KAFKA_USERNAME}",
    password: "${KAFKA_PASSWORD}"
  },
  sslConfig: {
    enabled: true,
    rejectUnauthorized: true
  },
  preserveOrder: true,
  enableMetrics: true,
  enableTracing: true,
  status: "active",
  enabled: true
};
var rabbitmqConnectorExample = {
  name: "rabbitmq_events",
  label: "RabbitMQ Event Bus",
  type: "message_queue",
  provider: "rabbitmq",
  authentication: {
    type: "basic",
    username: "${RABBITMQ_USERNAME}",
    password: "${RABBITMQ_PASSWORD}"
  },
  brokerConfig: {
    brokers: ["amqp://rabbitmq.example.com:5672"],
    clientId: "objectstack-rabbitmq-client"
  },
  topics: [
    {
      name: "notifications",
      label: "Notifications",
      topicName: "notifications",
      enabled: true,
      mode: "both",
      messageFormat: "json",
      routingKey: "notification.*",
      consumerConfig: {
        enabled: true,
        prefetchCount: 10,
        ackMode: "manual"
      },
      producerConfig: {
        enabled: true
      },
      dlqConfig: {
        enabled: true,
        queueName: "notifications-dlq",
        maxRetries: 3,
        retryDelayMs: 3e4
      }
    }
  ],
  deliveryGuarantee: "at_least_once",
  status: "active",
  enabled: true
};
var sqsConnectorExample = {
  name: "aws_sqs_queue",
  label: "AWS SQS Queue",
  type: "message_queue",
  provider: "aws_sqs",
  authentication: {
    type: "api_key",
    apiKey: "${AWS_ACCESS_KEY_ID}:${AWS_SECRET_ACCESS_KEY}",
    headerName: "Authorization"
  },
  brokerConfig: {
    brokers: ["https://sqs.us-east-1.amazonaws.com"]
  },
  topics: [
    {
      name: "task_queue",
      label: "Task Queue",
      topicName: "task-queue",
      enabled: true,
      mode: "consumer",
      messageFormat: "json",
      consumerConfig: {
        enabled: true,
        concurrency: 10,
        prefetchCount: 10,
        ackMode: "manual"
      },
      dlqConfig: {
        enabled: true,
        queueName: "task-queue-dlq",
        maxRetries: 3,
        retryDelayMs: 12e4
      }
    }
  ],
  deliveryGuarantee: "at_least_once",
  retryConfig: {
    strategy: "exponential_backoff",
    maxAttempts: 3,
    initialDelayMs: 1e3,
    maxDelayMs: 6e4,
    backoffMultiplier: 2
  },
  status: "active",
  enabled: true
};
var pubsubConnectorExample = {
  name: "gcp_pubsub",
  label: "Google Cloud Pub/Sub",
  type: "message_queue",
  provider: "google_pubsub",
  authentication: {
    type: "oauth2",
    clientId: "${GCP_CLIENT_ID}",
    clientSecret: "${GCP_CLIENT_SECRET}",
    authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
    tokenUrl: "https://oauth2.googleapis.com/token",
    grantType: "client_credentials",
    scopes: ["https://www.googleapis.com/auth/pubsub"]
  },
  brokerConfig: {
    brokers: ["pubsub.googleapis.com"]
  },
  topics: [
    {
      name: "analytics_events",
      label: "Analytics Events",
      topicName: "projects/my-project/topics/analytics-events",
      enabled: true,
      mode: "both",
      messageFormat: "json",
      consumerConfig: {
        enabled: true,
        consumerGroup: "objectstack-subscription",
        concurrency: 5,
        prefetchCount: 100,
        ackMode: "manual"
      }
    }
  ],
  deliveryGuarantee: "at_least_once",
  enableMetrics: true,
  status: "active",
  enabled: true
};
var GitHubProviderSchema = z.enum([
  "github",
  // GitHub.com
  "github_enterprise"
  // GitHub Enterprise Server
]).describe("GitHub provider type");
var GitHubRepositorySchema = z.object({
  /**
   * Repository owner (organization or user)
   */
  owner: z.string().describe("Repository owner (organization or username)"),
  /**
   * Repository name
   */
  name: z.string().describe("Repository name"),
  /**
   * Default branch name
   */
  defaultBranch: z.string().optional().default("main").describe("Default branch name"),
  /**
   * Enable auto-merge for PRs
   */
  autoMerge: z.boolean().optional().default(false).describe("Enable auto-merge for pull requests"),
  /**
   * Branch protection rules
   */
  branchProtection: z.object({
    requiredReviewers: z.number().int().min(0).optional().default(1).describe("Required number of reviewers"),
    requireStatusChecks: z.boolean().optional().default(true).describe("Require status checks to pass"),
    enforceAdmins: z.boolean().optional().default(false).describe("Enforce protections for admins"),
    allowForcePushes: z.boolean().optional().default(false).describe("Allow force pushes"),
    allowDeletions: z.boolean().optional().default(false).describe("Allow branch deletions")
  }).optional().describe("Branch protection configuration"),
  /**
   * Repository topics/tags
   */
  topics: z.array(z.string()).optional().describe("Repository topics")
});
var GitHubCommitConfigSchema = z.object({
  /**
   * Commit author name
   */
  authorName: z.string().optional().describe("Commit author name"),
  /**
   * Commit author email
   */
  authorEmail: z.string().email().optional().describe("Commit author email"),
  /**
   * GPG sign commits
   */
  signCommits: z.boolean().optional().default(false).describe("Sign commits with GPG"),
  /**
   * Commit message template
   */
  messageTemplate: z.string().optional().describe("Commit message template"),
  /**
   * Conventional commits format
   */
  useConventionalCommits: z.boolean().optional().default(true).describe("Use conventional commits format")
});
var GitHubPullRequestConfigSchema = z.object({
  /**
   * Default PR title template
   */
  titleTemplate: z.string().optional().describe("PR title template"),
  /**
   * Default PR body template
   */
  bodyTemplate: z.string().optional().describe("PR body template"),
  /**
   * Default reviewers
   */
  defaultReviewers: z.array(z.string()).optional().describe("Default reviewers (usernames)"),
  /**
   * Default assignees
   */
  defaultAssignees: z.array(z.string()).optional().describe("Default assignees (usernames)"),
  /**
   * Default labels
   */
  defaultLabels: z.array(z.string()).optional().describe("Default labels"),
  /**
   * Enable draft PRs by default
   */
  draftByDefault: z.boolean().optional().default(false).describe("Create draft PRs by default"),
  /**
   * Auto-delete head branch after merge
   */
  deleteHeadBranch: z.boolean().optional().default(true).describe("Delete head branch after merge")
});
var GitHubActionsWorkflowSchema = z.object({
  /**
   * Workflow name
   */
  name: z.string().describe("Workflow name"),
  /**
   * Workflow file path
   */
  path: z.string().describe("Workflow file path (e.g., .github/workflows/ci.yml)"),
  /**
   * Enable workflow
   */
  enabled: z.boolean().optional().default(true).describe("Enable workflow"),
  /**
   * Workflow triggers
   */
  triggers: z.array(z.enum([
    "push",
    "pull_request",
    "release",
    "schedule",
    "workflow_dispatch",
    "repository_dispatch"
  ])).optional().describe("Workflow triggers"),
  /**
   * Environment variables
   */
  env: z.record(z.string(), z.string()).optional().describe("Environment variables"),
  /**
   * Secrets required
   */
  secrets: z.array(z.string()).optional().describe("Required secrets")
});
var GitHubReleaseConfigSchema = z.object({
  /**
   * Tag name pattern
   */
  tagPattern: z.string().optional().default("v*").describe("Tag name pattern (e.g., v*, release/*)"),
  /**
   * Use semantic versioning
   */
  semanticVersioning: z.boolean().optional().default(true).describe("Use semantic versioning"),
  /**
   * Generate release notes automatically
   */
  autoReleaseNotes: z.boolean().optional().default(true).describe("Generate release notes automatically"),
  /**
   * Release name template
   */
  releaseNameTemplate: z.string().optional().describe("Release name template"),
  /**
   * Pre-release pattern
   */
  preReleasePattern: z.string().optional().describe("Pre-release pattern (e.g., *-alpha, *-beta)"),
  /**
   * Create draft releases
   */
  draftByDefault: z.boolean().optional().default(false).describe("Create draft releases by default")
});
var GitHubIssueTrackingSchema = z.object({
  /**
   * Enable issue tracking
   */
  enabled: z.boolean().optional().default(true).describe("Enable issue tracking"),
  /**
   * Default issue labels
   */
  defaultLabels: z.array(z.string()).optional().describe("Default issue labels"),
  /**
   * Issue template paths
   */
  templatePaths: z.array(z.string()).optional().describe("Issue template paths"),
  /**
   * Auto-assign issues
   */
  autoAssign: z.boolean().optional().default(false).describe("Auto-assign issues"),
  /**
   * Auto-close stale issues
   */
  autoCloseStale: z.object({
    enabled: z.boolean().default(false),
    daysBeforeStale: z.number().int().min(1).optional().default(60),
    daysBeforeClose: z.number().int().min(1).optional().default(7),
    staleLabel: z.string().optional().default("stale")
  }).optional().describe("Auto-close stale issues configuration")
});
var GitHubConnectorSchema = ConnectorSchema.extend({
  type: z.literal("saas"),
  /**
   * GitHub provider type
   */
  provider: GitHubProviderSchema.describe("GitHub provider"),
  /**
   * GitHub API base URL
   */
  baseUrl: z.string().url().optional().default("https://api.github.com").describe("GitHub API base URL"),
  /**
   * Repositories to integrate
   */
  repositories: z.array(GitHubRepositorySchema).describe("Repositories to manage"),
  /**
   * Commit configuration
   */
  commitConfig: GitHubCommitConfigSchema.optional().describe("Commit configuration"),
  /**
   * Pull request configuration
   */
  pullRequestConfig: GitHubPullRequestConfigSchema.optional().describe("Pull request configuration"),
  /**
   * GitHub Actions workflows
   */
  workflows: z.array(GitHubActionsWorkflowSchema).optional().describe("GitHub Actions workflows"),
  /**
   * Release configuration
   */
  releaseConfig: GitHubReleaseConfigSchema.optional().describe("Release configuration"),
  /**
   * Issue tracking configuration
   */
  issueTracking: GitHubIssueTrackingSchema.optional().describe("Issue tracking configuration"),
  /**
   * Enable webhooks
   */
  enableWebhooks: z.boolean().optional().default(true).describe("Enable GitHub webhooks"),
  /**
   * Webhook events to subscribe
   */
  webhookEvents: z.array(z.enum([
    "push",
    "pull_request",
    "issues",
    "issue_comment",
    "release",
    "workflow_run",
    "deployment",
    "deployment_status",
    "check_run",
    "check_suite",
    "status"
  ])).optional().describe("Webhook events to subscribe to")
});
var githubPublicConnectorExample = {
  name: "github_public",
  label: "GitHub.com",
  type: "saas",
  provider: "github",
  baseUrl: "https://api.github.com",
  authentication: {
    type: "oauth2",
    clientId: "${GITHUB_CLIENT_ID}",
    clientSecret: "${GITHUB_CLIENT_SECRET}",
    authorizationUrl: "https://github.com/login/oauth/authorize",
    tokenUrl: "https://github.com/login/oauth/access_token",
    scopes: ["repo", "workflow", "write:packages"]
  },
  repositories: [
    {
      owner: "objectstack-ai",
      name: "spec",
      defaultBranch: "main",
      autoMerge: false,
      branchProtection: {
        requiredReviewers: 1,
        requireStatusChecks: true,
        enforceAdmins: false,
        allowForcePushes: false,
        allowDeletions: false
      },
      topics: ["objectstack", "low-code", "metadata-driven"]
    }
  ],
  commitConfig: {
    authorName: "ObjectStack Bot",
    authorEmail: "bot@objectstack.ai",
    signCommits: false,
    useConventionalCommits: true
  },
  pullRequestConfig: {
    titleTemplate: "{{type}}: {{description}}",
    defaultReviewers: ["team-lead"],
    defaultLabels: ["automated", "ai-generated"],
    draftByDefault: false,
    deleteHeadBranch: true
  },
  workflows: [
    {
      name: "CI",
      path: ".github/workflows/ci.yml",
      enabled: true,
      triggers: ["push", "pull_request"]
    },
    {
      name: "Release",
      path: ".github/workflows/release.yml",
      enabled: true,
      triggers: ["release"]
    }
  ],
  releaseConfig: {
    tagPattern: "v*",
    semanticVersioning: true,
    autoReleaseNotes: true,
    releaseNameTemplate: "Release {{version}}",
    draftByDefault: false
  },
  issueTracking: {
    enabled: true,
    defaultLabels: ["needs-triage"],
    autoAssign: false,
    autoCloseStale: {
      enabled: true,
      daysBeforeStale: 60,
      daysBeforeClose: 7,
      staleLabel: "stale"
    }
  },
  enableWebhooks: true,
  webhookEvents: ["push", "pull_request", "release", "workflow_run"],
  status: "active",
  enabled: true
};
var githubEnterpriseConnectorExample = {
  name: "github_enterprise",
  label: "GitHub Enterprise",
  type: "saas",
  provider: "github_enterprise",
  baseUrl: "https://github.enterprise.com/api/v3",
  authentication: {
    type: "oauth2",
    clientId: "${GITHUB_ENTERPRISE_CLIENT_ID}",
    clientSecret: "${GITHUB_ENTERPRISE_CLIENT_SECRET}",
    authorizationUrl: "https://github.enterprise.com/login/oauth/authorize",
    tokenUrl: "https://github.enterprise.com/login/oauth/access_token",
    scopes: ["repo", "admin:org", "workflow"]
  },
  repositories: [
    {
      owner: "enterprise-org",
      name: "internal-app",
      defaultBranch: "develop",
      autoMerge: true,
      branchProtection: {
        requiredReviewers: 2,
        requireStatusChecks: true,
        enforceAdmins: true,
        allowForcePushes: false,
        allowDeletions: false
      }
    }
  ],
  commitConfig: {
    authorName: "CI Bot",
    authorEmail: "ci-bot@enterprise.com",
    signCommits: true,
    useConventionalCommits: true
  },
  pullRequestConfig: {
    titleTemplate: "[{{branch}}] {{description}}",
    bodyTemplate: `## Changes

{{changes}}

## Testing

{{testing}}`,
    defaultReviewers: ["tech-lead", "security-team"],
    defaultLabels: ["automated"],
    draftByDefault: true,
    deleteHeadBranch: true
  },
  releaseConfig: {
    tagPattern: "release/*",
    semanticVersioning: true,
    autoReleaseNotes: true,
    preReleasePattern: "*-rc*",
    draftByDefault: true
  },
  status: "active",
  enabled: true
};
var VercelProviderSchema = z.enum([
  "vercel"
]).describe("Vercel provider type");
var VercelFrameworkSchema = z.enum([
  "nextjs",
  "react",
  "vue",
  "nuxtjs",
  "gatsby",
  "remix",
  "astro",
  "sveltekit",
  "solid",
  "angular",
  "static",
  "other"
]).describe("Frontend framework");
var GitRepositoryConfigSchema = z.object({
  /**
   * Git provider type
   */
  type: z.enum(["github", "gitlab", "bitbucket"]).describe("Git provider"),
  /**
   * Repository identifier (owner/repo)
   */
  repo: z.string().describe("Repository identifier (e.g., owner/repo)"),
  /**
   * Production branch
   */
  productionBranch: z.string().optional().default("main").describe("Production branch name"),
  /**
   * Auto-deploy production branch
   */
  autoDeployProduction: z.boolean().optional().default(true).describe("Auto-deploy production branch"),
  /**
   * Auto-deploy preview branches
   */
  autoDeployPreview: z.boolean().optional().default(true).describe("Auto-deploy preview branches")
});
var BuildConfigSchema = z.object({
  /**
   * Build command
   */
  buildCommand: z.string().optional().describe("Build command (e.g., npm run build)"),
  /**
   * Output directory
   */
  outputDirectory: z.string().optional().describe("Output directory (e.g., .next, dist)"),
  /**
   * Install command
   */
  installCommand: z.string().optional().describe("Install command (e.g., npm install, pnpm install)"),
  /**
   * Development command
   */
  devCommand: z.string().optional().describe("Development command (e.g., npm run dev)"),
  /**
   * Node.js version
   */
  nodeVersion: z.string().optional().describe("Node.js version (e.g., 18.x, 20.x)"),
  /**
   * Environment variables
   */
  env: z.record(z.string(), z.string()).optional().describe("Build environment variables")
});
var DeploymentConfigSchema = z.object({
  /**
   * Enable automatic deployments
   */
  autoDeployment: z.boolean().optional().default(true).describe("Enable automatic deployments"),
  /**
   * Deployment regions
   */
  regions: z.array(z.enum([
    "iad1",
    // US East (Washington, D.C.)
    "sfo1",
    // US West (San Francisco)
    "gru1",
    // South America (São Paulo)
    "lhr1",
    // Europe West (London)
    "fra1",
    // Europe Central (Frankfurt)
    "sin1",
    // Asia (Singapore)
    "syd1",
    // Australia (Sydney)
    "hnd1",
    // Asia (Tokyo)
    "icn1"
    // Asia (Seoul)
  ])).optional().describe("Deployment regions"),
  /**
   * Enable preview deployments
   */
  enablePreview: z.boolean().optional().default(true).describe("Enable preview deployments"),
  /**
   * Preview deployment comments on PRs
   */
  previewComments: z.boolean().optional().default(true).describe("Post preview URLs in PR comments"),
  /**
   * Production deployment protection
   */
  productionProtection: z.boolean().optional().default(true).describe("Require approval for production deployments"),
  /**
   * Deploy hooks
   */
  deployHooks: z.array(z.object({
    name: z.string().describe("Hook name"),
    url: z.string().url().describe("Deploy hook URL"),
    branch: z.string().optional().describe("Target branch")
  })).optional().describe("Deploy hooks")
});
var DomainConfigSchema = z.object({
  /**
   * Domain name
   */
  domain: z.string().describe("Domain name (e.g., app.example.com)"),
  /**
   * Enable HTTPS redirect
   */
  httpsRedirect: z.boolean().optional().default(true).describe("Redirect HTTP to HTTPS"),
  /**
   * Custom SSL certificate
   */
  customCertificate: z.object({
    cert: z.string().describe("SSL certificate"),
    key: z.string().describe("Private key"),
    ca: z.string().optional().describe("Certificate authority")
  }).optional().describe("Custom SSL certificate"),
  /**
   * Git branch for this domain
   */
  gitBranch: z.string().optional().describe("Git branch to deploy to this domain")
});
var EnvironmentVariablesSchema = z.object({
  /**
   * Variable name
   */
  key: z.string().describe("Environment variable name"),
  /**
   * Variable value
   */
  value: z.string().describe("Environment variable value"),
  /**
   * Target environments
   */
  target: z.array(z.enum(["production", "preview", "development"])).describe("Target environments"),
  /**
   * Is secret (encrypted)
   */
  isSecret: z.boolean().optional().default(false).describe("Encrypt this variable"),
  /**
   * Git branch (for preview/development)
   */
  gitBranch: z.string().optional().describe("Specific git branch")
});
var EdgeFunctionConfigSchema = z.object({
  /**
   * Function name
   */
  name: z.string().describe("Edge function name"),
  /**
   * Function path
   */
  path: z.string().describe("Function path (e.g., /api/*)"),
  /**
   * Regions to deploy
   */
  regions: z.array(z.string()).optional().describe("Specific regions for this function"),
  /**
   * Memory limit (MB)
   */
  memoryLimit: z.number().int().min(128).max(3008).optional().default(1024).describe("Memory limit in MB"),
  /**
   * Timeout (seconds)
   */
  timeout: z.number().int().min(1).max(300).optional().default(10).describe("Timeout in seconds")
});
var VercelProjectSchema = z.object({
  /**
   * Project name
   */
  name: z.string().describe("Vercel project name"),
  /**
   * Framework
   */
  framework: VercelFrameworkSchema.optional().describe("Frontend framework"),
  /**
   * Git repository
   */
  gitRepository: GitRepositoryConfigSchema.optional().describe("Git repository configuration"),
  /**
   * Build configuration
   */
  buildConfig: BuildConfigSchema.optional().describe("Build configuration"),
  /**
   * Deployment configuration
   */
  deploymentConfig: DeploymentConfigSchema.optional().describe("Deployment configuration"),
  /**
   * Custom domains
   */
  domains: z.array(DomainConfigSchema).optional().describe("Custom domains"),
  /**
   * Environment variables
   */
  environmentVariables: z.array(EnvironmentVariablesSchema).optional().describe("Environment variables"),
  /**
   * Edge functions
   */
  edgeFunctions: z.array(EdgeFunctionConfigSchema).optional().describe("Edge functions"),
  /**
   * Root directory
   */
  rootDirectory: z.string().optional().describe("Root directory (for monorepos)")
});
var VercelMonitoringSchema = z.object({
  /**
   * Enable Web Analytics
   */
  enableWebAnalytics: z.boolean().optional().default(false).describe("Enable Vercel Web Analytics"),
  /**
   * Enable Speed Insights
   */
  enableSpeedInsights: z.boolean().optional().default(false).describe("Enable Vercel Speed Insights"),
  /**
   * Enable Log Drains
   */
  logDrains: z.array(z.object({
    name: z.string().describe("Log drain name"),
    url: z.string().url().describe("Log drain URL"),
    headers: z.record(z.string(), z.string()).optional().describe("Custom headers"),
    sources: z.array(z.enum(["static", "lambda", "edge"])).optional().describe("Log sources")
  })).optional().describe("Log drains configuration")
});
var VercelTeamSchema = z.object({
  /**
   * Team ID or slug
   */
  teamId: z.string().optional().describe("Team ID or slug"),
  /**
   * Team name
   */
  teamName: z.string().optional().describe("Team name")
});
var VercelConnectorSchema = ConnectorSchema.extend({
  type: z.literal("saas"),
  /**
   * Vercel provider
   */
  provider: VercelProviderSchema.describe("Vercel provider"),
  /**
   * Vercel API base URL
   */
  baseUrl: z.string().url().optional().default("https://api.vercel.com").describe("Vercel API base URL"),
  /**
   * Team configuration
   */
  team: VercelTeamSchema.optional().describe("Vercel team configuration"),
  /**
   * Projects to manage
   */
  projects: z.array(VercelProjectSchema).describe("Vercel projects"),
  /**
   * Monitoring configuration
   */
  monitoring: VercelMonitoringSchema.optional().describe("Monitoring configuration"),
  /**
   * Enable webhooks
   */
  enableWebhooks: z.boolean().optional().default(true).describe("Enable Vercel webhooks"),
  /**
   * Webhook events to subscribe
   */
  webhookEvents: z.array(z.enum([
    "deployment.created",
    "deployment.succeeded",
    "deployment.failed",
    "deployment.ready",
    "deployment.error",
    "deployment.canceled",
    "deployment-checks-completed",
    "deployment-prepared",
    "project.created",
    "project.removed"
  ])).optional().describe("Webhook events to subscribe to")
});
var vercelNextJsConnectorExample = {
  name: "vercel_production",
  label: "Vercel Production",
  type: "saas",
  provider: "vercel",
  baseUrl: "https://api.vercel.com",
  authentication: {
    type: "bearer",
    token: "${VERCEL_TOKEN}"
  },
  projects: [
    {
      name: "objectstack-app",
      framework: "nextjs",
      gitRepository: {
        type: "github",
        repo: "objectstack-ai/app",
        productionBranch: "main",
        autoDeployProduction: true,
        autoDeployPreview: true
      },
      buildConfig: {
        buildCommand: "npm run build",
        outputDirectory: ".next",
        installCommand: "npm ci",
        devCommand: "npm run dev",
        nodeVersion: "20.x",
        env: {
          NEXT_PUBLIC_API_URL: "https://api.objectstack.ai"
        }
      },
      deploymentConfig: {
        autoDeployment: true,
        regions: ["iad1", "sfo1", "fra1"],
        enablePreview: true,
        previewComments: true,
        productionProtection: true
      },
      domains: [
        {
          domain: "app.objectstack.ai",
          httpsRedirect: true,
          gitBranch: "main"
        },
        {
          domain: "staging.objectstack.ai",
          httpsRedirect: true,
          gitBranch: "develop"
        }
      ],
      environmentVariables: [
        {
          key: "DATABASE_URL",
          value: "${DATABASE_URL}",
          target: ["production", "preview"],
          isSecret: true
        },
        {
          key: "NEXT_PUBLIC_ANALYTICS_ID",
          value: "UA-XXXXXXXX-X",
          target: ["production"],
          isSecret: false
        }
      ],
      edgeFunctions: [
        {
          name: "api-middleware",
          path: "/api/*",
          regions: ["iad1", "sfo1"],
          memoryLimit: 1024,
          timeout: 10
        }
      ]
    }
  ],
  monitoring: {
    enableWebAnalytics: true,
    enableSpeedInsights: true,
    logDrains: [
      {
        name: "datadog-logs",
        url: "https://http-intake.logs.datadoghq.com/api/v2/logs",
        headers: {
          "DD-API-KEY": "${DATADOG_API_KEY}"
        },
        sources: ["lambda", "edge"]
      }
    ]
  },
  enableWebhooks: true,
  webhookEvents: [
    "deployment.succeeded",
    "deployment.failed",
    "deployment.ready"
  ],
  status: "active",
  enabled: true
};
var vercelStaticSiteConnectorExample = {
  name: "vercel_docs",
  label: "Vercel Documentation",
  type: "saas",
  provider: "vercel",
  baseUrl: "https://api.vercel.com",
  authentication: {
    type: "bearer",
    token: "${VERCEL_TOKEN}"
  },
  team: {
    teamId: "team_xxxxxx",
    teamName: "ObjectStack"
  },
  projects: [
    {
      name: "objectstack-docs",
      framework: "static",
      gitRepository: {
        type: "github",
        repo: "objectstack-ai/docs",
        productionBranch: "main",
        autoDeployProduction: true,
        autoDeployPreview: true
      },
      buildConfig: {
        buildCommand: "npm run build",
        outputDirectory: "dist",
        installCommand: "npm ci",
        nodeVersion: "18.x"
      },
      deploymentConfig: {
        autoDeployment: true,
        regions: ["iad1", "lhr1", "sin1"],
        enablePreview: true,
        previewComments: true,
        productionProtection: false
      },
      domains: [
        {
          domain: "docs.objectstack.ai",
          httpsRedirect: true
        }
      ],
      environmentVariables: [
        {
          key: "ALGOLIA_APP_ID",
          value: "${ALGOLIA_APP_ID}",
          target: ["production", "preview"],
          isSecret: false
        },
        {
          key: "ALGOLIA_API_KEY",
          value: "${ALGOLIA_API_KEY}",
          target: ["production", "preview"],
          isSecret: true
        }
      ]
    }
  ],
  monitoring: {
    enableWebAnalytics: true,
    enableSpeedInsights: false
  },
  enableWebhooks: false,
  status: "active",
  enabled: true
};

export { AckModeSchema, ApiVersionConfigSchema, BuildConfigSchema, CdcConfigSchema, CircuitBreakerConfigSchema, ConflictResolutionSchema, ConnectorActionSchema, ConnectorHealthSchema, ConnectorSchema, ConnectorStatusSchema, ConnectorTriggerSchema, ConnectorTypeSchema, ConsumerConfigSchema, DataSyncConfigSchema, DatabaseConnectorSchema, DatabasePoolConfigSchema, DatabaseProviderSchema, DatabaseTableSchema, DeliveryGuaranteeSchema, DeploymentConfigSchema, DlqConfigSchema, DomainConfigSchema, EdgeFunctionConfigSchema, EnvironmentVariablesSchema, ErrorCategorySchema, ErrorMappingConfigSchema, ErrorMappingRuleSchema, FieldMappingSchema2 as FieldMappingSchema, FileAccessPatternSchema, FileFilterConfigSchema, FileMetadataConfigSchema, FileStorageConnectorSchema, FileStorageProviderSchema, FileVersioningConfigSchema, GitHubActionsWorkflowSchema, GitHubCommitConfigSchema, GitHubConnectorSchema, GitHubIssueTrackingSchema, GitHubProviderSchema, GitHubPullRequestConfigSchema, GitHubReleaseConfigSchema, GitHubRepositorySchema, GitRepositoryConfigSchema, HealthCheckConfigSchema, MessageFormatSchema, MessageQueueConnectorSchema, MessageQueueProviderSchema, MultipartUploadConfigSchema, ProducerConfigSchema, RateLimitConfigSchema, RateLimitStrategySchema, RetryConfigSchema, RetryStrategySchema, SaasConnectorSchema, SaasObjectTypeSchema, SaasProviderSchema, SslConfigSchema, StorageBucketSchema, SyncStrategySchema, TopicQueueSchema, VercelConnectorSchema, VercelFrameworkSchema, VercelMonitoringSchema, VercelProjectSchema, VercelProviderSchema, VercelTeamSchema, WebhookConfigSchema, WebhookEventSchema, WebhookSignatureAlgorithmSchema, azureBlobConnectorExample, githubEnterpriseConnectorExample, githubPublicConnectorExample, googleDriveConnectorExample, hubspotConnectorExample, kafkaConnectorExample, mongoConnectorExample, postgresConnectorExample, pubsubConnectorExample, rabbitmqConnectorExample, s3ConnectorExample, salesforceConnectorExample, snowflakeConnectorExample, sqsConnectorExample, vercelNextJsConnectorExample, vercelStaticSiteConnectorExample };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map