pacc 4.40.3 → 4.40.5
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 +2 -2
- package/src/types.mjs +33 -17
- package/types/types.d.mts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "4.40.
|
|
3
|
+
"version": "4.40.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"typescript": "^5.9.3"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=22.
|
|
49
|
+
"node": ">=22.21.0"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
package/src/types.mjs
CHANGED
|
@@ -30,10 +30,23 @@ export const types = {
|
|
|
30
30
|
object: { name: "object" }
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
function error(message) {
|
|
34
34
|
throw new Error(message);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function raiseOnUnknownType(type, origin) {
|
|
38
|
+
switch (typeof type) {
|
|
39
|
+
case "string":
|
|
40
|
+
if (types[type]) {
|
|
41
|
+
return types[type];
|
|
42
|
+
}
|
|
43
|
+
case "undefined":
|
|
44
|
+
error(`Unknown type ${type} in '${origin}'`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return type;
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
export function addType(type) {
|
|
38
51
|
if (type.typeDefinition) {
|
|
39
52
|
const clazz = type;
|
|
@@ -63,29 +76,24 @@ export function addType(type) {
|
|
|
63
76
|
break;
|
|
64
77
|
|
|
65
78
|
case "string":
|
|
66
|
-
|
|
67
|
-
const ex = types[type.extends];
|
|
68
|
-
if (!ex) {
|
|
69
|
-
error(`${type.name}: missing type '${type.extends}'`);
|
|
70
|
-
}
|
|
71
|
-
type.extends = ex;
|
|
72
|
-
}
|
|
73
|
-
|
|
79
|
+
type.extends = raiseOnUnknownType(type.extends, type);
|
|
74
80
|
break;
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
if (!types[type.name]) {
|
|
84
|
+
types[type.name] = type;
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
for (const [path, attribute] of attributeIterator(type.attributes)) {
|
|
78
88
|
if (typeof attribute.type === "string") {
|
|
79
89
|
attribute.type = oneOfType(attribute.type);
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
if (types[type.name]) {
|
|
93
|
+
if (types[type.name] !== type) {
|
|
84
94
|
return Object.assign(types[type.name], type);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
types[type.name] = type;
|
|
88
|
-
|
|
89
97
|
return type;
|
|
90
98
|
}
|
|
91
99
|
|
|
@@ -95,11 +103,7 @@ export function oneOfType(definition) {
|
|
|
95
103
|
name,
|
|
96
104
|
members: list.reduce((all, type) => {
|
|
97
105
|
if (typeof type === "string") {
|
|
98
|
-
|
|
99
|
-
if (!t) {
|
|
100
|
-
error(`Unknown type ${type} in '${definition}'`);
|
|
101
|
-
}
|
|
102
|
-
type = t;
|
|
106
|
+
type = raiseOnUnknownType(type, definition);
|
|
103
107
|
}
|
|
104
108
|
return all.union(type.members ?? new Set([type]));
|
|
105
109
|
}, new Set())
|
|
@@ -124,3 +128,15 @@ export function oneOfType(definition) {
|
|
|
124
128
|
return aggregate(parts.join("|"), parts);
|
|
125
129
|
}
|
|
126
130
|
}
|
|
131
|
+
|
|
132
|
+
export function resolveTypeLinks() {
|
|
133
|
+
for (const type of Object.values(types)) {
|
|
134
|
+
if (typeof type.extends === "string") {
|
|
135
|
+
type.extends = raiseOnUnknownType(type.extends, type);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (type.owners) {
|
|
139
|
+
type.owners = type.owners.map(owner => raiseOnUnknownType(owner, type));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|