@stndrds/schema 1.0.0-alpha.89 → 1.0.0-alpha.90
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/dist/{chunk-JUVFK6XD.mjs → chunk-4362R5F2.mjs} +40 -1
- package/dist/{chunk-ZW4N6FV7.js → chunk-7QUI6TSO.js} +40 -1
- package/dist/index.d.mts +6060 -1182
- package/dist/index.d.ts +6060 -1182
- package/dist/index.js +4896 -656
- package/dist/index.mjs +4851 -611
- package/dist/utils.js +0 -1
- package/dist/utils.mjs +0 -1
- package/dist/validation/validators.d.mts +1 -1
- package/dist/validation/validators.d.ts +1 -1
- package/dist/validation/validators.js +2 -3
- package/dist/validation/validators.mjs +1 -2
- package/dist/{validators-CJmtOk1a.d.mts → validators-BFgj3O3w.d.mts} +5 -23
- package/dist/{validators-pv_b6bI_.d.ts → validators-C7i6EpQK.d.ts} +5 -23
- package/package.json +2 -10
- package/dist/chunk-3RG5ZIWI.js +0 -10
- package/dist/chunk-7WT53FJ4.js +0 -63
- package/dist/chunk-AGBBH7PL.mjs +0 -63
- package/dist/chunk-JBHONBEV.mjs +0 -19039
- package/dist/chunk-UVAA77R4.js +0 -19039
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
- package/dist/default-roles-5K3GHJTS.js +0 -23
- package/dist/default-roles-6D3HQ3DQ.mjs +0 -23
- package/dist/runtime-D7zd4qmo.d.mts +0 -12536
- package/dist/runtime-Di0FfOKV.d.ts +0 -12536
- package/dist/runtime.d.mts +0 -6
- package/dist/runtime.d.ts +0 -6
- package/dist/runtime.js +0 -319
- package/dist/runtime.mjs +0 -319
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
import { isValidIso3 } from "@stndrds/constants";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
|
+
// src/lib/lru-cache.ts
|
|
6
|
+
var LRUCache = class {
|
|
7
|
+
constructor(capacity) {
|
|
8
|
+
if (capacity <= 0) {
|
|
9
|
+
throw new Error("LRU cache capacity must be greater than 0");
|
|
10
|
+
}
|
|
11
|
+
this.capacity = capacity;
|
|
12
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
const value = this.cache.get(key);
|
|
16
|
+
if (value !== void 0) {
|
|
17
|
+
this.cache.delete(key);
|
|
18
|
+
this.cache.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
set(key, value) {
|
|
23
|
+
if (this.cache.has(key)) {
|
|
24
|
+
this.cache.delete(key);
|
|
25
|
+
} else if (this.cache.size >= this.capacity) {
|
|
26
|
+
const firstKey = this.cache.keys().next().value;
|
|
27
|
+
if (firstKey !== void 0) {
|
|
28
|
+
this.cache.delete(firstKey);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.cache.set(key, value);
|
|
32
|
+
}
|
|
33
|
+
has(key) {
|
|
34
|
+
return this.cache.has(key);
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.cache.clear();
|
|
38
|
+
}
|
|
39
|
+
get size() {
|
|
40
|
+
return this.cache.size;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
5
44
|
// src/phone-utils.ts
|
|
6
45
|
import { getCountryByIso3, stripTrunkPrefix } from "@stndrds/constants";
|
|
7
46
|
import { parsePhoneNumberFromString } from "libphonenumber-js";
|
|
@@ -81,7 +120,7 @@ function parseRawPhoneInput(rawInput, countryIso3) {
|
|
|
81
120
|
}
|
|
82
121
|
|
|
83
122
|
// src/validation/validators.ts
|
|
84
|
-
var regexPatternCache =
|
|
123
|
+
var regexPatternCache = new LRUCache(100);
|
|
85
124
|
function getCachedRegex(pattern) {
|
|
86
125
|
let cached = regexPatternCache.get(pattern);
|
|
87
126
|
if (!cached) {
|
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
var _constants = require('@stndrds/constants');
|
|
3
3
|
var _zod = require('zod');
|
|
4
4
|
|
|
5
|
+
// src/lib/lru-cache.ts
|
|
6
|
+
var LRUCache = class {
|
|
7
|
+
constructor(capacity) {
|
|
8
|
+
if (capacity <= 0) {
|
|
9
|
+
throw new Error("LRU cache capacity must be greater than 0");
|
|
10
|
+
}
|
|
11
|
+
this.capacity = capacity;
|
|
12
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
const value = this.cache.get(key);
|
|
16
|
+
if (value !== void 0) {
|
|
17
|
+
this.cache.delete(key);
|
|
18
|
+
this.cache.set(key, value);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
set(key, value) {
|
|
23
|
+
if (this.cache.has(key)) {
|
|
24
|
+
this.cache.delete(key);
|
|
25
|
+
} else if (this.cache.size >= this.capacity) {
|
|
26
|
+
const firstKey = this.cache.keys().next().value;
|
|
27
|
+
if (firstKey !== void 0) {
|
|
28
|
+
this.cache.delete(firstKey);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this.cache.set(key, value);
|
|
32
|
+
}
|
|
33
|
+
has(key) {
|
|
34
|
+
return this.cache.has(key);
|
|
35
|
+
}
|
|
36
|
+
clear() {
|
|
37
|
+
this.cache.clear();
|
|
38
|
+
}
|
|
39
|
+
get size() {
|
|
40
|
+
return this.cache.size;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
5
44
|
// src/phone-utils.ts
|
|
6
45
|
|
|
7
46
|
var _libphonenumberjs = require('libphonenumber-js');
|
|
@@ -81,7 +120,7 @@ function parseRawPhoneInput(rawInput, countryIso3) {
|
|
|
81
120
|
}
|
|
82
121
|
|
|
83
122
|
// src/validation/validators.ts
|
|
84
|
-
var regexPatternCache =
|
|
123
|
+
var regexPatternCache = new LRUCache(100);
|
|
85
124
|
function getCachedRegex(pattern) {
|
|
86
125
|
let cached = regexPatternCache.get(pattern);
|
|
87
126
|
if (!cached) {
|