import { ServicePluginDefinition } from '@wix/sdk-types'; interface DecrementAvailabilityRequest { /** * Items for which to decrease their available stock quantity. * @minSize 1 * @maxSize 300 */ items: Item[]; /** * Whether to validate that the availability level doesn't become negative after the decrement. * * When set to `true`, the operation fails if any item would have negative availability after the decrement. When set to `false`, allows negative inventory levels. */ restrictInventoryValue: boolean | null; /** * Order ID associated with this inventory change. * @format GUID */ orderId: string; /** Reason for the inventory decrement. */ reason: Reason; } /** Inventory item that represents a product or service with stock availability that needs to be tracked and updated. */ interface Item { /** * Catalog reference that uniquely identifies the item. * * Contains the app ID and catalog item ID required to locate the specific item in the catalog. */ catalogReference?: CatalogReference; /** * Location ID where the inventory is managed. * * When not provided, the default location is used for inventory tracking. * @format GUID */ locationId?: string | null; /** * Quantity of the item to increment or decrement. * * For example, `5` to reduce availability by 5 units or increase availability by 5 units. * @min 1 * @max 100000 */ quantity?: number; /** * Whether the item is part of a subscription order. * * Subscription items may be processed differently by inventory systems depending on their recurring nature. */ subscriptionItem?: boolean; } /** Used for grouping line items. Sent when an item is added to a cart, checkout, or order. */ interface CatalogReference { /** * ID of the item within the catalog it belongs to. * @minLength 1 * @maxLength 36 */ catalogItemId?: string; /** * ID of the app providing the catalog. * * You can get your app's ID from its page in the [app dashboard](https://dev.wix.com/dc3/my-apps/). * * For items from Wix catalogs, the following values always apply: * + Wix Stores: `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` * + Wix Bookings: `"13d21c63-b5ec-5912-8397-c3a5ddb27a97"` * + Wix Restaurants: `"9a5d83fd-8570-482e-81ab-cfa88942ee60"` * @minLength 1 */ appId?: string; /** * Additional item details in `key:value` pairs. * * Use this optional field for more specificity with item selection. The values of the `options` field differ depending on which catalog is providing the items. * * For Wix Stores products, learn more about integrating with [Catalog V3](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/e-commerce-integration) * or [Catalog V1](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/e-commerce-integration), depending on [the version the site uses](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-versioning/introduction). */ options?: Record | null; } declare enum Reason { /** Order was placed by a customer. */ ORDER_PLACED = "ORDER_PLACED", /** Order was paid for by a customer. */ ORDER_PAID = "ORDER_PAID", /** Order was canceled. */ ORDER_CANCELED = "ORDER_CANCELED", /** Order was refunded. */ ORDER_REFUNDED = "ORDER_REFUNDED", /** Order was edited by a merchant. */ ORDER_EDITED = "ORDER_EDITED", /** Order was rejected. */ ORDER_REJECTED = "ORDER_REJECTED" } interface DecrementAvailabilityResponse { } interface IncrementAvailabilityRequest { /** * Items for which to increase their available stock quantity. * @minSize 1 * @maxSize 300 */ items: Item[]; /** * Order ID associated with this inventory change. * @format GUID */ orderId: string; /** Reason for the inventory increment. */ reason: Reason; } interface IncrementAvailabilityResponse { } /** Configuration for the Inventory service plugin that defines how Wix communicates with the inventory provider. */ interface InventorySpiConfig { /** * Base URI where the endpoints are called. * Wix eCommerce appends the endpoint path to the base URI. For example, to call the Decrement Availability endpoint at `https://my-inventory.com/v1/decrement`, the base URI you provide here is `https://my-inventory.com/`. * @minLength 1 * @maxLength 200 */ deploymentUri?: string; } /** * this message is not directly used by any service, * it exists to describe the expected parameters that SHOULD be provided to invoked Velo methods as part of open-platform. * e.g. SPIs, event-handlers, etc.. * NOTE: this context object MUST be provided as the last argument in each Velo method signature. * * Example: * ```typescript * export function wixStores_onOrderCanceled({ event, metadata }: OrderCanceledEvent) { * ... * } * ``` */ interface Context { /** A unique identifier of the request. You may print this ID to your logs to help with future debugging and easier correlation with Wix's logs. */ requestId?: string | null; /** * [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 3-letter currency code. * @format CURRENCY */ currency?: string | null; /** An object that describes the identity that triggered this request. */ identity?: IdentificationData; /** A string representing a language and region in the format of `"xx-XX"`. First 2 letters represent the language code according to ISO 639-1. This is followed by a dash "-", and then a by 2 capital letters representing the region according to ISO 3166-2. For example, `"en-US"`. */ languages?: string[]; /** * The service provider app's instance ID. * @format GUID */ instanceId?: string | null; } declare enum IdentityType { UNKNOWN = "UNKNOWN", ANONYMOUS_VISITOR = "ANONYMOUS_VISITOR", MEMBER = "MEMBER", WIX_USER = "WIX_USER", APP = "APP" } interface IdentificationData extends IdentificationDataIdOneOf { /** * ID of a site visitor that has not logged in to the site. * @format GUID */ anonymousVisitorId?: string; /** * ID of a site visitor that has logged in to the site. * @format GUID */ memberId?: string; /** * ID of a Wix user (site owner, contributor, etc.). * @format GUID */ wixUserId?: string; /** * ID of an app. * @format GUID */ appId?: string; /** @readonly */ identityType?: IdentityType; } /** @oneof */ interface IdentificationDataIdOneOf { /** * ID of a site visitor that has not logged in to the site. * @format GUID */ anonymousVisitorId?: string; /** * ID of a site visitor that has logged in to the site. * @format GUID */ memberId?: string; /** * ID of a Wix user (site owner, contributor, etc.). * @format GUID */ wixUserId?: string; /** * ID of an app. * @format GUID */ appId?: string; } interface DecrementAvailabilityEnvelope { request: DecrementAvailabilityRequest; metadata: Context; } interface IncrementAvailabilityEnvelope { request: IncrementAvailabilityRequest; metadata: Context; } declare const provideHandlers: ServicePluginDefinition<{ /** * * Reduces the available stock quantity for specified items. * * Use this method when inventory needs to be decremented due to order events such as order placement or payment. The method supports validation to prevent negative inventory levels when `restrictInventoryValue` is set to true. */ decrementAvailability(payload: DecrementAvailabilityEnvelope): DecrementAvailabilityResponse | Promise; /** * * Increases the available stock quantity for specified items. * * Use this method when inventory needs to be incremented due to order events such as order cancellation, refund, or order editing. * This method does not validate stock levels and allows negative inventory to be corrected. */ incrementAvailability(payload: IncrementAvailabilityEnvelope): IncrementAvailabilityResponse | Promise; }>; /** * Cannot decrement availability due to insufficient stock or invalid request parameters. */ declare class DecrementNotPossibleWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; constructor(); /** @hidden */ static readonly __type = "wix_spi_error"; } /** * Cannot increment availability due to invalid request parameters. */ declare class IncrementNotPossibleWixError extends Error { /** @hidden */ httpCode: number; /** @hidden */ statusCode: string; /** @hidden */ applicationCode: string; /** @hidden */ name: string; /** @hidden */ errorType: string; /** @hidden */ spiErrorData: object; constructor(); /** @hidden */ static readonly __type = "wix_spi_error"; } export { type CatalogReference as C, type DecrementAvailabilityRequest as D, type Item as I, Reason as R, type DecrementAvailabilityResponse as a, type IncrementAvailabilityRequest as b, type IncrementAvailabilityResponse as c, type InventorySpiConfig as d, type Context as e, IdentityType as f, type IdentificationData as g, type IdentificationDataIdOneOf as h, DecrementNotPossibleWixError as i, IncrementNotPossibleWixError as j, type DecrementAvailabilityEnvelope as k, type IncrementAvailabilityEnvelope as l, provideHandlers as p };