Skip to content

Commit 59d274a

Browse files
committed
Use blueprint from smith
1 parent 3601b11 commit 59d274a

10 files changed

Lines changed: 656 additions & 128 deletions

File tree

package-lock.json

Lines changed: 616 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,16 @@
3232
"@metalsmith/metadata": "^0.3.0",
3333
"@prettier/plugin-php": "^0.22.2",
3434
"@prettier/plugin-ruby": "^4.0.4",
35-
"@seamapi/blueprint": "^0.43.1",
36-
"@seamapi/smith": "^0.3.3",
37-
"@seamapi/types": "1.399.1",
35+
"@seamapi/types": "^1.402.0",
3836
"change-case": "^5.4.4",
3937
"command-exists": "^1.2.9",
4038
"execa": "^9.3.1",
4139
"prettier": "^3.0.0",
4240
"zod": "^3.23.8"
4341
},
4442
"devDependencies": {
45-
"@types/command-exists": "^1.2.3",
46-
"@types/debug": "^4.1.12",
47-
"@types/micromatch": "^4.0.9"
43+
"@seamapi/blueprint": "^0.43.2",
44+
"@seamapi/smith": "^0.4.3",
45+
"@types/command-exists": "^1.2.3"
4846
}
4947
}

src/lib/blueprint.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as customHelpers from './handlebars-helpers.js'
44

55
export const helpers = { ...handlebarsHelpers, ...customHelpers }
66

7-
export * from './blueprint.js'
7+
export * from './format-code.js'
88
export * from './postprocess.js'
99
export * from './reference.js'
1010
export * from './report.js'

src/lib/layout/api-endpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type {
22
ActionAttempt,
3+
CodeSample,
34
Endpoint,
45
Parameter,
56
SdkName,
67
SeamAuthMethod,
78
SeamWorkspaceScope,
89
} from '@seamapi/blueprint'
9-
import type { CodeSample } from 'node_modules/@seamapi/blueprint/dist/index.cjs'
1010

1111
import {
1212
type ApiRouteResource,

src/lib/layout/api-namespace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Blueprint } from '@seamapi/blueprint'
22

3-
import type { PathMetadata } from 'lib/path-metadata.js'
3+
import type { PathMetadata } from '../path-metadata.js'
44

55
export interface ApiNamespaceLayoutContext {
66
title: string

src/lib/layout/api-route.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ import type {
44
Endpoint,
55
EnumProperty,
66
Property,
7+
ResourceSample,
78
Route,
8-
} from '@seamapi/blueprint'
9-
import { pascalCase } from 'change-case'
10-
import type {
119
SdkName,
1210
SyntaxName,
13-
} from 'node_modules/@seamapi/blueprint/dist/index.cjs'
14-
import type { ResourceSample } from 'node_modules/@seamapi/blueprint/lib/samples/resource-sample.js'
11+
} from '@seamapi/blueprint'
12+
import { pascalCase } from 'change-case'
1513

16-
import type { PathMetadata } from 'lib/path-metadata.js'
14+
import type { PathMetadata } from '../path-metadata.js'
1715

1816
export interface ApiRouteLayoutContext {
1917
title: string

src/lib/reference.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
} from './layout/index.js'
1212
import { PathMetadataSchema } from './path-metadata.js'
1313

14-
type Metadata = Partial<Pick<Blueprint, 'routes' | 'resources'>>
14+
interface Metadata {
15+
blueprint: Blueprint
16+
pathMetadata: unknown
17+
}
1518

1619
type File = ApiEndpointLayoutContext &
1720
ApiRouteLayoutContext &
@@ -32,15 +35,7 @@ export const reference = (
3235
? PathMetadataSchema.parse(metadata.pathMetadata)
3336
: {}
3437

35-
const blueprint: Blueprint = {
36-
title: '',
37-
routes: [],
38-
resources: {},
39-
events: [],
40-
actionAttempts: [],
41-
pagination: null,
42-
...metadata,
43-
}
38+
const { blueprint } = metadata
4439

4540
const namespacePaths = getNamespacePaths(blueprint.routes)
4641
for (const path of namespacePaths) {

src/lib/report.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,16 @@ interface ParameterReportItem {
5050
params: ReportItem[]
5151
}
5252

53-
type Metadata = Partial<Pick<Blueprint, 'routes' | 'resources'>>
53+
interface Metadata {
54+
blueprint: Pick<Blueprint, 'routes' | 'resources'>
55+
pathMetadata: unknown
56+
}
5457

5558
export const report = (
5659
files: Metalsmith.Files,
5760
metalsmith: Metalsmith,
5861
): void => {
59-
const metadata = {
60-
title: '',
61-
routes: [],
62-
resources: {},
63-
...(metalsmith.metadata() as Metadata),
64-
}
62+
const metadata = metalsmith.metadata() as Metadata
6563

6664
const reportData = generateReport(metadata)
6765

@@ -70,9 +68,15 @@ export const report = (
7068
layout: 'report.hbs',
7169
...reportData,
7270
}
71+
72+
files['api/_blueprint.json'] = {
73+
contents: Buffer.from(JSON.stringify(metadata.blueprint, null, 2)),
74+
layout: 'default.hbs',
75+
}
7376
}
7477

7578
function generateReport(metadata: Metadata): Report {
79+
const { blueprint } = metadata
7680
const report: Report = {
7781
undocumented: createEmptyReportSection(),
7882
noDescription: { ...createEmptyReportSection(), resources: [] },
@@ -87,12 +91,12 @@ function generateReport(metadata: Metadata): Report {
8791
},
8892
}
8993

90-
const resources = metadata.resources ?? {}
94+
const resources = blueprint.resources ?? {}
9195
for (const [resourceName, resource] of Object.entries(resources)) {
9296
processResource(resourceName, resource, report)
9397
}
9498

95-
const routes = metadata.routes ?? []
99+
const routes = blueprint.routes ?? []
96100
for (const route of routes) {
97101
processRoute(route, report, metadata)
98102
}

src/metalsmith.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { dirname } from 'node:path'
22
import { env } from 'node:process'
33
import { fileURLToPath } from 'node:url'
44

5-
import * as types from '@seamapi/types/connect'
65
import layouts from '@metalsmith/layouts'
76
import metadata from '@metalsmith/metadata'
8-
import { getHandlebarsPartials } from '@seamapi/smith'
7+
import { blueprint, getHandlebarsPartials } from '@seamapi/smith'
8+
import * as types from '@seamapi/types/connect'
99
import { deleteAsync } from 'del'
1010
import Metalsmith from 'metalsmith'
1111

1212
import {
13-
blueprint,
13+
formatCode,
1414
helpers,
1515
postprocess,
1616
reference,
@@ -34,12 +34,19 @@ Metalsmith(rootDir)
3434
pathMetadata: './data/paths.yaml',
3535
}),
3636
)
37-
.use(blueprint({ types, skipCodeFormat: env['SKIP_CODE_FORMAT'] != null }))
37+
.use(
38+
blueprint({
39+
types,
40+
formatCode,
41+
skipCodeFormat: env['SKIP_CODE_FORMAT'] != null,
42+
}),
43+
)
3844
.use(reference)
3945
.use(report)
4046
.use(
4147
layouts({
4248
default: 'default.hbs',
49+
transform: 'handlebars',
4350
engineOptions: {
4451
noEscape: true,
4552
helpers,

0 commit comments

Comments
 (0)