@live-change/relations-plugin 0.9.194 → 0.9.195

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/relations-plugin",
3
- "version": "0.9.194",
3
+ "version": "0.9.195",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.194",
25
+ "@live-change/framework": "^0.9.195",
26
26
  "pluralize": "^8.0.0"
27
27
  },
28
28
  "devDependencies": {
@@ -30,5 +30,5 @@
30
30
  "typedoc-plugin-markdown": "^4.6.3",
31
31
  "typedoc-plugin-rename-defaults": "^0.7.3"
32
32
  },
33
- "gitHead": "40d47cf397b45ca1f1fa888d4d85727376b2b0c0"
33
+ "gitHead": "9f61eddae56ddd89aba20988b8e208d948728496"
34
34
  }
@@ -161,7 +161,7 @@ export function getCreateFunction( validators, validationContext, config, contex
161
161
  async function execute(properties, { client, service, trigger }, emit) {
162
162
  const id = properties[modelPropertyName] || app.generateUid()
163
163
  const entity = await modelRuntime().get(id)
164
- if(entity) throw 'exists'
164
+ if(entity) throw app.logicError("exists")
165
165
  const data = extractObjectData(writeableProperties, properties,
166
166
  App.computeDefaults(model, properties, { client, service } ))
167
167
 
@@ -231,7 +231,7 @@ export function getUpdateFunction( validators, validationContext, config, contex
231
231
  async function execute(properties, { client, service, trigger }, emit) {
232
232
  const id = properties[modelPropertyName]
233
233
  const entity = await modelRuntime().get(id)
234
- if(!entity) throw 'not_found'
234
+ if(!entity) throw app.logicError("not_found")
235
235
  const data = App.utils.mergeDeep({},
236
236
  extractObjectData(writeableProperties, properties, entity),
237
237
  App.computeUpdates(model, { ...entity, ...properties }, { client, service })
@@ -103,7 +103,7 @@ function getCreateFunction( validators, validationContext, config, context) {
103
103
  return async function execute(properties, { client, service, trigger }, emit) {
104
104
  const id = properties[modelPropertyName] || app.generateUid()
105
105
  const entity = await modelRuntime().get(id)
106
- if(entity) throw 'exists'
106
+ if(entity) throw app.logicError("exists")
107
107
  const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
108
108
  const data = extractObjectData(writeableProperties, properties,
109
109
  App.computeDefaults(model, properties, { client, service } ))
@@ -182,13 +182,13 @@ function getUpdateFunction( validators, validationContext, config, context) {
182
182
  const id = properties[modelPropertyName]
183
183
  if(!id) throw new Error('no_id')
184
184
  const entity = await modelRuntime().get(id)
185
- if(!entity) throw 'not_found'
185
+ if(!entity) throw app.logicError("not_found")
186
186
  const entityTypeAndIdParts = extractTypeAndIdParts(otherPropertyNames, entity)
187
187
  const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
188
188
  /* console.log("UPDATE MATCH", entityTypeAndIdParts, '===', typeAndIdParts,
189
189
  '=>', JSON.stringify(entityTypeAndIdParts) === JSON.stringify(typeAndIdParts)) */
190
190
  if(JSON.stringify(entityTypeAndIdParts) !== JSON.stringify(typeAndIdParts)) {
191
- throw 'not_authorized'
191
+ throw app.logicError("not_authorized")
192
192
  }
193
193
  const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
194
194
  const data = App.utils.mergeDeep({},
@@ -291,11 +291,11 @@ function getDeleteFunction(config, context) {
291
291
  return async function execute(properties, { client, service, trigger }, emit) {
292
292
  const id = properties[modelPropertyName]
293
293
  const entity = await modelRuntime().get(id)
294
- if(!entity) throw 'not_found'
294
+ if(!entity) throw app.logicError("not_found")
295
295
  const entityTypeAndIdParts = extractTypeAndIdParts(otherPropertyNames, entity)
296
296
  const typeAndIdParts = extractTypeAndIdParts(otherPropertyNames, properties)
297
297
  if(JSON.stringify(entityTypeAndIdParts) !== JSON.stringify(typeAndIdParts)) {
298
- throw 'not_authorized'
298
+ throw app.logicError("not_authorized")
299
299
  }
300
300
  await fireChangeTriggers(context, objectType, extractIdentifiers(otherPropertyNames, entity), id,
301
301
  extractObjectData(writeableProperties, entity, {}), null, trigger)
@@ -98,7 +98,7 @@ function getCreateFunction( validators, validationContext, config, context) {
98
98
  return async function execute(properties, { client, service, trigger }, emit) {
99
99
  const id = properties[modelPropertyName] || app.generateUid()
100
100
  const entity = await modelRuntime().get(id)
101
- if(entity) throw 'exists'
101
+ if(entity) throw app.logicError("exists")
102
102
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
103
103
  const data = extractObjectData(writeableProperties, properties,
104
104
  App.computeDefaults(model, properties, { client, service } ))
@@ -173,11 +173,11 @@ function getUpdateFunction( validators, validationContext, config, context) {
173
173
  return async function execute(properties, { client, service, trigger }, emit) {
174
174
  const id = properties[modelPropertyName]
175
175
  const entity = await modelRuntime().get(id)
176
- if(!entity) throw 'not_found'
176
+ if(!entity) throw app.logicError("not_found")
177
177
  const entityIdParts = extractIdParts(otherPropertyNames, entity)
178
178
  const idParts = extractIdParts(otherPropertyNames, properties)
179
179
  if(JSON.stringify(entityIdParts) !== JSON.stringify(idParts)) {
180
- throw 'not_authorized'
180
+ throw app.logicError("not_authorized")
181
181
  }
182
182
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
183
183
  const data = App.utils.mergeDeep({},
@@ -267,11 +267,11 @@ function getDeleteFunction( validators, validationContext, config, context) {
267
267
  return async function execute(properties, { client, service, trigger }, emit) {
268
268
  const id = properties[modelPropertyName]
269
269
  const entity = await modelRuntime().get(id)
270
- if(!entity) throw 'not_found'
270
+ if(!entity) throw app.logicError("not_found")
271
271
  const entityIdParts = extractIdParts(otherPropertyNames, entity)
272
272
  const idParts = extractIdParts(otherPropertyNames, properties)
273
273
  if(JSON.stringify(entityIdParts) !== JSON.stringify(idParts)) {
274
- throw 'not_authorized'
274
+ throw app.logicError("not_authorized")
275
275
  }
276
276
  const identifiers = extractIdentifiers(otherPropertyNames, entity)
277
277
  await fireChangeTriggers(context, objectType, identifiers, id,