@prestizni-software/client-dem 0.2.14 → 0.2.15

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.
@@ -27,12 +27,14 @@ export async function createAutoUpdatedClass<C extends Constructor<any>>(
27
27
  ): Promise<AutoUpdated<C>> {
28
28
  if (typeof data !== "string")
29
29
  processIsRefProperties(data, classParam.prototype, undefined, [], loggers);
30
-
30
+ const props = Reflect.getMetadata("props", classParam.prototype);
31
+ if (typeof data !== "string")
32
+ checkForMissingRefs<C>(data, props, classParam, autoClassers);
31
33
  const instance = new (class extends AutoUpdatedClientObject<C> {})(
32
34
  socket,
33
35
  data,
34
36
  loggers,
35
- Reflect.getMetadata("props", classParam.prototype),
37
+ props,
36
38
  classParam.name,
37
39
  classParam,
38
40
  autoClassers,
@@ -123,6 +125,7 @@ export abstract class AutoUpdatedClientObject<T extends Constructor<any>> {
123
125
  this.emitter.dispatchEvent(new Event("loaded"+this.EmitterID));
124
126
  return;
125
127
  }
128
+ checkForMissingRefs<T>(res.data as any, properties, classProperty as any, autoClassers);
126
129
  this.data = res.data as IsData<T>;
127
130
  this.isLoading = false;
128
131
  this.emitter.dispatchEvent(new Event("loaded"+this.EmitterID));
@@ -438,3 +441,29 @@ export function processIsRefProperties(
438
441
  }
439
442
  return allProps;
440
443
  }
444
+
445
+ export function getMetadataRecursive(
446
+ metaKey: string,
447
+ proto: any,
448
+ prop: string
449
+ ) {
450
+ while (proto) {
451
+ const meta = Reflect.getMetadata(metaKey, proto, prop);
452
+ if (meta !== undefined) return meta;
453
+ proto = Object.getPrototypeOf(proto);
454
+ }
455
+ return undefined;
456
+ }
457
+
458
+ function checkForMissingRefs<C extends Constructor<any>>(data: IsData<InstanceType<C>>, props: any, classParam: C, autoClassers: { [key: string]: AutoUpdateManager<any>; }) {
459
+ if (typeof data !== "string") {
460
+ const entryKeys = Object.keys(data);
461
+ for (const prop of props) {
462
+ if (!entryKeys.includes(prop.toString()) &&
463
+ getMetadataRecursive("isRef", classParam.prototype, prop.toString())) {
464
+ (data as any)[prop] = Object.values(autoClassers).find((autoClasser) => autoClasser.getObject((data as any)[prop])
465
+ );
466
+ }
467
+ }
468
+ }
469
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.2.15](https://github.com/Prestizni-Software/client-dem/compare/v0.2.14...v0.2.15) (2025-11-10)
6
+
5
7
  ### [0.2.14](https://github.com/Prestizni-Software/client-dem/compare/v0.2.13...v0.2.14) (2025-11-06)
6
8
 
7
9
  ### [0.2.13](https://github.com/Prestizni-Software/client-dem/compare/v0.2.12...v0.2.13) (2025-11-06)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prestizni-software/client-dem",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "An solution for when making http requests is not a good solution",
5
5
  "keywords": [
6
6
  "websockets"