mirror of
https://github.com/lingble/twenty.git
synced 2025-12-25 00:47:26 +00:00
* wip: refacto and start creating custom resolver * feat: findMany & findUnique of a custom entity * feat: wip pagination * feat: initial metadata migration * feat: universal findAll with pagination * fix: clean small stuff in pagination * fix: test * fix: miss file * feat: rename custom into universal * feat: create metadata schema in default database --------- Co-authored-by: Charles Bochet <charles@twenty.com>
22 lines
603 B
TypeScript
22 lines
603 B
TypeScript
/**
|
|
* Converts a UUID to a base 36 string.
|
|
* This is used to generate the schema name since hyphens from workspace uuid are not allowed in postgres schema names.
|
|
*
|
|
* @param uuid
|
|
* @returns
|
|
*/
|
|
export function uuidToBase36(uuid: string): string {
|
|
let devId = false;
|
|
|
|
if (uuid.startsWith('twenty-')) {
|
|
devId = true;
|
|
// Clean dev uuids (twenty-)
|
|
uuid = uuid.replace('twenty-', '');
|
|
}
|
|
const hexString = uuid.replace(/-/g, '');
|
|
const base10Number = BigInt('0x' + hexString);
|
|
const base36String = base10Number.toString(36);
|
|
|
|
return `${devId ? 'twenty_' : ''}${base36String}`;
|
|
}
|