@kubun/protocol 0.3.6 → 0.3.8
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/lib/models/cluster.d.ts.map +1 -1
- package/lib/models/cluster.js +28 -6
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cluster.d.ts","sourceRoot":"","sources":["../../src/models/cluster.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,KAAK,UAAU,EAAe,MAAM,gBAAgB,CAAA;AAC1F,OAAO,EAAE,eAAe,EAAyD,MAAM,WAAW,CAAA;AAElG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAElB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAG1B,MAAM,eAAe,CAAA;AAUtB,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;AAEtE,MAAM,MAAM,gBAAgB,GAAG,IAAI,CACjC,aAAa,EACb,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,YAAY,CAChE,GAAG;IACF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,qBAAqB,CAAA;IAChC,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,kBAAkB,CAAA;CAChC,CAAA;AAED,KAAK,gBAAgB,GACjB,UAAU,CAAC,OAAO,GAClB,UAAU,CAAC,OAAO,GAClB,UAAU,CAAC,MAAM,GACjB,UAAU,CAAC,MAAM,CAAA;AACrB,KAAK,eAAe,GAAG,UAAU,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAA;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AM,CAAC,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,eAAe,CAAC;CAOhE"}
|
package/lib/models/cluster.js
CHANGED
|
@@ -43,10 +43,17 @@ function resolveReference(root, ref) {
|
|
|
43
43
|
}
|
|
44
44
|
function addScalar(refs, schema) {
|
|
45
45
|
const id = ScalarModelID.create(schema);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
title:
|
|
49
|
-
|
|
46
|
+
let normalizedSchema = schema;
|
|
47
|
+
if (schema.type === 'boolean') {
|
|
48
|
+
const { title: _, ...rest } = schema;
|
|
49
|
+
normalizedSchema = rest;
|
|
50
|
+
} else if (schema.title != null) {
|
|
51
|
+
normalizedSchema = {
|
|
52
|
+
...schema,
|
|
53
|
+
title: pascalCase(schema.title)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
refs[id.toString()] = normalizedSchema;
|
|
50
57
|
return toReference(id);
|
|
51
58
|
}
|
|
52
59
|
function addShape(refs, schema) {
|
|
@@ -221,6 +228,11 @@ export class ClusterBuilder {
|
|
|
221
228
|
let index;
|
|
222
229
|
if (typeof id === 'number') {
|
|
223
230
|
index = id;
|
|
231
|
+
} else if (typeof id === 'string' && id[0] === '#') {
|
|
232
|
+
index = Number.parseInt(id.slice(1), 10);
|
|
233
|
+
if (Number.isNaN(index)) {
|
|
234
|
+
throw new Error(`Invalid DocumentModelID: ${id}`);
|
|
235
|
+
}
|
|
224
236
|
} else {
|
|
225
237
|
const docID = typeof id === 'string' ? DocumentModelID.fromString(id) : id;
|
|
226
238
|
if (!docID.isLocal) {
|
|
@@ -242,8 +254,18 @@ export class ClusterBuilder {
|
|
|
242
254
|
const schemaReferences = {};
|
|
243
255
|
const schemaRequired = new Set();
|
|
244
256
|
const fieldsMeta = {};
|
|
257
|
+
const normalizedInterfaceIDs = interfaceIDs.map((id)=>{
|
|
258
|
+
if (id.startsWith('#')) {
|
|
259
|
+
const index = Number.parseInt(id.slice(1), 10);
|
|
260
|
+
if (Number.isNaN(index)) {
|
|
261
|
+
throw new Error(`Invalid DocumentModelID: ${id}`);
|
|
262
|
+
}
|
|
263
|
+
return DocumentModelID.local(index).toString();
|
|
264
|
+
}
|
|
265
|
+
return id;
|
|
266
|
+
});
|
|
245
267
|
// Add interface fields
|
|
246
|
-
for (const interfaceModel of
|
|
268
|
+
for (const interfaceModel of normalizedInterfaceIDs.map((id)=>this.get(id))){
|
|
247
269
|
for (const interfaceID of interfaceModel.interfaces){
|
|
248
270
|
interfaces.add(interfaceID);
|
|
249
271
|
}
|
|
@@ -255,7 +277,7 @@ export class ClusterBuilder {
|
|
|
255
277
|
Object.assign(fieldsMeta, interfaceModel.fieldsMeta ?? {});
|
|
256
278
|
}
|
|
257
279
|
// Add model extra fields
|
|
258
|
-
for (const interfaceID of
|
|
280
|
+
for (const interfaceID of normalizedInterfaceIDs){
|
|
259
281
|
interfaces.add(interfaceID);
|
|
260
282
|
}
|
|
261
283
|
for (const requiredKey of inputSchema.required ?? []){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubun/protocol",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"license": "see LICENSE.md",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@kubun/id": "^0.3.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"json-schema-typed": "^8.0.
|
|
25
|
+
"json-schema-typed": "^8.0.2"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build:clean": "del lib",
|