tinybase 3.1.0-beta.4 → 3.1.0-beta.5

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 (85) hide show
  1. package/lib/debug/ui-react.js +2 -2
  2. package/lib/{cjs-es6 → types}/checkpoints.d.ts +11 -13
  3. package/lib/{debug → types}/indexes.d.ts +8 -16
  4. package/lib/{debug → types}/metrics.d.ts +47 -50
  5. package/lib/{cjs → types}/persisters.d.ts +24 -30
  6. package/lib/{cjs-es6 → types}/queries.d.ts +472 -309
  7. package/lib/{debug → types}/relationships.d.ts +9 -17
  8. package/lib/{cjs-es6 → types}/store.d.ts +176 -1084
  9. package/lib/types/tinybase.d.ts +14 -0
  10. package/lib/{cjs-es6 → types}/tools.d.ts +7 -12
  11. package/lib/{debug → types}/ui-react.d.ts +11 -5
  12. package/lib/{checkpoints.d.ts → types/with-schemas/checkpoints.d.ts} +9 -7
  13. package/lib/{cjs → types/with-schemas}/indexes.d.ts +31 -18
  14. package/lib/types/with-schemas/internal/queries.d.ts +15 -0
  15. package/lib/types/with-schemas/internal/store.d.ts +101 -0
  16. package/lib/types/with-schemas/internal/ui-react.d.ts +776 -0
  17. package/lib/{cjs → types/with-schemas}/metrics.d.ts +54 -50
  18. package/lib/{debug → types/with-schemas}/persisters.d.ts +4 -4
  19. package/lib/{debug → types/with-schemas}/queries.d.ts +607 -346
  20. package/lib/{cjs → types/with-schemas}/relationships.d.ts +29 -20
  21. package/lib/{debug → types/with-schemas}/store.d.ts +386 -829
  22. package/lib/types/with-schemas/tinybase.d.ts +14 -0
  23. package/lib/{debug → types/with-schemas}/tools.d.ts +7 -10
  24. package/lib/{cjs-es6 → types/with-schemas}/ui-react.d.ts +817 -1314
  25. package/package.json +145 -29
  26. package/readme.md +3 -3
  27. package/lib/cjs/checkpoints.d.ts +0 -961
  28. package/lib/cjs/queries.d.ts +0 -3028
  29. package/lib/cjs/store.d.ts +0 -6143
  30. package/lib/cjs/tinybase.d.ts +0 -14
  31. package/lib/cjs/tools.d.ts +0 -536
  32. package/lib/cjs/ui-react.d.ts +0 -10921
  33. package/lib/cjs-es6/indexes.d.ts +0 -974
  34. package/lib/cjs-es6/metrics.d.ts +0 -829
  35. package/lib/cjs-es6/persisters.d.ts +0 -733
  36. package/lib/cjs-es6/relationships.d.ts +0 -1209
  37. package/lib/cjs-es6/tinybase.d.ts +0 -14
  38. package/lib/common.d.ts +0 -115
  39. package/lib/debug/checkpoints.d.ts +0 -961
  40. package/lib/debug/common.d.ts +0 -115
  41. package/lib/debug/tinybase.d.ts +0 -14
  42. package/lib/es6/checkpoints.d.ts +0 -961
  43. package/lib/es6/common.d.ts +0 -115
  44. package/lib/es6/indexes.d.ts +0 -974
  45. package/lib/es6/metrics.d.ts +0 -829
  46. package/lib/es6/persisters.d.ts +0 -733
  47. package/lib/es6/queries.d.ts +0 -3028
  48. package/lib/es6/relationships.d.ts +0 -1209
  49. package/lib/es6/store.d.ts +0 -6143
  50. package/lib/es6/tinybase.d.ts +0 -14
  51. package/lib/es6/tools.d.ts +0 -536
  52. package/lib/es6/ui-react.d.ts +0 -10921
  53. package/lib/indexes.d.ts +0 -974
  54. package/lib/metrics.d.ts +0 -829
  55. package/lib/persisters.d.ts +0 -733
  56. package/lib/queries.d.ts +0 -3028
  57. package/lib/relationships.d.ts +0 -1209
  58. package/lib/store.d.ts +0 -6143
  59. package/lib/tinybase.d.ts +0 -14
  60. package/lib/tools.d.ts +0 -536
  61. package/lib/ui-react.d.ts +0 -10921
  62. package/lib/umd/checkpoints.d.ts +0 -961
  63. package/lib/umd/common.d.ts +0 -115
  64. package/lib/umd/indexes.d.ts +0 -974
  65. package/lib/umd/metrics.d.ts +0 -829
  66. package/lib/umd/persisters.d.ts +0 -733
  67. package/lib/umd/queries.d.ts +0 -3028
  68. package/lib/umd/relationships.d.ts +0 -1209
  69. package/lib/umd/store.d.ts +0 -6143
  70. package/lib/umd/tinybase.d.ts +0 -14
  71. package/lib/umd/tools.d.ts +0 -536
  72. package/lib/umd/ui-react.d.ts +0 -10921
  73. package/lib/umd-es6/checkpoints.d.ts +0 -961
  74. package/lib/umd-es6/common.d.ts +0 -115
  75. package/lib/umd-es6/indexes.d.ts +0 -974
  76. package/lib/umd-es6/metrics.d.ts +0 -829
  77. package/lib/umd-es6/persisters.d.ts +0 -733
  78. package/lib/umd-es6/queries.d.ts +0 -3028
  79. package/lib/umd-es6/relationships.d.ts +0 -1209
  80. package/lib/umd-es6/store.d.ts +0 -6143
  81. package/lib/umd-es6/tinybase.d.ts +0 -14
  82. package/lib/umd-es6/tools.d.ts +0 -536
  83. package/lib/umd-es6/ui-react.d.ts +0 -10921
  84. /package/lib/{cjs-es6 → types}/common.d.ts +0 -0
  85. /package/lib/{cjs → types/with-schemas}/common.d.ts +0 -0
@@ -11,10 +11,11 @@
11
11
  * @module relationships
12
12
  */
13
13
 
14
+ import {CellIdFromSchema, TableIdFromSchema} from './internal/store';
14
15
  import {
15
16
  GetCell,
16
- NoSchemas,
17
17
  OptionalSchemas,
18
+ OptionalTablesSchema,
18
19
  RowCallback,
19
20
  Store,
20
21
  } from './store.d';
@@ -59,9 +60,9 @@ export type Relationship = {
59
60
  * objects in this Relationship.
60
61
  * @category Callback
61
62
  */
62
- export type RelationshipCallback = (
63
+ export type RelationshipCallback<Schema extends OptionalTablesSchema> = (
63
64
  relationshipId: Id,
64
- forEachRow: (rowCallback: RowCallback) => void,
65
+ forEachRow: (rowCallback: RowCallback<Schema>) => void,
65
66
  ) => void;
66
67
 
67
68
  /**
@@ -80,8 +81,8 @@ export type RelationshipCallback = (
80
81
  * @param localRowId The Id of the local Row whose remote Row Id changed.
81
82
  * @category Listener
82
83
  */
83
- export type RemoteRowIdListener = (
84
- relationships: Relationships,
84
+ export type RemoteRowIdListener<Schemas extends OptionalSchemas> = (
85
+ relationships: Relationships<Schemas>,
85
86
  relationshipId: Id,
86
87
  localRowId: Id,
87
88
  ) => void;
@@ -102,8 +103,8 @@ export type RemoteRowIdListener = (
102
103
  * @param remoteRowId The Id of the remote Row whose local Row Ids changed.
103
104
  * @category Listener
104
105
  */
105
- export type LocalRowIdsListener = (
106
- relationships: Relationships,
106
+ export type LocalRowIdsListener<Schemas extends OptionalSchemas> = (
107
+ relationships: Relationships<Schemas>,
107
108
  relationshipId: Id,
108
109
  remoteRowId: Id,
109
110
  ) => void;
@@ -125,8 +126,8 @@ export type LocalRowIdsListener = (
125
126
  * members changed.
126
127
  * @category Listener
127
128
  */
128
- export type LinkedRowIdsListener = (
129
- relationships: Relationships,
129
+ export type LinkedRowIdsListener<Schemas extends OptionalSchemas> = (
130
+ relationships: Relationships<Schemas>,
130
131
  relationshipId: Id,
131
132
  firstRowId: Id,
132
133
  ) => void;
@@ -253,7 +254,7 @@ export type RelationshipsListenerStats = {
253
254
  * @see Drawing demo
254
255
  * @category Relationships
255
256
  */
256
- export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
257
+ export interface Relationships<in out Schemas extends OptionalSchemas> {
257
258
  /**
258
259
  * The setRelationshipDefinition method lets you set the definition of a
259
260
  * Relationship.
@@ -340,11 +341,13 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
340
341
  * ```
341
342
  * @category Configuration
342
343
  */
343
- setRelationshipDefinition(
344
+ setRelationshipDefinition<LocalTableId extends TableIdFromSchema<Schemas[0]>>(
344
345
  relationshipId: Id,
345
- localTableId: Id,
346
- remoteTableId: Id,
347
- getRemoteRowId: Id | ((getCell: GetCell, localRowId: Id) => Id),
346
+ localTableId: LocalTableId,
347
+ remoteTableId: TableIdFromSchema<Schemas[0]>,
348
+ getRemoteRowId:
349
+ | CellIdFromSchema<Schemas[0], LocalTableId>
350
+ | ((getCell: GetCell<Schemas[0], LocalTableId>, localRowId: Id) => Id),
348
351
  ): Relationships<Schemas>;
349
352
 
350
353
  /**
@@ -473,7 +476,9 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
473
476
  * ```
474
477
  * @category Iterator
475
478
  */
476
- forEachRelationship(relationshipCallback: RelationshipCallback): void;
479
+ forEachRelationship(
480
+ relationshipCallback: RelationshipCallback<Schemas[0]>,
481
+ ): void;
477
482
 
478
483
  /**
479
484
  * The hasRelationship method returns a boolean indicating whether a given
@@ -528,7 +533,9 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
528
533
  * ```
529
534
  * @category Getter
530
535
  */
531
- getLocalTableId(relationshipId: Id): Id;
536
+ getLocalTableId<TableId extends TableIdFromSchema<Schemas[0]>>(
537
+ relationshipId: Id,
538
+ ): TableId | undefined;
532
539
 
533
540
  /**
534
541
  * The getRemoteTableId method returns the Id of the underlying remote Table
@@ -560,7 +567,9 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
560
567
  * ```
561
568
  * @category Getter
562
569
  */
563
- getRemoteTableId(relationshipId: Id): Id;
570
+ getRemoteTableId<TableId extends TableIdFromSchema<Schemas[0]>>(
571
+ relationshipId: Id,
572
+ ): TableId | undefined;
564
573
 
565
574
  /**
566
575
  * The getRemoteRowId method gets the remote Row Id for a given local Row in a
@@ -833,7 +842,7 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
833
842
  addRemoteRowIdListener(
834
843
  relationshipId: IdOrNull,
835
844
  localRowId: IdOrNull,
836
- listener: RemoteRowIdListener,
845
+ listener: RemoteRowIdListener<Schemas>,
837
846
  ): Id;
838
847
 
839
848
  /**
@@ -959,7 +968,7 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
959
968
  addLocalRowIdsListener(
960
969
  relationshipId: IdOrNull,
961
970
  remoteRowId: IdOrNull,
962
- listener: LocalRowIdsListener,
971
+ listener: LocalRowIdsListener<Schemas>,
963
972
  ): Id;
964
973
 
965
974
  /**
@@ -1030,7 +1039,7 @@ export interface Relationships<Schemas extends OptionalSchemas = NoSchemas> {
1030
1039
  addLinkedRowIdsListener(
1031
1040
  relationshipId: Id,
1032
1041
  firstRowId: Id,
1033
- listener: LinkedRowIdsListener,
1042
+ listener: LinkedRowIdsListener<Schemas>,
1034
1043
  ): Id;
1035
1044
 
1036
1045
  /**