@live-change/relations-plugin 0.7.21 → 0.7.23
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/itemOf.js +1 -1
- package/package.json +3 -3
- package/pluralRelationUtils.js +4 -4
- package/utils.js +4 -2
package/itemOf.js
CHANGED
|
@@ -20,7 +20,7 @@ module.exports = function(service, app) {
|
|
|
20
20
|
|
|
21
21
|
context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames)
|
|
22
22
|
addAccessControlParents(context)
|
|
23
|
-
defineIndexes(context.model, context.otherPropertyNames, context.others)
|
|
23
|
+
defineIndexes(context.model, context.otherPropertyNames.map(p => p[0].toLowerCase() + p.slice(1)), context.others)
|
|
24
24
|
|
|
25
25
|
if(config.sortBy) {
|
|
26
26
|
for(const sortFields of config.sortBy) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "^0.7.
|
|
24
|
+
"@live-change/framework": "^0.7.23",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "dc771ac085b8a54f18a38c65de923a1cdbdcdadc"
|
|
28
28
|
}
|
package/pluralRelationUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const App = require("@live-change/framework")
|
|
2
2
|
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App
|
|
3
|
-
const { extractIdParts,
|
|
3
|
+
const { extractIdParts, extractIdentifiers, extractObjectData, prepareAccessControl } = require("./utils.js")
|
|
4
4
|
|
|
5
5
|
const pluralize = require('pluralize')
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ function defineView(config, context) {
|
|
|
10
10
|
const indexName = 'by'+context.joinedOthersClassName
|
|
11
11
|
const viewProperties = {}
|
|
12
12
|
for (let i = 0; i < others.length; i++) {
|
|
13
|
-
viewProperties[otherPropertyNames[i]] = new PropertyDefinition({
|
|
13
|
+
viewProperties[otherPropertyNames[i][0].toLowerCase() + otherPropertyNames[i].slice(1) ] = new PropertyDefinition({
|
|
14
14
|
type: others[i],
|
|
15
15
|
validation: ['nonEmpty']
|
|
16
16
|
})
|
|
@@ -34,7 +34,7 @@ function defineView(config, context) {
|
|
|
34
34
|
accessControl: config.readAccessControl || config.writeAccessControl,
|
|
35
35
|
daoPath(properties, { client, context }) {
|
|
36
36
|
const idParts = extractIdParts(otherPropertyNames, properties)
|
|
37
|
-
const range = extractRange(properties)
|
|
37
|
+
const range = App.extractRange(properties)
|
|
38
38
|
const path = modelRuntime().sortedIndexRangePath(indexName, idParts, range)
|
|
39
39
|
return path
|
|
40
40
|
}
|
|
@@ -47,7 +47,7 @@ function defineCreateAction(config, context) {
|
|
|
47
47
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
|
|
48
48
|
} = context
|
|
49
49
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created'
|
|
50
|
-
const actionName = '
|
|
50
|
+
const actionName = 'create' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
51
51
|
const accessControl = config.createAccessControl || config.writeAccessControl
|
|
52
52
|
prepareAccessControl(accessControl, otherPropertyNames, others)
|
|
53
53
|
service.actions[actionName] = new ActionDefinition({
|
package/utils.js
CHANGED
|
@@ -52,18 +52,20 @@ function defineProperties(model, types, names) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function defineIndex(model, what, props) {
|
|
55
|
+
console.log("DEFINE INDEX", model.name, what, props)
|
|
55
56
|
model.indexes['by' + what] = new IndexDefinition({
|
|
56
57
|
property: props
|
|
57
58
|
})
|
|
58
59
|
}
|
|
59
60
|
function defineIndexes(model, props, types) {
|
|
61
|
+
console.log("DEFINE INDEXES", model.name, props, types)
|
|
60
62
|
const propCombinations = allCombinations(Object.keys(props))
|
|
61
63
|
for(const propCombination of propCombinations) {
|
|
62
64
|
const upperCaseProps = propCombination.map(id => {
|
|
63
65
|
const prop = props[id]
|
|
64
66
|
return prop[0].toUpperCase() + prop.slice(1)
|
|
65
67
|
})
|
|
66
|
-
defineIndex(model, upperCaseProps.join('And'), propCombination
|
|
68
|
+
defineIndex(model, upperCaseProps.join('And'), props[propCombination])
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -113,7 +115,7 @@ function processModelsAnnotation(service, app, annotation, multiple, cb) {
|
|
|
113
115
|
const writeableProperties = modelProperties || config.writeableProperties
|
|
114
116
|
//console.log("PPP", others)
|
|
115
117
|
const otherPropertyNames = what.map(other => other.name ? other.name : other)
|
|
116
|
-
const joinedOthersPropertyName = otherPropertyNames[0] +
|
|
118
|
+
const joinedOthersPropertyName = (otherPropertyNames[0][0].toLowerCase() + otherPropertyNames[0].slice(1)) +
|
|
117
119
|
(others.length > 1 ? ('And' + others.slice(1).join('And')) : '')
|
|
118
120
|
const joinedOthersClassName = others.join('And')
|
|
119
121
|
|