/*! Pixonaut SDK type declarations. Licensed under the MIT licence: see LICENSE-MIT. */ import { paths } from './schema.js'; /** What `P`'s `GET` answers, as JSON. */ export declare type AnswerOf

= ReadOf

extends { responses: { 200: { content: { "application/json": infer A; }; }; }; } ? A : never; /** What every bundle's `PixonautApiError` marks its refusals with: a * registered symbol, the same in each. */ declare const API_ERROR_BRAND: unique symbol; export declare interface ClientOptions { /** The key every read is made with. A secret or integration key only on a * server; in a browser, a publishable key. */ key: string; /** The API's address, such as `https://api.pixonaut.app`. */ baseUrl: string; /** The `fetch` reads are made with; the platform's own when omitted. */ fetch?: typeof fetch; /** The designer session reads are made in, sent as `x-pixonaut-session`. * A publishable key reads a shopper's upload only in the session it was * uploaded in. */ session?: string; } /** A client reading as `key`. In a browser, a key that must stay on a server * is refused here, before it is sent anywhere. */ export declare function createClient(opts: ClientOptions): PixonautClient; /** A method for every published `GET` operation, named from its * operationId, over `json` (an answer read as JSON) and `raw` (an answer * handed over as it came: a picture or a PDF). */ declare function operations({ json, raw }: Reads): { apiKeys: { /** List the tenant's API keys */ list: () => Promise>; }; assetCategories: { /** List asset categories */ list: (query?: QueryOf<"/v1/asset-categories">) => Promise>; }; assetFilters: { /** List the values the asset listing can filter on */ list: () => Promise>; }; assets: { /** Check whether the tenant already stores a file */ checkDuplicate: (sha256hex: string) => Promise>; content: { /** Fetch an asset's preview */ get: (id: string, query?: QueryOf<"/v1/assets/{id}/content">) => Promise; }; /** Read an asset */ get: (id: string) => Promise>; /** List assets */ list: (query?: QueryOf<"/v1/assets">) => Promise>; original: { /** Fetch an asset's file */ get: (id: string) => Promise; }; roundShapes: { /** Find the round shapes in a picture */ get: (id: string, query?: QueryOf<"/v1/assets/{id}/round-shapes">) => Promise>; }; usage: { /** Where an asset is used */ get: (id: string) => Promise>; }; }; assetTags: { /** List asset tags */ list: (query?: QueryOf<"/v1/asset-tags">) => Promise>; }; automations: { /** Read one of an automation's firings */ firing: (id: string, firingId: string) => Promise>; /** List an automation's firings */ firings: (id: string, query?: QueryOf<"/v1/automations/{id}/firings">) => Promise>; /** Read an automation */ get: (id: string) => Promise>; /** List the workspace's automations */ list: (query?: QueryOf<"/v1/automations">) => Promise>; /** List the placeholders an automation may write */ placeholders: () => Promise>; /** List an automation's versions */ versions: (id: string, query?: QueryOf<"/v1/automations/{id}/versions">) => Promise>; }; blanks: { /** Read a blank */ get: (id: string) => Promise>; /** List the tenant's blanks */ list: (query?: QueryOf<"/v1/blanks">) => Promise>; mockups: { /** List a blank's placements, views and mockups */ list: (id: string, query?: QueryOf<"/v1/blanks/{id}/mockups">) => Promise>; }; placements: { fittingTemplates: { /** List the templates that fit a placement */ list: (id: string, placementId: string, query?: QueryOf<"/v1/blanks/{id}/placements/{placementId}/fitting-templates">) => Promise>; }; }; previewTables: { /** Read the colour tables a design on a placement is drawn through */ get: (id: string, placementId: string) => Promise>; }; variants: { /** List a blank's variants */ list: (id: string, query?: QueryOf<"/v1/blanks/{id}/variants">) => Promise>; }; }; connectedStore: { /** Read this store's connection */ get: () => Promise>; }; customerSessions: { /** Inspect a customer session's uploads and proofs */ get: (id: string) => Promise>; }; designs: { delivery: { /** Read who a design's first order is for and where it ships */ get: (id: string) => Promise>; }; designer: { /** Open a design in the designer to correct it */ get: (id: string) => Promise>; }; /** Read one design */ get: (id: string) => Promise>; /** List the tenant's designs, newest first */ list: (query?: QueryOf<"/v1/designs">) => Promise>; mockup: { /** Render a design on a product photo */ get: (id: string, query?: QueryOf<"/v1/designs/{id}/mockup.png">) => Promise; }; proof: { /** Fetch a design's proof image */ get: (id: string, query?: QueryOf<"/v1/designs/{id}/proof">) => Promise; }; review: { /** Read a design as its customer reviews it */ get: (id: string) => Promise>; }; revisions: { /** Read one revision of a design */ get: (id: string, revision: string) => Promise>; image: { /** Draw a revision of a design */ get: (id: string, revision: string, query?: QueryOf<"/v1/designs/{id}/revisions/{revision}/image">) => Promise; }; /** List a design's revisions */ list: (id: string, query?: QueryOf<"/v1/designs/{id}/revisions">) => Promise>; }; }; events: { /** Pull the tenant's events after a given one */ list: (query?: QueryOf<"/v1/events">) => Promise>; }; orders: { deliveries: { /** Read an order's step delivery log */ list: (id: string) => Promise>; }; /** Read one order, with its history */ get: (id: string) => Promise>; job: { files: { /** Fetch the print file of an order */ get: (id: string, query?: QueryOf<"/v1/orders/{id}/job/file">) => Promise; /** List the files an order can be fetched as */ list: (id: string, query?: QueryOf<"/v1/orders/{id}/job/files">) => Promise>; }; /** Read an order as its printshop makes it */ get: (id: string, query?: QueryOf<"/v1/orders/{id}/job">) => Promise>; }; /** List the tenant's orders, newest first */ list: (query?: QueryOf<"/v1/orders">) => Promise>; progress: { /** Read an order as its customer follows it */ get: (id: string) => Promise>; }; /** List the blanks a failed order could be sent to */ rerouteTargets: (id: string, query?: QueryOf<"/v1/orders/{id}/reroute-targets">) => Promise>; }; prints: { files: { /** Fetch every file of a print as one zip */ bundle: (id: string, query?: QueryOf<"/v1/prints/{id}/bundle">) => Promise; /** Fetch a print's file */ get: (id: string, query?: QueryOf<"/v1/prints/{id}/file">) => Promise; /** List the files a print can be fetched as */ list: (id: string, query?: QueryOf<"/v1/prints/{id}/files">) => Promise>; }; /** Read one print */ get: (id: string) => Promise>; /** List the tenant's prints, newest first */ list: (query?: QueryOf<"/v1/prints">) => Promise>; }; printshopConnections: { /** List the tenant's printshop connections */ list: (query?: QueryOf<"/v1/printshop-connections">) => Promise>; }; shareLinks: { designer: { /** Read what a designer link was handed out with */ get: (id: string) => Promise>; }; /** List the tenant's share links */ list: (query?: QueryOf<"/v1/share-links">) => Promise>; }; storage: { /** Read the tenant's storage use */ get: () => Promise>; }; templates: { constraints: { /** Read what a print size of a template is judged against */ get: (id: string, query?: QueryOf<"/v1/templates/{id}/constraints">) => Promise>; }; fittingPlacements: { /** List the blank placements a template fits */ list: (id: string, query?: QueryOf<"/v1/templates/{id}/fitting-blanks">) => Promise>; }; /** Read a published template */ get: (id: string, query?: QueryOf<"/v1/templates/{id}">) => Promise>; /** List the tenant's templates */ list: (query?: QueryOf<"/v1/templates">) => Promise>; }; webhookEndpoints: { deliveries: { /** List an endpoint's recent deliveries */ list: (id: string) => Promise>; }; /** List the tenant's webhook endpoints */ list: () => Promise>; }; }; /** A path's `{name}` segments, by name. */ declare type PathParams = Record; /** A refusal from Pixonaut's API. `status` is the contract a host branches * on (an expired link's 401, a paused template's 404, a throttled visitor's * 429, an outage's 5xx); `code` is the server's `error`, as its error codes * list it, when its body names one; `requestId` names the request to * Pixonaut's support, when the response carried one. */ export declare class PixonautApiError extends Error { /** Whether `value` is a refusal from any of the SDK's bundles. Each entry * (client, core, the whole SDK) carries its own copy of this class, so a * refusal is told by its brand rather than by which copy made it: one * imported from the client catches the designer's refusals too. */ static [Symbol.hasInstance](value: unknown): boolean; readonly [API_ERROR_BRAND] = true; readonly status: number; readonly code?: string; readonly requestId?: string; /** what the design breaks, on a 422 that is a validation failure; the same * list `onValidation` was handed */ readonly violations?: RemoteViolation[]; /** The side refused, when `approve()` or `commit()` made a design of * several (#1364): its placement. */ placementId?: string; /** On a `link_design_limit` refusal: when the share link makes designs * again, in epoch milliseconds, or null for a limit in total, which never * reopens. */ readonly reopensAt?: number | null; /** On an `sdk_outdated` refusal: the first SDK release that draws the * template, or null when no released SDK does yet. */ readonly minimumSdkVersion?: string | null; constructor(message: string, status: number, detail?: { code?: string; violations?: RemoteViolation[]; requestId?: string; reopensAt?: number | null; minimumSdkVersion?: string | null; }); } /** The client: a method for every published `GET` operation, named from its * operationId (`client.templates.get(id)`). */ export declare type PixonautClient = ReturnType; /** The query `P`'s `GET` takes. */ export declare type QueryOf

= ReadOf

extends { parameters: { query?: infer Q; }; } ? NonNullable : never; declare type ReadOf

= paths[P] extends { get: infer O; } ? O : never; /** A path the reference serves a `GET` at. */ export declare type ReadPath = { [P in keyof paths]: paths[P] extends { get: object; } ? P : never; }[keyof paths]; declare interface Reads { /** `GET` `path` with `params` and `query`, and read its answer as JSON. */ json

(path: P, params: PathParams, query?: QueryOf

): Promise>; /** `GET` `path` with `params` and `query`, and hand its answer over as it * came: a picture or a PDF, for the caller to stream or save. */ raw

(path: P, params: PathParams, query?: QueryOf

): Promise; } /** A constraint failure as it arrives from the API, which strips `allowed` * before responding (issue #61, ADR 016 Amendment 3). * * Anything fed by BOTH paths — `onValidation`, notably — is typed as this, so * an embedder reading `allowed` off it gets a compile error rather than * `undefined` at runtime from the network path. * * Deliberately a plain `Omit` and NOT a branded type, unlike the API's * `PublicViolation`: a WASM `Violation` must remain assignable here, since the * local path really does hand one to the same callback. That means this type * documents intent rather than enforcing absence — it stops a consumer relying * on the field, not a producer including it. The enforcement that matters * happens server-side, where the field is actually removed. */ declare type RemoteViolation = Omit; /** A constraint failure as the WASM core emits it, `allowed` included. Only * the local path produces these: the browser already holds the template, so * restating one of its rules discloses nothing it did not send. */ declare interface Violation { layerId: string; prop: string; rule: string; given: unknown; allowed: unknown; /** `error` refuses a publish; `warning` never does (ADR 193). */ severity: "error" | "warning"; /** The code of the language whose overrides break the rule, when only * the template as it reads in that language does (#2123); a publish's * alone, so the designer never sees one. */ language?: string; /** The characters a glyph warning is about, each once in text order * (`text_draws_fallback_glyphs`, `text_draws_missing_glyphs`, #2214); * absent on every other rule. */ characters?: string[]; } export { }