kitcn 0.0.1 → 0.12.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 (93) hide show
  1. package/bin/intent.js +3 -0
  2. package/dist/aggregate/index.d.ts +388 -0
  3. package/dist/aggregate/index.js +37 -0
  4. package/dist/api-entry-BckXqaLb.js +66 -0
  5. package/dist/auth/client/index.d.ts +37 -0
  6. package/dist/auth/client/index.js +217 -0
  7. package/dist/auth/config/index.d.ts +45 -0
  8. package/dist/auth/config/index.js +24 -0
  9. package/dist/auth/generated/index.d.ts +2 -0
  10. package/dist/auth/generated/index.js +3 -0
  11. package/dist/auth/http/index.d.ts +64 -0
  12. package/dist/auth/http/index.js +461 -0
  13. package/dist/auth/index.d.ts +221 -0
  14. package/dist/auth/index.js +1398 -0
  15. package/dist/auth/nextjs/index.d.ts +50 -0
  16. package/dist/auth/nextjs/index.js +81 -0
  17. package/dist/auth-store-Cljlmdmi.js +197 -0
  18. package/dist/builder-CBdG5W6A.js +1974 -0
  19. package/dist/caller-factory-cTXNvYdz.js +216 -0
  20. package/dist/cli.mjs +13264 -0
  21. package/dist/codegen-lF80HSWu.mjs +3416 -0
  22. package/dist/context-utils-HPC5nXzx.d.ts +17 -0
  23. package/dist/create-schema-odyF4kCy.js +156 -0
  24. package/dist/create-schema-orm-DOyiNDCx.js +246 -0
  25. package/dist/crpc/index.d.ts +105 -0
  26. package/dist/crpc/index.js +169 -0
  27. package/dist/customFunctions-C0voKmtx.js +144 -0
  28. package/dist/error-BZEnI7Sq.js +41 -0
  29. package/dist/generated-contract-disabled-Cih4eITO.js +50 -0
  30. package/dist/generated-contract-disabled-D-sOFy92.d.ts +354 -0
  31. package/dist/http-types-DqJubRPJ.d.ts +292 -0
  32. package/dist/meta-utils-0Pu0Nrap.js +117 -0
  33. package/dist/middleware-BUybuv9n.d.ts +34 -0
  34. package/dist/middleware-C2qTZ3V7.js +84 -0
  35. package/dist/orm/index.d.ts +17 -0
  36. package/dist/orm/index.js +10713 -0
  37. package/dist/plugins/index.d.ts +2 -0
  38. package/dist/plugins/index.js +3 -0
  39. package/dist/procedure-caller-DtxLmGwA.d.ts +1467 -0
  40. package/dist/procedure-caller-MWcxhQDv.js +349 -0
  41. package/dist/query-context-B8o6-8kC.js +1518 -0
  42. package/dist/query-context-CFZqIvD7.d.ts +42 -0
  43. package/dist/query-options-Dw7cOyXl.js +121 -0
  44. package/dist/ratelimit/index.d.ts +269 -0
  45. package/dist/ratelimit/index.js +856 -0
  46. package/dist/ratelimit/react/index.d.ts +76 -0
  47. package/dist/ratelimit/react/index.js +183 -0
  48. package/dist/react/index.d.ts +1284 -0
  49. package/dist/react/index.js +2526 -0
  50. package/dist/rsc/index.d.ts +276 -0
  51. package/dist/rsc/index.js +233 -0
  52. package/dist/runtime-CtvJPkur.js +2453 -0
  53. package/dist/server/index.d.ts +5 -0
  54. package/dist/server/index.js +6 -0
  55. package/dist/solid/index.d.ts +1221 -0
  56. package/dist/solid/index.js +2940 -0
  57. package/dist/transformer-DtDhR3Lc.js +194 -0
  58. package/dist/types-BTb_4BaU.d.ts +42 -0
  59. package/dist/types-BiJE7qxR.d.ts +4 -0
  60. package/dist/types-DEJpkIhw.d.ts +88 -0
  61. package/dist/types-HhO_R6pd.d.ts +213 -0
  62. package/dist/validators-B7oIJCAp.js +279 -0
  63. package/dist/validators-vzRKjBJC.d.ts +88 -0
  64. package/dist/watcher.mjs +96 -0
  65. package/dist/where-clause-compiler-DdjN63Io.d.ts +4756 -0
  66. package/package.json +107 -34
  67. package/skills/convex/SKILL.md +486 -0
  68. package/skills/convex/references/features/aggregates.md +353 -0
  69. package/skills/convex/references/features/auth-admin.md +446 -0
  70. package/skills/convex/references/features/auth-organizations.md +1141 -0
  71. package/skills/convex/references/features/auth-polar.md +579 -0
  72. package/skills/convex/references/features/auth.md +470 -0
  73. package/skills/convex/references/features/create-plugins.md +153 -0
  74. package/skills/convex/references/features/http.md +676 -0
  75. package/skills/convex/references/features/migrations.md +162 -0
  76. package/skills/convex/references/features/orm.md +1166 -0
  77. package/skills/convex/references/features/react.md +657 -0
  78. package/skills/convex/references/features/scheduling.md +267 -0
  79. package/skills/convex/references/features/testing.md +209 -0
  80. package/skills/convex/references/setup/auth.md +501 -0
  81. package/skills/convex/references/setup/biome.md +190 -0
  82. package/skills/convex/references/setup/doc-guidelines.md +145 -0
  83. package/skills/convex/references/setup/index.md +761 -0
  84. package/skills/convex/references/setup/next.md +116 -0
  85. package/skills/convex/references/setup/react.md +175 -0
  86. package/skills/convex/references/setup/server.md +473 -0
  87. package/skills/convex/references/setup/start.md +67 -0
  88. package/LICENSE +0 -21
  89. package/README.md +0 -0
  90. package/dist/index.d.mts +0 -5
  91. package/dist/index.d.mts.map +0 -1
  92. package/dist/index.mjs +0 -6
  93. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,162 @@
1
+ # Migrations Reference
2
+
3
+ Built-in online data migrations for kitcn. Prerequisites: `setup/server.md`.
4
+
5
+ ## When to Migrate
6
+
7
+ Convex is not SQL — skip migrations for backward-compatible changes.
8
+
9
+ **Skip migrations:**
10
+ - Adding optional fields
11
+ - Adding new tables or indexes
12
+ - Code-level defaults on read (`doc.field ?? 'default'`)
13
+ - Keeping deprecated fields while new code rolls out
14
+
15
+ **Use migrations:**
16
+ - Optional → required (field must exist on every row)
17
+ - Type or enum narrowing
18
+ - Field rename or removal that would violate schema
19
+ - Semantic rewrites or one-time backfills
20
+
21
+ **Rule:** Old docs still pass schema + app logic → no migration. Old docs would fail → migrate.
22
+
23
+ ## Core API
24
+
25
+ ### `defineMigration`
26
+
27
+ ```ts
28
+ import { defineMigration } from 'kitcn/orm';
29
+
30
+ export const migration = defineMigration({
31
+ id: '20260227_080239_backfill_todo_priority', // timestamped unique id
32
+ description: 'backfill todo priority', // optional
33
+ up: {
34
+ table: 'todos',
35
+ migrateOne: async (_ctx, doc) => {
36
+ if (doc.priority === undefined || doc.priority === null) {
37
+ return { priority: 'medium' }; // partial patch
38
+ }
39
+ // return nothing to skip
40
+ },
41
+ },
42
+ down: { // optional — omit if not safely reversible
43
+ table: 'todos',
44
+ migrateOne: async (_ctx, doc) => {
45
+ if (doc.priority === 'medium') {
46
+ return { priority: undefined };
47
+ }
48
+ },
49
+ },
50
+ });
51
+ ```
52
+
53
+ ### MigrationStep Fields
54
+
55
+ | Field | Type | Default | Description |
56
+ |-------|------|---------|-------------|
57
+ | `table` | `string` | — | Table to iterate |
58
+ | `migrateOne` | `(ctx, doc) => patch \| void` | — | Per-document transform |
59
+ | `batchSize` | `number` | `128` (runtime) / `256` (CLI) | Docs per batch |
60
+ | `writeMode` | `'safe_bypass' \| 'normal'` | `'safe_bypass'` | Bypass or run ORM rules/triggers |
61
+
62
+ ### `migrateOne` Context
63
+
64
+ | Field | Type | Description |
65
+ |-------|------|-------------|
66
+ | `db` | `DatabaseWriter` | Raw Convex database writer |
67
+ | `orm` | `OrmWriter` | ORM writer for complex ops |
68
+ | `migrationId` | `string` | Current migration id |
69
+ | `runId` | `string` | Current run id |
70
+ | `direction` | `'up' \| 'down'` | Current direction |
71
+ | `dryRun` | `boolean` | Whether dry run |
72
+ | `writeMode` | `'safe_bypass' \| 'normal'` | Current write mode |
73
+
74
+ ### `defineMigrationSet`
75
+
76
+ Auto-generated manifest. Collects migrations, computes checksums, sorts by id:
77
+
78
+ ```ts
79
+ import { defineMigrationSet } from 'kitcn/orm';
80
+ export const migrations = defineMigrationSet([migration1, migration2]);
81
+ ```
82
+
83
+ ## CLI Commands
84
+
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `migrate create <name>` | Scaffold timestamped migration + update manifest |
88
+ | `migrate up [--prod]` | Apply all pending migrations in order |
89
+ | `migrate down --steps N [--prod]` | Roll back N migrations |
90
+ | `migrate down --to <id> [--prod]` | Roll back to specific migration |
91
+ | `migrate status [--prod]` | Show applied/pending/drift state |
92
+ | `migrate cancel [--prod]` | Cancel active run |
93
+
94
+ ## Deploy Integration
95
+
96
+ `kitcn deploy` auto-runs: `convex deploy` → `migrate up` → `aggregate backfill`.
97
+
98
+ Config in `kitcn.json`:
99
+
100
+ ```json
101
+ {
102
+ "deploy": {
103
+ "migrations": {
104
+ "enabled": "auto",
105
+ "wait": true,
106
+ "batchSize": 256,
107
+ "pollIntervalMs": 1000,
108
+ "timeoutMs": 900000,
109
+ "strict": true,
110
+ "allowDrift": false
111
+ }
112
+ }
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ `kitcn dev` uses relaxed defaults (`strict: false`, `allowDrift: true`).
119
+
120
+ ## Drift Safety
121
+
122
+ Applied migrations are immutable. Two drift checks:
123
+
124
+ | Drift | Cause | Effect |
125
+ |-------|-------|--------|
126
+ | Checksum mismatch | Applied migration file edited | Blocks next run |
127
+ | Missing from manifest | Applied migration deleted | Blocks next run |
128
+
129
+ `allowDrift` is emergency-only. Create new migrations for follow-up behavior.
130
+
131
+ ## Internal Tables
132
+
133
+ - `migration_state` — applied checksums and progress per migration
134
+ - `migration_run` — run lifecycle (start, status, failures)
135
+
136
+ Reserved names — do not create tables with these names.
137
+
138
+ ## Runtime Statuses
139
+
140
+ `pending` → `running` → `completed` | `failed` | `canceled` | `dry_run` | `noop` | `drift_blocked`
141
+
142
+ ## Best Practices
143
+
144
+ 1. **One migration per schema change** — don't bundle unrelated backfills.
145
+ 2. **Codegen before migrate up** — deterministic order prevents stale function code.
146
+ 3. **`safe_bypass` by default** — bypasses ORM rules/triggers for speed. Set `writeMode: 'normal'` when you need hooks.
147
+ 4. **Don't edit applied migrations** — triggers checksum drift. Create new migration instead.
148
+ 5. **Prefer code defaults** — `doc.field ?? 'default'` over migration when backward-compatible.
149
+
150
+ ## Common Workflow: Optional → Required
151
+
152
+ 1. `migrate create backfill_field`
153
+ 2. Implement `migrateOne` to fill missing values
154
+ 3. `codegen` then `migrate up`
155
+ 4. Harden schema (`.notNull()`)
156
+ 5. `codegen` to confirm
157
+
158
+ ## Related References
159
+
160
+ - ORM: `./orm.md`
161
+ - Triggers: docs at `/docs/orm/schema/triggers`
162
+ - CLI Backend: docs at `/docs/cli/backend`