ngx-signal-query 1.8.0-dev.2 → 1.8.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -220,9 +220,10 @@ type QueryResult<TData, TError = Error> = {
220
220
  /**
221
221
  * When the data was last updated, as a timestamp in ms: when the last
222
222
  * response landed or `setQueryData` wrote it; for `initialData`, its
223
- * `initialDataUpdatedAt`, or when it was seeded. A refetch that brings the
224
- * same data moves it too; one that fails or is cancelled doesn't. `0` while
225
- * there is no data, placeholder data included.
223
+ * `initialDataUpdatedAt`, or when it was seeded; for data a server render
224
+ * brought over (see {@link withHydration}), when the server fetched it. A
225
+ * refetch that brings the same data moves it too; one that fails or is
226
+ * cancelled doesn't. `0` while there is no data, placeholder data included.
226
227
  */
227
228
  dataUpdatedAt: Signal<number>;
228
229
  /** Current {@link QueryStatus}. */
@@ -386,7 +387,7 @@ declare class Query<TData, TError = Error> {
386
387
  declare class QueryCache extends Cache<Query<unknown, unknown>> {
387
388
  #private;
388
389
  constructor();
389
- getOrCreate<TData, TError = Error>(key: QueryKey, gcTime: number): Query<TData, TError>;
390
+ getOrCreate<TData, TError = Error>(key: QueryKey, gcTime: number, queryHash?: string): Query<TData, TError>;
390
391
  get<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined;
391
392
  /**
392
393
  * Like get(), but reactive, as findAll() is: a computed or an effect that
@@ -762,7 +763,8 @@ declare class QueryClient {
762
763
  * @internal
763
764
  */
764
765
  declare enum QueryClientFeatureKind {
765
- DefaultOptions = 0
766
+ DefaultOptions = 0,
767
+ Hydration = 1
766
768
  }
767
769
  /**
768
770
  * An opaque feature passed to {@link provideQueryClient}. Create one with a
@@ -781,11 +783,12 @@ interface QueryClientFeature<K extends QueryClientFeatureKind = QueryClientFeatu
781
783
  * `bootstrapApplication`). A client provided by another environment injector
782
784
  * goes with it: once that injector is destroyed, its queries stop, and none
783
785
  * of their fetches keeps the app busy. Pass features such as
784
- * {@link withDefaultOptions} to configure defaults. Registering the same
785
- * feature twice throws.
786
+ * {@link withDefaultOptions} to configure defaults, or {@link withHydration}
787
+ * to bring the data of a server render over to the browser. Registering the
788
+ * same feature twice throws.
786
789
  *
787
790
  * @param features - Optional {@link QueryClientFeature}s (e.g.
788
- * {@link withDefaultOptions}).
791
+ * {@link withDefaultOptions}, {@link withHydration}).
789
792
  * @returns Environment providers to add to the app's provider list.
790
793
  *
791
794
  * @example
@@ -1139,5 +1142,42 @@ declare class CancelledError extends Error {
1139
1142
  */
1140
1143
  declare function withDefaultOptions(options: DefaultOptions): QueryClientFeature<QueryClientFeatureKind.DefaultOptions>;
1141
1144
 
1142
- export { CancelledError, QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQueries, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions };
1145
+ /**
1146
+ * Feature for {@link provideQueryClient} that brings the data a server render
1147
+ * fetched over to the browser, so the page shows it at once rather than a
1148
+ * loading state. Add it to the providers the server and the browser share. It
1149
+ * works with Angular's `provideClientHydration()` or without it.
1150
+ *
1151
+ * Only queries that succeeded go over, and only data JSON carries as is:
1152
+ * strings, numbers, booleans, `null`, plain objects and arrays. A query whose
1153
+ * data holds a `Date`, a `Map` or a class instance stays on the server, and
1154
+ * the browser fetches it again; in development the server logs a warning
1155
+ * naming it.
1156
+ *
1157
+ * In the browser the data counts as fetched when the server fetched it, and
1158
+ * `staleTime` decides as for any data in the cache: with the default of `0`,
1159
+ * a component refetches its query in the background as it appears, showing
1160
+ * the server's data meanwhile. Set a `staleTime` to skip that request.
1161
+ *
1162
+ * Give it to one client per app: clients provided by other environment
1163
+ * injectors would share one place in the page, and only one of them would get
1164
+ * its data over.
1165
+ *
1166
+ * @returns A {@link QueryClientFeature} to pass to {@link provideQueryClient}.
1167
+ *
1168
+ * @example
1169
+ * ```ts
1170
+ * export const appConfig: ApplicationConfig = {
1171
+ * providers: [
1172
+ * provideQueryClient(
1173
+ * withDefaultOptions({ queries: { staleTime: 30_000 } }),
1174
+ * withHydration(),
1175
+ * ),
1176
+ * ],
1177
+ * }
1178
+ * ```
1179
+ */
1180
+ declare function withHydration(): QueryClientFeature<QueryClientFeatureKind.Hydration>;
1181
+
1182
+ export { CancelledError, QueryClient, QueryClientFeatureKind, injectIsFetching, injectIsMutating, injectMutation, injectQueries, injectQuery, injectQueryClient, keepPreviousData, mutationOptions, provideQueryClient, queryOptions, withDefaultOptions, withHydration };
1143
1183
  export type { DefaultMutationOptions, DefaultOptions, DefaultQueryOptions, DefaultedQueryOptions, InjectQueriesOptions, InvalidateQueryFilters, MutationFilters, MutationOptions, MutationResult, MutationState, MutationStatus, PlaceholderDataFunction, QueryClientFeature, QueryFilters, QueryKey, QueryOptions, QueryResult, QueryState, QueryStatus, RefetchIntervalValue, RetryDelayValue, RetryValue, StructuralSharingValue, Updater };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-signal-query",
3
- "version": "1.8.0-dev.2",
3
+ "version": "1.8.0-dev.3",
4
4
  "description": "Data fetching, caching and mutations for Angular, built on signals and RxJS. Observables end to end, TanStack Query concepts.",
5
5
  "keywords": [
6
6
  "angular",