cvx-kit 0.1.15 → 0.1.16

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 (45) hide show
  1. package/README.md +59 -38
  2. package/dist/relations.mjs +1 -1
  3. package/dist/relations.mjs.map +1 -1
  4. package/dist/zod-table.d.mts +59 -2
  5. package/dist/zod-table.mjs +1 -1
  6. package/dist/zod-table.mjs.map +1 -1
  7. package/package.json +10 -3
  8. package/AGENTS.md +0 -47
  9. package/CHANGELOG.md +0 -337
  10. package/ROADMAP.md +0 -126
  11. package/docs/agent-tools.md +0 -41
  12. package/docs/approvals.md +0 -201
  13. package/docs/architecture.md +0 -124
  14. package/docs/auth.md +0 -443
  15. package/docs/command-context.md +0 -150
  16. package/docs/commands-legacy.md +0 -513
  17. package/docs/commands.md +0 -173
  18. package/docs/conventions.md +0 -345
  19. package/docs/crud.md +0 -66
  20. package/docs/domain-contracts.md +0 -148
  21. package/docs/domain-operations.md +0 -615
  22. package/docs/effect.md +0 -403
  23. package/docs/llms.md +0 -324
  24. package/docs/maintainability.md +0 -124
  25. package/docs/migration.md +0 -351
  26. package/docs/oxlint.md +0 -260
  27. package/docs/querying.md +0 -329
  28. package/docs/tenancy.md +0 -176
  29. package/docs/triggers.md +0 -77
  30. package/docs/upgrading.md +0 -287
  31. package/docs/webhooks.md +0 -58
  32. package/docs/zod-table.md +0 -278
  33. package/scripts/convex-config-bridge.mjs +0 -44
  34. package/scripts/convex-smoke-env.mjs +0 -33
  35. package/scripts/extract-changelog.mjs +0 -29
  36. package/scripts/owned-process.mjs +0 -140
  37. package/scripts/owned-process.test.mjs +0 -107
  38. package/scripts/smoke-packed-components.mjs +0 -341
  39. package/scripts/smoke-packed-effect.mjs +0 -439
  40. package/scripts/smoke-packed-querying.mjs +0 -298
  41. package/scripts/test-packed-auth.mjs +0 -72
  42. package/scripts/test-packed-effect.mjs +0 -482
  43. package/scripts/test-packed-ids.mjs +0 -150
  44. package/scripts/test-packed-oxlint.mjs +0 -167
  45. package/scripts/test-packed-querying.mjs +0 -185
@@ -1,167 +0,0 @@
1
- import { strict as assert } from 'node:assert'
2
- import { execFileSync, spawnSync } from 'node:child_process'
3
- import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
4
- import { tmpdir } from 'node:os'
5
- import { join } from 'node:path'
6
- import { rules } from '../dist/oxlint.mjs'
7
-
8
- const root = join(import.meta.dirname, '..')
9
- const temporary = mkdtempSync(join(tmpdir(), 'cvx-kit-oxlint-'))
10
- const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
11
- const ruleNames = Object.keys(rules)
12
- assert.equal(ruleNames.length, 23)
13
-
14
- try {
15
- run('bun', ['pm', 'pack', '--destination', temporary, '--ignore-scripts'], root)
16
- for (const installer of ['npm', 'bun']) {
17
- const fixture = join(temporary, installer)
18
- mkdirSync(join(fixture, 'convex/components/example'), { recursive: true })
19
- mkdirSync(join(fixture, 'convex/api'), { recursive: true })
20
- mkdirSync(join(fixture, 'convex/domain/orders'), { recursive: true })
21
- writeFileSync(
22
- join(fixture, 'package.json'),
23
- JSON.stringify({
24
- private: true,
25
- type: 'module',
26
- dependencies: {
27
- 'cvx-kit': `file:${join(temporary, `cvx-kit-${manifest.version}.tgz`)}`,
28
- convex: manifest.devDependencies.convex,
29
- 'convex-helpers': manifest.devDependencies['convex-helpers'],
30
- zod: manifest.devDependencies.zod,
31
- },
32
- devDependencies: { oxlint: manifest.devDependencies.oxlint },
33
- }),
34
- )
35
- run(installer, ['install', '--ignore-scripts'], fixture)
36
- writeFileSync(
37
- join(fixture, '.oxlintrc.json'),
38
- JSON.stringify({
39
- jsPlugins: [{ name: 'cvx', specifier: 'cvx-kit/oxlint' }],
40
- rules: Object.fromEntries(ruleNames.map((name) => [`cvx/${name}`, 'error'])),
41
- }),
42
- )
43
- writeFileSync(
44
- join(fixture, 'convex/api/orders.ts'),
45
- "import { authMutation } from '../functions'; import { executeSaveOrder } from '../domain/orders/commands'; export const save = authMutation({ handler: (ctx, args) => executeSaveOrder(ctx, args) })\n",
46
- )
47
- writeFileSync(
48
- join(fixture, 'convex/components/example/client.ts'),
49
- 'export function run() { return 1 }\n',
50
- )
51
- for (const directory of ['api', 'components/example']) {
52
- mkdirSync(join(fixture, 'convex', directory, '__tests__'), { recursive: true })
53
- writeFileSync(
54
- join(fixture, 'convex', directory, '__tests__/behavior.test.ts'),
55
- 'test("behavior", () => { expect(1).toBe(1) })',
56
- )
57
- }
58
- const oxlint = join(fixture, 'node_modules/.bin/oxlint')
59
- run(oxlint, ['--config', '.oxlintrc.json', 'convex'], fixture)
60
- writeFileSync(
61
- join(fixture, 'convex/components/example/bad.ts'),
62
- `
63
- import { defineTable } from 'convex/server'
64
- import { host } from '../../host'
65
- function helper() { return process.env.SECRET }
66
- const privateHelper = () => helper()
67
- export const table = defineTable({})
68
- export { host }
69
- export const value = privateHelper()
70
- `,
71
- )
72
- writeFileSync(
73
- join(fixture, 'convex/host.ts'),
74
- "import { authMutation } from './functions'; export const save = authMutation({}); export const host = 1; import './components/example/bad'\n",
75
- )
76
- writeFileSync(
77
- join(fixture, 'convex/api/orders.ts'),
78
- `import { mutation } from '../_generated/server'
79
- import { makeFunctionReference as ref } from 'convex/server'
80
- import { z } from 'zod'
81
- import { createAuthFunctions } from 'cvx-kit/auth'
82
- import { zodTable } from 'cvx-kit/zod-table'
83
- import { other } from '../domain/users/commands'
84
- export const save = mutation({ handler: async (ctx) => {
85
- await ctx.db.insert('orders', { updatedAt: Date.now() })
86
- return ctx.db.query('orders').collect()
87
- }})
88
- export const constructors = createAuthFunctions({})
89
- export const state = z.enum(['draft'])
90
- export const target = ref('orders:save')
91
- export const value = other
92
- const orders = zodTable('orders', () => ({ name: z.string() }))
93
- export const dto = { ...orders.toPublicDto(row), _id: row._id }
94
- export const pagination = z.object({ numItems: z.number(), cursor: z.string().nullable() })
95
- `,
96
- )
97
- mkdirSync(join(fixture, 'convex/application'), { recursive: true })
98
- writeFileSync(
99
- join(fixture, 'convex/application/provider.ts'),
100
- "import Stripe from 'stripe'; export const provider = new Stripe('key')",
101
- )
102
- writeFileSync(
103
- join(fixture, 'convex/domain/orders/queries.ts'),
104
- "export function save(ctx) { return ctx.db.insert('orders', {}) }",
105
- )
106
- writeFileSync(
107
- join(fixture, 'convex/api/internal.ts'),
108
- "import { systemMutation } from '../functions'; export const internal = systemMutation({})",
109
- )
110
- const invalid = spawnSync(
111
- oxlint,
112
- ['--config', '.oxlintrc.json', '--format', 'json', 'convex'],
113
- {
114
- cwd: fixture,
115
- encoding: 'utf8',
116
- },
117
- )
118
- assert.ifError(invalid.error)
119
- assert.equal(invalid.status, 1, invalid.stderr)
120
- const diagnostics = JSON.parse(invalid.stdout).diagnostics
121
- for (const name of ruleNames) {
122
- assert.ok(
123
- diagnostics.some((item) => item.code === `cvx(${name})`),
124
- `${installer}: missing ${name}: ${invalid.stdout}`,
125
- )
126
- }
127
- writeFileSync(
128
- join(fixture, 'plugin-types.ts'),
129
- `
130
- import plugin, { rules, checkArchitecture, type ArchitectureDiagnostic, type RuleName } from 'cvx-kit/oxlint'
131
- import type { Plugin, Rule } from '@oxlint/plugins'
132
- const compatible: Plugin = plugin
133
- const name: RuleName = 'component-boundaries'
134
- const rule: Rule = rules[name]
135
- const issues: ArchitectureDiagnostic[] = checkArchitecture()
136
- void issues
137
- void compatible
138
- void rule
139
- `,
140
- )
141
- run(
142
- join(root, 'node_modules/.bin/tsc'),
143
- [
144
- '--noEmit',
145
- '--strict',
146
- '--skipLibCheck',
147
- '--target',
148
- 'es2025',
149
- '--module',
150
- 'esnext',
151
- '--moduleResolution',
152
- 'bundler',
153
- 'plugin-types.ts',
154
- ],
155
- fixture,
156
- )
157
- console.log(
158
- `${installer}: packed Oxlint plugin loads, all consumer rules report, and declarations typecheck`,
159
- )
160
- }
161
- } finally {
162
- rmSync(temporary, { recursive: true, force: true })
163
- }
164
-
165
- function run(command, args, cwd) {
166
- return execFileSync(command, args, { cwd, encoding: 'utf8', stdio: 'pipe' })
167
- }
@@ -1,185 +0,0 @@
1
- import assert from 'node:assert/strict'
2
- import { execFileSync } from 'node:child_process'
3
- import { createHash } from 'node:crypto'
4
- import { cpSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
5
- import { join, resolve, relative } from 'node:path'
6
-
7
- const root = resolve(import.meta.dirname, '..')
8
- const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
9
- const proof = mkdtempSync('/tmp/cvx-kit-querying-')
10
- console.log(`U8 retained proof: ${proof}`)
11
- const hash = (bytes) => createHash('sha256').update(bytes).digest('hex')
12
- function files(directory) {
13
- return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
14
- const path = join(directory, entry.name)
15
- return entry.isDirectory() ? files(path) : [path]
16
- })
17
- }
18
- function run(command, args, cwd, label) {
19
- const started = performance.now()
20
- try {
21
- const output = execFileSync(command, args, {
22
- cwd,
23
- encoding: 'utf8',
24
- stdio: 'pipe',
25
- timeout: 1200000,
26
- maxBuffer: 32 * 1024 * 1024,
27
- })
28
- writeFileSync(join(proof, `${label}.log`), output)
29
- console.log(`${label}: exit 0 (${((performance.now() - started) / 1000).toFixed(2)}s)`)
30
- return output
31
- } catch (error) {
32
- // Install output may contain credentials from caller's package-manager setup.
33
- if (label.endsWith('install'))
34
- writeFileSync(join(proof, `${label}.log`), `Install failed: exit ${error.status}\n`)
35
- else writeFileSync(join(proof, `${label}.log`), `${error.stdout ?? ''}\n${error.stderr ?? ''}`)
36
- throw new Error(`${label} failed; evidence retained at ${proof}`, { cause: error.status })
37
- }
38
- }
39
- const sourcePaths = [
40
- 'README.md',
41
- 'package.json',
42
- 'vite.config.ts',
43
- ...files(join(root, 'src'))
44
- .filter((p) => p.endsWith('.ts'))
45
- .map((p) => relative(root, p)),
46
- ...files(join(root, 'test/fixture-packed-querying')).map((p) => relative(root, p)),
47
- 'scripts/test-packed-querying.mjs',
48
- 'scripts/smoke-packed-querying.mjs',
49
- 'scripts/owned-process.mjs',
50
- 'scripts/owned-process.test.mjs',
51
- 'scripts/test-packed-oxlint.mjs',
52
- ]
53
- const sourceHashes = () =>
54
- Object.fromEntries(sourcePaths.map((p) => [p, hash(readFileSync(join(root, p)))]))
55
- const before = sourceHashes()
56
- writeFileSync(join(proof, 'source-before.json'), JSON.stringify(before, null, 2))
57
- run('bun', ['pm', 'pack', '--ignore-scripts', '--destination', proof], root, 'pack')
58
- const tarball = join(proof, `${manifest.name}-${manifest.version}.tgz`)
59
- writeFileSync(
60
- join(proof, 'package-identity.json'),
61
- JSON.stringify(
62
- {
63
- name: manifest.name,
64
- version: manifest.version,
65
- tarball,
66
- sha256: hash(readFileSync(tarball)),
67
- head: execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim(),
68
- files: run('tar', ['-tzf', tarball], root, 'tar-manifest').trim().split('\n'),
69
- },
70
- null,
71
- 2,
72
- ),
73
- )
74
- for (const [label, helpers, zod] of [
75
- ['installed', '0.1.128', '4.6.5'],
76
- ['minimum', '0.1.127', '4.5.4'],
77
- ]) {
78
- const fixture = join(proof, label)
79
- mkdirSync(fixture)
80
- writeFileSync(
81
- join(fixture, 'package.json'),
82
- JSON.stringify({
83
- private: true,
84
- type: 'module',
85
- dependencies: {
86
- 'cvx-kit': `file:${tarball}`,
87
- convex: '1.46.0',
88
- 'convex-helpers': helpers,
89
- zod,
90
- typescript: '7.0.2',
91
- 'convex-test': '0.0.61',
92
- '@types/node': manifest.devDependencies['@types/node'],
93
- oxlint: manifest.devDependencies.oxlint,
94
- },
95
- }),
96
- )
97
- const templates = join(root, 'test/fixture-packed-querying')
98
- for (const source of files(templates)) {
99
- const destination = join(fixture, relative(templates, source).replace(/\.template$/, ''))
100
- mkdirSync(resolve(destination, '..'), { recursive: true })
101
- cpSync(source, destination)
102
- }
103
- mkdirSync(join(fixture, 'convex/_generated'), { recursive: true })
104
- writeFileSync(
105
- join(fixture, 'convex/_generated/dataModel.ts'),
106
- `import type {DataModelFromSchemaDefinition} from 'convex/server'; import schema from '../schema'; export type DataModel = DataModelFromSchemaDefinition<typeof schema>\n`,
107
- )
108
- writeFileSync(
109
- join(fixture, 'convex/_generated/server.ts'),
110
- `import {queryGeneric, mutationGeneric, actionGeneric, internalQueryGeneric, internalMutationGeneric, internalActionGeneric, type GenericQueryCtx} from 'convex/server'; import type {DataModel} from './dataModel'; export const query = queryGeneric; export const mutation = mutationGeneric; export const action = actionGeneric; export const internalQuery = internalQueryGeneric; export const internalMutation = internalMutationGeneric; export const internalAction = internalActionGeneric; export type QueryCtx = GenericQueryCtx<DataModel>\n`,
111
- )
112
- writeFileSync(
113
- join(fixture, 'tsconfig.json'),
114
- JSON.stringify({
115
- compilerOptions: {
116
- strict: true,
117
- types: ['node'],
118
- skipLibCheck: false,
119
- noEmit: true,
120
- target: 'ES2025',
121
- module: 'ESNext',
122
- moduleResolution: 'bundler',
123
- allowImportingTsExtensions: true,
124
- },
125
- include: ['convex/**/*.ts', 'types.ts', 'runtime.ts', 'focused.ts'],
126
- }),
127
- )
128
- run('bun', ['install', '--ignore-scripts'], fixture, `${label}-install`)
129
- const versions = Object.fromEntries(
130
- ['cvx-kit', 'convex', 'convex-helpers', 'zod', 'typescript', 'convex-test'].map((name) => [
131
- name,
132
- JSON.parse(readFileSync(join(fixture, 'node_modules', name, 'package.json'), 'utf8')).version,
133
- ]),
134
- )
135
- writeFileSync(join(fixture, 'versions.json'), JSON.stringify(versions, null, 2))
136
- run(
137
- join(fixture, 'node_modules/.bin/tsc'),
138
- ['--project', 'tsconfig.json'],
139
- fixture,
140
- `${label}-types`,
141
- )
142
- const consumerRules = JSON.parse(
143
- run(
144
- 'node',
145
- [
146
- '--input-type=module',
147
- '-e',
148
- "import plugin from 'cvx-kit/oxlint'; console.log(JSON.stringify(Object.keys(plugin.rules)))",
149
- ],
150
- fixture,
151
- `${label}-consumer-rules`,
152
- ),
153
- )
154
- assert.equal(consumerRules.length, 23, 'Run every exported packaged consumer rule')
155
- writeFileSync(
156
- join(fixture, '.oxlintrc.json'),
157
- JSON.stringify({
158
- jsPlugins: [{ name: 'cvx', specifier: 'cvx-kit/oxlint' }],
159
- rules: Object.fromEntries(consumerRules.map((r) => [`cvx/${r}`, 'error'])),
160
- }),
161
- )
162
- run(
163
- join(fixture, 'node_modules/.bin/oxlint'),
164
- ['--config', '.oxlintrc.json', 'convex'],
165
- fixture,
166
- `${label}-consumer-lint`,
167
- )
168
- const tests = files(join(fixture, 'convex'))
169
- .filter((p) => p.endsWith('.test.ts'))
170
- .map((p) => relative(fixture, p))
171
- assert.equal(tests.length, 3)
172
- run(
173
- 'node',
174
- ['--import', './register.mjs', '--test', ...tests],
175
- fixture,
176
- `${label}-colocated-tests`,
177
- )
178
- run('node', ['--import', './register.mjs', 'runtime.ts'], fixture, `${label}-runtime`)
179
- run('node', ['--import', './register.mjs', 'focused.ts'], fixture, `${label}-focused`)
180
- }
181
- const after = sourceHashes()
182
- writeFileSync(join(proof, 'source-after.json'), JSON.stringify(after, null, 2))
183
- assert.deepEqual(after, before, 'source must stay fixed during packed verification')
184
- writeFileSync(join(proof, 'SUCCESS'), 'Both strict packed peers and full runtime stress passed.\n')
185
- console.log(`Packed querying complete. Evidence retained at ${proof}`)