@alizarin/clm 2.0.0-alpha.98 → 2.0.0-beta.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/dist/clm.js +13 -9
- package/package.json +5 -5
package/dist/clm.js
CHANGED
|
@@ -157,7 +157,7 @@ var ReferenceValueViewModel = class c extends String {
|
|
|
157
157
|
let c = this._pendingLookup, l = await RDM.retrieveCollection(c.collectionId), u = null;
|
|
158
158
|
if (c.type === "uuid" ? (u = getReferenceValueFromCollection(l, c.uuid), u || console.error("Could not find reference for UUID", c.uuid, "in collection", c.collectionId)) : c.type === "label" && (u = getReferenceValueByLabelFromCollection(l, c.label), u || console.error("Could not find reference for label", c.label, "in collection", c.collectionId)), u && (this._resolvedRef = new StaticReference(u), this._tile && this._nodeid)) {
|
|
159
159
|
let e = this._tile.data.get(this._nodeid);
|
|
160
|
-
Array.isArray(e) || this._tile.data.set(this._nodeid, this._resolvedRef.toJSON());
|
|
160
|
+
Array.isArray(e) && e.length <= 1 ? this._tile.data.set(this._nodeid, [this._resolvedRef.toJSON()]) : Array.isArray(e) || this._tile.data.set(this._nodeid, [this._resolvedRef.toJSON()]);
|
|
161
161
|
}
|
|
162
162
|
return this._resolvedRef;
|
|
163
163
|
})(), this._resolutionPromise) : null;
|
|
@@ -184,13 +184,17 @@ var ReferenceValueViewModel = class c extends String {
|
|
|
184
184
|
} : null;
|
|
185
185
|
}
|
|
186
186
|
async __asTileData() {
|
|
187
|
-
let e = await this._resolvePending();
|
|
188
|
-
return
|
|
187
|
+
let e = await this._resolvePending(), c = e && typeof e.toJSON == "function" ? e.toJSON() : e;
|
|
188
|
+
return c ? [c] : null;
|
|
189
189
|
}
|
|
190
190
|
static async __create(e, l, u, d) {
|
|
191
191
|
let f = l.nodeid, p = l.config?.controlledList || l.config?.rdmCollection;
|
|
192
192
|
if (!p) throw Error(`Node ${l.alias} (${l.nodeid}) missing controlledList or rdmCollection in config`);
|
|
193
193
|
if (e && (e.data.has(f) || e.data.set(f, null), u !== null)) {
|
|
194
|
+
if (Array.isArray(u)) {
|
|
195
|
+
if (u.length === 1) u = u[0];
|
|
196
|
+
else if (u.length === 0) return null;
|
|
197
|
+
}
|
|
194
198
|
if (u instanceof Promise) return u.then((u) => c.__create(e, l, u, d));
|
|
195
199
|
if (typeof u == "string") if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.exec(u)) {
|
|
196
200
|
let l = {
|
|
@@ -198,10 +202,10 @@ var ReferenceValueViewModel = class c extends String {
|
|
|
198
202
|
uuid: u,
|
|
199
203
|
collectionId: p
|
|
200
204
|
};
|
|
201
|
-
return e.data.set(f, {
|
|
205
|
+
return e.data.set(f, [{
|
|
202
206
|
__needs_rdm_lookup: !0,
|
|
203
207
|
uuid: u
|
|
204
|
-
}), new c(null, l, e, f, p);
|
|
208
|
+
}]), new c(null, l, e, f, p);
|
|
205
209
|
} else throw Error(`Set references using values from collections, not strings: ${u}`);
|
|
206
210
|
else if (typeof u == "object" && u && u.__needs_rdm_lookup && u.uuid) {
|
|
207
211
|
let l = {
|
|
@@ -209,20 +213,20 @@ var ReferenceValueViewModel = class c extends String {
|
|
|
209
213
|
uuid: u.uuid,
|
|
210
214
|
collectionId: p
|
|
211
215
|
};
|
|
212
|
-
return e.data.set(f, u), new c(null, l, e, f, p);
|
|
216
|
+
return e.data.set(f, [u]), new c(null, l, e, f, p);
|
|
213
217
|
} else if (typeof u == "object" && u && u.__needs_rdm_label_lookup && u.label) {
|
|
214
218
|
let l = u.controlledList || p, d = {
|
|
215
219
|
type: "label",
|
|
216
220
|
label: u.label,
|
|
217
221
|
collectionId: l
|
|
218
222
|
};
|
|
219
|
-
return e.data.set(f, u), new c(null, d, e, f, l);
|
|
223
|
+
return e.data.set(f, [u]), new c(null, d, e, f, l);
|
|
220
224
|
} else if (Array.isArray(u) && u.length > 0 && "labels" in u[0]) {
|
|
221
225
|
let l = new StaticReference(u[0]);
|
|
222
|
-
return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
|
|
226
|
+
return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
|
|
223
227
|
} else if (typeof u == "object" && u && "labels" in u) {
|
|
224
228
|
let l = new StaticReference(u);
|
|
225
|
-
return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
|
|
229
|
+
return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
|
|
226
230
|
} else throw Error("Could not set reference from this data: " + JSON.stringify(u));
|
|
227
231
|
}
|
|
228
232
|
return !e || !u ? null : new c(u, void 0, void 0, void 0, p);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alizarin/clm",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "Alizarin display serializers for CLM reference datatypes",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/flaxandteal/alizarin",
|
|
9
|
-
"directory": "ext/
|
|
9
|
+
"directory": "ext/alizarin-clm/js"
|
|
10
10
|
},
|
|
11
11
|
"author": "Phil Weir <phil.weir@flaxandteal.co.uk>",
|
|
12
12
|
"type": "module",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"dev": "vite",
|
|
21
21
|
"build": "vite build && tsc -p tsconfig.build.json",
|
|
22
22
|
"preview": "vite preview",
|
|
23
|
-
"test": "cd
|
|
23
|
+
"test": "cd ../../.. && npm test -- ext/alizarin-clm/js/tests/clm.test.ts"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"alizarin": "2.0.0-
|
|
26
|
+
"alizarin": "2.0.0-beta.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"alizarin": "file
|
|
29
|
+
"alizarin": "file:../../..",
|
|
30
30
|
"typescript": "~5.9.3",
|
|
31
31
|
"vite": "npm:rolldown-vite@7.2.5"
|
|
32
32
|
},
|