@nymphjs/tilmeld-setup 1.0.0-beta.132 → 1.0.0-beta.134

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.134](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.133...v1.0.0-beta.134) (2026-10-29)
7
+
8
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
9
+
10
+ # [1.0.0-beta.133](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.132...v1.0.0-beta.133) (2026-10-28)
11
+
12
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
13
+
6
14
  # [1.0.0-beta.132](https://forge.sciactive.com/sciactive/nymphjs/compare/v1.0.0-beta.131...v1.0.0-beta.132) (2026-10-26)
7
15
 
8
16
  **Note:** Version bump only for package @nymphjs/tilmeld-setup
package/dist/app/index.js CHANGED
@@ -22766,7 +22766,9 @@
22766
22766
  Array.prototype.slice.call(params));
22767
22767
  }
22768
22768
  toJSON() {
22769
- this.$check();
22769
+ if (this.$isASleepingReference && this.$sleepingReference) {
22770
+ return this.$sleepingReference;
22771
+ }
22770
22772
  const obj = {
22771
22773
  class: entityConstructorsToClassNames(this.constructor),
22772
22774
  guid: this.guid,
@@ -22780,30 +22782,52 @@
22780
22782
  }
22781
22783
  return obj;
22782
22784
  }
22783
- $init(entityJson) {
22785
+ $init(entityJson, isFromSave) {
22784
22786
  if (entityJson == null) {
22785
- return this.$proxy();
22787
+ return this;
22786
22788
  }
22787
22789
  this.$isASleepingReference = false;
22788
22790
  this.$sleepingReference = null;
22789
22791
  this.guid = entityJson.guid;
22790
22792
  this.cdate = entityJson.cdate;
22791
22793
  this.mdate = entityJson.mdate;
22792
- this.tags = entityJson.tags;
22794
+ if (
22795
+ // The instance is new.
22796
+ !this.$originalTags.length ||
22797
+ // The data is coming from a save.
22798
+ isFromSave ||
22799
+ // The tags haven't been modified.
22800
+ JSON.stringify([...this.tags].sort()) ===
22801
+ JSON.stringify([...this.$originalTags].sort())) {
22802
+ this.tags = entityJson.tags;
22803
+ }
22793
22804
  this.$originalTags = entityJson.tags.slice(0);
22794
- this.$dirty = {};
22795
- this.$dataStore = Object.entries(entityJson.data)
22796
- .map(([key, value]) => {
22797
- this.$dirty[key] = false;
22798
- return {
22799
- key,
22800
- value: classNamesToEntityConstructors(this.$nymph, referencesToEntities(value, this.$nymph)),
22801
- };
22802
- })
22803
- .reduce((obj, { key, value }) => Object.assign(obj, { [key]: value }), {});
22804
- this.$data = new Proxy(this.$dataStore, this.$dataHandler);
22805
+ if (!this.$nymph.weakCache || !this.$nymph.weakCacheKeepDirtyData) {
22806
+ // Clear dirty data tracker.
22807
+ for (let name in this.$dirty) {
22808
+ delete this.$dirty[name];
22809
+ }
22810
+ }
22811
+ for (let name in this.$dataStore) {
22812
+ if (!this.$dirty[name]) {
22813
+ if (name in entityJson.data) {
22814
+ this.$dataStore[name] = classNamesToEntityConstructors(this.$nymph, referencesToEntities(entityJson.data[name], this.$nymph));
22815
+ this.$dirty[name] = false;
22816
+ }
22817
+ else {
22818
+ delete this.$dataStore[name];
22819
+ delete this.$dirty[name];
22820
+ }
22821
+ }
22822
+ }
22823
+ for (let name in entityJson.data) {
22824
+ if (!(name in this.$dataStore)) {
22825
+ this.$dataStore[name] = classNamesToEntityConstructors(this.$nymph, referencesToEntities(entityJson.data[name], this.$nymph));
22826
+ this.$dirty[name] = false;
22827
+ }
22828
+ }
22805
22829
  this.$nymph.setEntityToCache(this.constructor, this);
22806
- return this.$proxy();
22830
+ return this;
22807
22831
  }
22808
22832
  $addTag(...tags) {
22809
22833
  this.$check();
@@ -22849,10 +22873,14 @@
22849
22873
  return false;
22850
22874
  }
22851
22875
  const obData = sortObj(object.toJSON());
22852
- obData.tags?.sort();
22876
+ if ('tags' in obData) {
22877
+ obData.tags?.sort();
22878
+ }
22853
22879
  // obData.data = sortObj(obData.data);
22854
22880
  const myData = sortObj(this.toJSON());
22855
- myData.tags?.sort();
22881
+ if ('tags' in myData) {
22882
+ myData.tags?.sort();
22883
+ }
22856
22884
  // myData.data = sortObj(myData.data);
22857
22885
  return isEqual(obData, myData);
22858
22886
  }
@@ -22913,10 +22941,14 @@
22913
22941
  }
22914
22942
  else {
22915
22943
  const obData = sortObj(object.toJSON());
22916
- obData.tags?.sort();
22944
+ if ('tags' in obData) {
22945
+ obData.tags?.sort();
22946
+ }
22917
22947
  // obData.data = sortObj(obData.data);
22918
22948
  const myData = sortObj(this.toJSON());
22919
- myData.tags?.sort();
22949
+ if ('tags' in myData) {
22950
+ myData.tags?.sort();
22951
+ }
22920
22952
  // myData.data = sortObj(myData.data);
22921
22953
  return isEqual(obData, myData);
22922
22954
  }
@@ -22949,7 +22981,7 @@
22949
22981
  $wake() {
22950
22982
  if (!this.$asleep()) {
22951
22983
  this.$wakePromise = null;
22952
- return Promise.resolve(this.$proxy());
22984
+ return Promise.resolve(this);
22953
22985
  }
22954
22986
  if (this.$sleepingReference?.[1] == null) {
22955
22987
  throw new InvalidStateError('Tried to wake a sleeping reference with no GUID.');
@@ -22962,7 +22994,7 @@
22962
22994
  const errObj = { data, textStatus: 'No data returned.' };
22963
22995
  return Promise.reject(errObj);
22964
22996
  }
22965
- return this.$init(data);
22997
+ return this.$init(data, false);
22966
22998
  })
22967
22999
  .finally(() => {
22968
23000
  this.$wakePromise = null;
@@ -22981,7 +23013,7 @@
22981
23013
  newLevel = level - 1;
22982
23014
  }
22983
23015
  if (newLevel !== undefined && newLevel < 0) {
22984
- resolve(this.$proxy());
23016
+ resolve(this);
22985
23017
  return;
22986
23018
  }
22987
23019
  const promises = [];
@@ -23016,10 +23048,10 @@
23016
23048
  };
23017
23049
  walkData(this.$data);
23018
23050
  if (promises.length) {
23019
- Promise.all(promises).then(() => resolve(this.$proxy()), (errObj) => reject(errObj));
23051
+ Promise.all(promises).then(() => resolve(this), (errObj) => reject(errObj));
23020
23052
  }
23021
23053
  else {
23022
- resolve(this.$proxy());
23054
+ resolve(this);
23023
23055
  }
23024
23056
  };
23025
23057
  if (this.$asleep()) {
@@ -23052,7 +23084,7 @@
23052
23084
  if (data == null) {
23053
23085
  throw new Error("The entity's data could not be refreshed.");
23054
23086
  }
23055
- this.$init(data);
23087
+ this.$init(data, false);
23056
23088
  return true;
23057
23089
  }
23058
23090
  $removeTag(...tags) {
@@ -23073,7 +23105,7 @@
23073
23105
  const paramArray = Array.prototype.slice.call(params);
23074
23106
  const data = await this.$nymph.serverCall(this, method, paramArray, stateless);
23075
23107
  if (!stateless && data.entity) {
23076
- this.$init(data.entity);
23108
+ this.$init(data.entity, false);
23077
23109
  }
23078
23110
  return data.return;
23079
23111
  }
@@ -23082,7 +23114,7 @@
23082
23114
  return this.$sleepingReference;
23083
23115
  }
23084
23116
  if (this.guid == null) {
23085
- return this.$proxy();
23117
+ return this;
23086
23118
  }
23087
23119
  return [
23088
23120
  'nymph_entity_reference',
@@ -23727,6 +23759,37 @@
23727
23759
  }
23728
23760
  }
23729
23761
 
23762
+ class QueryWeakCache {
23763
+ queries = new Map();
23764
+ get(queryJSON) {
23765
+ const weakRef = this.queries.get(queryJSON);
23766
+ const deref = weakRef && weakRef.deref();
23767
+ if (deref != null) {
23768
+ return deref;
23769
+ }
23770
+ else {
23771
+ this.queries.delete(queryJSON);
23772
+ }
23773
+ return null;
23774
+ }
23775
+ set(queryJSON, promise) {
23776
+ this.clean();
23777
+ if (!(promise instanceof Promise)) {
23778
+ return;
23779
+ }
23780
+ const weakRef = new WeakRef(promise);
23781
+ this.queries.set(queryJSON, weakRef);
23782
+ }
23783
+ clean() {
23784
+ this.queries.forEach((value, key) => {
23785
+ const deref = value && value.deref();
23786
+ if (deref == null) {
23787
+ this.queries.delete(key);
23788
+ }
23789
+ });
23790
+ }
23791
+ }
23792
+
23730
23793
  let requester;
23731
23794
  class Nymph {
23732
23795
  /**
@@ -23745,6 +23808,7 @@
23745
23808
  responseCallbacks = [];
23746
23809
  restUrl = '';
23747
23810
  weakCache = false;
23811
+ weakCacheKeepDirtyData = false;
23748
23812
  /**
23749
23813
  * Headers that will be sent with every request.
23750
23814
  *
@@ -23754,7 +23818,11 @@
23754
23818
  /**
23755
23819
  * The entity cache.
23756
23820
  */
23757
- cache = new EntityWeakCache();
23821
+ entityCache = new EntityWeakCache();
23822
+ /**
23823
+ * The query cache.
23824
+ */
23825
+ queryCache = new QueryWeakCache();
23758
23826
  /**
23759
23827
  * Return `null` or empty array instead of error when entity/ies not found.
23760
23828
  */
@@ -23763,6 +23831,7 @@
23763
23831
  this.restUrl = NymphOptions.restUrl;
23764
23832
  // @ts-ignore TS doesn't know about WeakRef.
23765
23833
  this.weakCache = !!NymphOptions.weakCache && typeof WeakRef !== 'undefined';
23834
+ this.weakCacheKeepDirtyData = !!NymphOptions.weakCacheKeepDirtyData;
23766
23835
  if ('returnNullOnNotFound' in NymphOptions &&
23767
23836
  NymphOptions.returnNullOnNotFound != null) {
23768
23837
  this.returnNullOnNotFound = NymphOptions.returnNullOnNotFound;
@@ -23836,12 +23905,24 @@
23836
23905
  });
23837
23906
  }
23838
23907
  async getUID(name) {
23839
- const data = await requester.GET({
23840
- url: this.restUrl,
23841
- headers: { ...this.headers },
23842
- dataType: 'text',
23843
- data: { action: 'uid', data: name },
23844
- });
23908
+ const query = { action: 'uid', data: name };
23909
+ let promise = null;
23910
+ const queryJSON = JSON.stringify(query);
23911
+ if (this.weakCache) {
23912
+ promise = this.queryCache.get(queryJSON);
23913
+ }
23914
+ if (promise == null) {
23915
+ promise = requester.GET({
23916
+ url: this.restUrl,
23917
+ headers: { ...this.headers },
23918
+ dataType: 'text',
23919
+ data: query,
23920
+ });
23921
+ if (this.weakCache) {
23922
+ this.queryCache.set(queryJSON, promise);
23923
+ }
23924
+ }
23925
+ const data = await promise;
23845
23926
  return Number(data);
23846
23927
  }
23847
23928
  async deleteUID(name) {
@@ -23904,11 +23985,11 @@
23904
23985
  return entity.map((e, i) => response[i] &&
23905
23986
  response[i].guid != null &&
23906
23987
  (e.guid == null || e.guid === response[i].guid)
23907
- ? e.$init(response[i])
23988
+ ? e.$init(response[i], method !== 'GET')
23908
23989
  : e);
23909
23990
  }
23910
23991
  else if (!Array.isArray(entity) && response.guid != null) {
23911
- return entity.$init(response);
23992
+ return entity.$init(response, method !== 'GET');
23912
23993
  }
23913
23994
  throw new Error('Server error');
23914
23995
  }
@@ -23936,7 +24017,7 @@
23936
24017
  return data;
23937
24018
  }
23938
24019
  else {
23939
- return this.initEntity(data);
24020
+ return this.initEntity(data, false);
23940
24021
  }
23941
24022
  }
23942
24023
  return null;
@@ -23949,18 +24030,30 @@
23949
24030
  if (typeof selectors[0] === 'string') {
23950
24031
  selectors = [{ type: '&', guid: selectors[0] }];
23951
24032
  }
23952
- const data = await requester.GET({
23953
- url: this.restUrl,
23954
- headers: { ...this.headers },
23955
- dataType: 'json',
23956
- data: {
23957
- action: 'entity',
23958
- data: [
23959
- entityConstructorsToClassNames(options),
23960
- ...entityConstructorsToClassNames(entitiesToReferences(selectors)),
23961
- ],
23962
- },
23963
- });
24033
+ const query = {
24034
+ action: 'entity',
24035
+ data: [
24036
+ entityConstructorsToClassNames(options),
24037
+ ...entityConstructorsToClassNames(entitiesToReferences(selectors)),
24038
+ ],
24039
+ };
24040
+ let promise = null;
24041
+ const queryJSON = JSON.stringify(query);
24042
+ if (this.weakCache) {
24043
+ promise = this.queryCache.get(queryJSON);
24044
+ }
24045
+ if (promise == null) {
24046
+ promise = requester.GET({
24047
+ url: this.restUrl,
24048
+ headers: { ...this.headers },
24049
+ dataType: 'json',
24050
+ data: query,
24051
+ });
24052
+ if (this.weakCache) {
24053
+ this.queryCache.set(queryJSON, promise);
24054
+ }
24055
+ }
24056
+ const data = await promise;
23964
24057
  if (options.return === 'count' || typeof data.guid !== 'undefined') {
23965
24058
  return data;
23966
24059
  }
@@ -23969,18 +24062,30 @@
23969
24062
  async getEntities(options, ...selectors) {
23970
24063
  let data = null;
23971
24064
  try {
23972
- data = await requester.GET({
23973
- url: this.restUrl,
23974
- headers: { ...this.headers },
23975
- dataType: 'json',
23976
- data: {
23977
- action: 'entities',
23978
- data: [
23979
- entityConstructorsToClassNames(options),
23980
- ...entityConstructorsToClassNames(entitiesToReferences(selectors)),
23981
- ],
23982
- },
23983
- });
24065
+ const query = {
24066
+ action: 'entities',
24067
+ data: [
24068
+ entityConstructorsToClassNames(options),
24069
+ ...entityConstructorsToClassNames(entitiesToReferences(selectors)),
24070
+ ],
24071
+ };
24072
+ let promise = null;
24073
+ const queryJSON = JSON.stringify(query);
24074
+ if (this.weakCache) {
24075
+ promise = this.queryCache.get(queryJSON);
24076
+ }
24077
+ if (promise == null) {
24078
+ promise = requester.GET({
24079
+ url: this.restUrl,
24080
+ headers: { ...this.headers },
24081
+ dataType: 'json',
24082
+ data: query,
24083
+ });
24084
+ if (this.weakCache) {
24085
+ this.queryCache.set(queryJSON, promise);
24086
+ }
24087
+ }
24088
+ data = await promise;
23984
24089
  }
23985
24090
  catch (e) {
23986
24091
  if (this.returnNullOnNotFound &&
@@ -24001,9 +24106,9 @@
24001
24106
  if (options.return && options.return === 'guid') {
24002
24107
  return data;
24003
24108
  }
24004
- return data.map((e) => this.initEntity(e));
24109
+ return data.map((e) => this.initEntity(e, false));
24005
24110
  }
24006
- initEntity(entityJSON) {
24111
+ initEntity(entityJSON, isFromSave) {
24007
24112
  const EntityClass = classNamesToEntityConstructors(this, entityJSON.class);
24008
24113
  if (!EntityClass) {
24009
24114
  throw new ClassNotAvailableError(entityJSON.class + ' class cannot be found.');
@@ -24011,29 +24116,29 @@
24011
24116
  let entity = EntityClass.factorySync();
24012
24117
  if (this.weakCache) {
24013
24118
  // Try to get it from cache.
24014
- const entityFromCache = this.cache.get(EntityClass, entityJSON.guid || '');
24119
+ const entityFromCache = this.entityCache.get(EntityClass, entityJSON.guid || '');
24015
24120
  if (entityFromCache != null) {
24016
24121
  entity = entityFromCache;
24017
24122
  }
24018
24123
  }
24019
- return entity.$init(entityJSON);
24124
+ return entity.$init(entityJSON, isFromSave);
24020
24125
  }
24021
24126
  getEntityFromCache(EntityClass, guid) {
24022
24127
  if (!this.weakCache) {
24023
24128
  return null;
24024
24129
  }
24025
- return this.cache.get(EntityClass, guid);
24130
+ return this.entityCache.get(EntityClass, guid);
24026
24131
  }
24027
24132
  setEntityToCache(EntityClass, entity) {
24028
24133
  if (!this.weakCache) {
24029
24134
  return;
24030
24135
  }
24031
- return this.cache.set(EntityClass, entity);
24136
+ return this.entityCache.set(EntityClass, entity);
24032
24137
  }
24033
- initEntitiesFromData(item) {
24138
+ initEntitiesFromData(item, isFromSave) {
24034
24139
  if (Array.isArray(item)) {
24035
24140
  // Recurse into lower arrays.
24036
- return item.map((entry) => this.initEntitiesFromData(entry));
24141
+ return item.map((entry) => this.initEntitiesFromData(entry, isFromSave));
24037
24142
  }
24038
24143
  else if (item instanceof Object && !(item instanceof Entity)) {
24039
24144
  if (item.hasOwnProperty('class') &&
@@ -24043,12 +24148,12 @@
24043
24148
  item.hasOwnProperty('tags') &&
24044
24149
  item.hasOwnProperty('data') &&
24045
24150
  classNamesToEntityConstructors(this, item.class) != null) {
24046
- return this.initEntity(item);
24151
+ return this.initEntity(item, isFromSave);
24047
24152
  }
24048
24153
  else {
24049
24154
  for (let [key, value] of Object.entries(item)) {
24050
24155
  // @ts-ignore: Key comes from the object. It's fine.
24051
- item[key] = this.initEntitiesFromData(value);
24156
+ item[key] = this.initEntitiesFromData(value, isFromSave);
24052
24157
  }
24053
24158
  }
24054
24159
  }
@@ -24094,7 +24199,7 @@
24094
24199
  });
24095
24200
  return {
24096
24201
  ...data,
24097
- return: this.initEntitiesFromData(data.return),
24202
+ return: this.initEntitiesFromData(data.return, false),
24098
24203
  };
24099
24204
  }
24100
24205
  async serverCallStatic(className, method, params) {
@@ -24112,7 +24217,7 @@
24112
24217
  },
24113
24218
  },
24114
24219
  });
24115
- return this.initEntitiesFromData(data);
24220
+ return this.initEntitiesFromData(data, false);
24116
24221
  }
24117
24222
  async serverCallStaticIterator(className, method, params) {
24118
24223
  const iterable = await requester.POST_ITERATOR({
@@ -24139,7 +24244,7 @@
24139
24244
  yield response;
24140
24245
  }
24141
24246
  else {
24142
- yield that.initEntitiesFromData(response);
24247
+ yield that.initEntitiesFromData(response, false);
24143
24248
  }
24144
24249
  }
24145
24250
  },
@@ -24247,8 +24352,8 @@
24247
24352
  }
24248
24353
  constructor() {
24249
24354
  super();
24250
- this.$data.enabled = true;
24251
- this.$data.abilities = [];
24355
+ this.enabled = true;
24356
+ this.abilities = [];
24252
24357
  }
24253
24358
  async $checkGroupname() {
24254
24359
  return await this.$serverCall('$checkGroupname', [], true);
@@ -24426,10 +24531,10 @@
24426
24531
  }
24427
24532
  constructor() {
24428
24533
  super();
24429
- this.$data.enabled = true;
24430
- this.$data.abilities = [];
24431
- this.$data.groups = [];
24432
- this.$data.inheritAbilities = true;
24534
+ this.enabled = true;
24535
+ this.abilities = [];
24536
+ this.groups = [];
24537
+ this.inheritAbilities = true;
24433
24538
  }
24434
24539
  async $checkUsername() {
24435
24540
  return await this.$serverCall('$checkUsername', [], true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymphjs/tilmeld-setup",
3
- "version": "1.0.0-beta.132",
3
+ "version": "1.0.0-beta.134",
4
4
  "description": "Nymph.js - Tilmeld Setup App",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "license": "Apache-2.0",
43
43
  "dependencies": {
44
- "@nymphjs/nymph": "^1.0.0-beta.132",
45
- "@nymphjs/tilmeld": "^1.0.0-beta.132",
44
+ "@nymphjs/nymph": "^1.0.0-beta.134",
45
+ "@nymphjs/tilmeld": "^1.0.0-beta.134",
46
46
  "express": "^5.2.1",
47
47
  "locutus": "^3.0.36"
48
48
  },
@@ -50,12 +50,12 @@
50
50
  "@material/elevation": "^14.0.0",
51
51
  "@material/typography": "^14.0.0",
52
52
  "@mdi/js": "^7.4.47",
53
- "@nymphjs/client": "^1.0.0-beta.132",
54
- "@nymphjs/driver-sqlite3": "^1.0.0-beta.132",
55
- "@nymphjs/query-parser": "^1.0.0-beta.132",
56
- "@nymphjs/server": "^1.0.0-beta.132",
57
- "@nymphjs/tilmeld-client": "^1.0.0-beta.132",
58
- "@nymphjs/tilmeld-components": "^1.0.0-beta.132",
53
+ "@nymphjs/client": "^1.0.0-beta.134",
54
+ "@nymphjs/driver-sqlite3": "^1.0.0-beta.134",
55
+ "@nymphjs/query-parser": "^1.0.0-beta.134",
56
+ "@nymphjs/server": "^1.0.0-beta.134",
57
+ "@nymphjs/tilmeld-client": "^1.0.0-beta.134",
58
+ "@nymphjs/tilmeld-components": "^1.0.0-beta.134",
59
59
  "@rollup/plugin-commonjs": "^29.0.3",
60
60
  "@rollup/plugin-node-resolve": "^16.0.3",
61
61
  "@rollup/plugin-sucrase": "^5.1.0",
@@ -98,5 +98,5 @@
98
98
  "tslib": "^2.8.1",
99
99
  "typescript": "^7.0.2"
100
100
  },
101
- "gitHead": "d421575ba555d6c9025ec4b3d9f6ce0f498adbf2"
101
+ "gitHead": "31b045084100c2267c2eac7ad457d52983b0b895"
102
102
  }