@rolster/vinegar 2.3.4 → 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/dist/cjs/index.js CHANGED
@@ -69,14 +69,17 @@ function fromPromise(value) {
69
69
  return value instanceof Promise ? value : Promise.resolve(value);
70
70
  }
71
71
 
72
+ function getRelationName(entity) {
73
+ return `${entity.constructor.name}|${entity.uuid}`;
74
+ }
72
75
  function itIsModelHidden(model) {
73
76
  return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;
74
77
  }
75
78
  class AbstractEntityManager {
76
79
  }
77
80
  class EntityManager {
78
- constructor(_dataSource) {
79
- this._dataSource = _dataSource;
81
+ constructor(dataSource) {
82
+ this.dataSource = dataSource;
80
83
  this.links = [];
81
84
  this.refreshs = [];
82
85
  this.syncs = [];
@@ -85,16 +88,18 @@ class EntityManager {
85
88
  this.procedures = [];
86
89
  this.relations = new Map();
87
90
  }
88
- persist(options) {
89
- this.links.push(options);
91
+ persist(link) {
92
+ this.links.push(link);
90
93
  }
91
- refresh(options) {
92
- options.relationable && this.relation(options.entity, options.model);
93
- this.refreshs.push(options);
94
+ refresh(refresh) {
95
+ const { entity, model, relationable } = refresh;
96
+ relationable && this.relation(entity, model);
97
+ this.refreshs.push(refresh);
94
98
  }
95
- sync(options) {
96
- options.relationable && this.relation(options.entity, options.model);
97
- this.syncs.push(options);
99
+ sync(sync) {
100
+ const { entity, model, relationable } = sync;
101
+ relationable && this.relation(entity, model);
102
+ this.syncs.push(sync);
98
103
  }
99
104
  destroy(entity) {
100
105
  this.select(entity).present((model) => {
@@ -107,7 +112,7 @@ class EntityManager {
107
112
  this.procedures.push(procedure);
108
113
  }
109
114
  relation(entity, model) {
110
- this.relations.set(entity.uuid, model);
115
+ this.relations.set(getRelationName(entity), model);
111
116
  }
112
117
  link(entity, model) {
113
118
  this.relation(entity, model);
@@ -142,11 +147,11 @@ class EntityManager {
142
147
  persistAll() {
143
148
  return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {
144
149
  link.relationable && this.relation(link.entity, model);
145
- return this._dataSource.insert(model);
150
+ return this.dataSource.insert(model);
146
151
  })));
147
152
  }
148
153
  refreshAll() {
149
- return Promise.all(this.refreshs.map((refresh) => this._dataSource.refresh(refresh)));
154
+ return Promise.all(this.refreshs.map((refresh) => this.dataSource.refresh(refresh)));
150
155
  }
151
156
  syncAll() {
152
157
  return Promise.all(this.syncs
@@ -157,17 +162,17 @@ class EntityManager {
157
162
  return syncs;
158
163
  }, [])
159
164
  .map(([model, dirty]) => {
160
- return this._dataSource.update(model, dirty);
165
+ return this.dataSource.update(model, dirty);
161
166
  }));
162
167
  }
163
168
  destroyAll() {
164
- return Promise.all(this.destroys.map((destroy) => this._dataSource.delete(destroy)));
169
+ return Promise.all(this.destroys.map((destroy) => this.dataSource.delete(destroy)));
165
170
  }
166
171
  hiddenAll() {
167
- return Promise.all(this.hiddens.map((hidden) => this._dataSource.hidden(hidden)));
172
+ return Promise.all(this.hiddens.map((hidden) => this.dataSource.hidden(hidden)));
168
173
  }
169
174
  procedureAll() {
170
- return Promise.all(this.procedures.map((procedure) => this._dataSource.procedure(procedure)));
175
+ return Promise.all(this.procedures.map((procedure) => this.dataSource.procedure(procedure)));
171
176
  }
172
177
  }
173
178
 
@@ -200,7 +205,7 @@ class EntitySync {
200
205
  this.entity = entity;
201
206
  this.model = model;
202
207
  this.relationable = relationable;
203
- this._dirty = this.createDirtyFromModel(model);
208
+ this.dirty = this.createDirtyFromModel(model);
204
209
  }
205
210
  verify(manager) {
206
211
  this.sync(manager);
@@ -217,7 +222,7 @@ class EntitySync {
217
222
  const _modelDirty = this.createDirtyFromModel(this.model);
218
223
  const _dirty = {};
219
224
  Object.entries(_modelDirty).forEach(([key, value]) => {
220
- if (_modelDirty[key] !== this._dirty[key]) {
225
+ if (_modelDirty[key] !== this.dirty[key]) {
221
226
  _dirty[key] = value;
222
227
  }
223
228
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../esm/database.js","../esm/datasource.js","../../node_modules/@rolster/commons/dist/esm/helpers.js","../../node_modules/@rolster/commons/dist/esm/optional.js","../../node_modules/@rolster/commons/dist/esm/promises.js","../esm/entity-manager.js","../esm/entity.js","../esm/persistent-unit.js","../esm/procedure.js","../esm/repository.js","../esm/result.js"],"sourcesContent":["export class AbstractEntityDatabase {\n}\n//# sourceMappingURL=database.js.map","export class AbstractEntityDataSource {\n}\n//# sourceMappingURL=datasource.js.map","const PRIMITIVES = [Date, RegExp, Function, String, Boolean, Number];\nconst SLICE_SIZE = 512;\nconst FALSY_VALUE = ['false', 'undefined', '0', 0];\nconst prototypeToString = Object.prototype.toString;\nfunction _clone(object, caches, replaces, ignoreKeysRegex) {\n if (typeof object !== 'object') {\n return object;\n }\n if (prototypeToString.call(object) === '[object Object]') {\n const [_object] = caches.filter((_object) => _object === object);\n /* istanbul ignore if */\n if (_object) {\n return _object;\n }\n caches.push(object);\n }\n const ConstructorObject = Object.getPrototypeOf(object).constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n if (!ignoreKeysRegex?.test(key)) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\n }\n }\n return _object;\n}\nexport function itIsDefined(object) {\n return typeof object !== 'undefined' && object !== null;\n}\nexport function itIsUndefined(object) {\n return !itIsDefined(object);\n}\nexport function parseBoolean(value) {\n return !(itIsUndefined(value) ||\n value === false ||\n FALSY_VALUE.includes(value));\n}\nexport function parse(value) {\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nexport function evalValueOrFunction(value) {\n return typeof value === 'function' ? value() : value;\n}\nexport function clone(object, replaces, ignoreKeysRegex) {\n return _clone(object, [], replaces, ignoreKeysRegex);\n}\nexport function freeze(object) {\n for (const prop in object) {\n const value = object[prop];\n if (typeof value === 'object' && !Object.isFrozen(value)) {\n freeze(value);\n }\n }\n return Object.freeze(object);\n}\nexport function callback(call, ...args) {\n return typeof call !== 'function' ? undefined : call.apply(call, args);\n}\nfunction normalizeValue(value) {\n return typeof value === 'object'\n ? Array.isArray(value)\n ? value.map((value) => normalizeValue(value))\n : normalizeJson(value)\n : value;\n}\nexport function normalizeJson(payload) {\n return Object.entries(payload).reduce((result, [key, value]) => {\n if (itIsDefined(value)) {\n result[key] = normalizeValue(value);\n }\n return result;\n }, {});\n}\n/* istanbul ignore next */\nexport function base64ToBlob(data64, mimeType) {\n const result64 = data64.replace(/^[^,]+,/, '').replace(/\\s/g, '');\n const byteCharacters = window.atob(result64);\n const byteArrays = [];\n for (let offset = 0; offset < byteCharacters.length; offset += SLICE_SIZE) {\n const slice = byteCharacters.slice(offset, offset + SLICE_SIZE);\n const byteNumbers = new Array(slice.length);\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i);\n }\n const byteArray = new Uint8Array(byteNumbers);\n byteArrays.push(byteArray);\n }\n return new Blob(byteArrays, { type: mimeType });\n}\n//# sourceMappingURL=helpers.js.map","import { itIsDefined } from './helpers';\nexport class Optional {\n constructor(value) {\n this.value = value;\n }\n present(callback) {\n return this.isPresent() ? callback(this.get()) : undefined;\n }\n empty(callback) {\n return this.isEmpty() ? callback() : undefined;\n }\n when(present, empty) {\n return this.isPresent() ? present(this.get()) : empty();\n }\n static build(value) {\n return itIsDefined(value) ? this.of(value) : this.empty();\n }\n static of(value) {\n if (itIsDefined(value)) {\n return new PresentOptional(value);\n }\n throw new Error('The passed value was null or undefined.');\n }\n static empty() {\n return new EmptyOptional();\n }\n}\nclass PresentOptional extends Optional {\n constructor(presentValue) {\n super(presentValue);\n this.presentValue = presentValue;\n }\n isPresent() {\n return true;\n }\n isEmpty() {\n return false;\n }\n get() {\n return this.presentValue;\n }\n}\nclass EmptyOptional extends Optional {\n isPresent() {\n return false;\n }\n isEmpty() {\n return true;\n }\n get() {\n throw new Error('The optional is not present.');\n }\n}\n//# sourceMappingURL=optional.js.map","import { itIsDefined } from './helpers';\nexport function fromPromise(value) {\n return value instanceof Promise ? value : Promise.resolve(value);\n}\nexport function resolvePromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n throw err;\n });\n}\nexport function voidPromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nexport function catchPromise(promise, catchError) {\n return promise.catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nfunction zipResolveCallbacks(options) {\n const { callbacks, catchError, index, resolve, result } = options;\n if (index === callbacks.length) {\n return resolve(result);\n }\n const promise = callbacks[index];\n new Promise(() => {\n promise()\n .then((value) => {\n result.push(value);\n return zipResolveCallbacks({\n ...options,\n index: index + 1,\n result\n });\n })\n .catch((err) => {\n return catchError(err);\n });\n });\n}\nexport function zipPromise(callbacks) {\n const result = [];\n return new Promise((resolve, reject) => {\n zipResolveCallbacks({\n callbacks,\n catchError: (err) => {\n reject(err);\n },\n index: 0,\n resolve: (result) => {\n resolve(result);\n },\n result\n });\n });\n}\nexport function securePromise(callback, catchError) {\n let promise$ = undefined;\n function itIsInstanced() {\n return itIsDefined(promise$);\n }\n function resolve() {\n if (!promise$) {\n promise$ = callback().catch((err) => {\n const errorValue = catchError && catchError(err);\n reset();\n if (errorValue) {\n return errorValue;\n }\n throw err;\n });\n }\n return promise$;\n }\n function reset() {\n promise$ = undefined;\n }\n function refresh() {\n promise$ = undefined;\n return resolve();\n }\n return { itIsInstanced, refresh, reset, resolve };\n}\n//# sourceMappingURL=promises.js.map","import { Optional, fromPromise } from '@rolster/commons';\nfunction itIsModelHidden(model) {\n return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;\n}\nexport class AbstractEntityManager {\n}\nexport class EntityManager {\n constructor(_dataSource) {\n this._dataSource = _dataSource;\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n this.relations = new Map();\n }\n persist(options) {\n this.links.push(options);\n }\n refresh(options) {\n options.relationable && this.relation(options.entity, options.model);\n this.refreshs.push(options);\n }\n sync(options) {\n options.relationable && this.relation(options.entity, options.model);\n this.syncs.push(options);\n }\n destroy(entity) {\n this.select(entity).present((model) => {\n itIsModelHidden(model)\n ? this.hiddens.push(model)\n : this.destroys.push(model);\n });\n }\n procedure(procedure) {\n this.procedures.push(procedure);\n }\n relation(entity, model) {\n this.relations.set(entity.uuid, model);\n }\n link(entity, model) {\n this.relation(entity, model);\n return entity;\n }\n select(entity) {\n return Optional.build(this.relations.has(entity.uuid)\n ? this.relations.get(entity.uuid)\n : undefined);\n }\n async flush() {\n const results = [\n ...(await this.persistAll()),\n ...(await this.refreshAll()),\n ...(await this.syncAll()),\n ...(await this.hiddenAll()),\n ...(await this.destroyAll()),\n ...(await this.procedureAll())\n ];\n this.dispose();\n return results;\n }\n dispose() {\n this.relations.clear();\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n }\n persistAll() {\n return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {\n link.relationable && this.relation(link.entity, model);\n return this._dataSource.insert(model);\n })));\n }\n refreshAll() {\n return Promise.all(this.refreshs.map((refresh) => this._dataSource.refresh(refresh)));\n }\n syncAll() {\n return Promise.all(this.syncs\n .filter(({ model }) => !this.destroys.includes(model))\n .reduce((syncs, sync) => {\n const dirty = sync.verify(this);\n dirty && syncs.push([sync.model, dirty]);\n return syncs;\n }, [])\n .map(([model, dirty]) => {\n return this._dataSource.update(model, dirty);\n }));\n }\n destroyAll() {\n return Promise.all(this.destroys.map((destroy) => this._dataSource.delete(destroy)));\n }\n hiddenAll() {\n return Promise.all(this.hiddens.map((hidden) => this._dataSource.hidden(hidden)));\n }\n procedureAll() {\n return Promise.all(this.procedures.map((procedure) => this._dataSource.procedure(procedure)));\n }\n}\n//# sourceMappingURL=entity-manager.js.map","function itIsModelEditable(model) {\n return typeof model === 'object' && 'updatedAt' in model;\n}\nexport class Entity {\n constructor(uuid) {\n this.uuid = uuid;\n }\n}\nexport class EntityLink {\n constructor(entity, relationable = true) {\n this.entity = entity;\n this.relationable = relationable;\n }\n}\nexport class EntityRefresh {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n }\n async execute() {\n this.refresh();\n }\n}\nexport class EntitySync {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n this._dirty = this.createDirtyFromModel(model);\n }\n verify(manager) {\n this.sync(manager);\n return this.createDirty();\n }\n createDirtyFromModel(model) {\n const dirty = {};\n Object.entries(model).forEach(([key, value]) => {\n dirty[key] = value;\n });\n return dirty;\n }\n createDirty() {\n const _modelDirty = this.createDirtyFromModel(this.model);\n const _dirty = {};\n Object.entries(_modelDirty).forEach(([key, value]) => {\n if (_modelDirty[key] !== this._dirty[key]) {\n _dirty[key] = value;\n }\n });\n const requiredUpdate = Object.keys(_dirty).length > 0;\n if (requiredUpdate && itIsModelEditable(this.model)) {\n _dirty['updatedAt'] = new Date();\n }\n return requiredUpdate ? _dirty : undefined;\n }\n}\n//# sourceMappingURL=entity.js.map","export class AbstractPersistentUnit {\n}\n//# sourceMappingURL=persistent-unit.js.map","export class AbstractProcedure {\n}\n//# sourceMappingURL=procedure.js.map","export class AbstractRepository {\n}\n//# sourceMappingURL=repository.js.map","export class PersistentUnitResult {\n constructor(code, error, model) {\n this.code = code;\n this.error = error;\n this.model = model;\n }\n}\n//# sourceMappingURL=result.js.map"],"names":[],"mappings":";;;;AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC6BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC/BO,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,CAAC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CAAC,CAAC;AAClE,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC9D,YAAY,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;AACvD,gBAAgB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACpC,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,QAAQ,IAAI,cAAc,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AAC7D,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AAC7C,SAAS;AACT,QAAQ,OAAO,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AACnD,KAAK;AACL;;ACxDO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,iBAAiB,CAAC;AAC/B;;ACDO,MAAM,kBAAkB,CAAC;AAChC;;ACDO,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;AACpC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACzB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../esm/database.js","../esm/datasource.js","../../node_modules/@rolster/commons/dist/esm/helpers.js","../../node_modules/@rolster/commons/dist/esm/optional.js","../../node_modules/@rolster/commons/dist/esm/promises.js","../esm/entity-manager.js","../esm/entity.js","../esm/persistent-unit.js","../esm/procedure.js","../esm/repository.js","../esm/result.js"],"sourcesContent":["export class AbstractEntityDatabase {\n}\n//# sourceMappingURL=database.js.map","export class AbstractEntityDataSource {\n}\n//# sourceMappingURL=datasource.js.map","const PRIMITIVES = [Date, RegExp, Function, String, Boolean, Number];\nconst SLICE_SIZE = 512;\nconst FALSY_VALUE = ['false', 'undefined', '0', 0];\nconst prototypeToString = Object.prototype.toString;\nfunction _clone(object, caches, replaces, ignoreKeysRegex) {\n if (typeof object !== 'object') {\n return object;\n }\n if (prototypeToString.call(object) === '[object Object]') {\n const [_object] = caches.filter((_object) => _object === object);\n /* istanbul ignore if */\n if (_object) {\n return _object;\n }\n caches.push(object);\n }\n const ConstructorObject = Object.getPrototypeOf(object).constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n if (!ignoreKeysRegex?.test(key)) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\n }\n }\n return _object;\n}\nexport function itIsDefined(object) {\n return typeof object !== 'undefined' && object !== null;\n}\nexport function itIsUndefined(object) {\n return !itIsDefined(object);\n}\nexport function parseBoolean(value) {\n return !(itIsUndefined(value) ||\n value === false ||\n FALSY_VALUE.includes(value));\n}\nexport function parse(value) {\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nexport function evalValueOrFunction(value) {\n return typeof value === 'function' ? value() : value;\n}\nexport function clone(object, replaces, ignoreKeysRegex) {\n return _clone(object, [], replaces, ignoreKeysRegex);\n}\nexport function freeze(object) {\n for (const prop in object) {\n const value = object[prop];\n if (typeof value === 'object' && !Object.isFrozen(value)) {\n freeze(value);\n }\n }\n return Object.freeze(object);\n}\nexport function callback(call, ...args) {\n return typeof call !== 'function' ? undefined : call.apply(call, args);\n}\nfunction normalizeValue(value) {\n return typeof value === 'object'\n ? Array.isArray(value)\n ? value.map((value) => normalizeValue(value))\n : normalizeJson(value)\n : value;\n}\nexport function normalizeJson(payload) {\n return Object.entries(payload).reduce((result, [key, value]) => {\n if (itIsDefined(value)) {\n result[key] = normalizeValue(value);\n }\n return result;\n }, {});\n}\n/* istanbul ignore next */\nexport function base64ToBlob(data64, mimeType) {\n const result64 = data64.replace(/^[^,]+,/, '').replace(/\\s/g, '');\n const byteCharacters = window.atob(result64);\n const byteArrays = [];\n for (let offset = 0; offset < byteCharacters.length; offset += SLICE_SIZE) {\n const slice = byteCharacters.slice(offset, offset + SLICE_SIZE);\n const byteNumbers = new Array(slice.length);\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i);\n }\n const byteArray = new Uint8Array(byteNumbers);\n byteArrays.push(byteArray);\n }\n return new Blob(byteArrays, { type: mimeType });\n}\n//# sourceMappingURL=helpers.js.map","import { itIsDefined } from './helpers';\nexport class Optional {\n constructor(value) {\n this.value = value;\n }\n present(callback) {\n return this.isPresent() ? callback(this.get()) : undefined;\n }\n empty(callback) {\n return this.isEmpty() ? callback() : undefined;\n }\n when(present, empty) {\n return this.isPresent() ? present(this.get()) : empty();\n }\n static build(value) {\n return itIsDefined(value) ? this.of(value) : this.empty();\n }\n static of(value) {\n if (itIsDefined(value)) {\n return new PresentOptional(value);\n }\n throw new Error('The passed value was null or undefined.');\n }\n static empty() {\n return new EmptyOptional();\n }\n}\nclass PresentOptional extends Optional {\n constructor(presentValue) {\n super(presentValue);\n this.presentValue = presentValue;\n }\n isPresent() {\n return true;\n }\n isEmpty() {\n return false;\n }\n get() {\n return this.presentValue;\n }\n}\nclass EmptyOptional extends Optional {\n isPresent() {\n return false;\n }\n isEmpty() {\n return true;\n }\n get() {\n throw new Error('The optional is not present.');\n }\n}\n//# sourceMappingURL=optional.js.map","import { itIsDefined } from './helpers';\nexport function fromPromise(value) {\n return value instanceof Promise ? value : Promise.resolve(value);\n}\nexport function resolvePromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n throw err;\n });\n}\nexport function voidPromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nexport function catchPromise(promise, catchError) {\n return promise.catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nfunction zipResolveCallbacks(options) {\n const { callbacks, catchError, index, resolve, result } = options;\n if (index === callbacks.length) {\n return resolve(result);\n }\n const promise = callbacks[index];\n new Promise(() => {\n promise()\n .then((value) => {\n result.push(value);\n return zipResolveCallbacks({\n ...options,\n index: index + 1,\n result\n });\n })\n .catch((err) => {\n return catchError(err);\n });\n });\n}\nexport function zipPromise(callbacks) {\n const result = [];\n return new Promise((resolve, reject) => {\n zipResolveCallbacks({\n callbacks,\n catchError: (err) => {\n reject(err);\n },\n index: 0,\n resolve: (result) => {\n resolve(result);\n },\n result\n });\n });\n}\nexport function securePromise(callback, catchError) {\n let promise$ = undefined;\n function itIsInstanced() {\n return itIsDefined(promise$);\n }\n function resolve() {\n if (!promise$) {\n promise$ = callback().catch((err) => {\n const errorValue = catchError && catchError(err);\n reset();\n if (errorValue) {\n return errorValue;\n }\n throw err;\n });\n }\n return promise$;\n }\n function reset() {\n promise$ = undefined;\n }\n function refresh() {\n promise$ = undefined;\n return resolve();\n }\n return { itIsInstanced, refresh, reset, resolve };\n}\n//# sourceMappingURL=promises.js.map","import { Optional, fromPromise } from '@rolster/commons';\nfunction getRelationName(entity) {\n return `${entity.constructor.name}|${entity.uuid}`;\n}\nfunction itIsModelHidden(model) {\n return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;\n}\nexport class AbstractEntityManager {\n}\nexport class EntityManager {\n constructor(dataSource) {\n this.dataSource = dataSource;\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n this.relations = new Map();\n }\n persist(link) {\n this.links.push(link);\n }\n refresh(refresh) {\n const { entity, model, relationable } = refresh;\n relationable && this.relation(entity, model);\n this.refreshs.push(refresh);\n }\n sync(sync) {\n const { entity, model, relationable } = sync;\n relationable && this.relation(entity, model);\n this.syncs.push(sync);\n }\n destroy(entity) {\n this.select(entity).present((model) => {\n itIsModelHidden(model)\n ? this.hiddens.push(model)\n : this.destroys.push(model);\n });\n }\n procedure(procedure) {\n this.procedures.push(procedure);\n }\n relation(entity, model) {\n this.relations.set(getRelationName(entity), model);\n }\n link(entity, model) {\n this.relation(entity, model);\n return entity;\n }\n select(entity) {\n return Optional.build(this.relations.has(entity.uuid)\n ? this.relations.get(entity.uuid)\n : undefined);\n }\n async flush() {\n const results = [\n ...(await this.persistAll()),\n ...(await this.refreshAll()),\n ...(await this.syncAll()),\n ...(await this.hiddenAll()),\n ...(await this.destroyAll()),\n ...(await this.procedureAll())\n ];\n this.dispose();\n return results;\n }\n dispose() {\n this.relations.clear();\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n }\n persistAll() {\n return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {\n link.relationable && this.relation(link.entity, model);\n return this.dataSource.insert(model);\n })));\n }\n refreshAll() {\n return Promise.all(this.refreshs.map((refresh) => this.dataSource.refresh(refresh)));\n }\n syncAll() {\n return Promise.all(this.syncs\n .filter(({ model }) => !this.destroys.includes(model))\n .reduce((syncs, sync) => {\n const dirty = sync.verify(this);\n dirty && syncs.push([sync.model, dirty]);\n return syncs;\n }, [])\n .map(([model, dirty]) => {\n return this.dataSource.update(model, dirty);\n }));\n }\n destroyAll() {\n return Promise.all(this.destroys.map((destroy) => this.dataSource.delete(destroy)));\n }\n hiddenAll() {\n return Promise.all(this.hiddens.map((hidden) => this.dataSource.hidden(hidden)));\n }\n procedureAll() {\n return Promise.all(this.procedures.map((procedure) => this.dataSource.procedure(procedure)));\n }\n}\n//# sourceMappingURL=entity-manager.js.map","function itIsModelEditable(model) {\n return typeof model === 'object' && 'updatedAt' in model;\n}\nexport class Entity {\n constructor(uuid) {\n this.uuid = uuid;\n }\n}\nexport class EntityLink {\n constructor(entity, relationable = true) {\n this.entity = entity;\n this.relationable = relationable;\n }\n}\nexport class EntityRefresh {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n }\n async execute() {\n this.refresh();\n }\n}\nexport class EntitySync {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n this.dirty = this.createDirtyFromModel(model);\n }\n verify(manager) {\n this.sync(manager);\n return this.createDirty();\n }\n createDirtyFromModel(model) {\n const dirty = {};\n Object.entries(model).forEach(([key, value]) => {\n dirty[key] = value;\n });\n return dirty;\n }\n createDirty() {\n const _modelDirty = this.createDirtyFromModel(this.model);\n const _dirty = {};\n Object.entries(_modelDirty).forEach(([key, value]) => {\n if (_modelDirty[key] !== this.dirty[key]) {\n _dirty[key] = value;\n }\n });\n const requiredUpdate = Object.keys(_dirty).length > 0;\n if (requiredUpdate && itIsModelEditable(this.model)) {\n _dirty['updatedAt'] = new Date();\n }\n return requiredUpdate ? _dirty : undefined;\n }\n}\n//# sourceMappingURL=entity.js.map","export class AbstractPersistentUnit {\n}\n//# sourceMappingURL=persistent-unit.js.map","export class AbstractProcedure {\n}\n//# sourceMappingURL=procedure.js.map","export class AbstractRepository {\n}\n//# sourceMappingURL=repository.js.map","export class PersistentUnitResult {\n constructor(code, error, model) {\n this.code = code;\n this.error = error;\n this.model = model;\n }\n}\n//# sourceMappingURL=result.js.map"],"names":[],"mappings":";;;;AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC6BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC/BO,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL,IAAI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HANGED
@@ -65,14 +65,17 @@ function fromPromise(value) {
65
65
  return value instanceof Promise ? value : Promise.resolve(value);
66
66
  }
67
67
 
68
+ function getRelationName(entity) {
69
+ return `${entity.constructor.name}|${entity.uuid}`;
70
+ }
68
71
  function itIsModelHidden(model) {
69
72
  return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;
70
73
  }
71
74
  class AbstractEntityManager {
72
75
  }
73
76
  class EntityManager {
74
- constructor(_dataSource) {
75
- this._dataSource = _dataSource;
77
+ constructor(dataSource) {
78
+ this.dataSource = dataSource;
76
79
  this.links = [];
77
80
  this.refreshs = [];
78
81
  this.syncs = [];
@@ -81,16 +84,18 @@ class EntityManager {
81
84
  this.procedures = [];
82
85
  this.relations = new Map();
83
86
  }
84
- persist(options) {
85
- this.links.push(options);
87
+ persist(link) {
88
+ this.links.push(link);
86
89
  }
87
- refresh(options) {
88
- options.relationable && this.relation(options.entity, options.model);
89
- this.refreshs.push(options);
90
+ refresh(refresh) {
91
+ const { entity, model, relationable } = refresh;
92
+ relationable && this.relation(entity, model);
93
+ this.refreshs.push(refresh);
90
94
  }
91
- sync(options) {
92
- options.relationable && this.relation(options.entity, options.model);
93
- this.syncs.push(options);
95
+ sync(sync) {
96
+ const { entity, model, relationable } = sync;
97
+ relationable && this.relation(entity, model);
98
+ this.syncs.push(sync);
94
99
  }
95
100
  destroy(entity) {
96
101
  this.select(entity).present((model) => {
@@ -103,7 +108,7 @@ class EntityManager {
103
108
  this.procedures.push(procedure);
104
109
  }
105
110
  relation(entity, model) {
106
- this.relations.set(entity.uuid, model);
111
+ this.relations.set(getRelationName(entity), model);
107
112
  }
108
113
  link(entity, model) {
109
114
  this.relation(entity, model);
@@ -138,11 +143,11 @@ class EntityManager {
138
143
  persistAll() {
139
144
  return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {
140
145
  link.relationable && this.relation(link.entity, model);
141
- return this._dataSource.insert(model);
146
+ return this.dataSource.insert(model);
142
147
  })));
143
148
  }
144
149
  refreshAll() {
145
- return Promise.all(this.refreshs.map((refresh) => this._dataSource.refresh(refresh)));
150
+ return Promise.all(this.refreshs.map((refresh) => this.dataSource.refresh(refresh)));
146
151
  }
147
152
  syncAll() {
148
153
  return Promise.all(this.syncs
@@ -153,17 +158,17 @@ class EntityManager {
153
158
  return syncs;
154
159
  }, [])
155
160
  .map(([model, dirty]) => {
156
- return this._dataSource.update(model, dirty);
161
+ return this.dataSource.update(model, dirty);
157
162
  }));
158
163
  }
159
164
  destroyAll() {
160
- return Promise.all(this.destroys.map((destroy) => this._dataSource.delete(destroy)));
165
+ return Promise.all(this.destroys.map((destroy) => this.dataSource.delete(destroy)));
161
166
  }
162
167
  hiddenAll() {
163
- return Promise.all(this.hiddens.map((hidden) => this._dataSource.hidden(hidden)));
168
+ return Promise.all(this.hiddens.map((hidden) => this.dataSource.hidden(hidden)));
164
169
  }
165
170
  procedureAll() {
166
- return Promise.all(this.procedures.map((procedure) => this._dataSource.procedure(procedure)));
171
+ return Promise.all(this.procedures.map((procedure) => this.dataSource.procedure(procedure)));
167
172
  }
168
173
  }
169
174
 
@@ -196,7 +201,7 @@ class EntitySync {
196
201
  this.entity = entity;
197
202
  this.model = model;
198
203
  this.relationable = relationable;
199
- this._dirty = this.createDirtyFromModel(model);
204
+ this.dirty = this.createDirtyFromModel(model);
200
205
  }
201
206
  verify(manager) {
202
207
  this.sync(manager);
@@ -213,7 +218,7 @@ class EntitySync {
213
218
  const _modelDirty = this.createDirtyFromModel(this.model);
214
219
  const _dirty = {};
215
220
  Object.entries(_modelDirty).forEach(([key, value]) => {
216
- if (_modelDirty[key] !== this._dirty[key]) {
221
+ if (_modelDirty[key] !== this.dirty[key]) {
217
222
  _dirty[key] = value;
218
223
  }
219
224
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../esm/database.js","../esm/datasource.js","../../node_modules/@rolster/commons/dist/esm/helpers.js","../../node_modules/@rolster/commons/dist/esm/optional.js","../../node_modules/@rolster/commons/dist/esm/promises.js","../esm/entity-manager.js","../esm/entity.js","../esm/persistent-unit.js","../esm/procedure.js","../esm/repository.js","../esm/result.js"],"sourcesContent":["export class AbstractEntityDatabase {\n}\n//# sourceMappingURL=database.js.map","export class AbstractEntityDataSource {\n}\n//# sourceMappingURL=datasource.js.map","const PRIMITIVES = [Date, RegExp, Function, String, Boolean, Number];\nconst SLICE_SIZE = 512;\nconst FALSY_VALUE = ['false', 'undefined', '0', 0];\nconst prototypeToString = Object.prototype.toString;\nfunction _clone(object, caches, replaces, ignoreKeysRegex) {\n if (typeof object !== 'object') {\n return object;\n }\n if (prototypeToString.call(object) === '[object Object]') {\n const [_object] = caches.filter((_object) => _object === object);\n /* istanbul ignore if */\n if (_object) {\n return _object;\n }\n caches.push(object);\n }\n const ConstructorObject = Object.getPrototypeOf(object).constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n if (!ignoreKeysRegex?.test(key)) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\n }\n }\n return _object;\n}\nexport function itIsDefined(object) {\n return typeof object !== 'undefined' && object !== null;\n}\nexport function itIsUndefined(object) {\n return !itIsDefined(object);\n}\nexport function parseBoolean(value) {\n return !(itIsUndefined(value) ||\n value === false ||\n FALSY_VALUE.includes(value));\n}\nexport function parse(value) {\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nexport function evalValueOrFunction(value) {\n return typeof value === 'function' ? value() : value;\n}\nexport function clone(object, replaces, ignoreKeysRegex) {\n return _clone(object, [], replaces, ignoreKeysRegex);\n}\nexport function freeze(object) {\n for (const prop in object) {\n const value = object[prop];\n if (typeof value === 'object' && !Object.isFrozen(value)) {\n freeze(value);\n }\n }\n return Object.freeze(object);\n}\nexport function callback(call, ...args) {\n return typeof call !== 'function' ? undefined : call.apply(call, args);\n}\nfunction normalizeValue(value) {\n return typeof value === 'object'\n ? Array.isArray(value)\n ? value.map((value) => normalizeValue(value))\n : normalizeJson(value)\n : value;\n}\nexport function normalizeJson(payload) {\n return Object.entries(payload).reduce((result, [key, value]) => {\n if (itIsDefined(value)) {\n result[key] = normalizeValue(value);\n }\n return result;\n }, {});\n}\n/* istanbul ignore next */\nexport function base64ToBlob(data64, mimeType) {\n const result64 = data64.replace(/^[^,]+,/, '').replace(/\\s/g, '');\n const byteCharacters = window.atob(result64);\n const byteArrays = [];\n for (let offset = 0; offset < byteCharacters.length; offset += SLICE_SIZE) {\n const slice = byteCharacters.slice(offset, offset + SLICE_SIZE);\n const byteNumbers = new Array(slice.length);\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i);\n }\n const byteArray = new Uint8Array(byteNumbers);\n byteArrays.push(byteArray);\n }\n return new Blob(byteArrays, { type: mimeType });\n}\n//# sourceMappingURL=helpers.js.map","import { itIsDefined } from './helpers';\nexport class Optional {\n constructor(value) {\n this.value = value;\n }\n present(callback) {\n return this.isPresent() ? callback(this.get()) : undefined;\n }\n empty(callback) {\n return this.isEmpty() ? callback() : undefined;\n }\n when(present, empty) {\n return this.isPresent() ? present(this.get()) : empty();\n }\n static build(value) {\n return itIsDefined(value) ? this.of(value) : this.empty();\n }\n static of(value) {\n if (itIsDefined(value)) {\n return new PresentOptional(value);\n }\n throw new Error('The passed value was null or undefined.');\n }\n static empty() {\n return new EmptyOptional();\n }\n}\nclass PresentOptional extends Optional {\n constructor(presentValue) {\n super(presentValue);\n this.presentValue = presentValue;\n }\n isPresent() {\n return true;\n }\n isEmpty() {\n return false;\n }\n get() {\n return this.presentValue;\n }\n}\nclass EmptyOptional extends Optional {\n isPresent() {\n return false;\n }\n isEmpty() {\n return true;\n }\n get() {\n throw new Error('The optional is not present.');\n }\n}\n//# sourceMappingURL=optional.js.map","import { itIsDefined } from './helpers';\nexport function fromPromise(value) {\n return value instanceof Promise ? value : Promise.resolve(value);\n}\nexport function resolvePromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n throw err;\n });\n}\nexport function voidPromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nexport function catchPromise(promise, catchError) {\n return promise.catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nfunction zipResolveCallbacks(options) {\n const { callbacks, catchError, index, resolve, result } = options;\n if (index === callbacks.length) {\n return resolve(result);\n }\n const promise = callbacks[index];\n new Promise(() => {\n promise()\n .then((value) => {\n result.push(value);\n return zipResolveCallbacks({\n ...options,\n index: index + 1,\n result\n });\n })\n .catch((err) => {\n return catchError(err);\n });\n });\n}\nexport function zipPromise(callbacks) {\n const result = [];\n return new Promise((resolve, reject) => {\n zipResolveCallbacks({\n callbacks,\n catchError: (err) => {\n reject(err);\n },\n index: 0,\n resolve: (result) => {\n resolve(result);\n },\n result\n });\n });\n}\nexport function securePromise(callback, catchError) {\n let promise$ = undefined;\n function itIsInstanced() {\n return itIsDefined(promise$);\n }\n function resolve() {\n if (!promise$) {\n promise$ = callback().catch((err) => {\n const errorValue = catchError && catchError(err);\n reset();\n if (errorValue) {\n return errorValue;\n }\n throw err;\n });\n }\n return promise$;\n }\n function reset() {\n promise$ = undefined;\n }\n function refresh() {\n promise$ = undefined;\n return resolve();\n }\n return { itIsInstanced, refresh, reset, resolve };\n}\n//# sourceMappingURL=promises.js.map","import { Optional, fromPromise } from '@rolster/commons';\nfunction itIsModelHidden(model) {\n return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;\n}\nexport class AbstractEntityManager {\n}\nexport class EntityManager {\n constructor(_dataSource) {\n this._dataSource = _dataSource;\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n this.relations = new Map();\n }\n persist(options) {\n this.links.push(options);\n }\n refresh(options) {\n options.relationable && this.relation(options.entity, options.model);\n this.refreshs.push(options);\n }\n sync(options) {\n options.relationable && this.relation(options.entity, options.model);\n this.syncs.push(options);\n }\n destroy(entity) {\n this.select(entity).present((model) => {\n itIsModelHidden(model)\n ? this.hiddens.push(model)\n : this.destroys.push(model);\n });\n }\n procedure(procedure) {\n this.procedures.push(procedure);\n }\n relation(entity, model) {\n this.relations.set(entity.uuid, model);\n }\n link(entity, model) {\n this.relation(entity, model);\n return entity;\n }\n select(entity) {\n return Optional.build(this.relations.has(entity.uuid)\n ? this.relations.get(entity.uuid)\n : undefined);\n }\n async flush() {\n const results = [\n ...(await this.persistAll()),\n ...(await this.refreshAll()),\n ...(await this.syncAll()),\n ...(await this.hiddenAll()),\n ...(await this.destroyAll()),\n ...(await this.procedureAll())\n ];\n this.dispose();\n return results;\n }\n dispose() {\n this.relations.clear();\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n }\n persistAll() {\n return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {\n link.relationable && this.relation(link.entity, model);\n return this._dataSource.insert(model);\n })));\n }\n refreshAll() {\n return Promise.all(this.refreshs.map((refresh) => this._dataSource.refresh(refresh)));\n }\n syncAll() {\n return Promise.all(this.syncs\n .filter(({ model }) => !this.destroys.includes(model))\n .reduce((syncs, sync) => {\n const dirty = sync.verify(this);\n dirty && syncs.push([sync.model, dirty]);\n return syncs;\n }, [])\n .map(([model, dirty]) => {\n return this._dataSource.update(model, dirty);\n }));\n }\n destroyAll() {\n return Promise.all(this.destroys.map((destroy) => this._dataSource.delete(destroy)));\n }\n hiddenAll() {\n return Promise.all(this.hiddens.map((hidden) => this._dataSource.hidden(hidden)));\n }\n procedureAll() {\n return Promise.all(this.procedures.map((procedure) => this._dataSource.procedure(procedure)));\n }\n}\n//# sourceMappingURL=entity-manager.js.map","function itIsModelEditable(model) {\n return typeof model === 'object' && 'updatedAt' in model;\n}\nexport class Entity {\n constructor(uuid) {\n this.uuid = uuid;\n }\n}\nexport class EntityLink {\n constructor(entity, relationable = true) {\n this.entity = entity;\n this.relationable = relationable;\n }\n}\nexport class EntityRefresh {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n }\n async execute() {\n this.refresh();\n }\n}\nexport class EntitySync {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n this._dirty = this.createDirtyFromModel(model);\n }\n verify(manager) {\n this.sync(manager);\n return this.createDirty();\n }\n createDirtyFromModel(model) {\n const dirty = {};\n Object.entries(model).forEach(([key, value]) => {\n dirty[key] = value;\n });\n return dirty;\n }\n createDirty() {\n const _modelDirty = this.createDirtyFromModel(this.model);\n const _dirty = {};\n Object.entries(_modelDirty).forEach(([key, value]) => {\n if (_modelDirty[key] !== this._dirty[key]) {\n _dirty[key] = value;\n }\n });\n const requiredUpdate = Object.keys(_dirty).length > 0;\n if (requiredUpdate && itIsModelEditable(this.model)) {\n _dirty['updatedAt'] = new Date();\n }\n return requiredUpdate ? _dirty : undefined;\n }\n}\n//# sourceMappingURL=entity.js.map","export class AbstractPersistentUnit {\n}\n//# sourceMappingURL=persistent-unit.js.map","export class AbstractProcedure {\n}\n//# sourceMappingURL=procedure.js.map","export class AbstractRepository {\n}\n//# sourceMappingURL=repository.js.map","export class PersistentUnitResult {\n constructor(code, error, model) {\n this.code = code;\n this.error = error;\n this.model = model;\n }\n}\n//# sourceMappingURL=result.js.map"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC6BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC/BO,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL,IAAI,OAAO,CAAC,QAAQ,EAAE;AACtB,QAAQ,OAAO,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AAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC9D,YAAY,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;AACvD,gBAAgB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACpC,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,QAAQ,IAAI,cAAc,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AAC7D,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AAC7C,SAAS;AACT,QAAQ,OAAO,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AACnD,KAAK;AACL;;ACxDO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,iBAAiB,CAAC;AAC/B;;ACDO,MAAM,kBAAkB,CAAC;AAChC;;ACDO,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;AACpC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACzB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../esm/database.js","../esm/datasource.js","../../node_modules/@rolster/commons/dist/esm/helpers.js","../../node_modules/@rolster/commons/dist/esm/optional.js","../../node_modules/@rolster/commons/dist/esm/promises.js","../esm/entity-manager.js","../esm/entity.js","../esm/persistent-unit.js","../esm/procedure.js","../esm/repository.js","../esm/result.js"],"sourcesContent":["export class AbstractEntityDatabase {\n}\n//# sourceMappingURL=database.js.map","export class AbstractEntityDataSource {\n}\n//# sourceMappingURL=datasource.js.map","const PRIMITIVES = [Date, RegExp, Function, String, Boolean, Number];\nconst SLICE_SIZE = 512;\nconst FALSY_VALUE = ['false', 'undefined', '0', 0];\nconst prototypeToString = Object.prototype.toString;\nfunction _clone(object, caches, replaces, ignoreKeysRegex) {\n if (typeof object !== 'object') {\n return object;\n }\n if (prototypeToString.call(object) === '[object Object]') {\n const [_object] = caches.filter((_object) => _object === object);\n /* istanbul ignore if */\n if (_object) {\n return _object;\n }\n caches.push(object);\n }\n const ConstructorObject = Object.getPrototypeOf(object).constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n if (!ignoreKeysRegex?.test(key)) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\n }\n }\n return _object;\n}\nexport function itIsDefined(object) {\n return typeof object !== 'undefined' && object !== null;\n}\nexport function itIsUndefined(object) {\n return !itIsDefined(object);\n}\nexport function parseBoolean(value) {\n return !(itIsUndefined(value) ||\n value === false ||\n FALSY_VALUE.includes(value));\n}\nexport function parse(value) {\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nexport function evalValueOrFunction(value) {\n return typeof value === 'function' ? value() : value;\n}\nexport function clone(object, replaces, ignoreKeysRegex) {\n return _clone(object, [], replaces, ignoreKeysRegex);\n}\nexport function freeze(object) {\n for (const prop in object) {\n const value = object[prop];\n if (typeof value === 'object' && !Object.isFrozen(value)) {\n freeze(value);\n }\n }\n return Object.freeze(object);\n}\nexport function callback(call, ...args) {\n return typeof call !== 'function' ? undefined : call.apply(call, args);\n}\nfunction normalizeValue(value) {\n return typeof value === 'object'\n ? Array.isArray(value)\n ? value.map((value) => normalizeValue(value))\n : normalizeJson(value)\n : value;\n}\nexport function normalizeJson(payload) {\n return Object.entries(payload).reduce((result, [key, value]) => {\n if (itIsDefined(value)) {\n result[key] = normalizeValue(value);\n }\n return result;\n }, {});\n}\n/* istanbul ignore next */\nexport function base64ToBlob(data64, mimeType) {\n const result64 = data64.replace(/^[^,]+,/, '').replace(/\\s/g, '');\n const byteCharacters = window.atob(result64);\n const byteArrays = [];\n for (let offset = 0; offset < byteCharacters.length; offset += SLICE_SIZE) {\n const slice = byteCharacters.slice(offset, offset + SLICE_SIZE);\n const byteNumbers = new Array(slice.length);\n for (let i = 0; i < slice.length; i++) {\n byteNumbers[i] = slice.charCodeAt(i);\n }\n const byteArray = new Uint8Array(byteNumbers);\n byteArrays.push(byteArray);\n }\n return new Blob(byteArrays, { type: mimeType });\n}\n//# sourceMappingURL=helpers.js.map","import { itIsDefined } from './helpers';\nexport class Optional {\n constructor(value) {\n this.value = value;\n }\n present(callback) {\n return this.isPresent() ? callback(this.get()) : undefined;\n }\n empty(callback) {\n return this.isEmpty() ? callback() : undefined;\n }\n when(present, empty) {\n return this.isPresent() ? present(this.get()) : empty();\n }\n static build(value) {\n return itIsDefined(value) ? this.of(value) : this.empty();\n }\n static of(value) {\n if (itIsDefined(value)) {\n return new PresentOptional(value);\n }\n throw new Error('The passed value was null or undefined.');\n }\n static empty() {\n return new EmptyOptional();\n }\n}\nclass PresentOptional extends Optional {\n constructor(presentValue) {\n super(presentValue);\n this.presentValue = presentValue;\n }\n isPresent() {\n return true;\n }\n isEmpty() {\n return false;\n }\n get() {\n return this.presentValue;\n }\n}\nclass EmptyOptional extends Optional {\n isPresent() {\n return false;\n }\n isEmpty() {\n return true;\n }\n get() {\n throw new Error('The optional is not present.');\n }\n}\n//# sourceMappingURL=optional.js.map","import { itIsDefined } from './helpers';\nexport function fromPromise(value) {\n return value instanceof Promise ? value : Promise.resolve(value);\n}\nexport function resolvePromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n throw err;\n });\n}\nexport function voidPromise(promise, catchError) {\n return promise\n .then(() => undefined)\n .catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nexport function catchPromise(promise, catchError) {\n return promise.catch((err) => {\n catchError && catchError(err);\n return undefined;\n });\n}\nfunction zipResolveCallbacks(options) {\n const { callbacks, catchError, index, resolve, result } = options;\n if (index === callbacks.length) {\n return resolve(result);\n }\n const promise = callbacks[index];\n new Promise(() => {\n promise()\n .then((value) => {\n result.push(value);\n return zipResolveCallbacks({\n ...options,\n index: index + 1,\n result\n });\n })\n .catch((err) => {\n return catchError(err);\n });\n });\n}\nexport function zipPromise(callbacks) {\n const result = [];\n return new Promise((resolve, reject) => {\n zipResolveCallbacks({\n callbacks,\n catchError: (err) => {\n reject(err);\n },\n index: 0,\n resolve: (result) => {\n resolve(result);\n },\n result\n });\n });\n}\nexport function securePromise(callback, catchError) {\n let promise$ = undefined;\n function itIsInstanced() {\n return itIsDefined(promise$);\n }\n function resolve() {\n if (!promise$) {\n promise$ = callback().catch((err) => {\n const errorValue = catchError && catchError(err);\n reset();\n if (errorValue) {\n return errorValue;\n }\n throw err;\n });\n }\n return promise$;\n }\n function reset() {\n promise$ = undefined;\n }\n function refresh() {\n promise$ = undefined;\n return resolve();\n }\n return { itIsInstanced, refresh, reset, resolve };\n}\n//# sourceMappingURL=promises.js.map","import { Optional, fromPromise } from '@rolster/commons';\nfunction getRelationName(entity) {\n return `${entity.constructor.name}|${entity.uuid}`;\n}\nfunction itIsModelHidden(model) {\n return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;\n}\nexport class AbstractEntityManager {\n}\nexport class EntityManager {\n constructor(dataSource) {\n this.dataSource = dataSource;\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n this.relations = new Map();\n }\n persist(link) {\n this.links.push(link);\n }\n refresh(refresh) {\n const { entity, model, relationable } = refresh;\n relationable && this.relation(entity, model);\n this.refreshs.push(refresh);\n }\n sync(sync) {\n const { entity, model, relationable } = sync;\n relationable && this.relation(entity, model);\n this.syncs.push(sync);\n }\n destroy(entity) {\n this.select(entity).present((model) => {\n itIsModelHidden(model)\n ? this.hiddens.push(model)\n : this.destroys.push(model);\n });\n }\n procedure(procedure) {\n this.procedures.push(procedure);\n }\n relation(entity, model) {\n this.relations.set(getRelationName(entity), model);\n }\n link(entity, model) {\n this.relation(entity, model);\n return entity;\n }\n select(entity) {\n return Optional.build(this.relations.has(entity.uuid)\n ? this.relations.get(entity.uuid)\n : undefined);\n }\n async flush() {\n const results = [\n ...(await this.persistAll()),\n ...(await this.refreshAll()),\n ...(await this.syncAll()),\n ...(await this.hiddenAll()),\n ...(await this.destroyAll()),\n ...(await this.procedureAll())\n ];\n this.dispose();\n return results;\n }\n dispose() {\n this.relations.clear();\n this.links = [];\n this.refreshs = [];\n this.syncs = [];\n this.destroys = [];\n this.hiddens = [];\n this.procedures = [];\n }\n persistAll() {\n return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {\n link.relationable && this.relation(link.entity, model);\n return this.dataSource.insert(model);\n })));\n }\n refreshAll() {\n return Promise.all(this.refreshs.map((refresh) => this.dataSource.refresh(refresh)));\n }\n syncAll() {\n return Promise.all(this.syncs\n .filter(({ model }) => !this.destroys.includes(model))\n .reduce((syncs, sync) => {\n const dirty = sync.verify(this);\n dirty && syncs.push([sync.model, dirty]);\n return syncs;\n }, [])\n .map(([model, dirty]) => {\n return this.dataSource.update(model, dirty);\n }));\n }\n destroyAll() {\n return Promise.all(this.destroys.map((destroy) => this.dataSource.delete(destroy)));\n }\n hiddenAll() {\n return Promise.all(this.hiddens.map((hidden) => this.dataSource.hidden(hidden)));\n }\n procedureAll() {\n return Promise.all(this.procedures.map((procedure) => this.dataSource.procedure(procedure)));\n }\n}\n//# sourceMappingURL=entity-manager.js.map","function itIsModelEditable(model) {\n return typeof model === 'object' && 'updatedAt' in model;\n}\nexport class Entity {\n constructor(uuid) {\n this.uuid = uuid;\n }\n}\nexport class EntityLink {\n constructor(entity, relationable = true) {\n this.entity = entity;\n this.relationable = relationable;\n }\n}\nexport class EntityRefresh {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n }\n async execute() {\n this.refresh();\n }\n}\nexport class EntitySync {\n constructor(entity, model, relationable = true) {\n this.entity = entity;\n this.model = model;\n this.relationable = relationable;\n this.dirty = this.createDirtyFromModel(model);\n }\n verify(manager) {\n this.sync(manager);\n return this.createDirty();\n }\n createDirtyFromModel(model) {\n const dirty = {};\n Object.entries(model).forEach(([key, value]) => {\n dirty[key] = value;\n });\n return dirty;\n }\n createDirty() {\n const _modelDirty = this.createDirtyFromModel(this.model);\n const _dirty = {};\n Object.entries(_modelDirty).forEach(([key, value]) => {\n if (_modelDirty[key] !== this.dirty[key]) {\n _dirty[key] = value;\n }\n });\n const requiredUpdate = Object.keys(_dirty).length > 0;\n if (requiredUpdate && itIsModelEditable(this.model)) {\n _dirty['updatedAt'] = new Date();\n }\n return requiredUpdate ? _dirty : undefined;\n }\n}\n//# sourceMappingURL=entity.js.map","export class AbstractPersistentUnit {\n}\n//# sourceMappingURL=persistent-unit.js.map","export class AbstractProcedure {\n}\n//# sourceMappingURL=procedure.js.map","export class AbstractRepository {\n}\n//# sourceMappingURL=repository.js.map","export class PersistentUnitResult {\n constructor(code, error, model) {\n this.code = code;\n this.error = error;\n this.model = model;\n }\n}\n//# sourceMappingURL=result.js.map"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC6BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC/BO,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL,IAAI,OAAO,CAAC,QAAQ,EAAE;AACtB,QAAQ,OAAO,IAAI,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC;AACnE,KAAK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IAAI,CAAC,KAAK,CAAC,CAAC;AAClE,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC;AAC1B,QAAQ,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC9D,YAAY,IAAI,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;AACtD,gBAAgB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACpC,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC9D,QAAQ,IAAI,cAAc,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AAC7D,YAAY,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;AAC7C,SAAS;AACT,QAAQ,OAAO,cAAc,GAAG,MAAM,GAAG,SAAS,CAAC;AACnD,KAAK;AACL;;ACxDO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,iBAAiB,CAAC;AAC/B;;ACDO,MAAM,kBAAkB,CAAC;AAChC;;ACDO,MAAM,oBAAoB,CAAC;AAClC,IAAI,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;AACpC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACzB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;AACL;;;;"}
@@ -4,13 +4,13 @@ import { EntityLink, EntitySync, EntityRefresh } from './entity';
4
4
  import { AbstractProcedure } from './procedure';
5
5
  import { PersistentUnitResult } from './result';
6
6
  import { AbstractModel, AbstractEntity, QueryEntityManager } from './types';
7
- type LinkOptions = EntityLink<AbstractEntity, AbstractModel>;
8
- type RefreshOptions = EntityRefresh<AbstractEntity, AbstractModel>;
9
- type SyncOptions = EntitySync<AbstractEntity, AbstractModel>;
7
+ type VinegarLink = EntityLink<AbstractEntity, AbstractModel>;
8
+ type VinegarRefresh = EntityRefresh<AbstractEntity, AbstractModel>;
9
+ type VinegarSync = EntitySync<AbstractEntity, AbstractModel>;
10
10
  export declare abstract class AbstractEntityManager implements QueryEntityManager {
11
- abstract persist(options: LinkOptions): void;
12
- abstract refresh(options: RefreshOptions): void;
13
- abstract sync(options: SyncOptions): void;
11
+ abstract persist(options: VinegarLink): void;
12
+ abstract refresh(options: VinegarRefresh): void;
13
+ abstract sync(options: VinegarSync): void;
14
14
  abstract destroy(entity: AbstractEntity): void;
15
15
  abstract procedure(procedure: AbstractProcedure): void;
16
16
  abstract relation(entity: AbstractEntity, model: AbstractModel): void;
@@ -20,7 +20,7 @@ export declare abstract class AbstractEntityManager implements QueryEntityManage
20
20
  abstract dispose(): void;
21
21
  }
22
22
  export declare class EntityManager implements AbstractEntityManager {
23
- private _dataSource;
23
+ private dataSource;
24
24
  private relations;
25
25
  private links;
26
26
  private refreshs;
@@ -28,10 +28,10 @@ export declare class EntityManager implements AbstractEntityManager {
28
28
  private destroys;
29
29
  private hiddens;
30
30
  private procedures;
31
- constructor(_dataSource: AbstractEntityDataSource);
32
- persist(options: LinkOptions): void;
33
- refresh(options: RefreshOptions): void;
34
- sync(options: SyncOptions): void;
31
+ constructor(dataSource: AbstractEntityDataSource);
32
+ persist(link: VinegarLink): void;
33
+ refresh(refresh: VinegarRefresh): void;
34
+ sync(sync: VinegarSync): void;
35
35
  destroy(entity: AbstractEntity): void;
36
36
  procedure(procedure: AbstractProcedure): void;
37
37
  relation(entity: AbstractEntity, model: AbstractModel): void;
@@ -1,12 +1,15 @@
1
1
  import { Optional, fromPromise } from '@rolster/commons';
2
+ function getRelationName(entity) {
3
+ return `${entity.constructor.name}|${entity.uuid}`;
4
+ }
2
5
  function itIsModelHidden(model) {
3
6
  return typeof model === 'object' && 'hidden' in model && 'hiddenAt' in model;
4
7
  }
5
8
  export class AbstractEntityManager {
6
9
  }
7
10
  export class EntityManager {
8
- constructor(_dataSource) {
9
- this._dataSource = _dataSource;
11
+ constructor(dataSource) {
12
+ this.dataSource = dataSource;
10
13
  this.links = [];
11
14
  this.refreshs = [];
12
15
  this.syncs = [];
@@ -15,16 +18,18 @@ export class EntityManager {
15
18
  this.procedures = [];
16
19
  this.relations = new Map();
17
20
  }
18
- persist(options) {
19
- this.links.push(options);
21
+ persist(link) {
22
+ this.links.push(link);
20
23
  }
21
- refresh(options) {
22
- options.relationable && this.relation(options.entity, options.model);
23
- this.refreshs.push(options);
24
+ refresh(refresh) {
25
+ const { entity, model, relationable } = refresh;
26
+ relationable && this.relation(entity, model);
27
+ this.refreshs.push(refresh);
24
28
  }
25
- sync(options) {
26
- options.relationable && this.relation(options.entity, options.model);
27
- this.syncs.push(options);
29
+ sync(sync) {
30
+ const { entity, model, relationable } = sync;
31
+ relationable && this.relation(entity, model);
32
+ this.syncs.push(sync);
28
33
  }
29
34
  destroy(entity) {
30
35
  this.select(entity).present((model) => {
@@ -37,7 +42,7 @@ export class EntityManager {
37
42
  this.procedures.push(procedure);
38
43
  }
39
44
  relation(entity, model) {
40
- this.relations.set(entity.uuid, model);
45
+ this.relations.set(getRelationName(entity), model);
41
46
  }
42
47
  link(entity, model) {
43
48
  this.relation(entity, model);
@@ -72,11 +77,11 @@ export class EntityManager {
72
77
  persistAll() {
73
78
  return Promise.all(this.links.map((link) => fromPromise(link.create(this)).then((model) => {
74
79
  link.relationable && this.relation(link.entity, model);
75
- return this._dataSource.insert(model);
80
+ return this.dataSource.insert(model);
76
81
  })));
77
82
  }
78
83
  refreshAll() {
79
- return Promise.all(this.refreshs.map((refresh) => this._dataSource.refresh(refresh)));
84
+ return Promise.all(this.refreshs.map((refresh) => this.dataSource.refresh(refresh)));
80
85
  }
81
86
  syncAll() {
82
87
  return Promise.all(this.syncs
@@ -87,17 +92,17 @@ export class EntityManager {
87
92
  return syncs;
88
93
  }, [])
89
94
  .map(([model, dirty]) => {
90
- return this._dataSource.update(model, dirty);
95
+ return this.dataSource.update(model, dirty);
91
96
  }));
92
97
  }
93
98
  destroyAll() {
94
- return Promise.all(this.destroys.map((destroy) => this._dataSource.delete(destroy)));
99
+ return Promise.all(this.destroys.map((destroy) => this.dataSource.delete(destroy)));
95
100
  }
96
101
  hiddenAll() {
97
- return Promise.all(this.hiddens.map((hidden) => this._dataSource.hidden(hidden)));
102
+ return Promise.all(this.hiddens.map((hidden) => this.dataSource.hidden(hidden)));
98
103
  }
99
104
  procedureAll() {
100
- return Promise.all(this.procedures.map((procedure) => this._dataSource.procedure(procedure)));
105
+ return Promise.all(this.procedures.map((procedure) => this.dataSource.procedure(procedure)));
101
106
  }
102
107
  }
103
108
  //# sourceMappingURL=entity-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entity-manager.js","sourceRoot":"","sources":["../../src/entity-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkBzD,SAAS,eAAe,CAAC,KAAU;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,UAAU,IAAI,KAAK,CAAC;AAC/E,CAAC;AAED,MAAM,OAAgB,qBAAqB;CAoB1C;AAED,MAAM,OAAO,aAAa;IAexB,YAAoB,WAAqC;QAArC,gBAAW,GAAX,WAAW,CAA0B;QAZjD,UAAK,GAAkB,EAAE,CAAC;QAE1B,aAAQ,GAAqB,EAAE,CAAC;QAEhC,UAAK,GAAkB,EAAE,CAAC;QAE1B,aAAQ,GAAoB,EAAE,CAAC;QAE/B,YAAO,GAAoB,EAAE,CAAC;QAE9B,eAAU,GAAwB,EAAE,CAAC;QAG3C,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IACpD,CAAC;IAEM,OAAO,CAAC,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,CAAC;IACJ,CAAC;IAEO,SAAS;QACf,OAAO,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAC7D,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,OAAO,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CACzE,CAAC;IACJ,CAAC;CACF"}
@@ -21,7 +21,7 @@ export declare abstract class EntitySync<E extends AbstractEntity, M extends Abs
21
21
  readonly entity: E;
22
22
  readonly model: M;
23
23
  readonly relationable: boolean;
24
- private _dirty;
24
+ private dirty;
25
25
  constructor(entity: E, model: M, relationable?: boolean);
26
26
  abstract sync(manager: QueryEntityManager): void;
27
27
  verify(manager: QueryEntityManager): Undefined<DirtyModel>;
@@ -27,7 +27,7 @@ export class EntitySync {
27
27
  this.entity = entity;
28
28
  this.model = model;
29
29
  this.relationable = relationable;
30
- this._dirty = this.createDirtyFromModel(model);
30
+ this.dirty = this.createDirtyFromModel(model);
31
31
  }
32
32
  verify(manager) {
33
33
  this.sync(manager);
@@ -44,7 +44,7 @@ export class EntitySync {
44
44
  const _modelDirty = this.createDirtyFromModel(this.model);
45
45
  const _dirty = {};
46
46
  Object.entries(_modelDirty).forEach(([key, value]) => {
47
- if (_modelDirty[key] !== this._dirty[key]) {
47
+ if (_modelDirty[key] !== this.dirty[key]) {
48
48
  _dirty[key] = value;
49
49
  }
50
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/entity.ts"],"names":[],"mappings":"AASA,SAAS,iBAAiB,CAAC,KAAU;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,WAAW,IAAI,KAAK,CAAC;A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MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAEtD,IAAI,cAAc,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACpD,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACnC,CAAC;QAED,OAAO,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolster/vinegar",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "Container package of basic classes to implement a clean architecture.",
5
5
  "module": "dist/esm/index.js",
6
6
  "main": "dist/cjs/index.js",