entropic-bond 1.48.1 → 1.50.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.
Files changed (141) hide show
  1. package/.github/workflows/release.yml +26 -0
  2. package/CHANGELOG.md +1151 -0
  3. package/docs/.nojekyll +1 -0
  4. package/docs/README.md +94 -0
  5. package/docs/classes/Auth.md +391 -0
  6. package/docs/classes/AuthMock.md +278 -0
  7. package/docs/classes/AuthService.md +188 -0
  8. package/docs/classes/CloudFunctions.md +123 -0
  9. package/docs/classes/CloudFunctionsMock.md +97 -0
  10. package/docs/classes/CloudStorage.md +215 -0
  11. package/docs/classes/DataSource.md +248 -0
  12. package/docs/classes/EntropicComponent.md +666 -0
  13. package/docs/classes/JsonDataSource.md +328 -0
  14. package/docs/classes/MockCloudStorage.md +279 -0
  15. package/docs/classes/Model.md +274 -0
  16. package/docs/classes/Observable.md +120 -0
  17. package/docs/classes/Persistent.md +420 -0
  18. package/docs/classes/ServerAuth.md +211 -0
  19. package/docs/classes/ServerAuthMock.md +176 -0
  20. package/docs/classes/ServerAuthService.md +130 -0
  21. package/docs/classes/Store.md +218 -0
  22. package/docs/classes/StoredFile.md +636 -0
  23. package/docs/enums/StoredFileEvent.md +41 -0
  24. package/docs/interfaces/AuthError.md +30 -0
  25. package/docs/interfaces/CloudFunctionsService.md +69 -0
  26. package/docs/interfaces/Collection.md +13 -0
  27. package/docs/interfaces/CustomCredentials.md +7 -0
  28. package/docs/interfaces/DocumentReference.md +49 -0
  29. package/docs/interfaces/JsonRawData.md +7 -0
  30. package/docs/interfaces/SignData.md +63 -0
  31. package/docs/interfaces/StoreParams.md +52 -0
  32. package/docs/interfaces/StoredFileChange.md +41 -0
  33. package/docs/interfaces/UploadControl.md +90 -0
  34. package/docs/interfaces/UserCredentials.md +113 -0
  35. package/docs/interfaces/Values.md +17 -0
  36. package/docs/modules.md +1273 -0
  37. package/package.json +23 -19
  38. package/src/auth/auth-mock.spec.ts +168 -0
  39. package/src/auth/auth-mock.ts +129 -0
  40. package/src/auth/auth.ts +185 -0
  41. package/src/auth/user-auth-types.ts +21 -0
  42. package/src/cloud-functions/cloud-functions-mock.spec.ts +136 -0
  43. package/src/cloud-functions/cloud-functions-mock.ts +23 -0
  44. package/src/cloud-functions/cloud-functions.ts +83 -0
  45. package/src/cloud-storage/cloud-storage.spec.ts +207 -0
  46. package/src/cloud-storage/cloud-storage.ts +60 -0
  47. package/src/cloud-storage/mock-cloud-storage.ts +72 -0
  48. package/src/cloud-storage/stored-file.ts +102 -0
  49. package/src/index.ts +19 -0
  50. package/src/observable/observable.spec.ts +105 -0
  51. package/src/observable/observable.ts +67 -0
  52. package/src/persistent/entropic-component.spec.ts +143 -0
  53. package/src/persistent/entropic-component.ts +135 -0
  54. package/src/persistent/persistent.spec.ts +828 -0
  55. package/src/persistent/persistent.ts +650 -0
  56. package/src/server-auth/server-auth-mock.spec.ts +53 -0
  57. package/src/server-auth/server-auth-mock.ts +45 -0
  58. package/src/server-auth/server-auth.ts +49 -0
  59. package/src/store/data-source.ts +186 -0
  60. package/src/store/json-data-source.spec.ts +100 -0
  61. package/src/store/json-data-source.ts +256 -0
  62. package/src/store/mocks/mock-data.json +155 -0
  63. package/src/store/mocks/test-user.ts +122 -0
  64. package/src/store/model.spec.ts +659 -0
  65. package/src/store/model.ts +462 -0
  66. package/src/store/store.spec.ts +30 -0
  67. package/src/store/store.ts +113 -0
  68. package/src/types/utility-types.spec.ts +117 -0
  69. package/src/types/utility-types.ts +116 -0
  70. package/src/utils/test-utils/test-person.ts +44 -0
  71. package/src/utils/utils.spec.ts +95 -0
  72. package/{lib/utils/utils.d.ts → src/utils/utils.ts} +34 -10
  73. package/tsconfig-build.json +7 -0
  74. package/tsconfig-cjs.json +9 -0
  75. package/tsconfig.json +33 -0
  76. package/vite.config.ts +22 -0
  77. package/lib/auth/auth-mock.d.ts +0 -21
  78. package/lib/auth/auth-mock.js +0 -108
  79. package/lib/auth/auth-mock.js.map +0 -1
  80. package/lib/auth/auth.d.ts +0 -129
  81. package/lib/auth/auth.js +0 -146
  82. package/lib/auth/auth.js.map +0 -1
  83. package/lib/auth/user-auth-types.d.ts +0 -19
  84. package/lib/auth/user-auth-types.js +0 -3
  85. package/lib/auth/user-auth-types.js.map +0 -1
  86. package/lib/cloud-functions/cloud-functions-mock.d.ts +0 -11
  87. package/lib/cloud-functions/cloud-functions-mock.js +0 -19
  88. package/lib/cloud-functions/cloud-functions-mock.js.map +0 -1
  89. package/lib/cloud-functions/cloud-functions.d.ts +0 -19
  90. package/lib/cloud-functions/cloud-functions.js +0 -64
  91. package/lib/cloud-functions/cloud-functions.js.map +0 -1
  92. package/lib/cloud-storage/cloud-storage.d.ts +0 -24
  93. package/lib/cloud-storage/cloud-storage.js +0 -37
  94. package/lib/cloud-storage/cloud-storage.js.map +0 -1
  95. package/lib/cloud-storage/mock-cloud-storage.d.ts +0 -20
  96. package/lib/cloud-storage/mock-cloud-storage.js +0 -68
  97. package/lib/cloud-storage/mock-cloud-storage.js.map +0 -1
  98. package/lib/cloud-storage/stored-file.d.ts +0 -39
  99. package/lib/cloud-storage/stored-file.js +0 -106
  100. package/lib/cloud-storage/stored-file.js.map +0 -1
  101. package/lib/index.d.ts +0 -19
  102. package/lib/index.js +0 -36
  103. package/lib/index.js.map +0 -1
  104. package/lib/observable/observable.d.ts +0 -52
  105. package/lib/observable/observable.js +0 -66
  106. package/lib/observable/observable.js.map +0 -1
  107. package/lib/persistent/entropic-component.d.ts +0 -76
  108. package/lib/persistent/entropic-component.js +0 -109
  109. package/lib/persistent/entropic-component.js.map +0 -1
  110. package/lib/persistent/persistent.d.ts +0 -281
  111. package/lib/persistent/persistent.js +0 -539
  112. package/lib/persistent/persistent.js.map +0 -1
  113. package/lib/server-auth/server-auth-mock.d.ts +0 -12
  114. package/lib/server-auth/server-auth-mock.js +0 -39
  115. package/lib/server-auth/server-auth-mock.js.map +0 -1
  116. package/lib/server-auth/server-auth.d.ts +0 -24
  117. package/lib/server-auth/server-auth.js +0 -36
  118. package/lib/server-auth/server-auth.js.map +0 -1
  119. package/lib/store/data-source.d.ts +0 -137
  120. package/lib/store/data-source.js +0 -62
  121. package/lib/store/data-source.js.map +0 -1
  122. package/lib/store/json-data-source.d.ts +0 -68
  123. package/lib/store/json-data-source.js +0 -199
  124. package/lib/store/json-data-source.js.map +0 -1
  125. package/lib/store/mocks/test-user.d.ts +0 -49
  126. package/lib/store/mocks/test-user.js +0 -135
  127. package/lib/store/mocks/test-user.js.map +0 -1
  128. package/lib/store/model.d.ts +0 -238
  129. package/lib/store/model.js +0 -417
  130. package/lib/store/model.js.map +0 -1
  131. package/lib/store/store.d.ts +0 -62
  132. package/lib/store/store.js +0 -102
  133. package/lib/store/store.js.map +0 -1
  134. package/lib/types/utility-types.d.ts +0 -45
  135. package/lib/types/utility-types.js +0 -3
  136. package/lib/types/utility-types.js.map +0 -1
  137. package/lib/utils/test-utils/test-person.d.ts +0 -33
  138. package/lib/utils/test-utils/test-person.js +0 -25
  139. package/lib/utils/test-utils/test-person.js.map +0 -1
  140. package/lib/utils/utils.js +0 -76
  141. package/lib/utils/utils.js.map +0 -1
@@ -1,281 +0,0 @@
1
- import { ClassPropNames, SomeClassProps, UnderscoredProp } from '../types/utility-types';
2
- export type PersistentConstructor = new () => Persistent;
3
- /**
4
- * The corresponding type of the plain object of a persistent class.
5
- */
6
- export type PersistentObject<T extends Persistent> = Omit<SomeClassProps<T>, 'className'> & Partial<DocumentReference> & {
7
- __className: string;
8
- __rootCollections?: Collections;
9
- };
10
- export type PersistentObjectWithId<T extends Persistent> = PersistentObject<T> & {
11
- id: string;
12
- };
13
- /**
14
- * The type of the plain object of a persistent class for all the nested properties.
15
- */
16
- export type MakePersistentObjects<T> = {
17
- [A in keyof T]: T[A] extends Persistent ? PersistentObject<T[A]> : MakePersistentObjects<T[A]>;
18
- };
19
- /**
20
- * A collection of document objects typically returned by Persistent.toObject()
21
- * @see Persistent.toObject
22
- */
23
- export type Collections = {
24
- [collectionPath: string]: PersistentObjectWithId<Persistent>[] | undefined;
25
- };
26
- /**
27
- * Stores information about a reference in another collection.
28
- */
29
- export interface DocumentReference {
30
- id: string;
31
- __className: string;
32
- __documentReference: {
33
- storedInCollection: string;
34
- };
35
- }
36
- /**
37
- * A class that provides several methods to serialize and deserialize objects.
38
- */
39
- export declare class Persistent {
40
- /**
41
- * Registers a class to be used by the persistence engine.
42
- * @param className the name of the class to be registered
43
- * @param factory the constructor of the registered class
44
- * @param annotation an annotation associated with the class
45
- */
46
- static registerFactory(className: string, factory: PersistentConstructor, annotation?: unknown): void;
47
- /**
48
- * Returns the constructor of a registered class
49
- * @param className the name of the class to be retrieved
50
- * @returns the constructor of the class
51
- * @throws an error if the class is not registered
52
- * @see registerFactory
53
- * @see registeredClasses
54
- * @see classesExtending
55
- * @see annotations
56
- */
57
- static classFactory(className: string | undefined): PersistentConstructor;
58
- /**
59
- * Returns the names of all registered classes
60
- * @returns the names of all registered classes
61
- * @see registerFactory
62
- * @see classFactory
63
- */
64
- static registeredClasses(): string[];
65
- /**
66
- * Returns the names of all registered classes that extend a given class
67
- * @param derivedFrom the class to be extended
68
- * @returns the names of all registered classes that extend the given class
69
- * @see registerFactory
70
- * @see classFactory
71
- */
72
- static classesExtending(derivedFrom: PersistentConstructor | Function): string[];
73
- /**
74
- * Returns the annotation associated with a registered class
75
- * @param className the name of the class to be retrieved
76
- * @returns the annotation associated with the class
77
- * @throws an error if the class is not registered
78
- * @see registerFactory
79
- */
80
- static annotations(className: string | Persistent | PersistentConstructor): unknown;
81
- /**
82
- * Returns a new instance of Persistent class.
83
- * @param className the initial id of this instance. If not provided, a new id will be generated
84
- */
85
- constructor(id?: string);
86
- /**
87
- * Gets the class name of this instance.
88
- */
89
- get className(): string;
90
- /**
91
- * Sets the id of this instance.
92
- * @param value the id of this instance
93
- */
94
- protected setId(value: string): void;
95
- /**
96
- * Returns the id of this instance.
97
- * @returns the id of this instance
98
- */
99
- get id(): string;
100
- /**
101
- * This method is called by the persistence engine when the instance has been
102
- * just serialized. It is called after the properties are initialized with
103
- * serialized data.
104
- */
105
- protected afterDeserialize(): void;
106
- /**
107
- * This method is called by the persistence engine before the instance is
108
- * serialized.
109
- */
110
- protected beforeSerialize(): void;
111
- /**
112
- * Returns an array of the persistent properties of this instance.
113
- * @returns an array of the persistent properties of this instance
114
- */
115
- getPersistentProperties(): readonly PersistentProperty[];
116
- /**
117
- * Get the property information of this instance
118
- * @param propName the persistent property name
119
- * @returns the property information
120
- */
121
- getPropInfo<T extends this>(propName: ClassPropNames<T>): PersistentProperty;
122
- /**
123
- * Query if the property is required
124
- * To mark a property as required, use the @required decorator
125
- * @param propName the persistent property name
126
- * @returns true if the property is required
127
- * @see required
128
- */
129
- isRequired<T extends this>(propName: ClassPropNames<T>): boolean;
130
- /**
131
- * Query if the property value is valid
132
- * Define the validator function using the @required decorator
133
- * @param propName the persistent property name
134
- * @returns true if the property value is valid using the validator function
135
- * passed to the @required decorator
136
- * @see required
137
- */
138
- isPropValueValid<T extends this>(propName: ClassPropNames<T>): boolean;
139
- /**
140
- * Copy the persistent properties of the given instance to this instance.
141
- * The property `id` will be ignored.
142
- * Only the properties that are not null or undefined will be copied.
143
- * @param instance the instance to be copied
144
- * @returns this instance
145
- * @see fromObject
146
- * @see toObject
147
- */
148
- clone(instance: Persistent): this;
149
- /**
150
- * Initializes the persistent properties of this instance from the properties
151
- * of given object.
152
- * @param obj the object to be copied
153
- * @returns this instance
154
- * @see clone
155
- * @see toObject
156
- */
157
- fromObject(obj: Partial<PersistentObject<this>> | {}): this;
158
- private fromObj;
159
- /**
160
- * Returns a plain object representation of this instance.
161
- * Only the properties that are not null or undefined will be copied.
162
- * @returns a plain object representation of this instance
163
- * @see fromObject
164
- * @see clone
165
- */
166
- toObject(): PersistentObject<this>;
167
- private toObj;
168
- static searchableArrayNameFor(propName: string): string;
169
- private fromDeepObject;
170
- private toDeepObj;
171
- private toReferenceObj;
172
- private buildRefObject;
173
- private pushDocument;
174
- private removeUnderscore;
175
- static createReference<T extends Persistent>(obj: PersistentObject<T> | string): T;
176
- static createInstance<T extends Persistent>(obj: PersistentObject<T> | string): T;
177
- static propInfo<T extends Persistent>(registeredClassName: string, propName: ClassPropNames<T>): PersistentProperty;
178
- private _id;
179
- private _persistentProperties;
180
- private static _factoryMap;
181
- }
182
- type CollectionPathCallback = (value: Persistent, prop: PersistentProperty) => string;
183
- type ValidatorFunction<T extends Persistent, P extends ClassPropNames<T>> = (value: T[P], property: PersistentProperty, persistentInstance: T) => boolean;
184
- interface PersistentProperty {
185
- name: string;
186
- isReference?: boolean;
187
- isPureReference?: boolean;
188
- storeInCollection?: string | CollectionPathCallback;
189
- subCollection?: string;
190
- forcedPersistentProps?: ClassPropNames<Persistent>[];
191
- toObjectSpecial?: (classObj: any) => any;
192
- fromObjectSpecial?: (obj: any) => any;
193
- searchableArray?: boolean;
194
- validator?: ValidatorFunction<any, any>;
195
- }
196
- /**
197
- * Decorator for a property that you want to persist.
198
- */
199
- export declare function persistent(target: Persistent, property: string): void;
200
- /**
201
- * Decorator for a property that is a reference to a persistent object and should be stored
202
- * in a specific collection.
203
- * @param collectionPath the path to the collection where the reference should be stored.
204
- * @returns
205
- */
206
- export declare function persistentReferenceAt(collectionPath: string | CollectionPathCallback): (target: Persistent, property: string) => void;
207
- /**
208
- * Decorator for a property that is a reference to a persistent object.
209
- * The reference content is automatically stored in a collection. The collection
210
- * is determined by the class name of the decorated property.
211
- * @see persistentPureReference
212
- */
213
- export declare function persistentReference(target: Persistent, property: string): void;
214
- /**
215
- * Decorator to declare a persistent reference (see @persistentReference) that stores
216
- * the values in forcedPersistentProps as values in the reference object. This is useful
217
- * when you are not able to wait for population of referenced properties.
218
- * @param forcedPersistentProps the properties whose values should be stored in the reference object
219
- * @param storedInCollection indicates the path of the collection where this reference is stored
220
- */
221
- export declare function persistentReferenceWithPersistentProps<T extends Persistent>(forcedPersistentProps: ClassPropNames<T>[], storeInCollection?: string | CollectionPathCallback): (target: Persistent, property: string) => void;
222
- /**
223
- * Decorator for a property that is a reference to a persistent object.
224
- * In this case, and contrary to the @persistentReference decorator, the reference
225
- * contents is not stored even it has been changed. Only the reference information
226
- * is stored.
227
- * @see persistentReference
228
- */
229
- export declare function persistentPureReference(target: Persistent, property: string, storeInCollection?: string | CollectionPathCallback): void;
230
- /**
231
- * Decorator to declare a persistent property as a pure reference (see @persistentPureReference) that stores
232
- * the values of the properties listed in forcedPersistentProps as values in the reference object. This is useful
233
- * when you only need a few properties to be available without needing to populate the referenced property.
234
- * @param forcedPersistentProps the properties whose values should be stored in the reference object
235
- * @param storedInCollection indicates the path of the collection where this reference is stored
236
- * @see persistentReferenceWithPersistentProps
237
- * @see persistentPureReference
238
- * @sample
239
- * class User extends Persistent {
240
- * @persistentPureReferenceWithPersistentProps( ['name', 'email'] ) private _friend: User
241
- * }
242
- * // the reference object will contain the properties name and email of the referenced user
243
- * // without having to populate the _friend property
244
- */
245
- export declare function persistentPureReferenceWithPersistentProps<T extends Persistent>(forcedPersistentProps: ClassPropNames<T>[], storeInCollection?: string | CollectionPathCallback): (target: Persistent, property: string) => void;
246
- export declare function persistentParser(options?: Partial<PersistentProperty>): (target: Persistent, property: string) => void;
247
- /**
248
- * Decorator to register a persistent class. Entropic Bond needs that you register
249
- * all persistent classes that you want to use in any persistent stream.
250
- * @param className the name of the class
251
- * @param annotation an optional annotation that can be used to store additional information
252
- */
253
- export declare function registerPersistentClass(className: string, annotation?: unknown): (constructor: PersistentConstructor) => void;
254
- /**
255
- * Decorator to register a legacy name for a persistent class. This is useful when you want to
256
- * be able to load old data that was stored with a different class name.
257
- * @param legacyName the legacy name of the class
258
- */
259
- export declare function registerLegacyClassName(legacyName: string): (constructor: PersistentConstructor) => void;
260
- /**
261
- * Decorator to make a `Persistent` array property searchable by the
262
- * persistance engine.
263
- * When a property is marked as searchable, the persistance engine will
264
- * generate internally a new property with the same name but with the suffix `_searchable`
265
- * and prefixed with the `_` character. This new property will contain an array
266
- * with the `id` of the persistent elements in the original array.
267
- */
268
- export declare function searchableArray(target: Persistent, property: string): void;
269
- /**
270
- * Decorator to mark the property as required.
271
- * @see requiredWithValidator
272
- */
273
- export declare function required(target: Persistent, property: string): void;
274
- /**
275
- * Decorator to mark the property as required.
276
- * @param validator a function that returns true if the property value is valid.
277
- * By default, the property is valid if it is not undefined and not null.
278
- * @see required
279
- */
280
- export declare function requiredWithValidator<T extends Persistent, P extends ClassPropNames<T>>(validator?: ValidatorFunction<T, P>): (target: T, property: UnderscoredProp<P>) => void;
281
- export {};