mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
fix: additional backwards compat
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
import type { Envelope } from '@prisma/client';
|
||||
import { EnvelopeType } from '@prisma/client';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
|
||||
import { mapSecondaryIdToDocumentId, mapSecondaryIdToTemplateId } from '../utils/envelope';
|
||||
|
||||
export const alphaid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 21);
|
||||
|
||||
export { nanoid } from 'nanoid';
|
||||
@ -29,3 +33,16 @@ type DatabaseIdPrefix =
|
||||
| 'team_setting';
|
||||
|
||||
export const generateDatabaseId = (prefix: DatabaseIdPrefix) => prefixedId(prefix, 16);
|
||||
|
||||
export const extractLegacyIds = (envelope: Pick<Envelope, 'type' | 'secondaryId'>) => {
|
||||
return {
|
||||
documentId:
|
||||
envelope.type === EnvelopeType.DOCUMENT
|
||||
? mapSecondaryIdToDocumentId(envelope.secondaryId)
|
||||
: null,
|
||||
templateId:
|
||||
envelope.type === EnvelopeType.TEMPLATE
|
||||
? mapSecondaryIdToTemplateId(envelope.secondaryId)
|
||||
: null,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user