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.
- package/README.md +59 -38
- package/dist/relations.mjs +1 -1
- package/dist/relations.mjs.map +1 -1
- package/dist/zod-table.d.mts +59 -2
- package/dist/zod-table.mjs +1 -1
- package/dist/zod-table.mjs.map +1 -1
- package/package.json +10 -3
- package/AGENTS.md +0 -47
- package/CHANGELOG.md +0 -337
- package/ROADMAP.md +0 -126
- package/docs/agent-tools.md +0 -41
- package/docs/approvals.md +0 -201
- package/docs/architecture.md +0 -124
- package/docs/auth.md +0 -443
- package/docs/command-context.md +0 -150
- package/docs/commands-legacy.md +0 -513
- package/docs/commands.md +0 -173
- package/docs/conventions.md +0 -345
- package/docs/crud.md +0 -66
- package/docs/domain-contracts.md +0 -148
- package/docs/domain-operations.md +0 -615
- package/docs/effect.md +0 -403
- package/docs/llms.md +0 -324
- package/docs/maintainability.md +0 -124
- package/docs/migration.md +0 -351
- package/docs/oxlint.md +0 -260
- package/docs/querying.md +0 -329
- package/docs/tenancy.md +0 -176
- package/docs/triggers.md +0 -77
- package/docs/upgrading.md +0 -287
- package/docs/webhooks.md +0 -58
- package/docs/zod-table.md +0 -278
- package/scripts/convex-config-bridge.mjs +0 -44
- package/scripts/convex-smoke-env.mjs +0 -33
- package/scripts/extract-changelog.mjs +0 -29
- package/scripts/owned-process.mjs +0 -140
- package/scripts/owned-process.test.mjs +0 -107
- package/scripts/smoke-packed-components.mjs +0 -341
- package/scripts/smoke-packed-effect.mjs +0 -439
- package/scripts/smoke-packed-querying.mjs +0 -298
- package/scripts/test-packed-auth.mjs +0 -72
- package/scripts/test-packed-effect.mjs +0 -482
- package/scripts/test-packed-ids.mjs +0 -150
- package/scripts/test-packed-oxlint.mjs +0 -167
- package/scripts/test-packed-querying.mjs +0 -185
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import { execFileSync } from 'node:child_process'
|
|
3
|
-
import { runOwnedProcess, collectOwnedCleanup } from './owned-process.mjs'
|
|
4
|
-
import { createHash } from 'node:crypto'
|
|
5
|
-
import {
|
|
6
|
-
cpSync,
|
|
7
|
-
existsSync,
|
|
8
|
-
mkdtempSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
readdirSync,
|
|
11
|
-
symlinkSync,
|
|
12
|
-
writeFileSync,
|
|
13
|
-
} from 'node:fs'
|
|
14
|
-
import { createServer } from 'node:net'
|
|
15
|
-
import { join, resolve, relative } from 'node:path'
|
|
16
|
-
import {
|
|
17
|
-
localConvexEnvironment,
|
|
18
|
-
assertIsolatedConvexFixture,
|
|
19
|
-
assertLocalConvexState,
|
|
20
|
-
} from './convex-smoke-env.mjs'
|
|
21
|
-
|
|
22
|
-
// Run against the retained installed peer of the exact packed stress candidate.
|
|
23
|
-
const packed = resolve(process.argv[2] ?? '')
|
|
24
|
-
const identity = JSON.parse(readFileSync(join(packed, 'package-identity.json'), 'utf8'))
|
|
25
|
-
const hash = (bytes) => createHash('sha256').update(bytes).digest('hex')
|
|
26
|
-
assert.equal(hash(readFileSync(identity.tarball)), identity.sha256)
|
|
27
|
-
const source = join(packed, 'installed')
|
|
28
|
-
assert.equal(
|
|
29
|
-
JSON.parse(readFileSync(join(source, 'node_modules/convex/package.json'), 'utf8')).version,
|
|
30
|
-
'1.46.0',
|
|
31
|
-
)
|
|
32
|
-
const fixture = mkdtempSync('/tmp/cvx-relational-engine-native-')
|
|
33
|
-
console.log(`U8 native retained proof: ${fixture}`)
|
|
34
|
-
cpSync(join(source, 'convex'), join(fixture, 'convex'), { recursive: true })
|
|
35
|
-
symlinkSync(join(source, 'node_modules'), join(fixture, 'node_modules'), 'dir')
|
|
36
|
-
writeFileSync(
|
|
37
|
-
join(fixture, 'package.json'),
|
|
38
|
-
JSON.stringify({
|
|
39
|
-
private: true,
|
|
40
|
-
type: 'module',
|
|
41
|
-
dependencies: { convex: '1.46.0', 'cvx-kit': identity.version },
|
|
42
|
-
}),
|
|
43
|
-
)
|
|
44
|
-
cpSync(join(source, 'register.mjs'), join(fixture, 'register.mjs'))
|
|
45
|
-
cpSync(
|
|
46
|
-
resolve(import.meta.dirname, '../test/fixture-packed-querying/audit-native.mjs.template'),
|
|
47
|
-
join(fixture, 'audit.mjs'),
|
|
48
|
-
)
|
|
49
|
-
cpSync(join(source, 'tsconfig.json'), join(fixture, 'tsconfig.json'))
|
|
50
|
-
writeFileSync(join(fixture, 'package-identity.json'), JSON.stringify(identity, null, 2))
|
|
51
|
-
// Native representative runs under central defaults, rather than the stress ceilings.
|
|
52
|
-
writeFileSync(
|
|
53
|
-
join(fixture, 'convex/querying.ts'),
|
|
54
|
-
`import { createQueryEngine } from 'cvx-kit/querying'
|
|
55
|
-
import schema from './schema'
|
|
56
|
-
import { relations } from './relations'
|
|
57
|
-
export const querying = createQueryEngine({ schema, relations })
|
|
58
|
-
`,
|
|
59
|
-
)
|
|
60
|
-
const originalRelations = readFileSync(join(fixture, 'convex/relations.ts'), 'utf8')
|
|
61
|
-
writeFileSync(join(fixture, 'convex/relations.ts'), originalRelations)
|
|
62
|
-
writeFileSync(join(fixture, 'convex/relationsEquivalent.ts'), originalRelations)
|
|
63
|
-
writeFileSync(
|
|
64
|
-
join(fixture, 'convex/relationsChanged.ts'),
|
|
65
|
-
originalRelations.replace(
|
|
66
|
-
'aliasLabels: r.many.labels({ from: r.tasks._id.through(r.edges.task), to: r.labels._id.through(r.edges.label) })',
|
|
67
|
-
'aliasLabels: r.many.labels({ from: r.tasks._id, to: r.labels.task })',
|
|
68
|
-
),
|
|
69
|
-
)
|
|
70
|
-
writeFileSync(
|
|
71
|
-
join(fixture, 'convex/api/probes.ts'),
|
|
72
|
-
`import { createQueryEngine } from 'cvx-kit/querying'
|
|
73
|
-
import { authQuery } from '../functions'
|
|
74
|
-
import { relations as equivalent } from '../relationsEquivalent'
|
|
75
|
-
import { relations as changed } from '../relationsChanged'
|
|
76
|
-
import schema from '../schema'
|
|
77
|
-
import { contract } from '../domain/tasks/contracts'
|
|
78
|
-
const eq = createQueryEngine({ schema, relations: equivalent })
|
|
79
|
-
const different = createQueryEngine({ schema, relations: changed })
|
|
80
|
-
export const resume = authQuery({ args: contract.queries.list.input, returns: contract.queries.list.result, handler: (ctx,args) => eq(ctx).tasks.paginate(args) })
|
|
81
|
-
export const reject = authQuery({ args: contract.queries.list.input, returns: contract.queries.list.result, handler: (ctx,args) => different(ctx).tasks.paginate(args) })
|
|
82
|
-
`,
|
|
83
|
-
)
|
|
84
|
-
writeFileSync(
|
|
85
|
-
join(fixture, 'convex/seed.ts'),
|
|
86
|
-
`import { internalMutation } from './_generated/server'
|
|
87
|
-
export const seed = internalMutation({ args: {}, handler: async (ctx) => {
|
|
88
|
-
const tasks = []
|
|
89
|
-
for(let ordinal=0;ordinal<24;ordinal++) tasks.push(await ctx.db.insert('tasks',{ordinal,tenant:'a',department:'support',status:'open',active:false,priority:0,code:'',authorized:ordinal>=5,secret:'NATIVE_PRIVATE'}))
|
|
90
|
-
const labels=[]
|
|
91
|
-
for(let ordinal=0;ordinal<6;ordinal++) labels.push(await ctx.db.insert('labels',{ordinal,tenant:'a',authorized:ordinal!==5,name:'native-label-'+ordinal,task:tasks[5]}))
|
|
92
|
-
await ctx.db.patch(tasks[5],{reference:tasks[0],required:labels[0]})
|
|
93
|
-
for(let ordinal=0;ordinal<6;ordinal++) await ctx.db.insert('edges',{ordinal,task:tasks[5],label:labels[ordinal],authorized:ordinal!==4})
|
|
94
|
-
await ctx.db.insert('edges',{ordinal:6,task:tasks[5],label:labels[1],authorized:true})
|
|
95
|
-
return {tasks,labels}
|
|
96
|
-
} })
|
|
97
|
-
`,
|
|
98
|
-
)
|
|
99
|
-
// Generated by the native CLI before deployment; initial binding supports the HTTP seed route.
|
|
100
|
-
const serverPath = join(fixture, 'convex/_generated/server.ts')
|
|
101
|
-
writeFileSync(
|
|
102
|
-
serverPath,
|
|
103
|
-
readFileSync(serverPath, 'utf8') +
|
|
104
|
-
"\nexport { httpActionGeneric as httpAction } from 'convex/server'\n",
|
|
105
|
-
)
|
|
106
|
-
writeFileSync(
|
|
107
|
-
join(fixture, 'convex/http.ts'),
|
|
108
|
-
`import { httpRouter } from 'convex/server'
|
|
109
|
-
import { httpAction } from './_generated/server'
|
|
110
|
-
import { makeFunctionReference } from 'convex/server'
|
|
111
|
-
const router=httpRouter()
|
|
112
|
-
router.route({path:'/seed',method:'POST',handler:httpAction(async ctx=>new Response(JSON.stringify(await ctx.runMutation(makeFunctionReference<'mutation'>('seed:seed'),{})),{headers:{'content-type':'application/json'}}))})
|
|
113
|
-
export default router
|
|
114
|
-
`,
|
|
115
|
-
)
|
|
116
|
-
// Metadata comes from actual native registered functions, not a reduced hand-written validator.
|
|
117
|
-
writeFileSync(
|
|
118
|
-
join(fixture, 'metadata.mjs'),
|
|
119
|
-
`import { writeFileSync } from 'node:fs'; import * as api from './convex/api/tasks.ts';
|
|
120
|
-
for(const [name, fn] of Object.entries(api)) writeFileSync('validator-'+name+'.json',JSON.stringify({args:JSON.parse(fn.exportArgs()),returns:JSON.parse(fn.exportReturns())}));
|
|
121
|
-
`,
|
|
122
|
-
)
|
|
123
|
-
writeFileSync(
|
|
124
|
-
join(fixture, 'verify.mjs'),
|
|
125
|
-
`import assert from 'node:assert/strict';import {readFileSync,writeFileSync} from 'node:fs';import {spawnSync} from 'node:child_process';
|
|
126
|
-
// Public fixture key only: configure the isolated backend, exercising its real process.env.
|
|
127
|
-
for (const [name,value] of [['CVX_QUERY_CURSOR_KEYS_JSON',JSON.stringify({fixture:'07'.repeat(64)})],['CVX_QUERY_CURSOR_CURRENT_KEY_ID','fixture']]) {
|
|
128
|
-
const result=spawnSync(process.execPath,['node_modules/convex/bin/main.js','env','set',name,value],{encoding:'utf8',timeout:30000});assert.equal(result.status,0,'fixture env setup failed');
|
|
129
|
-
}
|
|
130
|
-
const key=JSON.parse(readFileSync('.convex/local/default/config.json')).adminKey;
|
|
131
|
-
const who={subject:'native-reader',issuer:'https://fixture.test',tokenIdentifier:'https://fixture.test|native-reader',org_id:'a',role:'reader'};
|
|
132
|
-
const url='http://127.0.0.1:'+process.argv[2];const records=[];
|
|
133
|
-
async function call(path,label,args,valid=true,identity=who){
|
|
134
|
-
const started=performance.now();const res=await fetch(url+'/api/query',{method:'POST',headers:{'content-type':'application/json',...(identity?{Authorization:'Convex '+key+':'+Buffer.from(JSON.stringify(identity)).toString('base64')}:{})},body:JSON.stringify({path,args,format:'json'})});const raw=await res.text();writeFileSync('http-'+records.length+'-'+label+'.json',raw);const body=JSON.parse(raw);assert.equal(res.status,200);assert.equal(body.status,valid?'success':'error',label+': '+raw);assert.ok(!raw.includes('NATIVE_PRIVATE'));records.push({path,label,args,status:body.status,milliseconds:performance.now()-started,bytes:Buffer.byteLength(raw)});writeFileSync('native-results.json',JSON.stringify(records,null,2));return body;
|
|
135
|
-
}
|
|
136
|
-
// Local deployment registration also consumes the backend write-rate window.
|
|
137
|
-
await new Promise(resolve=>setTimeout(resolve,2000));
|
|
138
|
-
const seedResponse=await fetch('http://127.0.0.1:'+process.argv[3]+'/seed',{method:'POST'});const seedRaw=await seedResponse.text();writeFileSync('seed-envelope.json',seedRaw);assert.equal(seedResponse.status,200);const ids=JSON.parse(seedRaw);
|
|
139
|
-
for(const order of ['asc','desc']){let cursor=null;const actual=[];for(let page=0;page<30;page++){const body=await call('api/tasks:conditional','conditional-'+order+'-'+page,{numItems:7,cursor,order,filters:{active:false}});actual.push(...body.value.page.map(r=>r._id));if(body.value.isDone)break;assert.notEqual(body.value.continueCursor,cursor);cursor=body.value.continueCursor;}const expected=ids.tasks.slice(5);if(order==='desc')expected.reverse();assert.deepEqual(actual,expected);}
|
|
140
|
-
const first=(await call('api/tasks:list','first',{numItems:1,cursor:null})).value;
|
|
141
|
-
assert.match(first.continueCursor,/^pc\\./);assert.ok(!first.continueCursor.includes(ids.tasks[5]));
|
|
142
|
-
await call('api/probes:resume','equivalent-registry',{numItems:7,cursor:first.continueCursor});
|
|
143
|
-
await call('api/probes:reject','changed-registry',{numItems:7,cursor:first.continueCursor},false);
|
|
144
|
-
for(const [label,args,identity] of [['tamper',{numItems:1,cursor:first.continueCursor+'!'},who],['filter',{numItems:1,cursor:first.continueCursor,filters:{ordinal:6}},who],['order',{numItems:1,cursor:first.continueCursor,order:'desc'},who],['tenant',{numItems:1,cursor:first.continueCursor},{...who,org_id:'b'}],['principal',{numItems:1,cursor:first.continueCursor},{...who,subject:'other',tokenIdentifier:'other'}]]){const body=await call('api/tasks:list',label,args,false,identity);assert.match(body.errorMessage,/Invalid cursor/);}
|
|
145
|
-
await call('api/tasks:list','no-identity',{numItems:1,cursor:null},false,null);
|
|
146
|
-
await call('api/tasks:list','unsupported-role',{numItems:1,cursor:null},false,{...who,role:'unknown'});
|
|
147
|
-
const expanded=(await call('api/tasks:expanded','expanded',{numItems:7,cursor:null,filters:{ordinal:5}})).value.page[0];assert.equal(expanded.referenceTask,null);assert.equal(expanded.requiredLabel._id,ids.labels[0]);assert.equal(expanded.labels.page.length,5);assert.ok(expanded.labels.page.every(r=>r.owner._id===ids.tasks[5]));assert.deepEqual(expanded.labels.page.map(r=>r._id),expanded.aliasLabels.page.map(r=>r._id));
|
|
148
|
-
const predicate=(await call('api/tasks:list','nested-predicate',{numItems:7,cursor:null,filters:{labels:{some:{ordinal:1,owner:{ordinal:5}}}}})).value;assert.deepEqual(predicate.page.map(r=>r._id),[ids.tasks[5]]);
|
|
149
|
-
let cursor=null;const child=[];for(let page=0;page<10;page++){const value=(await call('api/tasks:next','child-'+page,{parent:ids.tasks[5],numItems:1,cursor})).value;child.push(...value.page.map(r=>r._id));if(value.isDone)break;cursor=value.continueCursor;}assert.deepEqual(child,[...ids.labels.slice(0,4),ids.labels[1]]);
|
|
150
|
-
await call('api/tasks:next','cross-parent',{parent:ids.tasks[6],numItems:1,cursor},false);
|
|
151
|
-
for(const [label,args] of [['wrong-scalar',{numItems:1,cursor:null,filters:{referenceTask:{ordinal:'wrong'}}}],['unknown-operator',{numItems:1,cursor:null,filters:{ordinal:{bad:1}}}],['bad-options',{numItems:0,cursor:null}],['unknown-field',{numItems:1,cursor:null,filters:{unknown:1}}]])await call('api/tasks:list',label,args,false);
|
|
152
|
-
const wrongTable=await call('api/tasks:next','wrong-table-parent',{parent:ids.labels[0],numItems:1,cursor:null},false);assert.match(wrongTable.errorMessage,/ArgumentValidationError/);assert.ok(!wrongTable.errorMessage.includes('Invalid cursor'));
|
|
153
|
-
const split=(await call('api/tasks:list','native-limit',{numItems:100,cursor:null,maximumRowsRead:8})).value;assert.match(split.splitCursor,/^pc\\./);assert.ok(['SplitRequired','SplitRecommended'].includes(split.pageStatus));
|
|
154
|
-
const left=(await call('api/tasks:list','end-left',{numItems:100,cursor:null,endCursor:split.splitCursor})).value;const right=(await call('api/tasks:list','end-right',{numItems:100,cursor:split.splitCursor,endCursor:split.continueCursor})).value;assert.deepEqual([...left.page,...right.page],split.page);
|
|
155
|
-
const cli=spawnSync(process.execPath,['node_modules/convex/bin/main.js','run','api/tasks:list',JSON.stringify({numItems:1,cursor:null}),'--identity',JSON.stringify(who)],{encoding:'utf8',timeout:30000});writeFileSync('cli-identity.stdout.log',cli.stdout);writeFileSync('cli-identity.stderr.log',cli.stderr);assert.equal(cli.status,0);assert.equal(JSON.parse(cli.stdout).page[0]._id,ids.tasks[5]);
|
|
156
|
-
writeFileSync('NATIVE_SUCCESS',JSON.stringify({cases:records.length,cliIdentity:true}));console.log(records.length+' native HTTP envelopes passed');
|
|
157
|
-
`,
|
|
158
|
-
)
|
|
159
|
-
const files = (dir) =>
|
|
160
|
-
readdirSync(dir, { withFileTypes: true }).flatMap((e) =>
|
|
161
|
-
e.isDirectory() ? files(join(dir, e.name)) : [join(dir, e.name)],
|
|
162
|
-
)
|
|
163
|
-
const paths = files(join(fixture, 'convex')).filter((p) => !p.includes('/_generated/'))
|
|
164
|
-
const hashes = () =>
|
|
165
|
-
Object.fromEntries(paths.map((p) => [relative(fixture, p), hash(readFileSync(p))]))
|
|
166
|
-
const before = hashes()
|
|
167
|
-
writeFileSync(join(fixture, 'source-before.json'), JSON.stringify(before, null, 2))
|
|
168
|
-
execFileSync(process.execPath, ['--import', './register.mjs', 'metadata.mjs'], {
|
|
169
|
-
cwd: fixture,
|
|
170
|
-
stdio: 'pipe',
|
|
171
|
-
})
|
|
172
|
-
const metadata = files(fixture).filter((p) => /validator-.*\.json$/.test(p))
|
|
173
|
-
writeFileSync(
|
|
174
|
-
join(fixture, 'native-validator-hashes.json'),
|
|
175
|
-
JSON.stringify(
|
|
176
|
-
metadata.map((p) => ({
|
|
177
|
-
path: relative(fixture, p),
|
|
178
|
-
bytes: readFileSync(p).length,
|
|
179
|
-
sha256: hash(readFileSync(p)),
|
|
180
|
-
})),
|
|
181
|
-
null,
|
|
182
|
-
2,
|
|
183
|
-
),
|
|
184
|
-
)
|
|
185
|
-
const env = localConvexEnvironment()
|
|
186
|
-
assertIsolatedConvexFixture(fixture)
|
|
187
|
-
async function freePort(requested = 0) {
|
|
188
|
-
const server = createServer()
|
|
189
|
-
await new Promise((done, fail) => {
|
|
190
|
-
server.once('error', fail)
|
|
191
|
-
server.listen(requested, '127.0.0.1', done)
|
|
192
|
-
})
|
|
193
|
-
const port = server.address().port
|
|
194
|
-
await new Promise((done) => server.close(done))
|
|
195
|
-
return port
|
|
196
|
-
}
|
|
197
|
-
const cloud = await freePort()
|
|
198
|
-
let site = await freePort()
|
|
199
|
-
while (site === cloud) site = await freePort()
|
|
200
|
-
const commands = []
|
|
201
|
-
const processes = []
|
|
202
|
-
async function run(label, args) {
|
|
203
|
-
commands.push([process.execPath, 'node_modules/convex/bin/main.js', ...args])
|
|
204
|
-
writeFileSync(join(fixture, 'commands.json'), JSON.stringify(commands, null, 2))
|
|
205
|
-
const result = await runOwnedProcess({
|
|
206
|
-
command: process.execPath,
|
|
207
|
-
args: commands.at(-1).slice(1),
|
|
208
|
-
cwd: fixture,
|
|
209
|
-
env,
|
|
210
|
-
onSpawn: (pid) => processes.push(pid),
|
|
211
|
-
})
|
|
212
|
-
const { stdout, stderr, ...evidence } = result
|
|
213
|
-
writeFileSync(join(fixture, label + '.stdout.log'), stdout)
|
|
214
|
-
writeFileSync(join(fixture, label + '.stderr.log'), stderr)
|
|
215
|
-
writeFileSync(join(fixture, label + '-result.json'), JSON.stringify(evidence, null, 2))
|
|
216
|
-
assert.equal(result.code, 0, label + ' failed; retained logs')
|
|
217
|
-
assert.equal(result.timedOut, false, label + ' timed out; retained logs')
|
|
218
|
-
assert.equal(result.cleanup?.alive, false, label + ' owned group survived cleanup')
|
|
219
|
-
console.log(label + ': exit 0')
|
|
220
|
-
}
|
|
221
|
-
let originalFailure
|
|
222
|
-
try {
|
|
223
|
-
await run('deploy', [
|
|
224
|
-
'dev',
|
|
225
|
-
'--once',
|
|
226
|
-
'--typecheck=disable',
|
|
227
|
-
'--local-cloud-port',
|
|
228
|
-
String(cloud),
|
|
229
|
-
'--local-site-port',
|
|
230
|
-
String(site),
|
|
231
|
-
])
|
|
232
|
-
assertLocalConvexState(fixture)
|
|
233
|
-
const cfg = JSON.parse(readFileSync(join(fixture, '.convex/local/default/config.json')))
|
|
234
|
-
assert.equal(cfg.ports.cloud, cloud)
|
|
235
|
-
assert.equal(cfg.ports.site, site)
|
|
236
|
-
writeFileSync(
|
|
237
|
-
join(fixture, 'local-binding.json'),
|
|
238
|
-
JSON.stringify({ ports: cfg.ports, backendVersion: cfg.backendVersion }),
|
|
239
|
-
)
|
|
240
|
-
execFileSync(join(source, 'node_modules/.bin/tsc'), ['--project', 'tsconfig.json'], {
|
|
241
|
-
cwd: fixture,
|
|
242
|
-
stdio: 'pipe',
|
|
243
|
-
})
|
|
244
|
-
writeFileSync(
|
|
245
|
-
join(fixture, 'strict-types-result.json'),
|
|
246
|
-
JSON.stringify({ exitCode: 0, strict: true, skipLibCheck: false }),
|
|
247
|
-
)
|
|
248
|
-
await run('runtime', [
|
|
249
|
-
'dev',
|
|
250
|
-
'--once',
|
|
251
|
-
'--typecheck=disable',
|
|
252
|
-
'--start',
|
|
253
|
-
`node verify.mjs ${cloud} ${site}`,
|
|
254
|
-
])
|
|
255
|
-
assert.ok(existsSync(join(fixture, 'NATIVE_SUCCESS')))
|
|
256
|
-
const rows = JSON.parse(readFileSync(join(fixture, 'native-results.json')))
|
|
257
|
-
assert.ok(rows.length >= 25)
|
|
258
|
-
assert.equal(files(fixture).filter((p) => /http-\d+-.*\.json$/.test(p)).length, rows.length)
|
|
259
|
-
const key = JSON.parse(readFileSync(join(fixture, '.convex/local/default/config.json'))).adminKey
|
|
260
|
-
for (const path of files(fixture).filter(
|
|
261
|
-
(p) => /\.(log|json)$/.test(p) && !p.includes('/.convex/'),
|
|
262
|
-
)) {
|
|
263
|
-
const bytes = readFileSync(path, 'utf8')
|
|
264
|
-
assert.ok(!bytes.includes(key))
|
|
265
|
-
assert.ok(!bytes.includes('Authorization: Convex'))
|
|
266
|
-
}
|
|
267
|
-
assert.deepEqual(hashes(), before)
|
|
268
|
-
assert.equal(hash(readFileSync(identity.tarball)), identity.sha256)
|
|
269
|
-
writeFileSync(join(fixture, 'source-after.json'), JSON.stringify(hashes(), null, 2))
|
|
270
|
-
} catch (error) {
|
|
271
|
-
originalFailure = error
|
|
272
|
-
throw error
|
|
273
|
-
} finally {
|
|
274
|
-
const cleanup = await collectOwnedCleanup({
|
|
275
|
-
pids: processes,
|
|
276
|
-
ports: [cloud, site],
|
|
277
|
-
checkPort: freePort,
|
|
278
|
-
failure: originalFailure,
|
|
279
|
-
})
|
|
280
|
-
writeFileSync(join(fixture, 'cleanup.json'), JSON.stringify(cleanup, null, 2))
|
|
281
|
-
// Preserve the original proof error; cleanup diagnostics remain independently recorded.
|
|
282
|
-
if (!originalFailure) {
|
|
283
|
-
assert.ok(
|
|
284
|
-
cleanup.groups.every((group) => !group.alive && !group.error && group.errors.length === 0),
|
|
285
|
-
'Owned process cleanup failed',
|
|
286
|
-
)
|
|
287
|
-
assert.ok(
|
|
288
|
-
cleanup.ports.every((port) => port.closed),
|
|
289
|
-
'Owned ports remain occupied',
|
|
290
|
-
)
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
writeFileSync(
|
|
294
|
-
join(fixture, 'SUCCESS'),
|
|
295
|
-
'Bounded exact packed default runtime integrated proof passed.\n',
|
|
296
|
-
)
|
|
297
|
-
execFileSync(process.execPath, ['audit.mjs'], { cwd: fixture, stdio: 'pipe' })
|
|
298
|
-
console.log(`Native proof complete: ${fixture}`)
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from 'node:child_process'
|
|
2
|
-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
|
3
|
-
import { tmpdir } from 'node:os'
|
|
4
|
-
import { basename, join, resolve } from 'node:path'
|
|
5
|
-
|
|
6
|
-
const root = resolve(import.meta.dirname, '..')
|
|
7
|
-
const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
|
|
8
|
-
const temporary = mkdtempSync(join(tmpdir(), 'cvx-kit-auth-'))
|
|
9
|
-
function run(command, args, cwd) {
|
|
10
|
-
try {
|
|
11
|
-
return execFileSync(command, args, { cwd, encoding: 'utf8', stdio: 'pipe' })
|
|
12
|
-
} catch (error) {
|
|
13
|
-
if (!args.includes('install')) {
|
|
14
|
-
process.stderr.write(error.stdout ?? '')
|
|
15
|
-
process.stderr.write(error.stderr ?? '')
|
|
16
|
-
}
|
|
17
|
-
throw new Error(`${command} ${args.join(' ')} failed in ${basename(cwd)}`, {
|
|
18
|
-
cause: error.code,
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
run('bun', ['pm', 'pack', '--ignore-scripts', '--destination', temporary], root)
|
|
24
|
-
const tarball = join(temporary, `${manifest.name}-${manifest.version}.tgz`)
|
|
25
|
-
// 1.45 is a declaration regression target, below the current workflow peer floor.
|
|
26
|
-
for (const convex of ['1.45.0', '1.46.0']) {
|
|
27
|
-
const fixture = mkdtempSync(join(temporary, `convex-${convex}-`))
|
|
28
|
-
writeFileSync(
|
|
29
|
-
join(fixture, 'package.json'),
|
|
30
|
-
JSON.stringify({
|
|
31
|
-
private: true,
|
|
32
|
-
type: 'module',
|
|
33
|
-
dependencies: {
|
|
34
|
-
'cvx-kit': `file:${tarball}`,
|
|
35
|
-
convex,
|
|
36
|
-
'convex-helpers': manifest.devDependencies['convex-helpers'],
|
|
37
|
-
effect: manifest.devDependencies.effect,
|
|
38
|
-
zod: manifest.devDependencies.zod,
|
|
39
|
-
typescript: manifest.devDependencies.typescript,
|
|
40
|
-
'@types/node': manifest.devDependencies['@types/node'],
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
)
|
|
44
|
-
writeFileSync(
|
|
45
|
-
join(fixture, 'auth.ts'),
|
|
46
|
-
readFileSync(join(root, 'test/auth-native-context-types.ts')),
|
|
47
|
-
)
|
|
48
|
-
writeFileSync(
|
|
49
|
-
join(fixture, 'shared-auth.ts'),
|
|
50
|
-
readFileSync(join(root, 'test/effect-auth-types.ts')),
|
|
51
|
-
)
|
|
52
|
-
writeFileSync(
|
|
53
|
-
join(fixture, 'tsconfig.json'),
|
|
54
|
-
JSON.stringify({
|
|
55
|
-
compilerOptions: {
|
|
56
|
-
strict: true,
|
|
57
|
-
noEmit: true,
|
|
58
|
-
skipLibCheck: true,
|
|
59
|
-
target: 'ES2025',
|
|
60
|
-
module: 'ESNext',
|
|
61
|
-
moduleResolution: 'bundler',
|
|
62
|
-
},
|
|
63
|
-
include: ['auth.ts', 'shared-auth.ts'],
|
|
64
|
-
}),
|
|
65
|
-
)
|
|
66
|
-
run('bun', ['install', '--ignore-scripts'], fixture)
|
|
67
|
-
run('bun', ['x', '--no-install', 'tsc', '--project', 'tsconfig.json'], fixture)
|
|
68
|
-
console.log(`Packed auth native contexts pass on Convex ${convex}`)
|
|
69
|
-
}
|
|
70
|
-
} finally {
|
|
71
|
-
rmSync(temporary, { recursive: true, force: true })
|
|
72
|
-
}
|