import {z} from 'zod' export type DeliveryStatusTransitionParams = {deliveryStatus: string | null, deliveryStatuses?: (Array | null) | undefined, sendScheduledMessage?: (boolean | null) | undefined, scheduledSendDeltaMinutes?: (number | null) | undefined} | {deliveryStatuses: Array | null, deliveryStatus?: (string | null) | undefined, sendScheduledMessage?: (boolean | null) | undefined, scheduledSendDeltaMinutes?: (number | null) | undefined}; export type CreateDeliveryStatusTransitionTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'delivery_status_transition', parameters: DeliveryStatusTransitionParams}; export type DriverGeolocationWithinParams = {metricValue: number, deliveryStatus: string, hasCancellationReason?: (boolean | null) | undefined, firstTaskOnly?: (boolean | null) | undefined, statusHistoryIncludes?: (string | null) | undefined, statusHistoryDoesNotInclude?: (string | null) | undefined, condition?: 'within' | undefined, metricName?: ('minutes' | 'miles' | 'kilometers') | undefined, location: 'pickup_location' | 'dropoff_location'}; export type DriverGeolocationGreaterThanParams = {metricValue: number, deliveryStatus: string, hasCancellationReason?: (boolean | null) | undefined, firstTaskOnly?: (boolean | null) | undefined, statusHistoryIncludes?: (string | null) | undefined, statusHistoryDoesNotInclude?: (string | null) | undefined, condition?: 'greater_than' | undefined, metricName?: ('minutes' | 'miles' | 'kilometers') | undefined, location: 'pickup_location' | 'dropoff_location'}; export type DriverGeolocationStoppedForParams = {metricValue: number, deliveryStatus: string, hasCancellationReason?: (boolean | null) | undefined, firstTaskOnly?: (boolean | null) | undefined, statusHistoryIncludes?: (string | null) | undefined, statusHistoryDoesNotInclude?: (string | null) | undefined, condition?: 'stopped_for' | undefined, metricName?: 'minutes' | undefined}; export type CreateDriverGeolocationTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'driver_geolocation', parameters: DriverGeolocationWithinParams | DriverGeolocationGreaterThanParams | DriverGeolocationStoppedForParams}; export type TaskReassignmentParams = {metricValue: number, metricName?: 'number_of_times' | undefined, sendOnEveryTaskReassignment: boolean}; export type CreateTaskReassignmentTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'task_reassignment', parameters: TaskReassignmentParams}; export type DeliveryIncidentReportParams = {dirType?: ('all' | 'refund_request') | undefined, dirCreated?: boolean | undefined, dirResolved?: boolean | undefined}; export type CreateDeliveryIncidentReportTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'delivery_incident_report', parameters: DeliveryIncidentReportParams}; export type StuckStatusParams = {metricValue: number, metricName?: ('hours' | 'minutes' | null) | undefined, deliveryStatus: string, activateBeforePickup?: boolean | undefined, metricValue2?: (number | null) | undefined, metricName2?: ('hours' | 'minutes' | null) | undefined}; export type CreateStuckStatusTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'stuck_status', parameters: StuckStatusParams}; export type StatusesChangedTooQuicklyParams = {metricValue: number, metricName?: 'seconds' | undefined, deliveryStatus1: string, deliveryStatus2: string}; export type CreateStatusChangedTooQuicklyTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'status_changed_too_quickly', parameters: StatusesChangedTooQuicklyParams}; export type DriverLocationVsDeliveryStatusParams = {metricValue: number, metricName?: 'miles' | undefined, deliveryStatus: string}; export type CreateDriverLocationVsDeliveryStatusTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'driver_location_vs_delivery_status', parameters: DriverLocationVsDeliveryStatusParams}; export type DropoffDelayedParams = {metricValue: number, metricName?: 'minutes' | undefined}; export type CreateDropoffDelayedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'dropoff_delayed', parameters: DropoffDelayedParams}; export type PickupDelayedParams = {metricValue: number, metricName?: 'minutes' | undefined}; export type CreatePickupDelayedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'pickup_delayed', parameters: PickupDelayedParams}; export type OrderNeedsAttentionParams = {onlyOrdersWithDeliveryWindows?: boolean | undefined}; export type CreateOrderNeedsAttentionTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'order_needs_attention', parameters: OrderNeedsAttentionParams}; export type NoParams = Record; export type CreateAutodispatchFailedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'autodispatch_failed', parameters?: NoParams | undefined}; export type CreateAddressValidationFailedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'address_validation_failed', parameters?: NoParams | undefined}; export type CreateOrderReadyToFulfillTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'order_ready_to_fulfill', parameters?: NoParams | undefined}; export type CreateJobCreationFailedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'job_creation_failed', parameters?: NoParams | undefined}; export type TaskHealthStatusParams = {status: string, healthStatus: string}; export type CreateTaskHealthStatusTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'task_health_status', parameters: TaskHealthStatusParams}; export type CreateTasksAttemptsExhaustedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'tasks_attempts_exhausted', parameters?: NoParams | undefined}; export type CreateDeliveryCancellationFailedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'delivery_cancellation_failed', parameters?: NoParams | undefined}; export type InternalDriverNotAssignedParams = {minutes: number, referenceStatus?: ('job_created' | 'pickup_start_time') | undefined}; export type CreateInternalDriverNotAssignedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'internal_driver_not_assigned', parameters: InternalDriverNotAssignedParams}; export type CreateNashAiInvalidPodTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'nash_ai_invalid_pod', parameters?: NoParams | undefined}; export type DeliveryCompletedTooEarlyParams = {metricValue: number}; export type CreateDeliveryCompletedTooEarlyTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'delivery_completed_too_early', parameters: DeliveryCompletedTooEarlyParams}; export type StatusTriggeredTooEarlyParams = {metricValue: number, deliveryStatus: string}; export type CreateStatusTriggeredTooEarlyTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'status_triggered_too_early', parameters: StatusTriggeredTooEarlyParams}; export type OrderNotDispatchedParams = {metricValue: number}; export type CreateOrderNotDispatchedCloseToPickupTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'order_not_dispatched_close_to_pickup', parameters: OrderNotDispatchedParams}; export type RefundRequestParams = {statuses: Array<'under_review' | 'needs_attention' | 'cancelled' | 'approved' | 'denied' | 'nash_approved'>}; export type CreateRefundRequestTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'refund_request', parameters: RefundRequestParams}; export type CreateOptimizationOrderUnassignedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'optimization_order_unassigned', parameters?: NoParams | undefined}; export type ZoneGeolocationParams = {zoneIds?: (Array | null) | undefined}; export type CreateZoneGeolocationTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'zone_geolocation', parameters: ZoneGeolocationParams}; export type CreateApiBasedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'api_based', parameters?: NoParams | undefined}; export type OptimizationActionStatusParams = {optimizationActionStatus: 'failed' | 'success' | 'skipped'}; export type CreateOptimizationActionStatusTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'optimization_action_status', parameters: OptimizationActionStatusParams}; export type DriverStackingParams = {annotateAllDeliveries?: boolean | undefined, matchCourierAcrossProviders?: boolean | undefined}; export type CreateDriverStackingTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'driver_stacking', parameters: DriverStackingParams}; export type TimeElapsedSinceStatusParams = {checkAfterMinutes?: (number | null) | undefined, deliveryStatus: string, statusCondition?: ('in' | 'not_in') | undefined, deliveryStatusArray: Array}; export type CreateTimeElapsedSinceStatusTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'time_elapsed_since_status', parameters: TimeElapsedSinceStatusParams}; export type ActivityStatus = 'QUEUED' | 'IN_PROGRESS' | 'SUCCESS' | 'FAILED' | 'CANCELLED' | 'SKIPPED' | 'SCHEDULED'; export type ActivityAction = 'act_dispatch_optimized_orders' | 'act_optimize_orders' | 'act_optimize_plan' | 'act_store_catalog_sync_run' | 'act_store_catalog_sync_file' | 'act_optimize_routes' | 'act_post_dispatch_reoptimize' | 'act_manifest_orders' | 'act_orders_bulk_operation' | 'act_orders_bulk_action' | 'act_process_csv_upload' | 'act_dispatch_routes' | 'act_dispatch_delivery_window_orders' | 'act_dispatch_and_manifest_batch' | 'act_dispatch_and_manifest_chunk' | 'generate_refund_ai_analysis_report' | 'generate_customer_feedback_report' | 'generate_report' | 'act_harness_experiment' | 'act_calculate_schedule'; export type ActivityStatusTransitionParams = {activityStatus: ActivityStatus, activityActions: Array}; export type CreateActivityStatusTransitionTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'activity_status_transition', parameters: ActivityStatusTransitionParams}; export type CreateDemoTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'demo', parameters?: NoParams | undefined}; export type CustomEventListenerParams = {eventNames: Array}; export type CreateCustomEventListenerTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'custom_event_listener', parameters: CustomEventListenerParams}; export type CreateProofOfDeliveryUploadedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'proof_of_delivery_uploaded', parameters?: NoParams | undefined}; export type CreateCourierUpdatedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'courier_updated', parameters?: NoParams | undefined}; export type CreateTimingUpdatedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'timing_updated', parameters?: NoParams | undefined}; export type CreateAiConversationCompletedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'ai_conversation_completed', parameters?: NoParams | undefined}; export type DeliveryWindowBookedTimeoutParams = {timeoutMinutes: number}; export type CreateDeliveryWindowBookedTimeoutTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'delivery_window_booked_timeout', parameters: DeliveryWindowBookedTimeoutParams}; export type OrderModifiedField = 'pickup_time' | 'dropoff_time' | 'pickup_location' | 'dropoff_location' | 'pickup_contact' | 'dropoff_contact' | 'pickup_instructions' | 'dropoff_instructions' | 'items' | 'tip' | 'order_value'; export type OrderModifiedParams = {modifiedFields: Array}; export type CreateOrderModifiedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'order_modified', parameters?: (OrderModifiedParams | null) | undefined}; export type RouteStatus = 'created' | 'assigned' | 'started' | 'in_progress' | 'completed' | 'failed' | 'canceled'; export type RouteStatusTransitionParams = {routeStatus?: (RouteStatus | null) | undefined, routeStatuses?: (Array | null) | undefined}; export type CreateRouteStatusTransitionTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'route_status_transition', parameters?: (RouteStatusTransitionParams | null) | undefined}; export type OrderTimeParams = {direction?: ('before' | 'at' | 'after') | undefined, offsetMinutes?: number | undefined}; export type CreateOrderTimeTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'order_pickup_start_time' | 'order_pickup_end_time' | 'order_dropoff_start_time' | 'order_dropoff_end_time' | 'order_cutoff_time', parameters?: OrderTimeParams | undefined}; export type CreateConversationMessageReceivedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'conversation_message_received', parameters?: NoParams | undefined}; export type CreateConversationAssignedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'conversation_assigned', parameters?: NoParams | undefined}; export type CreateConversationResolvedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'conversation_resolved', parameters?: NoParams | undefined}; export type CreateConversationReopenedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'conversation_reopened', parameters?: NoParams | undefined}; export type CreateConversationHandlerChangedTrigger = {name: string, notificationGroupIds: Array, description?: (string | null) | undefined, enabled?: boolean | undefined, message?: (string | null) | undefined, flag?: (boolean | null) | undefined, autoResolveFlag?: (boolean | null) | undefined, optionsGroupIds?: (Array | null) | undefined, contractIds?: (Array | null) | undefined, isInternal?: (boolean | null) | undefined, zoneIds?: (Array | null) | undefined, customEventName?: (string | null) | undefined, conditionalLogic?: ({[key: string]: unknown} | null) | undefined, type: 'conversation_handler_changed', parameters?: NoParams | undefined}; export type CreateNotificationTriggerInput = CreateDeliveryStatusTransitionTrigger | CreateDriverGeolocationTrigger | CreateTaskReassignmentTrigger | CreateDeliveryIncidentReportTrigger | CreateStuckStatusTrigger | CreateStatusChangedTooQuicklyTrigger | CreateDriverLocationVsDeliveryStatusTrigger | CreateDropoffDelayedTrigger | CreatePickupDelayedTrigger | CreateOrderNeedsAttentionTrigger | CreateAutodispatchFailedTrigger | CreateAddressValidationFailedTrigger | CreateOrderReadyToFulfillTrigger | CreateJobCreationFailedTrigger | CreateTaskHealthStatusTrigger | CreateTasksAttemptsExhaustedTrigger | CreateDeliveryCancellationFailedTrigger | CreateInternalDriverNotAssignedTrigger | CreateNashAiInvalidPodTrigger | CreateDeliveryCompletedTooEarlyTrigger | CreateStatusTriggeredTooEarlyTrigger | CreateOrderNotDispatchedCloseToPickupTrigger | CreateRefundRequestTrigger | CreateOptimizationOrderUnassignedTrigger | CreateZoneGeolocationTrigger | CreateApiBasedTrigger | CreateOptimizationActionStatusTrigger | CreateDriverStackingTrigger | CreateTimeElapsedSinceStatusTrigger | CreateActivityStatusTransitionTrigger | CreateDemoTrigger | CreateCustomEventListenerTrigger | CreateProofOfDeliveryUploadedTrigger | CreateCourierUpdatedTrigger | CreateTimingUpdatedTrigger | CreateAiConversationCompletedTrigger | CreateDeliveryWindowBookedTimeoutTrigger | CreateOrderModifiedTrigger | CreateRouteStatusTransitionTrigger | CreateOrderTimeTrigger | CreateConversationMessageReceivedTrigger | CreateConversationAssignedTrigger | CreateConversationResolvedTrigger | CreateConversationReopenedTrigger | CreateConversationHandlerChangedTrigger; export type CreateApiV1NotificationTriggersArgs = {body: CreateNotificationTriggerInput}; export type CreateApiV1NotificationTriggersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const notificationTriggerResponse = z.object({id: z.string(), type: z.string(), name: z.string(), description: z.string().nullable().optional(), enabled: z.boolean(), notificationGroupIds: z.array(z.string()).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create Notification Trigger * * POST /v1/notification-triggers */ export const createApiV1NotificationTriggers = async (args: CreateApiV1NotificationTriggersArgs, options?: CreateApiV1NotificationTriggersOptions) => { const {baseUrl = "https://api.sandbox.usenash.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/notification-triggers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(notificationTriggerResponse, await res.json()) };