@pgpm/types 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
@@ -1,5 +1,5 @@
1
1
  EXTENSION = pgpm-types
2
- DATA = sql/pgpm-types--0.15.2.sql
2
+ DATA = sql/pgpm-types--0.15.3.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pgpm/types",
3
- "version": "0.15.3",
3
+ "version": "0.15.4",
4
4
  "description": "Core PostgreSQL data types with deploy/verify/revert SQL scripts",
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.3"
24
+ "@pgpm/verify": "0.15.4"
25
25
  },
26
26
  "devDependencies": {
27
- "pgpm": "^1.0.0"
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": "187ed37f6b731132fe930acf5b5996b1e63ecca0"
37
+ "gitHead": "aad0dbef0336d6c18d027120ef9addc418822edd"
38
38
  }
@@ -1,6 +1,6 @@
1
1
  # pgpm-types extension
2
2
  comment = 'pgpm-types extension'
3
- default_version = '0.15.2'
3
+ default_version = '0.15.3'
4
4
  module_pathname = '$libdir/pgpm-types'
5
5
  requires = 'plpgsql,citext,pgpm-verify'
6
6
  relocatable = false
@@ -28,7 +28,7 @@ CREATE DOMAIN multiple_select AS jsonb
28
28
  COMMENT ON DOMAIN multiple_select IS '@name pgpmInternalTypeMultipleSelect';
29
29
 
30
30
  CREATE DOMAIN origin AS text
31
- CHECK (value = SUBSTRING(value FROM '^(https?://[^/]*)'));
31
+ CHECK (value = pg_catalog."substring"(value, '^(https?://[^/]*)'));
32
32
 
33
33
  COMMENT ON DOMAIN origin IS '@name pgpmInternalTypeOrigin';
34
34
 
@@ -1,237 +0,0 @@
1
- import { getConnections, PgTestClient } from 'pgsql-test';
2
-
3
- const validUrls = [
4
- 'http://foo.com/blah_blah',
5
- 'http://foo.com/blah_blah/',
6
- 'http://foo.com/blah_blah_(wikipedia)',
7
- 'http://foo.com/blah_blah_(wikipedia)_(again)',
8
- 'http://www.example.com/wpstyle/?p=364',
9
- 'https://www.example.com/foo/?bar=baz&inga=42&quux',
10
- 'http://✪df.ws/123',
11
- 'http://foo.com/blah_(wikipedia)#cite-1',
12
- 'http://foo.com/blah_(wikipedia)_blah#cite-1',
13
- 'http://foo.com/(something)?after=parens',
14
- 'http://code.google.com/events/#&product=browser',
15
- 'http://j.mp',
16
- 'http://foo.bar/?q=Test%20URL-encoded%20stuff',
17
- 'http://مثال.إختبار',
18
- 'http://例子.测试',
19
- 'http://उदाहरण.परीक्षा',
20
- "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
21
- 'http://1337.net',
22
- 'http://a.b-c.de',
23
- 'https://foo_bar.example.com/'
24
- ];
25
-
26
- const invalidUrls = [
27
- 'http://##',
28
- 'http://##/',
29
- 'http://foo.bar?q=Spaces should be encoded',
30
- '//',
31
- '//a',
32
- '///a',
33
- '///',
34
- 'http:///a',
35
- 'foo.com',
36
- 'rdar://1234',
37
- 'h://test',
38
- 'http:// shouldfail.com',
39
- ':// should fail',
40
- 'http://foo.bar/foo(bar)baz quux',
41
- 'ftps://foo.bar/',
42
- 'http://.www.foo.bar/',
43
- 'http://.www.foo.bar./'
44
- ];
45
-
46
- const validAttachments = [
47
- 'http://www.foo.bar/some.jpg',
48
- 'https://foo.bar/some.PNG'
49
- ];
50
-
51
- const invalidAttachments = [
52
- 'hi there',
53
- 'ftp://foo.bar/some.png',
54
- 'https:///foo.bar/some.png'
55
- ];
56
-
57
- const validImages = [
58
- { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
59
- { url: 'https://foo.bar/some.PNG', mime: 'image/jpg' }
60
- ];
61
-
62
- const invalidImages = [
63
- { url: 'hi there' },
64
- { url: 'https://foo.bar/some.png' }
65
- ];
66
-
67
- const validUploads = [
68
- { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
69
- { url: 'https://foo.bar/some.PNG', mime: 'image/png' }
70
- ];
71
-
72
- const invalidUploads = [
73
- { url: 'hi there' },
74
- { url: 'https://foo.bar/some.png' },
75
- { url: 'ftp://foo.bar/some.png', mime: 'image/png' }
76
- ];
77
-
78
- let pg: PgTestClient;
79
- let teardown: () => Promise<void>;
80
-
81
- beforeAll(async () => {
82
- ({ pg, teardown } = await getConnections());
83
- });
84
-
85
- beforeAll(async () => {
86
- await pg.any(`
87
- CREATE TABLE customers (
88
- id serial,
89
- url url,
90
- image image,
91
- attachment attachment,
92
- domain hostname,
93
- email email,
94
- upload upload
95
- );
96
- `);
97
- });
98
-
99
- beforeEach(async () => {
100
- await pg.beforeEach();
101
- });
102
-
103
- afterEach(async () => {
104
- await pg.afterEach();
105
- });
106
-
107
- afterAll(async () => {
108
- await teardown();
109
- });
110
-
111
- describe('types', () => {
112
- it('valid attachment and image', async () => {
113
- for (const attachment of validAttachments) {
114
- await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [attachment]);
115
- }
116
-
117
- for (const image of validImages) {
118
- await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [image]);
119
- }
120
- });
121
-
122
- it('invalid attachment and image', async () => {
123
- for (const attachment of invalidAttachments) {
124
- let failed = false;
125
- try {
126
- await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [attachment]);
127
- } catch (e) {
128
- failed = true;
129
- }
130
- expect(failed).toBe(true);
131
- }
132
-
133
- for (const image of invalidImages) {
134
- let failed = false;
135
- try {
136
- await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [image]);
137
- } catch (e) {
138
- failed = true;
139
- }
140
- expect(failed).toBe(true);
141
- }
142
- });
143
-
144
- it('valid upload', async () => {
145
- for (const upload of validUploads) {
146
- await pg.any(`INSERT INTO customers (upload) VALUES ($1::json);`, [upload]);
147
- }
148
- });
149
-
150
- it('invalid upload', async () => {
151
- for (const upload of invalidUploads) {
152
- let failed = false;
153
- try {
154
- await pg.any(`INSERT INTO customers (upload) VALUES ($1::json);`, [upload]);
155
- } catch (e) {
156
- failed = true;
157
- }
158
- expect(failed).toBe(true);
159
- }
160
- });
161
-
162
- it('valid url', async () => {
163
- for (const value of validUrls) {
164
- await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
165
- }
166
- });
167
-
168
- it('invalid url', async () => {
169
- for (const value of invalidUrls) {
170
- let failed = false;
171
- try {
172
- await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
173
- } catch (e) {
174
- failed = true;
175
- }
176
- expect(failed).toBe(true);
177
- }
178
- });
179
-
180
- it('email', async () => {
181
- await pg.any(`
182
- INSERT INTO customers (email) VALUES
183
- ('d@google.com'),
184
- ('d@google.in'),
185
- ('d@google.in'),
186
- ('d@www.google.in'),
187
- ('d@google.io'),
188
- ('dan@google.some.other.com')`);
189
- });
190
-
191
- it('not email', async () => {
192
- let failed = false;
193
- try {
194
- await pg.any(`
195
- INSERT INTO customers (email) VALUES
196
- ('http://google.some.other.com')`);
197
- } catch (e) {
198
- failed = true;
199
- }
200
- expect(failed).toBe(true);
201
- });
202
-
203
- it('hostname', async () => {
204
- await pg.any(`
205
- INSERT INTO customers (domain) VALUES
206
- ('google.com'),
207
- ('google.in'),
208
- ('google.in'),
209
- ('www.google.in'),
210
- ('google.io'),
211
- ('google.some.other.com')`);
212
- });
213
-
214
- it('not hostname', async () => {
215
- let failed = false;
216
- try {
217
- await pg.any(`
218
- INSERT INTO customers (domain) VALUES
219
- ('http://google.some.other.com')`);
220
- } catch (e) {
221
- failed = true;
222
- }
223
- expect(failed).toBe(true);
224
- });
225
-
226
- it('not hostname 2', async () => {
227
- let failed = false;
228
- try {
229
- await pg.any(`
230
- INSERT INTO customers (domain) VALUES
231
- ('google.some.other.com/a/b/d')`);
232
- } catch (e) {
233
- failed = true;
234
- }
235
- expect(failed).toBe(true);
236
- });
237
- });
@@ -1,237 +0,0 @@
1
- import { getConnections, PgTestClient } from 'pgsql-test';
2
-
3
- const validUrls = [
4
- 'http://foo.com/blah_blah',
5
- 'http://foo.com/blah_blah/',
6
- 'http://foo.com/blah_blah_(wikipedia)',
7
- 'http://foo.com/blah_blah_(wikipedia)_(again)',
8
- 'http://www.example.com/wpstyle/?p=364',
9
- 'https://www.example.com/foo/?bar=baz&inga=42&quux',
10
- 'http://✪df.ws/123',
11
- 'http://foo.com/blah_(wikipedia)#cite-1',
12
- 'http://foo.com/blah_(wikipedia)_blah#cite-1',
13
- 'http://foo.com/(something)?after=parens',
14
- 'http://code.google.com/events/#&product=browser',
15
- 'http://j.mp',
16
- 'http://foo.bar/?q=Test%20URL-encoded%20stuff',
17
- 'http://مثال.إختبار',
18
- 'http://例子.测试',
19
- 'http://उदाहरण.परीक्षा',
20
- "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
21
- 'http://1337.net',
22
- 'http://a.b-c.de',
23
- 'https://foo_bar.example.com/'
24
- ];
25
-
26
- const invalidUrls = [
27
- 'http://##',
28
- 'http://##/',
29
- 'http://foo.bar?q=Spaces should be encoded',
30
- '//',
31
- '//a',
32
- '///a',
33
- '///',
34
- 'http:///a',
35
- 'foo.com',
36
- 'rdar://1234',
37
- 'h://test',
38
- 'http:// shouldfail.com',
39
- ':// should fail',
40
- 'http://foo.bar/foo(bar)baz quux',
41
- 'ftps://foo.bar/',
42
- 'http://.www.foo.bar/',
43
- 'http://.www.foo.bar./'
44
- ];
45
-
46
- const validAttachments = [
47
- 'http://www.foo.bar/some.jpg',
48
- 'https://foo.bar/some.PNG'
49
- ];
50
-
51
- const invalidAttachments = [
52
- 'hi there',
53
- 'ftp://foo.bar/some.png',
54
- 'https:///foo.bar/some.png'
55
- ];
56
-
57
- const validImages = [
58
- { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
59
- { url: 'https://foo.bar/some.PNG', mime: 'image/jpg' }
60
- ];
61
-
62
- const invalidImages = [
63
- { url: 'hi there' },
64
- { url: 'https://foo.bar/some.png' }
65
- ];
66
-
67
- const validUploads = [
68
- { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
69
- { url: 'https://foo.bar/some.PNG', mime: 'image/png' }
70
- ];
71
-
72
- const invalidUploads = [
73
- { url: 'hi there' },
74
- { url: 'https://foo.bar/some.png' },
75
- { url: 'ftp://foo.bar/some.png', mime: 'image/png' }
76
- ];
77
-
78
- let pg: PgTestClient;
79
- let teardown: () => Promise<void>;
80
-
81
- beforeAll(async () => {
82
- ({ pg, teardown } = await getConnections());
83
- });
84
-
85
- beforeAll(async () => {
86
- await pg.any(`
87
- CREATE TABLE customers (
88
- id serial,
89
- url url,
90
- image image,
91
- attachment attachment,
92
- domain hostname,
93
- email email,
94
- upload upload
95
- );
96
- `);
97
- });
98
-
99
- beforeEach(async () => {
100
- await pg.beforeEach();
101
- });
102
-
103
- afterEach(async () => {
104
- await pg.afterEach();
105
- });
106
-
107
- afterAll(async () => {
108
- await teardown();
109
- });
110
-
111
- describe('types', () => {
112
- it('valid attachment and image', async () => {
113
- for (const attachment of validAttachments) {
114
- await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [attachment]);
115
- }
116
-
117
- for (const image of validImages) {
118
- await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [image]);
119
- }
120
- });
121
-
122
- it('invalid attachment and image', async () => {
123
- for (const attachment of invalidAttachments) {
124
- let failed = false;
125
- try {
126
- await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [attachment]);
127
- } catch (e) {
128
- failed = true;
129
- }
130
- expect(failed).toBe(true);
131
- }
132
-
133
- for (const image of invalidImages) {
134
- let failed = false;
135
- try {
136
- await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [image]);
137
- } catch (e) {
138
- failed = true;
139
- }
140
- expect(failed).toBe(true);
141
- }
142
- });
143
-
144
- it('valid upload', async () => {
145
- for (const upload of validUploads) {
146
- await pg.any(`INSERT INTO customers (upload) VALUES ($1::json);`, [upload]);
147
- }
148
- });
149
-
150
- it('invalid upload', async () => {
151
- for (const upload of invalidUploads) {
152
- let failed = false;
153
- try {
154
- await pg.any(`INSERT INTO customers (upload) VALUES ($1::json);`, [upload]);
155
- } catch (e) {
156
- failed = true;
157
- }
158
- expect(failed).toBe(true);
159
- }
160
- });
161
-
162
- it('valid url', async () => {
163
- for (const value of validUrls) {
164
- await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
165
- }
166
- });
167
-
168
- it('invalid url', async () => {
169
- for (const value of invalidUrls) {
170
- let failed = false;
171
- try {
172
- await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
173
- } catch (e) {
174
- failed = true;
175
- }
176
- expect(failed).toBe(true);
177
- }
178
- });
179
-
180
- it('email', async () => {
181
- await pg.any(`
182
- INSERT INTO customers (email) VALUES
183
- ('d@google.com'),
184
- ('d@google.in'),
185
- ('d@google.in'),
186
- ('d@www.google.in'),
187
- ('d@google.io'),
188
- ('dan@google.some.other.com')`);
189
- });
190
-
191
- it('not email', async () => {
192
- let failed = false;
193
- try {
194
- await pg.any(`
195
- INSERT INTO customers (email) VALUES
196
- ('http://google.some.other.com')`);
197
- } catch (e) {
198
- failed = true;
199
- }
200
- expect(failed).toBe(true);
201
- });
202
-
203
- it('hostname', async () => {
204
- await pg.any(`
205
- INSERT INTO customers (domain) VALUES
206
- ('google.com'),
207
- ('google.in'),
208
- ('google.in'),
209
- ('www.google.in'),
210
- ('google.io'),
211
- ('google.some.other.com')`);
212
- });
213
-
214
- it('not hostname', async () => {
215
- let failed = false;
216
- try {
217
- await pg.any(`
218
- INSERT INTO customers (domain) VALUES
219
- ('http://google.some.other.com')`);
220
- } catch (e) {
221
- failed = true;
222
- }
223
- expect(failed).toBe(true);
224
- });
225
-
226
- it('not hostname 2', async () => {
227
- let failed = false;
228
- try {
229
- await pg.any(`
230
- INSERT INTO customers (domain) VALUES
231
- ('google.some.other.com/a/b/d')`);
232
- } catch (e) {
233
- failed = true;
234
- }
235
- expect(failed).toBe(true);
236
- });
237
- });
@@ -1,21 +0,0 @@
1
- import { getConnections, PgTestClient } from 'pgsql-test';
2
-
3
- let teardown: () => Promise<void>;
4
- let pg: PgTestClient;
5
-
6
- beforeAll(async () => {
7
- ({ pg, teardown } = await getConnections());
8
- });
9
-
10
- afterAll(async () => {
11
- await teardown();
12
- });
13
-
14
- describe('@pgql/types', () => {
15
- it('creates domain types', async () => {
16
- const { typname } = await pg.one(
17
- `SELECT typname FROM pg_type WHERE typname = 'url'`
18
- );
19
- expect(typname).toBe('url');
20
- });
21
- });