feat(server): library refresh go brrr (#14456)

* feat: brr

---------
Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
Jonathan Jogenfors 2025-03-06 16:00:18 +01:00 committed by GitHub
parent bc61497461
commit 3af26ee94a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 855 additions and 531 deletions

View file

@ -10,6 +10,8 @@ import { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/o
import _ from 'lodash';
import { writeFileSync } from 'node:fs';
import path from 'node:path';
import picomatch from 'picomatch';
import parse from 'picomatch/lib/parse';
import { SystemConfig } from 'src/config';
import { CLIP_MODEL_INFO, serverVersion } from 'src/constants';
import { extraSyncModels } from 'src/dtos/sync.dto';
@ -268,3 +270,35 @@ export const useSwagger = (app: INestApplication, { write }: { write: boolean })
writeFileSync(outputPath, JSON.stringify(patchOpenAPI(specification), null, 2), { encoding: 'utf8' });
}
};
const convertTokenToSqlPattern = (token: parse.Token): string => {
switch (token.type) {
case 'slash': {
return '/';
}
case 'text': {
return token.value;
}
case 'globstar':
case 'star': {
return '%';
}
case 'underscore': {
return String.raw`\_`;
}
case 'qmark': {
return '_';
}
case 'dot': {
return '.';
}
default: {
return '';
}
}
};
export const globToSqlPattern = (glob: string) => {
const tokens = picomatch.parse(glob).tokens;
return tokens.map((token) => convertTokenToSqlPattern(token)).join('');
};