@pgpm/types 0.4.0

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.
Files changed (39) hide show
  1. package/LICENSE +22 -0
  2. package/Makefile +6 -0
  3. package/README.md +5 -0
  4. package/__tests__/domains.pgutils.test.ts +190 -0
  5. package/__tests__/domains.test.ts +190 -0
  6. package/__tests__/ext-types.test.ts +21 -0
  7. package/deploy/schemas/public/domains/attachment.sql +12 -0
  8. package/deploy/schemas/public/domains/email.sql +8 -0
  9. package/deploy/schemas/public/domains/hostname.sql +8 -0
  10. package/deploy/schemas/public/domains/image.sql +12 -0
  11. package/deploy/schemas/public/domains/multiple_select.sql +8 -0
  12. package/deploy/schemas/public/domains/single_select.sql +12 -0
  13. package/deploy/schemas/public/domains/upload.sql +10 -0
  14. package/deploy/schemas/public/domains/url.sql +8 -0
  15. package/deploy/schemas/public/schema.sql +2 -0
  16. package/jest.config.js +15 -0
  17. package/launchql-types.control +8 -0
  18. package/launchql.plan +13 -0
  19. package/package.json +28 -0
  20. package/revert/schemas/public/domains/attachment.sql +7 -0
  21. package/revert/schemas/public/domains/email.sql +7 -0
  22. package/revert/schemas/public/domains/hostname.sql +7 -0
  23. package/revert/schemas/public/domains/image.sql +7 -0
  24. package/revert/schemas/public/domains/multiple_select.sql +7 -0
  25. package/revert/schemas/public/domains/single_select.sql +7 -0
  26. package/revert/schemas/public/domains/upload.sql +7 -0
  27. package/revert/schemas/public/domains/url.sql +7 -0
  28. package/revert/schemas/public/schema.sql +1 -0
  29. package/sqitch.plan +13 -0
  30. package/sql/launchql-types--0.4.6.sql +46 -0
  31. package/verify/schemas/public/domains/attachment.sql +7 -0
  32. package/verify/schemas/public/domains/email.sql +7 -0
  33. package/verify/schemas/public/domains/hostname.sql +7 -0
  34. package/verify/schemas/public/domains/image.sql +7 -0
  35. package/verify/schemas/public/domains/multiple_select.sql +7 -0
  36. package/verify/schemas/public/domains/single_select.sql +7 -0
  37. package/verify/schemas/public/domains/upload.sql +7 -0
  38. package/verify/schemas/public/domains/url.sql +7 -0
  39. package/verify/schemas/public/schema.sql +1 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4
+ Copyright (c) 2025 Interweb, Inc.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/Makefile ADDED
@@ -0,0 +1,6 @@
1
+ EXTENSION = launchql-types
2
+ DATA = sql/launchql-types--0.4.6.sql
3
+
4
+ PG_CONFIG = pg_config
5
+ PGXS := $(shell $(PG_CONFIG) --pgxs)
6
+ include $(PGXS)
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @pgpm/types
2
+
3
+ Core PostgreSQL data types with SQL scripts.
4
+
5
+ Provides essential data types including attachment, email, hostname, image, multiple_select, single_select, upload, and url domains for PostgreSQL applications.
@@ -0,0 +1,190 @@
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
+ { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
48
+ { url: 'https://foo.bar/some.PNG', mime: 'image/jpg' }
49
+ ];
50
+
51
+ const invalidAttachments = [
52
+ { url: 'hi there' },
53
+ { url: 'https://foo.bar/some.png' }
54
+ ];
55
+
56
+ let pg: PgTestClient;
57
+ let teardown: () => Promise<void>;
58
+
59
+ beforeAll(async () => {
60
+ ({ pg, teardown } = await getConnections());
61
+ });
62
+
63
+ beforeAll(async () => {
64
+ await pg.any(`
65
+ CREATE TABLE customers (
66
+ id serial,
67
+ url url,
68
+ image image,
69
+ attachment attachment,
70
+ domain hostname,
71
+ email email
72
+ );
73
+ `);
74
+ });
75
+
76
+ beforeEach(async () => {
77
+ await pg.beforeEach();
78
+ });
79
+
80
+ afterEach(async () => {
81
+ await pg.afterEach();
82
+ });
83
+
84
+ afterAll(async () => {
85
+ await teardown();
86
+ });
87
+
88
+ describe('types', () => {
89
+ it('valid attachment and image', async () => {
90
+ for (const value of validAttachments) {
91
+ await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [value]);
92
+ await pg.any(`INSERT INTO customers (attachment) VALUES ($1::json);`, [value]);
93
+ }
94
+ });
95
+
96
+ it('invalid attachment and image', async () => {
97
+ for (const value of invalidAttachments) {
98
+ let failed = false;
99
+ try {
100
+ await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [value]);
101
+ } catch (e) {
102
+ failed = true;
103
+ }
104
+ expect(failed).toBe(true);
105
+ failed = false;
106
+ try {
107
+ await pg.any(`INSERT INTO customers (image) VALUES ($1);`, [value]);
108
+ } catch (e) {
109
+ failed = true;
110
+ }
111
+ expect(failed).toBe(true);
112
+ }
113
+ });
114
+
115
+ it('valid url', async () => {
116
+ for (const value of validUrls) {
117
+ await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
118
+ }
119
+ });
120
+
121
+ it('invalid url', async () => {
122
+ for (const value of invalidUrls) {
123
+ let failed = false;
124
+ try {
125
+ await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
126
+ } catch (e) {
127
+ failed = true;
128
+ }
129
+ expect(failed).toBe(true);
130
+ }
131
+ });
132
+
133
+ it('email', async () => {
134
+ await pg.any(`
135
+ INSERT INTO customers (email) VALUES
136
+ ('d@google.com'),
137
+ ('d@google.in'),
138
+ ('d@google.in'),
139
+ ('d@www.google.in'),
140
+ ('d@google.io'),
141
+ ('dan@google.some.other.com')`);
142
+ });
143
+
144
+ it('not email', async () => {
145
+ let failed = false;
146
+ try {
147
+ await pg.any(`
148
+ INSERT INTO customers (email) VALUES
149
+ ('http://google.some.other.com')`);
150
+ } catch (e) {
151
+ failed = true;
152
+ }
153
+ expect(failed).toBe(true);
154
+ });
155
+
156
+ it('hostname', async () => {
157
+ await pg.any(`
158
+ INSERT INTO customers (domain) VALUES
159
+ ('google.com'),
160
+ ('google.in'),
161
+ ('google.in'),
162
+ ('www.google.in'),
163
+ ('google.io'),
164
+ ('google.some.other.com')`);
165
+ });
166
+
167
+ it('not hostname', async () => {
168
+ let failed = false;
169
+ try {
170
+ await pg.any(`
171
+ INSERT INTO customers (domain) VALUES
172
+ ('http://google.some.other.com')`);
173
+ } catch (e) {
174
+ failed = true;
175
+ }
176
+ expect(failed).toBe(true);
177
+ });
178
+
179
+ it('not hostname 2', async () => {
180
+ let failed = false;
181
+ try {
182
+ await pg.any(`
183
+ INSERT INTO customers (domain) VALUES
184
+ ('google.some.other.com/a/b/d')`);
185
+ } catch (e) {
186
+ failed = true;
187
+ }
188
+ expect(failed).toBe(true);
189
+ });
190
+ });
@@ -0,0 +1,190 @@
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
+ { url: 'http://www.foo.bar/some.jpg', mime: 'image/jpg' },
48
+ { url: 'https://foo.bar/some.PNG', mime: 'image/jpg' }
49
+ ];
50
+
51
+ const invalidAttachments = [
52
+ { url: 'hi there' },
53
+ { url: 'https://foo.bar/some.png' }
54
+ ];
55
+
56
+ let pg: PgTestClient;
57
+ let teardown: () => Promise<void>;
58
+
59
+ beforeAll(async () => {
60
+ ({ pg, teardown } = await getConnections());
61
+ });
62
+
63
+ beforeAll(async () => {
64
+ await pg.any(`
65
+ CREATE TABLE customers (
66
+ id serial,
67
+ url url,
68
+ image image,
69
+ attachment attachment,
70
+ domain hostname,
71
+ email email
72
+ );
73
+ `);
74
+ });
75
+
76
+ beforeEach(async () => {
77
+ await pg.beforeEach();
78
+ });
79
+
80
+ afterEach(async () => {
81
+ await pg.afterEach();
82
+ });
83
+
84
+ afterAll(async () => {
85
+ await teardown();
86
+ });
87
+
88
+ describe('types', () => {
89
+ it('valid attachment and image', async () => {
90
+ for (const value of validAttachments) {
91
+ await pg.any(`INSERT INTO customers (image) VALUES ($1::json);`, [value]);
92
+ await pg.any(`INSERT INTO customers (attachment) VALUES ($1::json);`, [value]);
93
+ }
94
+ });
95
+
96
+ it('invalid attachment and image', async () => {
97
+ for (const value of invalidAttachments) {
98
+ let failed = false;
99
+ try {
100
+ await pg.any(`INSERT INTO customers (attachment) VALUES ($1);`, [value]);
101
+ } catch (e) {
102
+ failed = true;
103
+ }
104
+ expect(failed).toBe(true);
105
+ failed = false;
106
+ try {
107
+ await pg.any(`INSERT INTO customers (image) VALUES ($1);`, [value]);
108
+ } catch (e) {
109
+ failed = true;
110
+ }
111
+ expect(failed).toBe(true);
112
+ }
113
+ });
114
+
115
+ it('valid url', async () => {
116
+ for (const value of validUrls) {
117
+ await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
118
+ }
119
+ });
120
+
121
+ it('invalid url', async () => {
122
+ for (const value of invalidUrls) {
123
+ let failed = false;
124
+ try {
125
+ await pg.any(`INSERT INTO customers (url) VALUES ($1);`, [value]);
126
+ } catch (e) {
127
+ failed = true;
128
+ }
129
+ expect(failed).toBe(true);
130
+ }
131
+ });
132
+
133
+ it('email', async () => {
134
+ await pg.any(`
135
+ INSERT INTO customers (email) VALUES
136
+ ('d@google.com'),
137
+ ('d@google.in'),
138
+ ('d@google.in'),
139
+ ('d@www.google.in'),
140
+ ('d@google.io'),
141
+ ('dan@google.some.other.com')`);
142
+ });
143
+
144
+ it('not email', async () => {
145
+ let failed = false;
146
+ try {
147
+ await pg.any(`
148
+ INSERT INTO customers (email) VALUES
149
+ ('http://google.some.other.com')`);
150
+ } catch (e) {
151
+ failed = true;
152
+ }
153
+ expect(failed).toBe(true);
154
+ });
155
+
156
+ it('hostname', async () => {
157
+ await pg.any(`
158
+ INSERT INTO customers (domain) VALUES
159
+ ('google.com'),
160
+ ('google.in'),
161
+ ('google.in'),
162
+ ('www.google.in'),
163
+ ('google.io'),
164
+ ('google.some.other.com')`);
165
+ });
166
+
167
+ it('not hostname', async () => {
168
+ let failed = false;
169
+ try {
170
+ await pg.any(`
171
+ INSERT INTO customers (domain) VALUES
172
+ ('http://google.some.other.com')`);
173
+ } catch (e) {
174
+ failed = true;
175
+ }
176
+ expect(failed).toBe(true);
177
+ });
178
+
179
+ it('not hostname 2', async () => {
180
+ let failed = false;
181
+ try {
182
+ await pg.any(`
183
+ INSERT INTO customers (domain) VALUES
184
+ ('google.some.other.com/a/b/d')`);
185
+ } catch (e) {
186
+ failed = true;
187
+ }
188
+ expect(failed).toBe(true);
189
+ });
190
+ });
@@ -0,0 +1,21 @@
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
+ });
@@ -0,0 +1,12 @@
1
+ -- Deploy schemas/public/domains/attachment to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN attachment AS jsonb CHECK (
6
+ value ?& ARRAY['url', 'mime']
7
+ AND
8
+ value->>'url' ~ '^(https?)://[^\s/$.?#].[^\s]*$'
9
+ );
10
+ COMMENT ON DOMAIN attachment IS E'@name launchqlInternalTypeAttachment';
11
+ COMMIT;
12
+
@@ -0,0 +1,8 @@
1
+ -- Deploy schemas/public/domains/email to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN email AS citext CHECK (value ~ '^[a-zA-Z0-9.!#$%&''*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$');
6
+ COMMENT ON DOMAIN email IS E'@name launchqlInternalTypeEmail';
7
+ COMMIT;
8
+
@@ -0,0 +1,8 @@
1
+ -- Deploy schemas/public/domains/hostname to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN hostname AS text CHECK (VALUE ~ '^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$');
6
+ COMMENT ON DOMAIN hostname IS E'@name launchqlInternalTypeHostname';
7
+ COMMIT;
8
+
@@ -0,0 +1,12 @@
1
+ -- Deploy schemas/public/domains/image to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN image AS jsonb CHECK (
6
+ value ?& ARRAY['url', 'mime']
7
+ AND
8
+ value->>'url' ~ '^(https?)://[^\s/$.?#].[^\s]*$'
9
+ );
10
+ COMMENT ON DOMAIN image IS E'@name launchqlInternalTypeImage';
11
+ COMMIT;
12
+
@@ -0,0 +1,8 @@
1
+ -- Deploy schemas/public/domains/multiple_select to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN multiple_select AS jsonb CHECK (value ?& ARRAY['value']);
6
+ COMMENT ON DOMAIN multiple_select IS E'@name launchqlInternalTypeMultipleSelect';
7
+ COMMIT;
8
+
@@ -0,0 +1,12 @@
1
+ -- Deploy schemas/public/domains/single_select to pg
2
+
3
+ -- requires: schemas/public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE DOMAIN single_select AS jsonb CHECK (
8
+ value ?& ARRAY['value']
9
+ );
10
+ COMMENT ON DOMAIN single_select IS E'@name launchqlInternalTypeSingleSelect';
11
+
12
+ COMMIT;
@@ -0,0 +1,10 @@
1
+ -- Deploy schemas/public/domains/upload to pg
2
+
3
+ -- requires: schemas/public/schema
4
+
5
+ BEGIN;
6
+
7
+ CREATE DOMAIN upload AS text CHECK (VALUE ~ '^(https?)://[^\s/$.?#].[^\s]*$');
8
+ COMMENT ON DOMAIN upload IS E'@name launchqlInternalTypeUpload';
9
+
10
+ COMMIT;
@@ -0,0 +1,8 @@
1
+ -- Deploy schemas/public/domains/url to pg
2
+ -- requires: schemas/public/schema
3
+
4
+ BEGIN;
5
+ CREATE DOMAIN url AS text CHECK (VALUE ~ '^(https?)://[^\s/$.?#].[^\s]*$');
6
+ COMMENT ON DOMAIN url IS E'@name launchqlInternalTypeUrl';
7
+ COMMIT;
8
+
@@ -0,0 +1,2 @@
1
+ -- Deploy schemas/public/schema to pg
2
+
package/jest.config.js ADDED
@@ -0,0 +1,15 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+
6
+ // Match both __tests__ and colocated test files
7
+ testMatch: ['**/?(*.)+(test|spec).{ts,tsx,js,jsx}'],
8
+
9
+ // Ignore build artifacts and type declarations
10
+ testPathIgnorePatterns: ['/dist/', '\\.d\\.ts$'],
11
+ modulePathIgnorePatterns: ['<rootDir>/dist/'],
12
+ watchPathIgnorePatterns: ['/dist/'],
13
+
14
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
15
+ };
@@ -0,0 +1,8 @@
1
+ # launchql-types extension
2
+ comment = 'launchql-types extension'
3
+ default_version = '0.4.6'
4
+ module_pathname = '$libdir/launchql-types'
5
+ requires = 'plpgsql,citext,launchql-verify'
6
+ relocatable = false
7
+ superuser = false
8
+
package/launchql.plan ADDED
@@ -0,0 +1,13 @@
1
+ %syntax-version=1.0.0
2
+ %project=launchql-types
3
+ %uri=launchql-types
4
+
5
+ schemas/public/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/schema
6
+ schemas/public/domains/attachment [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/attachment
7
+ schemas/public/domains/email [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/email
8
+ schemas/public/domains/hostname [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/hostname
9
+ schemas/public/domains/image [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/image
10
+ schemas/public/domains/multiple_select [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/multiple_select
11
+ schemas/public/domains/single_select [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/single_select
12
+ schemas/public/domains/upload [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/upload
13
+ schemas/public/domains/url [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/url
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@pgpm/types",
3
+ "version": "0.4.0",
4
+ "description": "Core PostgreSQL data types with deploy/verify/revert SQL scripts",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "scripts": {
9
+ "bundle": "lql package",
10
+ "test": "jest",
11
+ "test:watch": "jest --watch"
12
+ },
13
+ "dependencies": {
14
+ "@pgpm/verify": "0.4.0"
15
+ },
16
+ "devDependencies": {
17
+ "@launchql/cli": "^4.9.0"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/launchql/extensions"
22
+ },
23
+ "homepage": "https://github.com/launchql/extensions",
24
+ "bugs": {
25
+ "url": "https://github.com/launchql/extensions/issues"
26
+ },
27
+ "gitHead": "cc9f52a335caa6e21ee7751b04b77c84ce6cb809"
28
+ }
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/attachment from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.attachment;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/email from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.email;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/hostname from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP DOMAIN hostname;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/image from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.image;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/multiple_select from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.multiple_select;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/single_select from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.single_select;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/upload from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.upload;
6
+
7
+ COMMIT;
@@ -0,0 +1,7 @@
1
+ -- Revert schemas/public/domains/url from pg
2
+
3
+ BEGIN;
4
+
5
+ DROP TYPE public.url;
6
+
7
+ COMMIT;
@@ -0,0 +1 @@
1
+ -- Revert schemas/public/schema from pg
package/sqitch.plan ADDED
@@ -0,0 +1,13 @@
1
+ %syntax-version=1.0.0
2
+ %project=launchql-types
3
+ %uri=launchql-types
4
+
5
+ schemas/public/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/schema
6
+ schemas/public/domains/attachment [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/attachment
7
+ schemas/public/domains/email [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/email
8
+ schemas/public/domains/hostname [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/hostname
9
+ schemas/public/domains/image [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/image
10
+ schemas/public/domains/multiple_select [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/multiple_select
11
+ schemas/public/domains/single_select [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/single_select
12
+ schemas/public/domains/upload [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/upload
13
+ schemas/public/domains/url [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/url
@@ -0,0 +1,46 @@
1
+ \echo Use "CREATE EXTENSION launchql-types" to load this file. \quit
2
+ CREATE DOMAIN attachment AS jsonb
3
+ CHECK (
4
+ value ?& ARRAY['url', 'mime']
5
+ AND (value ->> 'url') ~ E'^(https?)://[^\\s/$.?#].[^\\s]*$'
6
+ );
7
+
8
+ COMMENT ON DOMAIN attachment IS '@name launchqlInternalTypeAttachment';
9
+
10
+ CREATE DOMAIN email AS citext
11
+ CHECK (value ~ E'^[a-zA-Z0-9.!#$%&''*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$');
12
+
13
+ COMMENT ON DOMAIN email IS '@name launchqlInternalTypeEmail';
14
+
15
+ CREATE DOMAIN hostname AS text
16
+ CHECK (value ~ E'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$');
17
+
18
+ COMMENT ON DOMAIN hostname IS '@name launchqlInternalTypeHostname';
19
+
20
+ CREATE DOMAIN image AS jsonb
21
+ CHECK (
22
+ value ?& ARRAY['url', 'mime']
23
+ AND (value ->> 'url') ~ E'^(https?)://[^\\s/$.?#].[^\\s]*$'
24
+ );
25
+
26
+ COMMENT ON DOMAIN image IS '@name launchqlInternalTypeImage';
27
+
28
+ CREATE DOMAIN multiple_select AS jsonb
29
+ CHECK (value ?& ARRAY['value']);
30
+
31
+ COMMENT ON DOMAIN multiple_select IS '@name launchqlInternalTypeMultipleSelect';
32
+
33
+ CREATE DOMAIN single_select AS jsonb
34
+ CHECK (value ?& ARRAY['value']);
35
+
36
+ COMMENT ON DOMAIN single_select IS '@name launchqlInternalTypeSingleSelect';
37
+
38
+ CREATE DOMAIN upload AS text
39
+ CHECK (value ~ E'^(https?)://[^\\s/$.?#].[^\\s]*$');
40
+
41
+ COMMENT ON DOMAIN upload IS '@name launchqlInternalTypeUpload';
42
+
43
+ CREATE DOMAIN url AS text
44
+ CHECK (value ~ E'^(https?)://[^\\s/$.?#].[^\\s]*$');
45
+
46
+ COMMENT ON DOMAIN url IS '@name launchqlInternalTypeUrl';
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/attachment on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.attachment');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/email on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.email');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/hostname on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.hostname');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/image on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.image');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/multiple_select on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.multiple_select');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/single_select on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.single_select');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/upload on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.upload');
6
+
7
+ ROLLBACK;
@@ -0,0 +1,7 @@
1
+ -- Verify schemas/public/domains/url on pg
2
+
3
+ BEGIN;
4
+
5
+ SELECT verify_domain ('public.url');
6
+
7
+ ROLLBACK;
@@ -0,0 +1 @@
1
+ -- Verify schemas/public/schema on pg