pacc 4.40.5 → 4.41.1
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 +3 -3
- package/src/types.mjs +22 -6
- package/types/types.d.mts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.41.1",
|
|
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.44",
|
|
43
43
|
"c8": "^10.1.3",
|
|
44
44
|
"documentation": "^14.0.3",
|
|
45
45
|
"semantic-release": "^25.0.1",
|
|
46
46
|
"typescript": "^5.9.3"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=24.11.0"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
package/src/types.mjs
CHANGED
|
@@ -26,6 +26,12 @@ export const types = {
|
|
|
26
26
|
primitive: true,
|
|
27
27
|
prepareValue: value => (typeof value === "string" ? parseInt(value) : value)
|
|
28
28
|
},
|
|
29
|
+
duration: {
|
|
30
|
+
name: "duration",
|
|
31
|
+
primitive: true,
|
|
32
|
+
prepareValue: value =>
|
|
33
|
+
typeof value === "string" ? parseFloat(value) : value
|
|
34
|
+
},
|
|
29
35
|
url: { name: "url", primitive: true },
|
|
30
36
|
object: { name: "object" }
|
|
31
37
|
};
|
|
@@ -84,12 +90,6 @@ export function addType(type) {
|
|
|
84
90
|
types[type.name] = type;
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
for (const [path, attribute] of attributeIterator(type.attributes)) {
|
|
88
|
-
if (typeof attribute.type === "string") {
|
|
89
|
-
attribute.type = oneOfType(attribute.type);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
93
|
if (types[type.name] !== type) {
|
|
94
94
|
return Object.assign(types[type.name], type);
|
|
95
95
|
}
|
|
@@ -138,5 +138,21 @@ export function resolveTypeLinks() {
|
|
|
138
138
|
if (type.owners) {
|
|
139
139
|
type.owners = type.owners.map(owner => raiseOnUnknownType(owner, type));
|
|
140
140
|
}
|
|
141
|
+
|
|
142
|
+
for (const [path, attribute] of attributeIterator(type.attributes)) {
|
|
143
|
+
if (typeof attribute.type === "string") {
|
|
144
|
+
attribute.type = oneOfType(attribute.type);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
141
147
|
}
|
|
142
148
|
}
|
|
149
|
+
|
|
150
|
+
export function typeFactory(type, owner, data) {
|
|
151
|
+
const factory = type.factoryFor?.(owner, data) || type.clazz;
|
|
152
|
+
//console.log(factory, type, owner, data);
|
|
153
|
+
const object = new factory(owner);
|
|
154
|
+
|
|
155
|
+
object.read(data);
|
|
156
|
+
owner.addObject(object);
|
|
157
|
+
return object;
|
|
158
|
+
}
|
package/types/types.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export function addType(type: any): any;
|
|
2
2
|
export function oneOfType(definition: any): any;
|
|
3
3
|
export function resolveTypeLinks(): void;
|
|
4
|
+
export function typeFactory(type: any, owner: any, data: any): any;
|
|
4
5
|
export const types: {
|
|
5
6
|
string: {
|
|
6
7
|
name: string;
|
|
@@ -26,6 +27,11 @@ export const types: {
|
|
|
26
27
|
primitive: boolean;
|
|
27
28
|
prepareValue: (value: any) => any;
|
|
28
29
|
};
|
|
30
|
+
duration: {
|
|
31
|
+
name: string;
|
|
32
|
+
primitive: boolean;
|
|
33
|
+
prepareValue: (value: any) => any;
|
|
34
|
+
};
|
|
29
35
|
url: {
|
|
30
36
|
name: string;
|
|
31
37
|
primitive: boolean;
|