@live-change/user-service 0.2.19 → 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 +5 -4
- package/sessionOrUserItem.js +5 -2
- package/sessionOrUserProperty.js +1 -0
- package/userItem.js +5 -3
- package/userProperty.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.2.
|
|
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": "
|
|
25
|
-
"@live-change/relations-plugin": "^0.
|
|
24
|
+
"@live-change/framework": "0.5.20",
|
|
25
|
+
"@live-change/relations-plugin": "^0.5.20",
|
|
26
|
+
"pluralize": "8.0.0"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "1bf2012299025806e7d7c0c74af8f29e28094d16"
|
|
28
29
|
}
|
package/sessionOrUserItem.js
CHANGED
|
@@ -3,6 +3,8 @@ const App = require("@live-change/framework")
|
|
|
3
3
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
|
|
4
4
|
const { User } = 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) {
|
|
@@ -23,12 +25,13 @@ definition.processor(function(service, app) {
|
|
|
23
25
|
|
|
24
26
|
//console.log("USER ITEM", model)
|
|
25
27
|
|
|
28
|
+
if(model.itemOfAny) throw new Error("model " + modelName + " already have owner")
|
|
26
29
|
model.itemOfAny = {
|
|
27
30
|
...config
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
if(config.ownerReadAccess) {
|
|
31
|
-
const viewName = 'my' + modelName
|
|
34
|
+
const viewName = 'my' + pluralize(modelName)
|
|
32
35
|
service.views[viewName] = new ViewDefinition({
|
|
33
36
|
name: viewName,
|
|
34
37
|
access(params, context) {
|
|
@@ -43,7 +46,7 @@ definition.processor(function(service, app) {
|
|
|
43
46
|
})
|
|
44
47
|
for(const sortField of config.sortBy || []) {
|
|
45
48
|
const sortFieldUc = sortField.slice(0, 1).toUpperCase() + sortField.slice(1)
|
|
46
|
-
const viewName = 'mySessionOrUser' + modelName + '
|
|
49
|
+
const viewName = 'mySessionOrUser' + pluralize(modelName) + 'By' + sortFieldUc
|
|
47
50
|
service.views[viewName] = new ViewDefinition({
|
|
48
51
|
name: viewName,
|
|
49
52
|
access(params, context) {
|
package/sessionOrUserProperty.js
CHANGED
|
@@ -23,6 +23,7 @@ definition.processor(function(service, app) {
|
|
|
23
23
|
const config = model.sessionOrUserProperty
|
|
24
24
|
const writeableProperties = modelProperties || config.writableProperties
|
|
25
25
|
|
|
26
|
+
if(model.propertyOfAny) throw new Error("model " + modelName + " already have owner")
|
|
26
27
|
model.propertyOfAny = {
|
|
27
28
|
...config
|
|
28
29
|
}
|
package/userItem.js
CHANGED
|
@@ -3,6 +3,8 @@ const App = require("@live-change/framework")
|
|
|
3
3
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App
|
|
4
4
|
const { User } = 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) {
|
|
@@ -22,14 +24,14 @@ definition.processor(function(service, app) {
|
|
|
22
24
|
const writeableProperties = modelProperties || config.writableProperties
|
|
23
25
|
|
|
24
26
|
//console.log("USER ITEM", model)
|
|
25
|
-
|
|
27
|
+
if(model.itemOf) throw new Error("model " + modelName + " already have owner")
|
|
26
28
|
model.itemOf = {
|
|
27
29
|
what: User,
|
|
28
30
|
...config
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
if(config.userReadAccess) {
|
|
32
|
-
const viewName = 'myUser' + modelName
|
|
34
|
+
const viewName = 'myUser' + pluralize(modelName)
|
|
33
35
|
service.views[viewName] = new ViewDefinition({
|
|
34
36
|
name: viewName,
|
|
35
37
|
access(params, context) {
|
|
@@ -44,7 +46,7 @@ definition.processor(function(service, app) {
|
|
|
44
46
|
})
|
|
45
47
|
for(const sortField of config.sortBy || []) {
|
|
46
48
|
const sortFieldUc = sortField.slice(0, 1).toUpperCase() + sortField.slice(1)
|
|
47
|
-
const viewName = 'myUser' + modelName + '
|
|
49
|
+
const viewName = 'myUser' + pluralize(modelName) + 'By' + sortFieldUc
|
|
48
50
|
service.views[viewName] = new ViewDefinition({
|
|
49
51
|
name: viewName,
|
|
50
52
|
access(params, context) {
|
package/userProperty.js
CHANGED
|
@@ -23,6 +23,7 @@ definition.processor(function(service, app) {
|
|
|
23
23
|
const config = model.userProperty
|
|
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: User,
|
|
28
29
|
...config
|