pacc 4.40.2 → 4.40.4
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 +4 -4
- package/src/types.mjs +37 -15
- 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.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"ava": "^6.4.1",
|
|
42
|
-
"browser-ava": "^2.3.
|
|
42
|
+
"browser-ava": "^2.3.43",
|
|
43
43
|
"c8": "^10.1.3",
|
|
44
44
|
"documentation": "^14.0.3",
|
|
45
|
-
"semantic-release": "^25.0.
|
|
45
|
+
"semantic-release": "^25.0.1",
|
|
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;
|
|
@@ -46,6 +59,10 @@ export function addType(type) {
|
|
|
46
59
|
}
|
|
47
60
|
}
|
|
48
61
|
|
|
62
|
+
if (type.specializationOf) {
|
|
63
|
+
type.specializationOf.specializations[type.name] = type;
|
|
64
|
+
}
|
|
65
|
+
|
|
49
66
|
if (!type.owners) {
|
|
50
67
|
type.owners = [];
|
|
51
68
|
}
|
|
@@ -60,28 +77,25 @@ export function addType(type) {
|
|
|
60
77
|
|
|
61
78
|
case "string":
|
|
62
79
|
if (typeof type.extends === "string") {
|
|
63
|
-
|
|
64
|
-
if (!ex) {
|
|
65
|
-
error(`${type.name}: missing type '${type.extends}'`);
|
|
66
|
-
}
|
|
67
|
-
type.extends = ex;
|
|
80
|
+
type.extends = raiseOnUnknownType(type.extends, type);
|
|
68
81
|
}
|
|
69
|
-
|
|
70
82
|
break;
|
|
71
83
|
}
|
|
72
84
|
|
|
85
|
+
if (!types[type.name]) {
|
|
86
|
+
types[type.name] = type;
|
|
87
|
+
}
|
|
88
|
+
|
|
73
89
|
for (const [path, attribute] of attributeIterator(type.attributes)) {
|
|
74
90
|
if (typeof attribute.type === "string") {
|
|
75
91
|
attribute.type = oneOfType(attribute.type);
|
|
76
92
|
}
|
|
77
93
|
}
|
|
78
94
|
|
|
79
|
-
if (types[type.name]) {
|
|
95
|
+
if (types[type.name] !== type) {
|
|
80
96
|
return Object.assign(types[type.name], type);
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
types[type.name] = type;
|
|
84
|
-
|
|
85
99
|
return type;
|
|
86
100
|
}
|
|
87
101
|
|
|
@@ -91,11 +105,7 @@ export function oneOfType(definition) {
|
|
|
91
105
|
name,
|
|
92
106
|
members: list.reduce((all, type) => {
|
|
93
107
|
if (typeof type === "string") {
|
|
94
|
-
|
|
95
|
-
if (!t) {
|
|
96
|
-
error(`Unknown type ${type} in '${definition}'`);
|
|
97
|
-
}
|
|
98
|
-
type = t;
|
|
108
|
+
type = raiseOnUnknownType(type, definition); // addType({ name: type });
|
|
99
109
|
}
|
|
100
110
|
return all.union(type.members ?? new Set([type]));
|
|
101
111
|
}, new Set())
|
|
@@ -120,3 +130,15 @@ export function oneOfType(definition) {
|
|
|
120
130
|
return aggregate(parts.join("|"), parts);
|
|
121
131
|
}
|
|
122
132
|
}
|
|
133
|
+
|
|
134
|
+
export function resolveTypeLinks() {
|
|
135
|
+
for (const type of Object.values(types)) {
|
|
136
|
+
if (typeof type.extends === "string") {
|
|
137
|
+
type.extends = raiseOnUnknownType(type.extends, type);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (type.owners) {
|
|
141
|
+
type.owners = type.owners.map(owner => raiseOnUnknownType(owner, type));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|