mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-04 10:03:29 +01:00
feat(go): implement current Node backend features
This commit is contained in:
1 parent
566171342c
commit
c201847b83
84 files changed
+8921
-384
No files matched your search
@@ -5,7 +5,7 @@ const schema=require('../../src/core/model/conference/conferences.schema').defau
|
||||
const Model=mongoose.model('conference_date_contract',schema);
|
||||
const source=ts.createSourceFile('conference.ts',fs.readFileSync('src/server/routes/conference.ts','utf8'),ts.ScriptTarget.Latest,true);
|
||||
const apply=source.statements.find(n=>ts.isFunctionDeclaration(n)&&n.name?.text==='applyConferenceForm');
|
||||
const mod={exports:{}};vm.runInNewContext(ts.transpile(apply.getText(source)+';module.exports=applyConferenceForm',{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.CommonJS}),{module:mod,exports:{},Date});
|
||||
const mod={exports:{}};vm.runInNewContext(ts.transpile(apply.getText(source)+';module.exports=applyConferenceForm',{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.CommonJS}),{module:mod,exports:{},Date,isConferencePlan:id=>["conference","conference_workshop","conference_large"].includes(id)});
|
||||
const values=['March 1 2031','2031-02-30','0001-01-01','0000-01-01','-000001-01-01','+010000-01-01','2031-01-01T24:00:00Z','2031-01-01T01:00:00+02:00','invalid','',null,false,true,0,1,1.5,-1.5,1924992000000,'1924992000000',8640000000000001,{}, {toString:'bad'}, {valueOf:1},[],['2031','1','1'],[1],[null]];
|
||||
const cases=[];
|
||||
for(const field of ['startDate','endDate'])for(const value of values){
|
||||
|
||||
@@ -7,13 +7,17 @@ const path = 'src/server/routes/conference.ts';
|
||||
const tree = ts.createSourceFile(path, fs.readFileSync(path, 'utf8'), ts.ScriptTarget.Latest, true);
|
||||
const validator = tree.statements.find(s => ts.isFunctionDeclaration(s) && s.name?.text === 'validateConferenceForm');
|
||||
const plans = tree.statements.find(s => ts.isVariableStatement(s) && s.declarationList.declarations.some(d => d.name.getText(tree) === 'plans'));
|
||||
assert.ok(validator && plans);
|
||||
assert.ok(validator);
|
||||
process.env.SESSION_SECRET ||= 'synthetic-conference-contract';
|
||||
require('ts-node/register/transpile-only');
|
||||
const billing = require('../../src/core/billing/config');
|
||||
const helpers=tree.statements.filter(s=>ts.isFunctionDeclaration(s)&&['conferencePlans','offeredConferencePlans'].includes(s.name?.text));
|
||||
const now = '2030-01-01T00:00:00.000Z';
|
||||
class FixedDate extends Date { constructor(...args) { super(...(args.length ? args : [now])); } }
|
||||
class AnonymousError extends Error { constructor(code, options) { super(code); this.status = options.httpStatus; } }
|
||||
const code = ts.transpileModule(`${plans.getText(tree)}\n${validator.getText(tree)}\nmodule.exports = validateConferenceForm;`, {compilerOptions: {target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS}}).outputText;
|
||||
const code = ts.transpileModule(`${helpers.map(s=>s.getText(tree)).join("\n")}\n${validator.getText(tree)}\nmodule.exports = validateConferenceForm;`, {compilerOptions: {target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS}}).outputText;
|
||||
const moduleObject = {exports: {}};
|
||||
vm.runInNewContext(code, {module: moduleObject, AnonymousError, Date: FixedDate});
|
||||
vm.runInNewContext(code, {module: moduleObject, exports:moduleObject.exports, AnonymousError, Date: FixedDate, config:{BILLING_ENABLED:false}, billingPlans:billing.billingPlans, isConferencePlan:billing.isConferencePlan, billingError:(code,status=400)=>new AnonymousError(code,{httpStatus:status})});
|
||||
const base = {name: 'Conference', conferenceID: 'conference-test', startDate: '2031-01-01', endDate: '2031-02-01', plan: {planID: 'free_conference'}};
|
||||
const cases = [];
|
||||
function add(name, change) {
|
||||
|
||||
@@ -12,7 +12,7 @@ function visit(node) {
|
||||
ts.forEachChild(node, visit);
|
||||
}
|
||||
visit(tree); assert.ok(expression);
|
||||
const code=ts.transpileModule(`module.exports=function(expected){return ${expression}}`, {compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText;
|
||||
const code=ts.transpileModule(`module.exports=function(expected,origin){return ${expression}}`, {compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText;
|
||||
const fixture={exports:{}};
|
||||
vm.runInNewContext(code,{module:fixture,Buffer,createHash,setTimeout,clearTimeout});
|
||||
const git = value => createHash('sha1').update(`blob ${Buffer.byteLength(value)}\0`).update(value).digest('hex');
|
||||
@@ -40,7 +40,7 @@ const inputs=[
|
||||
for (const [name,pointer,revision=git(pointer)] of inputs) {
|
||||
const row={name,pointer,revision,proof};
|
||||
let fetched=0;
|
||||
const verify=fixture.exports.call({data:{getToken:async()=> 'synthetic'},downloadFile:()=>{fetched++;return Readable.from([Buffer.from(pointer)]);}}, {sha:revision});
|
||||
const verify=fixture.exports.call({data:{getToken:async()=> 'synthetic'},downloadFile:()=>{fetched++;return Readable.from([Buffer.from(pointer)]);}}, {sha:revision}, {downloadFile:()=>{fetched++;return Readable.from([Buffer.from(pointer)]);}});
|
||||
try { row.expected=await verify(proof); } catch(error) { row.error=error.message; }
|
||||
row.fetched=fetched;rows.push(row);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ const config={MAX_FILE_SIZE:100*1024*1024,SHARED_CACHE_ENABLED:false};
|
||||
let current, transfers=0;
|
||||
class File {
|
||||
constructor(){}
|
||||
async assertContentFile(){}
|
||||
async originalPath(){return current.name}
|
||||
isFileSupported(){return true}
|
||||
async sha(){return 'blob'}
|
||||
|
||||
@@ -22,7 +22,7 @@ for (const [kind, route, helper, modelName] of [
|
||||
compilerOptions: {target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.CommonJS},
|
||||
}).outputText;
|
||||
const module = {exports: {}};
|
||||
vm.runInNewContext(code, {module, Date});
|
||||
vm.runInNewContext(code, {module, Date, normalizePreserveFiles: require("../../src/core/preserve-files").normalizePreserveFiles});
|
||||
const schema = require(`../../src/core/model/${modelName}/${modelName}.schema.ts`).default;
|
||||
const Model = mongoose.model(`options_contract_${kind}`, schema);
|
||||
const add = (name, options, terms = ['Alice', '']) => {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
const fs=require('node:fs');
|
||||
const assert=require('node:assert/strict');
|
||||
process.env.SESSION_SECRET ||= 'synthetic-preserve-contract';
|
||||
require('ts-node/register/transpile-only');
|
||||
const {isPreservedPath,normalizePreserveFiles}=require('../../src/core/preserve-files');
|
||||
const patterns=[['*.bib'],['/refs.bib'],['paper/**','!paper/private/'],['*.bib','!secret.bib','secret.bib'],['paper/'],['/paper/\\{a,b\\}.bib'],['**/*.{bib,json}'],['file{01..03}.txt'],['file{a..c}.txt'],['@(a|b).bib'],['+(a|b).bib'],['?(a|b).bib'],['*(a|b).bib'],['*.bib','!private/**'],['[!a]*.bib'],['**/.hidden'],['[draft].bib'],['\\[draft\\].bib'],['{a,{b,c}}.bib']];
|
||||
const paths=['refs.bib','sub/refs.bib','secret.bib','paper','paper/a.bib','paper/private/a.bib','paper/a.json','paper/{a,b}.bib','file01.txt','file02.txt','file03.txt','file04.txt','filea.txt','fileb.txt','filec.txt','a.bib','b.bib','c.bib','ab.bib','.bib','.hidden','sub/.hidden','[draft].bib','private/a.bib','d.bib'];
|
||||
const cases=patterns.flatMap(patterns=>paths.map(path=>({patterns,path,expected:isPreservedPath(path,patterns)})));
|
||||
const target='backend/internal/anonymize/testdata/preserve-files.json';const output=JSON.stringify(cases,null,2)+'\n';
|
||||
if(process.argv.includes('--check'))assert.equal(fs.readFileSync(target,'utf8'),output);else fs.writeFileSync(target,output);
|
||||
console.log(`${cases.length} preservation cases`);
|
||||
@@ -12,12 +12,12 @@ const mongoose=require('mongoose');
|
||||
const tree=ts.createSourceFile('route-utils.ts',fs.readFileSync('src/server/routes/route-utils.ts','utf8'),ts.ScriptTarget.Latest,true);
|
||||
const errorHelper=tree.statements.find(s=>ts.isFunctionDeclaration(s)&&s.name?.text==='handleError');
|
||||
const errorModule={exports:{}};
|
||||
vm.runInNewContext(ts.transpile(errorHelper.getText(tree).replace(/^export\s+/, '')+';module.exports=handleError',{target:ts.ScriptTarget.ES2022}),{module:errorModule,Error,AnonymousError:require('../../src/core/AnonymousError').default,printError:()=>{}});
|
||||
vm.runInNewContext(ts.transpile(errorHelper.getText(tree).replace(/^export\s+/, '')+';module.exports=handleError',{target:ts.ScriptTarget.ES2022}),{module:errorModule,Error,AnonymousError:require('../../src/core/AnonymousError').default,printError:()=>{},isResponseCancellation:()=>false});
|
||||
const cases=[];
|
||||
for(const [kind,route,helper,modelName] of [['repo','repository','updateRepoModel','anonymizedRepositories'],['gist','gist','updateGistModel','anonymizedGists'],['pr','pullRequest','updatePullRequestModel','anonymizedPullRequests']]){
|
||||
const source=ts.createSourceFile(route,fs.readFileSync(`src/server/routes/${route}-private.ts`,'utf8'),ts.ScriptTarget.Latest,true);
|
||||
const fn=source.statements.find(s=>ts.isFunctionDeclaration(s)&&s.name?.text===helper);
|
||||
const mod={exports:{}};vm.runInNewContext(ts.transpile(fn.getText(source)+';module.exports='+helper,{target:ts.ScriptTarget.ES2022}),{module:mod,Date});
|
||||
const mod={exports:{}};vm.runInNewContext(ts.transpile(fn.getText(source)+';module.exports='+helper,{target:ts.ScriptTarget.ES2022}),{module:mod,Date,normalizePreserveFiles:require("../../src/core/preserve-files").normalizePreserveFiles});
|
||||
const Model=connection.model(modelName,require(`../../src/core/model/${modelName}/${modelName}.schema.ts`).default);
|
||||
const options=[{}, {image:'bad'}, {image:[]}, {image:{}}, {expirationDate:'bad'}, {expirationDate:[]}, {expirationDate:{}}, {expirationDate:{toString:'bad'}}, {expirationDate:1e16}, {expirationDate:'0001-01-01'}, {expirationDate:['2030','3','1']}, {image:'bad',expirationDate:'bad',link:false}, {image:true,link:false}, {expirationMode:0}, {expirationMode:true}, {expirationMode:{}}, {expirationMode:[]}, {expirationMode:{_id:'date'}}, {pageSource:{branch:1,path:false}}, {pageSource:{branch:{},path:'/'}}, {pageSource:{branch:[],path:{}}}, {pageSource:null}, {pageSource:true}, {pageSource:[]}, {pageSource:{unknown:'ignored'}}];
|
||||
for(const create of [true,false])for(const input of options){
|
||||
|
||||
+189
-98
@@ -3,98 +3,161 @@
|
||||
"method": "POST",
|
||||
"path": "/github/app/webhook",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 267,
|
||||
"line": 308,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/billing/webhook",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 19,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/app/login",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 40,
|
||||
"line": 49,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/app/callback",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 56,
|
||||
"line": 65,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/app/install",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 95,
|
||||
"line": 106,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/app/setup",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 127,
|
||||
"line": 138,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/connections",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 150,
|
||||
"line": 162,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/connections/email",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 200,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/github/connections/email",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 209,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/github/connections/migrate",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 187,
|
||||
"line": 227,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/github/connections/disconnect-oauth",
|
||||
"source": "src/server/routes/github-app.ts",
|
||||
"line": 246,
|
||||
"line": 287,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/account-recovery",
|
||||
"source": "src/server/routes/connection.ts",
|
||||
"line": 193,
|
||||
"line": 201,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/login",
|
||||
"source": "src/server/routes/connection.ts",
|
||||
"line": 198,
|
||||
"line": 206,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/github/auth",
|
||||
"source": "src/server/routes/connection.ts",
|
||||
"line": 215,
|
||||
"line": 223,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/github/login-token",
|
||||
"source": "src/server/routes/connection.ts",
|
||||
"line": 243,
|
||||
"line": 251,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/billing",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 78,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/billing/draft/:id",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 99,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/billing/draft",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 111,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/billing/checkout",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 119,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/billing/portal",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 132,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/billing/refresh",
|
||||
"source": "src/server/routes/billing.ts",
|
||||
"line": 141,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/maintenance/repositories/:repoId",
|
||||
"source": "src/server/routes/maintenance.ts",
|
||||
"line": 28,
|
||||
"line": 34,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "PATCH",
|
||||
"path": "/api/maintenance/repositories/:repoId",
|
||||
"source": "src/server/routes/maintenance.ts",
|
||||
"line": 41,
|
||||
"line": 47,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
@@ -139,200 +202,214 @@
|
||||
"line": 67,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/billing/summary",
|
||||
"source": "src/server/routes/admin-billing.ts",
|
||||
"line": 16,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/billing/grants",
|
||||
"source": "src/server/routes/admin-billing.ts",
|
||||
"line": 24,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/performance",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 87,
|
||||
"line": 89,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/cache",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 93,
|
||||
"line": 95,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/:repo_id",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 180,
|
||||
"line": 182,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/admin/queue/:name/:repo_id",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 205,
|
||||
"line": 207,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/retry-failed",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 233,
|
||||
"line": 235,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/drain",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 254,
|
||||
"line": 256,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/pause",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 265,
|
||||
"line": 267,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/resume",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 276,
|
||||
"line": 278,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queue/:name/empty",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 287,
|
||||
"line": 289,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/queues/pause-all",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 298,
|
||||
"line": 300,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/queues/metrics",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 354,
|
||||
"line": 356,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/queues",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 369,
|
||||
"line": 371,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/errors",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 430,
|
||||
"line": 441,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/errors/stats",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 475,
|
||||
"line": 486,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/admin/errors",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 606,
|
||||
"line": 617,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/overview",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 636,
|
||||
"line": 647,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/stats",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 821,
|
||||
"line": 832,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/repos",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 850,
|
||||
"line": 861,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/admin/repos/:repoId",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 969,
|
||||
"line": 980,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/repos/:repoId/github",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 984,
|
||||
"line": 995,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/users",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1077,
|
||||
"line": 1088,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/users/:username",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1141,
|
||||
"line": 1152,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/users/:username/repos",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1168,
|
||||
"line": 1179,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/users/:username/ban",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1189,
|
||||
"line": 1200,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/users/:username/activate",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1225,
|
||||
"line": 1236,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/users/:username/promote",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1243,
|
||||
"line": 1254,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/admin/users/:username/demote",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1261,
|
||||
"line": 1272,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/admin/conferences",
|
||||
"source": "src/server/routes/admin.ts",
|
||||
"line": 1279,
|
||||
"line": 1290,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
@@ -346,168 +423,168 @@
|
||||
"method": "GET",
|
||||
"path": "/api/conferences/plans",
|
||||
"source": "src/server/routes/conference.ts",
|
||||
"line": 44,
|
||||
"line": 36,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/conferences",
|
||||
"source": "src/server/routes/conference.ts",
|
||||
"line": 48,
|
||||
"line": 40,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/conferences/{:conferenceID}",
|
||||
"source": "src/server/routes/conference.ts",
|
||||
"line": 163,
|
||||
"line": 159,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/conferences/:conferenceID",
|
||||
"source": "src/server/routes/conference.ts",
|
||||
"line": 234,
|
||||
"line": 230,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/conferences/:conferenceID",
|
||||
"source": "src/server/routes/conference.ts",
|
||||
"line": 272,
|
||||
"line": 275,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/logout",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 27,
|
||||
"line": 31,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 40,
|
||||
"line": 44,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/dashboard",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 53,
|
||||
"line": 68,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/quota",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 58,
|
||||
"line": 73,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/user/project-name",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 134,
|
||||
"line": 159,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/default",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 143,
|
||||
"line": 168,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/user/default",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 153,
|
||||
"line": 178,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/user",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 175,
|
||||
"line": 200,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/anonymized_repositories",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 251,
|
||||
"line": 281,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/anonymized_gists",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 269,
|
||||
"line": 299,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/anonymized_pull_requests",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 284,
|
||||
"line": 314,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/search/github-users",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 301,
|
||||
"line": 331,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/all_repositories",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 336,
|
||||
"line": 366,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/user/:username/all_repositories",
|
||||
"source": "src/server/routes/user.ts",
|
||||
"line": 347,
|
||||
"line": 377,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/zip",
|
||||
"source": "src/server/routes/repository-public.ts",
|
||||
"line": 23,
|
||||
"line": 27,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/files",
|
||||
"source": "src/server/routes/repository-public.ts",
|
||||
"line": 184,
|
||||
"line": 192,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/files/counts",
|
||||
"source": "src/server/routes/repository-public.ts",
|
||||
"line": 204,
|
||||
"line": 212,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/files/search",
|
||||
"source": "src/server/routes/repository-public.ts",
|
||||
"line": 256,
|
||||
"line": 275,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/options",
|
||||
"source": "src/server/routes/repository-public.ts",
|
||||
"line": 275,
|
||||
"line": 294,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
@@ -521,91 +598,105 @@
|
||||
"method": "POST",
|
||||
"path": "/api/repo/claim",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 71,
|
||||
"line": 79,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/repo/:repoId/refresh",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 144,
|
||||
"line": 153,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/repo/:repoId/extend",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 177,
|
||||
"line": 187,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/repo/:repoId",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 240,
|
||||
"line": 260,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:owner/:repo",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 267,
|
||||
"line": 287,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:owner/:repo/branches",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 286,
|
||||
"line": 306,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:owner/:repo/readme",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 310,
|
||||
"line": 330,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:owner/:repo/tree",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 363,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:owner/:repo/file",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 386,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 343,
|
||||
"line": 412,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/repo/:repoId",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 490,
|
||||
"line": 568,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/repo",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 663,
|
||||
"line": 788,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/repo/:repoId/coauthors",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 773,
|
||||
"line": 905,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/repo/:repoId/coauthors",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 789,
|
||||
"line": 921,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/repo/:repoId/coauthors/:username",
|
||||
"source": "src/server/routes/repository-private.ts",
|
||||
"line": 852,
|
||||
"line": 984,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
@@ -626,49 +717,49 @@
|
||||
"method": "POST",
|
||||
"path": "/api/pr/:pullRequestId/refresh",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 24,
|
||||
"line": 25,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/pr/:pullRequestId/extend",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 43,
|
||||
"line": 45,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/pr/:pullRequestId",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 83,
|
||||
"line": 86,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/pr/:owner/:repository/:pullRequestId",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 104,
|
||||
"line": 107,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/pr/:pullRequestId",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 130,
|
||||
"line": 133,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/pr/:pullRequestId",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 218,
|
||||
"line": 221,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/pr",
|
||||
"source": "src/server/routes/pullRequest-private.ts",
|
||||
"line": 254,
|
||||
"line": 258,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
@@ -689,84 +780,84 @@
|
||||
"method": "POST",
|
||||
"path": "/api/gist/:gistId/refresh",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 23,
|
||||
"line": 24,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/gist/:gistId/extend",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 42,
|
||||
"line": 44,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/gist/:gistId",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 80,
|
||||
"line": 83,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/gist/source/:gistId",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 102,
|
||||
"line": 105,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/gist/:gistId",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 125,
|
||||
"line": 128,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/gist/:gistId",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 199,
|
||||
"line": 202,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/gist",
|
||||
"source": "src/server/routes/gist-private.ts",
|
||||
"line": 234,
|
||||
"line": 238,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/anonymize-preview",
|
||||
"source": "src/server/routes/anonymize-preview.ts",
|
||||
"line": 17,
|
||||
"line": 19,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/message",
|
||||
"source": "src/server/index.ts",
|
||||
"line": 259,
|
||||
"line": 282,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/healthcheck",
|
||||
"source": "src/server/index.ts",
|
||||
"line": 266,
|
||||
"line": 289,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/stat",
|
||||
"source": "src/server/index.ts",
|
||||
"line": 269,
|
||||
"line": 292,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/stat/history",
|
||||
"source": "src/server/index.ts",
|
||||
"line": 272,
|
||||
"line": 295,
|
||||
"verification": "first matching Go handler; behavior verified separately"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ const express=require('express'),ts=require('typescript');
|
||||
const fixture={exports:{}};
|
||||
let active;
|
||||
const results={decision:()=>({digest:active.record.digest,changed:false})};
|
||||
const dependencies={zlib,crypto,stream,'stream/promises':require('node:stream/promises'),perf_hooks:require('node:perf_hooks'),'../config':{default:{ANONYMIZATION_MASK:'XXXX',APP_HOSTNAME:'anonymous.test',additionalExtensions:[]}},'./blob-cache':{resultBlobCache:()=>results,CacheAdmissionError:class extends Error{}},'./anonymize-utils':{},'./cache-observability':{observeCache(){}}};
|
||||
const dependencies={zlib,crypto,stream,'stream/promises':require('node:stream/promises'),perf_hooks:require('node:perf_hooks'),'../config':{default:{ANONYMIZATION_MASK:'XXXX',APP_HOSTNAME:'anonymous.test',additionalExtensions:[]}},'./blob-cache':{resultBlobCache:()=>results,CacheAdmissionError:class extends Error{}},'./anonymize-utils':{classifyByName:()=>false},'./transformed-cache':{assertTransformScopeActive:async()=>{}},'./cache-observability':{observeCache(){}}};
|
||||
vm.runInNewContext(ts.transpileModule(fs.readFileSync('src/core/cached-response.ts','utf8'),{compilerOptions:{module:ts.ModuleKind.CommonJS,target:ts.ScriptTarget.ES2022}}).outputText,{module:fixture,exports:fixture.exports,require:name=>{assert.ok(dependencies[name],name);return dependencies[name]}});
|
||||
const cases=[];
|
||||
const accepts=['','gzip','identity','br','deflate','*','identity, gzip','gzip, identity','gzip;q=.5,identity;q=1','gzip;q=1,identity;q=.5','gzip;q=0','identity;q=0','*;q=0','gzip,identity;q=0','identity;q=0,br','gzip;q=0,*;q=1','*;q=0,gzip;q=1','gzip;q=NaN','gzip;q=-1','gzip;q=2','gzip;q=Infinity','gzip;q=1junk','gzip;q= 0.5','gzip;Q=0','gzip;q =0','gzip;q=0,gzip;q=1','gzip;q=1,gzip;q=0','gzip garbage','GZIP', 'unknown;q=-1,gzip',',,,gzip','gzip,,,','gzip;q="0"','gzip;q="0.5,identity;q=0"','gzip;q="\\0"','gzip;q="0','gzip;q=','gzip;q=;q=0','gzip;q=0;q=1','gzip;Q = "0.5"','gzip;broken;q=0','gzip garbage;q=-1','gzip;level="a,b;c";q=0','identity;q=0,*;q=.5'];
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
const fs=require('node:fs');const vm=require('node:vm');const assert=require('node:assert/strict');const ts=require('typescript');
|
||||
class AnonymousError extends Error{constructor(message,options){super(message);this.httpStatus=options?.httpStatus}}
|
||||
const specifications=[['repo','repository','validateNewRepo','repoId'],['gist','gist','validateNewGist','gistId'],['pr','pullRequest','validateNewPullRequest','pullRequestId']];
|
||||
process.env.SESSION_SECRET ||= 'synthetic-validation';require('ts-node/register/transpile-only');
|
||||
const {normalizePreserveFiles}=require('../../src/core/preserve-files');
|
||||
const cases=[];
|
||||
for(const [kind,file,name,id] of specifications){
|
||||
const path=`src/server/routes/${file}-private.ts`;const text=fs.readFileSync(path,'utf8');const tree=ts.createSourceFile(path,text,ts.ScriptTarget.Latest,true);
|
||||
const declaration=tree.statements.find(s=>ts.isFunctionDeclaration(s)&&s.name?.text===name);assert.ok(declaration,name);
|
||||
const code=ts.transpileModule(`${declaration.getText(tree)};module.exports=${name}`,{compilerOptions:{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.CommonJS}}).outputText;
|
||||
const module={exports:{}};vm.runInNewContext(code,{module,AnonymousError});const validate=module.exports;
|
||||
const module={exports:{}};vm.runInNewContext(code,{module,AnonymousError,normalizePreserveFiles});const validate=module.exports;
|
||||
const base={[id]:'example',source:{branch:'main',commit:'abc123',gistId:'snippet',repositoryFullName:'owner/repo',pullRequestId:42},options:{},terms:[]};
|
||||
const add=(name,change)=>{const body=structuredClone(base);change(body);let expected=null;try{validate(body)}catch(e){assert.ok(e instanceof AnonymousError,`${kind}/${name}: unexpected TS runtime exception`);expected={code:e.message,status:e.httpStatus}}cases.push({name:`${kind}/${name}`,kind,body,expected})};
|
||||
add('valid',()=>{});
|
||||
|
||||
Reference in new issue
Block a user