@xylabs/object-model 5.0.7 → 5.0.9
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/neutral/AnyObject.d.ts +2 -1
- package/dist/neutral/EmptyObject.d.ts +7 -0
- package/dist/neutral/index.d.ts +1 -0
- package/package.json +7 -7
- package/src/AnyObject.ts +3 -1
- package/src/EmptyObject.ts +29 -0
- package/src/index.ts +1 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TypedKey } from '@xylabs/typeof';
|
|
2
|
+
import type { EmptyObject } from './EmptyObject.ts';
|
|
2
3
|
/**
|
|
3
4
|
* Any object, which means that it does not enforce the set of fields that it has. Extending from AnyObject
|
|
4
5
|
* will result in a type that includes the universal set of field names
|
|
5
6
|
*/
|
|
6
|
-
export type AnyObject = Record<TypedKey, unknown
|
|
7
|
+
export type AnyObject = EmptyObject & Partial<Record<TypedKey, unknown>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An empty object, which means that it does enforce the set of field names, defaulting to an empty set until
|
|
3
|
+
* extended from, which then adds only those additional fields
|
|
4
|
+
*/
|
|
5
|
+
export type EmptyObject<T extends object = object> = Exclude<{
|
|
6
|
+
[K in keyof T]?: never;
|
|
7
|
+
}, unknown[] | ((...args: unknown[]) => unknown) | null>;
|
package/dist/neutral/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/object-model",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"src"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@xylabs/assert": "~5.0.
|
|
39
|
-
"@xylabs/logger": "~5.0.
|
|
40
|
-
"@xylabs/promise": "~5.0.
|
|
41
|
-
"@xylabs/typeof": "~5.0.
|
|
38
|
+
"@xylabs/assert": "~5.0.9",
|
|
39
|
+
"@xylabs/logger": "~5.0.9",
|
|
40
|
+
"@xylabs/promise": "~5.0.9",
|
|
41
|
+
"@xylabs/typeof": "~5.0.9"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@xylabs/ts-scripts-yarn3": "~7.1.
|
|
45
|
-
"@xylabs/tsconfig": "~7.1.
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.1",
|
|
45
|
+
"@xylabs/tsconfig": "~7.1.1",
|
|
46
46
|
"typescript": "~5.9.2",
|
|
47
47
|
"vitest": "~3.2.4"
|
|
48
48
|
},
|
package/src/AnyObject.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { TypedKey } from '@xylabs/typeof'
|
|
2
2
|
|
|
3
|
+
import type { EmptyObject } from './EmptyObject.ts'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Any object, which means that it does not enforce the set of fields that it has. Extending from AnyObject
|
|
5
7
|
* will result in a type that includes the universal set of field names
|
|
6
8
|
*/
|
|
7
|
-
export type AnyObject = Record<TypedKey, unknown
|
|
9
|
+
export type AnyObject = EmptyObject & Partial<Record<TypedKey, unknown>>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An empty object, which means that it does enforce the set of field names, defaulting to an empty set until
|
|
3
|
+
* extended from, which then adds only those additional fields
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type EmptyObject<T extends object = object> = Exclude<{ [K in keyof T]?: never }, unknown[] | ((...args: unknown[]) => unknown) | null>
|
|
7
|
+
|
|
8
|
+
/* export type EmptyObjectExperimental = Exclude<
|
|
9
|
+
|
|
10
|
+
Record<TypedKey, unknown>,
|
|
11
|
+
unknown[] | ((...args: unknown[]) => unknown) | null
|
|
12
|
+
> */
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
const foo: EmptyObjectExperimental = {}
|
|
16
|
+
const bar: EmptyObjectExperimental = []
|
|
17
|
+
const baz: EmptyObjectExperimental = () => null
|
|
18
|
+
const qux: EmptyObjectExperimental = null
|
|
19
|
+
|
|
20
|
+
type x = EmptyObjectExperimental & { test: boolean }
|
|
21
|
+
|
|
22
|
+
const y: x = { test: true, arie: 1 }
|
|
23
|
+
|
|
24
|
+
export type AnyObject = EmptyObjectExperimental & Partial<Record<TypedKey, unknown>>
|
|
25
|
+
|
|
26
|
+
export abstract class ValidatorBase<T extends EmptyObjectExperimental = AnyObject> {
|
|
27
|
+
abstract validate(payload: T): Promise<Error[]>
|
|
28
|
+
}
|
|
29
|
+
*/
|