dmx-api 3.0.1 → 4.0.0

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/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Version History
4
4
 
5
+ **4.0** -- Oct 16, 2024
6
+
7
+ * BREAKING CHANGES
8
+ - requires Vue 3 (instead Vue 2)
9
+
10
+ **3.1** -- Oct 16, 2024
11
+
12
+ * Adapted to DMX 5.3.5 (account management)
13
+
5
14
  **3.0.1** -- Jun 6, 2023
6
15
 
7
16
  * Improvement:
@@ -322,4 +331,4 @@ library's `init()` function.
322
331
 
323
332
  ------------
324
333
  Jörg Richter
325
- Jun 6, 2023
334
+ Oct 16, 2024
package/package.json CHANGED
@@ -1,22 +1,21 @@
1
1
  {
2
2
  "name": "dmx-api",
3
- "version": "3.0.1",
3
+ "version": "4.0.0",
4
4
  "description": "API and utilities for DMX 5 based frontends",
5
5
  "author": "Jörg Richter <jri@dmx.berlin>",
6
6
  "license": "AGPL-3.0",
7
7
  "main": "src/index.js",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/dmx-systems/dmx-api.git"
11
- },
12
- "scripts": {
13
- "build": "../../node_modules/.bin/webpack -p --hide-modules",
14
- "stats": "../../node_modules/.bin/webpack -p --json > stats.json && ../../node_modules/.bin/webpack-bundle-analyzer stats.json dist"
10
+ "url": "git+https://github.com/dmx-systems/dmx-api.git"
15
11
  },
16
12
  "dependencies": {
17
13
  "axios": "0.18.1",
18
14
  "clone": "2.1.2",
19
15
  "debounce": "1.2.0",
20
16
  "font-awesome": "4.7.0"
17
+ },
18
+ "peerDependencies": {
19
+ "vue": "3.x"
21
20
  }
22
21
  }
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import icons from './icons'
6
6
  import DMXWebSocket from './websocket'
7
7
  import {default as typeCache, init as initTypeCache, storeModule} from './type-cache'
8
8
 
9
- console.log('[DMX-API] 3.0.1')
9
+ console.log('[DMX-API] 4.0')
10
10
 
11
11
  let adminWorkspaceId // promise
12
12
 
package/src/model.js CHANGED
@@ -2,7 +2,6 @@ import rpc from './rpc'
2
2
  import typeCache from './type-cache'
3
3
  import permCache from './permission-cache'
4
4
  import utils from './utils'
5
- import Vue from 'vue'
6
5
 
7
6
  // TODO: inject or factor out
8
7
  const DEFAULT_TOPIC_ICON = '\uf111' // fa-circle
@@ -734,6 +733,9 @@ class Topicmap extends Topic {
734
733
  this._assocs = utils.mapById(utils.instantiateMany(topicmap.assocs, ViewAssoc)) // map: ID -> dmx.ViewAssoc
735
734
  }
736
735
 
736
+ /**
737
+ * @param id Number or String
738
+ */
737
739
  getTopic (id) {
738
740
  const topic = this.getTopicIfExists(id)
739
741
  if (!topic) {
@@ -742,6 +744,9 @@ class Topicmap extends Topic {
742
744
  return topic
743
745
  }
744
746
 
747
+ /**
748
+ * @param id Number or String
749
+ */
745
750
  getAssoc (id) {
746
751
  const assoc = this.getAssocIfExists(id)
747
752
  if (!assoc) {
@@ -761,26 +766,44 @@ class Topicmap extends Topic {
761
766
  return o
762
767
  }
763
768
 
769
+ /**
770
+ * @param id Number or String
771
+ */
764
772
  getTopicIfExists (id) {
765
773
  return this._topics[id]
766
774
  }
767
775
 
776
+ /**
777
+ * @param id Number or String
778
+ */
768
779
  getAssocIfExists (id) {
769
780
  return this._assocs[id]
770
781
  }
771
782
 
783
+ /**
784
+ * @param id Number or String
785
+ */
772
786
  hasTopic (id) {
773
787
  return this.getTopicIfExists(id)
774
788
  }
775
789
 
790
+ /**
791
+ * @param id Number or String
792
+ */
776
793
  hasAssoc (id) {
777
794
  return this.getAssocIfExists(id)
778
795
  }
779
796
 
797
+ /**
798
+ * @param id Number or String
799
+ */
780
800
  hasObject (id) {
781
801
  return this.hasTopic(id) || this.hasAssoc(id)
782
802
  }
783
803
 
804
+ /**
805
+ * @param id Number or String
806
+ */
784
807
  hasVisibleObject (id) {
785
808
  const o = this.getTopicIfExists(id) || this.getAssocIfExists(id)
786
809
  return o && o.isVisible()
@@ -831,8 +854,7 @@ class Topicmap extends Topic {
831
854
  if (!(topic instanceof ViewTopic)) {
832
855
  throw Error(`addTopic() expects ViewTopic, got ${topic.constructor.name}`)
833
856
  }
834
- // reactivity is required to trigger "visibleTopicIds" getter (module dmx-cytoscape-renderer)
835
- Vue.set(this._topics, topic.id, topic)
857
+ this._topics[topic.id] = topic
836
858
  }
837
859
 
838
860
  /**
@@ -845,8 +867,7 @@ class Topicmap extends Topic {
845
867
  if (!(assoc instanceof ViewAssoc)) {
846
868
  throw Error(`addAssoc() expects ViewAssoc, got ${assoc.constructor.name}`)
847
869
  }
848
- // reactivity is required to trigger "visibleAssocIds" getter (module dmx-cytoscape-renderer)
849
- Vue.set(this._assocs, assoc.id, assoc)
870
+ this._assocs[assoc.id] = assoc
850
871
  }
851
872
 
852
873
  /**
@@ -919,11 +940,8 @@ class Topicmap extends Topic {
919
940
 
920
941
  updateTopic (topic) {
921
942
  if (this.id === topic.id) {
922
- Vue.set(
923
- this.children,
924
- 'dmx.base.url#dmx.topicmaps.background_image',
925
- topic.children['dmx.base.url#dmx.topicmaps.background_image']
926
- )
943
+ const uri = 'dmx.base.url#dmx.topicmaps.background_image'
944
+ this.children[uri] = topic.children[uri]
927
945
  }
928
946
  }
929
947
 
@@ -934,16 +952,14 @@ class Topicmap extends Topic {
934
952
  * Note: if the topic is not in this topicmap nothing is performed.
935
953
  */
936
954
  removeTopic (id) {
937
- // reactivity is required to trigger "visibleTopicIds" getter (module dmx-cytoscape-renderer)
938
- Vue.delete(this._topics, id)
955
+ delete this._topics[id]
939
956
  }
940
957
 
941
958
  /**
942
959
  * Note: if the assoc is not in this topicmap nothing is performed.
943
960
  */
944
961
  removeAssoc (id) {
945
- // reactivity is required to trigger "visibleAssocIds" getter (module dmx-cytoscape-renderer)
946
- Vue.delete(this._assocs, id)
962
+ delete this._assocs[id]
947
963
  }
948
964
 
949
965
  // Associations
@@ -1042,9 +1058,7 @@ const viewPropsMixin = Base => class extends Base {
1042
1058
  }
1043
1059
 
1044
1060
  setViewProp (propUri, value) {
1045
- // Note: some view props must be reactive, e.g. 'dmx.topicmaps.pinned' reflects pin button state.
1046
- // Test it with topics/assocs which don't have a 'dmx.topicmaps.pinned' setting yet. ### FIXDOC
1047
- Vue.set(this.viewProps, propUri, value)
1061
+ this.viewProps[propUri] = value
1048
1062
  }
1049
1063
  }
1050
1064
 
package/src/rpc.js CHANGED
@@ -541,7 +541,7 @@ export default {
541
541
  * @return a promise for a Username topic
542
542
  */
543
543
  createUserAccount (username, password) {
544
- return http.post('/access-control/user-account', {
544
+ return http.post('/account-management/user-account', {
545
545
  username, password
546
546
  }).then(response =>
547
547
  new Topic(response.data)
package/src/type-cache.js CHANGED
@@ -1,7 +1,7 @@
1
- import {Topic, TopicType, AssocType, RoleType} from './model'
1
+ import { nextTick } from 'vue'
2
+ import { Topic, TopicType, AssocType, RoleType } from './model'
2
3
  import rpc from './rpc'
3
4
  import utils from './utils'
4
- import Vue from 'vue'
5
5
 
6
6
  const typeP = {} // intermediate type promises
7
7
 
@@ -87,7 +87,7 @@ const actions = {
87
87
  }
88
88
  // Note: role types are never updated as they are simple values and thus immutable
89
89
  })
90
- Vue.nextTick(() => {
90
+ nextTick(() => {
91
91
  // console.log(`Type-cache: processing ${directives.length} directives (DELETE_TYPE)`)
92
92
  directives.forEach(dir => {
93
93
  switch (dir.type) {
@@ -278,25 +278,21 @@ function _putType (type, typeClass, prop) {
278
278
  if (!(type instanceof typeClass)) {
279
279
  throw Error(`can't cache "${type.constructor.name}", expected is "${typeClass.name}", ${JSON.stringify(type)}`)
280
280
  }
281
- // Note: type cache must be reactive
282
- Vue.set(state[prop], type.uri, type)
281
+ state[prop][type.uri] = type
283
282
  }
284
283
 
285
284
  // ---
286
285
 
287
286
  function removeTopicType (uri) {
288
- // Note: type cache must be reactive
289
- Vue.delete(state.topicTypes, uri)
287
+ delete state.topicTypes[uri]
290
288
  }
291
289
 
292
290
  function removeAssocType (uri) {
293
- // Note: type cache must be reactive
294
- Vue.delete(state.assocTypes, uri)
291
+ delete state.assocTypes[uri]
295
292
  }
296
293
 
297
294
  function removeRoleType (uri) {
298
- // Note: type cache must be reactive
299
- Vue.delete(state.roleTypes, uri)
295
+ delete state.roleTypes[uri]
300
296
  }
301
297
 
302
298
  // ---