Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Changed Seller and Admin SDK record removal methods to delete and fixed Seller SDK types
Damian Legawiecf184f25097c9
diff --git a/.changeset/seller-sdk-delete-and-types.md b/.changeset/seller-sdk-delete-and-types.mdnew file mode 100644index 0000000000..4679d3e89c--- /dev/null+++ b/.changeset/seller-sdk-delete-and-types.md@@ -0,0 +1,10 @@+---+"@spree/seller-sdk": minor+"@spree/admin-sdk": minor+"@spree/dashboard": patch+"@spree/seller-dashboard": patch+---++Methods that delete a record are named `delete` in both SDKs. In the Seller SDK, `taxIdentifiers.remove`, `team.remove` and `invitations.revoke` are now `taxIdentifiers.delete`, `team.delete` and `invitations.delete`. In the Admin SDK, `sellers.team.remove` and `sellers.invitations.remove` are now `sellers.team.delete` and `sellers.invitations.delete`. Methods that detach something from a cart or order (`remove`), or change a record without deleting it (`revoke`), keep their names.++Seller SDK types are corrected: `team.invite` returns the `Invitation`, `auth.providers` returns `AuthProvidersResponse`, and `SellerTaxIdentifierParams` is split into `SellerTaxIdentifierCreateParams`, which requires `kind` and `value`, and `SellerTaxIdentifierUpdateParams`.diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.tsindex db70c057c4..1eb578f170 100644--- a/packages/admin-sdk/src/admin-client.ts+++ b/packages/admin-sdk/src/admin-client.ts@@ -1,4 +1,5 @@import type {+ AuthProvidersResponse,EmailPasswordLogin,FileUploadCreateParams,ListParams,@@ -342,26 +343,6 @@ export interface AuthTokens {user: AdminUser}-/**- * One authentication provider the store accepts.- *- * `password` providers are driven by the login form; `redirect` providers send- * the browser to `authorization_url` and come back through the OAuth callback.- */-export interface AuthProvider {- /** Registry key, e.g. "email" or "entra". Identifies the provider on login. */- key: string- kind: 'password' | 'redirect'- /** Button label for redirect providers. Absent for password providers. */- label?: string- /** Where to send the browser. Absent if the provider is misconfigured or unreachable. */- authorization_url?: string-}--export interface AuthProvidersResponse {- providers: AuthProvider[]-}-export interface PermissionRule {/** true for `can`, false for `cannot` */allow: boolean@@ -3332,7 +3313,7 @@ export class AdminClient {this.request<{ data: SellerTeamMember[] }>('GET', `/sellers/${sellerId}/team`, options),/** Revokes a member's access. */- remove: (sellerId: string, id: string, options?: RequestOptions): Promise<void> =>+ delete: (sellerId: string, id: string, options?: RequestOptions): Promise<void> =>this.request<void>('DELETE', `/sellers/${sellerId}/team/${id}`, options),},@@ -3342,7 +3323,7 @@ export class AdminClient {this.request<{ data: Invitation[] }>('GET', `/sellers/${sellerId}/invitations`, options),/** Withdraws an offer. */- remove: (sellerId: string, id: string, options?: RequestOptions): Promise<void> =>+ delete: (sellerId: string, id: string, options?: RequestOptions): Promise<void> =>this.request<void>('DELETE', `/sellers/${sellerId}/invitations/${id}`, options),/** Sends the email again; refused once the offer has lapsed. */diff --git a/packages/admin-sdk/src/index.ts b/packages/admin-sdk/src/index.tsindex 91de6d5deb..c790bc2a28 100644--- a/packages/admin-sdk/src/index.ts+++ b/packages/admin-sdk/src/index.ts@@ -1,6 +1,8 @@// Main clientexport type {+ AuthProvider,+ AuthProvidersResponse,FileUploadCreateParams,RequestOptions,RetryConfig,@@ -20,8 +22,6 @@ export {sumMoney,} from '@spree/sdk-core'export type {- AuthProvider,- AuthProvidersResponse,AuthTokens,DashboardCounters,LoginCredentials,diff --git a/packages/dashboard/src/hooks/use-sellers.ts b/packages/dashboard/src/hooks/use-sellers.tsindex f68d42a94e..5236f10b2c 100644--- a/packages/dashboard/src/hooks/use-sellers.ts+++ b/packages/dashboard/src/hooks/use-sellers.ts@@ -157,7 +157,7 @@ export function useSellerTeam(sellerId: string) {export function useRemoveSellerTeamMember(sellerId: string) {return useResourceMutation<void, Error, string>({- mutationFn: (id) => adminClient.sellers.team.remove(sellerId, id),+ mutationFn: (id) => adminClient.sellers.team.delete(sellerId, id),invalidate: [['sellers', sellerId, 'team'],['sellers', sellerId],@@ -176,7 +176,7 @@ export function useSellerInvitations(sellerId: string) {export function useRevokeSellerInvitation(sellerId: string) {return useResourceMutation<void, Error, string>({- mutationFn: (id) => adminClient.sellers.invitations.remove(sellerId, id),+ mutationFn: (id) => adminClient.sellers.invitations.delete(sellerId, id),invalidate: [['sellers', sellerId, 'invitations']],successMessage: i18n.t('admin.sellers.team.messages.invitation_revoked'),errorMessage: i18n.t('admin.errors.failed_to_delete'),diff --git a/packages/sdk-core/src/index.ts b/packages/sdk-core/src/index.tsindex 97ac8b5015..ef6e6b2ccb 100644--- a/packages/sdk-core/src/index.ts+++ b/packages/sdk-core/src/index.ts@@ -41,6 +41,8 @@ export { createRequestFn, SpreeError } from './request'// Shared typesexport type {AddressParams,+ AuthProvider,+ AuthProvidersResponse,EmailPasswordLogin,ErrorResponse,ListParams,diff --git a/packages/sdk-core/src/types.ts b/packages/sdk-core/src/types.tsindex 0de5b91bef..bdb245521f 100644--- a/packages/sdk-core/src/types.ts+++ b/packages/sdk-core/src/types.ts@@ -170,3 +170,23 @@ export interface PreferenceSchema {properties: Record<string, PreferencePropertySchema>additionalProperties: false}++/**+ * One authentication provider the store accepts.+ *+ * `password` providers are driven by the login form; `redirect` providers send+ * the browser to `authorization_url` and come back through the OAuth callback.+ */+export interface AuthProvider {+ /** Registry key, e.g. "email" or "entra". Identifies the provider on login. */+ key: string+ kind: 'password' | 'redirect'+ /** Button label for redirect providers. Absent for password providers. */+ label?: string+ /** Where to send the browser. Absent if the provider is misconfigured or unreachable. */+ authorization_url?: string+}++export interface AuthProvidersResponse {+ providers: AuthProvider[]+}diff --git a/packages/seller-dashboard/src/components/seller-tax-identifiers-card.tsx b/packages/seller-dashboard/src/components/seller-tax-identifiers-card.tsxindex b6933debed..07bf80470b 100644--- a/packages/seller-dashboard/src/components/seller-tax-identifiers-card.tsx+++ b/packages/seller-dashboard/src/components/seller-tax-identifiers-card.tsx@@ -37,7 +37,7 @@ export function SellerTaxIdentifiersCard() {onSuccess: refresh,})const remove = useMutation({- mutationFn: (id: string) => sellerClient().taxIdentifiers.remove(id),+ mutationFn: (id: string) => sellerClient().taxIdentifiers.delete(id),onSuccess: refresh,})const validate = useMutation({diff --git a/packages/seller-dashboard/src/pages/team.tsx b/packages/seller-dashboard/src/pages/team.tsxindex 053963a512..0f0d06baaf 100644--- a/packages/seller-dashboard/src/pages/team.tsx+++ b/packages/seller-dashboard/src/pages/team.tsx@@ -175,7 +175,7 @@ function MemberRow({ member, lastOne }: { member: TeamMember; lastOne: boolean }const confirm = useConfirm()const remove = useMutation({- mutationFn: (id: string) => sellerClient().team.remove(id),+ mutationFn: (id: string) => sellerClient().team.delete(id),onSuccess: () => {toastManager.add({ type: 'success', title: t('team.messages.removed') })void queryClient.invalidateQueries({ queryKey: ['seller', sellerId, 'team'] })@@ -302,7 +302,7 @@ function InvitationRow({ invitation }: { invitation: Invitation }) {})const revoke = useMutation({- mutationFn: (id: string) => sellerClient().invitations.revoke(id),+ mutationFn: (id: string) => sellerClient().invitations.delete(id),onSuccess: () => {toastManager.add({ type: 'success', title: t('team.messages.revoked') })void invalidate()diff --git a/packages/seller-sdk/src/index.ts b/packages/seller-sdk/src/index.tsindex 84943707df..5db290aafe 100644--- a/packages/seller-sdk/src/index.ts+++ b/packages/seller-sdk/src/index.ts@@ -1,4 +1,6 @@export type {+ AuthProvider,+ AuthProvidersResponse,FileUploadCreateParams,RequestOptions,RetryConfig,diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.tsindex dcc5b34276..4d62e2f8d3 100644--- a/packages/seller-sdk/src/seller-client.ts+++ b/packages/seller-sdk/src/seller-client.ts@@ -1,4 +1,5 @@import type {+ AuthProvidersResponse,ListParams,PaginatedResponse,PreferenceSchema,@@ -101,6 +102,7 @@ import type {PasswordResetUpdateParams,PolicyCreateParams,PolicyUpdateParams,+ ProductBulkDestroyParams,ProductBulkStatusParams,ProductBulkSubmitParams,ProductCreateParams,@@ -149,8 +151,8 @@ export class SellerClient {this.request<void>('POST', '/auth/logout', options),/** Sign-in methods this marketplace offers sellers, for the login page. */- providers: (options?: RequestOptions): Promise<{ providers: unknown[] }> =>- this.request<{ providers: unknown[] }>('GET', '/auth/providers', options),+ providers: (options?: RequestOptions): Promise<AuthProvidersResponse> =>+ this.request<AuthProvidersResponse>('GET', '/auth/providers', options),/*** Reads an invitation from the emailed link, before anyone signs in — the@@ -284,7 +286,7 @@ export class SellerClient {body: params,}),- remove: (id: string, options?: RequestOptions): Promise<void> =>+ delete: (id: string, options?: RequestOptions): Promise<void> =>this.request<void>('DELETE', `/tax_identifiers/${id}`, options),/**@@ -304,11 +306,11 @@ export class SellerClient {* Invites a colleague. They join when they accept; the seller's own* lifecycle is untouched, since hiring is not a transition.*/- invite: (params: TeamMemberCreateParams, options?: RequestOptions): Promise<unknown> =>- this.request<unknown>('POST', '/team', { ...options, body: params }),+ invite: (params: TeamMemberCreateParams, options?: RequestOptions): Promise<Invitation> =>+ this.request<Invitation>('POST', '/team', { ...options, body: params }),/** Revokes a member's access. The last remaining member cannot be removed. */- remove: (id: string, options?: RequestOptions): Promise<void> =>+ delete: (id: string, options?: RequestOptions): Promise<void> =>this.request<void>('DELETE', `/team/${id}`, options),}@@ -394,7 +396,7 @@ export class SellerClient {this.request<Invitation>('PATCH', `/invitations/${id}/resend`, options),/** Withdraws an offer that has not been accepted. */- revoke: (id: string, options?: RequestOptions): Promise<void> =>+ delete: (id: string, options?: RequestOptions): Promise<void> =>this.request<void>('DELETE', `/invitations/${id}`, options),/** The link a colleague opens to join; it carries the invitation's token. */@@ -483,7 +485,7 @@ export class SellerClient {/** Delete a selection. Ids outside this seller's catalog are ignored. */bulkDestroy: (- params: { ids: string[] },+ params: ProductBulkDestroyParams,options?: RequestOptions,): Promise<BulkProductResult> =>this.request('DELETE', '/products/bulk_destroy', { ...options, body: params }),