electrodb 2.3.3 → 2.3.5

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": "electrodb",
3
- "version": "2.3.3",
3
+ "version": "2.3.5",
4
4
  "description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/entity.js CHANGED
@@ -307,7 +307,7 @@ class Entity {
307
307
  return Promise.reject(err);
308
308
  } else {
309
309
  if (err.__isAWSError) {
310
- stackTrace.message = new e.ElectroError(e.ErrorCodes.AWSError, err.message).message;
310
+ stackTrace.message = new e.ElectroError(e.ErrorCodes.AWSError, `Error thrown by DynamoDB client: "${err.message}"`).message;
311
311
  return Promise.reject(stackTrace);
312
312
  } else if (err.isElectroError) {
313
313
  return Promise.reject(err);
@@ -1494,7 +1494,7 @@ class Entity {
1494
1494
  update.set(this.identifiers.entity, this.getName());
1495
1495
  update.set(this.identifiers.version, this.getVersion());
1496
1496
  for (const field of [...Object.keys(upsertAttributes), ...Object.keys(updatedKeys)]) {
1497
- const value = upsertAttributes[field] || updatedKeys[field];
1497
+ const value = u.getFirstDefined(upsertAttributes[field], updatedKeys[field]);
1498
1498
  if (!keyNames.includes(field)) {
1499
1499
  update.set(field, value);
1500
1500
  }
@@ -3023,7 +3023,7 @@ class Entity {
3023
3023
  if (sk.isCustom) {
3024
3024
  definitions[indexName].sk.push({name, label});
3025
3025
  } else {
3026
- definitions[indexName].sk.push({name, label: fromModel[name] || name});
3026
+ definitions[indexName].sk.push({name, label: u.getFirstDefined(fromModel[name], name) });
3027
3027
  }
3028
3028
  }
3029
3029
  }
package/src/errors.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  function getHelpLink(section) {
9
9
  section = section || "unknown-error-5001";
10
- return `https://github.com/tywalch/electrodb#${section}`;
10
+ return `https://electrodb.dev/en/reference/errors/#${section}`;
11
11
  }
12
12
 
13
13
  const ErrorCode = Symbol("error-code");
package/src/operations.js CHANGED
@@ -339,6 +339,9 @@ class AttributeOperationProxy {
339
339
 
340
340
  fromObject(operation, record) {
341
341
  for (let path of Object.keys(record)) {
342
+ if (record[path] === undefined) {
343
+ continue;
344
+ }
342
345
  const value = record[path];
343
346
  const parts = u.parseJSONPath(path);
344
347
  let attribute = this.attributes;
package/src/schema.js CHANGED
@@ -238,7 +238,7 @@ class Attribute {
238
238
 
239
239
  _makeApplyFixings({ prefix = "", postfix = "", casing= KeyCasing.none } = {}) {
240
240
  return (value) => {
241
- if ([AttributeTypes.string, AttributeTypes.enum].includes(this.type)) {
241
+ if ([AttributeTypes.string, AttributeTypes.enum].includes(this.type) && value !== undefined) {
242
242
  value = `${prefix}${value}${postfix}`;
243
243
  }
244
244
 
@@ -458,7 +458,7 @@ class Attribute {
458
458
  let reason = [];
459
459
  switch (this.type) {
460
460
  case AttributeTypes.enum:
461
- case AttributeTypes.enumSet:
461
+ // case AttributeTypes.enumSet:
462
462
  // isTyped = this.enumArray.every(enumValue => {
463
463
  // const val = Array.isArray(value) ? value : [value];
464
464
  // return val.includes(enumValue);
package/src/service.js CHANGED
@@ -155,7 +155,7 @@ class Service {
155
155
  default:
156
156
  /** start beta/v1 condition **/
157
157
  if (modelVersion !== this._modelVersion) {
158
- throw new e.ElectroError(e.ErrorCodes.InvalidJoin, "Invalid instance: Valid instances to join include Models and Entity instances. Additionally, all models must be in the same format (v1 vs beta). Review https://github.com/tywalch/electrodb#version-v1-migration for more detail.");
158
+ throw new e.ElectroError(e.ErrorCodes.InvalidJoin, "Invalid instance: Valid instances to join include Models and Entity instances.");
159
159
  } else if (modelVersion === ModelVersions.beta) {
160
160
  instance = applyBetaModelOverrides(instance, this._modelOverrides);
161
161
  } else {
package/src/util.js CHANGED
@@ -233,6 +233,10 @@ function shiftSortOrder(str = '', codePoint) {
233
233
  return newString;
234
234
  }
235
235
 
236
+ function getFirstDefined(...params) {
237
+ return params.find(val => val !== undefined);
238
+ }
239
+
236
240
  module.exports = {
237
241
  getUnique,
238
242
  batchItems,
@@ -241,6 +245,7 @@ module.exports = {
241
245
  removeFixings,
242
246
  parseJSONPath,
243
247
  shiftSortOrder,
248
+ getFirstDefined,
244
249
  getInstanceType,
245
250
  getModelVersion,
246
251
  formatKeyCasing,