@agile-ts/core
Advanced tools
Comparing version 0.0.7 to 0.0.8
# Change Log | ||
## 0.0.8 | ||
### Patch Changes | ||
- 198c212: added prettier and eslint and fixed some small issues | ||
## 0.0.7 | ||
@@ -15,4 +21,3 @@ | ||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
@@ -19,0 +24,0 @@ ## [0.0.5](https://github.com/agile-ts/agile/compare/v0.0.4...v0.0.5) (2020-11-05) |
@@ -1,2 +0,2 @@ | ||
import { Runtime, Integration, State, Storage, Collection, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface } from "./internal"; | ||
import { Runtime, Integration, State, Storage, Collection, DefaultItem, Computed, Event, CreateEventConfigInterface, DefaultEventPayload, Integrations, Observer, SubController, Storages, CreateStorageConfigInterface, RegisterConfigInterface, Logger, CreateLoggerConfigInterface, StateConfigInterface } from './internal'; | ||
export declare class Agile { | ||
@@ -3,0 +3,0 @@ config: AgileConfigInterface; |
@@ -67,7 +67,7 @@ "use strict"; | ||
config.logConfig = internal_1.defineConfig(config.logConfig, { | ||
prefix: "Agile", | ||
prefix: 'Agile', | ||
active: true, | ||
level: internal_1.Logger.level.WARN, | ||
canUseCustomStyles: true, | ||
allowedTags: ["runtime", "storage", "subscription", "multieditor"], | ||
allowedTags: ['runtime', 'storage', 'subscription', 'multieditor'], | ||
}); | ||
@@ -86,4 +86,4 @@ this.config = { | ||
// Create global instance of Agile | ||
if (!internal_1.globalBind("__agile__", this)) | ||
Agile.logger.warn("Be careful with multiple Agile Instances in one Application!"); | ||
if (!internal_1.globalBind('__agile__', this)) | ||
Agile.logger.warn('Be careful with multiple Agile Instances in one Application!'); | ||
} | ||
@@ -140,5 +140,5 @@ //========================================================================================================= | ||
Agile.logger = new internal_1.Logger({ | ||
prefix: "Agile", | ||
prefix: 'Agile', | ||
active: true, | ||
level: internal_1.Logger.level.WARN, | ||
}); |
@@ -1,2 +0,2 @@ | ||
import { Collection, CollectionKey, CreatePersistentConfigInterface, Group, GroupKey, ItemKey, Persistent, PersistentKey, StorageKey } from "../internal"; | ||
import { Collection, CollectionKey, CreatePersistentConfigInterface, Group, GroupKey, ItemKey, Persistent, PersistentKey, StorageKey } from '../internal'; | ||
export declare class CollectionPersistent<DataType = any> extends Persistent { | ||
@@ -3,0 +3,0 @@ collection: () => Collection<DataType>; |
@@ -119,3 +119,3 @@ "use strict"; | ||
// Load Items into Collection | ||
for (let itemKey of defaultGroup._value) { | ||
for (const itemKey of defaultGroup._value) { | ||
const itemStorageKey = CollectionPersistent.getItemStorageKey(itemKey, _key); | ||
@@ -163,3 +163,3 @@ // Get Storage Value | ||
// Persist Collection Items | ||
for (let itemKey of defaultGroup._value) { | ||
for (const itemKey of defaultGroup._value) { | ||
const item = this.collection().getItem(itemKey); | ||
@@ -198,3 +198,3 @@ const itemStorageKey = CollectionPersistent.getItemStorageKey(itemKey, _key); | ||
// Remove Collection Items from Storage | ||
for (let itemKey of defaultGroup._value) { | ||
for (const itemKey of defaultGroup._value) { | ||
const item = this.collection().getItem(itemKey); | ||
@@ -279,10 +279,10 @@ (_b = item === null || item === void 0 ? void 0 : item.persistent) === null || _b === void 0 ? void 0 : _b.removePersistedValue(); | ||
if (!itemKey || !collectionKey) | ||
internal_1.Agile.logger.warn("Failed to build unique Item StorageKey!"); | ||
internal_1.Agile.logger.warn('Failed to build unique Item StorageKey!'); | ||
if (!itemKey) | ||
itemKey = "unknown"; | ||
itemKey = 'unknown'; | ||
if (!collectionKey) | ||
collectionKey = "unknown"; | ||
collectionKey = 'unknown'; | ||
return this.storageItemKeyPattern | ||
.replace("${collectionKey}", collectionKey.toString()) | ||
.replace("${itemKey}", itemKey.toString()); | ||
.replace('${collectionKey}', collectionKey.toString()) | ||
.replace('${itemKey}', itemKey.toString()); | ||
} | ||
@@ -300,15 +300,15 @@ //========================================================================================================= | ||
if (!groupKey || !collectionKey) | ||
internal_1.Agile.logger.warn("Failed to build unique Group StorageKey!"); | ||
internal_1.Agile.logger.warn('Failed to build unique Group StorageKey!'); | ||
if (!groupKey) | ||
groupKey = "unknown"; | ||
groupKey = 'unknown'; | ||
if (!collectionKey) | ||
collectionKey = "unknown"; | ||
collectionKey = 'unknown'; | ||
return this.storageGroupKeyPattern | ||
.replace("${collectionKey}", collectionKey.toString()) | ||
.replace("${groupKey}", groupKey.toString()); | ||
.replace('${collectionKey}', collectionKey.toString()) | ||
.replace('${groupKey}', groupKey.toString()); | ||
} | ||
} | ||
exports.CollectionPersistent = CollectionPersistent; | ||
CollectionPersistent.defaultGroupSideEffectKey = "rebuildGroupStorageValue"; | ||
CollectionPersistent.storageItemKeyPattern = "_${collectionKey}_item_${itemKey}"; | ||
CollectionPersistent.storageGroupKeyPattern = "_${collectionKey}_group_${groupKey}"; | ||
CollectionPersistent.defaultGroupSideEffectKey = 'rebuildGroupStorageValue'; | ||
CollectionPersistent.storageItemKeyPattern = '_${collectionKey}_item_${itemKey}'; | ||
CollectionPersistent.storageGroupKeyPattern = '_${collectionKey}_group_${groupKey}'; |
@@ -1,2 +0,2 @@ | ||
import { State, Collection, DefaultItem, ItemKey, Item, StatePersistentConfigInterface, PersistentKey, StateRuntimeJobConfigInterface } from "../internal"; | ||
import { State, Collection, DefaultItem, ItemKey, Item, StatePersistentConfigInterface, PersistentKey, StateRuntimeJobConfigInterface } from '../internal'; | ||
export declare class Group<DataType = DefaultItem> extends State<Array<ItemKey>> { | ||
@@ -95,3 +95,3 @@ static rebuildGroupSideEffectKey: string; | ||
export interface GroupAddConfig { | ||
method?: "unshift" | "push"; | ||
method?: 'unshift' | 'push'; | ||
overwrite?: boolean; | ||
@@ -98,0 +98,0 @@ background?: boolean; |
@@ -131,3 +131,3 @@ "use strict"; | ||
config = internal_1.defineConfig(config, { | ||
method: "push", | ||
method: 'push', | ||
overwrite: false, | ||
@@ -153,3 +153,3 @@ background: false, | ||
// Add new ItemKey to Group | ||
newGroupValue[config.method || "push"](itemKey); | ||
newGroupValue[config.method || 'push'](itemKey); | ||
}); | ||
@@ -177,3 +177,3 @@ // Return if passed ItemKeys already exist | ||
replace(oldItemKey, newItemKey, config = {}) { | ||
let newGroupValue = internal_1.copy(this._value); | ||
const newGroupValue = internal_1.copy(this._value); | ||
newGroupValue.splice(newGroupValue.indexOf(oldItemKey), 1, newItemKey); | ||
@@ -218,3 +218,2 @@ this.set(newGroupValue, config); | ||
const groupItems = []; | ||
let groupOutput; | ||
// Create groupItems by finding Item at ItemKey in Collection | ||
@@ -229,3 +228,3 @@ this._value.forEach((itemKey) => { | ||
// Create groupOutput out of groupItems | ||
groupOutput = groupItems.map((item) => { | ||
const groupOutput = groupItems.map((item) => { | ||
return item.getPublicValue(); | ||
@@ -243,2 +242,2 @@ }); | ||
exports.Group = Group; | ||
Group.rebuildGroupSideEffectKey = "rebuildGroup"; | ||
Group.rebuildGroupSideEffectKey = 'rebuildGroup'; |
@@ -1,2 +0,2 @@ | ||
import { Agile, Item, Group, GroupKey, Selector, SelectorKey, StorageKey, GroupConfigInterface, CollectionPersistent, GroupAddConfig } from "../internal"; | ||
import { Agile, Item, Group, GroupKey, Selector, SelectorKey, StorageKey, GroupConfigInterface, CollectionPersistent, GroupAddConfig } from '../internal'; | ||
export declare class Collection<DataType = DefaultItem> { | ||
@@ -97,2 +97,9 @@ agileInstance: () => Agile; | ||
* @public | ||
* Check if Group exists in Collection | ||
* @param groupKey - Key/Name of Group | ||
* @param config - Config | ||
*/ | ||
hasGroup(groupKey: GroupKey | undefined, config?: HasConfigInterface): boolean; | ||
/** | ||
* @public | ||
* Get Group by Key/Name | ||
@@ -102,3 +109,3 @@ * @param groupKey - Key/Name of Group | ||
*/ | ||
getGroup(groupKey: GroupKey | undefined, config?: GetGroupConfigInterface): Group<DataType> | undefined; | ||
getGroup(groupKey: GroupKey | undefined, config?: HasConfigInterface): Group<DataType> | undefined; | ||
/** | ||
@@ -125,2 +132,9 @@ * @public | ||
* @public | ||
* Check if Selector exists in Collection | ||
* @param selectorKey - Key/Name of Selector | ||
* @param config - Config | ||
*/ | ||
hasSelector(selectorKey: SelectorKey | undefined, config?: HasConfigInterface): boolean; | ||
/** | ||
* @public | ||
* Get Selector by Key/Name | ||
@@ -130,3 +144,3 @@ * @param selectorKey - Key/Name of Selector | ||
*/ | ||
getSelector(selectorKey: SelectorKey | undefined, config?: GetSelectorConfigInterface): Selector<DataType> | undefined; | ||
getSelector(selectorKey: SelectorKey | undefined, config?: HasConfigInterface): Selector<DataType> | undefined; | ||
/** | ||
@@ -146,2 +160,9 @@ * @public | ||
* @public | ||
* Check if Item exists in Collection | ||
* @param itemKey - Key/Name of Item | ||
* @param config - Config | ||
*/ | ||
hasItem(itemKey: ItemKey | undefined, config?: HasConfigInterface): boolean; | ||
/** | ||
* @public | ||
* Get Item by Key/Name | ||
@@ -151,3 +172,3 @@ * @param itemKey - ItemKey of Item | ||
*/ | ||
getItem(itemKey: ItemKey | undefined, config?: GetItemConfigInterface): Item<DataType> | undefined; | ||
getItem(itemKey: ItemKey | undefined, config?: HasConfigInterface): Item<DataType> | undefined; | ||
/** | ||
@@ -165,3 +186,3 @@ * @public | ||
*/ | ||
getItemValue(itemKey: ItemKey | undefined, config?: GetItemConfigInterface): DataType | undefined; | ||
getItemValue(itemKey: ItemKey | undefined, config?: HasConfigInterface): DataType | undefined; | ||
/** | ||
@@ -301,3 +322,3 @@ * @public | ||
patch?: boolean; | ||
method?: "push" | "unshift"; | ||
method?: 'push' | 'unshift'; | ||
forEachItem?: (data: DataType, key: ItemKey, index: number) => void; | ||
@@ -332,20 +353,8 @@ background?: boolean; | ||
/** | ||
* @param notExisting - If also official not existing Items like Placeholder get found | ||
* @param notExisting - If placeholder can be found | ||
*/ | ||
export interface GetItemConfigInterface { | ||
export interface HasConfigInterface { | ||
notExisting?: boolean; | ||
} | ||
/** | ||
* @param notExisting - If also official not existing Groups like Placeholder get found | ||
*/ | ||
export interface GetGroupConfigInterface { | ||
notExisting?: boolean; | ||
} | ||
/** | ||
* @param notExisting - If also official not existing Selectors like Placeholder get found | ||
*/ | ||
export interface GetSelectorConfigInterface { | ||
notExisting?: boolean; | ||
} | ||
/** | ||
* @param instantiate - If Persistent gets instantiated | ||
@@ -352,0 +361,0 @@ * @param storageKeys - Key/Name of Storages which gets used to persist the Collection Value (NOTE: If not passed the default Storage will be used) |
@@ -21,12 +21,12 @@ "use strict"; | ||
this.config = { | ||
defaultGroupKey: "default", | ||
primaryKey: "id", | ||
defaultGroupKey: 'default', | ||
primaryKey: 'id', | ||
}; | ||
// Assign Properties | ||
let _config = typeof config === "function" ? config(this) : config; | ||
let _config = typeof config === 'function' ? config(this) : config; | ||
_config = internal_1.defineConfig(_config, { | ||
primaryKey: "id", | ||
primaryKey: 'id', | ||
groups: {}, | ||
selectors: {}, | ||
defaultGroupKey: "default", | ||
defaultGroupKey: 'default', | ||
}); | ||
@@ -124,3 +124,3 @@ this._key = _config.key; | ||
// Set Key/Name of Group to property Name | ||
for (let key in groupsObject) | ||
for (const key in groupsObject) | ||
if (!groupsObject[key]._key) | ||
@@ -152,3 +152,3 @@ groupsObject[key].setKey(key); | ||
// Set Key/Name of Selector to property Name | ||
for (let key in selectorsObject) | ||
for (const key in selectorsObject) | ||
if (!selectorsObject[key]._key) | ||
@@ -174,3 +174,3 @@ selectorsObject[key].setKey(key); | ||
config = internal_1.defineConfig(config, { | ||
method: "push", | ||
method: 'push', | ||
background: false, | ||
@@ -227,3 +227,3 @@ patch: false, | ||
if (!item) { | ||
internal_1.Agile.logger.error(`ItemKey '${itemKey}' doesn't exist in Collection '${this._key}'!`); | ||
internal_1.Agile.logger.error(`Item with key/name '${itemKey}' doesn't exist in Collection '${this._key}'!`); | ||
return undefined; | ||
@@ -235,19 +235,18 @@ } | ||
} | ||
// Merge changes into current ItemValue | ||
const newItemValue = internal_1.flatMerge(internal_1.copy(item.nextStateValue), changes, { | ||
addNewProperties: config.addNewProperties, | ||
}); | ||
const oldItemKey = item._value[primaryKey]; | ||
const newItemKey = newItemValue[primaryKey]; | ||
const updatedItemKey = oldItemKey !== newItemKey; | ||
const newItemKey = changes[primaryKey] || oldItemKey; | ||
const updateItemKey = oldItemKey !== newItemKey; | ||
// Delete primaryKey from 'changes' because if it has changed, it gets properly updated in 'updateItemKey' (below) | ||
if (changes[primaryKey]) | ||
delete changes[primaryKey]; | ||
// Update ItemKey | ||
if (updateItemKey) | ||
this.updateItemKey(oldItemKey, newItemKey, { | ||
background: config.background, | ||
}); | ||
// Apply changes to Item | ||
item.set(newItemValue, { | ||
item.patch(changes, { | ||
background: config.background, | ||
storage: !updatedItemKey, | ||
addNewProperties: config.addNewProperties, | ||
}); | ||
// Update ItemKey of Item | ||
if (updatedItemKey) | ||
this.updateItemKey(oldItemKey, newItemKey, { | ||
background: config.background, | ||
}); | ||
return item; | ||
@@ -281,2 +280,14 @@ } | ||
//========================================================================================================= | ||
// Has Group | ||
//========================================================================================================= | ||
/** | ||
* @public | ||
* Check if Group exists in Collection | ||
* @param groupKey - Key/Name of Group | ||
* @param config - Config | ||
*/ | ||
hasGroup(groupKey, config = {}) { | ||
return !!this.getGroup(groupKey, config); | ||
} | ||
//========================================================================================================= | ||
// Get Group | ||
@@ -367,2 +378,14 @@ //========================================================================================================= | ||
//========================================================================================================= | ||
// Has Selector | ||
//========================================================================================================= | ||
/** | ||
* @public | ||
* Check if Selector exists in Collection | ||
* @param selectorKey - Key/Name of Selector | ||
* @param config - Config | ||
*/ | ||
hasSelector(selectorKey, config = {}) { | ||
return !!this.getSelector(selectorKey, config); | ||
} | ||
//========================================================================================================= | ||
// Get Selector | ||
@@ -400,3 +423,3 @@ //========================================================================================================= | ||
if (!selector) { | ||
selector = new internal_1.Selector(this, "unknown", { | ||
selector = new internal_1.Selector(this, 'unknown', { | ||
key: selectorKey, | ||
@@ -429,2 +452,14 @@ isPlaceholder: true, | ||
//========================================================================================================= | ||
// Has Item | ||
//========================================================================================================= | ||
/** | ||
* @public | ||
* Check if Item exists in Collection | ||
* @param itemKey - Key/Name of Item | ||
* @param config - Config | ||
*/ | ||
hasItem(itemKey, config = {}) { | ||
return !!this.getItem(itemKey, config); | ||
} | ||
//========================================================================================================= | ||
// Get Item by Id | ||
@@ -461,3 +496,3 @@ //========================================================================================================= | ||
[this.config.primaryKey]: itemKey, | ||
dummy: "item", | ||
dummy: 'item', | ||
}, { | ||
@@ -481,3 +516,3 @@ isPlaceholder: true, | ||
getItemValue(itemKey, config = {}) { | ||
let item = this.getItem(itemKey, config); | ||
const item = this.getItem(itemKey, config); | ||
if (!item) | ||
@@ -542,3 +577,3 @@ return undefined; | ||
let size = 0; | ||
for (let group in this.groups) | ||
for (const group in this.groups) | ||
size++; | ||
@@ -556,3 +591,3 @@ return size; | ||
let size = 0; | ||
for (let selector in this.selectors) | ||
for (const selector in this.selectors) | ||
size++; | ||
@@ -574,6 +609,6 @@ return size; | ||
// Reset Groups | ||
for (let key in this.groups) | ||
for (const key in this.groups) | ||
(_a = this.getGroup(key)) === null || _a === void 0 ? void 0 : _a.reset(); | ||
// Reset Selectors | ||
for (let key in this.selectors) | ||
for (const key in this.selectors) | ||
(_b = this.getSelector(key)) === null || _b === void 0 ? void 0 : _b.reset(); | ||
@@ -618,2 +653,7 @@ } | ||
return false; | ||
// Check if Item with newItemKey already exists | ||
if (this.hasItem(newItemKey)) { | ||
internal_1.Agile.logger.warn(`Couldn't update ItemKey from '${oldItemKey}' to '${newItemKey}' because an Item with the key/name '${newItemKey}' already exists!`); | ||
return false; | ||
} | ||
// Remove Item from old ItemKey and add Item to new ItemKey | ||
@@ -623,14 +663,16 @@ delete this.data[oldItemKey]; | ||
// Update Key/Name of Item | ||
item.setKey(newItemKey); | ||
item.setKey(newItemKey, { | ||
background: config.background, | ||
}); | ||
// Update persist Key of Item (Doesn't get updated by updating key of Item because PersistKey is special formatted) | ||
(_a = item.persistent) === null || _a === void 0 ? void 0 : _a.setKey(internal_1.CollectionPersistent.getItemStorageKey(newItemKey, this._key)); | ||
// Update ItemKey in Groups | ||
for (let groupKey in this.groups) { | ||
for (const groupKey in this.groups) { | ||
const group = this.getGroup(groupKey, { notExisting: true }); | ||
if (!group || !group.has(oldItemKey)) | ||
continue; | ||
group.replace(oldItemKey, newItemKey, { background: config === null || config === void 0 ? void 0 : config.background }); | ||
group.replace(oldItemKey, newItemKey, { background: config.background }); | ||
} | ||
// Update ItemKey in Selectors | ||
for (let selectorKey in this.selectors) { | ||
for (const selectorKey in this.selectors) { | ||
const selector = this.getSelector(selectorKey, { notExisting: true }); | ||
@@ -643,3 +685,3 @@ if (!selector) | ||
force: true, | ||
background: config === null || config === void 0 ? void 0 : config.background, | ||
background: config.background, | ||
}); | ||
@@ -665,3 +707,3 @@ } | ||
const groupKeys = []; | ||
for (let groupKey in this.groups) { | ||
for (const groupKey in this.groups) { | ||
const group = this.getGroup(groupKey, { notExisting: true }); | ||
@@ -731,3 +773,3 @@ if (group === null || group === void 0 ? void 0 : group.has(itemKey)) | ||
// Remove Item from Groups | ||
for (let groupKey in this.groups) { | ||
for (const groupKey in this.groups) { | ||
const group = this.getGroup(groupKey, { notExisting: true }); | ||
@@ -742,3 +784,3 @@ if (group === null || group === void 0 ? void 0 : group.has(itemKey)) | ||
// Reselect Item in Selectors (to create new dummyItem that holds reference) | ||
for (let selectorKey in this.selectors) { | ||
for (const selectorKey in this.selectors) { | ||
const selector = this.getSelector(selectorKey, { notExisting: true }); | ||
@@ -771,3 +813,3 @@ if (selector === null || selector === void 0 ? void 0 : selector.hasSelected(itemKey)) | ||
} | ||
if (!_data.hasOwnProperty(primaryKey)) { | ||
if (!Object.prototype.hasOwnProperty.call(_data, primaryKey)) { | ||
internal_1.Agile.logger.error(`Collection '${this._key}' Item Data has to contain a primaryKey property called '${this.config.primaryKey}'!`); | ||
@@ -809,3 +851,3 @@ return false; | ||
// Rebuild Groups that include ItemKey | ||
for (let groupKey in this.groups) { | ||
for (const groupKey in this.groups) { | ||
const group = this.getGroup(groupKey); | ||
@@ -812,0 +854,0 @@ if (group === null || group === void 0 ? void 0 : group.has(itemKey)) { |
@@ -1,2 +0,2 @@ | ||
import { State, Collection, DefaultItem, StateKey } from "../internal"; | ||
import { State, Collection, DefaultItem, StateKey, StateRuntimeJobConfigInterface } from '../internal'; | ||
export declare class Item<DataType = DefaultItem> extends State<DataType> { | ||
@@ -18,4 +18,5 @@ static updateGroupSideEffectKey: string; | ||
* @param value - New Key/Name of State | ||
* @param config - Config | ||
*/ | ||
setKey(value: StateKey | undefined): this; | ||
setKey(value: StateKey | undefined, config?: SetItemKeyConfig): this; | ||
} | ||
@@ -28,1 +29,7 @@ /** | ||
} | ||
/** | ||
* @param updateItemValuePrimaryKey - If the primaryKey in ItemValue gets update | ||
*/ | ||
export interface SetItemKeyConfig extends StateRuntimeJobConfigInterface { | ||
updateItemValuePrimaryKey?: boolean; | ||
} |
@@ -21,3 +21,5 @@ "use strict"; | ||
// Reassign Key to assign sideEffects | ||
this.setKey(data[collection.config.primaryKey]); | ||
this.setKey(data[collection.config.primaryKey], { | ||
updateItemValuePrimaryKey: false, | ||
}); | ||
} | ||
@@ -31,5 +33,14 @@ //========================================================================================================= | ||
* @param value - New Key/Name of State | ||
* @param config - Config | ||
*/ | ||
setKey(value) { | ||
setKey(value, config = {}) { | ||
super.setKey(value); | ||
config = internal_1.defineConfig(config, { | ||
sideEffects: true, | ||
background: false, | ||
force: false, | ||
storage: true, | ||
overwrite: false, | ||
updateItemValuePrimaryKey: true, | ||
}); | ||
if (!value) | ||
@@ -41,4 +52,18 @@ return this; | ||
this.addSideEffect(Item.updateGroupSideEffectKey, (config) => this.collection().rebuildGroupsThatIncludeItemKey(value, config)); | ||
// Initial Rebuild | ||
this.collection().rebuildGroupsThatIncludeItemKey(value); | ||
// Update ItemKey in ItemValue (After updating the sideEffect because otherwise it calls the old sideEffect) | ||
if (config.updateItemValuePrimaryKey) | ||
this.patch({ [this.collection().config.primaryKey]: value }, { | ||
sideEffects: config.sideEffects, | ||
background: config.background, | ||
force: config.force, | ||
storage: config.storage, | ||
overwrite: config.overwrite, | ||
}); | ||
// Initial Rebuild (not necessary if updating primaryKey in ItemValue because a sideEffect of the patch method is to rebuild the Group) | ||
if (!config.updateItemValuePrimaryKey) | ||
this.collection().rebuildGroupsThatIncludeItemKey(value, { | ||
background: config.background, | ||
force: config.force, | ||
sideEffects: config.sideEffects, | ||
}); | ||
return this; | ||
@@ -48,2 +73,2 @@ } | ||
exports.Item = Item; | ||
Item.updateGroupSideEffectKey = "rebuildGroup"; | ||
Item.updateGroupSideEffectKey = 'rebuildGroup'; |
@@ -1,2 +0,2 @@ | ||
import { Collection, DefaultItem, Item, ItemKey, State, StateRuntimeJobConfigInterface } from "../internal"; | ||
import { Collection, DefaultItem, Item, ItemKey, State, StateRuntimeJobConfigInterface } from '../internal'; | ||
export declare class Selector<DataType = DefaultItem> extends State<DataType | undefined> { | ||
@@ -3,0 +3,0 @@ static dummyItemKey: string; |
@@ -54,3 +54,3 @@ "use strict"; | ||
}); // Because this.item might be outdated | ||
let newItem = this.collection().getItemWithReference(itemKey); | ||
const newItem = this.collection().getItemWithReference(itemKey); | ||
config = internal_1.defineConfig(config, { | ||
@@ -137,3 +137,3 @@ background: false, | ||
exports.Selector = Selector; | ||
Selector.dummyItemKey = "unknown"; | ||
Selector.rebuildSelectorSideEffectKey = "rebuildSelector"; | ||
Selector.dummyItemKey = 'unknown'; | ||
Selector.rebuildSelectorSideEffectKey = 'rebuildSelector'; |
@@ -1,2 +0,2 @@ | ||
import { Observer } from "../runtime/observer"; | ||
import { Observer } from '../runtime/observer'; | ||
export declare class ComputedTracker { | ||
@@ -3,0 +3,0 @@ static isTracking: boolean; |
@@ -1,2 +0,2 @@ | ||
import { State, Agile, Observer, StorageKey, StatePersistentConfigInterface, Event, StateConfigInterface } from "../internal"; | ||
import { State, Agile, Observer, Event, StateConfigInterface } from '../internal'; | ||
export declare class Computed<ComputedValueType = any> extends State<ComputedValueType> { | ||
@@ -41,3 +41,3 @@ agileInstance: () => Agile; | ||
patch(): this; | ||
persist(keyOrConfig?: StorageKey | StatePersistentConfigInterface, config?: StatePersistentConfigInterface): this; | ||
persist(): this; | ||
invert(): this; | ||
@@ -44,0 +44,0 @@ } |
@@ -88,3 +88,3 @@ "use strict"; | ||
const computedValue = this.computeFunction(); | ||
let foundDeps = internal_1.ComputedTracker.getTrackedObservers(); | ||
const foundDeps = internal_1.ComputedTracker.getTrackedObservers(); | ||
// Handle foundDeps and hardCodedDeps | ||
@@ -110,3 +110,3 @@ const newDeps = []; | ||
const finalInstances = []; | ||
for (let instance of instances) { | ||
for (const instance of instances) { | ||
if (instance instanceof internal_1.Observer) { | ||
@@ -117,5 +117,5 @@ finalInstances.push(instance); | ||
if (instance !== undefined && | ||
instance["observer"] !== undefined && | ||
instance["observer"] instanceof internal_1.Observer) | ||
finalInstances.push(instance["observer"]); | ||
instance['observer'] !== undefined && | ||
instance['observer'] instanceof internal_1.Observer) | ||
finalInstances.push(instance['observer']); | ||
} | ||
@@ -131,3 +131,3 @@ return finalInstances; | ||
} | ||
persist(keyOrConfig = {}, config = {}) { | ||
persist() { | ||
internal_1.Agile.logger.error("You can't use persist method on ComputedState!"); | ||
@@ -134,0 +134,0 @@ return this; |
@@ -1,2 +0,2 @@ | ||
import { Observer, RuntimeJob, ObserverKey, Event, SubscriptionContainer, IngestConfigInterface, RuntimeJobConfigInterface, RuntimeJobKey } from "../internal"; | ||
import { Observer, RuntimeJob, ObserverKey, Event, SubscriptionContainer, IngestConfigInterface, RuntimeJobConfigInterface, RuntimeJobKey } from '../internal'; | ||
export declare class EventObserver<PayloadType = any> extends Observer { | ||
@@ -3,0 +3,0 @@ event: () => Event<PayloadType>; |
@@ -1,3 +0,3 @@ | ||
import { Agile, EventJob, Observer } from "../internal"; | ||
import { EventObserver } from "./event.observer"; | ||
import { Agile, EventJob, Observer } from '../internal'; | ||
import { EventObserver } from './event.observer'; | ||
export declare class Event<PayloadType = DefaultEventPayload> { | ||
@@ -4,0 +4,0 @@ agileInstance: () => Agile; |
@@ -82,3 +82,3 @@ "use strict"; | ||
if (!internal_1.isFunction(_callback)) { | ||
internal_1.Agile.logger.error("A Event Callback Function has to be typeof Function!"); | ||
internal_1.Agile.logger.error('A Event Callback Function has to be typeof Function!'); | ||
return this; | ||
@@ -174,8 +174,10 @@ } | ||
if (!keys) { | ||
for (let key in this.callbacks) | ||
for (const key in this.callbacks) | ||
this.callbacks[key](payload); | ||
} | ||
else { | ||
for (let key of keys) | ||
this.callbacks[key](payload); | ||
for (const key of keys) { | ||
if (this.callbacks[key]) | ||
this.callbacks[key](payload); | ||
} | ||
} | ||
@@ -182,0 +184,0 @@ // Cause rerender |
@@ -1,3 +0,3 @@ | ||
import { Agile } from "./internal"; | ||
export * from "./internal"; | ||
import { Agile } from './internal'; | ||
export * from './internal'; | ||
export default Agile; |
@@ -1,2 +0,2 @@ | ||
import { Agile, Integration } from "../internal"; | ||
import { Agile, Integration } from '../internal'; | ||
export declare class Integrations { | ||
@@ -3,0 +3,0 @@ agileInstance: () => Agile; |
@@ -38,3 +38,3 @@ "use strict"; | ||
if (!integration._key) { | ||
internal_1.Agile.logger.error("Failed to integrate framework! Invalid Integration!", integration._key); | ||
internal_1.Agile.logger.error('Failed to integrate framework! Invalid Integration!', integration._key); | ||
return false; | ||
@@ -41,0 +41,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Agile } from "../internal"; | ||
import { Agile } from '../internal'; | ||
export declare class Integration<F = any, C = any> { | ||
@@ -3,0 +3,0 @@ _key: IntegrationKey; |
@@ -1,29 +0,29 @@ | ||
export * from "./logger"; | ||
export * from "./utils"; | ||
export * from "./agile"; | ||
export * from "./runtime"; | ||
export * from "./runtime/observer"; | ||
export * from "./runtime/runtime.job"; | ||
export * from "./runtime/subscription/container/SubscriptionContainer"; | ||
export * from "./runtime/subscription/container/CallbackSubscriptionContainer"; | ||
export * from "./runtime/subscription/container/ComponentSubscriptionContainer"; | ||
export * from "./runtime/subscription/sub.controller"; | ||
export * from "./storages"; | ||
export * from "./storages/storage"; | ||
export * from "./storages/persistent"; | ||
export * from "./state"; | ||
export * from "./state/state.observer"; | ||
export * from "./state/state.persistent"; | ||
export * from "./state/state.runtime.job"; | ||
export * from "./computed"; | ||
export * from "./computed/computed.tracker"; | ||
export * from "./collection"; | ||
export * from "./collection/group"; | ||
export * from "./collection/item"; | ||
export * from "./collection/selector"; | ||
export * from "./collection/collection.persistent"; | ||
export * from "./event"; | ||
export * from "./event/event.job"; | ||
export * from "./event/event.observer"; | ||
export * from "./integrations"; | ||
export * from "./integrations/integration"; | ||
export * from './logger'; | ||
export * from './utils'; | ||
export * from './agile'; | ||
export * from './runtime'; | ||
export * from './runtime/observer'; | ||
export * from './runtime/runtime.job'; | ||
export * from './runtime/subscription/container/SubscriptionContainer'; | ||
export * from './runtime/subscription/container/CallbackSubscriptionContainer'; | ||
export * from './runtime/subscription/container/ComponentSubscriptionContainer'; | ||
export * from './runtime/subscription/sub.controller'; | ||
export * from './storages'; | ||
export * from './storages/storage'; | ||
export * from './storages/persistent'; | ||
export * from './state'; | ||
export * from './state/state.observer'; | ||
export * from './state/state.persistent'; | ||
export * from './state/state.runtime.job'; | ||
export * from './computed'; | ||
export * from './computed/computed.tracker'; | ||
export * from './collection'; | ||
export * from './collection/group'; | ||
export * from './collection/item'; | ||
export * from './collection/selector'; | ||
export * from './collection/collection.persistent'; | ||
export * from './event'; | ||
export * from './event/event.job'; | ||
export * from './event/event.observer'; | ||
export * from './integrations'; | ||
export * from './integrations/integration'; |
@@ -151,3 +151,3 @@ export declare class Logger { | ||
export declare type LoggerConfig = CreateLoggerConfigInterface | ((logger: Logger) => CreateLoggerConfigInterface); | ||
export declare type ConsoleLogType = "log" | "warn" | "error" | "trace" | "table" | "info" | "debug"; | ||
export declare type ConsoleLogType = 'log' | 'warn' | 'error' | 'trace' | 'table' | 'info' | 'debug'; | ||
export declare type LoggerWatcherCallback = (loggerCategory: LoggerCategoryInterface, data: any[]) => void; | ||
@@ -154,0 +154,0 @@ /** |
@@ -14,5 +14,5 @@ "use strict"; | ||
this.watchers = {}; | ||
let _config = typeof config === "function" ? config(this) : config; | ||
let _config = typeof config === 'function' ? config(this) : config; | ||
_config = internal_1.defineConfig(_config, { | ||
prefix: "", | ||
prefix: '', | ||
allowedTags: [], | ||
@@ -65,34 +65,34 @@ canUseCustomStyles: true, | ||
this.createLoggerCategory({ | ||
key: "log", | ||
key: 'log', | ||
level: Logger.level.LOG, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "debug", | ||
customStyle: "color: #3c3c3c;", | ||
prefix: "Debug", | ||
key: 'debug', | ||
customStyle: 'color: #3c3c3c;', | ||
prefix: 'Debug', | ||
level: Logger.level.DEBUG, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "info", | ||
customStyle: "color: #6c69a0;", | ||
prefix: "Info", | ||
key: 'info', | ||
customStyle: 'color: #6c69a0;', | ||
prefix: 'Info', | ||
level: Logger.level.INFO, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "warn", | ||
prefix: "Warn", | ||
key: 'warn', | ||
prefix: 'Warn', | ||
level: Logger.level.WARN, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "error", | ||
prefix: "Error", | ||
key: 'error', | ||
prefix: 'Error', | ||
level: Logger.level.ERROR, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "trace", | ||
prefix: "Trace", | ||
key: 'trace', | ||
prefix: 'Trace', | ||
level: Logger.level.TRACE, | ||
}); | ||
this.createLoggerCategory({ | ||
key: "table", | ||
key: 'table', | ||
level: Logger.level.TABLE, | ||
@@ -122,34 +122,48 @@ }); | ||
return { | ||
log: () => { }, | ||
debug: () => { }, | ||
info: () => { }, | ||
warn: () => { }, | ||
error: () => { }, | ||
trace: () => { }, | ||
table: () => { }, | ||
log: () => { | ||
/* do nothing */ | ||
}, | ||
debug: () => { | ||
/* do nothing */ | ||
}, | ||
info: () => { | ||
/* do nothing */ | ||
}, | ||
warn: () => { | ||
/* do nothing */ | ||
}, | ||
error: () => { | ||
/* do nothing */ | ||
}, | ||
trace: () => { | ||
/* do nothing */ | ||
}, | ||
table: () => { | ||
/* do nothing */ | ||
}, | ||
}; | ||
} | ||
log(...data) { | ||
this.invokeConsole(data, "log", "log"); | ||
this.invokeConsole(data, 'log', 'log'); | ||
} | ||
debug(...data) { | ||
this.invokeConsole(data, "debug", typeof console.debug !== "undefined" ? "debug" : "log"); | ||
this.invokeConsole(data, 'debug', typeof console.debug !== 'undefined' ? 'debug' : 'log'); | ||
} | ||
info(...data) { | ||
this.invokeConsole(data, "info", typeof console.info !== "undefined" ? "info" : "log"); | ||
this.invokeConsole(data, 'info', typeof console.info !== 'undefined' ? 'info' : 'log'); | ||
} | ||
warn(...data) { | ||
this.invokeConsole(data, "warn", typeof console.warn !== "undefined" ? "warn" : "log"); | ||
this.invokeConsole(data, 'warn', typeof console.warn !== 'undefined' ? 'warn' : 'log'); | ||
} | ||
error(...data) { | ||
this.invokeConsole(data, "error", typeof console.error !== "undefined" ? "error" : "log"); | ||
this.invokeConsole(data, 'error', typeof console.error !== 'undefined' ? 'error' : 'log'); | ||
} | ||
trace(...data) { | ||
this.invokeConsole(data, "trace", typeof console.trace !== "undefined" ? "trace" : "log"); | ||
this.invokeConsole(data, 'trace', typeof console.trace !== 'undefined' ? 'trace' : 'log'); | ||
} | ||
table(...data) { | ||
this.invokeConsole(data, "table", typeof console.table !== "undefined" ? "table" : "log"); | ||
this.invokeConsole(data, 'table', typeof console.table !== 'undefined' ? 'table' : 'log'); | ||
} | ||
custom(loggerCategory, ...data) { | ||
this.invokeConsole(data, loggerCategory, "log"); | ||
this.invokeConsole(data, loggerCategory, 'log'); | ||
} | ||
@@ -173,18 +187,18 @@ //========================================================================================================= | ||
const buildPrefix = () => { | ||
let prefix = ""; | ||
let prefix = ''; | ||
if (this.config.prefix) | ||
prefix = prefix.concat(this.config.prefix); | ||
if (loggerCategory.prefix) | ||
prefix = prefix.concat(" " + loggerCategory.prefix); | ||
prefix = prefix.concat(' ' + loggerCategory.prefix); | ||
if (this.config.prefix || loggerCategory.prefix) | ||
prefix = prefix.concat(":"); | ||
prefix = prefix.concat(':'); | ||
return prefix; | ||
}; | ||
// Add built Prefix | ||
if (typeof data[0] === "string") | ||
data[0] = buildPrefix().concat(" ").concat(data[0]); | ||
if (typeof data[0] === 'string') | ||
data[0] = buildPrefix().concat(' ').concat(data[0]); | ||
else | ||
data.unshift(buildPrefix()); | ||
// Call Watcher Callbacks | ||
for (let key in this.watchers) { | ||
for (const key in this.watchers) { | ||
const watcher = this.watchers[key]; | ||
@@ -199,4 +213,4 @@ if (loggerCategory.level >= (watcher.level || 0)) { | ||
let hasStyledString = false; // NOTE: Only one style can be used for one String block! | ||
for (let log of data) { | ||
if (!hasStyledString && typeof log === "string") { | ||
for (const log of data) { | ||
if (!hasStyledString && typeof log === 'string') { | ||
newLogs.push(`%c${log}`); | ||
@@ -213,6 +227,6 @@ newLogs.push(loggerCategory.customStyle); | ||
// Handle Console Table Log | ||
if (consoleLogType === "table") { | ||
if (typeof data[0] === "string") { | ||
if (consoleLogType === 'table') { | ||
if (typeof data[0] === 'string') { | ||
console.log(data[0]); | ||
console.table(data.filter((d) => typeof d !== "string" && "number")); | ||
console.table(data.filter((d) => typeof d !== 'string' && 'number')); | ||
} | ||
@@ -234,3 +248,3 @@ return; | ||
loggerCategory = internal_1.defineConfig(loggerCategory, { | ||
prefix: "", | ||
prefix: '', | ||
level: 0, | ||
@@ -268,3 +282,3 @@ }); | ||
if (!internal_1.isFunction(_config.callback)) { | ||
console.error("Agile: A Watcher Callback Function has to be an function!"); | ||
console.error('Agile: A Watcher Callback Function has to be an function!'); | ||
return this; | ||
@@ -271,0 +285,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Agile, SubscriptionContainer, RuntimeJob } from "../internal"; | ||
import { Agile, SubscriptionContainer, RuntimeJob } from '../internal'; | ||
export declare class Runtime { | ||
@@ -3,0 +3,0 @@ agileInstance: () => Agile; |
@@ -34,3 +34,3 @@ "use strict"; | ||
// Logging | ||
internal_1.Agile.logger.if.tag(["runtime"]).info(`Created Job '${job._key}'`, job); | ||
internal_1.Agile.logger.if.tag(['runtime']).info(`Created Job '${job._key}'`, job); | ||
// Perform Job | ||
@@ -60,3 +60,3 @@ if (config.perform) { | ||
// Logging | ||
internal_1.Agile.logger.if.tag(["runtime"]).info(`Completed Job '${job._key}'`, job); | ||
internal_1.Agile.logger.if.tag(['runtime']).info(`Completed Job '${job._key}'`, job); | ||
// Perform Jobs as long as Jobs are left in queue, if no job left update/rerender Subscribers of jobsToRerender | ||
@@ -125,4 +125,4 @@ if (this.jobQueue.length > 0) { | ||
internal_1.Agile.logger.if | ||
.tag(["runtime"]) | ||
.info("Updated/Rerendered Subscriptions", subscriptionsToUpdate); | ||
.tag(['runtime']) | ||
.info('Updated/Rerendered Subscriptions', subscriptionsToUpdate); | ||
return true; | ||
@@ -145,3 +145,3 @@ } | ||
// Find Key of Job Observer in SubscriptionContainer | ||
for (let key in subscriptionContainer.subsObject) | ||
for (const key in subscriptionContainer.subsObject) | ||
if (subscriptionContainer.subsObject[key] === job.observer) | ||
@@ -165,5 +165,5 @@ foundKey = key; | ||
if (subscriptionContainer.subsObject && | ||
subscriptionContainer.subsObject[updatedKey]["value"]) | ||
subscriptionContainer.subsObject[updatedKey]['value']) | ||
props[updatedKey] = | ||
subscriptionContainer.subsObject[updatedKey]["value"]; | ||
subscriptionContainer.subsObject[updatedKey]['value']; | ||
}); | ||
@@ -170,0 +170,0 @@ subscriptionContainer.observerKeysToUpdate = []; |
@@ -1,2 +0,2 @@ | ||
import { Agile, StateKey, RuntimeJob, SubscriptionContainer } from "../internal"; | ||
import { Agile, StateKey, RuntimeJob, SubscriptionContainer } from '../internal'; | ||
export declare type ObserverKey = string | number; | ||
@@ -3,0 +3,0 @@ export declare class Observer<ValueType = any> { |
@@ -1,2 +0,2 @@ | ||
import { Observer, SubscriptionContainer } from "../internal"; | ||
import { Observer, SubscriptionContainer } from '../internal'; | ||
export declare class RuntimeJob<ObserverType extends Observer = Observer> { | ||
@@ -3,0 +3,0 @@ _key?: RuntimeJobKey; |
@@ -1,2 +0,2 @@ | ||
import { Observer, SubscriptionContainer, SubscriptionContainerKeyType } from "../../../internal"; | ||
import { Observer, SubscriptionContainer, SubscriptionContainerKeyType } from '../../../internal'; | ||
export declare class CallbackSubscriptionContainer extends SubscriptionContainer { | ||
@@ -3,0 +3,0 @@ callback: Function; |
@@ -1,2 +0,2 @@ | ||
import { Observer, SubscriptionContainer, SubscriptionContainerKeyType } from "../../../internal"; | ||
import { Observer, SubscriptionContainer, SubscriptionContainerKeyType } from '../../../internal'; | ||
export declare class ComponentSubscriptionContainer extends SubscriptionContainer { | ||
@@ -3,0 +3,0 @@ component: any; |
@@ -1,2 +0,2 @@ | ||
import { Observer } from "../../../internal"; | ||
import { Observer } from '../../../internal'; | ||
export declare class SubscriptionContainer { | ||
@@ -3,0 +3,0 @@ key?: SubscriptionContainerKeyType; |
@@ -1,2 +0,2 @@ | ||
import { Agile, Observer, SubscriptionContainer, ComponentSubscriptionContainer, CallbackSubscriptionContainer, SubscriptionContainerKeyType } from "../../internal"; | ||
import { Agile, Observer, SubscriptionContainer, ComponentSubscriptionContainer, CallbackSubscriptionContainer, SubscriptionContainerKeyType } from '../../internal'; | ||
export declare class SubController { | ||
@@ -25,3 +25,3 @@ agileInstance: () => Agile; | ||
props: { | ||
[key: string]: Observer["value"]; | ||
[key: string]: Observer['value']; | ||
}; | ||
@@ -28,0 +28,0 @@ }; |
@@ -31,3 +31,3 @@ "use strict"; | ||
const subsArray = []; | ||
for (let key in subs) | ||
for (const key in subs) | ||
subsArray.push(subs[key]); | ||
@@ -40,3 +40,3 @@ // Register Subscription -> decide weather subscriptionInstance is callback or component based | ||
// Register subs and build props object | ||
for (let key in subs) { | ||
for (const key in subs) { | ||
const observer = subs[key]; | ||
@@ -92,4 +92,4 @@ observer.subscribe(subscriptionContainer); | ||
internal_1.Agile.logger.if | ||
.tag(["core", "subscription"]) | ||
.info("Unregistered Callback based Subscription ", subscriptionInstance); | ||
.tag(['core', 'subscription']) | ||
.info('Unregistered Callback based Subscription ', subscriptionInstance); | ||
return; | ||
@@ -103,4 +103,4 @@ } | ||
internal_1.Agile.logger.if | ||
.tag(["core", "subscription"]) | ||
.info("Unregistered Component based Subscription ", subscriptionInstance); | ||
.tag(['core', 'subscription']) | ||
.info('Unregistered Component based Subscription ', subscriptionInstance); | ||
return; | ||
@@ -114,4 +114,4 @@ } | ||
internal_1.Agile.logger.if | ||
.tag(["core", "subscription"]) | ||
.info("Unregistered Component based Subscription ", subscriptionInstance); | ||
.tag(['core', 'subscription']) | ||
.info('Unregistered Component based Subscription ', subscriptionInstance); | ||
return; | ||
@@ -159,4 +159,4 @@ } | ||
internal_1.Agile.logger.if | ||
.tag(["core", "subscription"]) | ||
.info("Registered Component based Subscription ", componentSubscriptionContainer); | ||
.tag(['core', 'subscription']) | ||
.info('Registered Component based Subscription ', componentSubscriptionContainer); | ||
return componentSubscriptionContainer; | ||
@@ -180,4 +180,4 @@ } | ||
internal_1.Agile.logger.if | ||
.tag(["core", "subscription"]) | ||
.info("Registered Callback based Subscription ", callbackSubscriptionContainer); | ||
.tag(['core', 'subscription']) | ||
.info('Registered Callback based Subscription ', callbackSubscriptionContainer); | ||
return callbackSubscriptionContainer; | ||
@@ -184,0 +184,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Agile, StorageKey, StateObserver, StatePersistent, Observer, PersistentKey, StateIngestConfigInterface, StateRuntimeJobConfigInterface } from "../internal"; | ||
import { Agile, StorageKey, StateObserver, StatePersistent, Observer, PersistentKey, StateIngestConfigInterface, StateRuntimeJobConfigInterface } from '../internal'; | ||
export declare class State<ValueType = any> { | ||
@@ -3,0 +3,0 @@ agileInstance: () => Agile; |
@@ -139,3 +139,3 @@ "use strict"; | ||
type(type) { | ||
const supportedTypes = ["String", "Boolean", "Array", "Object", "Number"]; | ||
const supportedTypes = ['String', 'Boolean', 'Array', 'Object', 'Number']; | ||
// Check if type is a supported Type | ||
@@ -197,3 +197,3 @@ if (!supportedTypes.includes(type.name)) { | ||
if (!internal_1.isValidObject(targetWithChanges)) { | ||
internal_1.Agile.logger.error("TargetWithChanges has to be an Object!"); | ||
internal_1.Agile.logger.error('TargetWithChanges has to be an Object!'); | ||
return this; | ||
@@ -227,3 +227,3 @@ } | ||
if (!internal_1.isFunction(_callback)) { | ||
internal_1.Agile.logger.error("A Watcher Callback Function has to be typeof Function!"); | ||
internal_1.Agile.logger.error('A Watcher Callback Function has to be typeof Function!'); | ||
return this; | ||
@@ -257,3 +257,3 @@ } | ||
onInaugurated(callback) { | ||
const watcherKey = "InauguratedWatcherKey"; | ||
const watcherKey = 'InauguratedWatcherKey'; | ||
this.watch(watcherKey, (value) => { | ||
@@ -372,7 +372,7 @@ callback(value); | ||
invert() { | ||
if (typeof this._value === "boolean") { | ||
if (typeof this._value === 'boolean') { | ||
this.set(!this._value); | ||
} | ||
else { | ||
internal_1.Agile.logger.error("You can only invert boolean based States!"); | ||
internal_1.Agile.logger.error('You can only invert boolean based States!'); | ||
} | ||
@@ -391,3 +391,3 @@ return this; | ||
if (!internal_1.isFunction(method)) { | ||
internal_1.Agile.logger.error("A computeMethod has to be a function!"); | ||
internal_1.Agile.logger.error('A computeMethod has to be a function!'); | ||
return this; | ||
@@ -409,3 +409,3 @@ } | ||
if (!internal_1.isFunction(sideEffect)) { | ||
internal_1.Agile.logger.error("A sideEffect function has to be a function!"); | ||
internal_1.Agile.logger.error('A sideEffect function has to be a function!'); | ||
return this; | ||
@@ -451,3 +451,3 @@ } | ||
return true; | ||
let type = typeof value; | ||
const type = typeof value; | ||
return type === this.valueType; | ||
@@ -464,4 +464,4 @@ } | ||
// If State Value is used internal and output represents the real state value (for instance in Group) | ||
if (this["output"] !== undefined) | ||
return this["output"]; | ||
if (this['output'] !== undefined) | ||
return this['output']; | ||
return this._value; | ||
@@ -468,0 +468,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { Observer, State, ObserverKey, SubscriptionContainer, IngestConfigInterface, StateRuntimeJob, StateRuntimeJobConfigInterface, RuntimeJobKey } from "../internal"; | ||
import { Observer, State, ObserverKey, SubscriptionContainer, IngestConfigInterface, StateRuntimeJob, StateRuntimeJobConfigInterface, RuntimeJobKey } from '../internal'; | ||
export declare class StateObserver<ValueType = any> extends Observer { | ||
@@ -3,0 +3,0 @@ state: () => State<ValueType>; |
@@ -114,3 +114,3 @@ "use strict"; | ||
// Call Watchers Functions | ||
for (let watcherKey in state.watchers) | ||
for (const watcherKey in state.watchers) | ||
if (internal_1.isFunction(state.watchers[watcherKey])) | ||
@@ -120,3 +120,3 @@ state.watchers[watcherKey](state.getPublicValue()); | ||
if ((_a = job.config) === null || _a === void 0 ? void 0 : _a.sideEffects) | ||
for (let sideEffectKey in state.sideEffects) | ||
for (const sideEffectKey in state.sideEffects) | ||
if (internal_1.isFunction(state.sideEffects[sideEffectKey])) | ||
@@ -123,0 +123,0 @@ state.sideEffects[sideEffectKey](job.config); |
@@ -1,2 +0,2 @@ | ||
import { CreatePersistentConfigInterface, Persistent, PersistentKey, State, StorageKey } from "../internal"; | ||
import { CreatePersistentConfigInterface, Persistent, PersistentKey, State, StorageKey } from '../internal'; | ||
export declare class StatePersistent<ValueType = any> extends Persistent { | ||
@@ -3,0 +3,0 @@ static storeValueSideEffectKey: string; |
@@ -190,2 +190,2 @@ "use strict"; | ||
exports.StatePersistent = StatePersistent; | ||
StatePersistent.storeValueSideEffectKey = "rebuildStateStorageValue"; | ||
StatePersistent.storeValueSideEffectKey = 'rebuildStateStorageValue'; |
@@ -1,2 +0,2 @@ | ||
import { RuntimeJob, RuntimeJobConfigInterface, RuntimeJobKey, StateObserver } from "../internal"; | ||
import { RuntimeJob, RuntimeJobConfigInterface, RuntimeJobKey, StateObserver } from '../internal'; | ||
export declare class StateRuntimeJob extends RuntimeJob<StateObserver> { | ||
@@ -3,0 +3,0 @@ config: StateRuntimeJobConfigInterface; |
@@ -1,2 +0,2 @@ | ||
import { Agile, Storage, Persistent, StorageKey, StorageItemKey } from "../internal"; | ||
import { Agile, Storage, Persistent, StorageKey, StorageItemKey } from '../internal'; | ||
export declare class Storages { | ||
@@ -3,0 +3,0 @@ agileInstance: () => Agile; |
@@ -32,3 +32,3 @@ "use strict"; | ||
if (!Storages.localStorageAvailable()) { | ||
internal_1.Agile.logger.warn("Local Storage is here not available, to use Storage functionalities like persist please provide a custom Storage!"); | ||
internal_1.Agile.logger.warn('Local Storage is here not available, to use Storage functionalities like persist please provide a custom Storage!'); | ||
return false; | ||
@@ -38,3 +38,3 @@ } | ||
const _localStorage = new internal_1.Storage({ | ||
key: "localStorage", | ||
key: 'localStorage', | ||
async: false, | ||
@@ -61,3 +61,3 @@ methods: { | ||
// Check if Storage already exists | ||
if (this.storages.hasOwnProperty(storage.key)) { | ||
if (Object.prototype.hasOwnProperty.call(this.storages, storage.key)) { | ||
internal_1.Agile.logger.error(`Storage with the key/name '${storage.key}' already exists`); | ||
@@ -68,3 +68,3 @@ return false; | ||
if (!hasRegisteredAnyStorage && config.default === false) { | ||
internal_1.Agile.logger.warn("Be aware that Agile has to assign the first added Storage as default Storage!"); | ||
internal_1.Agile.logger.warn('Be aware that Agile has to assign the first added Storage as default Storage!'); | ||
} | ||
@@ -126,3 +126,3 @@ if (!hasRegisteredAnyStorage) | ||
if (!this.hasStorage()) { | ||
internal_1.Agile.logger.error("No Storage found! Please provide at least one Storage."); | ||
internal_1.Agile.logger.error('No Storage found! Please provide at least one Storage.'); | ||
return Promise.resolve(undefined); | ||
@@ -152,3 +152,3 @@ } | ||
if (!this.hasStorage()) { | ||
internal_1.Agile.logger.error("No Storage found! Please provide at least one Storage."); | ||
internal_1.Agile.logger.error('No Storage found! Please provide at least one Storage.'); | ||
return; | ||
@@ -158,3 +158,3 @@ } | ||
if (storageKeys) { | ||
for (let storageKey of storageKeys) | ||
for (const storageKey of storageKeys) | ||
(_a = this.getStorage(storageKey)) === null || _a === void 0 ? void 0 : _a.set(key, value); | ||
@@ -178,3 +178,3 @@ return; | ||
if (!this.hasStorage()) { | ||
internal_1.Agile.logger.error("No Storage found! Please provide at least one Storage."); | ||
internal_1.Agile.logger.error('No Storage found! Please provide at least one Storage.'); | ||
return; | ||
@@ -184,3 +184,3 @@ } | ||
if (storageKeys) { | ||
for (let storageKey of storageKeys) | ||
for (const storageKey of storageKeys) | ||
(_a = this.getStorage(storageKey)) === null || _a === void 0 ? void 0 : _a.remove(key); | ||
@@ -211,4 +211,4 @@ return; | ||
try { | ||
localStorage.setItem("_myDummyKey_", "myDummyValue"); | ||
localStorage.removeItem("_myDummyKey_"); | ||
localStorage.setItem('_myDummyKey_', 'myDummyValue'); | ||
localStorage.removeItem('_myDummyKey_'); | ||
return true; | ||
@@ -215,0 +215,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { Agile, StorageKey } from "../internal"; | ||
export declare class Persistent<ValueType = any> { | ||
import { Agile, StorageKey } from '../internal'; | ||
export declare class Persistent { | ||
agileInstance: () => Agile; | ||
@@ -64,3 +64,3 @@ static placeHolderKey: string; | ||
*/ | ||
loadPersistedValue(key?: PersistentKey): Promise<boolean>; | ||
loadPersistedValue(): Promise<boolean>; | ||
/** | ||
@@ -71,3 +71,3 @@ * @internal | ||
*/ | ||
persistValue(key?: PersistentKey): Promise<boolean>; | ||
persistValue(): Promise<boolean>; | ||
/** | ||
@@ -78,3 +78,3 @@ * @internal | ||
*/ | ||
removePersistedValue(key?: PersistentKey): Promise<boolean>; | ||
removePersistedValue(): Promise<boolean>; | ||
/** | ||
@@ -81,0 +81,0 @@ * @internal |
@@ -91,3 +91,3 @@ "use strict"; | ||
if (this._key === Persistent.placeHolderKey) { | ||
internal_1.Agile.logger.error("No valid persist Key found! Please provide a Key or assign one to the parent instance."); | ||
internal_1.Agile.logger.error('No valid persist Key found! Please provide a Key or assign one to the parent instance.'); | ||
isValid = false; | ||
@@ -97,3 +97,3 @@ } | ||
if (!this.defaultStorageKey || this.storageKeys.length <= 0) { | ||
internal_1.Agile.logger.error("No persist Storage Key found! Please provide at least one Storage Key."); | ||
internal_1.Agile.logger.error('No persist Storage Key found! Please provide at least one Storage Key.'); | ||
isValid = false; | ||
@@ -151,3 +151,3 @@ } | ||
*/ | ||
loadPersistedValue(key) { | ||
loadPersistedValue() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -166,3 +166,3 @@ internal_1.Agile.logger.error(`'loadPersistedValue' function isn't Set in Persistent! Be aware that Persistent is no stand alone class!`); | ||
*/ | ||
persistValue(key) { | ||
persistValue() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -181,3 +181,3 @@ internal_1.Agile.logger.error(`'persistValue' function isn't Set in Persistent! Be aware that Persistent is no stand alone class!`); | ||
*/ | ||
removePersistedValue(key) { | ||
removePersistedValue() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -201,2 +201,2 @@ internal_1.Agile.logger.error(`'removePersistedValue' function isn't Set in Persistent! Be aware that Persistent is no stand alone class!`); | ||
exports.Persistent = Persistent; | ||
Persistent.placeHolderKey = "__THIS_IS_A_PLACEHOLDER__"; | ||
Persistent.placeHolderKey = '__THIS_IS_A_PLACEHOLDER__'; |
@@ -14,3 +14,3 @@ "use strict"; | ||
config = internal_1.defineConfig(config, { | ||
prefix: "agile", | ||
prefix: 'agile', | ||
async: false, | ||
@@ -17,0 +17,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { Agile } from "./internal"; | ||
import { Agile } from './internal'; | ||
/** | ||
@@ -3,0 +3,0 @@ * @internal |
@@ -16,9 +16,9 @@ "use strict"; | ||
// Extra checking '!value' because 'typeof null === object' | ||
if (!value || typeof value !== "object") | ||
if (!value || typeof value !== 'object') | ||
return value; | ||
let temp; | ||
let newObject = Array.isArray(value) ? [] : {}; | ||
for (let property in value) { | ||
const newObject = Array.isArray(value) ? [] : {}; | ||
for (const property in value) { | ||
temp = value[property]; | ||
newObject[property] = typeof temp === "object" ? copy(temp) : temp; | ||
newObject[property] = typeof temp === 'object' ? copy(temp) : temp; | ||
} | ||
@@ -43,10 +43,10 @@ return newObject; | ||
catch (e) { | ||
return (typeof obj === "object" && | ||
return (typeof obj === 'object' && | ||
obj.nodeType === 1 && | ||
typeof obj.style === "object" && | ||
typeof obj.ownerDocument === "object"); | ||
typeof obj.style === 'object' && | ||
typeof obj.ownerDocument === 'object'); | ||
} | ||
} | ||
return (value !== null && | ||
typeof value === "object" && | ||
typeof value === 'object' && | ||
!isHTMLElement(value) && | ||
@@ -100,5 +100,5 @@ !Array.isArray(value)); | ||
if (instance) { | ||
const _agileInstance = isFunction(instance["agileInstance"]) | ||
? instance["agileInstance"]() | ||
: instance["agileInstance"]; | ||
const _agileInstance = isFunction(instance['agileInstance']) | ||
? instance['agileInstance']() | ||
: instance['agileInstance']; | ||
if (_agileInstance) | ||
@@ -108,6 +108,6 @@ return _agileInstance; | ||
// Return global bound agileInstance | ||
return globalThis["__agile__"]; | ||
return globalThis['__agile__']; | ||
} | ||
catch (e) { | ||
internal_1.Agile.logger.error("Failed to get Agile Instance from ", instance); | ||
internal_1.Agile.logger.error('Failed to get Agile Instance from ', instance); | ||
} | ||
@@ -126,3 +126,3 @@ return undefined; | ||
function isFunction(value) { | ||
return typeof value === "function"; | ||
return typeof value === 'function'; | ||
} | ||
@@ -141,4 +141,4 @@ exports.isFunction = isFunction; | ||
return (isFunction(value) && | ||
(value.constructor.name === "AsyncFunction" || | ||
valueString.includes("__awaiter"))); | ||
(value.constructor.name === 'AsyncFunction' || | ||
valueString.includes('__awaiter'))); | ||
} | ||
@@ -156,8 +156,8 @@ exports.isAsyncFunction = isAsyncFunction; | ||
function isValidUrl(url) { | ||
const pattern = new RegExp("^(https?:\\/\\/)?" + // protocol | ||
"((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name | ||
"((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address | ||
"(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path | ||
"(\\?[;&a-z\\d%_.~+=-]*)?" + // query string | ||
"(\\#[-a-z\\d_]*)?$", "i"); | ||
const pattern = new RegExp('^(https?:\\/\\/)?' + // protocol | ||
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name | ||
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address | ||
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path | ||
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string | ||
'(\\#[-a-z\\d_]*)?$', 'i'); | ||
return pattern.test(url); | ||
@@ -175,3 +175,3 @@ } | ||
function isJsonString(value) { | ||
if (typeof value !== "string") | ||
if (typeof value !== 'string') | ||
return false; | ||
@@ -202,3 +202,3 @@ try { | ||
const finalConfig = Object.assign(Object.assign({}, defaults), config); | ||
for (let key in finalConfig) | ||
for (const key in finalConfig) | ||
if (finalConfig[key] === undefined) | ||
@@ -224,3 +224,3 @@ finalConfig[key] = defaults[key]; | ||
// Loop through source object an merge changes into it | ||
let keys = Object.keys(changes); | ||
const keys = Object.keys(changes); | ||
keys.forEach((property) => { | ||
@@ -269,5 +269,5 @@ if (!config.addNewProperties && !_source[property]) | ||
function generateId(length) { | ||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | ||
const charactersLength = characters.length; | ||
let result = ""; | ||
let result = ''; | ||
if (!length) | ||
@@ -294,3 +294,3 @@ length = 5; | ||
// Copy Properties of Class | ||
for (let key in objectClone) | ||
for (const key in objectClone) | ||
objectClone[key] = copy(objectClone[key]); | ||
@@ -297,0 +297,0 @@ return objectClone; |
{ | ||
"name": "@agile-ts/core", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": "BennoDev", | ||
@@ -22,4 +22,4 @@ "license": "MIT", | ||
"dev-push": "yalc push", | ||
"watch": "tsc-watch --onSuccess \"npm run dev-push\"", | ||
"prepublish": "node ./scripts/prepublish.js && yarn run build" | ||
"watch": "tsc-watch --onSuccess \"yarn run dev-push\"", | ||
"release": "node ./scripts/prepublish.js && yarn run build" | ||
}, | ||
@@ -26,0 +26,0 @@ "publishConfig": { |
@@ -1,2 +0,2 @@ | ||
<img src="./HeaderBackground.png" alt="Banner"> | ||
<img src="static/header_background.png" alt="Banner"> | ||
@@ -3,0 +3,0 @@ > **Spacy**, **Simple**, **Scalable** State Management Framework |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
290593
7260