@stndrds/schema 1.0.0-alpha.233 → 1.0.0-alpha.235
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-FRWPIJDK.mjs → chunk-NAS2HJ3Y.mjs} +3 -3
- package/dist/{chunk-6SPNZSXS.js → chunk-PZJN5IJW.js} +4 -4
- package/dist/{chunk-SGSGREPG.js → chunk-QAF3HNKQ.js} +9 -8
- package/dist/{chunk-NOMHDOVE.mjs → chunk-U36ZIBEM.mjs} +9 -8
- package/dist/index.d.mts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +199 -150
- package/dist/index.mjs +132 -83
- package/dist/validation/all.js +9 -9
- package/dist/validation/all.mjs +2 -2
- package/dist/validation/object/index.js +15 -15
- package/dist/validation/object/index.mjs +2 -2
- package/dist/validation/primitives/text.js +2 -2
- package/dist/validation/primitives/text.mjs +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createCheckboxValidator } from './chunk-OSSGN43B.mjs';
|
|
2
2
|
import { createDateValidator } from './chunk-Q44QKLN4.mjs';
|
|
3
3
|
import { createNumberValidator } from './chunk-UANQJ2GH.mjs';
|
|
4
|
-
import { createTextValidator } from './chunk-
|
|
4
|
+
import { createTextValidator } from './chunk-U36ZIBEM.mjs';
|
|
5
5
|
import { createRichtextValidator } from './chunk-QVLQPW3O.mjs';
|
|
6
6
|
import { createMultiselectValidator, createSelectValidator, createStatusValidator } from './chunk-ZDQ5AP26.mjs';
|
|
7
7
|
import { createUserValidator } from './chunk-LV3FEUKU.mjs';
|
|
@@ -243,8 +243,8 @@ var SchemaError = class extends Error {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
var NotFoundError = class extends SchemaError {
|
|
246
|
-
constructor(resourceType, resourceId, code = SchemaErrorCode.RECORD_NOT_FOUND) {
|
|
247
|
-
super(
|
|
246
|
+
constructor(resourceType, resourceId, code = SchemaErrorCode.RECORD_NOT_FOUND, message = `${resourceType} with id "${resourceId}" not found`) {
|
|
247
|
+
super(message, code, {
|
|
248
248
|
resourceType,
|
|
249
249
|
resourceId
|
|
250
250
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chunk5WATIVCA_js = require('./chunk-5WATIVCA.js');
|
|
4
4
|
var chunkSI34M4IC_js = require('./chunk-SI34M4IC.js');
|
|
5
5
|
var chunkYIP5FJ5H_js = require('./chunk-YIP5FJ5H.js');
|
|
6
|
-
var
|
|
6
|
+
var chunkQAF3HNKQ_js = require('./chunk-QAF3HNKQ.js');
|
|
7
7
|
var chunkEW5XR2X3_js = require('./chunk-EW5XR2X3.js');
|
|
8
8
|
var chunkQWKLQRBX_js = require('./chunk-QWKLQRBX.js');
|
|
9
9
|
var chunkKNGWHQLR_js = require('./chunk-KNGWHQLR.js');
|
|
@@ -36,7 +36,7 @@ function withEmptyToNull(validator) {
|
|
|
36
36
|
function createAttributeValidator(attr, messages = chunkYKWSHBT5_js.DEFAULT_VALIDATION_MESSAGES) {
|
|
37
37
|
switch (attr.type) {
|
|
38
38
|
case "text":
|
|
39
|
-
return
|
|
39
|
+
return chunkQAF3HNKQ_js.createTextValidator(attr, messages);
|
|
40
40
|
case "richtext":
|
|
41
41
|
return chunkEW5XR2X3_js.createRichtextValidator(attr, messages);
|
|
42
42
|
case "number":
|
|
@@ -245,8 +245,8 @@ var SchemaError = class extends Error {
|
|
|
245
245
|
}
|
|
246
246
|
};
|
|
247
247
|
var NotFoundError = class extends SchemaError {
|
|
248
|
-
constructor(resourceType, resourceId, code = SchemaErrorCode.RECORD_NOT_FOUND) {
|
|
249
|
-
super(
|
|
248
|
+
constructor(resourceType, resourceId, code = SchemaErrorCode.RECORD_NOT_FOUND, message = `${resourceType} with id "${resourceId}" not found`) {
|
|
249
|
+
super(message, code, {
|
|
250
250
|
resourceType,
|
|
251
251
|
resourceId
|
|
252
252
|
});
|
|
@@ -6,27 +6,28 @@ var zod = require('zod');
|
|
|
6
6
|
// src/lib/lru-cache.ts
|
|
7
7
|
var LRUCache = class {
|
|
8
8
|
constructor(capacity) {
|
|
9
|
-
if (capacity <= 0) {
|
|
9
|
+
if (!Number.isInteger(capacity) || capacity <= 0) {
|
|
10
10
|
throw new Error("LRU cache capacity must be greater than 0");
|
|
11
11
|
}
|
|
12
12
|
this.capacity = capacity;
|
|
13
13
|
this.cache = /* @__PURE__ */ new Map();
|
|
14
14
|
}
|
|
15
15
|
get(key) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.cache.delete(key);
|
|
19
|
-
this.cache.set(key, value);
|
|
16
|
+
if (!this.cache.has(key)) {
|
|
17
|
+
return void 0;
|
|
20
18
|
}
|
|
19
|
+
const value = this.cache.get(key);
|
|
20
|
+
this.cache.delete(key);
|
|
21
|
+
this.cache.set(key, value);
|
|
21
22
|
return value;
|
|
22
23
|
}
|
|
23
24
|
set(key, value) {
|
|
24
25
|
if (this.cache.has(key)) {
|
|
25
26
|
this.cache.delete(key);
|
|
26
27
|
} else if (this.cache.size >= this.capacity) {
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
this.cache.delete(
|
|
28
|
+
const first = this.cache.keys().next();
|
|
29
|
+
if (!first.done) {
|
|
30
|
+
this.cache.delete(first.value);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
this.cache.set(key, value);
|
|
@@ -4,27 +4,28 @@ import { z } from 'zod';
|
|
|
4
4
|
// src/lib/lru-cache.ts
|
|
5
5
|
var LRUCache = class {
|
|
6
6
|
constructor(capacity) {
|
|
7
|
-
if (capacity <= 0) {
|
|
7
|
+
if (!Number.isInteger(capacity) || capacity <= 0) {
|
|
8
8
|
throw new Error("LRU cache capacity must be greater than 0");
|
|
9
9
|
}
|
|
10
10
|
this.capacity = capacity;
|
|
11
11
|
this.cache = /* @__PURE__ */ new Map();
|
|
12
12
|
}
|
|
13
13
|
get(key) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.cache.delete(key);
|
|
17
|
-
this.cache.set(key, value);
|
|
14
|
+
if (!this.cache.has(key)) {
|
|
15
|
+
return void 0;
|
|
18
16
|
}
|
|
17
|
+
const value = this.cache.get(key);
|
|
18
|
+
this.cache.delete(key);
|
|
19
|
+
this.cache.set(key, value);
|
|
19
20
|
return value;
|
|
20
21
|
}
|
|
21
22
|
set(key, value) {
|
|
22
23
|
if (this.cache.has(key)) {
|
|
23
24
|
this.cache.delete(key);
|
|
24
25
|
} else if (this.cache.size >= this.capacity) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
this.cache.delete(
|
|
26
|
+
const first = this.cache.keys().next();
|
|
27
|
+
if (!first.done) {
|
|
28
|
+
this.cache.delete(first.value);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
this.cache.set(key, value);
|
package/dist/index.d.mts
CHANGED
|
@@ -2773,7 +2773,7 @@ declare class SchemaError extends Error {
|
|
|
2773
2773
|
declare class NotFoundError extends SchemaError {
|
|
2774
2774
|
readonly resourceType: string;
|
|
2775
2775
|
readonly resourceId: string;
|
|
2776
|
-
constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode);
|
|
2776
|
+
constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode, message?: string);
|
|
2777
2777
|
}
|
|
2778
2778
|
/**
|
|
2779
2779
|
* Object not found error
|
|
@@ -7075,7 +7075,7 @@ declare class FlagRegistry {
|
|
|
7075
7075
|
* Register a feature flag definition.
|
|
7076
7076
|
*
|
|
7077
7077
|
* @param flag - The flag definition to register
|
|
7078
|
-
* @throws
|
|
7078
|
+
* @throws DuplicateError If a flag with the same name is already registered
|
|
7079
7079
|
*
|
|
7080
7080
|
* @example
|
|
7081
7081
|
* ```typescript
|
|
@@ -7091,7 +7091,7 @@ declare class FlagRegistry {
|
|
|
7091
7091
|
* This operation is atomic - either all flags are registered or none are.
|
|
7092
7092
|
*
|
|
7093
7093
|
* @param flags - Array of flag definitions to register
|
|
7094
|
-
* @throws
|
|
7094
|
+
* @throws DuplicateError If any flag name conflicts with existing or duplicate within batch
|
|
7095
7095
|
*/
|
|
7096
7096
|
registerAll(flags: FeatureFlagDefinition[]): void;
|
|
7097
7097
|
/**
|
|
@@ -7106,7 +7106,7 @@ declare class FlagRegistry {
|
|
|
7106
7106
|
*
|
|
7107
7107
|
* @param name - The flag name
|
|
7108
7108
|
* @returns The flag definition
|
|
7109
|
-
* @throws
|
|
7109
|
+
* @throws NotFoundError If the flag is not registered
|
|
7110
7110
|
*/
|
|
7111
7111
|
getOrThrow<T = unknown>(name: string): FeatureFlagDefinition<T>;
|
|
7112
7112
|
/**
|
|
@@ -7314,7 +7314,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7314
7314
|
* Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
|
|
7315
7315
|
* @param objects - Single object/builder or array of objects/builders to register
|
|
7316
7316
|
* @returns this (for chaining)
|
|
7317
|
-
* @throws
|
|
7317
|
+
* @throws SchemaError if object is invalid or already registered
|
|
7318
7318
|
*
|
|
7319
7319
|
* @example
|
|
7320
7320
|
* ```typescript
|
|
@@ -7360,7 +7360,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7360
7360
|
* Get a native object or throw if not found
|
|
7361
7361
|
* @param name - The object name
|
|
7362
7362
|
* @returns The object definition
|
|
7363
|
-
* @throws
|
|
7363
|
+
* @throws NotFoundError if not found
|
|
7364
7364
|
*/
|
|
7365
7365
|
getByNameOrThrow(name: string): ObjectDefinition;
|
|
7366
7366
|
/**
|
|
@@ -7393,9 +7393,9 @@ declare class NativeObjectRegistryClass {
|
|
|
7393
7393
|
*/
|
|
7394
7394
|
summary(): string;
|
|
7395
7395
|
/**
|
|
7396
|
-
*
|
|
7396
|
+
* Return registry summary and optionally pass it to a debug writer.
|
|
7397
7397
|
*/
|
|
7398
|
-
debug():
|
|
7398
|
+
debug(write?: (message: string) => void): string;
|
|
7399
7399
|
}
|
|
7400
7400
|
/**
|
|
7401
7401
|
* Singleton instance of the registry
|
|
@@ -7415,7 +7415,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7415
7415
|
* console.log(registry.listNames()); // ["products", "orders", ...]
|
|
7416
7416
|
*
|
|
7417
7417
|
* // Debug
|
|
7418
|
-
* registry.debug();
|
|
7418
|
+
* registry.debug((summary) => logger.info(summary));
|
|
7419
7419
|
* ```
|
|
7420
7420
|
*/
|
|
7421
7421
|
declare const registry: NativeObjectRegistryClass;
|
|
@@ -7510,9 +7510,9 @@ declare class ViewRegistry {
|
|
|
7510
7510
|
*/
|
|
7511
7511
|
summary(): string;
|
|
7512
7512
|
/**
|
|
7513
|
-
*
|
|
7513
|
+
* Return summary and optionally pass it to a debug writer.
|
|
7514
7514
|
*/
|
|
7515
|
-
debug():
|
|
7515
|
+
debug(write?: (message: string) => void): string;
|
|
7516
7516
|
private makeKey;
|
|
7517
7517
|
}
|
|
7518
7518
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2773,7 +2773,7 @@ declare class SchemaError extends Error {
|
|
|
2773
2773
|
declare class NotFoundError extends SchemaError {
|
|
2774
2774
|
readonly resourceType: string;
|
|
2775
2775
|
readonly resourceId: string;
|
|
2776
|
-
constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode);
|
|
2776
|
+
constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode, message?: string);
|
|
2777
2777
|
}
|
|
2778
2778
|
/**
|
|
2779
2779
|
* Object not found error
|
|
@@ -7075,7 +7075,7 @@ declare class FlagRegistry {
|
|
|
7075
7075
|
* Register a feature flag definition.
|
|
7076
7076
|
*
|
|
7077
7077
|
* @param flag - The flag definition to register
|
|
7078
|
-
* @throws
|
|
7078
|
+
* @throws DuplicateError If a flag with the same name is already registered
|
|
7079
7079
|
*
|
|
7080
7080
|
* @example
|
|
7081
7081
|
* ```typescript
|
|
@@ -7091,7 +7091,7 @@ declare class FlagRegistry {
|
|
|
7091
7091
|
* This operation is atomic - either all flags are registered or none are.
|
|
7092
7092
|
*
|
|
7093
7093
|
* @param flags - Array of flag definitions to register
|
|
7094
|
-
* @throws
|
|
7094
|
+
* @throws DuplicateError If any flag name conflicts with existing or duplicate within batch
|
|
7095
7095
|
*/
|
|
7096
7096
|
registerAll(flags: FeatureFlagDefinition[]): void;
|
|
7097
7097
|
/**
|
|
@@ -7106,7 +7106,7 @@ declare class FlagRegistry {
|
|
|
7106
7106
|
*
|
|
7107
7107
|
* @param name - The flag name
|
|
7108
7108
|
* @returns The flag definition
|
|
7109
|
-
* @throws
|
|
7109
|
+
* @throws NotFoundError If the flag is not registered
|
|
7110
7110
|
*/
|
|
7111
7111
|
getOrThrow<T = unknown>(name: string): FeatureFlagDefinition<T>;
|
|
7112
7112
|
/**
|
|
@@ -7314,7 +7314,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7314
7314
|
* Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
|
|
7315
7315
|
* @param objects - Single object/builder or array of objects/builders to register
|
|
7316
7316
|
* @returns this (for chaining)
|
|
7317
|
-
* @throws
|
|
7317
|
+
* @throws SchemaError if object is invalid or already registered
|
|
7318
7318
|
*
|
|
7319
7319
|
* @example
|
|
7320
7320
|
* ```typescript
|
|
@@ -7360,7 +7360,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7360
7360
|
* Get a native object or throw if not found
|
|
7361
7361
|
* @param name - The object name
|
|
7362
7362
|
* @returns The object definition
|
|
7363
|
-
* @throws
|
|
7363
|
+
* @throws NotFoundError if not found
|
|
7364
7364
|
*/
|
|
7365
7365
|
getByNameOrThrow(name: string): ObjectDefinition;
|
|
7366
7366
|
/**
|
|
@@ -7393,9 +7393,9 @@ declare class NativeObjectRegistryClass {
|
|
|
7393
7393
|
*/
|
|
7394
7394
|
summary(): string;
|
|
7395
7395
|
/**
|
|
7396
|
-
*
|
|
7396
|
+
* Return registry summary and optionally pass it to a debug writer.
|
|
7397
7397
|
*/
|
|
7398
|
-
debug():
|
|
7398
|
+
debug(write?: (message: string) => void): string;
|
|
7399
7399
|
}
|
|
7400
7400
|
/**
|
|
7401
7401
|
* Singleton instance of the registry
|
|
@@ -7415,7 +7415,7 @@ declare class NativeObjectRegistryClass {
|
|
|
7415
7415
|
* console.log(registry.listNames()); // ["products", "orders", ...]
|
|
7416
7416
|
*
|
|
7417
7417
|
* // Debug
|
|
7418
|
-
* registry.debug();
|
|
7418
|
+
* registry.debug((summary) => logger.info(summary));
|
|
7419
7419
|
* ```
|
|
7420
7420
|
*/
|
|
7421
7421
|
declare const registry: NativeObjectRegistryClass;
|
|
@@ -7510,9 +7510,9 @@ declare class ViewRegistry {
|
|
|
7510
7510
|
*/
|
|
7511
7511
|
summary(): string;
|
|
7512
7512
|
/**
|
|
7513
|
-
*
|
|
7513
|
+
* Return summary and optionally pass it to a debug writer.
|
|
7514
7514
|
*/
|
|
7515
|
-
debug():
|
|
7515
|
+
debug(write?: (message: string) => void): string;
|
|
7516
7516
|
private makeKey;
|
|
7517
7517
|
}
|
|
7518
7518
|
/**
|