@geenius/docs 0.1.0 → 0.4.1

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 (158) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +53 -1
  3. package/package.json +101 -13
  4. package/packages/convex/dist/index.d.ts +503 -0
  5. package/packages/convex/dist/index.js +482 -0
  6. package/packages/convex/dist/index.js.map +1 -0
  7. package/packages/react/dist/index.d.ts +439 -0
  8. package/packages/react/dist/index.js +4954 -0
  9. package/packages/react/dist/index.js.map +1 -0
  10. package/packages/react-css/{src/styles.css → dist/index.css} +183 -223
  11. package/packages/react-css/dist/index.css.map +1 -0
  12. package/packages/react-css/dist/index.d.ts +443 -0
  13. package/packages/react-css/dist/index.js +5058 -0
  14. package/packages/react-css/dist/index.js.map +1 -0
  15. package/packages/shared/dist/index.d.ts +684 -0
  16. package/packages/shared/dist/index.js +788 -0
  17. package/packages/shared/dist/index.js.map +1 -0
  18. package/packages/solidjs/dist/index.d.ts +435 -0
  19. package/packages/solidjs/dist/index.js +4584 -0
  20. package/packages/solidjs/dist/index.js.map +1 -0
  21. package/packages/solidjs-css/{src/styles.css → dist/index.css} +183 -223
  22. package/packages/solidjs-css/dist/index.css.map +1 -0
  23. package/packages/solidjs-css/dist/index.d.ts +432 -0
  24. package/packages/solidjs-css/dist/index.js +4934 -0
  25. package/packages/solidjs-css/dist/index.js.map +1 -0
  26. package/.changeset/config.json +0 -11
  27. package/.github/CODEOWNERS +0 -1
  28. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -16
  29. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -11
  30. package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
  31. package/.github/dependabot.yml +0 -11
  32. package/.github/workflows/ci.yml +0 -23
  33. package/.github/workflows/release.yml +0 -29
  34. package/.nvmrc +0 -1
  35. package/.project/ACCOUNT.yaml +0 -4
  36. package/.project/IDEAS.yaml +0 -7
  37. package/.project/PROJECT.yaml +0 -11
  38. package/.project/ROADMAP.yaml +0 -15
  39. package/CODE_OF_CONDUCT.md +0 -16
  40. package/CONTRIBUTING.md +0 -26
  41. package/SECURITY.md +0 -15
  42. package/SUPPORT.md +0 -8
  43. package/packages/convex/README.md +0 -1
  44. package/packages/convex/package.json +0 -12
  45. package/packages/convex/src/convex.config.ts +0 -3
  46. package/packages/convex/src/index.ts +0 -3
  47. package/packages/convex/src/mutations.ts +0 -270
  48. package/packages/convex/src/queries.ts +0 -175
  49. package/packages/convex/src/schema.ts +0 -55
  50. package/packages/react/README.md +0 -1
  51. package/packages/react/package.json +0 -36
  52. package/packages/react/src/DocsLayout.tsx +0 -116
  53. package/packages/react/src/DocsProvider.tsx +0 -93
  54. package/packages/react/src/RouterDocsContent.tsx +0 -148
  55. package/packages/react/src/RouterDocsLayout.tsx +0 -161
  56. package/packages/react/src/components/Breadcrumbs.tsx +0 -34
  57. package/packages/react/src/components/DocPage.tsx +0 -191
  58. package/packages/react/src/components/DocSearch.tsx +0 -140
  59. package/packages/react/src/components/DocSidebar.tsx +0 -86
  60. package/packages/react/src/components/DocsLayout.tsx +0 -62
  61. package/packages/react/src/components/EditButton.tsx +0 -26
  62. package/packages/react/src/components/PageNavigation.tsx +0 -45
  63. package/packages/react/src/components/TableOfContents.tsx +0 -46
  64. package/packages/react/src/components/VersionSelector.tsx +0 -60
  65. package/packages/react/src/components/index.ts +0 -9
  66. package/packages/react/src/hooks/index.ts +0 -8
  67. package/packages/react/src/hooks/useDocSearch.ts +0 -55
  68. package/packages/react/src/hooks/useDocs.ts +0 -57
  69. package/packages/react/src/hooks/useDocsAdmin.ts +0 -151
  70. package/packages/react/src/hooks/useTableOfContents.ts +0 -66
  71. package/packages/react/src/index.ts +0 -38
  72. package/packages/react/src/pages/DocSearchPage.tsx +0 -129
  73. package/packages/react/src/pages/DocViewPage.tsx +0 -158
  74. package/packages/react/src/pages/DocsAdminPage.tsx +0 -330
  75. package/packages/react/src/pages/DocsIndexPage.tsx +0 -172
  76. package/packages/react/src/pages/index.ts +0 -4
  77. package/packages/react/src/useDocs.ts +0 -58
  78. package/packages/react/tsup.config.ts +0 -12
  79. package/packages/react-css/README.md +0 -1
  80. package/packages/react-css/package.json +0 -37
  81. package/packages/react-css/src/DocsLayout.tsx +0 -117
  82. package/packages/react-css/src/DocsProvider.tsx +0 -93
  83. package/packages/react-css/src/RouterDocsContent.tsx +0 -60
  84. package/packages/react-css/src/RouterDocsLayout.tsx +0 -101
  85. package/packages/react-css/src/components/DocPage.tsx +0 -21
  86. package/packages/react-css/src/components/DocSearch.tsx +0 -55
  87. package/packages/react-css/src/components/DocSidebar.tsx +0 -56
  88. package/packages/react-css/src/components/DocsLayout.tsx +0 -28
  89. package/packages/react-css/src/components/common.tsx +0 -93
  90. package/packages/react-css/src/components/index.ts +0 -5
  91. package/packages/react-css/src/hooks/index.ts +0 -2
  92. package/packages/react-css/src/index.ts +0 -6
  93. package/packages/react-css/src/index.tsx +0 -3
  94. package/packages/react-css/src/pages/DocViewPage.tsx +0 -78
  95. package/packages/react-css/src/pages/DocsAdminPage.tsx +0 -101
  96. package/packages/react-css/src/pages/DocsIndexPage.tsx +0 -68
  97. package/packages/react-css/src/pages/index.ts +0 -3
  98. package/packages/react-css/src/useDocs.ts +0 -58
  99. package/packages/react-css/tsconfig.json +0 -19
  100. package/packages/react-css/tsup.config.ts +0 -10
  101. package/packages/shared/README.md +0 -1
  102. package/packages/shared/package.json +0 -31
  103. package/packages/shared/src/__tests__/docs.test.ts +0 -69
  104. package/packages/shared/src/config.ts +0 -80
  105. package/packages/shared/src/index.ts +0 -179
  106. package/packages/shared/src/providers/astro.ts +0 -94
  107. package/packages/shared/src/providers/fumadocs.ts +0 -116
  108. package/packages/shared/src/providers/internal.ts +0 -80
  109. package/packages/shared/src/types.ts +0 -73
  110. package/packages/shared/tsconfig.json +0 -18
  111. package/packages/shared/tsup.config.ts +0 -12
  112. package/packages/shared/vitest.config.ts +0 -4
  113. package/packages/solidjs/README.md +0 -1
  114. package/packages/solidjs/package.json +0 -33
  115. package/packages/solidjs/src/DocsLayout.tsx +0 -87
  116. package/packages/solidjs/src/DocsProvider.tsx +0 -95
  117. package/packages/solidjs/src/RouterDocsContent.tsx +0 -147
  118. package/packages/solidjs/src/RouterDocsLayout.tsx +0 -161
  119. package/packages/solidjs/src/components/Breadcrumbs.tsx +0 -27
  120. package/packages/solidjs/src/components/DocPage.tsx +0 -110
  121. package/packages/solidjs/src/components/DocSearch.tsx +0 -81
  122. package/packages/solidjs/src/components/DocSidebar.tsx +0 -92
  123. package/packages/solidjs/src/components/DocsLayout.tsx +0 -38
  124. package/packages/solidjs/src/components/EditButton.tsx +0 -15
  125. package/packages/solidjs/src/components/PageNavigation.tsx +0 -31
  126. package/packages/solidjs/src/components/TableOfContents.tsx +0 -41
  127. package/packages/solidjs/src/components/VersionSelector.tsx +0 -30
  128. package/packages/solidjs/src/components/index.ts +0 -9
  129. package/packages/solidjs/src/createDocs.ts +0 -62
  130. package/packages/solidjs/src/index.ts +0 -28
  131. package/packages/solidjs/src/pages/DocSearchPage.tsx +0 -72
  132. package/packages/solidjs/src/pages/DocViewPage.tsx +0 -80
  133. package/packages/solidjs/src/pages/DocsAdminPage.tsx +0 -123
  134. package/packages/solidjs/src/pages/DocsIndexPage.tsx +0 -85
  135. package/packages/solidjs/src/pages/index.ts +0 -4
  136. package/packages/solidjs/src/primitives/createDocSearch.ts +0 -42
  137. package/packages/solidjs/src/primitives/createDocs.ts +0 -35
  138. package/packages/solidjs/src/primitives/createDocsAdmin.ts +0 -63
  139. package/packages/solidjs/src/primitives/createTableOfContents.ts +0 -51
  140. package/packages/solidjs/src/primitives/index.ts +0 -4
  141. package/packages/solidjs/tsup.config.ts +0 -12
  142. package/packages/solidjs-css/README.md +0 -1
  143. package/packages/solidjs-css/package.json +0 -36
  144. package/packages/solidjs-css/src/DocsLayout.tsx +0 -106
  145. package/packages/solidjs-css/src/DocsProvider.tsx +0 -95
  146. package/packages/solidjs-css/src/RouterDocsContent.tsx +0 -54
  147. package/packages/solidjs-css/src/RouterDocsLayout.tsx +0 -104
  148. package/packages/solidjs-css/src/createDocs.ts +0 -62
  149. package/packages/solidjs-css/src/index.ts +0 -7
  150. package/packages/solidjs-css/src/index.tsx +0 -17
  151. package/packages/solidjs-css/src/pages/DocViewPage.tsx +0 -111
  152. package/packages/solidjs-css/src/pages/DocsAdminPage.tsx +0 -332
  153. package/packages/solidjs-css/src/pages/DocsIndexPage.tsx +0 -116
  154. package/packages/solidjs-css/src/pages/index.ts +0 -3
  155. package/packages/solidjs-css/src/primitives/index.ts +0 -1
  156. package/packages/solidjs-css/tsconfig.json +0 -20
  157. package/packages/solidjs-css/tsup.config.ts +0 -10
  158. package/pnpm-workspace.yaml +0 -2
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
- "changelog": "@changesets/cli/changelog",
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "patch",
10
- "ignore": []
11
- }
@@ -1 +0,0 @@
1
- * @mxn2020
@@ -1,16 +0,0 @@
1
- ---
2
- name: Bug Report
3
- about: Report a bug
4
- labels: bug
5
- ---
6
-
7
- ## Describe the bug
8
-
9
- ## Steps to reproduce
10
-
11
- ## Expected behavior
12
-
13
- ## Environment
14
- - Package version:
15
- - Node version:
16
- - OS:
@@ -1,11 +0,0 @@
1
- ---
2
- name: Feature Request
3
- about: Suggest a new feature
4
- labels: enhancement
5
- ---
6
-
7
- ## Problem
8
-
9
- ## Proposed solution
10
-
11
- ## Alternatives considered
@@ -1,10 +0,0 @@
1
- ## What
2
-
3
- ## Why
4
-
5
- ## How
6
-
7
- ## Checklist
8
- - [ ] Tests added/updated
9
- - [ ] `pnpm changeset` run (if applicable)
10
- - [ ] Documentation updated
@@ -1,11 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "npm"
4
- directory: "/"
5
- schedule:
6
- interval: "weekly"
7
- open-pull-requests-limit: 10
8
- - package-ecosystem: "github-actions"
9
- directory: "/"
10
- schedule:
11
- interval: "weekly"
@@ -1,23 +0,0 @@
1
- name: CI
2
- on:
3
- pull_request:
4
- branches: [main]
5
- push:
6
- branches: [main]
7
-
8
- jobs:
9
- check:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
- - uses: pnpm/action-setup@v4
14
- with:
15
- version: 10
16
- - uses: actions/setup-node@v4
17
- with:
18
- node-version-file: '.nvmrc'
19
- cache: 'pnpm'
20
- - run: pnpm install --frozen-lockfile
21
- - run: pnpm build
22
- - run: pnpm lint
23
- - run: pnpm test
@@ -1,29 +0,0 @@
1
- name: Release
2
- on:
3
- push:
4
- branches: [main]
5
-
6
- concurrency: ${{ github.workflow }}-${{ github.ref }}
7
-
8
- jobs:
9
- release:
10
- runs-on: ubuntu-latest
11
- steps:
12
- - uses: actions/checkout@v4
13
- - uses: pnpm/action-setup@v4
14
- with:
15
- version: 10
16
- - uses: actions/setup-node@v4
17
- with:
18
- node-version-file: '.nvmrc'
19
- cache: 'pnpm'
20
- registry-url: 'https://registry.npmjs.org'
21
- - run: pnpm install --frozen-lockfile
22
- - run: pnpm build
23
- - uses: changesets/action@v1
24
- with:
25
- publish: pnpm changeset publish
26
- version: pnpm changeset version
27
- env:
28
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 22
@@ -1,4 +0,0 @@
1
- owner: Mehdi Nabhani
2
- email: mehdi@geenius.app
3
- github: mxn2020
4
- organization: geenius
@@ -1,7 +0,0 @@
1
- ideas:
2
- - title: "CLI scaffolding"
3
- description: "Add a create command to geenius-cli for this package"
4
- priority: medium
5
- - title: "Vue adapter"
6
- description: "Add Vue 3 support alongside React and SolidJS"
7
- priority: low
@@ -1,11 +0,0 @@
1
- name: geenius-docs
2
- description: "Geenius Docs — Provider-based documentation system (Astro/Fumadocs/Internal) for React + SolidJS"
3
- category: library
4
- priority: high
5
- tags:
6
- - geenius
7
- - npm-package
8
- - react
9
- - solidjs
10
- deploy_url: null
11
- npm_scope: "@geenius-docs"
@@ -1,15 +0,0 @@
1
- version: "0.1"
2
- milestones:
3
- - name: "v0.1.0 — Initial Release"
4
- status: in-progress
5
- items:
6
- - "Core shared types and logic"
7
- - "React hooks and components"
8
- - "SolidJS primitives"
9
- - "npm publishing via Changesets"
10
- - name: "v0.2.0 — Stability"
11
- status: planned
12
- items:
13
- - "Test coverage ≥ 50%"
14
- - "API documentation"
15
- - "Convex adapter"
@@ -1,16 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, disability, ethnicity, gender identity and expression, level of experience,
8
- education, socio-economic status, nationality, personal appearance, race,
9
- religion, or sexual identity and orientation.
10
-
11
- ## Enforcement
12
-
13
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
14
- reported to the project team at conduct@geenius.app.
15
-
16
- This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
package/CONTRIBUTING.md DELETED
@@ -1,26 +0,0 @@
1
- # Contributing to @geenius-docs
2
-
3
- Thank you for your interest in contributing!
4
-
5
- ## Development Setup
6
-
7
- ```bash
8
- git clone https://github.com/mxn2020/geenius-docs.git
9
- cd geenius-docs
10
- pnpm install
11
- pnpm build
12
- pnpm test
13
- ```
14
-
15
- ## Pull Request Process
16
-
17
- 1. Fork the repo and create a feature branch from `main`
18
- 2. Add or update tests as appropriate
19
- 3. Run `pnpm changeset` to describe your changes for the changelog
20
- 4. Open a PR against `main`
21
-
22
- ## Code Style
23
-
24
- - TypeScript strict mode
25
- - ESLint + Prettier formatting
26
- - Conventional commits preferred
package/SECURITY.md DELETED
@@ -1,15 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- | Version | Supported |
6
- | ------- | --------- |
7
- | 0.x.x | ✅ |
8
-
9
- ## Reporting a Vulnerability
10
-
11
- Please report security vulnerabilities by emailing **security@geenius.app**.
12
-
13
- Do **not** open a public GitHub issue for security vulnerabilities.
14
-
15
- We will acknowledge receipt within 48 hours and provide a detailed response within 5 business days.
package/SUPPORT.md DELETED
@@ -1,8 +0,0 @@
1
- # Support
2
-
3
- ## Getting Help
4
-
5
- - 📖 [Documentation](https://docs.geenius.app)
6
- - 🐛 [Bug Reports](https://github.com/mxn2020/geenius-docs/issues/new?template=bug_report.md)
7
- - 💡 [Feature Requests](https://github.com/mxn2020/geenius-docs/issues/new?template=feature_request.md)
8
- - 📧 Email: support@geenius.app
@@ -1 +0,0 @@
1
- # ✦ @geenius-docs/convex\n\n> A premium module for the Geenius Boilerplate Ecosystem.\n\n---\n\n## Overview\nBuilt with Steve Jobs-level minimalism and Jony Ive-level craftsmanship, this package is designed to deliver unparalleled developer experience (DX) and rock-solid performance.\n\n## Installation\n\n```bash\npnpm add @geenius-docs/convex\n```\n\n## Usage\n\n```typescript\nimport { init } from '@geenius-docs/convex';\n\n// Initialize the module with absolute precision\ninit({\n mode: 'premium',\n});\n```\n\n## Architecture\n- **Zero-config**: It just works.\n- **Strictly Typed**: Fully written in TypeScript for flawless IntelliSense.\n- **Framework Agnostic**: seamlessly integrates into the Geenius ecosystem.\n\n---\n\n*Designed by Antigravity HQ*\n
@@ -1,12 +0,0 @@
1
- {
2
- "name": "@geenius-docs/convex",
3
- "version": "0.1.0",
4
- "private": true,
5
- "type": "module",
6
- "main": "src/index.ts",
7
- "author": "Antigravity HQ",
8
- "license": "MIT",
9
- "engines": {
10
- "node": ">=20.0.0"
11
- }
12
- }
@@ -1,3 +0,0 @@
1
- import { defineComponent } from "convex/server";
2
- const component = defineComponent("docs");
3
- export default component;
@@ -1,3 +0,0 @@
1
- export { default as componentDefinition } from "./convex.config";
2
- export * from "./mutations";
3
- export * from "./queries";
@@ -1,270 +0,0 @@
1
- import { v } from "convex/values";
2
- import { mutation } from "./_generated/server.js";
3
-
4
- // ─── Sections ────────────────────────────────────────────────
5
-
6
- export const createSection = mutation({
7
- args: {
8
- title: v.string(),
9
- slug: v.string(),
10
- parentId: v.optional(v.id("doc_sections")),
11
- order: v.number(),
12
- icon: v.optional(v.string()),
13
- description: v.optional(v.string()),
14
- access: v.union(v.literal("public"), v.literal("team"), v.literal("admin")),
15
- },
16
- returns: v.id("doc_sections"),
17
- handler: async (ctx, args) => {
18
- return await ctx.db.insert("doc_sections", {
19
- ...args,
20
- createdAt: Date.now(),
21
- });
22
- },
23
- });
24
-
25
- export const updateSection = mutation({
26
- args: {
27
- sectionId: v.id("doc_sections"),
28
- title: v.optional(v.string()),
29
- slug: v.optional(v.string()),
30
- order: v.optional(v.number()),
31
- icon: v.optional(v.string()),
32
- description: v.optional(v.string()),
33
- access: v.optional(
34
- v.union(v.literal("public"), v.literal("team"), v.literal("admin"))
35
- ),
36
- },
37
- returns: v.null(),
38
- handler: async (ctx, args) => {
39
- const { sectionId, ...updates } = args;
40
- const clean = Object.fromEntries(
41
- Object.entries(updates).filter(([, val]) => val !== undefined)
42
- );
43
- await ctx.db.patch(sectionId, clean);
44
- return null;
45
- },
46
- });
47
-
48
- export const deleteSection = mutation({
49
- args: { sectionId: v.id("doc_sections") },
50
- returns: v.null(),
51
- handler: async (ctx, args) => {
52
- // Delete all pages in this section
53
- const pages = await ctx.db
54
- .query("doc_pages")
55
- .withIndex("by_sectionId", (q) => q.eq("sectionId", args.sectionId))
56
- .collect();
57
-
58
- for (const page of pages) {
59
- // Delete search index entries for each page
60
- const indexEntries = await ctx.db
61
- .query("doc_search_index")
62
- .withIndex("by_pageId", (q) => q.eq("pageId", page._id))
63
- .collect();
64
- for (const entry of indexEntries) {
65
- await ctx.db.delete(entry._id);
66
- }
67
- await ctx.db.delete(page._id);
68
- }
69
-
70
- await ctx.db.delete(args.sectionId);
71
- return null;
72
- },
73
- });
74
-
75
- export const reorderSections = mutation({
76
- args: { sectionIds: v.array(v.id("doc_sections")) },
77
- returns: v.null(),
78
- handler: async (ctx, args) => {
79
- for (let i = 0; i < args.sectionIds.length; i++) {
80
- await ctx.db.patch(args.sectionIds[i], { order: i });
81
- }
82
- return null;
83
- },
84
- });
85
-
86
- // ─── Pages ───────────────────────────────────────────────────
87
-
88
- export const createPage = mutation({
89
- args: {
90
- title: v.string(),
91
- slug: v.string(),
92
- content: v.string(),
93
- sectionId: v.id("doc_sections"),
94
- access: v.union(v.literal("public"), v.literal("team"), v.literal("admin")),
95
- tags: v.optional(v.array(v.string())),
96
- version: v.optional(v.string()),
97
- status: v.optional(
98
- v.union(
99
- v.literal("draft"),
100
- v.literal("published"),
101
- v.literal("archived")
102
- )
103
- ),
104
- author: v.optional(
105
- v.object({ name: v.string(), avatar: v.optional(v.string()) })
106
- ),
107
- excerpt: v.optional(v.string()),
108
- order: v.optional(v.number()),
109
- },
110
- returns: v.id("doc_pages"),
111
- handler: async (ctx, args) => {
112
- const now = Date.now();
113
- const stripped = args.content
114
- .replace(/```[\s\S]*?```/g, "")
115
- .replace(/[#*_~>|-]/g, "")
116
- .trim();
117
- const words = stripped.split(/\s+/).filter(Boolean);
118
- const wordCount = words.length;
119
- const readingTime = Math.max(1, Math.ceil(wordCount / 225));
120
-
121
- return await ctx.db.insert("doc_pages", {
122
- title: args.title,
123
- slug: args.slug,
124
- content: args.content,
125
- excerpt: args.excerpt,
126
- sectionId: args.sectionId,
127
- order: args.order ?? 0,
128
- author: args.author ?? { name: "Anonymous" },
129
- version: args.version,
130
- access: args.access,
131
- tags: args.tags ?? [],
132
- status: args.status ?? "draft",
133
- createdAt: now,
134
- updatedAt: now,
135
- wordCount,
136
- readingTime,
137
- viewCount: 0,
138
- });
139
- },
140
- });
141
-
142
- export const updatePage = mutation({
143
- args: {
144
- pageId: v.id("doc_pages"),
145
- title: v.optional(v.string()),
146
- slug: v.optional(v.string()),
147
- content: v.optional(v.string()),
148
- excerpt: v.optional(v.string()),
149
- sectionId: v.optional(v.id("doc_sections")),
150
- order: v.optional(v.number()),
151
- access: v.optional(
152
- v.union(v.literal("public"), v.literal("team"), v.literal("admin"))
153
- ),
154
- tags: v.optional(v.array(v.string())),
155
- version: v.optional(v.string()),
156
- status: v.optional(
157
- v.union(
158
- v.literal("draft"),
159
- v.literal("published"),
160
- v.literal("archived")
161
- )
162
- ),
163
- lastEditedBy: v.optional(
164
- v.object({ name: v.string(), editedAt: v.string() })
165
- ),
166
- },
167
- returns: v.null(),
168
- handler: async (ctx, args) => {
169
- const { pageId, ...updates } = args;
170
- const clean: Record<string, unknown> = Object.fromEntries(
171
- Object.entries(updates).filter(([, val]) => val !== undefined)
172
- );
173
-
174
- // Recalculate word count if content changed
175
- if (typeof clean.content === "string") {
176
- const stripped = (clean.content as string)
177
- .replace(/```[\s\S]*?```/g, "")
178
- .replace(/[#*_~>|-]/g, "")
179
- .trim();
180
- const words = stripped.split(/\s+/).filter(Boolean);
181
- clean.wordCount = words.length;
182
- clean.readingTime = Math.max(1, Math.ceil(words.length / 225));
183
- }
184
-
185
- clean.updatedAt = Date.now();
186
- await ctx.db.patch(pageId, clean);
187
- return null;
188
- },
189
- });
190
-
191
- export const publishPage = mutation({
192
- args: { pageId: v.id("doc_pages") },
193
- returns: v.null(),
194
- handler: async (ctx, args) => {
195
- await ctx.db.patch(args.pageId, {
196
- status: "published",
197
- updatedAt: Date.now(),
198
- });
199
- return null;
200
- },
201
- });
202
-
203
- export const archivePage = mutation({
204
- args: { pageId: v.id("doc_pages") },
205
- returns: v.null(),
206
- handler: async (ctx, args) => {
207
- await ctx.db.patch(args.pageId, {
208
- status: "archived",
209
- updatedAt: Date.now(),
210
- });
211
- return null;
212
- },
213
- });
214
-
215
- export const deletePage = mutation({
216
- args: { pageId: v.id("doc_pages") },
217
- returns: v.null(),
218
- handler: async (ctx, args) => {
219
- // Delete search index entries
220
- const indexEntries = await ctx.db
221
- .query("doc_search_index")
222
- .withIndex("by_pageId", (q) => q.eq("pageId", args.pageId))
223
- .collect();
224
- for (const entry of indexEntries) {
225
- await ctx.db.delete(entry._id);
226
- }
227
- await ctx.db.delete(args.pageId);
228
- return null;
229
- },
230
- });
231
-
232
- export const reorderPages = mutation({
233
- args: { pageIds: v.array(v.id("doc_pages")) },
234
- returns: v.null(),
235
- handler: async (ctx, args) => {
236
- for (let i = 0; i < args.pageIds.length; i++) {
237
- await ctx.db.patch(args.pageIds[i], { order: i });
238
- }
239
- return null;
240
- },
241
- });
242
-
243
- export const incrementViewCount = mutation({
244
- args: { pageId: v.id("doc_pages") },
245
- returns: v.null(),
246
- handler: async (ctx, args) => {
247
- const page = await ctx.db.get(args.pageId);
248
- if (page) {
249
- await ctx.db.patch(args.pageId, { viewCount: (page.viewCount ?? 0) + 1 });
250
- }
251
- return null;
252
- },
253
- });
254
-
255
- export const movePage = mutation({
256
- args: {
257
- pageId: v.id("doc_pages"),
258
- newSectionId: v.id("doc_sections"),
259
- newOrder: v.number(),
260
- },
261
- returns: v.null(),
262
- handler: async (ctx, args) => {
263
- await ctx.db.patch(args.pageId, {
264
- sectionId: args.newSectionId,
265
- order: args.newOrder,
266
- updatedAt: Date.now(),
267
- });
268
- return null;
269
- },
270
- });