@live-change/relations-plugin 0.9.46 → 0.9.48

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.46",
3
+ "version": "0.9.48",
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.9.46",
25
+ "@live-change/framework": "^0.9.48",
26
26
  "pluralize": "^8.0.0"
27
27
  },
28
- "gitHead": "9d2fe9cbfb28f6cd389c8cbc5cf051f583f58e9e"
28
+ "gitHead": "87d012a548f6170fb78b565a111644eddc571a32"
29
29
  }
@@ -138,7 +138,7 @@ export function getSetFunction( validators, validationContext, config, context)
138
138
  otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others
139
139
  } = context
140
140
  const eventName = modelName + 'Set'
141
- async function execute(properties, { client, service }, emit) {
141
+ async function execute(properties, { client, service, trigger }, emit) {
142
142
  const idParts = extractIdParts(otherPropertyNames, properties)
143
143
  const id = idParts.length > 1 ? idParts.map(p => JSON.stringify(p)).join(':') : idParts[0]
144
144
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
package/utilsAny.js CHANGED
@@ -242,14 +242,19 @@ export function defineAnyTypeIndexes(config, context, useId = false) {
242
242
  function: async function(input, output, { tableName }) {
243
243
  const table = await input.table(tableName)
244
244
  await table.onChange(async (obj, oldObj) => {
245
- const id = obj?.id ?? oldObj?.id
245
+ const id = obj?.id ?? oldObj?.id
246
246
  const typeJson = id.slice(0, id.indexOf(':'))
247
- const type = JSON.parse(typeJson)
248
- const count = await table.count({ gte: typeJson+':', lte: type+'_\xFF\xFF\xFF\xFF', limit: 1 })
249
- if(count > 0) {
250
- await output.put({ id: type })
251
- } else {
252
- await output.delete({ id: type })
247
+ try {
248
+ const type = JSON.parse(typeJson)
249
+ const count = await table.count({ gte: typeJson+':', lte: type+'_\xFF\xFF\xFF\xFF', limit: 1 })
250
+ if(count > 0) {
251
+ await output.put({ id: type })
252
+ } else {
253
+ await output.delete({ id: type })
254
+ }
255
+ } catch(e) {
256
+ output.debug('typeJson', typeJson, 'id', id)
257
+ console.error("Error parsing typeJson", typeJson, e)
253
258
  }
254
259
  })
255
260
  },
@@ -269,12 +274,18 @@ export function defineAnyTypeIndexes(config, context, useId = false) {
269
274
  const index = await input.index(indexName)
270
275
  await index.onChange(async (obj, oldObj) => {
271
276
  const id = obj?.id ?? oldObj?.id
272
- const type = id.slice(0, id.indexOf(':'))
273
- const count = await index.count({ gte: type+':', lte: type+'_\xFF\xFF\xFF\xFF', limit: 1 })
274
- if(count > 0) {
275
- await output.put({ id: JSON.parse(type) })
276
- } else {
277
- await output.delete({ id: JSON.parse(type) })
277
+ const typeJson = id.slice(0, id.indexOf(':'))
278
+ try {
279
+ const type = JSON.parse(typeJson)
280
+ const count = await index.count({ gte: type+':', lte: typeJson+'_\xFF\xFF\xFF\xFF', limit: 1 })
281
+ if(count > 0) {
282
+ await output.put({ id: type })
283
+ } else {
284
+ await output.delete({ id: type })
285
+ }
286
+ } catch(e) {
287
+ output.debug('typeJson', typeJson, 'id', id)
288
+ console.error("Error parsing typeJson", typeJson, e)
278
289
  }
279
290
  })
280
291
  },