@palantir/pack.document-schema.model-types 0.2.1 → 0.3.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/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-transpileBrowser.log +2 -1
- package/.turbo/turbo-transpileCjs.log +2 -1
- package/.turbo/turbo-transpileEsm.log +2 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +28 -0
- package/build/browser/index.js +20 -5
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +20 -4
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +96 -35
- package/build/esm/index.js +20 -5
- package/build/esm/index.js.map +1 -1
- package/build/types/index.d.ts +4 -4
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types/ActivityEvent.d.ts +42 -1
- package/build/types/types/ActivityEvent.d.ts.map +1 -1
- package/build/types/types/DocumentMetadata.d.ts +18 -12
- package/build/types/types/DocumentMetadata.d.ts.map +1 -1
- package/build/types/types/Metadata.d.ts +3 -1
- package/build/types/types/Metadata.d.ts.map +1 -1
- package/build/types/types/Model.d.ts +23 -3
- package/build/types/types/Model.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +16 -2
- package/src/types/ActivityEvent.ts +51 -2
- package/src/types/DocumentMetadata.ts +21 -12
- package/src/types/Metadata.ts +23 -2
- package/src/types/Model.ts +31 -4
package/src/types/Model.ts
CHANGED
|
@@ -23,13 +23,27 @@ import type { WithMetadata } from "./Metadata.js";
|
|
|
23
23
|
* It includes a zod schema for validation and type information.
|
|
24
24
|
*/
|
|
25
25
|
// TODO: I think we can/should hide the zod types
|
|
26
|
-
export interface Model<
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export interface Model<
|
|
27
|
+
T = unknown,
|
|
28
|
+
Z extends ZodType<T> = ZodType<T>,
|
|
29
|
+
M extends ModelMetadata<T> = ModelMetadata<T>,
|
|
30
|
+
> extends WithMetadata<M> {
|
|
29
31
|
readonly __type: T;
|
|
30
32
|
readonly zodSchema: Readonly<Z>;
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
export type RecordModel<T = unknown, Z extends ZodType<T> = ZodType<T>> = Model<
|
|
36
|
+
T,
|
|
37
|
+
Z,
|
|
38
|
+
RecordModelMetadata<T>
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
export type UnionModel<T = unknown, Z extends ZodType<T> = ZodType<T>> = Model<
|
|
42
|
+
T,
|
|
43
|
+
Z,
|
|
44
|
+
UnionModelMetadata<T>
|
|
45
|
+
>;
|
|
46
|
+
|
|
33
47
|
export type ModelData<M extends Model> = M["__type"];
|
|
34
48
|
|
|
35
49
|
/**
|
|
@@ -49,7 +63,7 @@ export const ExternalRefType = {
|
|
|
49
63
|
|
|
50
64
|
export type ExternalRefType = typeof ExternalRefType[keyof typeof ExternalRefType];
|
|
51
65
|
|
|
52
|
-
export interface
|
|
66
|
+
export interface RecordModelMetadata<T = unknown> {
|
|
53
67
|
/**
|
|
54
68
|
* Which fields in the model are external references (e.g. UserRef, DocumentRef, etc).
|
|
55
69
|
*/
|
|
@@ -59,3 +73,16 @@ export interface ModelMetadata<T = unknown> {
|
|
|
59
73
|
*/
|
|
60
74
|
readonly name: string;
|
|
61
75
|
}
|
|
76
|
+
|
|
77
|
+
export interface UnionModelMetadata<T = unknown> {
|
|
78
|
+
/**
|
|
79
|
+
* The field name used to discriminate between union variants.
|
|
80
|
+
*/
|
|
81
|
+
readonly discriminant: keyof T;
|
|
82
|
+
/**
|
|
83
|
+
* The name of the model (should match the typescript symbol).
|
|
84
|
+
*/
|
|
85
|
+
readonly name: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type ModelMetadata<T = unknown> = RecordModelMetadata<T> | UnionModelMetadata<T>;
|