@katn30/trakr 3.0.0 → 4.0.0
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/README.md +70 -0
- package/dist/dev/index.cjs +597 -63
- package/dist/dev/index.cjs.map +1 -1
- package/dist/dev/index.d.cts +65 -5
- package/dist/dev/index.d.ts +65 -5
- package/dist/dev/index.js +592 -62
- package/dist/dev/index.js.map +1 -1
- package/dist/prod/index.cjs +597 -63
- package/dist/prod/index.cjs.map +1 -1
- package/dist/prod/index.js +592 -62
- package/dist/prod/index.js.map +1 -1
- package/package.json +1 -1
package/dist/dev/index.d.cts
CHANGED
|
@@ -221,6 +221,10 @@ interface IdAssignment {
|
|
|
221
221
|
value: number;
|
|
222
222
|
}
|
|
223
223
|
declare function AutoId<This extends object, Value>(_target: undefined, context: ClassFieldDecoratorContext<This, Value>): void;
|
|
224
|
+
declare function Id<This extends object, Value>(_target: undefined, context: ClassFieldDecoratorContext<This, Value>): void;
|
|
225
|
+
declare function getIdentityProperties(proto: object): string[];
|
|
226
|
+
declare function getIdentity(obj: object): unknown;
|
|
227
|
+
declare function getIdentityObject(obj: object): Record<string, unknown>;
|
|
224
228
|
|
|
225
229
|
interface StateTarget {
|
|
226
230
|
trackingId: number;
|
|
@@ -418,7 +422,7 @@ interface GeneratedEvent<TEventType extends string = string, TPayload = Record<s
|
|
|
418
422
|
eventType: TEventType;
|
|
419
423
|
payload: TPayload;
|
|
420
424
|
trackingId?: number;
|
|
421
|
-
targetId?:
|
|
425
|
+
targetId?: unknown;
|
|
422
426
|
}
|
|
423
427
|
interface EventLifecycleOptions<TEventType extends string = string> {
|
|
424
428
|
itemAdded?: TEventType;
|
|
@@ -426,23 +430,79 @@ interface EventLifecycleOptions<TEventType extends string = string> {
|
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
declare class EventTracker extends Tracker {
|
|
433
|
+
withContext<T>(ctx: unknown, action: () => T): T;
|
|
429
434
|
onCommit(keys?: IdAssignment[]): void;
|
|
430
435
|
generateEvents<TEventType extends string = string>(): GeneratedEvent<TEventType>[];
|
|
431
436
|
}
|
|
432
437
|
|
|
433
|
-
|
|
438
|
+
interface HistoryOptions<TSelf = any, TValue = any> {
|
|
439
|
+
entryFactory: (self: TSelf, newValue: TValue, oldValue: TValue, change: Change, ctx?: unknown) => unknown;
|
|
440
|
+
}
|
|
441
|
+
type HistoryConfig = boolean | HistoryOptions;
|
|
442
|
+
interface EventPropertyOptions {
|
|
443
|
+
eventType?: string;
|
|
444
|
+
history?: HistoryConfig;
|
|
434
445
|
coalesceWithin?: number;
|
|
435
|
-
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
interface EventTrackedOptions {
|
|
449
|
+
coalesceWithin?: number;
|
|
450
|
+
eventType?: string;
|
|
451
|
+
history?: HistoryConfig;
|
|
452
|
+
}
|
|
453
|
+
declare function EventTracked(validator?: (self: any, newValue: any) => string | undefined, onChange?: (self: any, newValue: any, oldValue: any) => void, options?: EventTrackedOptions): {
|
|
436
454
|
<T extends TrackedObject, V>(target: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext<T, V>): ClassAccessorDecoratorResult<T, V>;
|
|
437
455
|
<T extends TrackedObject, V>(target: (this: T, value: V) => void, context: ClassSetterDecoratorContext<T, V>): (this: T, value: V) => void;
|
|
438
456
|
<T extends TrackedObject, V>(target: (this: T) => V, context: ClassGetterDecoratorContext<T, V>): (this: T) => V;
|
|
439
457
|
};
|
|
440
458
|
|
|
459
|
+
interface CollectionHistoryOptions<T = any> {
|
|
460
|
+
entryFactory: (self: T, change: Change, ctx?: unknown) => unknown;
|
|
461
|
+
}
|
|
462
|
+
type CollectionHistoryConfig = boolean | CollectionHistoryOptions;
|
|
463
|
+
interface EventTrackedCollectionOptions<T = any, TEventType extends string = string> extends EventLifecycleOptions<TEventType> {
|
|
464
|
+
eventType?: TEventType;
|
|
465
|
+
history?: CollectionHistoryConfig;
|
|
466
|
+
owner?: {
|
|
467
|
+
object: TrackedObject;
|
|
468
|
+
property: string;
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
interface CollectionOp {
|
|
472
|
+
op: "add" | "remove" | "change";
|
|
473
|
+
item?: TrackedObject;
|
|
474
|
+
identity?: unknown;
|
|
475
|
+
diff?: Record<string, unknown>;
|
|
476
|
+
raw?: unknown;
|
|
477
|
+
snapshot?: Record<string, unknown>;
|
|
478
|
+
}
|
|
441
479
|
declare class EventTrackedCollection<T, TEventType extends string = string> extends TrackedCollection<T> {
|
|
442
480
|
private readonly _eventOptions;
|
|
443
|
-
|
|
481
|
+
private readonly _historyOps;
|
|
482
|
+
private readonly _baselineItems;
|
|
483
|
+
constructor(tracker: Tracker, items?: T[], validator?: (value: T[]) => string | undefined, options?: EventTrackedCollectionOptions<T, TEventType>);
|
|
444
484
|
/** @internal */
|
|
445
485
|
get _lifecycleOptions(): EventLifecycleOptions<TEventType> | undefined;
|
|
486
|
+
/** @internal */
|
|
487
|
+
get _aggregateOptions(): EventTrackedCollectionOptions<T, TEventType> | undefined;
|
|
488
|
+
/** @internal */
|
|
489
|
+
get _historyOpsList(): CollectionOp[];
|
|
490
|
+
/** @internal */
|
|
491
|
+
_clearHistoryOps(): void;
|
|
492
|
+
/** @internal */
|
|
493
|
+
_isInBaseline(item: T): boolean;
|
|
494
|
+
/** @internal */
|
|
495
|
+
_baselineListSnapshot(): T[];
|
|
496
|
+
/** @internal */
|
|
497
|
+
_rebaseline(): void;
|
|
498
|
+
private _isAggregateMode;
|
|
499
|
+
private _isHistoryMode;
|
|
500
|
+
private _validateItemHasIdentity;
|
|
501
|
+
private _attachItemChangeWatchers;
|
|
502
|
+
private _recordAddOp;
|
|
503
|
+
private _recordRemoveOp;
|
|
504
|
+
private _recordChangeOpDiff;
|
|
505
|
+
private _recordChangeOp;
|
|
446
506
|
}
|
|
447
507
|
|
|
448
|
-
export { AutoId, type EventLifecycleOptions, EventTracked, EventTrackedCollection, EventTracker, type GeneratedEvent, type ITracked, type IdAssignment, type PropertyScope, State, Tracked, TrackedCollection, TrackedCollectionChanged, TrackedObject, type TrackedPropertyChanged, Tracker, TrackerSession, TypedEvent };
|
|
508
|
+
export { AutoId, type CollectionHistoryConfig, type CollectionHistoryOptions, type EventLifecycleOptions, type EventPropertyOptions, EventTracked, EventTrackedCollection, type EventTrackedCollectionOptions, type EventTrackedOptions, EventTracker, type GeneratedEvent, type HistoryConfig, type HistoryOptions, type ITracked, Id, type IdAssignment, type PropertyScope, State, Tracked, TrackedCollection, TrackedCollectionChanged, TrackedObject, type TrackedPropertyChanged, Tracker, TrackerSession, TypedEvent, getIdentity, getIdentityObject, getIdentityProperties };
|
package/dist/dev/index.d.ts
CHANGED
|
@@ -221,6 +221,10 @@ interface IdAssignment {
|
|
|
221
221
|
value: number;
|
|
222
222
|
}
|
|
223
223
|
declare function AutoId<This extends object, Value>(_target: undefined, context: ClassFieldDecoratorContext<This, Value>): void;
|
|
224
|
+
declare function Id<This extends object, Value>(_target: undefined, context: ClassFieldDecoratorContext<This, Value>): void;
|
|
225
|
+
declare function getIdentityProperties(proto: object): string[];
|
|
226
|
+
declare function getIdentity(obj: object): unknown;
|
|
227
|
+
declare function getIdentityObject(obj: object): Record<string, unknown>;
|
|
224
228
|
|
|
225
229
|
interface StateTarget {
|
|
226
230
|
trackingId: number;
|
|
@@ -418,7 +422,7 @@ interface GeneratedEvent<TEventType extends string = string, TPayload = Record<s
|
|
|
418
422
|
eventType: TEventType;
|
|
419
423
|
payload: TPayload;
|
|
420
424
|
trackingId?: number;
|
|
421
|
-
targetId?:
|
|
425
|
+
targetId?: unknown;
|
|
422
426
|
}
|
|
423
427
|
interface EventLifecycleOptions<TEventType extends string = string> {
|
|
424
428
|
itemAdded?: TEventType;
|
|
@@ -426,23 +430,79 @@ interface EventLifecycleOptions<TEventType extends string = string> {
|
|
|
426
430
|
}
|
|
427
431
|
|
|
428
432
|
declare class EventTracker extends Tracker {
|
|
433
|
+
withContext<T>(ctx: unknown, action: () => T): T;
|
|
429
434
|
onCommit(keys?: IdAssignment[]): void;
|
|
430
435
|
generateEvents<TEventType extends string = string>(): GeneratedEvent<TEventType>[];
|
|
431
436
|
}
|
|
432
437
|
|
|
433
|
-
|
|
438
|
+
interface HistoryOptions<TSelf = any, TValue = any> {
|
|
439
|
+
entryFactory: (self: TSelf, newValue: TValue, oldValue: TValue, change: Change, ctx?: unknown) => unknown;
|
|
440
|
+
}
|
|
441
|
+
type HistoryConfig = boolean | HistoryOptions;
|
|
442
|
+
interface EventPropertyOptions {
|
|
443
|
+
eventType?: string;
|
|
444
|
+
history?: HistoryConfig;
|
|
434
445
|
coalesceWithin?: number;
|
|
435
|
-
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
interface EventTrackedOptions {
|
|
449
|
+
coalesceWithin?: number;
|
|
450
|
+
eventType?: string;
|
|
451
|
+
history?: HistoryConfig;
|
|
452
|
+
}
|
|
453
|
+
declare function EventTracked(validator?: (self: any, newValue: any) => string | undefined, onChange?: (self: any, newValue: any, oldValue: any) => void, options?: EventTrackedOptions): {
|
|
436
454
|
<T extends TrackedObject, V>(target: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext<T, V>): ClassAccessorDecoratorResult<T, V>;
|
|
437
455
|
<T extends TrackedObject, V>(target: (this: T, value: V) => void, context: ClassSetterDecoratorContext<T, V>): (this: T, value: V) => void;
|
|
438
456
|
<T extends TrackedObject, V>(target: (this: T) => V, context: ClassGetterDecoratorContext<T, V>): (this: T) => V;
|
|
439
457
|
};
|
|
440
458
|
|
|
459
|
+
interface CollectionHistoryOptions<T = any> {
|
|
460
|
+
entryFactory: (self: T, change: Change, ctx?: unknown) => unknown;
|
|
461
|
+
}
|
|
462
|
+
type CollectionHistoryConfig = boolean | CollectionHistoryOptions;
|
|
463
|
+
interface EventTrackedCollectionOptions<T = any, TEventType extends string = string> extends EventLifecycleOptions<TEventType> {
|
|
464
|
+
eventType?: TEventType;
|
|
465
|
+
history?: CollectionHistoryConfig;
|
|
466
|
+
owner?: {
|
|
467
|
+
object: TrackedObject;
|
|
468
|
+
property: string;
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
interface CollectionOp {
|
|
472
|
+
op: "add" | "remove" | "change";
|
|
473
|
+
item?: TrackedObject;
|
|
474
|
+
identity?: unknown;
|
|
475
|
+
diff?: Record<string, unknown>;
|
|
476
|
+
raw?: unknown;
|
|
477
|
+
snapshot?: Record<string, unknown>;
|
|
478
|
+
}
|
|
441
479
|
declare class EventTrackedCollection<T, TEventType extends string = string> extends TrackedCollection<T> {
|
|
442
480
|
private readonly _eventOptions;
|
|
443
|
-
|
|
481
|
+
private readonly _historyOps;
|
|
482
|
+
private readonly _baselineItems;
|
|
483
|
+
constructor(tracker: Tracker, items?: T[], validator?: (value: T[]) => string | undefined, options?: EventTrackedCollectionOptions<T, TEventType>);
|
|
444
484
|
/** @internal */
|
|
445
485
|
get _lifecycleOptions(): EventLifecycleOptions<TEventType> | undefined;
|
|
486
|
+
/** @internal */
|
|
487
|
+
get _aggregateOptions(): EventTrackedCollectionOptions<T, TEventType> | undefined;
|
|
488
|
+
/** @internal */
|
|
489
|
+
get _historyOpsList(): CollectionOp[];
|
|
490
|
+
/** @internal */
|
|
491
|
+
_clearHistoryOps(): void;
|
|
492
|
+
/** @internal */
|
|
493
|
+
_isInBaseline(item: T): boolean;
|
|
494
|
+
/** @internal */
|
|
495
|
+
_baselineListSnapshot(): T[];
|
|
496
|
+
/** @internal */
|
|
497
|
+
_rebaseline(): void;
|
|
498
|
+
private _isAggregateMode;
|
|
499
|
+
private _isHistoryMode;
|
|
500
|
+
private _validateItemHasIdentity;
|
|
501
|
+
private _attachItemChangeWatchers;
|
|
502
|
+
private _recordAddOp;
|
|
503
|
+
private _recordRemoveOp;
|
|
504
|
+
private _recordChangeOpDiff;
|
|
505
|
+
private _recordChangeOp;
|
|
446
506
|
}
|
|
447
507
|
|
|
448
|
-
export { AutoId, type EventLifecycleOptions, EventTracked, EventTrackedCollection, EventTracker, type GeneratedEvent, type ITracked, type IdAssignment, type PropertyScope, State, Tracked, TrackedCollection, TrackedCollectionChanged, TrackedObject, type TrackedPropertyChanged, Tracker, TrackerSession, TypedEvent };
|
|
508
|
+
export { AutoId, type CollectionHistoryConfig, type CollectionHistoryOptions, type EventLifecycleOptions, type EventPropertyOptions, EventTracked, EventTrackedCollection, type EventTrackedCollectionOptions, type EventTrackedOptions, EventTracker, type GeneratedEvent, type HistoryConfig, type HistoryOptions, type ITracked, Id, type IdAssignment, type PropertyScope, State, Tracked, TrackedCollection, TrackedCollectionChanged, TrackedObject, type TrackedPropertyChanged, Tracker, TrackerSession, TypedEvent, getIdentity, getIdentityObject, getIdentityProperties };
|