Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Correct dashboard and Admin SDK docs

Damian Legawiecea4e3554e2ad
diff --git a/docs/developer/dashboard/plugins/distributing.mdx b/docs/developer/dashboard/plugins/distributing.mdx
index 732aaee81e..9628d6c5db 100644
--- a/docs/developer/dashboard/plugins/distributing.mdx
+++ b/docs/developer/dashboard/plugins/distributing.mdx
@@ -31,7 +31,7 @@ bin/rails generate your_plugin:install
bin/rails db:migrate
```
-**No `vite.config.ts` edit.** As long as your plugin's `package.json` declares the `spree.dashboard.plugin` marker (the CLI scaffold does this for you — see [Publishing](/developer/dashboard/publishing#tell-the-vite-plugin-where-to-find-you)), `spreeDashboardPlugin()` walks the host's dependencies at build time and finds it automatically. Tailwind picks up the plugin's class names without any extra wiring.
+**No `vite.config.ts` edit.** As long as your plugin's `package.json` declares the `spree.dashboard.plugin` marker (the CLI scaffold does this for you — see [Publishing](/developer/dashboard/plugins/publishing#tell-the-vite-plugin-where-to-find-you)), `spreeDashboardPlugin()` walks the host's dependencies at build time and finds it automatically. Tailwind picks up the plugin's class names without any extra wiring.
### Manual whitelist (advanced)
@@ -82,10 +82,9 @@ export function getConfig() { return _config }
// consumer
import { configure } from '@your-scope/your-plugin'
configure({ endpoint: '/custom' })
-import '@your-scope/your-plugin'
```
-Simple, no dependencies. The consumer has to call `configure` **before** importing the plugin (or the plugin's `defineDashboardPlugin` runs with defaults).
+Simple, no dependencies — but mind the timing: ES module imports are hoisted, so the plugin module (including any top-level `defineDashboardPlugin` call) always executes **before** your `configure(...)` line runs. This pattern therefore only works for values the plugin reads lazily — at render or fetch time, like an API endpoint — never for anything its import-time registration depends on. If config shapes what gets registered (which nav entries, which routes), use the factory pattern below instead.
### `definePlugin(config)` factory
diff --git a/docs/developer/dashboard/plugins/scaffolding.mdx b/docs/developer/dashboard/plugins/scaffolding.mdx
index 185bc04661..e22602ec71 100644
--- a/docs/developer/dashboard/plugins/scaffolding.mdx
+++ b/docs/developer/dashboard/plugins/scaffolding.mdx
@@ -111,7 +111,7 @@ That's the whole entry-point. Edit it to register what your plugin needs and rem
## The example endpoints
-The generated `client.ts` calls `adminClient.request()` against `/api/v3/admin/<name>s` — those endpoints don't exist by default. You'd add them on the Rails side (a `BrandsController`, a Brand model, etc.) for the plugin to do anything end-to-end. The CLI doesn't scaffold the Rails engine today; for now, write that part by hand using the [backend customization docs](/developer/customization/extending-backend).
+The generated `client.ts` calls `adminClient.request()` against `/api/v3/admin/<name>s` — those endpoints don't exist by default. You'd add them on the Rails side (a `BrandsController`, a Brand model, etc.) for the plugin to do anything end-to-end. The CLI doesn't scaffold the Rails engine today; for now, write that part by hand using the [backend customization docs](/developer/dashboard/customization/backend).
## Reference
diff --git a/docs/developer/sdk/admin/extending.mdx b/docs/developer/sdk/admin/extending.mdx
index 15327605ec..73df7bfe88 100644
--- a/docs/developer/sdk/admin/extending.mdx
+++ b/docs/developer/sdk/admin/extending.mdx
@@ -25,7 +25,7 @@ interface Brand {
// Paths are relative to /api/v3/admin
const brands = await client.request<PaginatedResponse<Brand>>('GET', '/brands')
-const nike = await client.request<Brand>('GET', '/brands/nike')
+const brand = await client.request<Brand>('GET', '/brands/brand_2X9aQf7kEw')
```
`client.request` uses the same auth headers (secret API key *or* JWT, whichever was configured at client creation), retry logic, and base URL as every other resource on the client. The 401 → refresh → retry handshake that's wired up for the dashboard's user session applies to your custom endpoint too.
@@ -54,7 +54,7 @@ Standard list params work — pass them as the third argument's `params`:
const result = await client.request<PaginatedResponse<Brand>>('GET', '/brands', {
params: {
page: 2,
- per_page: 25,
+ limit: 25,
filter: { name_cont: 'nike' },
sort: '-created_at',
},
@@ -66,5 +66,5 @@ The SDK transforms `filter`/`sort` into the Ransack-flavored query string the Ad
## See also
- The [Store SDK extending guide](/developer/sdk/extending) covers the same pattern for storefront endpoints — the API is identical, only the base path (`/api/v3/store`) and auth header differ.
-- The [Store API](/developer/tutorial/store-api) and [SDK](/developer/tutorial/sdk) tutorials walk through creating new Spree endpoints end-to-end (Rails controller, serializer, TypeScript types). Everything they show for the Store API applies equivalently for the Admin API.
+- The [API](/developer/tutorial/api) and [SDK](/developer/tutorial/sdk) tutorials walk through creating new Spree endpoints end-to-end (Rails controller, serializer, TypeScript types). Everything they show for the Store API applies equivalently for the Admin API.
- For building dashboard UI on top of your custom endpoint, see the [Dashboard](/developer/dashboard/overview) section — start with [Customization Quickstart](/developer/dashboard/customization/quickstart) for in-app changes or [Plugin Overview](/developer/dashboard/plugins/overview) for redistributable packages.
diff --git a/docs/docs.json b/docs/docs.json
index e4f71fc1fa..894ce453a3 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -45,7 +45,7 @@
},
{
"source": "/developer/customization/dashboard-plugins",
- "destination": "/developer/dashboard/overview"
+ "destination": "/developer/dashboard/plugins/overview"
},
{
"source": "/developer/customization/event-subscribers",
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index 219cc758f5..88c4957792 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -248,7 +248,7 @@ export class AdminClient {
* const client = createAdminClient({ baseUrl: 'https://api.shop.com', token: '...' })
*
* const brands = await client.request<PaginatedResponse<Brand>>('GET', '/brands')
- * const nike = await client.request<Brand>('GET', '/brands/nike')
+ * const brand = await client.request<Brand>('GET', '/brands/brand_2X9aQf7kEw')
* ```
*/
readonly request: RequestFn