Skip to content

Commit 3fb6948

Browse files
committed
continued imprvoements
1 parent 05d40e3 commit 3fb6948

6 files changed

Lines changed: 72 additions & 30 deletions

File tree

app/globals.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,8 @@ div[style*="--callout-color"] > svg {
9999
div[style*="--callout-color"] > div[role="none"] {
100100
display: none !important;
101101
}
102+
103+
/* Callout description uses text-fd-muted-foreground — override it to full foreground */
104+
div[style*="--callout-color"] {
105+
--color-fd-muted-foreground: var(--color-fd-foreground);
106+
}

content/docs/admin-api/index.mdx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ import { Callout } from 'fumadocs-ui/components/callout';
77

88
### Getting Started
99

10-
{/* At the core of Next Commerce is the Admin API, developers can seamless build custom store operations, create orders, and integrate third-party services. Empower your business with streamlined control and endless possibilities, all through our intuitive and powerful API. */}
11-
1210
At the core of Next Commerce is the Admin API, developers can manage store resources, integrate third-party services and build seamless external order flows.
1311

1412

1513
### Authentication
1614

17-
1815
The Admin API uses Oauth 2 authorization protocol to manage access to your store's resources. Oauth Apps (and associated access tokens) can be tailored with object-level permission to ensure that each integrated service only has access to necessary objects.
1916

2017
Before using the Admin API, you'll need to create a store and create an OAuth App necessary for API access. To create an OAuth App, navigate to **Settings > API Access** and create a new Oauth App with applicable [permissions](/docs/admin-api/permissions) to retrieve your **Access Token**. It is recommended to create unique Oauth Apps per external system so that you can revoke as needed.

content/docs/admin-api/reference/2023-02-10/meta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"title": "API Reference",
44
"pages": [
55
"apps",
6-
"carts",
7-
"customers",
86
"fulfillment",
7+
"carts",
8+
"products",
9+
"payments",
910
"gift-cards",
1011
"metadata",
1112
"orders",
12-
"payments",
13-
"products",
14-
"store",
1513
"storefront",
14+
"store",
1615
"subscriptions",
1716
"support",
17+
"customers",
1818
"webhooks"
1919
]
2020
}

content/docs/admin-api/reference/meta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
"title": "API Reference",
33
"pages": [
44
"apps",
5-
"carts",
6-
"customers",
75
"fulfillment",
6+
"carts",
7+
"products",
8+
"payments",
89
"gift-cards",
910
"metadata",
1011
"orders",
11-
"payments",
12-
"products",
13-
"store",
1412
"storefront",
13+
"store",
1514
"subscriptions",
1615
"support",
16+
"customers",
1717
"webhooks"
1818
]
1919
}

content/docs/admin-api/reference/unstable/meta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
"title": "API Reference",
44
"pages": [
55
"apps",
6-
"carts",
7-
"customers",
86
"fulfillment",
7+
"carts",
8+
"products",
9+
"payments",
910
"gift-cards",
1011
"metadata",
1112
"orders",
12-
"payments",
13-
"products",
14-
"store",
1513
"storefront",
14+
"store",
1615
"subscriptions",
1716
"support",
17+
"customers",
1818
"webhooks"
1919
]
2020
}

scripts/generate-api-docs.mjs

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,36 @@ function isWebhookFile(filename) {
143143
return filename.includes('.');
144144
}
145145

146+
/**
147+
* Extract the tag order from an OpenAPI spec by first-appearance in paths.
148+
* Returns an array of tag names in spec order.
149+
*/
150+
function getTagOrder(specPath) {
151+
const raw = readFileSync(specPath, 'utf8');
152+
const spec = yaml.load(raw);
153+
if (spec.tags?.length) return spec.tags.map(t => t.name);
154+
const seen = [];
155+
for (const methods of Object.values(spec.paths ?? {})) {
156+
for (const op of Object.values(methods)) {
157+
if (!op || typeof op !== 'object') continue;
158+
for (const tag of op.tags ?? []) {
159+
if (!seen.includes(tag)) seen.push(tag);
160+
}
161+
}
162+
}
163+
return seen;
164+
}
165+
166+
/**
167+
* Sort tag folders to match spec order; any folders not in spec go at the end alphabetically.
168+
*/
169+
function sortBySpecOrder(folders, specOrder) {
170+
return [
171+
...specOrder.filter(t => folders.includes(t)),
172+
...folders.filter(t => !specOrder.includes(t)).sort(),
173+
];
174+
}
175+
146176
/**
147177
* Scan generated MDX files and return a map of URL path → HTTP method.
148178
* urlBase is the /docs/... prefix for this output directory.
@@ -293,10 +323,13 @@ for (const wspec of WEBHOOK_SPECS) {
293323

294324
// For the default admin-api reference dir, write a meta.json listing tag folders
295325
const refDir = 'content/docs/admin-api/reference';
296-
const tagFolders = readdirSync(refDir, { withFileTypes: true })
297-
.filter(e => e.isDirectory() && !VERSION_SUBFOLDERS.includes(e.name))
298-
.map(e => e.name)
299-
.sort();
326+
const stableTagOrder = getTagOrder(specs[0].input[0]);
327+
const tagFolders = sortBySpecOrder(
328+
readdirSync(refDir, { withFileTypes: true })
329+
.filter(e => e.isDirectory() && !VERSION_SUBFOLDERS.includes(e.name))
330+
.map(e => e.name),
331+
stableTagOrder,
332+
);
300333
// root:true version subdirs are discovered automatically — don't add to pages array
301334
writeFileSync(
302335
join(refDir, 'meta.json'),
@@ -308,10 +341,14 @@ console.log(`Wrote reference/meta.json with tag folders: ${tagFolders.join(', ')
308341
for (const version of VERSION_SUBFOLDERS) {
309342
const versionDir = join(refDir, version);
310343
if (!existsSync(versionDir)) continue;
311-
const versionTagFolders = readdirSync(versionDir, { withFileTypes: true })
312-
.filter(e => e.isDirectory())
313-
.map(e => e.name)
314-
.sort();
344+
const versionSpecPath = specs.find(s => s.output === versionDir)?.input[0] ?? specs[0].input[0];
345+
const versionTagOrder = getTagOrder(versionSpecPath);
346+
const versionTagFolders = sortBySpecOrder(
347+
readdirSync(versionDir, { withFileTypes: true })
348+
.filter(e => e.isDirectory())
349+
.map(e => e.name),
350+
versionTagOrder,
351+
);
315352
writeFileSync(
316353
join(versionDir, 'meta.json'),
317354
JSON.stringify({ root: true, title: 'API Reference', pages: versionTagFolders }, null, 2),
@@ -321,10 +358,13 @@ for (const version of VERSION_SUBFOLDERS) {
321358

322359
// For the campaigns api dir, write a meta.json listing tag folders (same pattern as admin-api)
323360
const campaignsApiDir = 'content/docs/campaigns/api';
324-
const campaignsTagFolders = readdirSync(campaignsApiDir, { withFileTypes: true })
325-
.filter(e => e.isDirectory() && !CAMPAIGNS_VERSION_SUBFOLDERS.includes(e.name))
326-
.map(e => e.name)
327-
.sort();
361+
const campaignsTagOrder = getTagOrder(specs.find(s => s.output === campaignsApiDir).input[0]);
362+
const campaignsTagFolders = sortBySpecOrder(
363+
readdirSync(campaignsApiDir, { withFileTypes: true })
364+
.filter(e => e.isDirectory() && !CAMPAIGNS_VERSION_SUBFOLDERS.includes(e.name))
365+
.map(e => e.name),
366+
campaignsTagOrder,
367+
);
328368
// root:true version subdirs are discovered automatically — don't add to pages array
329369
writeFileSync(
330370
join(campaignsApiDir, 'meta.json'),

0 commit comments

Comments
 (0)