@onehat/data 1.20.9 → 1.21.1

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.
Files changed (51) hide show
  1. package/cypress/downloads/downloads.html +0 -0
  2. package/cypress/e2e/Entity.cy.js +2 -2
  3. package/cypress/e2e/Property/Base64.cy.js +37 -3
  4. package/cypress/e2e/Property/Boolean.cy.js +30 -0
  5. package/cypress/e2e/Property/Currency.cy.js +41 -0
  6. package/cypress/e2e/Property/Date.cy.js +33 -0
  7. package/cypress/e2e/Property/DateTime.cy.js +33 -0
  8. package/cypress/e2e/Property/Float.cy.js +31 -0
  9. package/cypress/e2e/Property/Integer.cy.js +31 -0
  10. package/cypress/e2e/Property/Json.cy.js +29 -0
  11. package/cypress/e2e/Property/PercentInt.cy.js +32 -0
  12. package/cypress/e2e/Property/Property.cy.js +29 -0
  13. package/cypress/e2e/Property/Time.cy.js +33 -0
  14. package/cypress/e2e/Repository/Repository.cy.js +23 -16
  15. package/cypress/e2e/Schema.cy.js +2 -2
  16. package/package.json +1 -1
  17. package/src/Integration/Browser/Repository/Cookie.js +4 -4
  18. package/src/Integration/Browser/Repository/IndexedDB.js +4 -4
  19. package/src/Integration/Browser/Repository/LocalStorage.js +4 -4
  20. package/src/Integration/Browser/Repository/SecureLocalStorage.js +2 -2
  21. package/src/Integration/Browser/Repository/SecureSessionStorage.js +2 -2
  22. package/src/Integration/Browser/Repository/SessionStorage.js +4 -4
  23. package/src/Integration/ReactNative/Repository/AsyncStorage.js +8 -8
  24. package/src/Integration/ReactNative/Repository/SecureStore.js +4 -4
  25. package/src/Property/Base64.js +21 -11
  26. package/src/Property/Boolean.js +20 -12
  27. package/src/Property/Currency.js +30 -21
  28. package/src/Property/Date.js +23 -14
  29. package/src/Property/DateTime.js +18 -9
  30. package/src/Property/File.js +0 -4
  31. package/src/Property/Float.js +19 -10
  32. package/src/Property/Integer.js +19 -10
  33. package/src/Property/Json.js +22 -13
  34. package/src/Property/Percent.js +2 -2
  35. package/src/Property/PercentInt.js +16 -7
  36. package/src/Property/Property.js +150 -140
  37. package/src/Property/String.js +2 -7
  38. package/src/Property/Time.js +17 -8
  39. package/src/Property/Uuid.js +3 -8
  40. package/src/Property/index.js +2 -0
  41. package/src/Repository/Ajax.js +33 -28
  42. package/src/Repository/LocalFromRemote/Command.js +5 -5
  43. package/src/Repository/LocalFromRemote/CommandRepository.js +1 -1
  44. package/src/Repository/LocalFromRemote/LocalFromRemote.js +18 -17
  45. package/src/Repository/Memory.js +22 -21
  46. package/src/Repository/Null.js +5 -5
  47. package/src/Repository/Offline.js +17 -16
  48. package/src/Repository/OneBuild.js +57 -42
  49. package/src/Repository/OneBuild2.js +16 -10
  50. package/src/Repository/Repository.js +105 -102
  51. package/src/Schema/Schema.js +9 -6
@@ -274,6 +274,12 @@ export default class Schema extends EventEmitter {
274
274
  return;
275
275
  }
276
276
 
277
+ // In here, we're looking for default values for each property
278
+ // based entirely on the property definition or property type.
279
+ // The property has not been intantiatiated in either case,
280
+ // so we don't have access to the entity's data.
281
+ // Unfortunately, defaults get applied at instantiation time...
282
+
277
283
  const found = {};
278
284
  _.each(this.model.properties, (property) => {
279
285
  let defaultValue = null;
@@ -282,14 +288,11 @@ export default class Schema extends EventEmitter {
282
288
  } else {
283
289
  // Look in the property types for a default value
284
290
  let propertyType = PropertyTypes[property.type];
285
- if (!_.isNil(propertyType)) {
286
- defaultValue = propertyType.defaultValue;
287
- } else {
291
+ if (!propertyType) {
288
292
  propertyType = PropertyTypes['string'];
289
- if (!_.isNil(propertyType.defaultValue)) {
290
- defaultValue = propertyType.defaultValue;
291
- }
292
293
  }
294
+ const staticDefaults = propertyType.getStaticDefaults();
295
+ defaultValue = staticDefaults.defaultValue;
293
296
  }
294
297
  if (_.isFunction(defaultValue)) {
295
298
  defaultValue = defaultValue();