import type { Square } from "square" import { defineSquareOperation } from "../lib" /** * Deletes a set of [CatalogItem](entity:CatalogItem)s based on the provided * list of target IDs and returns a set of successfully deleted IDs in the * response. */ export const batchSquareDeleteCatalogObjects = defineSquareOperation< Square.BatchDeleteCatalogObjectsRequest, Square.BatchDeleteCatalogObjectsResponse >({ allowedKeys: ["objectIds"], description: "Deletes a set of [CatalogItem](entity:CatalogItem)s based on the provided list of target IDs and returns a set of successfully deleted IDs in the response.", execute: (api, input) => api.catalog.batchDelete(input), name: "Batch Square Delete Catalog Objects", replaySafety: "unsafe", requiredKeys: ["objectIds"], scopes: ["ITEMS_WRITE"], }) /** Returns a set of objects based on the provided ID. */ export const batchRetrieveSquareCatalogObjects = defineSquareOperation< Square.BatchGetCatalogObjectsRequest, Square.BatchGetCatalogObjectsResponse >({ allowedKeys: [ "objectIds", "includeRelatedObjects", "catalogVersion", "includeDeletedObjects", "includeCategoryPathToRoot", "includeOptions", ], description: "Returns a set of objects based on the provided ID.", execute: (api, input) => api.catalog.batchGet(input), name: "Batch Square Retrieve Catalog Objects", replaySafety: "safe", requiredKeys: ["objectIds"], scopes: ["ITEMS_READ"], }) /** * Creates or updates up to 10,000 target objects based on the provided list of * objects. */ export const batchSquareUpsertCatalogObjects = defineSquareOperation< Square.BatchUpsertCatalogObjectsRequest, Square.BatchUpsertCatalogObjectsResponse >({ allowedKeys: ["idempotencyKey", "batches"], description: "Creates or updates up to 10,000 target objects based on the provided list of objects.", execute: (api, input) => api.catalog.batchUpsert(input), name: "Batch Square Upsert Catalog Objects", replaySafety: "safe", requiredKeys: ["idempotencyKey", "batches"], scopes: ["ITEMS_WRITE"], }) /** * Retrieves information about the Square Catalog API, such as batch size limits * that can be used by the `BatchUpsertCatalogObjects` endpoint. */ export const getSquareCatalogInfo = defineSquareOperation< Record, Square.CatalogInfoResponse >({ allowedKeys: [], description: "Retrieves information about the Square Catalog API, such as batch size limits that can be used by the `BatchUpsertCatalogObjects` endpoint.", execute: (api, _input) => api.catalog.info(), name: "Catalog Square Info", replaySafety: "safe", requiredKeys: [], scopes: ["ITEMS_READ"], }) /** * Uploads an image file to be represented by a * [CatalogImage](entity:CatalogImage) object that can be linked to an existing * [CatalogObject](entity:CatalogObject) instance. */ export const createSquareCatalogImage = defineSquareOperation< Square.catalog.CreateImagesRequest, Square.CreateCatalogImageResponse >({ allowedKeys: ["request", "imageFile"], description: "Uploads an image file to be represented by a [CatalogImage](entity:CatalogImage) object that can be linked to an existing [CatalogObject](entity:CatalogObject) instance.", execute: (api, input) => api.catalog.images.create(input), name: "Create Square Catalog Image", replaySafety: "unsafe", requiredKeys: [], scopes: ["ITEMS_WRITE"], }) /** * Deletes a single [CatalogObject](entity:CatalogObject) based on the provided * ID and returns the set of successfully deleted IDs in the response. */ export const deleteSquareCatalogObject = defineSquareOperation< Square.catalog.DeleteObjectRequest, Square.DeleteCatalogObjectResponse >({ allowedKeys: ["objectId"], description: "Deletes a single [CatalogObject](entity:CatalogObject) based on the provided ID and returns the set of successfully deleted IDs in the response.", execute: (api, input) => api.catalog.object.delete(input), name: "Delete Square Catalog Object", replaySafety: "safe", requiredKeys: ["objectId"], scopes: ["ITEMS_WRITE"], }) /** * Returns a list of all [CatalogObject](entity:CatalogObject)s of the specified * types in the catalog. */ export const listSquareCatalog = defineSquareOperation< Square.ListCatalogRequest, Square.ListCatalogResponse >({ allowedKeys: ["cursor", "types", "catalogVersion"], description: "Returns a list of all [CatalogObject](entity:CatalogObject)s of the specified types in the catalog.", execute: (api, input) => api.catalog.list(input), name: "List Square Catalog", replaySafety: "safe", requiredKeys: [], scopes: ["ITEMS_READ"], }) /** * Returns a single [CatalogItem](entity:CatalogItem) as a * [CatalogObject](entity:CatalogObject) based on the provided ID. */ export const retrieveSquareCatalogObject = defineSquareOperation< Square.catalog.GetObjectRequest, Square.GetCatalogObjectResponse >({ allowedKeys: [ "objectId", "includeRelatedObjects", "catalogVersion", "includeCategoryPathToRoot", ], description: "Returns a single [CatalogItem](entity:CatalogItem) as a [CatalogObject](entity:CatalogObject) based on the provided ID.", execute: (api, input) => api.catalog.object.get(input), name: "Retrieve Square Catalog Object", replaySafety: "safe", requiredKeys: ["objectId"], scopes: ["ITEMS_READ"], }) /** * Searches for catalog items or item variations by matching supported search * attribute values, including custom attribute values, against one or more of * the specified query filters. */ export const searchSquareCatalogItems = defineSquareOperation< Square.SearchCatalogItemsRequest, Square.SearchCatalogItemsResponse >({ allowedKeys: [ "textFilter", "categoryIds", "stockLevels", "enabledLocationIds", "cursor", "limit", "sortOrder", "productTypes", "customAttributeFilters", "archivedState", "includeOptions", ], description: "Searches for catalog items or item variations by matching supported search attribute values, including custom attribute values, against one or more of the specified query filters.", execute: (api, input) => api.catalog.searchItems(input), name: "Search Square Catalog Items", replaySafety: "safe", requiredKeys: [], scopes: ["ITEMS_READ"], }) /** * Searches for [CatalogObject](entity:CatalogObject) of any type by matching * supported search attribute values, excluding custom attribute values on items * or item variations, against one or more of the specified query filters. */ export const searchSquareCatalogObjects = defineSquareOperation< Square.SearchCatalogObjectsRequest, Square.SearchCatalogObjectsResponse >({ allowedKeys: [ "cursor", "objectTypes", "includeDeletedObjects", "includeRelatedObjects", "beginTime", "query", "limit", "includeCategoryPathToRoot", "includeOptions", ], description: "Searches for [CatalogObject](entity:CatalogObject) of any type by matching supported search attribute values, excluding custom attribute values on items or item variations, against one or more of the specified query filters.", execute: (api, input) => api.catalog.search(input), name: "Search Square Catalog Objects", replaySafety: "safe", requiredKeys: [], scopes: ["ITEMS_READ"], }) /** * Uploads a new image file to replace the existing one in the specified * [CatalogImage](entity:CatalogImage) object. */ export const updateSquareCatalogImage = defineSquareOperation< Square.catalog.UpdateImagesRequest, Square.UpdateCatalogImageResponse >({ allowedKeys: ["imageId", "request", "imageFile"], description: "Uploads a new image file to replace the existing one in the specified [CatalogImage](entity:CatalogImage) object.", execute: (api, input) => api.catalog.images.update(input), name: "Update Square Catalog Image", replaySafety: "safe", requiredKeys: ["imageId"], scopes: ["ITEMS_WRITE"], }) /** * Updates the [CatalogModifierList](entity:CatalogModifierList) objects that * apply to the targeted [CatalogItem](entity:CatalogItem) without having to * perform an upsert on the entire item. */ export const updateSquareItemModifierLists = defineSquareOperation< Square.UpdateItemModifierListsRequest, Square.UpdateItemModifierListsResponse >({ allowedKeys: ["itemIds", "modifierListsToEnable", "modifierListsToDisable"], description: "Updates the [CatalogModifierList](entity:CatalogModifierList) objects that apply to the targeted [CatalogItem](entity:CatalogItem) without having to perform an upsert on the entire item.", execute: (api, input) => api.catalog.updateItemModifierLists(input), name: "Update Square Item Modifier Lists", replaySafety: "unsafe", requiredKeys: ["itemIds"], scopes: ["ITEMS_WRITE"], }) /** * Updates the [CatalogTax](entity:CatalogTax) objects that apply to the * targeted [CatalogItem](entity:CatalogItem) without having to perform an * upsert on the entire item. */ export const updateSquareItemTaxes = defineSquareOperation< Square.UpdateItemTaxesRequest, Square.UpdateItemTaxesResponse >({ allowedKeys: ["itemIds", "taxesToEnable", "taxesToDisable"], description: "Updates the [CatalogTax](entity:CatalogTax) objects that apply to the targeted [CatalogItem](entity:CatalogItem) without having to perform an upsert on the entire item.", execute: (api, input) => api.catalog.updateItemTaxes(input), name: "Update Square Item Taxes", replaySafety: "unsafe", requiredKeys: ["itemIds"], scopes: ["ITEMS_WRITE"], }) /** Creates a new or updates the specified [CatalogObject](entity:CatalogObject). */ export const upsertSquareCatalogObject = defineSquareOperation< Square.catalog.UpsertCatalogObjectRequest, Square.UpsertCatalogObjectResponse >({ allowedKeys: ["idempotencyKey", "object"], description: "Creates a new or updates the specified [CatalogObject](entity:CatalogObject).", execute: (api, input) => api.catalog.object.upsert(input), name: "Upsert Square Catalog Object", replaySafety: "safe", requiredKeys: ["idempotencyKey", "object"], scopes: ["ITEMS_WRITE"], })