entropic-bond 1.50.4 → 1.51.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/lib/auth/auth-mock.d.ts +3 -2
- package/lib/auth/auth.d.ts +3 -2
- package/lib/cloud-functions/cloud-functions-mock.d.ts +1 -0
- package/lib/cloud-storage/mock-cloud-storage.d.ts +1 -0
- package/lib/cloud-storage/stored-file.d.ts +4 -3
- package/lib/entropic-bond.js +432 -361
- package/lib/entropic-bond.js.map +1 -1
- package/lib/entropic-bond.umd.cjs +2 -2
- package/lib/entropic-bond.umd.cjs.map +1 -1
- package/lib/persistent/entropic-component.d.ts +3 -2
- package/lib/persistent/persistent.d.ts +3 -1
- package/lib/server-auth/server-auth-mock.d.ts +3 -2
- package/lib/server-auth/server-auth.d.ts +1 -0
- package/lib/store/data-source.d.ts +22 -1
- package/lib/store/json-data-source.d.ts +7 -3
- package/lib/store/mocks/test-user.d.ts +6 -0
- package/lib/store/model.d.ts +3 -2
- package/lib/store/store.d.ts +3 -2
- package/lib/types/utility-types.d.ts +2 -2
- package/lib/utils/utils.d.ts +2 -1
- package/package.json +9 -9
- package/lib/auth/auth-mock.spec.d.ts +0 -1
- package/lib/cloud-functions/cloud-functions-mock.spec.d.ts +0 -1
- package/lib/cloud-storage/cloud-storage.spec.d.ts +0 -1
- package/lib/observable/observable.spec.d.ts +0 -1
- package/lib/persistent/entropic-component.spec.d.ts +0 -1
- package/lib/persistent/persistent.spec.d.ts +0 -67
- package/lib/server-auth/server-auth-mock.spec.d.ts +0 -1
- package/lib/store/json-data-source.spec.d.ts +0 -1
- package/lib/store/model.spec.d.ts +0 -1
- package/lib/store/store.spec.d.ts +0 -1
- package/lib/types/utility-types.spec.d.ts +0 -1
- package/lib/utils/utils.spec.d.ts +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Callback, Unsubscriber } from '../observable/observable';
|
|
2
|
-
import { ClassArrayPropNames, ClassProps, Elements } from '../types/utility-types';
|
|
3
1
|
import { Persistent } from './persistent';
|
|
2
|
+
import { ClassArrayPropNames, ClassProps, Elements } from '../types/utility-types';
|
|
3
|
+
import { Callback, Unsubscriber } from '../observable/observable';
|
|
4
|
+
|
|
4
5
|
export type PropChangeEvent<T> = Partial<ClassProps<T>>;
|
|
5
6
|
export type PropChangeCallback<T> = Callback<PropChangeEvent<T>>;
|
|
6
7
|
type ArrayPropsElem<T> = Elements<T[ClassArrayPropNames<T>]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ClassPropNames, SomeClassProps, UnderscoredProp } from '../types/utility-types';
|
|
2
|
+
|
|
2
3
|
export type PersistentConstructor = new () => Persistent;
|
|
3
4
|
/**
|
|
4
5
|
* The corresponding type of the plain object of a persistent class.
|
|
@@ -168,6 +169,7 @@ export declare class Persistent {
|
|
|
168
169
|
static searchableArrayNameFor(propName: string): string;
|
|
169
170
|
private fromDeepObject;
|
|
170
171
|
private toDeepObj;
|
|
172
|
+
static collectionPath(ownerInstance: Persistent, prop: PersistentProperty): string;
|
|
171
173
|
private toReferenceObj;
|
|
172
174
|
private buildRefObject;
|
|
173
175
|
private pushDocument;
|
|
@@ -181,7 +183,7 @@ export declare class Persistent {
|
|
|
181
183
|
}
|
|
182
184
|
type CollectionPathCallback = (value: Persistent, prop: PersistentProperty) => string;
|
|
183
185
|
type ValidatorFunction<T extends Persistent, P extends ClassPropNames<T>> = (value: T[P], property: PersistentProperty, persistentInstance: T) => boolean;
|
|
184
|
-
interface PersistentProperty {
|
|
186
|
+
export interface PersistentProperty {
|
|
185
187
|
name: string;
|
|
186
188
|
isReference?: boolean;
|
|
187
189
|
isPureReference?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { UserCredentials } from '../auth/user-auth-types';
|
|
2
|
-
import { Collection } from '../types/utility-types';
|
|
3
1
|
import { ServerAuthService, CustomCredentials } from './server-auth';
|
|
2
|
+
import { Collection } from '../types/utility-types';
|
|
3
|
+
import { UserCredentials } from '../auth/user-auth-types';
|
|
4
|
+
|
|
4
5
|
export declare class ServerAuthMock extends ServerAuthService {
|
|
5
6
|
constructor(userCredentials: Collection<UserCredentials<{}>>);
|
|
6
7
|
getUser<T extends CustomCredentials>(userId: string): Promise<UserCredentials<T> | undefined>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Persistent, PersistentObject, Collections } from '../persistent/persistent';
|
|
2
1
|
import { ClassPropNames } from '../types/utility-types';
|
|
2
|
+
import { Persistent, PersistentObject, Collections, PersistentProperty } from '../persistent/persistent';
|
|
3
|
+
|
|
3
4
|
export type DocumentObject = PersistentObject<Persistent>;
|
|
4
5
|
/**
|
|
5
6
|
* The query operators
|
|
@@ -52,6 +53,12 @@ export type QueryObject<T> = {
|
|
|
52
53
|
propertyName: ClassPropNames<T> | string;
|
|
53
54
|
};
|
|
54
55
|
};
|
|
56
|
+
export type DocumentListenerUninstaller = () => void;
|
|
57
|
+
interface DocumentChange {
|
|
58
|
+
before: DocumentObject | undefined;
|
|
59
|
+
after: DocumentObject;
|
|
60
|
+
}
|
|
61
|
+
export type DocumentChangeListerner = (change: DocumentChange) => void;
|
|
55
62
|
/**
|
|
56
63
|
* The data source interface.
|
|
57
64
|
* It defines the methods that must be implemented by a data source
|
|
@@ -60,6 +67,16 @@ export type QueryObject<T> = {
|
|
|
60
67
|
* A data source is used by the store to retrieve and save data.
|
|
61
68
|
*/
|
|
62
69
|
export declare abstract class DataSource {
|
|
70
|
+
installReferencePersistentPropsUpdaters(onUpdate?: (doc: Persistent) => void, throwOnNonImplementedListener?: boolean): DocumentListenerUninstaller[];
|
|
71
|
+
/**
|
|
72
|
+
* Installs a document change listener
|
|
73
|
+
* Implement the required logic to install a listener that will be called
|
|
74
|
+
* when a document is changed in your concrete the data source
|
|
75
|
+
* @param documentPath the path of the document to be listened
|
|
76
|
+
* @param listener the callback to be called when the document is changed
|
|
77
|
+
* @returns a function that uninstalls the listener
|
|
78
|
+
*/
|
|
79
|
+
protected documentChangeListerner(prop: PersistentProperty, listener: DocumentChangeListerner): DocumentListenerUninstaller | undefined;
|
|
63
80
|
/**
|
|
64
81
|
* Retrieves a document by id
|
|
65
82
|
* Implement the required logic to retrieve a document by id from your concrete
|
|
@@ -134,4 +151,8 @@ export declare abstract class DataSource {
|
|
|
134
151
|
static toPropertyPathOperations<T extends Persistent>(operations: QueryOperation<T>[]): QueryOperation<T>[];
|
|
135
152
|
static isArrayOperator(operator: QueryOperator): boolean;
|
|
136
153
|
private static toPropertyPathValue;
|
|
154
|
+
private onDocumentChange;
|
|
155
|
+
private static getSystemRegisteredReferencesWithStoredProps;
|
|
156
|
+
private onUpdate;
|
|
137
157
|
}
|
|
158
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DataSource, DocumentChangeListerner, DocumentListenerUninstaller, DocumentObject, QueryObject } from './data-source';
|
|
2
|
+
import { Collections, Persistent, PersistentObject, PersistentProperty } from '../persistent/persistent';
|
|
3
|
+
|
|
3
4
|
export interface JsonRawData {
|
|
4
5
|
[collection: string]: {
|
|
5
6
|
[documentId: string]: PersistentObject<Persistent>;
|
|
@@ -17,7 +18,7 @@ export interface ErrorOnOperation {
|
|
|
17
18
|
* It is useful for testing purposes.
|
|
18
19
|
* The data in the JSON object is not persisted.
|
|
19
20
|
*/
|
|
20
|
-
export declare class JsonDataSource
|
|
21
|
+
export declare class JsonDataSource extends DataSource {
|
|
21
22
|
/**
|
|
22
23
|
* @param jsonRawData the JSON object to be used as data store
|
|
23
24
|
*/
|
|
@@ -51,6 +52,8 @@ export declare class JsonDataSource implements DataSource {
|
|
|
51
52
|
wait(): Promise<any[]>;
|
|
52
53
|
private incCursor;
|
|
53
54
|
simulateError(error: string | ErrorOnOperation | undefined): this;
|
|
55
|
+
protected documentChangeListerner(prop: PersistentProperty, listener: DocumentChangeListerner): DocumentListenerUninstaller | undefined;
|
|
56
|
+
private notifyChange;
|
|
54
57
|
private decCursor;
|
|
55
58
|
private queryProcessor;
|
|
56
59
|
private retrieveQueryDocs;
|
|
@@ -65,4 +68,5 @@ export declare class JsonDataSource implements DataSource {
|
|
|
65
68
|
private _simulateDelay;
|
|
66
69
|
private _pendingPromises;
|
|
67
70
|
private _simulateError;
|
|
71
|
+
private _listener;
|
|
68
72
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Persistent } from '../../persistent/persistent';
|
|
2
|
+
|
|
2
3
|
interface Name {
|
|
3
4
|
firstName: string;
|
|
4
5
|
lastName: string;
|
|
@@ -46,4 +47,9 @@ export declare class DerivedUser extends TestUser {
|
|
|
46
47
|
get salary(): number | undefined;
|
|
47
48
|
private _salary;
|
|
48
49
|
}
|
|
50
|
+
export declare class UsesUserAsPersistentProp extends Persistent {
|
|
51
|
+
set user(value: TestUser | undefined);
|
|
52
|
+
get user(): TestUser | undefined;
|
|
53
|
+
private _user;
|
|
54
|
+
}
|
|
49
55
|
export {};
|
package/lib/store/model.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Persistent } from '../persistent/persistent';
|
|
2
|
-
import { ClassPropNames, PropPath, PropPathType } from '../types/utility-types';
|
|
3
1
|
import { DataSource, QueryOperator, QueryObject, QueryOrder } from './data-source';
|
|
2
|
+
import { ClassPropNames, PropPath, PropPathType } from '../types/utility-types';
|
|
3
|
+
import { Persistent } from '../persistent/persistent';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Provides abstraction to the database access. You should gain access to a Model
|
|
6
7
|
* object through the Store.getModel method instead of its constructor.
|
package/lib/store/store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Persistent } from '../persistent/persistent';
|
|
2
|
-
import { DataSource } from './data-source';
|
|
3
1
|
import { Model } from './model';
|
|
2
|
+
import { DataSource } from './data-source';
|
|
3
|
+
import { Persistent } from '../persistent/persistent';
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* The store is the main entry point for the data access layer.
|
|
6
7
|
* It provides methods to retrieve models for collections and subcollections.
|
|
@@ -38,8 +38,8 @@ export type Require<T, K extends keyof T> = T & {
|
|
|
38
38
|
export type Primitive = string | number | bigint | boolean | undefined | symbol;
|
|
39
39
|
type Decr = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
40
40
|
type Concat<T, U> = `${string & T}${string & U}`;
|
|
41
|
-
export type PropPath<T extends {}, AllowedTypes = any, MaxDepth extends number =
|
|
41
|
+
export type PropPath<T extends {}, AllowedTypes = any, MaxDepth extends number = 9, Prefix = ''> = MaxDepth extends number ? {
|
|
42
42
|
[P in keyof T]: T[P] extends Function ? never : T[P] extends AllowedTypes ? T[P] extends Primitive | ArrayLike<any> ? Concat<Prefix, P> : Concat<Prefix, P> | PropPath<T[P] & {}, AllowedTypes, Decr[MaxDepth], `${Concat<Prefix, P>}.`> : never;
|
|
43
|
-
}[keyof T]
|
|
43
|
+
}[keyof T] : never;
|
|
44
44
|
export type PropPathType<T, Path, MaxDepth extends number = 2> = MaxDepth extends number ? Path extends keyof T ? T[Path] : Path extends `${infer PropName}.${infer SubPropName}` ? PropName extends keyof T ? PropPathType<T[PropName], SubPropName, Decr[MaxDepth]> : never : never : never;
|
|
45
45
|
export {};
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PropPath, PropPathType } from '../types/utility-types';
|
|
2
|
+
|
|
2
3
|
/**
|
|
3
4
|
* A map of key-value pairs
|
|
4
5
|
* @param varName the name of the variable
|
|
@@ -57,4 +58,4 @@ export declare function snakeCase(str: string | undefined | null, snakeChar?: st
|
|
|
57
58
|
* const result = getDeepValue( obj, path )
|
|
58
59
|
* // result = 1
|
|
59
60
|
*/
|
|
60
|
-
export declare function getDeepValue<T extends {}, P extends PropPath<T
|
|
61
|
+
export declare function getDeepValue<T extends {}, P extends PropPath<T> & string>(obj: T, path: P): PropPathType<T, P>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "entropic-bond",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.51.0",
|
|
5
5
|
"description": "Tidy up your messy components",
|
|
6
6
|
"main": "./lib/entropic-bond.umd.cjs",
|
|
7
7
|
"module": "./lib/entropic-bond.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"test": "vitest",
|
|
36
|
-
"build": "
|
|
36
|
+
"build": "vite build",
|
|
37
37
|
"prepare": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
"@semantic-release/changelog": "^6.0.3",
|
|
57
57
|
"@semantic-release/git": "^10.0.1",
|
|
58
58
|
"@type-challenges/utils": "^0.1.1",
|
|
59
|
-
"@types/node": "^20.
|
|
59
|
+
"@types/node": "^20.12.7",
|
|
60
60
|
"@types/uuid": "^9.0.8",
|
|
61
61
|
"git-branch-is": "^4.0.0",
|
|
62
|
-
"husky": "^9.0.
|
|
63
|
-
"semantic-release": "^23.0.
|
|
64
|
-
"typedoc": "^0.25.
|
|
62
|
+
"husky": "^9.0.11",
|
|
63
|
+
"semantic-release": "^23.0.8",
|
|
64
|
+
"typedoc": "^0.25.13",
|
|
65
65
|
"typedoc-plugin-markdown": "^3.17.1",
|
|
66
|
-
"typescript": "^5.
|
|
67
|
-
"vite-plugin-dts": "^3.
|
|
68
|
-
"vitest": "^1.
|
|
66
|
+
"typescript": "^5.4.5",
|
|
67
|
+
"vite-plugin-dts": "^3.8.2",
|
|
68
|
+
"vitest": "^1.5.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"uuid": "^9.0.1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Persistent } from './persistent';
|
|
2
|
-
interface InnerObject {
|
|
3
|
-
nonPersistedReferences: PersistentClass[];
|
|
4
|
-
}
|
|
5
|
-
declare class PersistentClass extends Persistent {
|
|
6
|
-
protected beforeSerialize(): void;
|
|
7
|
-
protected afterDeserialize(): void;
|
|
8
|
-
set persistentProp(val: number | undefined);
|
|
9
|
-
get persistentProp(): number | undefined;
|
|
10
|
-
set personPureRef(value: Person | undefined);
|
|
11
|
-
get personPureRef(): Person | undefined;
|
|
12
|
-
set persistentArray(value: PersistentClass[] | undefined);
|
|
13
|
-
get persistentArray(): PersistentClass[] | undefined;
|
|
14
|
-
_persistentProp: number | undefined;
|
|
15
|
-
_persistentArray: PersistentClass[] | undefined;
|
|
16
|
-
_personPureRef: Person | undefined;
|
|
17
|
-
_nonPersistentProp: number | undefined;
|
|
18
|
-
}
|
|
19
|
-
declare class NotRegistered extends Persistent {
|
|
20
|
-
}
|
|
21
|
-
declare class Person extends Persistent {
|
|
22
|
-
protected beforeSerialize(): void;
|
|
23
|
-
protected afterDeserialize(): void;
|
|
24
|
-
set name(value: string | undefined);
|
|
25
|
-
get name(): string | undefined;
|
|
26
|
-
set salary(value: number | undefined);
|
|
27
|
-
get salary(): number | undefined;
|
|
28
|
-
set doNotPersist(value: number | undefined);
|
|
29
|
-
get doNotPersist(): number | undefined;
|
|
30
|
-
set anObjectProperty(value: PersistentClass);
|
|
31
|
-
get anObjectProperty(): PersistentClass;
|
|
32
|
-
set skills(value: string[] | undefined);
|
|
33
|
-
get skills(): string[] | undefined;
|
|
34
|
-
set arrayOfPersistent(value: PersistentClass[] | undefined);
|
|
35
|
-
get arrayOfPersistent(): PersistentClass[] | undefined;
|
|
36
|
-
set document(value: PersistentClass | undefined);
|
|
37
|
-
get document(): PersistentClass | undefined;
|
|
38
|
-
set arrayOfRefs(value: PersistentClass[]);
|
|
39
|
-
get arrayOfRefs(): PersistentClass[];
|
|
40
|
-
set persistentObject(value: InnerObject | undefined);
|
|
41
|
-
get persistentObject(): InnerObject | undefined;
|
|
42
|
-
private _name?;
|
|
43
|
-
private _salary?;
|
|
44
|
-
private _skills;
|
|
45
|
-
private _anObjectProperty;
|
|
46
|
-
private _arrayOfPersistent;
|
|
47
|
-
_notRegistered: NotRegistered | undefined;
|
|
48
|
-
_arrayOfArray: number[][] | undefined;
|
|
49
|
-
_arrayOfPersistentArray: PersistentClass[][] | undefined;
|
|
50
|
-
_plainObject: {
|
|
51
|
-
[key: string]: unknown;
|
|
52
|
-
} | undefined;
|
|
53
|
-
_document: PersistentClass | undefined;
|
|
54
|
-
_docAtArbitraryCollection: PersistentClass | undefined;
|
|
55
|
-
_docAtArbitraryCollectionRefFunc: PersistentClass | undefined;
|
|
56
|
-
private _arrayOfRefs;
|
|
57
|
-
private _persistentObject;
|
|
58
|
-
_referenceWithStoredValues: PersistentClass | undefined;
|
|
59
|
-
private _doNotPersist;
|
|
60
|
-
}
|
|
61
|
-
export declare class WithAnnotations extends PersistentClass {
|
|
62
|
-
}
|
|
63
|
-
export declare class WithAnnotations2 extends PersistentClass {
|
|
64
|
-
}
|
|
65
|
-
export declare class WithAnnotations3 extends PersistentClass {
|
|
66
|
-
}
|
|
67
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|