@mintlify/scraping 4.0.1109 → 4.0.1111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__test__/sdk-typedoc.test.ts +612 -0
- package/bin/sdk/converters/typedoc.js +144 -14
- package/bin/sdk/converters/typedoc.js.map +1 -1
- package/bin/sdk/types.d.ts +1 -1
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/sdk/converters/typedoc.ts +194 -23
- package/src/sdk/types.ts +1 -1
|
@@ -235,4 +235,616 @@ describe('convertTypedoc', () => {
|
|
|
235
235
|
}).slug
|
|
236
236
|
).toBe('classes/Client/login');
|
|
237
237
|
});
|
|
238
|
+
|
|
239
|
+
describe('member-level @category tags', () => {
|
|
240
|
+
const client = {
|
|
241
|
+
id: 1,
|
|
242
|
+
name: 'Auth0Client',
|
|
243
|
+
kind: 128,
|
|
244
|
+
comment: { summary: [{ kind: 'text', text: 'SDK for SPAs.' }] },
|
|
245
|
+
children: [
|
|
246
|
+
{
|
|
247
|
+
id: 2,
|
|
248
|
+
name: 'constructor',
|
|
249
|
+
kind: 512,
|
|
250
|
+
signatures: [
|
|
251
|
+
{
|
|
252
|
+
id: 3,
|
|
253
|
+
name: 'new Auth0Client',
|
|
254
|
+
kind: 16384,
|
|
255
|
+
parameters: [
|
|
256
|
+
{
|
|
257
|
+
id: 4,
|
|
258
|
+
name: 'options',
|
|
259
|
+
kind: 32768,
|
|
260
|
+
type: { type: 'intrinsic', name: 'object' },
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
type: { type: 'reference', name: 'Auth0Client', target: 1 },
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
id: 5,
|
|
269
|
+
name: 'mfa',
|
|
270
|
+
kind: 1024,
|
|
271
|
+
type: { type: 'intrinsic', name: 'object' },
|
|
272
|
+
comment: { summary: [{ kind: 'text', text: 'MFA API.' }] },
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
id: 6,
|
|
276
|
+
name: 'checkSession',
|
|
277
|
+
kind: 2048,
|
|
278
|
+
signatures: [
|
|
279
|
+
{ id: 7, name: 'checkSession', kind: 4096, type: { type: 'intrinsic', name: 'void' } },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: 8,
|
|
284
|
+
name: 'getTokenSilently',
|
|
285
|
+
kind: 2048,
|
|
286
|
+
signatures: [
|
|
287
|
+
{
|
|
288
|
+
id: 9,
|
|
289
|
+
name: 'getTokenSilently',
|
|
290
|
+
kind: 4096,
|
|
291
|
+
type: { type: 'intrinsic', name: 'string' },
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: 10,
|
|
297
|
+
name: 'logout',
|
|
298
|
+
kind: 2048,
|
|
299
|
+
signatures: [
|
|
300
|
+
{ id: 11, name: 'logout', kind: 4096, type: { type: 'intrinsic', name: 'void' } },
|
|
301
|
+
],
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
id: 12,
|
|
305
|
+
name: 'secret',
|
|
306
|
+
kind: 1024,
|
|
307
|
+
flags: { isPrivate: true },
|
|
308
|
+
type: { type: 'intrinsic', name: 'string' },
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
async function convert(classNode: object) {
|
|
314
|
+
const artifact = path.join(directory, 'typedoc.json');
|
|
315
|
+
await writeFile(
|
|
316
|
+
artifact,
|
|
317
|
+
JSON.stringify({ id: 0, name: '@auth0/example', kind: 1, children: [classNode] })
|
|
318
|
+
);
|
|
319
|
+
const reference = await convertTypedoc(artifact);
|
|
320
|
+
return reference.pages.find((page) => page.slug === 'classes/Auth0Client')?.content ?? '';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function headings(content: string): string[] {
|
|
324
|
+
return content.split('\n').filter((line) => /^#{2,5} /.test(line));
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
it('renders one section per category in artifact order', async () => {
|
|
328
|
+
const content = await convert({
|
|
329
|
+
...client,
|
|
330
|
+
groups: [
|
|
331
|
+
{ title: 'Constructors', children: [2] },
|
|
332
|
+
{ title: 'Properties', children: [5, 12] },
|
|
333
|
+
{ title: 'Methods', children: [6, 8, 10] },
|
|
334
|
+
],
|
|
335
|
+
categories: [
|
|
336
|
+
{ title: 'Constructor', children: [2] },
|
|
337
|
+
{ title: 'Sub-clients', children: [5, 12] },
|
|
338
|
+
{ title: 'Authentication', children: [6] },
|
|
339
|
+
{ title: 'Tokens', children: [8] },
|
|
340
|
+
{ title: 'Other', children: [10] },
|
|
341
|
+
],
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
expect(headings(content)).toEqual([
|
|
345
|
+
'## Constructor',
|
|
346
|
+
'### Parameters',
|
|
347
|
+
'### Returns',
|
|
348
|
+
'## Sub-clients',
|
|
349
|
+
'## Authentication',
|
|
350
|
+
'### checkSession()',
|
|
351
|
+
'## Tokens',
|
|
352
|
+
'### getTokenSilently()',
|
|
353
|
+
'#### Returns',
|
|
354
|
+
'## Other',
|
|
355
|
+
'### logout()',
|
|
356
|
+
]);
|
|
357
|
+
expect(content).toContain('<ResponseField name={"mfa"} type={"object"} required>');
|
|
358
|
+
expect(content).not.toContain('secret');
|
|
359
|
+
expect(content).not.toContain('## Methods');
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it('nests categories under kind groups when typedoc categorizes by group', async () => {
|
|
363
|
+
const content = await convert({
|
|
364
|
+
...client,
|
|
365
|
+
groups: [
|
|
366
|
+
{
|
|
367
|
+
title: 'Constructors',
|
|
368
|
+
children: [2],
|
|
369
|
+
categories: [{ title: 'Constructor', children: [2] }],
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
title: 'Properties',
|
|
373
|
+
children: [5],
|
|
374
|
+
categories: [{ title: 'Sub-clients', children: [5] }],
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
title: 'Methods',
|
|
378
|
+
children: [6, 8, 10],
|
|
379
|
+
categories: [
|
|
380
|
+
{ title: 'Authentication', children: [6] },
|
|
381
|
+
{ title: 'Other', children: [10] },
|
|
382
|
+
{ title: 'Tokens', children: [8] },
|
|
383
|
+
],
|
|
384
|
+
},
|
|
385
|
+
],
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
expect(headings(content)).toEqual([
|
|
389
|
+
'## Constructors',
|
|
390
|
+
'### Constructor',
|
|
391
|
+
'#### Parameters',
|
|
392
|
+
'#### Returns',
|
|
393
|
+
'## Properties',
|
|
394
|
+
'### Sub-clients',
|
|
395
|
+
'## Methods',
|
|
396
|
+
'### Authentication',
|
|
397
|
+
'#### checkSession()',
|
|
398
|
+
'### Other',
|
|
399
|
+
'#### logout()',
|
|
400
|
+
'### Tokens',
|
|
401
|
+
'#### getTokenSilently()',
|
|
402
|
+
]);
|
|
403
|
+
expect(content).toContain(
|
|
404
|
+
'#### getTokenSilently()\n\n```typescript\ngetTokenSilently(): string\n```\n\n**Returns**\n\n`string`'
|
|
405
|
+
);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('renders a member once even when its id is repeated across categories', async () => {
|
|
409
|
+
const content = await convert({
|
|
410
|
+
...client,
|
|
411
|
+
categories: [
|
|
412
|
+
{ title: 'Primary', children: Array.from({ length: 500 }, () => 6) },
|
|
413
|
+
{ title: 'Secondary', children: [6, 8] },
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
expect(content.match(/### checkSession\(\)/g)).toHaveLength(1);
|
|
418
|
+
expect(headings(content)).toEqual([
|
|
419
|
+
'## Primary',
|
|
420
|
+
'### checkSession()',
|
|
421
|
+
'## Secondary',
|
|
422
|
+
'### getTokenSilently()',
|
|
423
|
+
'#### Returns',
|
|
424
|
+
]);
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('escapes category titles used as headings', async () => {
|
|
428
|
+
const content = await convert({
|
|
429
|
+
...client,
|
|
430
|
+
categories: [
|
|
431
|
+
{ title: 'Collections <T>', children: [5] },
|
|
432
|
+
{ title: 'Login {redirect}', children: [6, 8, 10] },
|
|
433
|
+
],
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
expect(headings(content)).toEqual([
|
|
437
|
+
'## Collections',
|
|
438
|
+
'## Login \\{redirect}',
|
|
439
|
+
'### checkSession()',
|
|
440
|
+
'### getTokenSilently()',
|
|
441
|
+
'#### Returns',
|
|
442
|
+
'### logout()',
|
|
443
|
+
]);
|
|
444
|
+
expect(content).not.toContain('<T>');
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('keeps multi-line titles inside a single heading', async () => {
|
|
448
|
+
const content = await convert({
|
|
449
|
+
...client,
|
|
450
|
+
categories: [
|
|
451
|
+
{ title: 'Auth\nexport const x = alert(1)', children: [5] },
|
|
452
|
+
{ title: 'A\n\n# Big', children: [6] },
|
|
453
|
+
],
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
expect(headings(content)).toEqual([
|
|
457
|
+
'## Auth export const x = alert(1)',
|
|
458
|
+
'## A # Big',
|
|
459
|
+
'### checkSession()',
|
|
460
|
+
]);
|
|
461
|
+
expect(content).not.toMatch(/^export /m);
|
|
462
|
+
expect(content).not.toMatch(/^# Big/m);
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
it('mirrors custom member @group titles', async () => {
|
|
466
|
+
const content = await convert({
|
|
467
|
+
...client,
|
|
468
|
+
groups: [
|
|
469
|
+
{ title: 'Constructors', children: [2] },
|
|
470
|
+
{ title: 'Sub-clients', children: [5] },
|
|
471
|
+
{ title: 'Methods', children: [6, 8, 10] },
|
|
472
|
+
],
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
expect(headings(content)).toEqual([
|
|
476
|
+
'## Constructors',
|
|
477
|
+
'### Parameters',
|
|
478
|
+
'### Returns',
|
|
479
|
+
'## Sub-clients',
|
|
480
|
+
'## Methods',
|
|
481
|
+
'### checkSession()',
|
|
482
|
+
'### getTokenSilently()',
|
|
483
|
+
'#### Returns',
|
|
484
|
+
'### logout()',
|
|
485
|
+
]);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it('keeps the kind-based layout when members only have default groups', async () => {
|
|
489
|
+
const content = await convert({
|
|
490
|
+
...client,
|
|
491
|
+
groups: [
|
|
492
|
+
{ title: 'Constructors', children: [2] },
|
|
493
|
+
{ title: 'Properties', children: [5, 12] },
|
|
494
|
+
{ title: 'Methods', children: [6, 8, 10] },
|
|
495
|
+
],
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
expect(headings(content)).toEqual([
|
|
499
|
+
'## Constructor',
|
|
500
|
+
'### Parameters',
|
|
501
|
+
'### Returns',
|
|
502
|
+
'## Properties',
|
|
503
|
+
'## Methods',
|
|
504
|
+
'### checkSession()',
|
|
505
|
+
'### getTokenSilently()',
|
|
506
|
+
'#### Returns',
|
|
507
|
+
'### logout()',
|
|
508
|
+
]);
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
describe('@category and @group tags', () => {
|
|
513
|
+
const categorized = {
|
|
514
|
+
id: 0,
|
|
515
|
+
name: '@auth0/example',
|
|
516
|
+
kind: 1,
|
|
517
|
+
children: [
|
|
518
|
+
{ id: 1, name: 'helper', kind: 64, signatures: [] },
|
|
519
|
+
{
|
|
520
|
+
id: 3,
|
|
521
|
+
name: 'MfaApiClient',
|
|
522
|
+
kind: 128,
|
|
523
|
+
comment: {
|
|
524
|
+
summary: [{ kind: 'text', text: 'Client for MFA.' }],
|
|
525
|
+
blockTags: [{ tag: '@category', content: [{ kind: 'text', text: 'Authentication' }] }],
|
|
526
|
+
},
|
|
527
|
+
children: [],
|
|
528
|
+
},
|
|
529
|
+
{ id: 9, name: 'ChallengeAuthenticatorParams', kind: 256, children: [] },
|
|
530
|
+
{ id: 11, name: 'ChallengeResponse', kind: 256, children: [] },
|
|
531
|
+
{ id: 14, name: 'UsersClient', kind: 128, children: [] },
|
|
532
|
+
{ id: 19, name: 'Plain', kind: 256, children: [] },
|
|
533
|
+
{ id: 21, name: 'UserId', kind: 2097152, type: { type: 'intrinsic', name: 'string' } },
|
|
534
|
+
{ id: 30, name: 'Secret', kind: 128, flags: { isPrivate: true }, children: [] },
|
|
535
|
+
],
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
async function convert(project: object) {
|
|
539
|
+
const artifact = path.join(directory, 'typedoc.json');
|
|
540
|
+
await writeFile(artifact, JSON.stringify(project));
|
|
541
|
+
return convertTypedoc(artifact);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
it('mirrors top-level categories from the artifact', async () => {
|
|
545
|
+
const reference = await convert({
|
|
546
|
+
...categorized,
|
|
547
|
+
groups: [
|
|
548
|
+
{ title: 'Classes', children: [3, 14] },
|
|
549
|
+
{ title: 'Interfaces', children: [9, 11, 19] },
|
|
550
|
+
{ title: 'Type Aliases', children: [21] },
|
|
551
|
+
{ title: 'Functions', children: [1] },
|
|
552
|
+
],
|
|
553
|
+
categories: [
|
|
554
|
+
{ title: 'Authentication', children: [3, 9, 11, 30] },
|
|
555
|
+
{ title: 'Management', children: [14, 21] },
|
|
556
|
+
{ title: 'Other', children: [19, 1] },
|
|
557
|
+
],
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
expect(reference.groups).toEqual([
|
|
561
|
+
{
|
|
562
|
+
group: 'Authentication',
|
|
563
|
+
pages: [
|
|
564
|
+
'classes/MfaApiClient',
|
|
565
|
+
'interfaces/ChallengeAuthenticatorParams',
|
|
566
|
+
'interfaces/ChallengeResponse',
|
|
567
|
+
],
|
|
568
|
+
},
|
|
569
|
+
{ group: 'Management', pages: ['classes/UsersClient', 'types/UserId'] },
|
|
570
|
+
{ group: 'Other', pages: ['interfaces/Plain', 'functions/helper'] },
|
|
571
|
+
]);
|
|
572
|
+
const mfa = reference.pages.find((page) => page.slug === 'classes/MfaApiClient');
|
|
573
|
+
expect(mfa?.content).not.toContain('@category');
|
|
574
|
+
expect(mfa?.content).not.toContain('Authentication');
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
it('nests categories inside groups when typedoc categorizes by group', async () => {
|
|
578
|
+
const reference = await convert({
|
|
579
|
+
...categorized,
|
|
580
|
+
groups: [
|
|
581
|
+
{
|
|
582
|
+
title: 'Classes',
|
|
583
|
+
children: [3, 14],
|
|
584
|
+
categories: [
|
|
585
|
+
{ title: 'Authentication', children: [3] },
|
|
586
|
+
{ title: 'Management', children: [14] },
|
|
587
|
+
],
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
title: 'Interfaces',
|
|
591
|
+
children: [9, 11, 19],
|
|
592
|
+
categories: [
|
|
593
|
+
{ title: 'Authentication', children: [9, 11] },
|
|
594
|
+
{ title: 'Other', children: [19] },
|
|
595
|
+
],
|
|
596
|
+
},
|
|
597
|
+
{ title: 'Functions', children: [1] },
|
|
598
|
+
],
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
expect(reference.groups).toEqual([
|
|
602
|
+
{
|
|
603
|
+
group: 'Classes',
|
|
604
|
+
pages: [
|
|
605
|
+
{ group: 'Authentication', pages: ['classes/MfaApiClient'] },
|
|
606
|
+
{ group: 'Management', pages: ['classes/UsersClient'] },
|
|
607
|
+
],
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
group: 'Interfaces',
|
|
611
|
+
pages: [
|
|
612
|
+
{
|
|
613
|
+
group: 'Authentication',
|
|
614
|
+
pages: ['interfaces/ChallengeAuthenticatorParams', 'interfaces/ChallengeResponse'],
|
|
615
|
+
},
|
|
616
|
+
{ group: 'Other', pages: ['interfaces/Plain'] },
|
|
617
|
+
],
|
|
618
|
+
},
|
|
619
|
+
{ group: 'Functions', pages: ['functions/helper'] },
|
|
620
|
+
]);
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
it('mirrors custom @group titles in artifact order', async () => {
|
|
624
|
+
const reference = await convert({
|
|
625
|
+
...categorized,
|
|
626
|
+
groups: [
|
|
627
|
+
{ title: 'Helpers', children: [1] },
|
|
628
|
+
{ title: 'Classes', children: [3, 14] },
|
|
629
|
+
{ title: 'Interfaces', children: [9, 11, 19] },
|
|
630
|
+
{ title: 'Type Aliases', children: [21] },
|
|
631
|
+
],
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
expect(reference.groups.map((group) => group.group)).toEqual([
|
|
635
|
+
'Helpers',
|
|
636
|
+
'Classes',
|
|
637
|
+
'Interfaces',
|
|
638
|
+
'Type Aliases',
|
|
639
|
+
]);
|
|
640
|
+
expect(reference.groups[0]).toEqual({ group: 'Helpers', pages: ['functions/helper'] });
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
it('detects a @group that borrows a default title for a different kind', async () => {
|
|
644
|
+
const reference = await convert({
|
|
645
|
+
...categorized,
|
|
646
|
+
groups: [
|
|
647
|
+
{ title: 'Classes', children: [3, 14, 9] },
|
|
648
|
+
{ title: 'Interfaces', children: [11, 19] },
|
|
649
|
+
{ title: 'Type Aliases', children: [21] },
|
|
650
|
+
{ title: 'Functions', children: [1] },
|
|
651
|
+
],
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
expect(reference.groups[0]).toEqual({
|
|
655
|
+
group: 'Classes',
|
|
656
|
+
pages: [
|
|
657
|
+
'classes/MfaApiClient',
|
|
658
|
+
'classes/UsersClient',
|
|
659
|
+
'interfaces/ChallengeAuthenticatorParams',
|
|
660
|
+
],
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
it('keeps kind-based groups when the artifact only has default groups', async () => {
|
|
665
|
+
const reference = await convert({
|
|
666
|
+
...categorized,
|
|
667
|
+
groups: [
|
|
668
|
+
{ title: 'Functions', children: [1] },
|
|
669
|
+
{ title: 'Classes', children: [3, 14] },
|
|
670
|
+
{ title: 'Interfaces', children: [9, 11, 19] },
|
|
671
|
+
{ title: 'Type Aliases', children: [21] },
|
|
672
|
+
],
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
expect(reference.groups.map((group) => group.group)).toEqual([
|
|
676
|
+
'Classes',
|
|
677
|
+
'Interfaces',
|
|
678
|
+
'Functions',
|
|
679
|
+
'Type Aliases',
|
|
680
|
+
]);
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
it('detects a @group that only contains namespaces', async () => {
|
|
684
|
+
const reference = await convert({
|
|
685
|
+
id: 0,
|
|
686
|
+
name: '@auth0/example',
|
|
687
|
+
kind: 1,
|
|
688
|
+
children: [
|
|
689
|
+
{
|
|
690
|
+
id: 1,
|
|
691
|
+
name: 'Admin',
|
|
692
|
+
kind: 4,
|
|
693
|
+
children: [{ id: 2, name: 'Users', kind: 128, children: [] }],
|
|
694
|
+
groups: [{ title: 'Classes', children: [2] }],
|
|
695
|
+
},
|
|
696
|
+
{ id: 3, name: 'Client', kind: 128, children: [] },
|
|
697
|
+
],
|
|
698
|
+
groups: [
|
|
699
|
+
{ title: 'Classes', children: [3] },
|
|
700
|
+
{ title: 'Admin APIs', children: [1] },
|
|
701
|
+
],
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
expect(reference.groups).toEqual([
|
|
705
|
+
{ group: 'Classes', pages: ['classes/Client'] },
|
|
706
|
+
{
|
|
707
|
+
group: 'Admin APIs',
|
|
708
|
+
pages: [
|
|
709
|
+
{ group: 'Admin', pages: [{ group: 'Classes', pages: ['Admin/classes/Users'] }] },
|
|
710
|
+
],
|
|
711
|
+
},
|
|
712
|
+
]);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it('collapses a wrapped @category title onto one line', async () => {
|
|
716
|
+
const reference = await convert({
|
|
717
|
+
...categorized,
|
|
718
|
+
categories: [{ title: 'Multi-factor\nauthentication', children: [3] }],
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
expect(reference.groups).toEqual([
|
|
722
|
+
{ group: 'Multi-factor authentication', pages: ['classes/MfaApiClient'] },
|
|
723
|
+
]);
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
it('lists a page under every category that references it', async () => {
|
|
727
|
+
const reference = await convert({
|
|
728
|
+
...categorized,
|
|
729
|
+
categories: [
|
|
730
|
+
{ title: 'Clients', children: [3, 1] },
|
|
731
|
+
{ title: 'Helpers', children: [1, 1] },
|
|
732
|
+
{ title: 'Utilities', children: [1] },
|
|
733
|
+
],
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
expect(reference.groups).toEqual([
|
|
737
|
+
{ group: 'Clients', pages: ['classes/MfaApiClient', 'functions/helper'] },
|
|
738
|
+
{ group: 'Helpers', pages: ['functions/helper'] },
|
|
739
|
+
{ group: 'Utilities', pages: ['functions/helper'] },
|
|
740
|
+
]);
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
it('fails the build when a page is listed in more than 8 groups', async () => {
|
|
744
|
+
await expect(
|
|
745
|
+
convert({
|
|
746
|
+
...categorized,
|
|
747
|
+
categories: Array.from({ length: 9 }, (_, index) => ({
|
|
748
|
+
title: `Category ${index}`,
|
|
749
|
+
children: [1],
|
|
750
|
+
})),
|
|
751
|
+
})
|
|
752
|
+
).rejects.toThrow('"helper" is listed in more than 8 navigation groups');
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it('fails the build when a declaration name exceeds 512 characters', async () => {
|
|
756
|
+
await expect(
|
|
757
|
+
convert({
|
|
758
|
+
...categorized,
|
|
759
|
+
children: [{ id: 1, name: 'x'.repeat(513), kind: 64, signatures: [] }],
|
|
760
|
+
})
|
|
761
|
+
).rejects.toThrow('exceeds 512 characters');
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
it('expands each namespace once even when ids are repeated across the layout', async () => {
|
|
765
|
+
const depth = 24;
|
|
766
|
+
let child: Record<string, unknown> = {
|
|
767
|
+
id: depth + 1,
|
|
768
|
+
name: 'Leaf',
|
|
769
|
+
kind: 128,
|
|
770
|
+
children: [],
|
|
771
|
+
};
|
|
772
|
+
for (let level = depth; level >= 1; level -= 1) {
|
|
773
|
+
const childId = child.id as number;
|
|
774
|
+
child = {
|
|
775
|
+
id: level,
|
|
776
|
+
name: `Ns${level}`,
|
|
777
|
+
kind: 4,
|
|
778
|
+
children: [child],
|
|
779
|
+
groups: [{ title: 'Namespaces', children: [childId, childId] }],
|
|
780
|
+
categories: [
|
|
781
|
+
{ title: 'A', children: [childId, childId] },
|
|
782
|
+
{ title: 'B', children: [childId] },
|
|
783
|
+
],
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
const reference = await convert({
|
|
787
|
+
id: 0,
|
|
788
|
+
name: '@auth0/example',
|
|
789
|
+
kind: 1,
|
|
790
|
+
children: [child],
|
|
791
|
+
categories: [{ title: 'Root', children: [1, 1] }],
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
const serialized = JSON.stringify(reference.groups);
|
|
795
|
+
expect(serialized.length).toBeLessThan(5_000);
|
|
796
|
+
expect(serialized.match(/Leaf/g)).toHaveLength(2);
|
|
797
|
+
expect(reference.groups).toEqual([
|
|
798
|
+
{
|
|
799
|
+
group: 'Root',
|
|
800
|
+
pages: [expect.objectContaining({ group: 'Ns1' })],
|
|
801
|
+
},
|
|
802
|
+
]);
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
it('nests namespaces that carry their own categories', async () => {
|
|
806
|
+
const reference = await convert({
|
|
807
|
+
id: 0,
|
|
808
|
+
name: '@auth0/example',
|
|
809
|
+
kind: 1,
|
|
810
|
+
children: [
|
|
811
|
+
{
|
|
812
|
+
id: 1,
|
|
813
|
+
name: 'Admin',
|
|
814
|
+
kind: 4,
|
|
815
|
+
children: [
|
|
816
|
+
{ id: 2, name: 'Users', kind: 128, children: [] },
|
|
817
|
+
{ id: 3, name: 'Roles', kind: 128, children: [] },
|
|
818
|
+
],
|
|
819
|
+
groups: [{ title: 'Classes', children: [2, 3] }],
|
|
820
|
+
categories: [
|
|
821
|
+
{ title: 'Identity', children: [2] },
|
|
822
|
+
{ title: 'Access', children: [3] },
|
|
823
|
+
],
|
|
824
|
+
},
|
|
825
|
+
{ id: 4, name: 'Client', kind: 128, children: [] },
|
|
826
|
+
],
|
|
827
|
+
groups: [
|
|
828
|
+
{ title: 'Namespaces', children: [1] },
|
|
829
|
+
{ title: 'Classes', children: [4] },
|
|
830
|
+
],
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
expect(reference.groups).toEqual([
|
|
834
|
+
{
|
|
835
|
+
group: 'Namespaces',
|
|
836
|
+
pages: [
|
|
837
|
+
{
|
|
838
|
+
group: 'Admin',
|
|
839
|
+
pages: [
|
|
840
|
+
{ group: 'Identity', pages: ['Admin/classes/Users'] },
|
|
841
|
+
{ group: 'Access', pages: ['Admin/classes/Roles'] },
|
|
842
|
+
],
|
|
843
|
+
},
|
|
844
|
+
],
|
|
845
|
+
},
|
|
846
|
+
{ group: 'Classes', pages: ['classes/Client'] },
|
|
847
|
+
]);
|
|
848
|
+
});
|
|
849
|
+
});
|
|
238
850
|
});
|