entropic-bond 1.50.0 → 1.50.1

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 (111) hide show
  1. package/lib/auth/auth-mock.d.ts +22 -0
  2. package/lib/auth/auth-mock.spec.d.ts +1 -0
  3. package/lib/auth/auth.d.ts +131 -0
  4. package/lib/auth/user-auth-types.d.ts +19 -0
  5. package/lib/cloud-functions/cloud-functions-mock.d.ts +11 -0
  6. package/lib/cloud-functions/cloud-functions-mock.spec.d.ts +1 -0
  7. package/lib/cloud-functions/cloud-functions.d.ts +19 -0
  8. package/lib/cloud-storage/cloud-storage.d.ts +24 -0
  9. package/lib/cloud-storage/cloud-storage.spec.d.ts +1 -0
  10. package/lib/cloud-storage/mock-cloud-storage.d.ts +20 -0
  11. package/lib/cloud-storage/stored-file.d.ts +39 -0
  12. package/lib/entropic-bond.js +1667 -0
  13. package/lib/entropic-bond.umd.cjs +7 -0
  14. package/lib/index.d.ts +19 -0
  15. package/lib/observable/observable.d.ts +52 -0
  16. package/lib/observable/observable.spec.d.ts +1 -0
  17. package/lib/persistent/entropic-component.d.ts +76 -0
  18. package/lib/persistent/entropic-component.spec.d.ts +1 -0
  19. package/lib/persistent/persistent.d.ts +281 -0
  20. package/lib/persistent/persistent.spec.d.ts +67 -0
  21. package/lib/server-auth/server-auth-mock.d.ts +12 -0
  22. package/lib/server-auth/server-auth-mock.spec.d.ts +1 -0
  23. package/lib/server-auth/server-auth.d.ts +24 -0
  24. package/lib/store/data-source.d.ts +137 -0
  25. package/lib/store/json-data-source.d.ts +68 -0
  26. package/lib/store/json-data-source.spec.d.ts +1 -0
  27. package/lib/store/mocks/test-user.d.ts +49 -0
  28. package/lib/store/model.d.ts +238 -0
  29. package/lib/store/model.spec.d.ts +1 -0
  30. package/lib/store/store.d.ts +62 -0
  31. package/lib/store/store.spec.d.ts +1 -0
  32. package/lib/types/utility-types.d.ts +45 -0
  33. package/lib/types/utility-types.spec.d.ts +1 -0
  34. package/lib/utils/test-utils/test-person.d.ts +33 -0
  35. package/{src/utils/utils.ts → lib/utils/utils.d.ts} +10 -34
  36. package/lib/utils/utils.spec.d.ts +1 -0
  37. package/package.json +4 -1
  38. package/.github/workflows/release.yml +0 -26
  39. package/CHANGELOG.md +0 -1151
  40. package/docs/.nojekyll +0 -1
  41. package/docs/README.md +0 -94
  42. package/docs/classes/Auth.md +0 -391
  43. package/docs/classes/AuthMock.md +0 -278
  44. package/docs/classes/AuthService.md +0 -188
  45. package/docs/classes/CloudFunctions.md +0 -123
  46. package/docs/classes/CloudFunctionsMock.md +0 -97
  47. package/docs/classes/CloudStorage.md +0 -215
  48. package/docs/classes/DataSource.md +0 -248
  49. package/docs/classes/EntropicComponent.md +0 -666
  50. package/docs/classes/JsonDataSource.md +0 -328
  51. package/docs/classes/MockCloudStorage.md +0 -279
  52. package/docs/classes/Model.md +0 -274
  53. package/docs/classes/Observable.md +0 -120
  54. package/docs/classes/Persistent.md +0 -420
  55. package/docs/classes/ServerAuth.md +0 -211
  56. package/docs/classes/ServerAuthMock.md +0 -176
  57. package/docs/classes/ServerAuthService.md +0 -130
  58. package/docs/classes/Store.md +0 -218
  59. package/docs/classes/StoredFile.md +0 -636
  60. package/docs/enums/StoredFileEvent.md +0 -41
  61. package/docs/interfaces/AuthError.md +0 -30
  62. package/docs/interfaces/CloudFunctionsService.md +0 -69
  63. package/docs/interfaces/Collection.md +0 -13
  64. package/docs/interfaces/CustomCredentials.md +0 -7
  65. package/docs/interfaces/DocumentReference.md +0 -49
  66. package/docs/interfaces/JsonRawData.md +0 -7
  67. package/docs/interfaces/SignData.md +0 -63
  68. package/docs/interfaces/StoreParams.md +0 -52
  69. package/docs/interfaces/StoredFileChange.md +0 -41
  70. package/docs/interfaces/UploadControl.md +0 -90
  71. package/docs/interfaces/UserCredentials.md +0 -113
  72. package/docs/interfaces/Values.md +0 -17
  73. package/docs/modules.md +0 -1273
  74. package/src/auth/auth-mock.spec.ts +0 -168
  75. package/src/auth/auth-mock.ts +0 -129
  76. package/src/auth/auth.ts +0 -185
  77. package/src/auth/user-auth-types.ts +0 -21
  78. package/src/cloud-functions/cloud-functions-mock.spec.ts +0 -136
  79. package/src/cloud-functions/cloud-functions-mock.ts +0 -23
  80. package/src/cloud-functions/cloud-functions.ts +0 -83
  81. package/src/cloud-storage/cloud-storage.spec.ts +0 -207
  82. package/src/cloud-storage/cloud-storage.ts +0 -60
  83. package/src/cloud-storage/mock-cloud-storage.ts +0 -72
  84. package/src/cloud-storage/stored-file.ts +0 -102
  85. package/src/index.ts +0 -19
  86. package/src/observable/observable.spec.ts +0 -105
  87. package/src/observable/observable.ts +0 -67
  88. package/src/persistent/entropic-component.spec.ts +0 -143
  89. package/src/persistent/entropic-component.ts +0 -135
  90. package/src/persistent/persistent.spec.ts +0 -828
  91. package/src/persistent/persistent.ts +0 -650
  92. package/src/server-auth/server-auth-mock.spec.ts +0 -53
  93. package/src/server-auth/server-auth-mock.ts +0 -45
  94. package/src/server-auth/server-auth.ts +0 -49
  95. package/src/store/data-source.ts +0 -186
  96. package/src/store/json-data-source.spec.ts +0 -100
  97. package/src/store/json-data-source.ts +0 -256
  98. package/src/store/mocks/mock-data.json +0 -155
  99. package/src/store/mocks/test-user.ts +0 -122
  100. package/src/store/model.spec.ts +0 -659
  101. package/src/store/model.ts +0 -462
  102. package/src/store/store.spec.ts +0 -30
  103. package/src/store/store.ts +0 -113
  104. package/src/types/utility-types.spec.ts +0 -117
  105. package/src/types/utility-types.ts +0 -116
  106. package/src/utils/test-utils/test-person.ts +0 -44
  107. package/src/utils/utils.spec.ts +0 -95
  108. package/tsconfig-build.json +0 -7
  109. package/tsconfig-cjs.json +0 -9
  110. package/tsconfig.json +0 -33
  111. package/vite.config.ts +0 -22
package/docs/.nojekyll DELETED
@@ -1 +0,0 @@
1
- TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
package/docs/README.md DELETED
@@ -1,94 +0,0 @@
1
- entropic-bond / [Exports](modules.md)
2
-
3
- # Entropic Bond
4
-
5
- > Tidy up your messy components
6
-
7
- **Entropic Bond** helps your _TypeScript_ software development, both in the frontend and the backend. It is composed by several abstractions that make your code fully decoupled from the database, authorization service or cloud storage provider yet easy to use. In addition, it offers an observer based architecture to intercommunicate your business logic entities efficiently.
8
-
9
- ## Who needs to focus on a unique backend provider
10
-
11
- **Entropic Bond** is designed with the serverless and NoSQL models in mind. This doesn't mean you cannot use it in such scenarios. Moreover, it is an excellent tool to develop _Functions as a Service_ (FaaS). With **Entropic Bond**, you just forget about those implementation details. You only need to focus on developing your domain model.
12
-
13
- ## Who needs a global state
14
-
15
- **Entropic Bond** removes the need to maintain a global state. The underlying architecture is designed in a way that the state is maintained at entity level and the relationship between the entities is provided by a notification infrastructure.
16
-
17
- ## How to use
18
-
19
- Typically, you will derive all your business logic entities from the `EntropicComponent` class. This class provides two main functionalities; persistence and observability.
20
-
21
- ### API
22
-
23
- You can find the API documentation [here](docs/modules.md).
24
-
25
- ### Persistence
26
-
27
- The persistence mechanism allows defining which entities and which properties of those entities should be stored in the database. To make an entity persistent, it should derive from the `EntropicComponent` class or the `Persistent` class.
28
-
29
- In order to allow the persistence mechanism to automatically instantiate entities from the database, you should use the `@registerPersistentClass` decorator passing the class name as a parameter.
30
-
31
- The properties or attributes that you want to be streamed should be preceded by the `@persistent` decorator in the attribute declaration. The property name must be private and prefixed with an underscore (_). Access to the public attributes should be done by the use of accessors.
32
-
33
- ```ts
34
- @registerPersistentClass( 'MyEntity' )
35
- class MyEntity extends EntropicBond {
36
- @persistent private _persistentProp1: string
37
- @persistent private _persistentProp2: boolean
38
- @persistent private _persistentProp3: AnotherPersistentObject
39
- @persistent private _persistentProp4: number[]
40
-
41
- private _nonPersistentProp: unknown
42
-
43
- // accessors go here ...
44
- }
45
- ```
46
-
47
- #### Storing and querying the persistent entities
48
-
49
- The database abstraction is provided by the `Store` object. To learn how to set up a concrete database, [see below](setup_the_database_access).
50
-
51
- The `Store.getModel` method will return an object with methods to access the database.
52
-
53
- ```ts
54
- let foundEntity: MyEntity
55
- const myEntity = new MyEntity()
56
- const entityModel = Store.getModel<MyEntity>( 'MyEntity' )
57
-
58
- // fill myEntity object with data here ...
59
-
60
- await entityModel.save( myEntity ) // saves myEntity in the database
61
-
62
- foundEntity = await entityModel.findById( '0340d-349ab' ) // retrieves from database
63
-
64
- foundEntity = await entityModel.find().
65
- .where( 'persistentProp1', '==', 'foo' )
66
- .where( 'persistentProp2', '==', true )
67
- .limit( 10 )
68
- .orderBy( 'persistentProp1', 'desc' )
69
- .get() // retrieves from database
70
-
71
- entityModel.delete( '0340d-349ab' ) // deletes from database
72
- ```
73
-
74
- #### Set up the database access
75
-
76
- The database access is encapsulated in a `DataSource` object. A concrete implementation of a _JSON_ `DataSource` is provided as `JsonDataSource`. You can use this implementation for testing purposes.
77
-
78
- Currently, there is an official plugin to connect to a **Firebase** _Firestore_ database. To install the plugin, run:
79
-
80
- ```sh
81
- npm i entropic-bond-firebase
82
- ```
83
-
84
- You can develop new plugins following the [plugin developer's](plugin_development) section.
85
-
86
- You should instantiate the concrete implementation of the `DataSource` and pass it to the `useDataSource` method of the `Store` object.
87
-
88
- ```ts
89
- Store.useDataSource( new JsonDataSource() )
90
- ```
91
-
92
- ### Observability
93
-
94
- ### Auth
@@ -1,391 +0,0 @@
1
- [entropic-bond](../README.md) / [Exports](../modules.md) / Auth
2
-
3
- # Class: Auth
4
-
5
- The Auth class is a singleton that provides a unified interface to the authentication service.
6
- You should register an authentication service by using `Auth.useAuthService`
7
- method before using the Auth class.
8
-
9
- ## Hierarchy
10
-
11
- - [`AuthService`](AuthService.md)
12
-
13
- ↳ **`Auth`**
14
-
15
- ## Table of contents
16
-
17
- ### Constructors
18
-
19
- - [constructor](Auth.md#constructor)
20
-
21
- ### Properties
22
-
23
- - [error](Auth.md#error)
24
-
25
- ### Accessors
26
-
27
- - [instance](Auth.md#instance)
28
-
29
- ### Methods
30
-
31
- - [linkAdditionalProvider](Auth.md#linkadditionalprovider)
32
- - [login](Auth.md#login)
33
- - [logout](Auth.md#logout)
34
- - [onAuthStateChange](Auth.md#onauthstatechange)
35
- - [removeAuthStateChange](Auth.md#removeauthstatechange)
36
- - [resetEmailPassword](Auth.md#resetemailpassword)
37
- - [signUp](Auth.md#signup)
38
- - [unlinkProvider](Auth.md#unlinkprovider)
39
- - [useAuthService](Auth.md#useauthservice)
40
-
41
- ## Constructors
42
-
43
- ### constructor
44
-
45
- • `Protected` **new Auth**()
46
-
47
- #### Overrides
48
-
49
- [AuthService](AuthService.md).[constructor](AuthService.md#constructor)
50
-
51
- #### Defined in
52
-
53
- [auth/auth.ts:39](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L39)
54
-
55
- ## Properties
56
-
57
- ### error
58
-
59
- ▪ `Static` **error**: `Object`
60
-
61
- #### Type declaration
62
-
63
- | Name | Type |
64
- | :------ | :------ |
65
- | `shouldBeRegistered` | `string` |
66
-
67
- #### Defined in
68
-
69
- [auth/auth.ts:37](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L37)
70
-
71
- ## Accessors
72
-
73
- ### instance
74
-
75
- • `Static` `get` **instance**(): [`Auth`](Auth.md)
76
-
77
- The instance of the Auth class
78
-
79
- #### Returns
80
-
81
- [`Auth`](Auth.md)
82
-
83
- the authentication service
84
-
85
- #### Defined in
86
-
87
- [auth/auth.ts:63](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L63)
88
-
89
- ## Methods
90
-
91
- ### linkAdditionalProvider
92
-
93
- ▸ **linkAdditionalProvider**(`provider`): `Promise`<`unknown`\>
94
-
95
- Links an additional authentication provider to the authenticated user.
96
-
97
- **`Example`**
98
-
99
- ```ts
100
- // Link a Google account to the auth service
101
- Auth.instance.linkAdditionalProvider({ authProvider: 'google' })
102
- ```
103
-
104
- #### Parameters
105
-
106
- | Name | Type | Description |
107
- | :------ | :------ | :------ |
108
- | `provider` | [`AuthProvider`](../modules.md#authprovider) | the provider to be linked |
109
-
110
- #### Returns
111
-
112
- `Promise`<`unknown`\>
113
-
114
- a promise that resolves when the process is done
115
-
116
- #### Overrides
117
-
118
- [AuthService](AuthService.md).[linkAdditionalProvider](AuthService.md#linkadditionalprovider)
119
-
120
- #### Defined in
121
-
122
- [auth/auth.ts:148](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L148)
123
-
124
- ___
125
-
126
- ### login
127
-
128
- ▸ **login**<`T`\>(`singData`): `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
129
-
130
- Logs in an existing user
131
-
132
- **`Example`**
133
-
134
- ```ts
135
- // Log in an existing user with email and password
136
- Auth.instance.login({ authProvider: 'email', email: 'john@test.com', password: '123456' })
137
- // Log in an existing user with a Google account
138
- Auth.instance.login({ authProvider: 'google'})
139
- ```
140
-
141
- #### Type parameters
142
-
143
- | Name | Type |
144
- | :------ | :------ |
145
- | `T` | extends `Object` |
146
-
147
- #### Parameters
148
-
149
- | Name | Type | Description |
150
- | :------ | :------ | :------ |
151
- | `singData` | [`SignData`](../interfaces/SignData.md) | the data to be used to log in the user |
152
-
153
- #### Returns
154
-
155
- `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
156
-
157
- a promise that resolves to the user credentials
158
-
159
- #### Overrides
160
-
161
- [AuthService](AuthService.md).[login](AuthService.md#login)
162
-
163
- #### Defined in
164
-
165
- [auth/auth.ts:91](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L91)
166
-
167
- ___
168
-
169
- ### logout
170
-
171
- ▸ **logout**(): `Promise`<`void`\>
172
-
173
- Logs out the current user
174
-
175
- #### Returns
176
-
177
- `Promise`<`void`\>
178
-
179
- a promise that resolves when the user is logged out
180
-
181
- #### Overrides
182
-
183
- [AuthService](AuthService.md).[logout](AuthService.md#logout)
184
-
185
- #### Defined in
186
-
187
- [auth/auth.ts:99](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L99)
188
-
189
- ___
190
-
191
- ### onAuthStateChange
192
-
193
- ▸ **onAuthStateChange**<`T`\>(`onChange`): [`Unsubscriber`](../modules.md#unsubscriber)
194
-
195
- Adds a listener to be called when the authentication state changes.
196
-
197
- **`Example`**
198
-
199
- ```ts
200
- // Add a listener to be called when the authentication state changes
201
- const removeListener = Auth.instance.onAuthStateChange( userCredentials => {
202
- if ( userCredentials ) {
203
- // The user is logged in
204
- } else {
205
- // The user is logged out
206
- }
207
- })
208
- ```
209
-
210
- #### Type parameters
211
-
212
- | Name | Type |
213
- | :------ | :------ |
214
- | `T` | extends `Object` |
215
-
216
- #### Parameters
217
-
218
- | Name | Type | Description |
219
- | :------ | :------ | :------ |
220
- | `onChange` | (`userCredentials`: [`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>) => `void` | the listener to be called when the authentication state changes. The listener is called with the user credentials as a parameter. If the user is logged out, the listener is called with `undefined` as a parameter. |
221
-
222
- #### Returns
223
-
224
- [`Unsubscriber`](../modules.md#unsubscriber)
225
-
226
- a function to remove the listener
227
-
228
- #### Overrides
229
-
230
- [AuthService](AuthService.md).[onAuthStateChange](AuthService.md#onauthstatechange)
231
-
232
- #### Defined in
233
-
234
- [auth/auth.ts:128](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L128)
235
-
236
- ___
237
-
238
- ### removeAuthStateChange
239
-
240
- ▸ **removeAuthStateChange**<`T`\>(`onChange`): `void`
241
-
242
- Removes a listener that was added by `onAuthStateChange` method.
243
-
244
- #### Type parameters
245
-
246
- | Name | Type |
247
- | :------ | :------ |
248
- | `T` | extends `Object` |
249
-
250
- #### Parameters
251
-
252
- | Name | Type | Description |
253
- | :------ | :------ | :------ |
254
- | `onChange` | (`userCredentials`: [`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>) => `void` | the listener to be removed |
255
-
256
- #### Returns
257
-
258
- `void`
259
-
260
- #### Defined in
261
-
262
- [auth/auth.ts:136](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L136)
263
-
264
- ___
265
-
266
- ### resetEmailPassword
267
-
268
- ▸ **resetEmailPassword**(`email`): `Promise`<`void`\>
269
-
270
- Resets the password associated with the email.
271
-
272
- #### Parameters
273
-
274
- | Name | Type | Description |
275
- | :------ | :------ | :------ |
276
- | `email` | `string` | the email address of the user to reset the password |
277
-
278
- #### Returns
279
-
280
- `Promise`<`void`\>
281
-
282
- a promise that resolves when the process is done
283
-
284
- #### Overrides
285
-
286
- [AuthService](AuthService.md).[resetEmailPassword](AuthService.md#resetemailpassword)
287
-
288
- #### Defined in
289
-
290
- [auth/auth.ts:108](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L108)
291
-
292
- ___
293
-
294
- ### signUp
295
-
296
- ▸ **signUp**<`T`\>(`singData`): `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
297
-
298
- Signs up a new user
299
-
300
- **`Example`**
301
-
302
- ```ts
303
- // Sign up a new user with email and password
304
- Auth.instance.signUp({ authProvider: 'email', email: 'john@test.com', password: '123456' })
305
- // Sign up a new user with a Google account
306
- Auth.instance.signUp({ authProvider: 'google'})
307
- ```
308
-
309
- #### Type parameters
310
-
311
- | Name | Type |
312
- | :------ | :------ |
313
- | `T` | extends `Object` |
314
-
315
- #### Parameters
316
-
317
- | Name | Type | Description |
318
- | :------ | :------ | :------ |
319
- | `singData` | [`SignData`](../interfaces/SignData.md) | the data to be used to sign up the user |
320
-
321
- #### Returns
322
-
323
- `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
324
-
325
- a promise that resolves to the user credentials
326
-
327
- #### Overrides
328
-
329
- [AuthService](AuthService.md).[signUp](AuthService.md#signup)
330
-
331
- #### Defined in
332
-
333
- [auth/auth.ts:77](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L77)
334
-
335
- ___
336
-
337
- ### unlinkProvider
338
-
339
- ▸ **unlinkProvider**(`provider`): `Promise`<`unknown`\>
340
-
341
- Unlinks an authentication provider from the authenticated user.
342
-
343
- **`Example`**
344
-
345
- ```ts
346
- // Unlink the Google account from the auth service
347
- Auth.instance.unlinkProvider({ authProvider: 'google' })
348
- ```
349
-
350
- #### Parameters
351
-
352
- | Name | Type | Description |
353
- | :------ | :------ | :------ |
354
- | `provider` | [`AuthProvider`](../modules.md#authprovider) | the provider to be unlinked |
355
-
356
- #### Returns
357
-
358
- `Promise`<`unknown`\>
359
-
360
- a promise that resolves when the process is done
361
-
362
- #### Overrides
363
-
364
- [AuthService](AuthService.md).[unlinkProvider](AuthService.md#unlinkprovider)
365
-
366
- #### Defined in
367
-
368
- [auth/auth.ts:160](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L160)
369
-
370
- ___
371
-
372
- ### useAuthService
373
-
374
- ▸ `Static` **useAuthService**(`authService`): `void`
375
-
376
- Registers an authentication service to be used by the Auth class.
377
- You need to register an authentication service before using the Auth class.
378
-
379
- #### Parameters
380
-
381
- | Name | Type | Description |
382
- | :------ | :------ | :------ |
383
- | `authService` | [`AuthService`](AuthService.md) | the authentication service to be used by the Auth class |
384
-
385
- #### Returns
386
-
387
- `void`
388
-
389
- #### Defined in
390
-
391
- [auth/auth.ts:52](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L52)