contentbase 0.0.4 → 0.0.6

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.
Files changed (82) hide show
  1. package/package.json +3 -2
  2. package/.mcp.json +0 -9
  3. package/MCP-DESCRIPTIONS-REVIEW.md +0 -122
  4. package/bun.lock +0 -512
  5. package/dist/cnotes +0 -0
  6. package/examples/sdlc-queries.ts +0 -161
  7. package/public/web-demo/index.html +0 -813
  8. package/scripts/examples/01-collection-setup.ts +0 -46
  9. package/scripts/examples/02-querying.ts +0 -67
  10. package/scripts/examples/03-sections.ts +0 -36
  11. package/scripts/examples/04-relationships.ts +0 -54
  12. package/scripts/examples/05-document-api.ts +0 -54
  13. package/scripts/examples/06-extract-sections.ts +0 -55
  14. package/scripts/examples/07-validation.ts +0 -46
  15. package/scripts/examples/08-serialization.ts +0 -51
  16. package/scripts/examples/lib/format.ts +0 -87
  17. package/scripts/examples/lib/setup.ts +0 -21
  18. package/scripts/examples/run-all.ts +0 -43
  19. package/showcases/national-parks/models.ts +0 -74
  20. package/showcases/national-parks/parks/acadia.mdx +0 -40
  21. package/showcases/national-parks/parks/yosemite.mdx +0 -44
  22. package/showcases/national-parks/parks/zion.mdx +0 -44
  23. package/showcases/national-parks/queries.ts +0 -103
  24. package/showcases/national-parks/trails/angels-landing.mdx +0 -19
  25. package/showcases/national-parks/trails/cathedral-lakes.mdx +0 -19
  26. package/showcases/national-parks/trails/half-dome.mdx +0 -19
  27. package/showcases/national-parks/trails/jordan-pond-path.mdx +0 -19
  28. package/showcases/national-parks/trails/mist-trail.mdx +0 -19
  29. package/showcases/national-parks/trails/observation-point.mdx +0 -19
  30. package/showcases/national-parks/trails/precipice-trail.mdx +0 -19
  31. package/showcases/national-parks/trails/the-narrows.mdx +0 -19
  32. package/showcases/node_modules/.cache/.repl_history +0 -3
  33. package/showcases/recipes/cuisines/chinese.mdx +0 -28
  34. package/showcases/recipes/cuisines/italian.mdx +0 -32
  35. package/showcases/recipes/cuisines/mexican.mdx +0 -28
  36. package/showcases/recipes/models.ts +0 -77
  37. package/showcases/recipes/queries.ts +0 -89
  38. package/showcases/recipes/recipes/chinese/egg-fried-rice.mdx +0 -43
  39. package/showcases/recipes/recipes/chinese/mapo-tofu.mdx +0 -47
  40. package/showcases/recipes/recipes/italian/bruschetta.mdx +0 -38
  41. package/showcases/recipes/recipes/italian/cacio-e-pepe.mdx +0 -39
  42. package/showcases/recipes/recipes/italian/tiramisu.mdx +0 -43
  43. package/showcases/recipes/recipes/mexican/chicken-tinga.mdx +0 -44
  44. package/showcases/recipes/recipes/mexican/guacamole.mdx +0 -39
  45. package/showcases/vinyl-collection/albums/bitches-brew.mdx +0 -36
  46. package/showcases/vinyl-collection/albums/i-put-a-spell-on-you.mdx +0 -35
  47. package/showcases/vinyl-collection/albums/in-rainbows.mdx +0 -35
  48. package/showcases/vinyl-collection/albums/kind-of-blue.mdx +0 -32
  49. package/showcases/vinyl-collection/albums/ok-computer.mdx +0 -37
  50. package/showcases/vinyl-collection/albums/wild-is-the-wind.mdx +0 -35
  51. package/showcases/vinyl-collection/artists/miles-davis.mdx +0 -27
  52. package/showcases/vinyl-collection/artists/nina-simone.mdx +0 -26
  53. package/showcases/vinyl-collection/artists/radiohead.mdx +0 -27
  54. package/showcases/vinyl-collection/models.ts +0 -73
  55. package/showcases/vinyl-collection/queries.ts +0 -87
  56. package/src/__tests__/semantic-search.integration.test.ts +0 -284
  57. package/test/ast-query.test.ts +0 -128
  58. package/test/collection.test.ts +0 -215
  59. package/test/define-model.test.ts +0 -78
  60. package/test/document.test.ts +0 -225
  61. package/test/extract-sections.test.ts +0 -356
  62. package/test/fixtures/sdlc/MODELS.md +0 -106
  63. package/test/fixtures/sdlc/SKILL.md +0 -404
  64. package/test/fixtures/sdlc/epics/authentication.mdx +0 -42
  65. package/test/fixtures/sdlc/epics/searching-and-browsing.mdx +0 -21
  66. package/test/fixtures/sdlc/index.ts +0 -9
  67. package/test/fixtures/sdlc/models.ts +0 -91
  68. package/test/fixtures/sdlc/stories/authentication/a-user-should-be-able-to-login.mdx +0 -20
  69. package/test/fixtures/sdlc/stories/authentication/a-user-should-be-able-to-register.mdx +0 -20
  70. package/test/fixtures/sdlc/templates/epic.md +0 -23
  71. package/test/fixtures/sdlc/templates/story.md +0 -19
  72. package/test/helpers.ts +0 -21
  73. package/test/model-instance.test.ts +0 -197
  74. package/test/pattern.test.ts +0 -191
  75. package/test/query-dsl.test.ts +0 -431
  76. package/test/query.test.ts +0 -196
  77. package/test/relationships.test.ts +0 -214
  78. package/test/section.test.ts +0 -160
  79. package/test/table-of-contents.test.ts +0 -135
  80. package/test/validator.test.ts +0 -62
  81. package/tsconfig.json +0 -18
  82. package/vitest.config.ts +0 -11
@@ -1,161 +0,0 @@
1
- /**
2
- * Contentbase Example: Querying an SDLC Content Collection
3
- *
4
- * This script demonstrates loading a collection of Epics and Stories
5
- * from markdown files and querying them using the Contentbase API.
6
- *
7
- * Run with: bun run examples/sdlc-queries.ts
8
- */
9
- import path from "path";
10
- import { fileURLToPath } from "url";
11
- import { Collection, type InferModelInstance } from "../src/index";
12
- import { Epic, Story, type StoryDef } from "../test/fixtures/sdlc/models";
13
-
14
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
- const basePath = path.resolve(__dirname, "../test/fixtures/sdlc");
16
-
17
- async function main() {
18
- // 1. Create and load the collection
19
- const collection = new Collection({
20
- rootPath: basePath,
21
- name: "sdlc",
22
- });
23
-
24
- collection.register(Epic);
25
- collection.register(Story);
26
- await collection.load();
27
-
28
- console.log("Available documents:", collection.available);
29
-
30
- // -------------------------------------------------------
31
- // 2. Get a single model instance by path ID
32
- // -------------------------------------------------------
33
- const authEpic = collection.getModel("epics/authentication", Epic);
34
-
35
- console.log("\n--- Epic: Authentication ---");
36
- console.log("Title:", authEpic.title);
37
- console.log("Slug:", authEpic.slug);
38
- console.log("Status:", authEpic.meta.status);
39
- console.log("Priority:", authEpic.meta.priority);
40
- console.log("Is complete?", authEpic.computed.isComplete);
41
-
42
- // -------------------------------------------------------
43
- // 3. Query all epics
44
- // -------------------------------------------------------
45
- const allEpics = await collection.query(Epic).fetchAll();
46
-
47
- console.log("\n--- All Epics ---");
48
- for (const epic of allEpics) {
49
- console.log(` ${epic.title} (${epic.meta.status})`);
50
- }
51
-
52
- // -------------------------------------------------------
53
- // 4. Filter with where clauses
54
- // -------------------------------------------------------
55
- const highPriority = await collection
56
- .query(Epic)
57
- .where("meta.priority", "high")
58
- .fetchAll();
59
-
60
- console.log("\n--- High Priority Epics ---");
61
- for (const epic of highPriority) {
62
- console.log(` ${epic.title} — priority: ${epic.meta.priority}`);
63
- }
64
-
65
- // -------------------------------------------------------
66
- // 5. Query helpers: first, last, count
67
- // -------------------------------------------------------
68
- const firstEpic = await collection.query(Epic).first();
69
- const lastEpic = await collection.query(Epic).last();
70
- const epicCount = await collection.query(Epic).count();
71
-
72
- console.log("\n--- Query Helpers ---");
73
- console.log("First epic:", firstEpic?.title);
74
- console.log("Last epic:", lastEpic?.title);
75
- console.log("Total epics:", epicCount);
76
-
77
- // -------------------------------------------------------
78
- // 6. Chained where clauses (AND logic)
79
- // -------------------------------------------------------
80
- const filtered = await collection
81
- .query(Epic)
82
- .where("meta.status", "created")
83
- .whereExists("meta.priority")
84
- .fetchAll();
85
-
86
- console.log("\n--- Created Epics with Priority Set ---");
87
- for (const epic of filtered) {
88
- console.log(` ${epic.title} — ${epic.meta.priority}`);
89
- }
90
-
91
- // -------------------------------------------------------
92
- // 7. HasMany relationships — Epic -> Stories
93
- // -------------------------------------------------------
94
- const stories = authEpic.relationships.stories.fetchAll();
95
-
96
- console.log("\n--- Stories under Authentication Epic ---");
97
- for (const story of stories) {
98
- console.log(` ${story.title}`);
99
- }
100
-
101
- console.log("First story:", authEpic.relationships.stories.first()?.title);
102
- console.log("Last story:", authEpic.relationships.stories.last()?.title);
103
-
104
- // -------------------------------------------------------
105
- // 8. BelongsTo relationships — Story -> Epic
106
- // -------------------------------------------------------
107
- const registerStory: InferModelInstance<StoryDef> = collection.getModel(
108
- "stories/authentication/a-user-should-be-able-to-register",
109
- Story
110
- );
111
-
112
- const parentEpic = registerStory.relationships.epic.fetch();
113
-
114
- console.log("\n--- Story -> Epic (belongsTo) ---");
115
- console.log(`"${registerStory.title}" belongs to "${parentEpic.title}"`);
116
-
117
- // -------------------------------------------------------
118
- // 9. Sections — structured data extracted from headings
119
- // -------------------------------------------------------
120
- console.log("\n--- Sections: Acceptance Criteria ---");
121
- for (const criterion of registerStory.sections.acceptanceCriteria) {
122
- console.log(` • ${criterion}`);
123
- }
124
-
125
- console.log("\n--- Sections: Mockups ---");
126
- for (const [label, url] of Object.entries(registerStory.sections.mockups)) {
127
- console.log(` ${label}: ${url}`);
128
- }
129
-
130
- // -------------------------------------------------------
131
- // 10. Validation
132
- // -------------------------------------------------------
133
- const result = await registerStory.validate();
134
-
135
- console.log("\n--- Validation ---");
136
- console.log("Valid?", result.valid);
137
- console.log("Error count:", result.errors.length);
138
-
139
- // -------------------------------------------------------
140
- // 11. Serialization
141
- // -------------------------------------------------------
142
- const json = authEpic.toJSON({
143
- computed: ["isComplete"],
144
- related: ["stories"],
145
- });
146
-
147
- console.log("\n--- toJSON ---");
148
- console.log(JSON.stringify(json, null, 2));
149
-
150
- // -------------------------------------------------------
151
- // 12. Working with the raw Document
152
- // -------------------------------------------------------
153
- const doc = authEpic.document;
154
-
155
- console.log("\n--- Raw Document ---");
156
- console.log("Headings:", doc.nodes.headings.length);
157
- console.log("Links:", doc.nodes.links.length);
158
- console.log("Lists:", doc.nodes.lists.length);
159
- }
160
-
161
- main().catch(console.error);