From 14efb2a420f279fa8cdfb072d5ebd4edff38c58b Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 22 Oct 2024 18:08:33 +0300 Subject: [PATCH] chore(js-sdk,types): add tsdocs for admin JS SDK methods [3/n] (#9712) --- .../core/js-sdk/src/admin/fulfillment-set.ts | 122 +++++++++ packages/core/js-sdk/src/admin/fulfillment.ts | 75 ++++++ .../core/js-sdk/src/admin/inventory-item.ts | 253 +++++++++++++++++- packages/core/js-sdk/src/admin/invite.ts | 180 ++++++++++++- packages/core/js-sdk/src/store/index.ts | 2 +- .../http/fulfillment-set/admin/entities.ts | 84 ++++++ .../http/fulfillment-set/admin/payloads.ts | 66 +++++ .../http/fulfillment-set/admin/responses.ts | 6 + .../src/http/fulfillment/admin/entitites.ts | 139 ++++++++++ .../src/http/fulfillment/admin/payloads.ts | 117 +++++++- .../src/http/fulfillment/admin/responses.ts | 3 + .../http/inventory-level/admin/entities.ts | 28 ++ .../http/inventory-level/admin/payloads.ts | 32 ++- .../src/http/inventory-level/admin/queries.ts | 4 + .../http/inventory-level/admin/responses.ts | 6 + .../src/http/inventory/admin/entities.ts | 85 +++++- .../src/http/inventory/admin/payloads.ts | 42 +++ .../types/src/http/inventory/admin/queries.ts | 40 +++ .../src/http/inventory/admin/responses.ts | 6 + .../types/src/http/invite/admin/entities.ts | 24 ++ .../types/src/http/invite/admin/payloads.ts | 16 ++ .../types/src/http/invite/admin/responses.ts | 12 + 22 files changed, 1327 insertions(+), 15 deletions(-) diff --git a/packages/core/js-sdk/src/admin/fulfillment-set.ts b/packages/core/js-sdk/src/admin/fulfillment-set.ts index a8769e97658fa..8014b1e12a643 100644 --- a/packages/core/js-sdk/src/admin/fulfillment-set.ts +++ b/packages/core/js-sdk/src/admin/fulfillment-set.ts @@ -14,6 +14,21 @@ export class FulfillmentSet { this.client = client } + /** + * This method deletes a fulfillment set. It sends a request to the + * [Delete Fulfillment Set](https://docs.medusajs.com/v2/api/admin#fulfillment-sets_deletefulfillmentsetsid) + * API route. + * + * @param id - The fulfillment set's ID. + * @param headers - Headers to pass in the request. + * @returns The deletion's details. + * + * @example + * sdk.admin.fulfillmentSet.delete("fset_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async delete(id: string, headers?: ClientHeaders) { return await this.client.fetch( `/admin/fulfillment-sets/${id}`, @@ -24,6 +39,29 @@ export class FulfillmentSet { ) } + /** + * This method adds a service zone to a fulfillment set. It uses the + * [Add Service Zone](https://docs.medusajs.com/v2/api/admin#fulfillment-sets_postfulfillmentsetsidservicezones) + * API route. + * + * @param id - The fulfillment set's ID. + * @param body - The service zone's details. + * @param query - Configure the fields to retrieve in the fulfillment set. + * @param headers - Headers to pass in the request. + * @returns The fulfillment set's details. + * + * @example + * sdk.admin.fulfillmentSet.createServiceZone("fset_123", { + * name: "Europe Service Zone", + * geo_zones: [{ + * type: "country", + * country_code: "us" + * }] + * }) + * .then(({ fulfillment_set }) => { + * console.log(fulfillment_set) + * }) + */ async createServiceZone( id: string, body: HttpTypes.AdminCreateFulfillmentSetServiceZone, @@ -41,6 +79,47 @@ export class FulfillmentSet { ) } + /** + * This method retrieves a fulfillment set's service zone's details. It sends a request to the + * [Get Service Zone](https://docs.medusajs.com/v2/api/admin#fulfillment-sets_getfulfillmentsetsidservicezoneszone_id) + * API route. + * + * @param fulfillmentSetId - The fulfillment set's ID. + * @param serviceZoneId - The service zone's ID. + * @param query - Configure the fields to retrieve in the service zone. + * @param headers - Headers to pass in the request. + * @returns The service zone's details. + * + * @example + * To retrieve a fulfillment set's service zone by its ID: + * + * ```ts + * sdk.admin.fulfillmentSet.retrieveServiceZone( + * "fset_123", + * "serzo_123" + * ) + * .then(({ service_zone }) => { + * console.log(service_zone) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.fulfillmentSet.retrieveServiceZone( + * "fset_123", + * "serzo_123", + * { + * fields: "id,*geo_zones" + * } + * ) + * .then(({ service_zone }) => { + * console.log(service_zone) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieveServiceZone( fulfillmentSetId: string, serviceZoneId: string, @@ -57,6 +136,30 @@ export class FulfillmentSet { ) } + /** + * This method updates a service zone in a fulfillment set. It sends a request to the + * [Update Service Zone](https://docs.medusajs.com/v2/api/admin#fulfillment-sets_postfulfillmentsetsidservicezoneszone_id) + * API route. + * + * @param fulfillmentSetId - The fulfillment set's ID. + * @param serviceZoneId - The service zone's ID. + * @param body - The data to update in the service zone. + * @param query - Configure the fields to retrieve in the fulfillment set. + * @param headers - Headers to pass in the request. + * @returns The fulfillment set's details. + * + * @example + * sdk.admin.fulfillmentSet.updateServiceZone( + * "fset_123", + * "serzo_123", + * { + * name: "Europe Service Zone", + * } + * ) + * .then(({ fulfillment_set }) => { + * console.log(fulfillment_set) + * }) + */ async updateServiceZone( fulfillmentSetId: string, serviceZoneId: string, @@ -75,6 +178,25 @@ export class FulfillmentSet { ) } + /** + * This method deletes a service zone in a fulfillment set. It sends a request to the + * [Remove Service Zone](https://docs.medusajs.com/v2/api/admin#fulfillment-sets_deletefulfillmentsetsidservicezoneszone_id) + * API route. + * + * @param fulfillmentSetId - The fulfullment set's ID. + * @param serviceZoneId - The service zone's ID. + * @param headers - Headers to pass in the request. + * @returns The deletion's details. + * + * @example + * sdk.admin.fulfillmentSet.deleteServiceZone( + * "fset_123", + * "serzo_123", + * ) + * .then(({ deleted, parent: fulfillmentSet }) => { + * console.log(deleted, fulfillmentSet) + * }) + */ async deleteServiceZone( fulfillmentSetId: string, serviceZoneId: string, diff --git a/packages/core/js-sdk/src/admin/fulfillment.ts b/packages/core/js-sdk/src/admin/fulfillment.ts index eab1d0817d2f0..565fcf7dc054b 100644 --- a/packages/core/js-sdk/src/admin/fulfillment.ts +++ b/packages/core/js-sdk/src/admin/fulfillment.ts @@ -14,6 +14,39 @@ export class Fulfillment { this.client = client } + /** + * This method creates a fulfillment. It sends a request to the + * [Create Fulfillment](https://docs.medusajs.com/v2/api/admin#fulfillments_postfulfillments) + * API route. + * + * @param body - The fulfillment's details. + * @param query - Configure the fields to retrieve in the fulfillment. + * @param headers - Headers to pass in the request. + * @returns The fulfillment's details. + * + * @example + * sdk.admin.fulfillment.create({ + * location_id: "sloc_123", + * provider_id: "my_fulfillment", + * delivery_address: { + * country_code: "us" + * }, + * items: [ + * { + * title: "Shirt", + * sku: "SHIRT", + * quantity: 1, + * barcode: "123" + * } + * ], + * labels: [], + * order: {}, + * order_id: "order_123" + * }) + * .then(({ fulfillment }) => { + * console.log(fulfillment) + * }) + */ async create( body: HttpTypes.AdminCreateFulfillment, query?: HttpTypes.SelectParams, @@ -30,6 +63,22 @@ export class Fulfillment { ) } + /** + * This method cancels a fulfillment. It sends a request to the + * [Cancel Fulfillment](https://docs.medusajs.com/v2/api/admin#fulfillments_postfulfillmentsidcancel) + * API route. + * + * @param id - The fulfillment's ID. + * @param query - Configure the fields to retrieve in the fulfillment. + * @param headers - Headers to pass in the request. + * @returns The fulfillment's details. + * + * @example + * sdk.admin.fulfillment.cancel("ful_123") + * .then(({ fulfillment }) => { + * console.log(fulfillment) + * }) + */ async cancel( id: string, query?: HttpTypes.SelectParams, @@ -41,10 +90,36 @@ export class Fulfillment { method: "POST", body: {}, headers, + query } ) } + /** + * This method creates a shipment for a fulfillment. It sends a request to the + * [Create Shipment](https://docs.medusajs.com/v2/api/admin#fulfillments_postfulfillmentsidshipment) + * API route. + * + * @param id - The fulfillment's ID. + * @param body - The shipment's details. + * @param query - Configure the fields to retrieve in the fulfillment. + * @param headers - Headers to pass in the request. + * @returns The fulfillment's details. + * + * @example + * sdk.admin.fulfillment.createShipment("ful_123", { + * labels: [ + * { + * tracking_number: "123", + * tracking_url: "example.com", + * label_url: "example.com" + * } + * ] + * }) + * .then(({ fulfillment }) => { + * console.log(fulfillment) + * }) + */ async createShipment( id: string, body: HttpTypes.AdminCreateFulfillmentShipment, diff --git a/packages/core/js-sdk/src/admin/inventory-item.ts b/packages/core/js-sdk/src/admin/inventory-item.ts index d4a06ad028630..accc273bef7ac 100644 --- a/packages/core/js-sdk/src/admin/inventory-item.ts +++ b/packages/core/js-sdk/src/admin/inventory-item.ts @@ -14,6 +14,24 @@ export class InventoryItem { this.client = client } + /** + * This method creates an inventory item. It sends a request to the + * [Create Inventory Item](https://docs.medusajs.com/v2/api/admin#inventory-items_postinventoryitems) + * API route. + * + * @param body - The inventory item's details. + * @param query - Configure the fields to retrieve in the inventory item. + * @param headers - Headers to pass in the request. + * @returns The inventory item's details. + * + * @example + * sdk.admin.inventoryItem.create({ + * sku: "SHIRT" + * }) + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + */ async create( body: HttpTypes.AdminCreateInventoryItem, query?: HttpTypes.SelectParams, @@ -30,6 +48,25 @@ export class InventoryItem { ) } + /** + * This method updates an inventory level. It sends a request to the + * [Update Inventory Item](https://docs.medusajs.com/v2/api/admin#inventory-items_postinventoryitemsid) + * API route. + * + * @param id - The inventory item's ID. + * @param body - The data to update. + * @param query - Configure the fields to retrieve in the inventory item. + * @param headers - Headers to pass in the request. + * @returns The inventory item's details. + * + * @example + * sdk.admin.inventoryItem.update("iitem_123", { + * sku: "SHIRT" + * }) + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + */ async update( id: string, body: HttpTypes.AdminUpdateInventoryItem, @@ -47,6 +84,53 @@ export class InventoryItem { ) } + /** + * This method retrieves a paginated list of inventory items. It sends a request to the + * [List Inventory Items](https://docs.medusajs.com/v2/api/admin#inventory-items_getinventoryitems) + * API route. + * + * @param query - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of inventory items. + * + * @example + * To retrieve the list of inventory items: + * + * ```ts + * sdk.admin.inventoryItem.list() + * .then(({ inventory_items, count, limit, offset }) => { + * console.log(inventory_items) + * }) + * ``` + * + * To configure the pagination, pass the `limit` and `offset` query parameters. + * + * For example, to retrieve only 10 items and skip 10 items: + * + * ```ts + * sdk.admin.inventoryItem.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ inventory_items, count, limit, offset }) => { + * console.log(inventory_items) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each inventory item: + * + * ```ts + * sdk.admin.inventoryItem.list({ + * fields: "id,*location_levels" + * }) + * .then(({ inventory_items, count, limit, offset }) => { + * console.log(inventory_items) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list( query?: HttpTypes.AdminInventoryItemParams, headers?: ClientHeaders @@ -60,6 +144,38 @@ export class InventoryItem { ) } + /** + * This method retrieves an inventory item by its ID. It sends a request to the + * [Get Inventory Item](https://docs.medusajs.com/v2/api/admin#inventory-items_getinventoryitemsid) API route. + * + * @param id - The inventory item's ID. + * @param query - Configure the fields to retrieve in the inventory item. + * @param headers - Headers to pass in the request + * @returns The inventory item's details. + * + * @example + * To retrieve an inventory item by its ID: + * + * ```ts + * sdk.admin.inventoryItem.retrieve("iitem_123") + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.inventoryItem.retrieve("iitem_123", { + * fields: "id,*location_levels" + * }) + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) { return await this.client.fetch( `/admin/inventory-items/${id}`, @@ -70,6 +186,21 @@ export class InventoryItem { ) } + /** + * This method deletes an inventory item. This sends a request to the + * [Delete Inventory Item](https://docs.medusajs.com/v2/api/admin#inventory-items_deleteinventoryitemsid) + * API route. + * + * @param id - The inventory item's ID. + * @param headers - Headers to pass in the request + * @returns The deletion's details. + * + * @example + * sdk.admin.inventoryItem.delete("iitem_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async delete(id: string, headers?: ClientHeaders) { return await this.client.fetch( `/admin/inventory-items/${id}`, @@ -80,6 +211,54 @@ export class InventoryItem { ) } + /** + * This method retrieves a paginated list of inventory levels that belong to an inventory item. + * It sends a request to the [List Inventory Items](https://docs.medusajs.com/v2/api/admin#inventory-items_getinventoryitems) + * API route. + * + * @param id - The inventory item's ID. + * @param query - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of inventory levels. + * + * @example + * To retrieve the list of inventory levels: + * + * ```ts + * sdk.admin.inventoryItem.listLevels("iitem_123") + * .then(({ inventory_levels, count, limit, offset }) => { + * console.log(inventory_levels) + * }) + * ``` + * + * To configure the pagination, pass the `limit` and `offset` query parameters. + * + * For example, to retrieve only 10 items and skip 10 items: + * + * ```ts + * sdk.admin.inventoryItem.listLevels("iitem_123", { + * limit: 10, + * offset: 10 + * }) + * .then(({ inventory_levels, count, limit, offset }) => { + * console.log(inventory_levels) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each inventory level: + * + * ```ts + * sdk.admin.inventoryItem.listLevels("iitem_123", { + * fields: "id,*inventory_item" + * }) + * .then(({ inventory_levels, count, limit, offset }) => { + * console.log(inventory_levels) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async listLevels( id: string, query?: HttpTypes.AdminInventoryLevelFilters, @@ -94,6 +273,33 @@ export class InventoryItem { ) } + /** + * This method updates the inventory level of the specified inventory item and + * stock location. + * + * This method sends a request to the + * [Update Inventory Level](https://docs.medusajs.com/v2/api/admin#inventory-items_postinventoryitemsidlocationlevelslocation_id) + * API route. + * + * @param id - The inventory item's ID. + * @param locationId - The stock location's ID. + * @param body - The details to update. + * @param query - Configure the fields to retrieve in the inventory item. + * @param headers - Headers to pass in the request + * @returns The inventory item's details. + * + * @example + * sdk.admin.inventoryItem.updateLevel( + * "iitem_123", + * "sloc_123", + * { + * stocked_quantity: 10 + * } + * ) + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + */ async updateLevel( id: string, locationId: string, @@ -112,8 +318,30 @@ export class InventoryItem { ) } + /** + * This method deletes an inventory level associated with an inventory item + * and a stock location. + * + * This method sends a request to the + * [Remove Inventory Level](https://docs.medusajs.com/v2/api/admin#inventory-items_deleteinventoryitemsidlocationlevelslocation_id) + * API route. + * + * @param id - The inventory item's ID. + * @param locationId - The stock location's ID. + * @param headers - Headers to pass in the request + * @returns The deletion's details. + * + * @example + * sdk.admin.inventoryItem.deleteLevel( + * "iitem_123", + * "sloc_123", + * ) + * .then(({ deleted, parent: inventoryItem }) => { + * console.log(deleted, inventoryItem) + * }) + */ async deleteLevel(id: string, locationId: string, headers?: ClientHeaders) { - return await this.client.fetch( + return await this.client.fetch( `/admin/inventory-items/${id}/location-levels/${locationId}`, { method: "DELETE", @@ -122,6 +350,29 @@ export class InventoryItem { ) } + /** + * This method manages the inventory levels of an inventory item. It sends a request to the + * [Manage Inventory Levels](https://docs.medusajs.com/v2/api/admin#inventory-items_postinventoryitemsidlocationlevelsbatch) + * API route. + * + * @param id - The inventory item's ID. + * @param body - The inventory levels to create or delete. + * @param query - Configure the fields to retrieve in the inventory item. + * @param headers - Headers to pass in the request + * @returns The inventory item's details. + * + * @example + * sdk.admin.inventoryItem.batchUpdateLevels("iitem_123", { + * create: [{ + * location_id: "sloc_123", + * stocked_quantity: 10 + * }], + * delete: ["sloc_123"] + * }) + * .then(({ inventory_item }) => { + * console.log(inventory_item) + * }) + */ async batchUpdateLevels( id: string, body: HttpTypes.AdminBatchUpdateInventoryLevelLocation, diff --git a/packages/core/js-sdk/src/admin/invite.ts b/packages/core/js-sdk/src/admin/invite.ts index 345556c4f9a56..d9f0ad566bc44 100644 --- a/packages/core/js-sdk/src/admin/invite.ts +++ b/packages/core/js-sdk/src/admin/invite.ts @@ -1,7 +1,6 @@ import { FindParams, HttpTypes, - PaginatedResponse, SelectParams, } from "@medusajs/types" import { Client } from "../client" @@ -19,13 +18,52 @@ export class Invite { this.client = client } + /** + * This method accepts an invite. It requires sending a previous request to + * the {@link Auth.register}. + * + * This method sends a request to the [Accept Invite] + * (https://docs.medusajs.com/v2/api/admin#invites_postinvitesaccept) + * API route. + * + * @param input - The details of the user to create. + * @param query - Configure the fields to retrieve in the user. + * @param headers - Headers to pass in the request + * @returns The user's details. + * + * @example + * const token = await sdk.auth.register("user", "emailpass", { + * email: "user@gmail.com", + * password: "supersecret" + * }) + * + * sdk.admin.invite.accept( + * { + * email: "user@gmail.com", + * first_name: "John", + * last_name: "Smith", + * invite_token: "12345..." + * }, + * { + * Authorization: `Bearer ${token}` + * } + * ) + * .then(({ user }) => { + * console.log(user) + * }) + */ async accept( - input: HttpTypes.AdminAcceptInvite & { invite_token: string }, + input: HttpTypes.AdminAcceptInvite & { + /** + * The invite's token. + */ + invite_token: string + }, query?: SelectParams, headers?: ClientHeaders ) { const { invite_token, ...rest } = input - return await this.client.fetch<{ user: HttpTypes.AdminUserResponse }>( + return await this.client.fetch( `/admin/invites/accept?token=${input.invite_token}`, { method: "POST", @@ -36,12 +74,30 @@ export class Invite { ) } + /** + * This method creates an invite. It sends a request to the + * [Create Invite](https://docs.medusajs.com/v2/api/admin#invites_postinvites) + * API route. + * + * @param body - The invite's details. + * @param query - Configure the fields to retrieve in the invite. + * @param headers - Headers to pass in the request + * @returns The invite's details. + * + * @example + * sdk.admin.invite.create({ + * email: "user@gmail.com", + * }) + * .then(({ invite }) => { + * console.log(invite) + * }) + */ async create( body: HttpTypes.AdminCreateInvite, query?: SelectParams, headers?: ClientHeaders ) { - return await this.client.fetch<{ invite: HttpTypes.AdminInviteResponse }>( + return await this.client.fetch( `/admin/invites`, { method: "POST", @@ -52,8 +108,41 @@ export class Invite { ) } + /** + * This method retrieves an invite by its ID. It sends a request to the + * [Get Invite](https://docs.medusajs.com/v2/api/admin#invites_getinvitesid) + * API route. + * + * @param id - The invite's ID. + * @param query - Configure the fields to retrieve in the invite. + * @param headers - Headers to pass in the request + * @returns The invite's details. + * + * @example + * To retrieve an invite its ID: + * + * ```ts + * sdk.admin.invite.retrieve("invite_123") + * .then(({ invite }) => { + * console.log(invite) + * }) + * ``` + * + * To specify the fields and relations to retrieve: + * + * ```ts + * sdk.admin.invite.retrieve("invite_123", { + * fields: "id,email" + * }) + * .then(({ invite }) => { + * console.log(invite) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) { - return await this.client.fetch<{ invite: HttpTypes.AdminInviteResponse }>( + return await this.client.fetch( `/admin/invites/${id}`, { headers, @@ -62,17 +151,79 @@ export class Invite { ) } + /** + * This method retrieves a paginated list of invites. It sends a request to the + * [List Invites](https://docs.medusajs.com/v2/api/admin#invites_getinvites) + * API route. + * + * @param queryParams - Filters and pagination configurations. + * @param headers - Headers to pass in the request. + * @returns The paginated list of invites. + * + * @example + * To retrieve the list of invites: + * + * ```ts + * sdk.admin.invite.list() + * .then(({ invites, count, limit, offset }) => { + * console.log(invites) + * }) + * ``` + * + * To configure the pagination, pass the `limit` and `offset` query parameters. + * + * For example, to retrieve only 10 items and skip 10 items: + * + * ```ts + * sdk.admin.invite.list({ + * limit: 10, + * offset: 10 + * }) + * .then(({ invites, count, limit, offset }) => { + * console.log(invites) + * }) + * ``` + * + * Using the `fields` query parameter, you can specify the fields and relations to retrieve + * in each invite: + * + * ```ts + * sdk.admin.invite.list({ + * fields: "id,email" + * }) + * .then(({ invites, count, limit, offset }) => { + * console.log(invites) + * }) + * ``` + * + * Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/v2/api/store#select-fields-and-relations). + */ async list(queryParams?: FindParams, headers?: ClientHeaders) { return await this.client.fetch< - PaginatedResponse<{ invites: HttpTypes.AdminInviteResponse[] }> + HttpTypes.AdminInviteListResponse >(`/admin/invites`, { headers, query: queryParams, }) } + /** + * This method refreshes the token of an invite. It sends a request to the + * [Refresh Invite Token](https://docs.medusajs.com/v2/api/admin#invites_postinvitesidresend) + * API route. + * + * @param id - The invite's ID. + * @param headers - Headers to pass in the request. + * @returns The invite's details. + * + * @example + * sdk.admin.invite.resend("invite_123") + * .then(({ invite }) => { + * console.log(invite) + * }) + */ async resend(id: string, headers?: ClientHeaders) { - return await this.client.fetch<{ invite: HttpTypes.AdminInviteResponse }>( + return await this.client.fetch( `/admin/invites/${id}/resend`, { method: "POST", @@ -81,6 +232,21 @@ export class Invite { ) } + /** + * This method deletes an invite. It sends a request to the + * [Delete Invite](https://docs.medusajs.com/v2/api/admin#invites_deleteinvitesid) + * API route. + * + * @param id - The invite's ID. + * @param headers - Headers to pass in the request. + * @returns The deletion's details. + * + * @example + * sdk.admin.invite.delete("invite_123") + * .then(({ deleted }) => { + * console.log(deleted) + * }) + */ async delete(id: string, headers?: ClientHeaders) { return await this.client.fetch( `/admin/invites/${id}`, diff --git a/packages/core/js-sdk/src/store/index.ts b/packages/core/js-sdk/src/store/index.ts index 6fd743da3aa2d..3eb35f1225fd4 100644 --- a/packages/core/js-sdk/src/store/index.ts +++ b/packages/core/js-sdk/src/store/index.ts @@ -1071,7 +1071,7 @@ export class Store { * }, * {}, * { - * authorization: `Bearer ${token}` + * Authorization: `Bearer ${token}` * } * ) * .then(({ customer }) => { diff --git a/packages/core/types/src/http/fulfillment-set/admin/entities.ts b/packages/core/types/src/http/fulfillment-set/admin/entities.ts index b06b7c18f1444..a4b28d97c26a8 100644 --- a/packages/core/types/src/http/fulfillment-set/admin/entities.ts +++ b/packages/core/types/src/http/fulfillment-set/admin/entities.ts @@ -3,36 +3,120 @@ import { AdminShippingOption } from "../../shipping-option" import { AdminStockLocation } from "../../stock-locations" export interface AdminGeoZone { + /** + * The geo zone's ID. + */ id: string + /** + * The geo zone's type. + */ type: GeoZoneType + /** + * The geo zone's country code. + * + * @example + * us + */ country_code: string + /** + * The geo zone's province code. + */ province_code: string | null + /** + * The geo zone's city. + */ city: string | null + /** + * The geo zone's postal expression. + */ postal_expression: Record | null + /** + * The date the geo zone was created. + */ created_at: string + /** + * The date the geo zone was updated. + */ updated_at: string + /** + * The date the geo zone was deleted. + */ deleted_at: string | null } export interface AdminServiceZone { + /** + * The service zone's ID. + */ id: string + /** + * The service zone's name. + */ name: string + /** + * The ID of the fulfillment set this service zone belongs to. + */ fulfillment_set_id: string + /** + * The fulfillment set this service zone belongs to. + */ fulfillment_set: AdminFulfillmentSet + /** + * The service zone's geo zones. + */ geo_zones: AdminGeoZone[] + /** + * The shipping options that can be used in this service zone. + */ shipping_options: AdminShippingOption[] + /** + * The date the service zone is created. + */ created_at: string + /** + * The date the service zone is updated. + */ updated_at: string + /** + * The date the service zone is deleted. + */ deleted_at: string | null } export interface AdminFulfillmentSet { + /** + * The fulfillment set's ID. + */ id: string + /** + * The fulfillment set's name. + */ name: string + /** + * The fulfillment set's type. + * + * @example + * delivery + */ type: string + /** + * The stock location associated with this fulfillment set. + */ location: AdminStockLocation + /** + * The fulfillment set's service zones. + */ service_zones: AdminServiceZone[] + /** + * The date the fulfillment set is created. + */ created_at: string + /** + * The date the fulfillment set is updated. + */ updated_at: string + /** + * The date the fulfillment set is deleted. + */ deleted_at: string | null } diff --git a/packages/core/types/src/http/fulfillment-set/admin/payloads.ts b/packages/core/types/src/http/fulfillment-set/admin/payloads.ts index a3a0a84d84279..f93f9706cb46b 100644 --- a/packages/core/types/src/http/fulfillment-set/admin/payloads.ts +++ b/packages/core/types/src/http/fulfillment-set/admin/payloads.ts @@ -1,6 +1,18 @@ interface AdminUpsertGeoZone { + /** + * The geo zone's type. + */ type: string + /** + * The geo zone's country code. + * + * @example + * us + */ country_code: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } @@ -12,19 +24,37 @@ interface AdminUpsertFulfillmentSetServiceZoneCountry interface AdminUpsertFulfillmentSetServiceZoneProvince extends AdminUpsertGeoZone { type: "province" + /** + * The geo zone's province code. + */ province_code: string } interface AdminUpsertFulfillmentSetServiceZoneCity extends AdminUpsertGeoZone { type: "city" + /** + * The geo zone's province code. + */ province_code: string + /** + * The geo zone's city. + */ city: string } interface AdminUpsertFulfillmentSetServiceZoneZip extends AdminUpsertGeoZone { type: "zip" + /** + * The geo zone's province code. + */ province_code: string + /** + * The geo zone's city. + */ city: string + /** + * The geo zone's postal expression or ZIP code. + */ postal_expression: Record } @@ -35,11 +65,21 @@ type AdminUpsertFulfillmentSetServiceZoneGeoZone = | AdminUpsertFulfillmentSetServiceZoneZip export interface AdminCreateFulfillmentSetServiceZone { + /** + * The service zone's name. + */ name: string + /** + * The service zone's geo zones to restrict it to + * specific geographical locations. + */ geo_zones: AdminUpsertFulfillmentSetServiceZoneGeoZone[] } interface AdminUpdateGeoZone extends AdminUpsertGeoZone { + /** + * The ID of the geo zone to update. + */ id?: string } @@ -51,19 +91,37 @@ interface AdminUpdateFulfillmentSetServiceZoneCountry interface AdminUpdateFulfillmentSetServiceZoneProvince extends AdminUpdateGeoZone { type: "province" + /** + * The geo zone's province code. + */ province_code: string } interface AdminUpdateFulfillmentSetServiceZoneCity extends AdminUpdateGeoZone { type: "city" + /** + * The geo zone's province code. + */ province_code: string + /** + * The geo zone's city. + */ city: string } interface AdminUpdateFulfillmentSetServiceZoneZip extends AdminUpdateGeoZone { type: "zip" + /** + * The geo zone's province code. + */ province_code: string + /** + * The geo zone's city. + */ city: string + /** + * The geo zone's postal expression or ZIP code. + */ postal_expression: Record } @@ -74,6 +132,14 @@ type AdminUpdateFulfillmentSetServiceZoneGeoZone = | AdminUpdateFulfillmentSetServiceZoneZip export interface AdminUpdateFulfillmentSetServiceZone { + /** + * The service zone's name. + */ name?: string + /** + * The service zone's geo zones to restrict it to + * specific geographical locations. You can update + * existing ones by their IDs or add new ones. + */ geo_zones?: AdminUpdateFulfillmentSetServiceZoneGeoZone[] } diff --git a/packages/core/types/src/http/fulfillment-set/admin/responses.ts b/packages/core/types/src/http/fulfillment-set/admin/responses.ts index 5d1e62384f951..a52b6be41e269 100644 --- a/packages/core/types/src/http/fulfillment-set/admin/responses.ts +++ b/packages/core/types/src/http/fulfillment-set/admin/responses.ts @@ -2,6 +2,9 @@ import { DeleteResponse, DeleteResponseWithParent } from "../../common" import { AdminFulfillmentSet, AdminServiceZone } from "./entities" export interface AdminServiceZoneResponse { + /** + * The service zone's details. + */ service_zone: AdminServiceZone } @@ -9,6 +12,9 @@ export interface AdminServiceZoneDeleteResponse extends DeleteResponseWithParent<"service_zone", AdminFulfillmentSet> {} export interface AdminFulfillmentSetResponse { + /** + * The fulfillment set's details. + */ fulfillment_set: AdminFulfillmentSet } diff --git a/packages/core/types/src/http/fulfillment/admin/entitites.ts b/packages/core/types/src/http/fulfillment/admin/entitites.ts index 2f0efaf577b45..460d58d41067a 100644 --- a/packages/core/types/src/http/fulfillment/admin/entitites.ts +++ b/packages/core/types/src/http/fulfillment/admin/entitites.ts @@ -1,16 +1,49 @@ import { AdminFulfillmentProvider } from "../../fulfillment-provider" export interface AdminFulfillmentItem { + /** + * The fulfillment item's ID. + */ id: string + /** + * The fulfillment item's title. + */ title: string + /** + * The fulfillment item's quantity. + */ quantity: number + /** + * The fulfillment item's SKU. + */ sku: string + /** + * The fulfillment item's barcode. + */ barcode: string + /** + * The ID of the associated line item in an order. + */ line_item_id: string | null + /** + * The ID of the associated inventory item. + */ inventory_item_id: string | null + /** + * The ID of the fulfillment that the item belongs to. + */ fulfillment_id: string + /** + * The date the fulfillment item was created. + */ created_at: string + /** + * The date the fulfillment item was updated. + */ updated_at: string + /** + * The date the fulfillment item was deleted. + */ deleted_at: string | null } @@ -26,40 +59,146 @@ export interface AdminFulfillmentLabel { } export interface AdminFulfillmentAddress { + /** + * The address's ID. + */ id: string + /** + * The ID of the fulfillment this address belongs to. + */ fulfillment_id: string | null + /** + * The address's company. + */ company: string | null + /** + * The address's first name. + */ first_name: string | null + /** + * The address's last name. + */ last_name: string | null + /** + * The address's first line. + */ address_1: string | null + /** + * The address's last line. + */ address_2: string | null + /** + * The address's city. + */ city: string | null + /** + * The address's country code. + * + * @example + * us + */ country_code: string | null + /** + * The address's province. + */ province: string | null + /** + * The address's postal code. + */ postal_code: string | null + /** + * The address's phone number. + */ phone: string | null + /** + * Key-value pairs of custom data. + */ metadata: Record | null + /** + * The date the address was created. + */ created_at: string + /** + * The date the address was updated. + */ updated_at: string + /** + * The date the address was deleted. + */ deleted_at: string | null } export interface AdminFulfillment { + /** + * The fulfillment's ID. + */ id: string + /** + * The ID of the stock location the items + * are delivered from. + */ location_id: string + /** + * The ID of the fulfillment provider + * handling the fulfillment. + */ provider_id: string + /** + * The ID of the associated shipping option. + */ shipping_option_id: string | null + /** + * The associated fulfillment provider's details. + */ provider: AdminFulfillmentProvider + /** + * The address to deliver the items to. + */ delivery_address: AdminFulfillmentAddress + /** + * The items to fulfill. + */ items: AdminFulfillmentItem[] + /** + * The fulfillment's labels. + */ labels: AdminFulfillmentLabel[] + /** + * The date the fulfillment items were packed. + */ packed_at: string | null + /** + * The date the fulfillment items were shipped. + */ shipped_at: string | null + /** + * The date the fulfillment items were delivered. + */ delivered_at: string | null + /** + * The date the fulfillment was canceled. + */ canceled_at: string | null + /** + * Data useful for the fulfillment provider handling the fulfillment. + * + * Learn more in [this documentation](https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment#data-property). + */ data: Record | null + /** + * Key-value pairs of custom data. + */ metadata: Record | null + /** + * The date the fulfillment was created. + */ created_at: string + /** + * The date the fulfillment was updated. + */ updated_at: string + /** + * The date the fulfillment was deleted. + */ deleted_at: string | null } diff --git a/packages/core/types/src/http/fulfillment/admin/payloads.ts b/packages/core/types/src/http/fulfillment/admin/payloads.ts index f39d3da09dc63..efc6d532143e0 100644 --- a/packages/core/types/src/http/fulfillment/admin/payloads.ts +++ b/packages/core/types/src/http/fulfillment/admin/payloads.ts @@ -1,46 +1,155 @@ interface AdminCreateFulfillmentItem { + /** + * The item's name. + */ title: string + /** + * The item's SKU. + */ sku: string + /** + * The item's quantity. + */ quantity: number + /** + * The item's barcode. + */ barcode: string + /** + * The ID of the associated line item in an order. + */ line_item_id?: string + /** + * The ID of the associated inventory item. + */ inventory_item_id?: string } interface AdminCreateFulfillmentLabel { + /** + * The tracking number of the fulfillment's shipment. + */ tracking_number: string + /** + * The tracking URL of the fulfillment's shipment. + */ tracking_url: string + /** + * The label URL of the fulfillment's shipment. + */ label_url: string } interface AdminFulfillmentDeliveryAddress { + /** + * The address's first name. + */ first_name?: string + /** + * The address's last name. + */ last_name?: string + /** + * The address's phone number. + */ phone?: string + /** + * The address's company. + */ company?: string + /** + * The address's first line. + */ address_1?: string + /** + * The address's second line. + */ address_2?: string + /** + * The address's city. + */ city?: string + /** + * The address's country code. + * + * @example + * us + */ country_code?: string + /** + * The address's province. + */ province?: string + /** + * The address's postal code. + */ postal_code?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } export interface AdminCreateFulfillment { + /** + * The ID of the location the items are fulfilled from. + */ location_id: string + /** + * The ID of the fulfillment provider used to handle the fulfillment. + */ provider_id: string + /** + * The address to deliver items to. + */ delivery_address: AdminFulfillmentDeliveryAddress + /** + * The items to fulfill. + */ items: AdminCreateFulfillmentItem[] + /** + * The fulfillment's shipment labels. + */ labels: AdminCreateFulfillmentLabel[] - // TODO: Validator requires an empty object for the order field. - // This is a temporary solution until the order field is - // removed or typed correctly. - order: Record + /** + * The ID of the order the fulfillment is created for. + */ order_id: string + /** + * The ID of the associated shipping option. + */ + shipping_option_id?: string | null + /** + * Data useful for the fulfillment provider handling the fulfillment. + * + * Learn more in [this documentation](https://docs.medusajs.com/v2/resources/commerce-modules/fulfillment#data-property). + */ + data?: Record | null + /** + * The date the fulfillment items were packed. + */ + packed_at?: Date | null + /** + * The date the fulfillment items were shipped. + */ + shipped_at?: Date | null + /** + * The date the fulfillment items were delivered. + */ + delivered_at?: Date | null + /** + * The date the fulfillment was canceled. + */ + canceled_at?: Date | null + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } export interface AdminCreateFulfillmentShipment { + /** + * The shipment's labels. + */ labels: AdminCreateFulfillmentLabel[] } diff --git a/packages/core/types/src/http/fulfillment/admin/responses.ts b/packages/core/types/src/http/fulfillment/admin/responses.ts index a997cd4c2f5d1..e3f192296b080 100644 --- a/packages/core/types/src/http/fulfillment/admin/responses.ts +++ b/packages/core/types/src/http/fulfillment/admin/responses.ts @@ -1,5 +1,8 @@ import { AdminFulfillment } from "./entitites" export interface AdminFulfillmentResponse { + /** + * The fulfillment's details. + */ fulfillment: AdminFulfillment } diff --git a/packages/core/types/src/http/inventory-level/admin/entities.ts b/packages/core/types/src/http/inventory-level/admin/entities.ts index 21848d435a3c0..82c5933c83e08 100644 --- a/packages/core/types/src/http/inventory-level/admin/entities.ts +++ b/packages/core/types/src/http/inventory-level/admin/entities.ts @@ -1,10 +1,38 @@ export interface InventoryLevel { + /** + * The inventory level's ID. + */ id: string + /** + * The ID of the associated inventory item. + */ inventory_item_id: string + /** + * The ID of the associated stock location + */ location_id: string + /** + * The associated inventory item's stocked quantity in the + * associated stock location. + */ stocked_quantity: number + /** + * The associated inventory item's reserved quantity in the + * associated stock location. + */ reserved_quantity: number + /** + * The associated inventory item's available quantity in the + * associated stock location. + */ available_quantity: number + /** + * The associated inventory item's incoming quantity in the + * associated stock location. + */ incoming_quantity: number + /** + * Key-value pairs of custom data. + */ metadata?: Record | null } diff --git a/packages/core/types/src/http/inventory-level/admin/payloads.ts b/packages/core/types/src/http/inventory-level/admin/payloads.ts index f65b3494216f2..eb576aa29655e 100644 --- a/packages/core/types/src/http/inventory-level/admin/payloads.ts +++ b/packages/core/types/src/http/inventory-level/admin/payloads.ts @@ -1,16 +1,46 @@ export interface AdminUpdateInventoryLevel { + /** + * The associated inventory item's stocked quantity in the + * associated stock location. + */ stocked_quantity?: number + /** + * The associated inventory item's incoming quantity in the + * associated stock location. + */ incoming_quantity?: number } export interface AdminCreateInventoryLevel { + /** + * The ID of the associated stock location. + */ location_id: string + /** + * The associated inventory item's stocked quantity in the + * associated stock location. + */ stocked_quantity?: number + /** + * The associated inventory item's incoming quantity in the + * associated stock location. + */ incoming_quantity?: number } export interface AdminBatchUpdateInventoryLevelLocation { - delete?: string[] // a list of location_ids + /** + * A list of location IDs to + * delete their associated inventory + * levels of the inventory item. + */ + delete?: string[] + /** + * @ignore + */ update?: never // TODO - not implemented // AdminUpdateInventoryLevel[] + /** + * A list of inventory levels to create. + */ create?: AdminCreateInventoryLevel[] } diff --git a/packages/core/types/src/http/inventory-level/admin/queries.ts b/packages/core/types/src/http/inventory-level/admin/queries.ts index 93214e5192468..5f75f4814cdd6 100644 --- a/packages/core/types/src/http/inventory-level/admin/queries.ts +++ b/packages/core/types/src/http/inventory-level/admin/queries.ts @@ -1,5 +1,9 @@ import { FindParams } from "../../common" export interface AdminInventoryLevelFilters extends FindParams { + /** + * Filter by stock location IDs to retrieve their + * associated inventory levels. + */ location_id?: string | string[] } diff --git a/packages/core/types/src/http/inventory-level/admin/responses.ts b/packages/core/types/src/http/inventory-level/admin/responses.ts index adbad9cbde2e9..6a05d8e117b7e 100644 --- a/packages/core/types/src/http/inventory-level/admin/responses.ts +++ b/packages/core/types/src/http/inventory-level/admin/responses.ts @@ -2,9 +2,15 @@ import { PaginatedResponse } from "../../common" import { InventoryLevel } from "./entities" export interface AdminInventoryLevelResponse { + /** + * The inventory level's details. + */ inventory_level: InventoryLevel } export type AdminInventoryLevelListResponse = PaginatedResponse<{ + /** + * The list of inventory levels. + */ inventory_levels: InventoryLevel[] }> diff --git a/packages/core/types/src/http/inventory/admin/entities.ts b/packages/core/types/src/http/inventory/admin/entities.ts index 92fe195dec7c9..4ebcb6b95f511 100644 --- a/packages/core/types/src/http/inventory/admin/entities.ts +++ b/packages/core/types/src/http/inventory/admin/entities.ts @@ -1,34 +1,117 @@ export interface AdminInventoryItem { + /** + * The inventory item's ID. + */ id: string + /** + * The inventory item's SKU. + */ sku?: string | null + /** + * The inventory item's origin country. + */ origin_country?: string | null + /** + * The inventory item's HS code. + */ hs_code?: string | null + /** + * Whether the item requires shipping. + */ requires_shipping: boolean + /** + * The inventory item's MID code. + */ mid_code?: string | null + /** + * The inventory item's material. + */ material?: string | null + /** + * The inventory item's weight. + */ weight?: number | null + /** + * The inventory item's length. + */ length?: number | null + /** + * The inventory item's height. + */ height?: number | null + /** + * The inventory item's width. + */ width?: number | null + /** + * The inventory item's title. + */ title?: string | null + /** + * The inventory item's description. + */ description?: string | null + /** + * The inventory item's thumbnail URL. + */ thumbnail?: string | null + /** + * Key-value pairs of custom data. + */ metadata?: Record | null - + /** + * The item's associated inventory levels. + */ location_levels?: AdminInventoryLevel[] } export interface AdminInventoryLevel { + /** + * The inventory level's ID. + */ id: string + /** + * The date the inventory level was created. + */ created_at: Date + /** + * The date the inventory level was updated. + */ updated_at: Date + /** + * The date the inventory level was deleted. + */ deleted_at: Date | null + /** + * The ID of the associated inventory item. + */ inventory_item_id: string + /** + * The ID of the associated stock location. + */ location_id: string + /** + * The associated inventory item's stocked quantity in the associated location. + */ stocked_quantity: number + /** + * The associated inventory item's reserved quantity in the associated location. + */ reserved_quantity: number + /** + * The associated inventory item's incoming quantity in the associated location. + */ incoming_quantity: number + /** + * Key-value pairs of custom data. + */ metadata: Record | null + /** + * The associated inventory item. + */ inventory_item?: AdminInventoryItem + /** + * The associated inventory item's available quantity in the associated location. + */ available_quantity: number | null } diff --git a/packages/core/types/src/http/inventory/admin/payloads.ts b/packages/core/types/src/http/inventory/admin/payloads.ts index 13908fc016351..f8ce4c3f6eace 100644 --- a/packages/core/types/src/http/inventory/admin/payloads.ts +++ b/packages/core/types/src/http/inventory/admin/payloads.ts @@ -1,17 +1,59 @@ export interface AdminCreateInventoryItem { + /** + * The inventory item's SKU. + */ sku?: string + /** + * The inventory item's HS code. + */ hs_code?: string + /** + * The inventory item's weight. + */ weight?: number + /** + * The inventory item's length. + */ length?: number + /** + * The inventory item's height. + */ height?: number + /** + * The inventory item's width. + */ width?: number + /** + * The inventory item's origin country. + */ origin_country?: string + /** + * The inventory item's MID code. + */ mid_code?: string + /** + * The inventory item's material. + */ material?: string + /** + * The inventory item's title. + */ title?: string + /** + * The inventory item's description. + */ description?: string + /** + * Whether the inventory item requires shipping. + */ requires_shipping?: boolean + /** + * The inventory item's thumbnail URL. + */ thumbnail?: string + /** + * Key-value pairs of custom data. + */ metadata?: Record } diff --git a/packages/core/types/src/http/inventory/admin/queries.ts b/packages/core/types/src/http/inventory/admin/queries.ts index 29ed3f3301363..bfc1a6274f27a 100644 --- a/packages/core/types/src/http/inventory/admin/queries.ts +++ b/packages/core/types/src/http/inventory/admin/queries.ts @@ -4,17 +4,57 @@ import { BaseFilterable, OperatorMap } from "../../../dal" export interface AdminInventoryItemParams extends FindParams, BaseFilterable { + /** + * Filter by inventory item ID(s). + */ id?: string | string[] + /** + * Query or keywords to search the inventory item's searchable fields. + */ q?: string + /** + * Filter by SKU(s). + */ sku?: string | string[] + /** + * Filter by origin countries. + */ origin_country?: string | string[] + /** + * Filter by MID code(s). + */ mid_code?: string | string[] + /** + * Filter by HS code(s). + */ hs_code?: string | string[] + /** + * Filter by material(s). + */ material?: string | string[] + /** + * Filter by whether the item requires shipping. + */ requires_shipping?: boolean + /** + * Filter by weight(s). + */ weight?: number | OperatorMap + /** + * Filter by length(s). + */ length?: number | OperatorMap + /** + * Filter by height(s). + */ height?: number | OperatorMap + /** + * Filter by width(s). + */ width?: number | OperatorMap + /** + * Filter by stock location IDs to retrieve inventory items + * that have inventory levels associated with the locations. + */ location_levels?: Record<"location_id", string | string[]> } diff --git a/packages/core/types/src/http/inventory/admin/responses.ts b/packages/core/types/src/http/inventory/admin/responses.ts index 350039ab014b0..a90e40c0448d1 100644 --- a/packages/core/types/src/http/inventory/admin/responses.ts +++ b/packages/core/types/src/http/inventory/admin/responses.ts @@ -6,10 +6,16 @@ import { import { AdminInventoryItem } from "./entities" export interface AdminInventoryItemResponse { + /** + * The inventory item's details. + */ inventory_item: AdminInventoryItem } export type AdminInventoryItemListResponse = PaginatedResponse<{ + /** + * The list of inventory items. + */ inventory_items: AdminInventoryItem[] }> diff --git a/packages/core/types/src/http/invite/admin/entities.ts b/packages/core/types/src/http/invite/admin/entities.ts index 19dd60b1f07ad..10dc03dfcc1e0 100644 --- a/packages/core/types/src/http/invite/admin/entities.ts +++ b/packages/core/types/src/http/invite/admin/entities.ts @@ -1,10 +1,34 @@ export interface AdminInvite { + /** + * The invite's ID. + */ id: string + /** + * The email of the invited user. + */ email: string + /** + * Whether the invite was accepted. + */ accepted: boolean + /** + * The invite token. + */ token: string + /** + * The date the invite expires. + */ expires_at?: Date + /** + * Key-value pairs of custom data. + */ metadata?: Record + /** + * The date that the invite was created. + */ created_at?: Date + /** + * The date that the invite was updated. + */ updated_at?: Date } diff --git a/packages/core/types/src/http/invite/admin/payloads.ts b/packages/core/types/src/http/invite/admin/payloads.ts index 16a91338ca6cc..13d9b0076e34e 100644 --- a/packages/core/types/src/http/invite/admin/payloads.ts +++ b/packages/core/types/src/http/invite/admin/payloads.ts @@ -1,9 +1,25 @@ export type AdminAcceptInvite = { + /** + * The user's email. + */ + email: string + /** + * The user's first name. + */ first_name: string + /** + * The user's last name. + */ last_name: string } export type AdminCreateInvite = { + /** + * The email of the user to invite. + */ email: string + /** + * Key-value pairs of custom data. + */ metadata?: Record } diff --git a/packages/core/types/src/http/invite/admin/responses.ts b/packages/core/types/src/http/invite/admin/responses.ts index 6f16363b39168..fd2f74e416696 100644 --- a/packages/core/types/src/http/invite/admin/responses.ts +++ b/packages/core/types/src/http/invite/admin/responses.ts @@ -3,18 +3,30 @@ import { AdminUser } from "../../user" import { AdminInvite } from "./entities" export interface AdminInviteResponse { + /** + * The invite's details. + */ invite: AdminInvite } export type AdminInviteListResponse = PaginatedResponse<{ + /** + * The list of invites. + */ invites: AdminInvite[] }> export type AdminAcceptInviteResponse = | { + /** + * The user's details. + */ user: AdminUser } | { + /** + * A message if an error occurs. + */ message: string }