UNPKG

pg-mem-uuid-ossp

Version:
78 lines 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uuidOssp = exports.X500 = exports.OID = exports.URL = exports.DNS = void 0; const pg_mem_1 = require("pg-mem"); const uuid = require("uuid"); exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; exports.OID = '6ba7b812-9dad-11d1-80b4-00c04fd430c8'; exports.X500 = '6ba7b814-9dad-11d1-80b4-00c04fd430c8'; function uuidOssp(schema) { const functionDefs = [ { name: 'uuid_generate_v1', implementation: uuid.v1, returns: pg_mem_1.DataType.uuid, impure: true }, { name: 'uuid_generate_v1mc', implementation: uuid.v1, returns: pg_mem_1.DataType.uuid, impure: true }, { name: 'uuid_generate_v3', implementation: (namespace, name) => uuid.v3(name, namespace), returns: pg_mem_1.DataType.uuid, impure: true, args: [pg_mem_1.DataType.uuid, pg_mem_1.DataType.text] }, { name: 'uuid_generate_v4', implementation: uuid.v4, returns: pg_mem_1.DataType.uuid, impure: true }, { name: 'uuid_generate_v5', implementation: (namespace, name) => uuid.v5(name, namespace), returns: pg_mem_1.DataType.uuid, impure: true, args: [pg_mem_1.DataType.text, pg_mem_1.DataType.text] }, { name: 'uuid_ns_url', implementation: () => exports.URL, returns: pg_mem_1.DataType.uuid, impure: false }, { name: 'uuid_ns_dns', implementation: () => exports.DNS, returns: pg_mem_1.DataType.uuid, impure: false }, { name: 'uuid_ns_oid', implementation: () => exports.OID, returns: pg_mem_1.DataType.uuid, impure: false }, { name: 'uuid_ns_x500', implementation: () => exports.X500, returns: pg_mem_1.DataType.uuid, impure: false }, { name: 'uuid_nil', implementation: () => uuid.NIL, returns: pg_mem_1.DataType.uuid, impure: false }, ]; functionDefs.forEach(f => schema.registerFunction(f)); } exports.uuidOssp = uuidOssp; //# sourceMappingURL=uuid-ossp.js.map