UNPKG

@zingage/postgres-multi-tenant-ids

Version:

PostgreSQL IDs for secure multi-tenant applications

18 lines 1.53 kB
import type { ScopedId, TenantId, TenantShortId } from "../helpers/config-agnostic-types.js"; import { type UUIDV8 } from "../helpers/utils.js"; import type { NamedEntityTypeConfigs } from "../index.js"; export declare function makeMakeScopedIdBound<T extends NamedEntityTypeConfigs>(tenantScopedEntityTypeConfigs: T): <K extends keyof T & string>(tenantId: TenantId, entityType: K, date?: Date) => ScopedId<T, K>; export declare function makeScopedId<T extends NamedEntityTypeConfigs, K extends keyof T & string>(tenantScopedEntityTypeConfigs: T, tenantId: TenantId, entityType: K, date?: Date): ScopedId<T, K>; /** * NB: filling in T is just a convenient way to do a cast if you (think you) * know what type of id you're getting from the outside world. */ export declare function isScopedId<T extends NamedEntityTypeConfigs, K extends keyof T & string>(id: UUIDV8): id is ScopedId<T, K>; /** * NB: filling in T is just a convenient way to do a cast if you (think you) * know what type of id you're getting from the outside world. */ export declare function stringIsScopedId<T extends NamedEntityTypeConfigs, K extends keyof T & string>(id: string): id is ScopedId<T, K>; export declare function getTenantShortIdFromScopedId<T extends NamedEntityTypeConfigs, K extends keyof T & string>(id: ScopedId<T, K>): TenantShortId; export declare function scopedIdsBelongToSameTenant<T extends NamedEntityTypeConfigs, K extends keyof T & string>(ids: ScopedId<T, K>[]): boolean; //# sourceMappingURL=tenant-scoped-entity-ids.d.ts.map