UNPKG

947 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.UuidFactory = exports.UuidFactoryMode = void 0;
4const random_string_generator_util_1 = require("@nestjs/common/utils/random-string-generator.util");
5const deterministic_uuid_registry_1 = require("./deterministic-uuid-registry");
6var UuidFactoryMode;
7(function (UuidFactoryMode) {
8 UuidFactoryMode["Random"] = "random";
9 UuidFactoryMode["Deterministic"] = "deterministic";
10})(UuidFactoryMode || (exports.UuidFactoryMode = UuidFactoryMode = {}));
11class UuidFactory {
12 static set mode(value) {
13 this._mode = value;
14 }
15 static get(key = '') {
16 return this._mode === UuidFactoryMode.Deterministic
17 ? deterministic_uuid_registry_1.DeterministicUuidRegistry.get(key)
18 : (0, random_string_generator_util_1.randomStringGenerator)();
19 }
20}
21exports.UuidFactory = UuidFactory;
22UuidFactory._mode = UuidFactoryMode.Random;