@livestore/livestore 0.0.13 → 0.0.14

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 (205) hide show
  1. package/README.md +18 -21
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/QueryCache.d.ts +1 -1
  4. package/dist/QueryCache.d.ts.map +1 -1
  5. package/dist/QueryCache.js.map +1 -1
  6. package/dist/__tests__/react/fixture.d.ts +5 -4
  7. package/dist/__tests__/react/fixture.d.ts.map +1 -1
  8. package/dist/__tests__/react/fixture.js +13 -14
  9. package/dist/__tests__/react/fixture.js.map +1 -1
  10. package/dist/__tests__/react/useComponentState.test.d.ts +2 -0
  11. package/dist/__tests__/react/useComponentState.test.d.ts.map +1 -0
  12. package/dist/__tests__/react/useComponentState.test.js +68 -0
  13. package/dist/__tests__/react/useComponentState.test.js.map +1 -0
  14. package/dist/__tests__/react/useLQuery.test.d.ts +2 -0
  15. package/dist/__tests__/react/useLQuery.test.d.ts.map +1 -0
  16. package/dist/__tests__/react/useLQuery.test.js +38 -0
  17. package/dist/__tests__/react/useLQuery.test.js.map +1 -0
  18. package/dist/__tests__/react/useLiveStoreComponent.test.js +4 -9
  19. package/dist/__tests__/react/useLiveStoreComponent.test.js.map +1 -1
  20. package/dist/__tests__/react/useQuery.test.d.ts +2 -0
  21. package/dist/__tests__/react/useQuery.test.d.ts.map +1 -0
  22. package/dist/__tests__/react/useQuery.test.js +33 -0
  23. package/dist/__tests__/react/useQuery.test.js.map +1 -0
  24. package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.d.ts +2 -0
  25. package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.d.ts.map +1 -0
  26. package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.js +38 -0
  27. package/dist/__tests__/react/utils/extractStackInfoFromStackTrace.test.js.map +1 -0
  28. package/dist/__tests__/reactive.test.js +168 -95
  29. package/dist/__tests__/reactive.test.js.map +1 -1
  30. package/dist/__tests__/reactiveQueries/sql.test.d.ts +2 -0
  31. package/dist/__tests__/reactiveQueries/sql.test.d.ts.map +1 -0
  32. package/dist/__tests__/reactiveQueries/sql.test.js +337 -0
  33. package/dist/__tests__/reactiveQueries/sql.test.js.map +1 -0
  34. package/dist/effect/LiveStore.d.ts +3 -9
  35. package/dist/effect/LiveStore.d.ts.map +1 -1
  36. package/dist/effect/LiveStore.js +11 -7
  37. package/dist/effect/LiveStore.js.map +1 -1
  38. package/dist/inMemoryDatabase.d.ts +17 -21
  39. package/dist/inMemoryDatabase.d.ts.map +1 -1
  40. package/dist/inMemoryDatabase.js +2 -9
  41. package/dist/inMemoryDatabase.js.map +1 -1
  42. package/dist/index.d.ts +9 -7
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +7 -3
  45. package/dist/index.js.map +1 -1
  46. package/dist/migrations.d.ts +7 -0
  47. package/dist/migrations.d.ts.map +1 -1
  48. package/dist/migrations.js +18 -13
  49. package/dist/migrations.js.map +1 -1
  50. package/dist/react/LiveStoreProvider.d.ts +1 -3
  51. package/dist/react/LiveStoreProvider.d.ts.map +1 -1
  52. package/dist/react/LiveStoreProvider.js +13 -10
  53. package/dist/react/LiveStoreProvider.js.map +1 -1
  54. package/dist/react/index.d.ts +4 -4
  55. package/dist/react/index.d.ts.map +1 -1
  56. package/dist/react/index.js +3 -3
  57. package/dist/react/index.js.map +1 -1
  58. package/dist/react/useComponentState.d.ts +50 -0
  59. package/dist/react/useComponentState.d.ts.map +1 -0
  60. package/dist/react/useComponentState.js +248 -0
  61. package/dist/react/useComponentState.js.map +1 -0
  62. package/dist/react/useGlobalQuery.d.ts +2 -2
  63. package/dist/react/useGlobalQuery.d.ts.map +1 -1
  64. package/dist/react/useGlobalQuery.js +5 -2
  65. package/dist/react/useGlobalQuery.js.map +1 -1
  66. package/dist/react/useGraphQL.d.ts +5 -3
  67. package/dist/react/useGraphQL.d.ts.map +1 -1
  68. package/dist/react/useGraphQL.js +27 -7
  69. package/dist/react/useGraphQL.js.map +1 -1
  70. package/dist/react/useLiveStoreComponent.d.ts +14 -14
  71. package/dist/react/useLiveStoreComponent.d.ts.map +1 -1
  72. package/dist/react/useLiveStoreComponent.js +151 -91
  73. package/dist/react/useLiveStoreComponent.js.map +1 -1
  74. package/dist/react/useQuery.d.ts +3 -0
  75. package/dist/react/useQuery.d.ts.map +1 -0
  76. package/dist/react/useQuery.js +42 -0
  77. package/dist/react/useQuery.js.map +1 -0
  78. package/dist/react/useTemporaryQuery.d.ts +8 -0
  79. package/dist/react/useTemporaryQuery.d.ts.map +1 -0
  80. package/dist/react/useTemporaryQuery.js +17 -0
  81. package/dist/react/useTemporaryQuery.js.map +1 -0
  82. package/dist/react/utils/extractNamesFromStackTrace.d.ts +3 -0
  83. package/dist/react/utils/extractNamesFromStackTrace.d.ts.map +1 -0
  84. package/dist/react/utils/extractNamesFromStackTrace.js +40 -0
  85. package/dist/react/utils/extractNamesFromStackTrace.js.map +1 -0
  86. package/dist/react/utils/extractStackInfoFromStackTrace.d.ts +7 -0
  87. package/dist/react/utils/extractStackInfoFromStackTrace.d.ts.map +1 -0
  88. package/dist/react/utils/extractStackInfoFromStackTrace.js +40 -0
  89. package/dist/react/utils/extractStackInfoFromStackTrace.js.map +1 -0
  90. package/dist/reactive.d.ts +42 -48
  91. package/dist/reactive.d.ts.map +1 -1
  92. package/dist/reactive.js +293 -186
  93. package/dist/reactive.js.map +1 -1
  94. package/dist/reactiveQueries/base-class.d.ts +28 -20
  95. package/dist/reactiveQueries/base-class.d.ts.map +1 -1
  96. package/dist/reactiveQueries/base-class.js +25 -17
  97. package/dist/reactiveQueries/base-class.js.map +1 -1
  98. package/dist/reactiveQueries/graph.d.ts +10 -0
  99. package/dist/reactiveQueries/graph.d.ts.map +1 -0
  100. package/dist/reactiveQueries/graph.js +6 -0
  101. package/dist/reactiveQueries/graph.js.map +1 -0
  102. package/dist/reactiveQueries/graphql.d.ts +35 -18
  103. package/dist/reactiveQueries/graphql.d.ts.map +1 -1
  104. package/dist/reactiveQueries/graphql.js +91 -10
  105. package/dist/reactiveQueries/graphql.js.map +1 -1
  106. package/dist/reactiveQueries/js.d.ts +17 -13
  107. package/dist/reactiveQueries/js.d.ts.map +1 -1
  108. package/dist/reactiveQueries/js.js +31 -8
  109. package/dist/reactiveQueries/js.js.map +1 -1
  110. package/dist/reactiveQueries/sql.d.ts +22 -18
  111. package/dist/reactiveQueries/sql.d.ts.map +1 -1
  112. package/dist/reactiveQueries/sql.js +81 -16
  113. package/dist/reactiveQueries/sql.js.map +1 -1
  114. package/dist/schema.d.ts +0 -2
  115. package/dist/schema.d.ts.map +1 -1
  116. package/dist/schema.js +3 -6
  117. package/dist/schema.js.map +1 -1
  118. package/dist/storage/in-memory/index.d.ts +2 -2
  119. package/dist/storage/in-memory/index.d.ts.map +1 -1
  120. package/dist/storage/in-memory/index.js.map +1 -1
  121. package/dist/storage/index.d.ts +2 -2
  122. package/dist/storage/index.d.ts.map +1 -1
  123. package/dist/storage/tauri/index.d.ts +2 -2
  124. package/dist/storage/tauri/index.d.ts.map +1 -1
  125. package/dist/storage/tauri/index.js.map +1 -1
  126. package/dist/storage/web-worker/index.d.ts +4 -4
  127. package/dist/storage/web-worker/index.d.ts.map +1 -1
  128. package/dist/storage/web-worker/index.js +3 -5
  129. package/dist/storage/web-worker/index.js.map +1 -1
  130. package/dist/storage/web-worker/worker.js +2 -2
  131. package/dist/storage/web-worker/worker.js.map +1 -1
  132. package/dist/store.d.ts +19 -52
  133. package/dist/store.d.ts.map +1 -1
  134. package/dist/store.js +323 -266
  135. package/dist/store.js.map +1 -1
  136. package/dist/util.d.ts +3 -1
  137. package/dist/util.d.ts.map +1 -1
  138. package/dist/util.js +2 -0
  139. package/dist/util.js.map +1 -1
  140. package/package.json +2 -1
  141. package/src/QueryCache.ts +1 -1
  142. package/src/__tests__/react/fixture.tsx +21 -16
  143. package/src/__tests__/react/{useLiveStoreComponent.test.tsx → useComponentState.test.tsx} +9 -20
  144. package/src/__tests__/react/useQuery.test.tsx +48 -0
  145. package/src/__tests__/react/utils/extractStackInfoFromStackTrace.test.ts +40 -0
  146. package/src/__tests__/reactive.test.ts +194 -142
  147. package/src/__tests__/reactiveQueries/sql.test.ts +372 -0
  148. package/src/effect/LiveStore.ts +14 -18
  149. package/src/inMemoryDatabase.ts +22 -30
  150. package/src/index.ts +8 -6
  151. package/src/migrations.ts +39 -21
  152. package/src/react/LiveStoreProvider.tsx +13 -16
  153. package/src/react/index.ts +4 -8
  154. package/src/react/{useLiveStoreComponent.ts → useComponentState.ts} +98 -230
  155. package/src/react/useQuery.ts +58 -0
  156. package/src/react/useTemporaryQuery.ts +21 -0
  157. package/src/react/utils/extractStackInfoFromStackTrace.ts +47 -0
  158. package/src/reactive.ts +386 -267
  159. package/src/reactiveQueries/base-class.ts +61 -39
  160. package/src/reactiveQueries/graph.ts +15 -0
  161. package/src/reactiveQueries/graphql.ts +147 -31
  162. package/src/reactiveQueries/js.ts +54 -21
  163. package/src/reactiveQueries/sql.ts +128 -37
  164. package/src/schema.ts +2 -5
  165. package/src/storage/in-memory/index.ts +2 -2
  166. package/src/storage/index.ts +2 -2
  167. package/src/storage/tauri/index.ts +2 -2
  168. package/src/storage/web-worker/index.ts +6 -8
  169. package/src/storage/web-worker/worker.ts +2 -2
  170. package/src/store.ts +394 -418
  171. package/src/util.ts +8 -2
  172. package/dist/backends/base.d.ts +0 -13
  173. package/dist/backends/base.d.ts.map +0 -1
  174. package/dist/backends/base.js +0 -53
  175. package/dist/backends/base.js.map +0 -1
  176. package/dist/backends/in-memory/index.d.ts +0 -22
  177. package/dist/backends/in-memory/index.d.ts.map +0 -1
  178. package/dist/backends/in-memory/index.js +0 -45
  179. package/dist/backends/in-memory/index.js.map +0 -1
  180. package/dist/backends/index.d.ts +0 -41
  181. package/dist/backends/index.d.ts.map +0 -1
  182. package/dist/backends/index.js +0 -16
  183. package/dist/backends/index.js.map +0 -1
  184. package/dist/backends/tauri/index.d.ts +0 -21
  185. package/dist/backends/tauri/index.d.ts.map +0 -1
  186. package/dist/backends/tauri/index.js +0 -48
  187. package/dist/backends/tauri/index.js.map +0 -1
  188. package/dist/backends/utils/idb.d.ts +0 -10
  189. package/dist/backends/utils/idb.d.ts.map +0 -1
  190. package/dist/backends/utils/idb.js +0 -58
  191. package/dist/backends/utils/idb.js.map +0 -1
  192. package/dist/backends/web-worker/index.d.ts +0 -26
  193. package/dist/backends/web-worker/index.d.ts.map +0 -1
  194. package/dist/backends/web-worker/index.js +0 -63
  195. package/dist/backends/web-worker/index.js.map +0 -1
  196. package/dist/backends/web-worker/worker.d.ts +0 -17
  197. package/dist/backends/web-worker/worker.d.ts.map +0 -1
  198. package/dist/backends/web-worker/worker.js +0 -139
  199. package/dist/backends/web-worker/worker.js.map +0 -1
  200. package/dist/storage/base.d.ts +0 -10
  201. package/dist/storage/base.d.ts.map +0 -1
  202. package/dist/storage/base.js +0 -14
  203. package/dist/storage/base.js.map +0 -1
  204. package/src/react/useGlobalQuery.ts +0 -37
  205. package/src/react/useGraphQL.ts +0 -112
@@ -1,24 +1,32 @@
1
- import * as otel from '@opentelemetry/api';
2
- import type { ComponentKey } from '../componentKey.js';
3
- import type { Store } from '../store.js';
1
+ import type * as otel from '@opentelemetry/api';
2
+ import type { StackInfo } from '../react/utils/extractStackInfoFromStackTrace.js';
3
+ import type { Atom, GetAtom, Thunk } from '../reactive.js';
4
+ import { type DbContext } from './graph.js';
5
+ import type { LiveStoreJSQuery } from './js.js';
4
6
  export type UnsubscribeQuery = () => void;
5
- export declare abstract class LiveStoreQueryBase {
6
- /** The key for the associated component */
7
- componentKey: ComponentKey;
8
- /** Human-readable label for the query for debugging */
7
+ export interface ILiveStoreQuery<TResult> {
8
+ id: number;
9
+ /** A reactive thunk representing the query results */
10
+ results$: Thunk<TResult, DbContext>;
9
11
  label: string;
10
- /** A pointer back to the store containing this query */
11
- store: Store<any>;
12
- /** Otel Span is started in LiveStore store but ended in this query */
13
- otelContext: otel.Context;
14
- /** The string key is used to identify a subscription from "outside" */
15
- activeSubscriptions: Map<string, UnsubscribeQuery>;
16
- constructor({ componentKey, label, store, otelContext, }: {
17
- componentKey: ComponentKey;
18
- label: string;
19
- store: Store<any>;
20
- otelContext: otel.Context;
21
- });
22
- destroy: () => void;
12
+ run: (otelContext?: otel.Context) => TResult;
13
+ destroy(): void;
14
+ activeSubscriptions: Set<SubscriberInfo>;
15
+ }
16
+ export type SubscriberInfo = {
17
+ stack: StackInfo[];
18
+ };
19
+ export declare abstract class LiveStoreQueryBase<TResult> implements ILiveStoreQuery<TResult> {
20
+ id: number;
21
+ /** Human-readable label for the query for debugging */
22
+ abstract label: string;
23
+ abstract results$: Thunk<TResult, DbContext>;
24
+ activeSubscriptions: Set<SubscriberInfo>;
25
+ get runs(): number;
26
+ abstract destroy: () => void;
27
+ run: (otelContext?: otel.Context) => TResult;
28
+ runAndDestroy: (otelContext?: otel.Context) => TResult;
23
29
  }
30
+ export type GetAtomResult = <T>(atom: Atom<T, any> | LiveStoreJSQuery<T>) => T;
31
+ export declare const makeGetAtomResult: (get: GetAtom, otelContext: otel.Context) => GetAtomResult;
24
32
  //# sourceMappingURL=base-class.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-class.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/base-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAA;AAEzC,8BAAsB,kBAAkB;IACtC,2CAA2C;IAC3C,YAAY,EAAE,YAAY,CAAA;IAC1B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;IACb,wDAAwD;IACxD,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACjB,sEAAsE;IACtE,WAAW,EAAE,I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AO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IACnF,EAAE,SAAmB;IAErB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAE5C,mBAAmB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAY;IAEpD,IAAI,IAAI,WAEP;IAED,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAQ5B,GAAG,iBAAkB,KAAK,OAAO,KAAG,OAAO,CAA4C;IAEvF,aAAa,iBAAkB,KAAK,OAAO,KAAG,OAAO,CAIpD;CACF;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;AAE9E,eAAO,MAAM,iBAAiB,QAAS,OAAO,eAAe,KAAK,OAAO,kBAOxE,CAAA"}
@@ -1,22 +1,30 @@
1
- import * as otel from '@opentelemetry/api';
1
+ let queryIdCounter = 0;
2
2
  export class LiveStoreQueryBase {
3
- constructor({ componentKey, label, store, otelContext, }) {
4
- /** The string key is used to identify a subscription from "outside" */
5
- this.activeSubscriptions = new Map();
6
- this.destroy = () => {
7
- const span = otel.trace.getSpan(this.otelContext);
8
- span.end();
9
- // NOTE usually the `unsubscribe` function is called by `useLiveStoreComponent` but this code path
10
- // is used for manual store destruction, so we need to manually unsubscribe here
11
- for (const [_key, unsubscribe] of this.activeSubscriptions) {
12
- // unsubscribe from the query
13
- unsubscribe();
14
- }
3
+ constructor() {
4
+ this.id = queryIdCounter++;
5
+ this.activeSubscriptions = new Set();
6
+ // subscribe = (
7
+ // onNewValue: (value: TResult) => void,
8
+ // onSubsubscribe?: () => void,
9
+ // options?: { label?: string } | undefined,
10
+ // ): (() => void) => this.store.subscribe(this as any, onNewValue as any, onSubsubscribe, options)
11
+ this.run = (otelContext) => this.results$.computeResult(otelContext);
12
+ this.runAndDestroy = (otelContext) => {
13
+ const result = this.run(otelContext);
14
+ this.destroy();
15
+ return result;
15
16
  };
16
- this.componentKey = componentKey;
17
- this.label = label;
18
- this.store = store;
19
- this.otelContext = otelContext;
17
+ }
18
+ get runs() {
19
+ return this.results$.recomputations;
20
20
  }
21
21
  }
22
+ export const makeGetAtomResult = (get, otelContext) => {
23
+ const getAtom = (atom) => {
24
+ if (atom._tag === 'thunk' || atom._tag === 'ref')
25
+ return get(atom, otelContext);
26
+ return get(atom.results$, otelContext);
27
+ };
28
+ return getAtom;
29
+ };
22
30
  //# sourceMappingURL=base-class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-class.js","sourceRoot":"","sources":["../../src/reactiveQueries/base-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAO1C,MAAM,OAAgB,kBAAkB;IAatC,YAAY,EACV,YAAY,EACZ,KAAK,EACL,KAAK,EACL,WAAW,GAMZ;QAbD,uEAAuE;QACvE,wBAAmB,GAAkC,IAAI,GAAG,EAAE,CAAA;QAmB9D,YAAO,GAAG,GAAG,EAAE;YACb,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAE,CAAA;YAClD,IAAI,CAAC,GAAG,EAAE,CAAA;YAEV,kGAAkG;YAClG,gFAAgF;YAChF,KAAK,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC1D,6BAA6B;gBAC7B,WAAW,EAAE,CAAA;aACd;QACH,CAAC,CAAA;QAhBC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;CAaF"}
1
+ {"version":3,"file":"base-class.js","sourceRoot":"","sources":["../../src/reactiveQueries/base-class.ts"],"names":[],"mappings":"AASA,IAAI,cAAc,GAAG,CAAC,CAAA;AAqBtB,MAAM,OAAgB,kBAAkB;IAAxC;QACE,OAAE,GAAG,cAAc,EAAE,CAAA;QAOrB,wBAAmB,GAAwB,IAAI,GAAG,EAAE,CAAA;QAQpD,gBAAgB;QAChB,0CAA0C;QAC1C,iCAAiC;QACjC,8CAA8C;QAC9C,mGAAmG;QAEnG,QAAG,GAAG,CAAC,WAA0B,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;QAEvF,kBAAa,GAAG,CAAC,WAA0B,EAAW,EAAE;YACtD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;YACpC,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;IACH,CAAC;IAnBC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAA;IACrC,CAAC;CAiBF;AAID,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAE,WAAyB,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAkB,CAAC,IAAI,EAAE,EAAE;QACtC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK;YAAE,OAAO,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAC/E,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;IACxC,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type * as otel from '@opentelemetry/api';
2
+ import { ReactiveGraph } from '../reactive.js';
3
+ import type { QueryDebugInfo, RefreshReason, Store } from '../store.js';
4
+ export type DbContext = {
5
+ store: Store;
6
+ otelTracer: otel.Tracer;
7
+ rootOtelContext: otel.Context;
8
+ };
9
+ export declare const dbGraph: ReactiveGraph<RefreshReason, QueryDebugInfo, DbContext>;
10
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,KAAK,CAAA;IACZ,UAAU,EAAE,IAAI,CAAC,MAAM,CAAA;IACvB,eAAe,EAAE,IAAI,CAAC,OAAO,CAAA;CAC9B,CAAA;AAED,eAAO,MAAM,OAAO,yDAElB,CAAA"}
@@ -0,0 +1,6 @@
1
+ import ReactDOM from 'react-dom';
2
+ import { ReactiveGraph } from '../reactive.js';
3
+ export const dbGraph = new ReactiveGraph({
4
+ effectsWrapper: (run) => ReactDOM.unstable_batchedUpdates(() => run()),
5
+ });
6
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/reactiveQueries/graph.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAS9C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,aAAa,CAA2C;IACjF,cAAc,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC;CACvE,CAAC,CAAA"}
@@ -1,25 +1,42 @@
1
1
  import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
- import type * as otel from '@opentelemetry/api';
3
- import type { ComponentKey } from '../componentKey.js';
4
- import type { GetAtom, Thunk } from '../reactive.js';
5
- import type { BaseGraphQLContext, Store } from '../store.js';
6
- import { LiveStoreQueryBase } from './base-class.js';
7
- import type { LiveStoreJSQuery } from './js.js';
8
- export declare class LiveStoreGraphQLQuery<TResult extends Record<string, any>, VariableValues extends Record<string, any>, TContext extends BaseGraphQLContext> extends LiveStoreQueryBase {
2
+ import * as otel from '@opentelemetry/api';
3
+ import * as graphql from 'graphql';
4
+ import type { Thunk } from '../reactive.js';
5
+ import { type BaseGraphQLContext, type Store } from '../store.js';
6
+ import { type GetAtomResult, LiveStoreQueryBase } from './base-class.js';
7
+ import { type DbContext } from './graph.js';
8
+ import { LiveStoreJSQuery } from './js.js';
9
+ export declare const queryGraphQL: <TResult extends Record<string, any>, TVariableValues extends Record<string, any>>(document: DocumentNode<TResult, TVariableValues>, genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues), { label }?: {
10
+ label?: string | undefined;
11
+ }) => LiveStoreGraphQLQuery<TResult, TVariableValues, BaseGraphQLContext>;
12
+ export declare class LiveStoreGraphQLQuery<TResult extends Record<string, any>, TVariableValues extends Record<string, any>, TContext extends BaseGraphQLContext> extends LiveStoreQueryBase<TResult> {
9
13
  _tag: 'graphql';
10
14
  /** The abstract GraphQL query */
11
- document: DocumentNode<TResult, VariableValues>;
15
+ document: DocumentNode<TResult, TVariableValues>;
12
16
  /** A reactive thunk representing the query results */
13
- results$: Thunk<TResult>;
14
- constructor({ document, results$, ...baseProps }: {
15
- document: DocumentNode<TResult, VariableValues>;
16
- context: TContext;
17
- results$: Thunk<TResult>;
18
- componentKey: ComponentKey;
19
- label: string;
20
- store: Store<TContext>;
21
- otelContext: otel.Context;
17
+ results$: Thunk<TResult, DbContext>;
18
+ variableValues$: Thunk<TVariableValues, DbContext>;
19
+ label: string;
20
+ constructor({ document, label, genVariableValues, }: {
21
+ document: DocumentNode<TResult, TVariableValues>;
22
+ genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues);
23
+ label?: string;
22
24
  });
23
- pipe: <U>(f: (x: TResult, get: GetAtom) => U) => LiveStoreJSQuery<U>;
25
+ /**
26
+ * Returns a new reactive query that contains the result of
27
+ * running an arbitrary JS computation on the results of this SQL query.
28
+ */
29
+ pipe: <U>(fn: (result: TResult, get: GetAtomResult) => U) => LiveStoreJSQuery<U>;
30
+ queryOnce: ({ document, otelContext, otelTracer, variableValues, store, }: {
31
+ document: graphql.DocumentNode;
32
+ otelContext: otel.Context;
33
+ otelTracer: otel.Tracer;
34
+ variableValues: TVariableValues;
35
+ store: Store<TContext>;
36
+ }) => {
37
+ result: TResult;
38
+ queriedTables: string[];
39
+ };
40
+ destroy: () => void;
24
41
  }
25
42
  //# sourceMappingURL=graphql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAC1F,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,qBAAa,qBAAqB,CAChC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnC,cAAc,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1C,QAAQ,SAAS,kBAAkB,CACnC,SAAQ,kBAAkB;IAC1B,I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AAC,MAAM,EAAE,GAAG,CAAC,EACnC,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3C,QAAQ,SAAS,kBAAkB,CACnC,SAAQ,kBAAkB,CAAC,OAAO,CAAC;IACnC,IAAI,EAAE,SAAS,CAAY;IAE3B,iCAAiC;IACjC,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;IAEhD,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAEnC,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;IAElD,KAAK,EAAE,MAAM,CAAA;gBAED,EACV,QAAQ,EACR,KAAK,EACL,iBAAiB,GAClB,EAAE;QACD,QAAQ,EAAE,YAAY,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;QAChD,iBAAiB,EAAE,eAAe,GAAG,CAAC,CAAC,GAAG,EAAE,aAAa,KAAK,eAAe,CAAC,CAAA;QAC9E,KAAK,CAAC,EAAE,MAAM,CAAA;KACf;IAuDD;;;OAGG;IACH,IAAI,mBAAoB,OAAO,OAAO,aAAa,+BAQ/C;IAEJ,SAAS;kBAOG,oBAAoB;qBACjB,KAAK,OAAO;oBACb,KAAK,MAAM;wBACP,eAAe;eACxB,MAAM,QAAQ,CAAC;;;;MAyCvB;IAED,OAAO,aAGN;CACF"}
@@ -1,18 +1,99 @@
1
- import { LiveStoreQueryBase } from './base-class.js';
1
+ import { assertNever, shouldNeverHappen } from '@livestore/utils';
2
+ import * as otel from '@opentelemetry/api';
3
+ import * as graphql from 'graphql';
4
+ import { LiveStoreQueryBase, makeGetAtomResult } from './base-class.js';
5
+ import { dbGraph } from './graph.js';
6
+ import { LiveStoreJSQuery } from './js.js';
7
+ export const queryGraphQL = (document, genVariableValues, { label } = {}) => new LiveStoreGraphQLQuery({ document, genVariableValues, label });
2
8
  export class LiveStoreGraphQLQuery extends LiveStoreQueryBase {
3
- constructor({ document, results$, ...baseProps }) {
4
- super(baseProps);
9
+ constructor({ document, label, genVariableValues, // context,
10
+ }) {
11
+ super();
5
12
  this._tag = 'graphql';
6
- this.pipe = (f) => this.store.queryJS((get) => {
7
- const results = get(this.results$);
8
- return f(results, get);
9
- }, {
10
- componentKey: this.componentKey,
13
+ /**
14
+ * Returns a new reactive query that contains the result of
15
+ * running an arbitrary JS computation on the results of this SQL query.
16
+ */
17
+ this.pipe = (fn) => new LiveStoreJSQuery({
18
+ fn: (get) => {
19
+ const results = get(this.results$);
20
+ return fn(results, get);
21
+ },
11
22
  label: `${this.label}:js`,
12
- otelContext: this.otelContext,
23
+ onDestroy: () => this.destroy(),
13
24
  });
25
+ this.queryOnce = ({ document, otelContext, otelTracer, variableValues, store, }) => {
26
+ // const schema = this.schema
27
+ // const context = this.context
28
+ const schema = store.graphQLSchema ?? shouldNeverHappen("Can't run a GraphQL query on a store without GraphQL schema");
29
+ const context = store.graphQLContext ?? shouldNeverHappen("Can't run a GraphQL query on a store without GraphQL context");
30
+ const operationName = graphql.getOperationAST(document)?.name?.value;
31
+ return otelTracer.startActiveSpan(`executeGraphQLQuery: ${operationName}`, {}, otelContext, (span) => {
32
+ try {
33
+ span.setAttribute('graphql.variables', JSON.stringify(variableValues));
34
+ span.setAttribute('graphql.query', graphql.print(document));
35
+ context.queriedTables.clear();
36
+ context.otelContext = otel.trace.setSpan(otel.context.active(), span);
37
+ const res = graphql.executeSync({
38
+ document,
39
+ contextValue: context,
40
+ schema: schema,
41
+ variableValues,
42
+ });
43
+ // TODO track number of nested SQL queries via Otel + debug info
44
+ if (res.errors) {
45
+ span.setStatus({ code: otel.SpanStatusCode.ERROR, message: 'GraphQL error' });
46
+ span.setAttribute('graphql.error', res.errors.join('\n'));
47
+ span.setAttribute('graphql.error-detail', JSON.stringify(res.errors));
48
+ console.error(`graphql error (${operationName})`, res.errors);
49
+ }
50
+ return { result: res.data, queriedTables: Array.from(context.queriedTables.values()) };
51
+ }
52
+ finally {
53
+ span.end();
54
+ }
55
+ });
56
+ };
57
+ this.destroy = () => {
58
+ dbGraph.destroy(this.variableValues$);
59
+ dbGraph.destroy(this.results$);
60
+ };
61
+ const labelWithDefault = label ?? graphql.getOperationAST(document)?.name?.value ?? 'graphql';
62
+ this.label = labelWithDefault;
14
63
  this.document = document;
15
- this.results$ = results$;
64
+ // if (context === undefined) {
65
+ // return shouldNeverHappen("Can't run a GraphQL query on a store without GraphQL context")
66
+ // }
67
+ // TODO don't even create a thunk if variables are static
68
+ const variableValues$ = dbGraph.makeThunk((get, _addDebugInfo, { rootOtelContext }, otelContext) => {
69
+ if (typeof genVariableValues === 'function') {
70
+ return genVariableValues(makeGetAtomResult(get, otelContext ?? rootOtelContext));
71
+ }
72
+ else {
73
+ return genVariableValues;
74
+ }
75
+ }, { label: `${labelWithDefault}:variableValues`, meta: { liveStoreThunkType: 'graphqlVariableValues' } });
76
+ this.variableValues$ = variableValues$;
77
+ // const resultsLabel = `${labelWithDefault}:results` + (this.temporaryQueries ? ':temp' : '')
78
+ const resultsLabel = `${labelWithDefault}:results`;
79
+ this.results$ = dbGraph.makeThunk((get, addDebugInfo, { store, otelTracer, rootOtelContext }, otelContext) => {
80
+ const variableValues = get(variableValues$);
81
+ const { result, queriedTables } = this.queryOnce({
82
+ document,
83
+ variableValues,
84
+ otelContext: otelContext ?? rootOtelContext,
85
+ otelTracer,
86
+ store: store,
87
+ });
88
+ // Add dependencies on any tables that were used
89
+ for (const tableName of queriedTables) {
90
+ const tableRef = store.tableRefs[tableName];
91
+ assertNever(tableRef !== undefined, `No table ref found for ${tableName}`);
92
+ get(tableRef);
93
+ }
94
+ addDebugInfo({ _tag: 'graphql', label: resultsLabel, query: graphql.print(document) });
95
+ return result;
96
+ }, { label: resultsLabel, meta: { liveStoreThunkType: 'graphqlResults' } });
16
97
  }
17
98
  }
18
99
  //# sourceMappingURL=graphql.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/reactiveQ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,EAAE,WAAW,IAAI,eAAe;gBAC3C,UAAU;gBACV,KAAK,EAAE,KAAwB;aAChC,CAAC,CAAA;YAEF,gDAAgD;YAChD,KAAK,MAAM,SAAS,IAAI,aAAa,EAAE;gBACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;gBAC3C,WAAW,CAAC,QAAQ,KAAK,SAAS,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAA;gBAC1E,GAAG,CAAC,QAAS,CAAC,CAAA;aACf;YAED,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YAEtF,OAAO,MAAM,CAAA;QACf,CAAC,EACD,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,EAAE,CAExE,CAAA;IACH,CAAC;CA0EF"}
@@ -1,19 +1,23 @@
1
- import type * as otel from '@opentelemetry/api';
2
- import type { ComponentKey } from '../componentKey.js';
3
- import type { GetAtom, Thunk } from '../reactive.js';
4
- import type { Store } from '../store.js';
5
- import { LiveStoreQueryBase } from './base-class.js';
6
- export declare class LiveStoreJSQuery<TResult> extends LiveStoreQueryBase {
1
+ import type { Thunk } from '../reactive.js';
2
+ import { type GetAtomResult, LiveStoreQueryBase } from './base-class.js';
3
+ import type { DbContext } from './graph.js';
4
+ export declare const queryJS: <TResult>(fn: (get: GetAtomResult) => TResult, options: {
5
+ label: string;
6
+ }) => LiveStoreJSQuery<TResult>;
7
+ export declare class LiveStoreJSQuery<TResult> extends LiveStoreQueryBase<TResult> {
7
8
  _tag: 'js';
8
9
  /** A reactive thunk representing the query results */
9
- results$: Thunk<TResult>;
10
- constructor({ results$, ...baseProps }: {
11
- results$: Thunk<TResult>;
12
- componentKey: ComponentKey;
10
+ results$: Thunk<TResult, DbContext>;
11
+ label: string;
12
+ /** Currently only used for "nested destruction" of piped queries */
13
+ private onDestroy;
14
+ constructor({ fn, label, onDestroy, }: {
13
15
  label: string;
14
- store: Store<any>;
15
- otelContext: otel.Context;
16
+ fn: (get: GetAtomResult) => TResult;
17
+ /** Currently only used for "nested destruction" of piped queries */
18
+ onDestroy?: () => void;
16
19
  });
17
- pipe: <U>(f: (x: TResult, get: GetAtom) => U) => LiveStoreJSQuery<U>;
20
+ pipe: <U>(fn: (result: TResult, get: GetAtomResult) => U) => LiveStoreJSQuery<U>;
21
+ destroy: () => void;
18
22
  }
19
23
  //# sourceMappingURL=js.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/js.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,qBAAa,gBAAgB,CAAC,OAAO,CAAE,SAAQ,kBAAkB;IAC/D,IAAI,EAAE,IAAI,CAAO;IACjB,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;gBAEZ,EACV,QAAQ,EACR,GAAG,SAAS,EACb,EAAE;QACD,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;QACxB,YAAY,EAAE,YAAY,CAAA;QAC1B,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACjB,WAAW,EAAE,IAAI,CAAC,OAAO,CAAA;KAC1B;IAMD,IAAI,aAAc,OAAO,OAAO,OAAO,+BAOpC;CACJ"}
1
+ {"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/js.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,aAAa,EAAE,kBAAkB,EAAqB,MAAM,iBAAiB,CAAA;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAG3C,eAAO,MAAM,OAAO,sBAAuB,aAAa,uBAAuB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,8BACnC,CAAA;AAE7D,qBAAa,gBAAgB,CAAC,OAAO,CAAE,SAAQ,kBAAkB,CAAC,OAAO,CAAC;IACxE,IAAI,EAAE,IAAI,CAAO;IAEjB,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAEnC,KAAK,EAAE,MAAM,CAAA;IAEb,oEAAoE;IACpE,OAAO,CAAC,SAAS,CAA0B;gBAE/B,EACV,EAAE,EACF,KAAK,EACL,SAAS,GACV,EAAE;QACD,KAAK,EAAE,MAAM,CAAA;QACb,EAAE,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,OAAO,CAAA;QACnC,oEAAoE;QACpE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;KACvB;IAwBD,IAAI,mBAAoB,OAAO,OAAO,aAAa,+BAQ/C;IAEJ,OAAO,aAGN;CACF"}
@@ -1,13 +1,36 @@
1
- import { LiveStoreQueryBase } from './base-class.js';
1
+ import * as otel from '@opentelemetry/api';
2
+ import { LiveStoreQueryBase, makeGetAtomResult } from './base-class.js';
3
+ import { dbGraph } from './graph.js';
4
+ export const queryJS = (fn, options) => new LiveStoreJSQuery({ fn, label: options.label });
2
5
  export class LiveStoreJSQuery extends LiveStoreQueryBase {
3
- constructor({ results$, ...baseProps }) {
4
- super(baseProps);
6
+ constructor({ fn, label, onDestroy, }) {
7
+ super();
5
8
  this._tag = 'js';
6
- this.pipe = (f) => this.store.queryJS((get) => {
7
- const results = get(this.results$);
8
- return f(results, get);
9
- }, { componentKey: this.componentKey, label: `${this.label}:js`, otelContext: this.otelContext });
10
- this.results$ = results$;
9
+ this.pipe = (fn) => new LiveStoreJSQuery({
10
+ fn: (get) => {
11
+ const results = get(this.results$);
12
+ return fn(results, get);
13
+ },
14
+ label: `${this.label}:js`,
15
+ onDestroy: () => this.destroy(),
16
+ });
17
+ this.destroy = () => {
18
+ dbGraph.destroy(this.results$);
19
+ this.onDestroy?.();
20
+ };
21
+ this.onDestroy = onDestroy;
22
+ this.label = label;
23
+ const queryLabel = `${label}:results`;
24
+ this.results$ = dbGraph.makeThunk((get, addDebugInfo, { otelTracer, rootOtelContext }, otelContext) => otelTracer.startActiveSpan(`js:${label}`, {}, otelContext ?? rootOtelContext, (span) => {
25
+ try {
26
+ addDebugInfo({ _tag: 'js', label, query: fn.toString() });
27
+ const otelContext = otel.trace.setSpan(otel.context.active(), span);
28
+ return fn(makeGetAtomResult(get, otelContext));
29
+ }
30
+ finally {
31
+ span.end();
32
+ }
33
+ }), { label: queryLabel, meta: { liveStoreThunkType: 'jsResults' } });
11
34
  }
12
35
  }
13
36
  //# sourceMappingURL=js.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"js.js","sourceRoot":"","sources":["../../src/reactiveQueries/js.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,OAAO,gBAA0B,SAAQ,kBAAkB;IAK/D,YAAY,EACV,QAAQ,EACR,GAAG,SAAS,EAOb;QACC,KAAK,CAAC,SAAS,CAAC,CAAA;QAdlB,SAAI,GAAS,IAAI,CAAA;QAmBjB,SAAI,GAAG,CAAI,CAAkC,EAAuB,EAAE,CACpE,IAAI,CAAC,KAAK,CAAC,OAAO,CAChB,CAAC,GAAG,EAAE,EAAE;YACN,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAClC,OAAO,CAAC,C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,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC9B,IAAI,CAAC,SAAS,EAAE,EAAE,CAAA;QACpB,CAAC,CAAA;QAlCC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAElB,MAAM,UAAU,GAAG,GAAG,KAAK,UAAU,CAAA;QAErC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,SAAS,CAC/B,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,WAAW,EAAE,EAAE,CAClE,UAAU,CAAC,eAAe,CAAC,MAAM,KAAK,EAAE,EAAE,EAAE,EAAE,WAAW,IAAI,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;YACrF,IAAI;gBACF,YAAY,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;gBAEzD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,CAAA;gBACnE,OAAO,EAAE,CAAC,iBAAiB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;aAC/C;oBAAS;gBACR,IAAI,CAAC,GAAG,EAAE,CAAA;aACX;QACH,CAAC,CAAC,EACJ,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,kBAAkB,EAAE,WAAW,EAAE,EAAE,CACjE,CAAA;IACH,CAAC;CAgBF"}
@@ -1,31 +1,35 @@
1
- import type * as otel from '@opentelemetry/api';
2
- import type { ComponentKey } from '../componentKey.js';
3
- import type { GetAtom, Thunk } from '../reactive.js';
4
- import type { Store } from '../store.js';
5
- import { LiveStoreQueryBase } from './base-class.js';
6
- import type { LiveStoreJSQuery } from './js.js';
7
- export declare class LiveStoreSQLQuery<Row> extends LiveStoreQueryBase {
1
+ import type { Thunk } from '../reactive.js';
2
+ import type { Bindable } from '../util.js';
3
+ import { type GetAtomResult, LiveStoreQueryBase } from './base-class.js';
4
+ import type { DbContext } from './graph.js';
5
+ import { LiveStoreJSQuery } from './js.js';
6
+ export declare const querySQL: <Row>(query: string | ((get: GetAtomResult) => string), options: {
7
+ queriedTables: ReadonlyArray<string>;
8
+ bindValues?: Bindable;
9
+ label?: string;
10
+ }) => LiveStoreSQLQuery<Row>;
11
+ export declare class LiveStoreSQLQuery<Row> extends LiveStoreQueryBase<ReadonlyArray<Row>> {
8
12
  _tag: 'sql';
9
13
  /** A reactive thunk representing the query text */
10
- queryString$: Thunk<string>;
14
+ queryString$: Thunk<string, DbContext>;
11
15
  /** A reactive thunk representing the query results */
12
- results$: Thunk<Row[]>;
13
- constructor({ queryString$, results$, ...baseProps }: {
14
- queryString$: Thunk<string>;
15
- results$: Thunk<Row[]>;
16
- componentKey: ComponentKey;
17
- label: string;
18
- store: Store<any>;
19
- otelContext: otel.Context;
16
+ results$: Thunk<ReadonlyArray<Row>, DbContext>;
17
+ label: string;
18
+ constructor({ genQueryString, queriedTables, bindValues, label, }: {
19
+ label?: string;
20
+ genQueryString: string | ((get: GetAtomResult) => string);
21
+ queriedTables: ReadonlyArray<string>;
22
+ bindValues?: Bindable;
20
23
  });
21
24
  /**
22
25
  * Returns a new reactive query that contains the result of
23
26
  * running an arbitrary JS computation on the results of this SQL query.
24
27
  */
25
- pipe: <U>(f: (result: Row[], get: GetAtom) => U) => LiveStoreJSQuery<U>;
28
+ pipe: <U>(fn: (result: ReadonlyArray<Row>, get: GetAtomResult) => U) => LiveStoreJSQuery<U>;
26
29
  /** Returns a reactive query */
27
30
  getFirstRow: (args?: {
28
31
  defaultValue?: Row;
29
- }) => LiveStoreJSQuery<Row>;
32
+ }) => LiveStoreJSQuery<NonNullable<Row>>;
33
+ destroy: () => void;
30
34
  }
31
35
  //# sourceMappingURL=sql.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/C,qBAAa,iBAAiB,CAAC,GAAG,CAAE,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,KAAK,CAAQ;IACnB,mDAAmD;IACnD,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3B,sDAAsD;IACtD,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAA;gBAEV,EACV,YAAY,EACZ,QAAQ,EACR,GAAG,SAAS,EACb,EAAE;QACD,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QAC3B,QAAQ,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAA;QACtB,YAAY,EAAE,YAAY,CAAA;QAC1B,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QACjB,WAAW,EAAE,IAAI,CAAC,OAAO,CAAA;KAC1B;IAOD;;;OAGG;IACH,IAAI,kBAAmB,GAAG,EAAE,OAAO,OAAO,+BAWvC;IAEH,gCAAgC;IAChC,WAAW,UAAW;QAAE,YAAY,CAAC,EAAE,GAAG,CAAA;KAAE,2BAWzC;CACJ"}
1
+ {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/reactiveQueries/sql.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE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