@dereekb/model 13.11.18 → 13.12.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.
- package/index.cjs.js +139 -0
- package/index.esm.js +138 -1
- package/package.json +2 -2
- package/src/lib/type/type.d.ts +33 -0
package/index.cjs.js
CHANGED
|
@@ -21,6 +21,56 @@ var makeError = require('make-error');
|
|
|
21
21
|
id: modelIdType
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
function _array_like_to_array$3(arr, len) {
|
|
25
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
26
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
27
|
+
return arr2;
|
|
28
|
+
}
|
|
29
|
+
function _array_with_holes$3(arr) {
|
|
30
|
+
if (Array.isArray(arr)) return arr;
|
|
31
|
+
}
|
|
32
|
+
function _iterable_to_array_limit$3(arr, i) {
|
|
33
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
34
|
+
if (_i == null) return;
|
|
35
|
+
var _arr = [];
|
|
36
|
+
var _n = true;
|
|
37
|
+
var _d = false;
|
|
38
|
+
var _s, _e;
|
|
39
|
+
try {
|
|
40
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
41
|
+
_arr.push(_s.value);
|
|
42
|
+
if (i && _arr.length === i) break;
|
|
43
|
+
}
|
|
44
|
+
} catch (err) {
|
|
45
|
+
_d = true;
|
|
46
|
+
_e = err;
|
|
47
|
+
} finally{
|
|
48
|
+
try {
|
|
49
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
50
|
+
} finally{
|
|
51
|
+
if (_d) throw _e;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return _arr;
|
|
55
|
+
}
|
|
56
|
+
function _non_iterable_rest$3() {
|
|
57
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
58
|
+
}
|
|
59
|
+
function _sliced_to_array$3(arr, i) {
|
|
60
|
+
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
|
|
61
|
+
}
|
|
62
|
+
function _type_of$1(obj) {
|
|
63
|
+
"@swc/helpers - typeof";
|
|
64
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
65
|
+
}
|
|
66
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
67
|
+
if (!o) return;
|
|
68
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
69
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
70
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
71
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
72
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
73
|
+
}
|
|
24
74
|
/**
|
|
25
75
|
* Singleton ArkType schema that accepts any empty object (`{}`).
|
|
26
76
|
*
|
|
@@ -54,6 +104,93 @@ function clearable(definition) {
|
|
|
54
104
|
}
|
|
55
105
|
return result;
|
|
56
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* JSON Schema export helper that compensates for arktype's lossy export of narrow predicates,
|
|
109
|
+
* morphs, and `undefined`. Without this:.
|
|
110
|
+
*
|
|
111
|
+
* - narrowed strings like `type('string > 0').narrow(...)` export as the empty schema `{}`
|
|
112
|
+
* because arktype drops the narrow predicate and has no JSON-shaped base to fall back on.
|
|
113
|
+
* - {@link clearable} (a `T | null | undefined` union) exports as `anyOf: [<T>, {}, {type:"null"}]`
|
|
114
|
+
* because `undefined` has no JSON Schema equivalent.
|
|
115
|
+
*
|
|
116
|
+
* The fallback config:
|
|
117
|
+
* - `predicate` / `morph` — drop the lossy wrapper, keep the JSON-shaped base (e.g. a narrowed
|
|
118
|
+
* `string > 0` becomes `{type:"string", minLength:1}`).
|
|
119
|
+
* - `default` — emit `false` (matches nothing). This is a no-op inside `anyOf`, and
|
|
120
|
+
* {@link pruneFalseUnionBranches} strips it so `T | null | undefined` reads as `T | null`.
|
|
121
|
+
*
|
|
122
|
+
* The result is round-tripped through `JSON.parse(JSON.stringify(...))` to invoke arktype's
|
|
123
|
+
* boxed-node `toJSON()` callbacks before pruning; `structuredClone` would not call them.
|
|
124
|
+
*
|
|
125
|
+
* @param t - The arktype Type to export.
|
|
126
|
+
* @returns The pruned JSON Schema fragment as a plain object.
|
|
127
|
+
*/ function arktypeToJsonSchemaForExport(t) {
|
|
128
|
+
var raw = t.toJsonSchema({
|
|
129
|
+
fallback: {
|
|
130
|
+
predicate: function predicate(ctx) {
|
|
131
|
+
return ctx.base;
|
|
132
|
+
},
|
|
133
|
+
morph: function morph(ctx) {
|
|
134
|
+
return ctx.base;
|
|
135
|
+
},
|
|
136
|
+
// `false` is a valid JSON Schema value ("matches nothing"), but arktype's TS types
|
|
137
|
+
// reject `false` as the fallback return — cast through `unknown` to keep runtime behavior.
|
|
138
|
+
default: function _default() {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// structuredClone would skip arktype's boxed-node toJSON() callbacks, so JSON round-trip is required here.
|
|
144
|
+
return pruneFalseUnionBranches(JSON.parse(JSON.stringify(raw))); // NOSONAR typescript:S7784
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Walks a JSON Schema and removes `false` entries from `anyOf` / `oneOf` arrays. `false`
|
|
148
|
+
* schemas match nothing, so dropping them does not change what the schema accepts — it
|
|
149
|
+
* just keeps the rendered output clean when {@link arktypeToJsonSchemaForExport}'s
|
|
150
|
+
* `() => false` fallback emitted no-op branches for unjsonifiable types like `undefined`.
|
|
151
|
+
*
|
|
152
|
+
* @param value - JSON Schema fragment to clean.
|
|
153
|
+
* @returns A structurally equivalent fragment with `false` branches dropped from any
|
|
154
|
+
* `anyOf` / `oneOf` arrays.
|
|
155
|
+
*/ function pruneFalseUnionBranches(value) {
|
|
156
|
+
var result = value;
|
|
157
|
+
if (Array.isArray(value)) {
|
|
158
|
+
result = value.map(pruneFalseUnionBranches);
|
|
159
|
+
} else if (value && (typeof value === "undefined" ? "undefined" : _type_of$1(value)) === 'object') {
|
|
160
|
+
var out = {};
|
|
161
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
162
|
+
try {
|
|
163
|
+
for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
164
|
+
var _step_value = _sliced_to_array$3(_step.value, 2), key = _step_value[0], raw = _step_value[1];
|
|
165
|
+
if ((key === 'anyOf' || key === 'oneOf') && Array.isArray(raw)) {
|
|
166
|
+
var filtered = raw.filter(function(v) {
|
|
167
|
+
return v !== false;
|
|
168
|
+
}).map(pruneFalseUnionBranches);
|
|
169
|
+
if (filtered.length > 0) {
|
|
170
|
+
out[key] = filtered;
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
out[key] = pruneFalseUnionBranches(raw);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
} catch (err) {
|
|
177
|
+
_didIteratorError = true;
|
|
178
|
+
_iteratorError = err;
|
|
179
|
+
} finally{
|
|
180
|
+
try {
|
|
181
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
182
|
+
_iterator.return();
|
|
183
|
+
}
|
|
184
|
+
} finally{
|
|
185
|
+
if (_didIteratorError) {
|
|
186
|
+
throw _iteratorError;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
result = out;
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
57
194
|
|
|
58
195
|
/**
|
|
59
196
|
* Matches "Date | string.date.parse".
|
|
@@ -2926,6 +3063,7 @@ exports.WEBSITE_URL_WEBSITE_LINK_TYPE = WEBSITE_URL_WEBSITE_LINK_TYPE;
|
|
|
2926
3063
|
exports.YOUTUBE_BASE_URL = YOUTUBE_BASE_URL;
|
|
2927
3064
|
exports.YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID = YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID;
|
|
2928
3065
|
exports.YOUTUBE_WEBSITE_LINK_TYPE = YOUTUBE_WEBSITE_LINK_TYPE;
|
|
3066
|
+
exports.arktypeToJsonSchemaForExport = arktypeToJsonSchemaForExport;
|
|
2929
3067
|
exports.basicSyncEntityCommonTypeSynchronizerInstanceFactory = basicSyncEntityCommonTypeSynchronizerInstanceFactory;
|
|
2930
3068
|
exports.cashappProfileUrl = cashappProfileUrl;
|
|
2931
3069
|
exports.cashappProfileUrlToWebsiteLink = cashappProfileUrlToWebsiteLink;
|
|
@@ -2961,6 +3099,7 @@ exports.noAccessRoleMap = noAccessRoleMap;
|
|
|
2961
3099
|
exports.paypalProfileUrl = paypalProfileUrl;
|
|
2962
3100
|
exports.paypalProfileUrlToWebsiteLink = paypalProfileUrlToWebsiteLink;
|
|
2963
3101
|
exports.phoneNumberToWebsiteLink = phoneNumberToWebsiteLink;
|
|
3102
|
+
exports.pruneFalseUnionBranches = pruneFalseUnionBranches;
|
|
2964
3103
|
exports.snapchatProfileUrl = snapchatProfileUrl;
|
|
2965
3104
|
exports.snapchatProfileUrlToWebsiteLink = snapchatProfileUrlToWebsiteLink;
|
|
2966
3105
|
exports.spotifyProfileUrl = spotifyProfileUrl;
|
package/index.esm.js
CHANGED
|
@@ -19,6 +19,56 @@ import { BaseError } from 'make-error';
|
|
|
19
19
|
id: modelIdType
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
function _array_like_to_array$3(arr, len) {
|
|
23
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
24
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
25
|
+
return arr2;
|
|
26
|
+
}
|
|
27
|
+
function _array_with_holes$3(arr) {
|
|
28
|
+
if (Array.isArray(arr)) return arr;
|
|
29
|
+
}
|
|
30
|
+
function _iterable_to_array_limit$3(arr, i) {
|
|
31
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
32
|
+
if (_i == null) return;
|
|
33
|
+
var _arr = [];
|
|
34
|
+
var _n = true;
|
|
35
|
+
var _d = false;
|
|
36
|
+
var _s, _e;
|
|
37
|
+
try {
|
|
38
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
39
|
+
_arr.push(_s.value);
|
|
40
|
+
if (i && _arr.length === i) break;
|
|
41
|
+
}
|
|
42
|
+
} catch (err) {
|
|
43
|
+
_d = true;
|
|
44
|
+
_e = err;
|
|
45
|
+
} finally{
|
|
46
|
+
try {
|
|
47
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
48
|
+
} finally{
|
|
49
|
+
if (_d) throw _e;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return _arr;
|
|
53
|
+
}
|
|
54
|
+
function _non_iterable_rest$3() {
|
|
55
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56
|
+
}
|
|
57
|
+
function _sliced_to_array$3(arr, i) {
|
|
58
|
+
return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
|
|
59
|
+
}
|
|
60
|
+
function _type_of$1(obj) {
|
|
61
|
+
"@swc/helpers - typeof";
|
|
62
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
63
|
+
}
|
|
64
|
+
function _unsupported_iterable_to_array$3(o, minLen) {
|
|
65
|
+
if (!o) return;
|
|
66
|
+
if (typeof o === "string") return _array_like_to_array$3(o, minLen);
|
|
67
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
68
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
69
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
70
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
|
|
71
|
+
}
|
|
22
72
|
/**
|
|
23
73
|
* Singleton ArkType schema that accepts any empty object (`{}`).
|
|
24
74
|
*
|
|
@@ -52,6 +102,93 @@ function clearable(definition) {
|
|
|
52
102
|
}
|
|
53
103
|
return result;
|
|
54
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* JSON Schema export helper that compensates for arktype's lossy export of narrow predicates,
|
|
107
|
+
* morphs, and `undefined`. Without this:.
|
|
108
|
+
*
|
|
109
|
+
* - narrowed strings like `type('string > 0').narrow(...)` export as the empty schema `{}`
|
|
110
|
+
* because arktype drops the narrow predicate and has no JSON-shaped base to fall back on.
|
|
111
|
+
* - {@link clearable} (a `T | null | undefined` union) exports as `anyOf: [<T>, {}, {type:"null"}]`
|
|
112
|
+
* because `undefined` has no JSON Schema equivalent.
|
|
113
|
+
*
|
|
114
|
+
* The fallback config:
|
|
115
|
+
* - `predicate` / `morph` — drop the lossy wrapper, keep the JSON-shaped base (e.g. a narrowed
|
|
116
|
+
* `string > 0` becomes `{type:"string", minLength:1}`).
|
|
117
|
+
* - `default` — emit `false` (matches nothing). This is a no-op inside `anyOf`, and
|
|
118
|
+
* {@link pruneFalseUnionBranches} strips it so `T | null | undefined` reads as `T | null`.
|
|
119
|
+
*
|
|
120
|
+
* The result is round-tripped through `JSON.parse(JSON.stringify(...))` to invoke arktype's
|
|
121
|
+
* boxed-node `toJSON()` callbacks before pruning; `structuredClone` would not call them.
|
|
122
|
+
*
|
|
123
|
+
* @param t - The arktype Type to export.
|
|
124
|
+
* @returns The pruned JSON Schema fragment as a plain object.
|
|
125
|
+
*/ function arktypeToJsonSchemaForExport(t) {
|
|
126
|
+
var raw = t.toJsonSchema({
|
|
127
|
+
fallback: {
|
|
128
|
+
predicate: function predicate(ctx) {
|
|
129
|
+
return ctx.base;
|
|
130
|
+
},
|
|
131
|
+
morph: function morph(ctx) {
|
|
132
|
+
return ctx.base;
|
|
133
|
+
},
|
|
134
|
+
// `false` is a valid JSON Schema value ("matches nothing"), but arktype's TS types
|
|
135
|
+
// reject `false` as the fallback return — cast through `unknown` to keep runtime behavior.
|
|
136
|
+
default: function _default() {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
// structuredClone would skip arktype's boxed-node toJSON() callbacks, so JSON round-trip is required here.
|
|
142
|
+
return pruneFalseUnionBranches(JSON.parse(JSON.stringify(raw))); // NOSONAR typescript:S7784
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Walks a JSON Schema and removes `false` entries from `anyOf` / `oneOf` arrays. `false`
|
|
146
|
+
* schemas match nothing, so dropping them does not change what the schema accepts — it
|
|
147
|
+
* just keeps the rendered output clean when {@link arktypeToJsonSchemaForExport}'s
|
|
148
|
+
* `() => false` fallback emitted no-op branches for unjsonifiable types like `undefined`.
|
|
149
|
+
*
|
|
150
|
+
* @param value - JSON Schema fragment to clean.
|
|
151
|
+
* @returns A structurally equivalent fragment with `false` branches dropped from any
|
|
152
|
+
* `anyOf` / `oneOf` arrays.
|
|
153
|
+
*/ function pruneFalseUnionBranches(value) {
|
|
154
|
+
var result = value;
|
|
155
|
+
if (Array.isArray(value)) {
|
|
156
|
+
result = value.map(pruneFalseUnionBranches);
|
|
157
|
+
} else if (value && (typeof value === "undefined" ? "undefined" : _type_of$1(value)) === 'object') {
|
|
158
|
+
var out = {};
|
|
159
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
160
|
+
try {
|
|
161
|
+
for(var _iterator = Object.entries(value)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
162
|
+
var _step_value = _sliced_to_array$3(_step.value, 2), key = _step_value[0], raw = _step_value[1];
|
|
163
|
+
if ((key === 'anyOf' || key === 'oneOf') && Array.isArray(raw)) {
|
|
164
|
+
var filtered = raw.filter(function(v) {
|
|
165
|
+
return v !== false;
|
|
166
|
+
}).map(pruneFalseUnionBranches);
|
|
167
|
+
if (filtered.length > 0) {
|
|
168
|
+
out[key] = filtered;
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
out[key] = pruneFalseUnionBranches(raw);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
_didIteratorError = true;
|
|
176
|
+
_iteratorError = err;
|
|
177
|
+
} finally{
|
|
178
|
+
try {
|
|
179
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
180
|
+
_iterator.return();
|
|
181
|
+
}
|
|
182
|
+
} finally{
|
|
183
|
+
if (_didIteratorError) {
|
|
184
|
+
throw _iteratorError;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
result = out;
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
55
192
|
|
|
56
193
|
/**
|
|
57
194
|
* Matches "Date | string.date.parse".
|
|
@@ -2863,4 +3000,4 @@ function _ts_generator(thisArg, body) {
|
|
|
2863
3000
|
return val != null && isWebsiteUrlWithPrefix(val) || ctx.mustBe('a valid website URL starting with http:// or https://');
|
|
2864
3001
|
});
|
|
2865
3002
|
|
|
2866
|
-
export { ADDRESS_CITY_MAX_LENGTH, ADDRESS_COUNTRY_MAX_LENGTH, ADDRESS_LINE_MAX_LENGTH, ADDRESS_STATE_CODE_MAX_LENGTH, ADDRESS_STATE_MAX_LENGTH, ADDRESS_ZIP_MAX_LENGTH, ARKTYPE_DATE_DTO_TYPE, AbstractModelPermissionService, CASHAPP_BASE_URL, CASHAPP_USERNAME_PREFIX, CASHAPP_WEBSITE_LINK_TYPE, EMAIL_URL_WEBSITE_LINK_TYPE, EMPTY_ARKTYPE_TYPE, FACEBOOK_BASE_URL, FACEBOOK_WEBSITE_LINK_TYPE, FULL_ACCESS_ROLE_KEY, GRANTED_ADMIN_ROLE_KEY, GRANTED_DELETE_ROLE_KEY, GRANTED_OWNER_ROLE_KEY, GRANTED_READ_ROLE_KEY, GRANTED_SYS_ADMIN_ROLE_KEY, GRANTED_UPDATE_ROLE_KEY, GrantedRoleMapReaderInstance, INSTAGRAM_BASE_URL, INSTAGRAM_WEBSITE_LINK_TYPE, NO_ACCESS_ROLE_KEY, PAYPAL_BASE_URL, PAYPAL_WEBSITE_LINK_TYPE, PHONE_URL_WEBSITE_LINK_TYPE, SNAPCHAT_BASE_URL, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID, SNAPCHAT_WEBSITE_LINK_TYPE, SPOTIFY_BASE_URL, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID, SPOTIFY_WEBSITE_LINK_TYPE, TIKTOK_BASE_URL, TIKTOK_USERNAME_PREFIX, TIKTOK_WEBSITE_LINK_TYPE, TWITTER_BASE_URL, TWITTER_WEBSITE_LINK_TYPE, UNKNOWN_WEBSITE_LINK_TYPE, VENMO_BASE_URL, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID, VENMO_WEBSITE_LINK_TYPE, WEBSITE_FILE_LINK_DATA_MAX_LENGTH, WEBSITE_FILE_LINK_DATA_REGEX, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_MIME_TYPE_REGEX, WEBSITE_FILE_LINK_NAME_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_REGEX, WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE, WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH, WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID, WEBSITE_LINK_TYPE_MAX_LENGTH, WEBSITE_LINK_TYPE_REGEX, WEBSITE_URL_WEBSITE_LINK_TYPE, YOUTUBE_BASE_URL, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID, YOUTUBE_WEBSITE_LINK_TYPE, basicSyncEntityCommonTypeSynchronizerInstanceFactory, cashappProfileUrl, cashappProfileUrlToWebsiteLink, clearable, contextGrantedModelRoles, decodeWebsiteLinkEncodedDataToWebsiteFileLink, e164PhoneNumberType, e164PhoneNumberWithExtensionType, e164PhoneNumberWithOptionalExtensionType, emailAddressToWebsiteLink, emptyType, encodeWebsiteFileLinkToWebsiteLinkEncodedData, facebookProfileUrl, facebookProfileUrlToWebsiteLink, fullAccessGrantedModelRoles, fullAccessRoleMap, grantedRoleKeysMapFromArray, grantedRoleMapReader, instagramProfileUrl, instagramProfileUrlToWebsiteLink, isFullAccessRoleMap, isGrantedAdminLevelRole, isNoAccessRoleMap, isValidWebsiteLinkType, iso8601DayStringType, latLngPointType, latLngStringType, minuteOfDayType, modelIdType, modelKeyType, noAccessContextGrantedModelRoles, noAccessRoleMap, paypalProfileUrl, paypalProfileUrlToWebsiteLink, phoneNumberToWebsiteLink, snapchatProfileUrl, snapchatProfileUrlToWebsiteLink, spotifyProfileUrl, spotifyProfileUrlToWebsiteLink, syncEntityCommonTypeIdPairFactory, syncEntityFactory, syncEntitySynchronizer, targetModelIdParamsType, targetModelParamsType, tiktokProfileUrl, tiktokProfileUrlToWebsiteLink, toTransformAndValidateFunctionResult, toTransformAndValidateFunctionResultFactory, transformAndValidateFunctionResultFactory, transformAndValidateObject, transformAndValidateObjectFactory, transformAndValidateObjectResult, transformAndValidateResultFactory, twitterProfileUrl, twitterProfileUrlToWebsiteLink, uniqueKeyedType, unitedStatesAddressWithStateCodeType, unitedStatesAddressWithStateStringType, usernameFromUsernameOrWebsiteWithBaseUrlUsername, usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername, usernameOrWebsiteUrlToWebsiteUrl, venmoProfileUrl, venmoProfileUrlToWebsiteLink, websiteFileLinkToWebsiteLink, websiteFileLinkType, websiteLinkToWebsiteLinkFile, websiteLinkType, websiteUrlToWebsiteLink, websiteUrlType, websiteUrlWithPrefixType, youtubeProfileUrl, youtubeProfileUrlToWebsiteLink };
|
|
3003
|
+
export { ADDRESS_CITY_MAX_LENGTH, ADDRESS_COUNTRY_MAX_LENGTH, ADDRESS_LINE_MAX_LENGTH, ADDRESS_STATE_CODE_MAX_LENGTH, ADDRESS_STATE_MAX_LENGTH, ADDRESS_ZIP_MAX_LENGTH, ARKTYPE_DATE_DTO_TYPE, AbstractModelPermissionService, CASHAPP_BASE_URL, CASHAPP_USERNAME_PREFIX, CASHAPP_WEBSITE_LINK_TYPE, EMAIL_URL_WEBSITE_LINK_TYPE, EMPTY_ARKTYPE_TYPE, FACEBOOK_BASE_URL, FACEBOOK_WEBSITE_LINK_TYPE, FULL_ACCESS_ROLE_KEY, GRANTED_ADMIN_ROLE_KEY, GRANTED_DELETE_ROLE_KEY, GRANTED_OWNER_ROLE_KEY, GRANTED_READ_ROLE_KEY, GRANTED_SYS_ADMIN_ROLE_KEY, GRANTED_UPDATE_ROLE_KEY, GrantedRoleMapReaderInstance, INSTAGRAM_BASE_URL, INSTAGRAM_WEBSITE_LINK_TYPE, NO_ACCESS_ROLE_KEY, PAYPAL_BASE_URL, PAYPAL_WEBSITE_LINK_TYPE, PHONE_URL_WEBSITE_LINK_TYPE, SNAPCHAT_BASE_URL, SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID, SNAPCHAT_WEBSITE_LINK_TYPE, SPOTIFY_BASE_URL, SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID, SPOTIFY_WEBSITE_LINK_TYPE, TIKTOK_BASE_URL, TIKTOK_USERNAME_PREFIX, TIKTOK_WEBSITE_LINK_TYPE, TWITTER_BASE_URL, TWITTER_WEBSITE_LINK_TYPE, UNKNOWN_WEBSITE_LINK_TYPE, VENMO_BASE_URL, VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID, VENMO_WEBSITE_LINK_TYPE, WEBSITE_FILE_LINK_DATA_MAX_LENGTH, WEBSITE_FILE_LINK_DATA_REGEX, WEBSITE_FILE_LINK_ENCODE_SEPARATOR, WEBSITE_FILE_LINK_MIME_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_MIME_TYPE_REGEX, WEBSITE_FILE_LINK_NAME_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_MAX_LENGTH, WEBSITE_FILE_LINK_TYPE_REGEX, WEBSITE_FILE_LINK_WEBSITE_LINK_TYPE, WEBSITE_LINK_ENCODED_DATA_MAX_LENGTH, WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID, WEBSITE_LINK_TYPE_MAX_LENGTH, WEBSITE_LINK_TYPE_REGEX, WEBSITE_URL_WEBSITE_LINK_TYPE, YOUTUBE_BASE_URL, YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID, YOUTUBE_WEBSITE_LINK_TYPE, arktypeToJsonSchemaForExport, basicSyncEntityCommonTypeSynchronizerInstanceFactory, cashappProfileUrl, cashappProfileUrlToWebsiteLink, clearable, contextGrantedModelRoles, decodeWebsiteLinkEncodedDataToWebsiteFileLink, e164PhoneNumberType, e164PhoneNumberWithExtensionType, e164PhoneNumberWithOptionalExtensionType, emailAddressToWebsiteLink, emptyType, encodeWebsiteFileLinkToWebsiteLinkEncodedData, facebookProfileUrl, facebookProfileUrlToWebsiteLink, fullAccessGrantedModelRoles, fullAccessRoleMap, grantedRoleKeysMapFromArray, grantedRoleMapReader, instagramProfileUrl, instagramProfileUrlToWebsiteLink, isFullAccessRoleMap, isGrantedAdminLevelRole, isNoAccessRoleMap, isValidWebsiteLinkType, iso8601DayStringType, latLngPointType, latLngStringType, minuteOfDayType, modelIdType, modelKeyType, noAccessContextGrantedModelRoles, noAccessRoleMap, paypalProfileUrl, paypalProfileUrlToWebsiteLink, phoneNumberToWebsiteLink, pruneFalseUnionBranches, snapchatProfileUrl, snapchatProfileUrlToWebsiteLink, spotifyProfileUrl, spotifyProfileUrlToWebsiteLink, syncEntityCommonTypeIdPairFactory, syncEntityFactory, syncEntitySynchronizer, targetModelIdParamsType, targetModelParamsType, tiktokProfileUrl, tiktokProfileUrlToWebsiteLink, toTransformAndValidateFunctionResult, toTransformAndValidateFunctionResultFactory, transformAndValidateFunctionResultFactory, transformAndValidateObject, transformAndValidateObjectFactory, transformAndValidateObjectResult, transformAndValidateResultFactory, twitterProfileUrl, twitterProfileUrlToWebsiteLink, uniqueKeyedType, unitedStatesAddressWithStateCodeType, unitedStatesAddressWithStateStringType, usernameFromUsernameOrWebsiteWithBaseUrlUsername, usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername, usernameOrWebsiteUrlToWebsiteUrl, venmoProfileUrl, venmoProfileUrlToWebsiteLink, websiteFileLinkToWebsiteLink, websiteFileLinkType, websiteLinkToWebsiteLinkFile, websiteLinkType, websiteUrlToWebsiteLink, websiteUrlType, websiteUrlWithPrefixType, youtubeProfileUrl, youtubeProfileUrlToWebsiteLink };
|
package/package.json
CHANGED
package/src/lib/type/type.d.ts
CHANGED
|
@@ -72,3 +72,36 @@ export declare function emptyType<T = {}>(): Type<T>;
|
|
|
72
72
|
*/
|
|
73
73
|
export declare function clearable<const def extends string>(definition: def): Type<Maybe<type.infer<def>>>;
|
|
74
74
|
export declare function clearable<T>(definition: Type<T>): Type<Maybe<T>>;
|
|
75
|
+
/**
|
|
76
|
+
* JSON Schema export helper that compensates for arktype's lossy export of narrow predicates,
|
|
77
|
+
* morphs, and `undefined`. Without this:.
|
|
78
|
+
*
|
|
79
|
+
* - narrowed strings like `type('string > 0').narrow(...)` export as the empty schema `{}`
|
|
80
|
+
* because arktype drops the narrow predicate and has no JSON-shaped base to fall back on.
|
|
81
|
+
* - {@link clearable} (a `T | null | undefined` union) exports as `anyOf: [<T>, {}, {type:"null"}]`
|
|
82
|
+
* because `undefined` has no JSON Schema equivalent.
|
|
83
|
+
*
|
|
84
|
+
* The fallback config:
|
|
85
|
+
* - `predicate` / `morph` — drop the lossy wrapper, keep the JSON-shaped base (e.g. a narrowed
|
|
86
|
+
* `string > 0` becomes `{type:"string", minLength:1}`).
|
|
87
|
+
* - `default` — emit `false` (matches nothing). This is a no-op inside `anyOf`, and
|
|
88
|
+
* {@link pruneFalseUnionBranches} strips it so `T | null | undefined` reads as `T | null`.
|
|
89
|
+
*
|
|
90
|
+
* The result is round-tripped through `JSON.parse(JSON.stringify(...))` to invoke arktype's
|
|
91
|
+
* boxed-node `toJSON()` callbacks before pruning; `structuredClone` would not call them.
|
|
92
|
+
*
|
|
93
|
+
* @param t - The arktype Type to export.
|
|
94
|
+
* @returns The pruned JSON Schema fragment as a plain object.
|
|
95
|
+
*/
|
|
96
|
+
export declare function arktypeToJsonSchemaForExport(t: Type<unknown>): unknown;
|
|
97
|
+
/**
|
|
98
|
+
* Walks a JSON Schema and removes `false` entries from `anyOf` / `oneOf` arrays. `false`
|
|
99
|
+
* schemas match nothing, so dropping them does not change what the schema accepts — it
|
|
100
|
+
* just keeps the rendered output clean when {@link arktypeToJsonSchemaForExport}'s
|
|
101
|
+
* `() => false` fallback emitted no-op branches for unjsonifiable types like `undefined`.
|
|
102
|
+
*
|
|
103
|
+
* @param value - JSON Schema fragment to clean.
|
|
104
|
+
* @returns A structurally equivalent fragment with `false` branches dropped from any
|
|
105
|
+
* `anyOf` / `oneOf` arrays.
|
|
106
|
+
*/
|
|
107
|
+
export declare function pruneFalseUnionBranches(value: unknown): unknown;
|