@alizarin/clm 2.0.0-alpha.103 → 2.0.0-alpha.106

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.
Files changed (2) hide show
  1. package/dist/clm.js +10 -10
  2. package/package.json +2 -2
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,24 +184,24 @@ var ReferenceValueViewModel = class c extends String {
184
184
  } : null;
185
185
  }
186
186
  async __asTileData() {
187
- let e = await this._resolvePending();
188
- return e && typeof e.toJSON == "function" ? e.toJSON() : e;
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 (u instanceof Promise) return u.then((u) => c.__create(e, l, u, d));
194
+ if (Array.isArray(u) && u.length === 1 && (u = u[0]), u instanceof Promise) return u.then((u) => c.__create(e, l, u, d));
195
195
  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
196
  let l = {
197
197
  type: "uuid",
198
198
  uuid: u,
199
199
  collectionId: p
200
200
  };
201
- return e.data.set(f, {
201
+ return e.data.set(f, [{
202
202
  __needs_rdm_lookup: !0,
203
203
  uuid: u
204
- }), new c(null, l, e, f, p);
204
+ }]), new c(null, l, e, f, p);
205
205
  } else throw Error(`Set references using values from collections, not strings: ${u}`);
206
206
  else if (typeof u == "object" && u && u.__needs_rdm_lookup && u.uuid) {
207
207
  let l = {
@@ -209,20 +209,20 @@ var ReferenceValueViewModel = class c extends String {
209
209
  uuid: u.uuid,
210
210
  collectionId: p
211
211
  };
212
- return e.data.set(f, u), new c(null, l, e, f, p);
212
+ return e.data.set(f, [u]), new c(null, l, e, f, p);
213
213
  } else if (typeof u == "object" && u && u.__needs_rdm_label_lookup && u.label) {
214
214
  let l = u.controlledList || p, d = {
215
215
  type: "label",
216
216
  label: u.label,
217
217
  collectionId: l
218
218
  };
219
- return e.data.set(f, u), new c(null, d, e, f, l);
219
+ return e.data.set(f, [u]), new c(null, d, e, f, l);
220
220
  } else if (Array.isArray(u) && u.length > 0 && "labels" in u[0]) {
221
221
  let l = new StaticReference(u[0]);
222
- return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
222
+ return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
223
223
  } else if (typeof u == "object" && u && "labels" in u) {
224
224
  let l = new StaticReference(u);
225
- return e.data.set(f, l.toJSON()), new c(l, void 0, void 0, void 0, p);
225
+ return e.data.set(f, [l.toJSON()]), new c(l, void 0, void 0, void 0, p);
226
226
  } else throw Error("Could not set reference from this data: " + JSON.stringify(u));
227
227
  }
228
228
  return !e || !u ? null : new c(u, void 0, void 0, void 0, p);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alizarin/clm",
3
- "version": "2.0.0-alpha.103",
3
+ "version": "2.0.0-alpha.106",
4
4
  "description": "Alizarin display serializers for CLM reference datatypes",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -23,7 +23,7 @@
23
23
  "test": "cd ../../../.. && npm test -- ext/js/@alizarin/clm/tests/clm.test.ts"
24
24
  },
25
25
  "peerDependencies": {
26
- "alizarin": "2.0.0-alpha.103"
26
+ "alizarin": "2.0.0-alpha.106"
27
27
  },
28
28
  "devDependencies": {
29
29
  "alizarin": "file:../../../..",