// Types of @marshplan/sdk (sdk/marshplan-sdk.js, sdk/marshplan-sdk.mjs). The API itself: /docs and /openapi.yaml. export type LonLat = [number, number]; export type Point = LonLat | { lon: number; lat: number } | string; export interface MarshplanOptions { baseUrl: string; /** Ключ компании: секретный mp_… или публичный mp_pk_… (страницы сайта) */ apiKey?: string; /** Токен приложения (mpa_…, после login) или телефона курьера (mpd_…) */ token?: string; refreshToken?: string; /** Новые токены после обновления: сохраните их */ onTokens?: (t: { access_token: string; refresh_token: string }) => void; /** Повторы при сбое сети, 429, 502 и 503 (по умолчанию 2); изменения — с одним Idempotency-Key */ retries?: number; fetch?: typeof fetch; timeout?: number; } export declare class MarshplanError extends Error { status: number; code?: string; requestId?: string; body?: any; } export type OrderStatus = 'new' | 'planned' | 'in_transit' | 'arrived' | 'delivered' | 'failed' | 'cancelled'; export interface OrderInput { external_id?: string; date?: string; name?: string; phone?: string; email?: string; address?: string; location?: LonLat; from?: string; to?: string; time_window?: [string, string]; slot?: string; service?: number; amount?: number; weight?: number; skills?: string[]; priority?: number; depot?: string; driver?: string; comment?: string; details?: string; notify?: boolean; metadata?: Record; } export interface Order extends OrderInput { id: string; status: OrderStatus; status_time?: string; location: LonLat | null; geocode?: { status: 'found' | 'given' | 'not_found' | 'out_of_coverage'; title?: string; precision?: string; message?: string }; booking?: string; plan?: { id: string; route: string; stop: string }; courier?: { id?: string; name?: string; phone?: string; vehicle?: string }; eta?: string; tracking_url?: string; proof?: { comment?: string; photo_url?: string; time?: string }; cancel_reason?: string; fail_reason?: string; history: { status: OrderStatus; time: string }[]; created: string; updated: string; warning?: string; } export interface OrderFilter { date?: string; from?: string; to?: string; status?: OrderStatus | OrderStatus[] | string; external_id?: string; plan_id?: string; updated_since?: string | number; limit?: number; cursor?: string; } export interface DeliveryQuote { deliverable: boolean; reason?: string; code?: string; address?: string; location?: LonLat; zone: { id: string; name: string } | null; date?: string; slots?: { slot: string; from: string; to: string; available: boolean; left?: number; reason?: string }[]; next_available?: { date: string; slot: string } | null; } export interface Tokens { access_token: string; refresh_token: string; token_type: 'Bearer'; expires_in: number; user: any; org: any; } export interface SyncEvent { id: string; stop?: string; status: 'started' | 'finished' | 'arrived' | 'done' | 'failed'; t?: number; comment?: string; photo?: string; } export declare class Marshplan { constructor(opts: MarshplanOptions); baseUrl: string; token: string; refreshToken: string; // search and routes geocode(q: string, opts?: { limit?: number; near?: LonLat; types?: string[] }): Promise; suggest(q: string, opts?: { limit?: number; near?: LonLat }): Promise; reverse(lon: number | string, lat?: number, opts?: { radius?: number }): Promise; route(points: Point[], opts?: { mode?: 'car' | 'foot' | 'truck'; steps?: boolean; geometry?: 'geojson' | 'polyline6' | 'none'; depart_at?: string; day?: string; truck?: { weight?: number; payload?: number; pass?: string | string[] } }): Promise; isochrone(point: Point, opts?: { minutes?: number[]; mode?: string; depart_at?: string }): Promise; match(track: [number, number, number?][], opts?: any): Promise; distance(coordinates: LonLat[]): Promise; matrix(sources: Point[], destinations?: Point[], opts?: { mode?: string }): Promise; optimize(problemOrPoints: any, opts?: any): Promise; optimizeAsync(problem: any, opts?: { onProgress?: (p: number) => void; interval?: number }): Promise; job(id: string): Promise; cancelJob(id: string): Promise; geocodeBatch(queries: string[], opts?: { near?: LonLat }): Promise; // orders createOrder(order: OrderInput, opts?: { idempotencyKey?: string }): Promise; upsertOrders(orders: OrderInput[]): Promise<{ created: number; updated: number; errors: number; results: any[] }>; orders(filter?: OrderFilter): Promise<{ orders: Order[]; has_more: boolean; next_cursor?: string }>; iterateOrders(filter?: OrderFilter): AsyncGenerator; order(id: string): Promise; orderByExternal(externalId: string): Promise; updateOrder(id: string, patch: OrderInput): Promise; deleteOrder(id: string): Promise<{ deleted: string }>; cancelOrder(id: string, reason?: string): Promise; cancelOrders(body: { ids?: string[]; external_ids?: string[]; reason?: string }): Promise<{ cancelled: number; results: any[] }>; planOrders(body?: { date?: string; ids?: string[]; name?: string; include?: ('recurring' | 'slots')[]; options?: any; save?: boolean }, opts?: { interval?: number; maxWait?: number }): Promise; deliveryQuote(where: Point, opts?: { date?: string; amount?: number; slots?: boolean }): Promise; widgetConfig(): Promise; static verifyWebhook(body: string | Uint8Array | ArrayBuffer, signature: string | undefined, secret: string): Promise; // apps and courier phones login(email: string, password: string, opts?: { client?: string; device?: string }): Promise; refresh(): Promise; logout(): Promise<{ revoked: boolean }>; apps(): Promise<{ id: string; client?: string; device?: string; created: string; current?: boolean }[]>; revokeApp(id: string): Promise; pairingCode(driverId: string): Promise<{ code: string; code_text: string; expires: string; deep_link: string; server: string; driver: any }>; driverDevices(driverId: string): Promise; unpairDevice(driverId: string, deviceId: string): Promise; pairDevice(code: string, device?: { platform?: string; name?: string; app_version?: string; push_provider?: 'fcm' | 'apns' | 'rustore'; push_token?: string | null }): Promise<{ token: string; device_id: string; driver: any; org: any }>; courierMe(): Promise; courierRoutes(date?: string): Promise<{ date: string; routes: any[] }>; updateDevice(d: { platform?: string; name?: string; app_version?: string; push_provider?: string; push_token?: string | null }): Promise; unpairMe(): Promise; courierSync(token: string, body: { version?: number; events?: SyncEvent[]; points?: any[] }): Promise<{ applied: string[]; failed: { id: string; code: string; error: string }[]; saved_points: number; version: number; route?: any }>; courier(token: string): Promise; courierStatus(token: string, body: any): Promise; courierTrack(token: string, points: any[]): Promise; // plans, fleet, notifications (see the source for the rest) createPlan(plan: any): Promise; plans(): Promise; plan(id: string, opts?: { fact?: boolean }): Promise; deletePlan(id: string): Promise; fleet(): Promise; saveFleet(f: any): Promise; drivers(): Promise; createDriver(d: any): Promise; updateDriver(id: string, patch: any): Promise; deleteDriver(id: string): Promise; zones(): Promise; createZone(z: any): Promise; webhooks(): Promise; createWebhook(h: { url: string; events?: string[]; secret?: string }): Promise; updateWebhook(id: string, patch: any): Promise; deleteWebhook(id: string): Promise; keys(): Promise; createKey(nameOrOpts: string | { name: string; kind?: 'secret' | 'public'; scopes?: string[]; origins?: string[] }): Promise; updateKey(id: string, patch: { name?: string; scopes?: string[]; origins?: string[] }): Promise; deleteKey(id: string): Promise; events(opts?: any): { on(type: string, fn: (data: any) => void): void; close(): void }; report(opts?: any): Promise; knowledge(opts?: { weeks?: number }): Promise; knowledgePlace(where: [number, number] | string): Promise<{ point: [number, number]; title?: string; own: any; shared?: any }>; knowledgeSettings(settings: { share?: boolean; learned_service?: boolean }): Promise<{ share: boolean; learned_service: boolean }>; benchmarks(days?: number): Promise; styleUrl(theme?: 'light' | 'dark'): string; createMap(container: string | HTMLElement, opts?: any): any; [method: string]: any; } export default Marshplan;