cvx-kit 0.1.12 → 0.1.14

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 (79) hide show
  1. package/AGENTS.md +47 -0
  2. package/CHANGELOG.md +36 -0
  3. package/README.md +144 -0
  4. package/dist/auth.d.mts +3 -1
  5. package/dist/auth.mjs +1 -1
  6. package/dist/auth.mjs.map +1 -1
  7. package/dist/index.d.mts +5 -2
  8. package/dist/index.mjs +1 -1
  9. package/dist/modules/contracts/binding.d.mts +13 -1
  10. package/dist/modules/contracts/binding.mjs +1 -1
  11. package/dist/modules/contracts/binding.mjs.map +1 -1
  12. package/dist/modules/effect/api-zod.d.mts +1 -1
  13. package/dist/modules/effect/command.d.mts +13 -9
  14. package/dist/modules/effect/command.mjs.map +1 -1
  15. package/dist/modules/effect/domain.d.mts +31 -3
  16. package/dist/modules/effect/domain.mjs.map +1 -1
  17. package/dist/modules/effect/query.d.mts +6 -5
  18. package/dist/modules/effect/query.mjs.map +1 -1
  19. package/dist/modules/foundation/foundation.d.mts +14 -13
  20. package/dist/modules/foundation/foundation.mjs.map +1 -1
  21. package/dist/modules/foundation/operation.d.mts +20 -1
  22. package/dist/modules/foundation/operation.mjs.map +1 -1
  23. package/dist/oxlint/architecture.d.mts +2 -0
  24. package/dist/oxlint/architecture.mjs +1 -1
  25. package/dist/oxlint/architecture.mjs.map +1 -1
  26. package/dist/oxlint/ast.d.mts +10 -1
  27. package/dist/oxlint/ast.mjs +1 -1
  28. package/dist/oxlint/ast.mjs.map +1 -1
  29. package/dist/oxlint.d.mts +1 -1
  30. package/dist/oxlint.mjs +1 -1
  31. package/dist/oxlint.mjs.map +1 -1
  32. package/dist/querying/cursors.d.mts +45 -0
  33. package/dist/querying/cursors.mjs +2 -0
  34. package/dist/querying/cursors.mjs.map +1 -0
  35. package/dist/querying/execution.d.mts +30 -0
  36. package/dist/querying/execution.mjs +2 -0
  37. package/dist/querying/execution.mjs.map +1 -0
  38. package/dist/querying/filters.d.mts +136 -0
  39. package/dist/querying/filters.mjs +2 -0
  40. package/dist/querying/filters.mjs.map +1 -0
  41. package/dist/querying/planner.d.mts +50 -0
  42. package/dist/querying/planner.mjs +2 -0
  43. package/dist/querying/planner.mjs.map +1 -0
  44. package/dist/querying/relationships.d.mts +41 -0
  45. package/dist/querying/relationships.mjs +2 -0
  46. package/dist/querying/relationships.mjs.map +1 -0
  47. package/dist/querying/security.d.mts +107 -0
  48. package/dist/querying/security.mjs +2 -0
  49. package/dist/querying/security.mjs.map +1 -0
  50. package/dist/querying.d.mts +39 -0
  51. package/dist/querying.mjs +2 -0
  52. package/dist/querying.mjs.map +1 -0
  53. package/dist/relations-public.d.mts +2 -0
  54. package/dist/relations-public.mjs +1 -0
  55. package/dist/relations.d.mts +155 -0
  56. package/dist/relations.mjs +2 -0
  57. package/dist/relations.mjs.map +1 -0
  58. package/dist/zod-convex.d.mts +10 -0
  59. package/dist/zod-convex.mjs +2 -0
  60. package/dist/zod-convex.mjs.map +1 -0
  61. package/dist/zod-registration.d.mts +10 -0
  62. package/dist/zod-registration.mjs +2 -0
  63. package/dist/zod-registration.mjs.map +1 -0
  64. package/dist/zod-table.d.mts +63 -8
  65. package/dist/zod-table.mjs +1 -1
  66. package/dist/zod-table.mjs.map +1 -1
  67. package/docs/conventions.md +12 -0
  68. package/docs/domain-contracts.md +42 -9
  69. package/docs/llms.md +15 -5
  70. package/docs/oxlint.md +129 -25
  71. package/docs/querying.md +293 -0
  72. package/docs/zod-table.md +93 -13
  73. package/package.json +11 -1
  74. package/scripts/owned-process.mjs +140 -0
  75. package/scripts/owned-process.test.mjs +107 -0
  76. package/scripts/smoke-packed-querying.mjs +296 -0
  77. package/scripts/test-packed-effect.mjs +10 -1
  78. package/scripts/test-packed-oxlint.mjs +5 -1
  79. package/scripts/test-packed-querying.mjs +185 -0
@@ -0,0 +1,185 @@
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}`)