@contractspec/example.video-api-showcase 2.1.0

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.
@@ -0,0 +1,241 @@
1
+ // src/build-api-video.ts
2
+ import { VIDEO_FORMATS } from "@contractspec/lib.video-gen/design/layouts";
3
+ import { resolveRenderConfig } from "@contractspec/lib.video-gen/renderers/config";
4
+ var DEFAULT_FPS = 30;
5
+ var DEFAULT_DURATION_FRAMES = 450;
6
+ function buildApiVideo(spec, options) {
7
+ const fps = options?.fps ?? DEFAULT_FPS;
8
+ const durationInFrames = options?.durationInFrames ?? DEFAULT_DURATION_FRAMES;
9
+ return {
10
+ id: `api-video-${spec.specName.toLowerCase()}-${Date.now().toString(36)}`,
11
+ scenes: [
12
+ {
13
+ id: "scene-api-overview",
14
+ compositionId: "ApiOverview",
15
+ props: {
16
+ specName: spec.specName,
17
+ method: spec.method,
18
+ endpoint: spec.endpoint,
19
+ specCode: spec.specCode,
20
+ generatedOutputs: spec.generatedOutputs,
21
+ tagline: options?.tagline ?? "One spec. Every surface."
22
+ },
23
+ durationInFrames
24
+ }
25
+ ],
26
+ totalDurationInFrames: durationInFrames,
27
+ fps,
28
+ format: VIDEO_FORMATS.landscape
29
+ };
30
+ }
31
+ function buildRenderConfig(outputPath, preset = "standard") {
32
+ return resolveRenderConfig({ outputPath }, preset);
33
+ }
34
+ function buildApiVideoSuite(specs, options) {
35
+ return specs.map((spec) => buildApiVideo(spec, options));
36
+ }
37
+
38
+ // src/docs/video-api-showcase.docblock.ts
39
+ import { registerDocBlocks } from "@contractspec/lib.contracts-spec/docs";
40
+ var blocks = [
41
+ {
42
+ id: "docs.examples.video-api-showcase",
43
+ title: "Video API Showcase (example)",
44
+ summary: "Spec-driven example: build API overview videos directly from contract spec metadata using manual VideoProject construction.",
45
+ kind: "reference",
46
+ visibility: "public",
47
+ route: "/docs/examples/video-api-showcase",
48
+ tags: ["video", "api", "spec-driven", "example"],
49
+ body: `## What this example shows
50
+
51
+ - Manually constructing a \`VideoProject\` from contract spec metadata (name, method, endpoint, code, outputs).
52
+ - Using the \`ApiOverview\` composition to visualize how a spec generates multiple API surfaces.
53
+ - Configuring render settings with quality presets (\`draft\`, \`standard\`, \`high\`).
54
+ - Building video scenes with explicit composition IDs and props.
55
+
56
+ ## Key concepts
57
+
58
+ - **Spec-to-Video**: Contract spec metadata (name, method, endpoint, code snippet) becomes the input props for the \`ApiOverview\` composition.
59
+ - **Manual project construction**: Instead of using \`VideoGenerator\`, this example builds the \`VideoProject\` directly -- useful when you know exactly which composition and props to use.
60
+ - **Render configuration**: Shows how to use \`resolveRenderConfig()\` with quality presets for different output needs.
61
+
62
+ ## Notes
63
+
64
+ - This approach is ideal when the video structure is known ahead of time (e.g., always an API overview).
65
+ - For dynamic scene planning from content briefs, use \`VideoGenerator\` instead (see the video-marketing-clip example).
66
+ `
67
+ },
68
+ {
69
+ id: "docs.examples.video-api-showcase.usage",
70
+ title: "Video API Showcase -- Usage",
71
+ summary: "How to generate API overview videos from contract spec definitions.",
72
+ kind: "usage",
73
+ visibility: "public",
74
+ route: "/docs/examples/video-api-showcase/usage",
75
+ tags: ["video", "api", "usage"],
76
+ body: `## Usage
77
+
78
+ \`\`\`ts
79
+ import { buildApiVideo } from "@contractspec/example.video-api-showcase/build-api-video";
80
+ import { createUserSpec, listTransactionsSpec } from "@contractspec/example.video-api-showcase/sample-specs";
81
+
82
+ // Build a video project for a single API spec
83
+ const project = buildApiVideo(createUserSpec);
84
+
85
+ console.log(project.scenes[0].compositionId); // "ApiOverview"
86
+ console.log(project.format); // { type: "landscape", width: 1920, height: 1080 }
87
+
88
+ // Build with custom duration and tagline
89
+ const custom = buildApiVideo(listTransactionsSpec, {
90
+ durationInFrames: 600,
91
+ tagline: "From spec to production in seconds.",
92
+ });
93
+ \`\`\`
94
+
95
+ ## Guardrails
96
+
97
+ - The \`specCode\` field should be a concise snippet (10-20 lines) for readability in the video.
98
+ - Generated outputs list should contain 3-8 items for optimal visual layout.
99
+ - Tagline should be short (under 40 characters) to fit within the composition frame.
100
+ `
101
+ }
102
+ ];
103
+ registerDocBlocks(blocks);
104
+ // src/example.ts
105
+ import { defineExample } from "@contractspec/lib.contracts-spec";
106
+ var example = defineExample({
107
+ meta: {
108
+ key: "video-api-showcase",
109
+ version: "1.0.0",
110
+ title: "Video API Showcase",
111
+ description: "Generate API documentation videos from contract spec definitions using the ApiOverview composition.",
112
+ kind: "script",
113
+ visibility: "public",
114
+ stability: "experimental",
115
+ owners: ["@platform.core"],
116
+ tags: ["video", "api", "documentation", "spec-driven"]
117
+ },
118
+ docs: {
119
+ rootDocId: "docs.examples.video-api-showcase",
120
+ usageDocId: "docs.examples.video-api-showcase.usage"
121
+ },
122
+ entrypoints: {
123
+ packageName: "@contractspec/example.video-api-showcase",
124
+ docs: "./docs"
125
+ },
126
+ surfaces: {
127
+ templates: true,
128
+ sandbox: { enabled: true, modes: ["markdown"] },
129
+ studio: { enabled: true, installable: true },
130
+ mcp: { enabled: true }
131
+ }
132
+ });
133
+ var example_default = example;
134
+
135
+ // src/sample-specs.ts
136
+ var createUserSpec = {
137
+ specName: "CreateUser",
138
+ method: "POST",
139
+ endpoint: "/api/users",
140
+ specCode: `export const createUser = defineCommand({
141
+ meta: {
142
+ name: "CreateUser",
143
+ version: "1.0.0",
144
+ stability: "Stable",
145
+ },
146
+ io: {
147
+ input: z.object({
148
+ email: z.string().email(),
149
+ name: z.string(),
150
+ role: z.enum(["admin", "user"]),
151
+ }),
152
+ output: z.object({
153
+ id: z.string().uuid(),
154
+ email: z.string(),
155
+ createdAt: z.date(),
156
+ }),
157
+ },
158
+ });`,
159
+ generatedOutputs: [
160
+ "REST Endpoint",
161
+ "GraphQL Mutation",
162
+ "Prisma Model",
163
+ "TypeScript SDK",
164
+ "MCP Tool",
165
+ "OpenAPI Spec"
166
+ ]
167
+ };
168
+ var listTransactionsSpec = {
169
+ specName: "ListTransactions",
170
+ method: "GET",
171
+ endpoint: "/api/transactions",
172
+ specCode: `export const listTransactions = defineQuery({
173
+ meta: {
174
+ name: "ListTransactions",
175
+ version: "1.0.0",
176
+ stability: "Stable",
177
+ },
178
+ io: {
179
+ input: z.object({
180
+ accountId: z.string().uuid(),
181
+ from: z.date().optional(),
182
+ to: z.date().optional(),
183
+ limit: z.number().default(50),
184
+ }),
185
+ output: z.object({
186
+ transactions: z.array(transactionSchema),
187
+ total: z.number(),
188
+ hasMore: z.boolean(),
189
+ }),
190
+ },
191
+ });`,
192
+ generatedOutputs: [
193
+ "REST Endpoint",
194
+ "GraphQL Query",
195
+ "Prisma Query",
196
+ "TypeScript SDK",
197
+ "OpenAPI Spec"
198
+ ]
199
+ };
200
+ var sendNotificationSpec = {
201
+ specName: "SendNotification",
202
+ method: "POST",
203
+ endpoint: "/api/notifications",
204
+ specCode: `export const sendNotification = defineCommand({
205
+ meta: {
206
+ name: "SendNotification",
207
+ version: "1.0.0",
208
+ stability: "Beta",
209
+ },
210
+ io: {
211
+ input: z.object({
212
+ userId: z.string().uuid(),
213
+ channel: z.enum(["push", "email", "sms"]),
214
+ title: z.string(),
215
+ body: z.string(),
216
+ }),
217
+ output: z.object({
218
+ notificationId: z.string().uuid(),
219
+ deliveredAt: z.date().nullable(),
220
+ status: z.enum(["sent", "failed", "queued"]),
221
+ }),
222
+ },
223
+ });`,
224
+ generatedOutputs: [
225
+ "REST Endpoint",
226
+ "GraphQL Mutation",
227
+ "TypeScript SDK",
228
+ "MCP Tool",
229
+ "OpenAPI Spec",
230
+ "Event Schema"
231
+ ]
232
+ };
233
+ export {
234
+ sendNotificationSpec,
235
+ listTransactionsSpec,
236
+ example_default as example,
237
+ createUserSpec,
238
+ buildRenderConfig,
239
+ buildApiVideoSuite,
240
+ buildApiVideo
241
+ };
@@ -0,0 +1,103 @@
1
+ // src/sample-specs.ts
2
+ var createUserSpec = {
3
+ specName: "CreateUser",
4
+ method: "POST",
5
+ endpoint: "/api/users",
6
+ specCode: `export const createUser = defineCommand({
7
+ meta: {
8
+ name: "CreateUser",
9
+ version: "1.0.0",
10
+ stability: "Stable",
11
+ },
12
+ io: {
13
+ input: z.object({
14
+ email: z.string().email(),
15
+ name: z.string(),
16
+ role: z.enum(["admin", "user"]),
17
+ }),
18
+ output: z.object({
19
+ id: z.string().uuid(),
20
+ email: z.string(),
21
+ createdAt: z.date(),
22
+ }),
23
+ },
24
+ });`,
25
+ generatedOutputs: [
26
+ "REST Endpoint",
27
+ "GraphQL Mutation",
28
+ "Prisma Model",
29
+ "TypeScript SDK",
30
+ "MCP Tool",
31
+ "OpenAPI Spec"
32
+ ]
33
+ };
34
+ var listTransactionsSpec = {
35
+ specName: "ListTransactions",
36
+ method: "GET",
37
+ endpoint: "/api/transactions",
38
+ specCode: `export const listTransactions = defineQuery({
39
+ meta: {
40
+ name: "ListTransactions",
41
+ version: "1.0.0",
42
+ stability: "Stable",
43
+ },
44
+ io: {
45
+ input: z.object({
46
+ accountId: z.string().uuid(),
47
+ from: z.date().optional(),
48
+ to: z.date().optional(),
49
+ limit: z.number().default(50),
50
+ }),
51
+ output: z.object({
52
+ transactions: z.array(transactionSchema),
53
+ total: z.number(),
54
+ hasMore: z.boolean(),
55
+ }),
56
+ },
57
+ });`,
58
+ generatedOutputs: [
59
+ "REST Endpoint",
60
+ "GraphQL Query",
61
+ "Prisma Query",
62
+ "TypeScript SDK",
63
+ "OpenAPI Spec"
64
+ ]
65
+ };
66
+ var sendNotificationSpec = {
67
+ specName: "SendNotification",
68
+ method: "POST",
69
+ endpoint: "/api/notifications",
70
+ specCode: `export const sendNotification = defineCommand({
71
+ meta: {
72
+ name: "SendNotification",
73
+ version: "1.0.0",
74
+ stability: "Beta",
75
+ },
76
+ io: {
77
+ input: z.object({
78
+ userId: z.string().uuid(),
79
+ channel: z.enum(["push", "email", "sms"]),
80
+ title: z.string(),
81
+ body: z.string(),
82
+ }),
83
+ output: z.object({
84
+ notificationId: z.string().uuid(),
85
+ deliveredAt: z.date().nullable(),
86
+ status: z.enum(["sent", "failed", "queued"]),
87
+ }),
88
+ },
89
+ });`,
90
+ generatedOutputs: [
91
+ "REST Endpoint",
92
+ "GraphQL Mutation",
93
+ "TypeScript SDK",
94
+ "MCP Tool",
95
+ "OpenAPI Spec",
96
+ "Event Schema"
97
+ ]
98
+ };
99
+ export {
100
+ sendNotificationSpec,
101
+ listTransactionsSpec,
102
+ createUserSpec
103
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Spec metadata used to build API overview videos.
3
+ * Maps directly to ApiOverviewProps.
4
+ */
5
+ export interface ApiSpecDefinition {
6
+ /** Contract spec name (e.g., "CreateUser") */
7
+ specName: string;
8
+ /** HTTP method */
9
+ method: string;
10
+ /** Endpoint path */
11
+ endpoint: string;
12
+ /** Contract spec code snippet */
13
+ specCode: string;
14
+ /** Generated output surfaces */
15
+ generatedOutputs: string[];
16
+ }
17
+ /**
18
+ * CreateUser -- user registration endpoint.
19
+ */
20
+ export declare const createUserSpec: ApiSpecDefinition;
21
+ /**
22
+ * ListTransactions -- financial transaction listing.
23
+ */
24
+ export declare const listTransactionsSpec: ApiSpecDefinition;
25
+ /**
26
+ * SendNotification -- push notification dispatch.
27
+ */
28
+ export declare const sendNotificationSpec: ApiSpecDefinition;
@@ -0,0 +1,104 @@
1
+ // @bun
2
+ // src/sample-specs.ts
3
+ var createUserSpec = {
4
+ specName: "CreateUser",
5
+ method: "POST",
6
+ endpoint: "/api/users",
7
+ specCode: `export const createUser = defineCommand({
8
+ meta: {
9
+ name: "CreateUser",
10
+ version: "1.0.0",
11
+ stability: "Stable",
12
+ },
13
+ io: {
14
+ input: z.object({
15
+ email: z.string().email(),
16
+ name: z.string(),
17
+ role: z.enum(["admin", "user"]),
18
+ }),
19
+ output: z.object({
20
+ id: z.string().uuid(),
21
+ email: z.string(),
22
+ createdAt: z.date(),
23
+ }),
24
+ },
25
+ });`,
26
+ generatedOutputs: [
27
+ "REST Endpoint",
28
+ "GraphQL Mutation",
29
+ "Prisma Model",
30
+ "TypeScript SDK",
31
+ "MCP Tool",
32
+ "OpenAPI Spec"
33
+ ]
34
+ };
35
+ var listTransactionsSpec = {
36
+ specName: "ListTransactions",
37
+ method: "GET",
38
+ endpoint: "/api/transactions",
39
+ specCode: `export const listTransactions = defineQuery({
40
+ meta: {
41
+ name: "ListTransactions",
42
+ version: "1.0.0",
43
+ stability: "Stable",
44
+ },
45
+ io: {
46
+ input: z.object({
47
+ accountId: z.string().uuid(),
48
+ from: z.date().optional(),
49
+ to: z.date().optional(),
50
+ limit: z.number().default(50),
51
+ }),
52
+ output: z.object({
53
+ transactions: z.array(transactionSchema),
54
+ total: z.number(),
55
+ hasMore: z.boolean(),
56
+ }),
57
+ },
58
+ });`,
59
+ generatedOutputs: [
60
+ "REST Endpoint",
61
+ "GraphQL Query",
62
+ "Prisma Query",
63
+ "TypeScript SDK",
64
+ "OpenAPI Spec"
65
+ ]
66
+ };
67
+ var sendNotificationSpec = {
68
+ specName: "SendNotification",
69
+ method: "POST",
70
+ endpoint: "/api/notifications",
71
+ specCode: `export const sendNotification = defineCommand({
72
+ meta: {
73
+ name: "SendNotification",
74
+ version: "1.0.0",
75
+ stability: "Beta",
76
+ },
77
+ io: {
78
+ input: z.object({
79
+ userId: z.string().uuid(),
80
+ channel: z.enum(["push", "email", "sms"]),
81
+ title: z.string(),
82
+ body: z.string(),
83
+ }),
84
+ output: z.object({
85
+ notificationId: z.string().uuid(),
86
+ deliveredAt: z.date().nullable(),
87
+ status: z.enum(["sent", "failed", "queued"]),
88
+ }),
89
+ },
90
+ });`,
91
+ generatedOutputs: [
92
+ "REST Endpoint",
93
+ "GraphQL Mutation",
94
+ "TypeScript SDK",
95
+ "MCP Tool",
96
+ "OpenAPI Spec",
97
+ "Event Schema"
98
+ ]
99
+ };
100
+ export {
101
+ sendNotificationSpec,
102
+ listTransactionsSpec,
103
+ createUserSpec
104
+ };
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "@contractspec/example.video-api-showcase",
3
+ "version": "2.1.0",
4
+ "description": "Generate API documentation videos from contract spec definitions using the ApiOverview composition.",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "bun": "./dist/index.js",
11
+ "node": "./dist/node/index.js",
12
+ "browser": "./dist/browser/index.js",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./build-api-video": {
16
+ "types": "./dist/build-api-video.d.ts",
17
+ "bun": "./dist/build-api-video.js",
18
+ "node": "./dist/node/build-api-video.js",
19
+ "browser": "./dist/browser/build-api-video.js",
20
+ "default": "./dist/build-api-video.js"
21
+ },
22
+ "./docs": {
23
+ "types": "./dist/docs/index.d.ts",
24
+ "bun": "./dist/docs/index.js",
25
+ "node": "./dist/node/docs/index.js",
26
+ "browser": "./dist/browser/docs/index.js",
27
+ "default": "./dist/docs/index.js"
28
+ },
29
+ "./docs/index": {
30
+ "types": "./dist/docs/index.d.ts",
31
+ "bun": "./dist/docs/index.js",
32
+ "node": "./dist/node/docs/index.js",
33
+ "browser": "./dist/browser/docs/index.js",
34
+ "default": "./dist/docs/index.js"
35
+ },
36
+ "./docs/video-api-showcase.docblock": {
37
+ "types": "./dist/docs/video-api-showcase.docblock.d.ts",
38
+ "bun": "./dist/docs/video-api-showcase.docblock.js",
39
+ "node": "./dist/node/docs/video-api-showcase.docblock.js",
40
+ "browser": "./dist/browser/docs/video-api-showcase.docblock.js",
41
+ "default": "./dist/docs/video-api-showcase.docblock.js"
42
+ },
43
+ "./example": {
44
+ "types": "./dist/example.d.ts",
45
+ "bun": "./dist/example.js",
46
+ "node": "./dist/node/example.js",
47
+ "browser": "./dist/browser/example.js",
48
+ "default": "./dist/example.js"
49
+ },
50
+ "./sample-specs": {
51
+ "types": "./dist/sample-specs.d.ts",
52
+ "bun": "./dist/sample-specs.js",
53
+ "node": "./dist/node/sample-specs.js",
54
+ "browser": "./dist/browser/sample-specs.js",
55
+ "default": "./dist/sample-specs.js"
56
+ }
57
+ },
58
+ "scripts": {
59
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
60
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
61
+ "build": "bun run prebuild && bun run build:bundle && bun run build:types",
62
+ "build:bundle": "contractspec-bun-build transpile",
63
+ "build:types": "contractspec-bun-build types",
64
+ "dev": "contractspec-bun-build dev",
65
+ "clean": "rimraf dist .turbo",
66
+ "lint": "bun lint:fix",
67
+ "lint:fix": "eslint src --fix",
68
+ "lint:check": "eslint src",
69
+ "test": "bun test --pass-with-no-tests",
70
+ "prebuild": "contractspec-bun-build prebuild",
71
+ "typecheck": "tsc --noEmit"
72
+ },
73
+ "dependencies": {
74
+ "@contractspec/lib.contracts-spec": "2.1.1",
75
+ "@contractspec/lib.contracts-integrations": "2.1.1",
76
+ "@contractspec/lib.video-gen": "1.42.1"
77
+ },
78
+ "devDependencies": {
79
+ "@contractspec/tool.typescript": "2.1.0",
80
+ "@contractspec/tool.bun": "2.1.0",
81
+ "typescript": "^5.9.3"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public",
85
+ "exports": {
86
+ ".": {
87
+ "types": "./dist/index.d.ts",
88
+ "bun": "./dist/index.js",
89
+ "node": "./dist/node/index.js",
90
+ "browser": "./dist/browser/index.js",
91
+ "default": "./dist/index.js"
92
+ },
93
+ "./build-api-video": {
94
+ "types": "./dist/build-api-video.d.ts",
95
+ "bun": "./dist/build-api-video.js",
96
+ "node": "./dist/node/build-api-video.js",
97
+ "browser": "./dist/browser/build-api-video.js",
98
+ "default": "./dist/build-api-video.js"
99
+ },
100
+ "./docs": {
101
+ "types": "./dist/docs/index.d.ts",
102
+ "bun": "./dist/docs/index.js",
103
+ "node": "./dist/node/docs/index.js",
104
+ "browser": "./dist/browser/docs/index.js",
105
+ "default": "./dist/docs/index.js"
106
+ },
107
+ "./docs/index": {
108
+ "types": "./dist/docs/index.d.ts",
109
+ "bun": "./dist/docs/index.js",
110
+ "node": "./dist/node/docs/index.js",
111
+ "browser": "./dist/browser/docs/index.js",
112
+ "default": "./dist/docs/index.js"
113
+ },
114
+ "./docs/video-api-showcase.docblock": {
115
+ "types": "./dist/docs/video-api-showcase.docblock.d.ts",
116
+ "bun": "./dist/docs/video-api-showcase.docblock.js",
117
+ "node": "./dist/node/docs/video-api-showcase.docblock.js",
118
+ "browser": "./dist/browser/docs/video-api-showcase.docblock.js",
119
+ "default": "./dist/docs/video-api-showcase.docblock.js"
120
+ },
121
+ "./example": {
122
+ "types": "./dist/example.d.ts",
123
+ "bun": "./dist/example.js",
124
+ "node": "./dist/node/example.js",
125
+ "browser": "./dist/browser/example.js",
126
+ "default": "./dist/example.js"
127
+ },
128
+ "./sample-specs": {
129
+ "types": "./dist/sample-specs.d.ts",
130
+ "bun": "./dist/sample-specs.js",
131
+ "node": "./dist/node/sample-specs.js",
132
+ "browser": "./dist/browser/sample-specs.js",
133
+ "default": "./dist/sample-specs.js"
134
+ }
135
+ },
136
+ "registry": "https://registry.npmjs.org/"
137
+ },
138
+ "license": "MIT",
139
+ "repository": {
140
+ "type": "git",
141
+ "url": "https://github.com/lssm-tech/contractspec.git",
142
+ "directory": "packages/examples/video-api-showcase"
143
+ },
144
+ "homepage": "https://contractspec.io"
145
+ }