@the-w1zard/types 1.0.2 → 1.0.3
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/package.json +1 -1
- package/src/hook-system.d.ts +12814 -0
- package/src/index.js +0 -141
- package/src/primitives.js +0 -102
package/src/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export * from './primitives';
|
|
2
|
-
export function MaybePromise(v) {
|
|
3
|
-
return v !== undefined || v != null ? v : Promise.resolve(v);
|
|
4
|
-
}
|
|
5
|
-
// TYPES
|
|
6
|
-
// #region ══════════════════════════════════════════════════════════════════════════════════════════════════════
|
|
7
|
-
// #region PRIMITIVE TYPES
|
|
8
|
-
const IncantationsConfig = (config) => config;
|
|
9
|
-
export const GRAPH_KEYS = ['types', 'enums', 'interfaces', 'generics'];
|
|
10
|
-
// #endregion ============================================
|
|
11
|
-
// #region TYPE GRAPH UTILITIES
|
|
12
|
-
// ============================================
|
|
13
|
-
// Helper to create primitive types
|
|
14
|
-
export function createPrimitiveGraph(type, options) {
|
|
15
|
-
return {
|
|
16
|
-
type,
|
|
17
|
-
kind: "primitive",
|
|
18
|
-
...options
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
// Helper to create object type
|
|
22
|
-
export function createObjectGraph(properties, options) {
|
|
23
|
-
return {
|
|
24
|
-
type: "Object",
|
|
25
|
-
kind: "composite",
|
|
26
|
-
properties,
|
|
27
|
-
...options
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
// Helper to create array type
|
|
31
|
-
export function createArrayGraph(elementType, options) {
|
|
32
|
-
return {
|
|
33
|
-
type: "Array",
|
|
34
|
-
kind: "composite",
|
|
35
|
-
elements: [elementType],
|
|
36
|
-
...options
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
// Helper to create union type
|
|
40
|
-
export function createUnionGraph(members, options) {
|
|
41
|
-
return {
|
|
42
|
-
type: "Union",
|
|
43
|
-
kind: "composite",
|
|
44
|
-
unionMembers: members,
|
|
45
|
-
...options
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
// Helper to create function type
|
|
49
|
-
export function createFunctionGraph(parameters, returnType, options) {
|
|
50
|
-
return {
|
|
51
|
-
type: "Function",
|
|
52
|
-
kind: "composite",
|
|
53
|
-
parameters,
|
|
54
|
-
returnType,
|
|
55
|
-
...options
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
// Helper to create generic type
|
|
59
|
-
export function createGenericGraph(name, typeParameters, constraint, options) {
|
|
60
|
-
return {
|
|
61
|
-
type: "Generic",
|
|
62
|
-
kind: "generic",
|
|
63
|
-
name,
|
|
64
|
-
typeParameters,
|
|
65
|
-
constraint,
|
|
66
|
-
...options
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
// #endregion ============================================
|
|
70
|
-
// #region EXAMPLE USAGE
|
|
71
|
-
// ============================================
|
|
72
|
-
// Example: Build a type graph for a config
|
|
73
|
-
const stringType = createPrimitiveGraph("String");
|
|
74
|
-
const numberType = createPrimitiveGraph("Number");
|
|
75
|
-
const booleanType = createPrimitiveGraph("Boolean");
|
|
76
|
-
const variantSchemaGraph = createObjectGraph({
|
|
77
|
-
size: createUnionGraph([
|
|
78
|
-
createPrimitiveGraph("String", { value: "small" }),
|
|
79
|
-
createPrimitiveGraph("String", { value: "large" })
|
|
80
|
-
]),
|
|
81
|
-
color: createUnionGraph([
|
|
82
|
-
createPrimitiveGraph("String", { value: "red" }),
|
|
83
|
-
createPrimitiveGraph("String", { value: "blue" })
|
|
84
|
-
])
|
|
85
|
-
});
|
|
86
|
-
const configGraph = {
|
|
87
|
-
type: "Interface",
|
|
88
|
-
kind: "composite",
|
|
89
|
-
name: "IncantationsConfig",
|
|
90
|
-
properties: {
|
|
91
|
-
variants: variantSchemaGraph,
|
|
92
|
-
defaultVariants: createObjectGraph({
|
|
93
|
-
size: createPrimitiveGraph("String", { defaultValue: "small" })
|
|
94
|
-
})
|
|
95
|
-
},
|
|
96
|
-
typeParameters: [
|
|
97
|
-
{
|
|
98
|
-
type: "TypeParameter",
|
|
99
|
-
name: "S",
|
|
100
|
-
constraint: createPrimitiveGraph("String")
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: "TypeParameter",
|
|
104
|
-
name: "V",
|
|
105
|
-
constraint: createPrimitiveGraph("Object")
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
};
|
|
109
|
-
export function chain(value) { return Promise.resolve(value); }
|
|
110
|
-
export class PlinkoDefinitionError extends Error {
|
|
111
|
-
errors;
|
|
112
|
-
warnings;
|
|
113
|
-
constructor(message, errors, warnings = []) {
|
|
114
|
-
super(message);
|
|
115
|
-
this.errors = errors;
|
|
116
|
-
this.warnings = warnings;
|
|
117
|
-
this.name = "PlinkoDefinitionError";
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
export class PlinkoTimeoutError extends Error {
|
|
121
|
-
nodeId;
|
|
122
|
-
timeoutMs;
|
|
123
|
-
constructor(nodeId, timeoutMs) {
|
|
124
|
-
super(`Plinko node "${nodeId}" timed out after ${timeoutMs}ms.`);
|
|
125
|
-
this.nodeId = nodeId;
|
|
126
|
-
this.timeoutMs = timeoutMs;
|
|
127
|
-
this.name = "PlinkoTimeoutError";
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
export class PlinkoTransitionLimitError extends Error {
|
|
131
|
-
graphId;
|
|
132
|
-
runId;
|
|
133
|
-
limit;
|
|
134
|
-
constructor(graphId, runId, limit) {
|
|
135
|
-
super(`Plinko graph "${graphId}" run "${runId}" exceeded maxTransitions (${limit}).`);
|
|
136
|
-
this.graphId = graphId;
|
|
137
|
-
this.runId = runId;
|
|
138
|
-
this.limit = limit;
|
|
139
|
-
this.name = "PlinkoTransitionLimitError";
|
|
140
|
-
}
|
|
141
|
-
}
|
package/src/primitives.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// #region PRIMITIVE TYPES
|
|
2
|
-
const IncantationsConfig = (config) => config;
|
|
3
|
-
// #endregion ============================================
|
|
4
|
-
// #region TYPE GRAPH UTILITIES
|
|
5
|
-
// ============================================
|
|
6
|
-
// Helper to create primitive types
|
|
7
|
-
export function createPrimitiveGraph(type, options) {
|
|
8
|
-
return {
|
|
9
|
-
type,
|
|
10
|
-
kind: "primitive",
|
|
11
|
-
...options
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
// Helper to create object type
|
|
15
|
-
export function createObjectGraph(properties, options) {
|
|
16
|
-
return {
|
|
17
|
-
type: "Object",
|
|
18
|
-
kind: "composite",
|
|
19
|
-
properties,
|
|
20
|
-
...options
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
// Helper to create array type
|
|
24
|
-
export function createArrayGraph(elementType, options) {
|
|
25
|
-
return {
|
|
26
|
-
type: "Array",
|
|
27
|
-
kind: "composite",
|
|
28
|
-
elements: [elementType],
|
|
29
|
-
...options
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
// Helper to create union type
|
|
33
|
-
export function createUnionGraph(members, options) {
|
|
34
|
-
return {
|
|
35
|
-
type: "Union",
|
|
36
|
-
kind: "composite",
|
|
37
|
-
unionMembers: members,
|
|
38
|
-
...options
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
// Helper to create function type
|
|
42
|
-
export function createFunctionGraph(parameters, returnType, options) {
|
|
43
|
-
return {
|
|
44
|
-
type: "Function",
|
|
45
|
-
kind: "composite",
|
|
46
|
-
parameters,
|
|
47
|
-
returnType,
|
|
48
|
-
...options
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// Helper to create generic type
|
|
52
|
-
export function createGenericGraph(name, typeParameters, constraint, options) {
|
|
53
|
-
return {
|
|
54
|
-
type: "Generic",
|
|
55
|
-
kind: "generic",
|
|
56
|
-
name,
|
|
57
|
-
typeParameters,
|
|
58
|
-
constraint,
|
|
59
|
-
...options
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
// #endregion ============================================
|
|
63
|
-
// #region EXAMPLE USAGE
|
|
64
|
-
// ============================================
|
|
65
|
-
// Example: Build a type graph for a config
|
|
66
|
-
const stringType = createPrimitiveGraph("String");
|
|
67
|
-
const numberType = createPrimitiveGraph("Number");
|
|
68
|
-
const booleanType = createPrimitiveGraph("Boolean");
|
|
69
|
-
const variantSchemaGraph = createObjectGraph({
|
|
70
|
-
size: createUnionGraph([
|
|
71
|
-
createPrimitiveGraph("String", { value: "small" }),
|
|
72
|
-
createPrimitiveGraph("String", { value: "large" })
|
|
73
|
-
]),
|
|
74
|
-
color: createUnionGraph([
|
|
75
|
-
createPrimitiveGraph("String", { value: "red" }),
|
|
76
|
-
createPrimitiveGraph("String", { value: "blue" })
|
|
77
|
-
])
|
|
78
|
-
});
|
|
79
|
-
const configGraph = {
|
|
80
|
-
type: "Interface",
|
|
81
|
-
kind: "composite",
|
|
82
|
-
name: "IncantationsConfig",
|
|
83
|
-
properties: {
|
|
84
|
-
variants: variantSchemaGraph,
|
|
85
|
-
defaultVariants: createObjectGraph({
|
|
86
|
-
size: createPrimitiveGraph("String", { defaultValue: "small" })
|
|
87
|
-
})
|
|
88
|
-
},
|
|
89
|
-
typeParameters: [
|
|
90
|
-
{
|
|
91
|
-
type: "TypeParameter",
|
|
92
|
-
name: "S",
|
|
93
|
-
constraint: createPrimitiveGraph("String")
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
type: "TypeParameter",
|
|
97
|
-
name: "V",
|
|
98
|
-
constraint: createPrimitiveGraph("Object")
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
};
|
|
102
|
-
// #endregion ============================================
|