@rolster/vinegar 2.3.0 → 2.3.2

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
@@ -238,6 +238,14 @@ class AbstractProcedure {
238
238
  class AbstractRepository {
239
239
  }
240
240
 
241
+ class PersistentUnitResult {
242
+ constructor(code, error, model) {
243
+ this.code = code;
244
+ this.error = error;
245
+ this.model = model;
246
+ }
247
+ }
248
+
241
249
  exports.AbstractEntityDataSource = AbstractEntityDataSource;
242
250
  exports.AbstractEntityDatabase = AbstractEntityDatabase;
243
251
  exports.AbstractEntityManager = AbstractEntityManager;
@@ -249,4 +257,5 @@ exports.EntityLink = EntityLink;
249
257
  exports.EntityManager = EntityManager;
250
258
  exports.EntityRefresh = EntityRefresh;
251
259
  exports.EntitySync = EntitySync;
260
+ exports.PersistentUnitResult = PersistentUnitResult;
252
261
  //# sourceMappingURL=index.js.map
@@ -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"],"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) {\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 prototypeObject = Object.getPrototypeOf(object);\n const ConstructorObject = prototypeObject.constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\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) {\n return _clone(object, [], replaces);\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();\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() {\n this.sync();\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"],"names":[],"mappings":";;;;AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC4BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC9BO,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;AACL,IAAI,KAAK,CAAC,QAAQ,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC;AACvD,KAAK;AACL,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE;AACzB,QAAQ,OAAO,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC;AAChE,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,KAAK,EAAE;AACxB,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;AAClE,KAAK;AACL,IAAI,OAAO,EAAE,CAAC,KAAK,EAAE;AACrB,QAAQ,IAAI,WAAW,C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ources":["../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) {\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 prototypeObject = Object.getPrototypeOf(object);\n const ConstructorObject = prototypeObject.constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\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) {\n return _clone(object, [], replaces);\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();\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() {\n this.sync();\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;;AC4BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC9BO,MAAM,QAAQ,CAAC;AACtB,IAAI,WAAW,CAAC,KAAK,EAAE;AACvB,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;AAC3B,KAAK;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O,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;;;;;;;;;;;;;;;"}
package/dist/es/index.js CHANGED
@@ -234,5 +234,13 @@ class AbstractProcedure {
234
234
  class AbstractRepository {
235
235
  }
236
236
 
237
- export { AbstractEntityDataSource, AbstractEntityDatabase, AbstractEntityManager, AbstractPersistentUnit, AbstractProcedure, AbstractRepository, Entity, EntityLink, EntityManager, EntityRefresh, EntitySync };
237
+ class PersistentUnitResult {
238
+ constructor(code, error, model) {
239
+ this.code = code;
240
+ this.error = error;
241
+ this.model = model;
242
+ }
243
+ }
244
+
245
+ export { AbstractEntityDataSource, AbstractEntityDatabase, AbstractEntityManager, AbstractPersistentUnit, AbstractProcedure, AbstractRepository, Entity, EntityLink, EntityManager, EntityRefresh, EntitySync, PersistentUnitResult };
238
246
  //# sourceMappingURL=index.js.map
@@ -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"],"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) {\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 prototypeObject = Object.getPrototypeOf(object);\n const ConstructorObject = prototypeObject.constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\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) {\n return _clone(object, [], replaces);\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();\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() {\n this.sync();\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"],"names":[],"mappings":"AAAO,MAAM,sBAAsB,CAAC;AACpC;;ACDO,MAAM,wBAAwB,CAAC;AACtC;;AC4BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC9BO,MAAM,QAAQ,CAAC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E,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;;;;"}
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) {\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 prototypeObject = Object.getPrototypeOf(object);\n const ConstructorObject = prototypeObject.constructor;\n if (PRIMITIVES.includes(ConstructorObject)) {\n return new ConstructorObject(object);\n }\n const _object = new ConstructorObject();\n for (const key in object) {\n _object[key] = replaces\n ? replaces[key] ?? _clone(object[key], caches)\n : _clone(object[key], caches);\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) {\n return _clone(object, [], replaces);\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();\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() {\n this.sync();\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;;AC4BO,SAAS,WAAW,CAAC,MAAM,EAAE;AACpC,IAAI,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,IAAI,CAAC;AAC5D;;AC9BO,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;AACL,IAAI,KAAK,CAAC,QAAQ,EAAE;AACpB,QAAQ,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC;AACvD,KAAK;AACL,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE;AACzB,QAAQ,OAAO,IAAI,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,KAAK,EAAE,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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;;;;"}
@@ -5,4 +5,5 @@ export * from './entity';
5
5
  export * from './persistent-unit';
6
6
  export * from './procedure';
7
7
  export * from './repository';
8
+ export * from './result';
8
9
  export * from './types';
package/dist/esm/index.js CHANGED
@@ -5,5 +5,6 @@ export * from './entity';
5
5
  export * from './persistent-unit';
6
6
  export * from './procedure';
7
7
  export * from './repository';
8
+ export * from './result';
8
9
  export * from './types';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { AbstractModel } from './types';
2
- export type PersistentUnitResultCode = 'insert' | 'refresh' | 'update' | 'delete' | 'hidden' | 'procedure';
2
+ export type PersistentUnitResultCode = 'insert' | 'refresh' | 'update' | 'delete' | 'hidden' | 'procedure' | 'operation';
3
3
  export declare class PersistentUnitResult {
4
4
  readonly code: PersistentUnitResultCode;
5
5
  readonly error: any;
@@ -1 +1 @@
1
- {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,oBAAoB;IAC/B,YACkB,IAA8B,EAC9B,KAAU,EACV,KAAqB;QAFrB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,UAAK,GAAL,KAAK,CAAK;QACV,UAAK,GAAL,KAAK,CAAgB;IACpC,CAAC;CACL"}
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/result.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,oBAAoB;IAC/B,YACkB,IAA8B,EAC9B,KAAU,EACV,KAAqB;QAFrB,SAAI,GAAJ,IAAI,CAA0B;QAC9B,UAAK,GAAL,KAAK,CAAK;QACV,UAAK,GAAL,KAAK,CAAgB;IACpC,CAAC;CACL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolster/vinegar",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
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",