@live-change/session-service 0.2.16 → 0.2.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/session-service",
3
- "version": "0.2.16",
3
+ "version": "0.2.22",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,9 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "^0.5.7",
25
- "@live-change/relations-plugin": "^0.1.10"
24
+ "@live-change/framework": "0.5.20",
25
+ "@live-change/relations-plugin": "^0.5.20",
26
+ "pluralize": "8.0.0"
26
27
  },
27
- "gitHead": "98a41ae61218a0ec58d4861b6409d8d9facde37f"
28
+ "gitHead": "1bf2012299025806e7d7c0c74af8f29e28094d16"
28
29
  }
package/sessionItem.js CHANGED
@@ -3,6 +3,8 @@ const App = require("@live-change/framework")
3
3
  const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
4
4
  const { Session } = require("./model.js")
5
5
 
6
+ const pluralize = require('pluralize')
7
+
6
8
  definition.processor(function(service, app) {
7
9
 
8
10
  for(let modelName in service.models) {
@@ -24,13 +26,14 @@ definition.processor(function(service, app) {
24
26
 
25
27
  console.log("SESSION ITEM", model)
26
28
 
29
+ if(model.itemOf) throw new Error("model " + modelName + " already have owner")
27
30
  model.itemOf = {
28
31
  what: Session,
29
32
  ...config
30
33
  }
31
34
 
32
35
  if(config.sessionReadAccess) {
33
- const viewName = 'mySession' + modelName + 's'
36
+ const viewName = 'mySession' + pluralize(modelName)
34
37
  service.views[viewName] = new ViewDefinition({
35
38
  name: viewName,
36
39
  access: config.sessionReadAccess,
@@ -42,7 +45,7 @@ definition.processor(function(service, app) {
42
45
  })
43
46
  for(const sortField of config.sortBy) {
44
47
  const sortFieldUc = sortField.slice(0, 1).toUpperCase() + sortField.slice(1)
45
- const viewName = 'mySession' + modelName + 'sBy' + sortFieldUc
48
+ const viewName = 'mySession' + pluralize(modelName) + 'By' + sortFieldUc
46
49
  service.views[viewName] = new ViewDefinition({
47
50
  name: viewName,
48
51
  access: config.sessionReadAccess,
@@ -23,6 +23,7 @@ definition.processor(function(service, app) {
23
23
  const config = model.sessionProperty
24
24
  const writeableProperties = modelProperties || config.writableProperties
25
25
 
26
+ if(model.propertyOf) throw new Error("model " + modelName + " already have owner")
26
27
  model.propertyOf = {
27
28
  what: Session,
28
29
  ...config