| 123456789101112131415161718192021222324 |
- import {readFileSync} from 'node:fs';
- import {specs} from './legacy-direct-specs.mjs';
- import {legacyAddonFields} from './legacy-direct-projection.mjs';
- import {withXiaoshuRuntime} from './xiaoshu-runtime-compat.mjs';
- import {legacyAppointmentDefaults,legacyWritingStageSupport} from '../legacy-appointment-transform.mjs';
- export function buildDirectBundle(columns,windows=[],company='7pIbDBJmKx') {
- const definitions=structuredClone(specs);
- for(const [m,s] of Object.entries(definitions)){
- s.fields=legacyAddonFields[m]||(m==='52'?['sy','yb','lj','yp']:['content','synopsis','mp4','ico','author','source']);
- s.addonColumns=columns.filter(c=>c.table_name===s.className).map(c=>c.column_name);
- s.commonColumns=columns.filter(c=>c.table_name==='CommonModel').map(c=>c.column_name);
- if(!s.addonColumns.includes('id')||!s.commonColumns.includes('generalId'))throw Error('Unexpected physical schema');
- }
- const userSource=readFileSync(new URL('../backfill-legacy-users.mjs',import.meta.url),'utf8');
- const userProjection=userSource.slice(userSource.indexOf('function text(value)'),userSource.indexOf('function requestGroups('));
- const prefix='const company={__type:"Pointer",className:"Company",objectId:'+JSON.stringify(company)+'};\n'+userProjection;
- const cloudSource=name=>readFileSync(new URL('../cloud/'+name+'.js',import.meta.url),'utf8');
- const operations=readFileSync(new URL('../deploy-admin-functions.mjs',import.meta.url),'utf8')
- .match(/const operationsGatewayCode = String.raw`([\s\S]*?)\n`;/)?.[1];
- if(!operations)throw Error('Unexpected operations gateway definition');
- const writingSupport=legacyAppointmentDefaults(operations)+legacyWritingStageSupport(cloudSource('payroll-integrity'));
- const files=['legacy-finance','legacy-direct-supplement','legacy-direct-control','legacy-writing-sync-ownership','legacy-writing-sync','legacy-direct-sync'];
- return withXiaoshuRuntime((prefix+writingSupport+files.map(cloudSource).join('\n')).replaceAll('__SPECS__',JSON.stringify(definitions)).replaceAll('__WINDOWS__',JSON.stringify(windows)).replaceAll('__COMPANY_ID__',JSON.stringify(company)));
- }
|