@pgpm/types 0.11.1 → 0.12.2
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/README.md
CHANGED
|
@@ -22,9 +22,10 @@ Core PostgreSQL data types with SQL scripts.
|
|
|
22
22
|
|
|
23
23
|
- **email**: Case-insensitive email address validation
|
|
24
24
|
- **url**: HTTP/HTTPS URL validation
|
|
25
|
+
- **origin**: Origin URL validation (scheme + host)
|
|
25
26
|
- **hostname**: Domain name validation
|
|
26
27
|
- **image**: JSON-based image metadata with URL and MIME type
|
|
27
|
-
- **attachment**:
|
|
28
|
+
- **attachment**: File attachment metadata as a URL string or JSON with URL and MIME type
|
|
28
29
|
- **upload**: File upload metadata
|
|
29
30
|
- **single_select**: Single selection field
|
|
30
31
|
- **multiple_select**: Multiple selection field
|
|
@@ -156,7 +157,7 @@ INSERT INTO customers (domain) VALUES
|
|
|
156
157
|
|
|
157
158
|
### Image and Attachment Domains
|
|
158
159
|
|
|
159
|
-
The `image`
|
|
160
|
+
The `image` domain stores JSON objects with URL and MIME type information. The `attachment` domain accepts either that JSON shape or a plain URL string.
|
|
160
161
|
|
|
161
162
|
```sql
|
|
162
163
|
-- Valid image
|
|
@@ -166,9 +167,12 @@ INSERT INTO customers (profile_image) VALUES
|
|
|
166
167
|
-- Valid attachment
|
|
167
168
|
INSERT INTO customers (document) VALUES
|
|
168
169
|
('{"url": "https://storage.example.com/file.pdf", "mime": "application/pdf"}'::json);
|
|
170
|
+
|
|
171
|
+
-- Valid attachment as plain URL
|
|
172
|
+
INSERT INTO customers (document) VALUES ('https://storage.example.com/favicon.ico');
|
|
169
173
|
```
|
|
170
174
|
|
|
171
|
-
**Structure**:
|
|
175
|
+
**Structure**: Image values and JSON-form attachments expect `url` and `mime` properties; attachments also allow a bare URL string.
|
|
172
176
|
|
|
173
177
|
## Domain Types Reference
|
|
174
178
|
|
|
@@ -176,9 +180,10 @@ INSERT INTO customers (document) VALUES
|
|
|
176
180
|
|--------|-----------|-------------|---------|
|
|
177
181
|
| `email` | `citext` | Case-insensitive email address | `user@example.com` |
|
|
178
182
|
| `url` | `text` | HTTP/HTTPS URL | `https://example.com/path` |
|
|
183
|
+
| `origin` | `text` | Origin (scheme + host) | `https://example.com` |
|
|
179
184
|
| `hostname` | `text` | Domain name without protocol | `example.com` |
|
|
180
185
|
| `image` | `json` | Image metadata with URL and MIME | `{"url": "...", "mime": "image/jpeg"}` |
|
|
181
|
-
| `attachment` | `json` | File attachment metadata | `{"url": "...", "mime": "application/pdf"}` |
|
|
186
|
+
| `attachment` | `json` | File attachment URL or metadata | `{"url": "...", "mime": "application/pdf"}` or `https://example.com/favicon.ico` |
|
|
182
187
|
| `upload` | `text` | File upload identifier | Various formats |
|
|
183
188
|
| `single_select` | `text` | Single selection value | Text value |
|
|
184
189
|
| `multiple_select` | `text[]` | Multiple selection values | Array of text values |
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
BEGIN;
|
|
5
5
|
CREATE DOMAIN attachment AS jsonb CHECK (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
(
|
|
7
|
+
jsonb_typeof(VALUE) = 'object'
|
|
8
|
+
AND VALUE ?& ARRAY['url', 'mime']
|
|
9
|
+
AND VALUE->>'url' ~ '^(https?)://[^\s/$.?#].[^\s]*$'
|
|
10
|
+
)
|
|
11
|
+
OR (
|
|
12
|
+
jsonb_typeof(VALUE) = 'string'
|
|
13
|
+
AND VALUE #>> '{}' ~ '^(https?)://[^\s/$.?#].[^\s]*$'
|
|
14
|
+
)
|
|
9
15
|
);
|
|
10
16
|
COMMENT ON DOMAIN attachment IS E'@name launchqlInternalTypeAttachment';
|
|
11
17
|
COMMIT;
|
|
12
|
-
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
-- Deploy schemas/public/domains/origin to pg
|
|
2
|
-
|
|
3
2
|
-- requires: schemas/public/schema
|
|
4
3
|
|
|
5
4
|
BEGIN;
|
|
6
|
-
|
|
7
|
-
CREATE DOMAIN origin AS text CHECK (VALUE = substring(VALUE from '^(https?://[^/]*)') );
|
|
5
|
+
CREATE DOMAIN origin AS text CHECK (VALUE = substring(VALUE from '^(https?://[^/]*)'));
|
|
8
6
|
COMMENT ON DOMAIN origin IS E'@name launchqlInternalTypeOrigin';
|
|
9
|
-
|
|
10
7
|
COMMIT;
|
|
8
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.2",
|
|
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,7 +21,7 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@pgpm/verify": "0.
|
|
24
|
+
"@pgpm/verify": "0.12.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"pgpm": "^0.2.0"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"bugs": {
|
|
35
35
|
"url": "https://github.com/launchql/pgpm-modules/issues"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "880c1b99631ac536288584ace0ac3dd40300f17e"
|
|
38
38
|
}
|
package/pgpm.plan
CHANGED
|
@@ -8,6 +8,7 @@ schemas/public/domains/email [schemas/public/schema] 2017-08-11T08:11:51Z skitch
|
|
|
8
8
|
schemas/public/domains/hostname [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/hostname
|
|
9
9
|
schemas/public/domains/image [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/image
|
|
10
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/origin [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/origin
|
|
11
12
|
schemas/public/domains/single_select [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/single_select
|
|
12
13
|
schemas/public/domains/upload [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/upload
|
|
13
14
|
schemas/public/domains/url [schemas/public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/public/domains/url
|