Skip to content

Commit 39cc382

Browse files
committed
refactor: simplify domain types and rename to constructiveInternalType*
- Remove single_select and multiple_select domain types - Simplify validation: - email: citext (no regex) - hostname: text (no regex) - url: text with simple http/https prefix check - origin: text with simple http/https prefix check - attachment: text (no regex) - image: jsonb requiring only 'url' key - upload: jsonb requiring url OR id OR key - Rename all smart comments from pgpmInternalType* to constructiveInternalType* - Version bump to 0.16.0
1 parent 3ada2ad commit 39cc382

19 files changed

Lines changed: 59 additions & 129 deletions

File tree

packages/types/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
EXTENSION = pgpm-types
2-
DATA = sql/pgpm-types--0.15.3.sql
2+
DATA = sql/pgpm-types--0.16.0.sql
33

44
PG_CONFIG = pg_config
55
PGXS := $(shell $(PG_CONFIG) --pgxs)

packages/types/deploy/schemas/public/domains/attachment.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
-- requires: schemas/public/schema
33

44
BEGIN;
5-
CREATE DOMAIN attachment AS text CHECK (VALUE ~ '^(https?)://[^\s/$.?#].[^\s]*$');
6-
COMMENT ON DOMAIN attachment IS E'@name pgpmInternalTypeAttachment';
5+
CREATE DOMAIN attachment AS text;
6+
COMMENT ON DOMAIN attachment IS E'@name constructiveInternalTypeAttachment';
77
COMMIT;

packages/types/deploy/schemas/public/domains/email.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- requires: schemas/public/schema
33

44
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 pgpmInternalTypeEmail';
5+
CREATE DOMAIN email AS citext;
6+
COMMENT ON DOMAIN email IS E'@name constructiveInternalTypeEmail';
77
COMMIT;
88

packages/types/deploy/schemas/public/domains/hostname.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- requires: schemas/public/schema
33

44
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 pgpmInternalTypeHostname';
5+
CREATE DOMAIN hostname AS text;
6+
COMMENT ON DOMAIN hostname IS E'@name constructiveInternalTypeHostname';
77
COMMIT;
88

packages/types/deploy/schemas/public/domains/image.sql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
-- requires: schemas/public/schema
33

44
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 pgpmInternalTypeImage';
5+
CREATE DOMAIN image AS jsonb CHECK (value ? 'url');
6+
COMMENT ON DOMAIN image IS E'@name constructiveInternalTypeImage';
117
COMMIT;
128

packages/types/deploy/schemas/public/domains/multiple_select.sql

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/types/deploy/schemas/public/domains/origin.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- requires: schemas/public/schema
33

44
BEGIN;
5-
CREATE DOMAIN origin AS text CHECK (VALUE = substring(VALUE from '^(https?://[^/]*)'));
6-
COMMENT ON DOMAIN origin IS E'@name pgpmInternalTypeOrigin';
5+
CREATE DOMAIN origin AS text CHECK (value LIKE 'http://%' OR value LIKE 'https://%');
6+
COMMENT ON DOMAIN origin IS E'@name constructiveInternalTypeOrigin';
77
COMMIT;
88

packages/types/deploy/schemas/public/domains/single_select.sql

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
-- Deploy schemas/public/domains/upload to pg
2-
32
-- requires: schemas/public/schema
43

54
BEGIN;
6-
7-
CREATE DOMAIN upload AS jsonb CHECK (
8-
value ?& ARRAY['url', 'mime']
9-
AND
10-
value->>'url' ~ '^(https?)://[^\s/$.?#].[^\s]*$'
11-
);
12-
COMMENT ON DOMAIN upload IS E'@name pgpmInternalTypeUpload';
13-
5+
CREATE DOMAIN upload AS jsonb CHECK (value ? 'url' OR value ? 'id' OR value ? 'key');
6+
COMMENT ON DOMAIN upload IS E'@name constructiveInternalTypeUpload';
147
COMMIT;

packages/types/deploy/schemas/public/domains/url.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- requires: schemas/public/schema
33

44
BEGIN;
5-
CREATE DOMAIN url AS text CHECK (VALUE ~ '^(https?)://[^\s/$.?#].[^\s]*$');
6-
COMMENT ON DOMAIN url IS E'@name pgpmInternalTypeUrl';
5+
CREATE DOMAIN url AS text CHECK (value LIKE 'http://%' OR value LIKE 'https://%');
6+
COMMENT ON DOMAIN url IS E'@name constructiveInternalTypeUrl';
77
COMMIT;
88

0 commit comments

Comments
 (0)