@pgpm/uuid 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Makefile
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/uuid",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
4
4
|
"description": "UUID utilities and extensions for PostgreSQL",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/verify": "0.15.
|
|
24
|
+
"@pgpm/verify": "0.15.4"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"pgpm": "^1.
|
|
27
|
+
"pgpm": "^1.2.2"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "aad0dbef0336d6c18d027120ef9addc418822edd"
|
|
38
38
|
}
|
package/pgpm-uuid.control
CHANGED
package/__tests__/uuid.test.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { getConnections, PgTestClient } from 'pgsql-test';
|
|
2
|
-
|
|
3
|
-
let pg: PgTestClient;
|
|
4
|
-
let teardown: () => Promise<void>;
|
|
5
|
-
|
|
6
|
-
beforeAll(async () => {
|
|
7
|
-
({ pg, teardown } = await getConnections());
|
|
8
|
-
|
|
9
|
-
await pg.any(`
|
|
10
|
-
CREATE TABLE public.items (
|
|
11
|
-
id UUID DEFAULT uuids.pseudo_order_uuid(),
|
|
12
|
-
name TEXT,
|
|
13
|
-
seed TEXT,
|
|
14
|
-
custom_id UUID
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
CREATE TABLE public.items_seeded (
|
|
18
|
-
id UUID,
|
|
19
|
-
tenant TEXT
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
CREATE TRIGGER set_custom_id
|
|
23
|
-
BEFORE INSERT ON public.items
|
|
24
|
-
FOR EACH ROW
|
|
25
|
-
EXECUTE FUNCTION uuids.trigger_set_uuid_seed('custom_id', 'seed');
|
|
26
|
-
|
|
27
|
-
CREATE TRIGGER set_id_from_tenant
|
|
28
|
-
BEFORE INSERT ON public.items_seeded
|
|
29
|
-
FOR EACH ROW
|
|
30
|
-
EXECUTE FUNCTION uuids.trigger_set_uuid_related_field('id', 'tenant');
|
|
31
|
-
`);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterAll(async () => {
|
|
35
|
-
try {
|
|
36
|
-
await teardown();
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error('Teardown failed:', e);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
beforeEach(() => pg.beforeEach());
|
|
43
|
-
afterEach(() => pg.afterEach());
|
|
44
|
-
|
|
45
|
-
describe('uuids.pseudo_order_uuid()', () => {
|
|
46
|
-
it('generates a valid UUID', async () => {
|
|
47
|
-
const { pseudo_order_uuid } = await pg.one(`
|
|
48
|
-
SELECT uuids.pseudo_order_uuid() AS pseudo_order_uuid
|
|
49
|
-
`);
|
|
50
|
-
expect(pseudo_order_uuid).toMatch(
|
|
51
|
-
/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$/
|
|
52
|
-
);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('uuids.pseudo_order_seed_uuid(seed)', () => {
|
|
57
|
-
it('generates a valid UUID from a seed', async () => {
|
|
58
|
-
const { pseudo_order_seed_uuid } = await pg.one(
|
|
59
|
-
`SELECT uuids.pseudo_order_seed_uuid($1) AS pseudo_order_seed_uuid`,
|
|
60
|
-
['tenant123']
|
|
61
|
-
);
|
|
62
|
-
expect(pseudo_order_seed_uuid).toMatch(
|
|
63
|
-
/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$/
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('uuids.trigger_set_uuid_seed', () => {
|
|
69
|
-
it('sets custom_id based on static seed', async () => {
|
|
70
|
-
const { custom_id } = await pg.one(
|
|
71
|
-
`INSERT INTO public.items (name, seed) VALUES ($1, $2) RETURNING custom_id`,
|
|
72
|
-
['Item A', 'my-seed']
|
|
73
|
-
);
|
|
74
|
-
expect(custom_id).toMatch(
|
|
75
|
-
/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$/
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('uuids.trigger_set_uuid_related_field', () => {
|
|
81
|
-
it('sets id based on tenant column', async () => {
|
|
82
|
-
const { id } = await pg.one(
|
|
83
|
-
`INSERT INTO public.items_seeded (tenant) VALUES ($1) RETURNING id`,
|
|
84
|
-
['tenant-42']
|
|
85
|
-
);
|
|
86
|
-
expect(id).toMatch(
|
|
87
|
-
/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$/
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
File without changes
|