@live-change/relations-plugin 0.8.32 → 0.8.33

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineProperties, defineIndexes,
3
3
  processModelsAnnotation, addAccessControlParents,
4
- defineDeleteByOwnerEvents, defineParentDeleteTriggers, defineParentCopyTriggers, defineAuthorProperties
4
+ defineDeleteByOwnerEvents, defineParentDeleteTriggers, defineParentCopyTriggers
5
5
  } from './utils.js'
6
6
 
7
7
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.8.32",
3
+ "version": "0.8.33",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.8.32",
25
+ "@live-change/framework": "^0.8.33",
26
26
  "pluralize": "^8.0.0"
27
27
  },
28
- "gitHead": "9ea7767670a99404794087726223064c45d798d3"
28
+ "gitHead": "98ff6f9c09e5fc1f408010df6cc8038eff571276"
29
29
  }
@@ -139,6 +139,8 @@ function getUpdateFunction( validators, validationContext, config, context) {
139
139
  if(!entity) throw 'not_found'
140
140
  const entityTypeAndIdParts = extractTypeAndIdParts(otherPropertyNames, entity)
141
141
  const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
142
+ console.log("UPDATE MATCH", entityTypeAndIdParts, '===', typeAndIdParts,
143
+ '=>', JSON.stringify(entityTypeAndIdParts) === JSON.stringify(typeAndIdParts))
142
144
  if(JSON.stringify(entityTypeAndIdParts) !== JSON.stringify(typeAndIdParts)) {
143
145
  throw 'not_authorized'
144
146
  }
package/saveAuthor.js CHANGED
@@ -1,4 +1,36 @@
1
- import { defineAuthorProperties } from './utils.js'
1
+ import {
2
+ PropertyDefinition
3
+ } from "@live-change/framework"
4
+
5
+ export function defineAuthorProperties() {
6
+ return {
7
+ authorType: new PropertyDefinition({
8
+ type: String,
9
+ validation: ['nonEmpty'],
10
+ default: (_props, context) => context.client.user ? 'user_User' : 'session_Session'
11
+ }),
12
+ author: new PropertyDefinition({
13
+ type: String,
14
+ validation: ['nonEmpty'],
15
+ default: (_props, context) => context.client.user ? context.client.user : context.client.session
16
+ })
17
+ }
18
+ }
19
+
20
+ export function defineUpdaterProperties() {
21
+ return {
22
+ updaterType: new PropertyDefinition({
23
+ type: String,
24
+ validation: ['nonEmpty'],
25
+ default: (_props, context) => context.client.user ? 'user_User' : 'session_Session'
26
+ }),
27
+ updater: new PropertyDefinition({
28
+ type: String,
29
+ validation: ['nonEmpty'],
30
+ default: (_props, context) => context.client.user ? context.client.user : context.client.session
31
+ })
32
+ }
33
+ }
2
34
 
3
35
  export default function(service, app) {
4
36
  for(let modelName in service.models) {
@@ -9,5 +41,11 @@ export default function(service, app) {
9
41
  ...defineAuthorProperties()
10
42
  }
11
43
  }
44
+ if(model.saveUpdater) {
45
+ model.properties = {
46
+ ...model.properties,
47
+ ...defineUpdaterProperties()
48
+ }
49
+ }
12
50
  }
13
51
  }
package/utils.js CHANGED
@@ -41,21 +41,6 @@ export function defineProperties(model, types, names) {
41
41
  return identifiers
42
42
  }
43
43
 
44
- export function defineAuthorProperties() {
45
- return {
46
- authorType: new PropertyDefinition({
47
- type: String,
48
- validation: ['nonEmpty'],
49
- default: (_props, context) => context.client.user ? 'user_User' : 'session_Session'
50
- }),
51
- author: new PropertyDefinition({
52
- type: String,
53
- validation: ['nonEmpty'],
54
- default: (_props, context) => context.client.user ? context.client.user : context.client.session
55
- })
56
- }
57
- }
58
-
59
44
  export function defineIndex(model, what, props) {
60
45
  console.log("DEFINE INDEX", model.name, what, props)
61
46
  model.indexes['by' + what] = new IndexDefinition({