houdini 1.2.2 → 1.2.4

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 (64) hide show
  1. package/build/cmd-cjs/index.js +183 -63
  2. package/build/cmd-esm/index.js +183 -63
  3. package/build/codegen-cjs/index.js +181 -61
  4. package/build/codegen-esm/index.js +181 -61
  5. package/build/lib/fs.d.ts +8 -1
  6. package/build/lib/index.d.ts +1 -0
  7. package/build/lib/parse.d.ts +1 -1
  8. package/build/lib/types.d.ts +11 -0
  9. package/build/lib-cjs/index.js +181 -69
  10. package/build/lib-esm/index.js +179 -69
  11. package/build/runtime/cache/cache.d.ts +5 -1
  12. package/build/runtime/cache/lists.d.ts +3 -3
  13. package/build/runtime/cache/storage.d.ts +8 -2
  14. package/build/runtime/cache/subscription.d.ts +1 -0
  15. package/build/runtime/client/documentStore.d.ts +9 -2
  16. package/build/runtime/client/index.d.ts +6 -3
  17. package/build/runtime/lib/index.d.ts +1 -0
  18. package/build/runtime/lib/lru.d.ts +52 -0
  19. package/build/runtime/lib/types.d.ts +1 -0
  20. package/build/runtime-cjs/cache/cache.d.ts +5 -1
  21. package/build/runtime-cjs/cache/cache.js +84 -27
  22. package/build/runtime-cjs/cache/lists.d.ts +3 -3
  23. package/build/runtime-cjs/cache/lists.js +20 -8
  24. package/build/runtime-cjs/cache/storage.d.ts +8 -2
  25. package/build/runtime-cjs/cache/storage.js +22 -5
  26. package/build/runtime-cjs/cache/subscription.d.ts +1 -0
  27. package/build/runtime-cjs/cache/subscription.js +3 -0
  28. package/build/runtime-cjs/client/documentStore.d.ts +9 -2
  29. package/build/runtime-cjs/client/documentStore.js +13 -9
  30. package/build/runtime-cjs/client/index.d.ts +6 -3
  31. package/build/runtime-cjs/client/index.js +6 -8
  32. package/build/runtime-cjs/client/plugins/cache.js +3 -0
  33. package/build/runtime-cjs/client/plugins/mutation.js +10 -6
  34. package/build/runtime-cjs/lib/index.d.ts +1 -0
  35. package/build/runtime-cjs/lib/index.js +1 -0
  36. package/build/runtime-cjs/lib/lru.d.ts +52 -0
  37. package/build/runtime-cjs/lib/lru.js +73 -0
  38. package/build/runtime-cjs/lib/types.d.ts +1 -0
  39. package/build/runtime-cjs/lib/types.js +7 -2
  40. package/build/runtime-esm/cache/cache.d.ts +5 -1
  41. package/build/runtime-esm/cache/cache.js +84 -27
  42. package/build/runtime-esm/cache/lists.d.ts +3 -3
  43. package/build/runtime-esm/cache/lists.js +20 -8
  44. package/build/runtime-esm/cache/storage.d.ts +8 -2
  45. package/build/runtime-esm/cache/storage.js +22 -5
  46. package/build/runtime-esm/cache/subscription.d.ts +1 -0
  47. package/build/runtime-esm/cache/subscription.js +3 -0
  48. package/build/runtime-esm/client/documentStore.d.ts +9 -2
  49. package/build/runtime-esm/client/documentStore.js +13 -9
  50. package/build/runtime-esm/client/index.d.ts +6 -3
  51. package/build/runtime-esm/client/index.js +6 -8
  52. package/build/runtime-esm/client/plugins/cache.js +3 -0
  53. package/build/runtime-esm/client/plugins/mutation.js +10 -6
  54. package/build/runtime-esm/lib/index.d.ts +1 -0
  55. package/build/runtime-esm/lib/index.js +1 -0
  56. package/build/runtime-esm/lib/lru.d.ts +52 -0
  57. package/build/runtime-esm/lib/lru.js +48 -0
  58. package/build/runtime-esm/lib/types.d.ts +1 -0
  59. package/build/runtime-esm/lib/types.js +5 -1
  60. package/build/test-cjs/index.js +181 -61
  61. package/build/test-esm/index.js +181 -61
  62. package/build/vite-cjs/index.js +200 -62
  63. package/build/vite-esm/index.js +200 -62
  64. package/package.json +1 -1
@@ -61830,6 +61830,9 @@ var DataSource = {
61830
61830
  };
61831
61831
  var fragmentKey = " $fragments";
61832
61832
  var PendingValue = Symbol("houdini_loading");
61833
+ function isPending(value) {
61834
+ return typeof value === "symbol";
61835
+ }
61833
61836
 
61834
61837
  // src/runtime/lib/store.ts
61835
61838
  var subscriber_queue = [];
@@ -61948,6 +61951,7 @@ __export(fs_exports, {
61948
61951
  recursiveCopy: () => recursiveCopy,
61949
61952
  remove: () => remove,
61950
61953
  rmdir: () => rmdir,
61954
+ snapshot: () => snapshot,
61951
61955
  stat: () => stat,
61952
61956
  writeFile: () => writeFile
61953
61957
  });
@@ -62142,16 +62146,17 @@ function existsSync(dirPath) {
62142
62146
  }
62143
62147
  return import_memfs.fs.existsSync(dirPath);
62144
62148
  }
62145
- async function readdir(filepath) {
62149
+ async function readdir(filepath, opts) {
62146
62150
  if (!houdini_mode.is_testing) {
62147
- return await fs.readdir(filepath);
62151
+ return await fs.readdir(filepath, opts);
62148
62152
  }
62149
62153
  if (filepath.includes("build/runtime")) {
62150
- return await fs.readdir(filepath);
62154
+ return await fs.readdir(filepath, opts);
62151
62155
  }
62152
62156
  try {
62153
- return import_memfs.fs.readdirSync(filepath);
62154
- } catch {
62157
+ return import_memfs.fs.readdirSync(filepath, opts);
62158
+ } catch (e2) {
62159
+ console.log(e2);
62155
62160
  return [];
62156
62161
  }
62157
62162
  }
@@ -62202,6 +62207,11 @@ async function recursiveCopy(source, target, transforms, notRoot) {
62202
62207
  );
62203
62208
  }
62204
62209
  }
62210
+ function snapshot(base) {
62211
+ return Object.fromEntries(
62212
+ Object.entries(import_memfs.vol.toJSON()).filter(([key]) => !base || key.startsWith(base)).map(([key, value]) => [!base ? key : key.substring(base.length), value])
62213
+ );
62214
+ }
62205
62215
  async function glob(pattern) {
62206
62216
  return await promisify(import_glob.glob)(posixify(pattern));
62207
62217
  }
@@ -63741,10 +63751,10 @@ var ListManager = class {
63741
63751
  this.lists.get(list.name).get(parentID).lists.push(handler);
63742
63752
  this.listsByField.get(parentID).get(list.key).push(handler);
63743
63753
  }
63744
- removeIDFromAllLists(id) {
63754
+ removeIDFromAllLists(id, layer) {
63745
63755
  for (const fieldMap of this.lists.values()) {
63746
63756
  for (const list of fieldMap.values()) {
63747
- list.removeID(id);
63757
+ list.removeID(id, void 0, layer);
63748
63758
  }
63749
63759
  }
63750
63760
  }
@@ -63841,6 +63851,10 @@ var List = class {
63841
63851
  updates: ["append", "prepend"],
63842
63852
  selection: {
63843
63853
  fields: {
63854
+ __typename: {
63855
+ keyRaw: "__typename",
63856
+ type: "String"
63857
+ },
63844
63858
  node: {
63845
63859
  type: listType,
63846
63860
  keyRaw: "node",
@@ -63865,7 +63879,15 @@ var List = class {
63865
63879
  };
63866
63880
  insertData = {
63867
63881
  newEntry: {
63868
- edges: [{ node: { ...data, __typename: listType } }]
63882
+ edges: [
63883
+ {
63884
+ __typename: listType + "Edge",
63885
+ node: {
63886
+ ...data,
63887
+ __typename: listType
63888
+ }
63889
+ }
63890
+ ]
63869
63891
  }
63870
63892
  };
63871
63893
  } else {
@@ -63901,7 +63923,7 @@ var List = class {
63901
63923
  layer: layer?.id
63902
63924
  });
63903
63925
  }
63904
- removeID(id, variables = {}) {
63926
+ removeID(id, variables = {}, layer) {
63905
63927
  if (!this.validateWhen()) {
63906
63928
  return;
63907
63929
  }
@@ -63948,7 +63970,7 @@ var List = class {
63948
63970
  subscribers.map((sub) => sub[0]),
63949
63971
  variables
63950
63972
  );
63951
- this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
63973
+ this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID, layer);
63952
63974
  for (const [spec] of subscribers) {
63953
63975
  spec.set(
63954
63976
  this.cache._internal_unstable.getSelection({
@@ -63961,12 +63983,12 @@ var List = class {
63961
63983
  }
63962
63984
  return true;
63963
63985
  }
63964
- remove(data, variables = {}) {
63986
+ remove(data, variables = {}, layer) {
63965
63987
  const targetID = this.cache._internal_unstable.id(this.listType(data), data);
63966
63988
  if (!targetID) {
63967
63989
  return;
63968
63990
  }
63969
- return this.removeID(targetID, variables);
63991
+ return this.removeID(targetID, variables, layer);
63970
63992
  }
63971
63993
  listType(data) {
63972
63994
  return data.__typename || this.type;
@@ -63998,7 +64020,7 @@ var List = class {
63998
64020
  layer,
63999
64021
  where
64000
64022
  }) {
64001
- if (!this.remove(data, variables)) {
64023
+ if (!this.remove(data, variables, layer)) {
64002
64024
  this.addToList(selection, data, variables, where, layer);
64003
64025
  }
64004
64026
  }
@@ -64135,7 +64157,7 @@ var StaleManager = class {
64135
64157
  // src/runtime/cache/storage.ts
64136
64158
  var InMemoryStorage = class {
64137
64159
  data;
64138
- idCount = 0;
64160
+ idCount = 1;
64139
64161
  rank = 0;
64140
64162
  constructor() {
64141
64163
  this.data = [];
@@ -64155,11 +64177,11 @@ var InMemoryStorage = class {
64155
64177
  insert(id, field, location, target) {
64156
64178
  return this.topLayer.insert(id, field, location, target);
64157
64179
  }
64158
- remove(id, field, target) {
64159
- return this.topLayer.remove(id, field, target);
64180
+ remove(id, field, target, layerToUser = this.topLayer) {
64181
+ return layerToUser.remove(id, field, target);
64160
64182
  }
64161
- delete(id) {
64162
- return this.topLayer.delete(id);
64183
+ delete(id, layerToUser = this.topLayer) {
64184
+ return layerToUser.delete(id);
64163
64185
  }
64164
64186
  deleteField(id, field) {
64165
64187
  return this.topLayer.deleteField(id, field);
@@ -64293,6 +64315,23 @@ var InMemoryStorage = class {
64293
64315
  }
64294
64316
  return this.data[this.data.length - 1];
64295
64317
  }
64318
+ serialize() {
64319
+ return JSON.stringify({
64320
+ rank: this.rank,
64321
+ fields: this.topLayer.fields,
64322
+ links: this.topLayer.links
64323
+ });
64324
+ }
64325
+ hydrate(args, layer) {
64326
+ if (!args) {
64327
+ return;
64328
+ }
64329
+ const { rank, fields, links } = args;
64330
+ this.rank = rank;
64331
+ layer ??= this.createLayer(true);
64332
+ layer.fields = fields;
64333
+ layer.links = links;
64334
+ }
64296
64335
  };
64297
64336
  var Layer = class {
64298
64337
  id;
@@ -64531,6 +64570,9 @@ var InMemorySubscriptions = class {
64531
64570
  subscribers = {};
64532
64571
  referenceCounts = {};
64533
64572
  keyVersions = {};
64573
+ activeFields(parent) {
64574
+ return Object.keys(this.subscribers[parent] || {});
64575
+ }
64534
64576
  add({
64535
64577
  parent,
64536
64578
  spec,
@@ -64799,20 +64841,7 @@ var Cache = class {
64799
64841
  }) {
64800
64842
  const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
64801
64843
  const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
64802
- const notified = [];
64803
- for (const spec of subscribers.concat(notifySubscribers)) {
64804
- if (!notified.includes(spec.set)) {
64805
- notified.push(spec.set);
64806
- spec.set(
64807
- this._internal_unstable.getSelection({
64808
- parent: spec.parentID || rootID,
64809
- selection: spec.selection,
64810
- variables: spec.variables?.() || {},
64811
- ignoreMasking: false
64812
- }).data
64813
- );
64814
- }
64815
- }
64844
+ this.#notifySubscribers(subscribers.concat(notifySubscribers));
64816
64845
  return subscribers;
64817
64846
  }
64818
64847
  read(...args) {
@@ -64851,10 +64880,10 @@ var Cache = class {
64851
64880
  }
64852
64881
  return handler;
64853
64882
  }
64854
- delete(id) {
64883
+ delete(id, layer) {
64855
64884
  this._internal_unstable.subscriptions.removeAllSubscribers(id);
64856
- this._internal_unstable.lists.removeIDFromAllLists(id);
64857
- this._internal_unstable.storage.delete(id);
64885
+ this._internal_unstable.lists.removeIDFromAllLists(id, layer);
64886
+ this._internal_unstable.storage.delete(id, layer);
64858
64887
  }
64859
64888
  setConfig(config) {
64860
64889
  this._internal_unstable.setConfig(config);
@@ -64886,6 +64915,76 @@ var Cache = class {
64886
64915
  config() {
64887
64916
  return this._internal_unstable.config;
64888
64917
  }
64918
+ serialize() {
64919
+ return this._internal_unstable.storage.serialize();
64920
+ }
64921
+ hydrate(...args) {
64922
+ return this._internal_unstable.storage.hydrate(...args);
64923
+ }
64924
+ clearLayer(layerID) {
64925
+ const layer = this._internal_unstable.storage.getLayer(layerID);
64926
+ if (!layer) {
64927
+ throw new Error("Cannot find layer with id: " + layerID);
64928
+ }
64929
+ const toNotify = [];
64930
+ const allFields = [];
64931
+ for (const target of [layer.fields, layer.links]) {
64932
+ for (const [id, fields] of Object.entries(target)) {
64933
+ allFields.push(
64934
+ ...Object.entries(fields).map(([field, value]) => ({ id, field, value }))
64935
+ );
64936
+ }
64937
+ }
64938
+ const displayFields = [];
64939
+ for (const pair of allFields) {
64940
+ const { displayLayers } = this._internal_unstable.storage.get(pair.id, pair.field);
64941
+ if (!displayLayers.includes(layerID)) {
64942
+ continue;
64943
+ }
64944
+ displayFields.push(pair);
64945
+ }
64946
+ for (const [id, operation] of Object.entries(layer.operations)) {
64947
+ if (operation.deleted) {
64948
+ displayFields.push(
64949
+ ...this._internal_unstable.subscriptions.activeFields(id).map((field) => ({ id, field }))
64950
+ );
64951
+ }
64952
+ const fields = Object.keys(operation.fields ?? {});
64953
+ if (fields.length > 0) {
64954
+ displayFields.push(...fields.map((field) => ({ id, field })));
64955
+ }
64956
+ }
64957
+ layer.clear();
64958
+ for (const display of displayFields) {
64959
+ const { field, id } = display;
64960
+ const notify = !("value" in display) || this._internal_unstable.storage.get(id, field).value !== display.value;
64961
+ if (notify) {
64962
+ toNotify.push(
64963
+ ...this._internal_unstable.subscriptions.get(id, field).map((sub) => sub[0])
64964
+ );
64965
+ }
64966
+ }
64967
+ this.#notifySubscribers(toNotify);
64968
+ }
64969
+ #notifySubscribers(subs) {
64970
+ if (subs.length === 0) {
64971
+ return;
64972
+ }
64973
+ const notified = [];
64974
+ for (const spec of subs) {
64975
+ if (!notified.includes(spec.set)) {
64976
+ notified.push(spec.set);
64977
+ spec.set(
64978
+ this._internal_unstable.getSelection({
64979
+ parent: spec.parentID || rootID,
64980
+ selection: spec.selection,
64981
+ variables: spec.variables?.() || {},
64982
+ ignoreMasking: false
64983
+ }).data
64984
+ );
64985
+ }
64986
+ }
64987
+ }
64889
64988
  };
64890
64989
  var CacheInternal = class {
64891
64990
  _disabled = false;
@@ -65173,8 +65272,16 @@ var CacheInternal = class {
65173
65272
  operation.position || "last",
65174
65273
  layer
65175
65274
  );
65275
+ } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
65276
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
65277
+ selection: fieldSelection,
65278
+ data: target,
65279
+ variables,
65280
+ where: operation.position || "last",
65281
+ layer
65282
+ });
65176
65283
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
65177
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
65284
+ this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
65178
65285
  } else if (operation.action === "delete" && operation.type) {
65179
65286
  if (typeof target !== "string") {
65180
65287
  throw new Error("Cannot delete a record with a non-string ID");
@@ -65183,15 +65290,7 @@ var CacheInternal = class {
65183
65290
  if (!targetID) {
65184
65291
  continue;
65185
65292
  }
65186
- this.cache.delete(targetID);
65187
- } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
65188
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
65189
- selection: fieldSelection,
65190
- data: target,
65191
- variables,
65192
- where: operation.position || "last",
65193
- layer
65194
- });
65293
+ this.cache.delete(targetID, layer);
65195
65294
  }
65196
65295
  }
65197
65296
  }
@@ -65660,6 +65759,9 @@ var cachePolicy = ({
65660
65759
  },
65661
65760
  afterNetwork(ctx, { resolve: resolve2, value, marshalVariables: marshalVariables2 }) {
65662
65761
  if (value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
65762
+ if (ctx.cacheParams && "serverSideFallback" in ctx.cacheParams) {
65763
+ serverSideFallback = ctx.cacheParams?.serverSideFallback ?? serverSideFallback;
65764
+ }
65663
65765
  const targetCache = serverSide && serverSideFallback ? new Cache({ disabled: false }) : localCache;
65664
65766
  let layer;
65665
65767
  if (!serverSide && ctx.cacheParams?.layer) {
@@ -65817,7 +65919,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
65817
65919
  var mutation = documentPlugin(ArtifactKind.Mutation, () => {
65818
65920
  return {
65819
65921
  async start(ctx, { next, marshalVariables: marshalVariables2 }) {
65820
- const layer = cache_default._internal_unstable.storage.createLayer(true);
65922
+ const layerOptimistic = cache_default._internal_unstable.storage.createLayer(true);
65821
65923
  const optimisticResponse = ctx.stuff.optimisticResponse;
65822
65924
  let toNotify = [];
65823
65925
  if (optimisticResponse) {
@@ -65828,25 +65930,29 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
65828
65930
  data: optimisticResponse
65829
65931
  }),
65830
65932
  variables: marshalVariables2(ctx),
65831
- layer: layer.id
65933
+ layer: layerOptimistic.id
65832
65934
  });
65833
65935
  }
65834
65936
  ctx.cacheParams = {
65835
65937
  ...ctx.cacheParams,
65836
- layer,
65938
+ layer: layerOptimistic,
65837
65939
  notifySubscribers: toNotify,
65838
65940
  forceNotify: true
65839
65941
  };
65840
65942
  next(ctx);
65841
65943
  },
65842
65944
  afterNetwork(ctx, { resolve: resolve2 }) {
65843
- ctx.cacheParams?.layer?.clear();
65945
+ if (ctx.cacheParams?.layer) {
65946
+ cache_default.clearLayer(ctx.cacheParams.layer.id);
65947
+ }
65844
65948
  resolve2(ctx);
65845
65949
  },
65846
65950
  end(ctx, { resolve: resolve2, value }) {
65847
65951
  const hasErrors = value.errors && value.errors.length > 0;
65848
65952
  if (hasErrors) {
65849
- ctx.cacheParams?.layer?.clear();
65953
+ if (ctx.cacheParams?.layer) {
65954
+ cache_default.clearLayer(ctx.cacheParams.layer.id);
65955
+ }
65850
65956
  }
65851
65957
  if (ctx.cacheParams?.layer) {
65852
65958
  cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
@@ -65856,7 +65962,7 @@ var mutation = documentPlugin(ArtifactKind.Mutation, () => {
65856
65962
  catch(ctx, { error }) {
65857
65963
  if (ctx.cacheParams?.layer) {
65858
65964
  const { layer } = ctx.cacheParams;
65859
- layer.clear();
65965
+ cache_default.clearLayer(layer.id);
65860
65966
  cache_default._internal_unstable.storage.resolveLayer(layer.id);
65861
65967
  }
65862
65968
  throw error;
@@ -65997,20 +66103,23 @@ var steps = {
65997
66103
  backwards: ["end", "afterNetwork"]
65998
66104
  };
65999
66105
  var DocumentStore = class extends Writable {
66000
- #artifact;
66106
+ artifact;
66001
66107
  #client;
66002
66108
  #configFile;
66003
66109
  #plugins;
66004
66110
  #lastVariables;
66005
66111
  #lastContext = null;
66006
66112
  pendingPromise = null;
66113
+ serverSideFallback;
66007
66114
  constructor({
66008
66115
  artifact,
66009
66116
  plugins: plugins2,
66010
66117
  pipeline: pipeline2,
66011
66118
  client: client2,
66012
- cache = true,
66119
+ cache,
66120
+ enableCache = true,
66013
66121
  initialValue,
66122
+ initialVariables,
66014
66123
  fetching
66015
66124
  }) {
66016
66125
  fetching ??= artifact.kind === ArtifactKind.Query;
@@ -66021,7 +66130,7 @@ var DocumentStore = class extends Writable {
66021
66130
  stale: false,
66022
66131
  source: null,
66023
66132
  fetching,
66024
- variables: null
66133
+ variables: initialVariables ?? null
66025
66134
  };
66026
66135
  super(initialState, () => {
66027
66136
  return () => {
@@ -66029,13 +66138,14 @@ var DocumentStore = class extends Writable {
66029
66138
  this.cleanup();
66030
66139
  };
66031
66140
  });
66032
- this.#artifact = artifact;
66141
+ this.artifact = artifact;
66033
66142
  this.#client = client2;
66034
66143
  this.#lastVariables = null;
66035
66144
  this.#configFile = getCurrentConfig();
66036
66145
  this.#plugins = pipeline2 ?? [
66037
66146
  cachePolicy({
66038
- enabled: cache,
66147
+ cache,
66148
+ enabled: enableCache,
66039
66149
  setFetching: (fetching2, data) => {
66040
66150
  this.update((state) => {
66041
66151
  const newState = { ...state, fetching: fetching2 };
@@ -66062,9 +66172,9 @@ var DocumentStore = class extends Writable {
66062
66172
  } = {}) {
66063
66173
  let context = new ClientPluginContextWrapper({
66064
66174
  config: this.#configFile,
66065
- text: this.#artifact.raw,
66066
- hash: this.#artifact.hash,
66067
- policy: policy ?? this.#artifact.policy,
66175
+ text: this.artifact.raw,
66176
+ hash: this.artifact.hash,
66177
+ policy: policy ?? this.artifact.policy,
66068
66178
  variables: null,
66069
66179
  metadata,
66070
66180
  session,
@@ -66077,7 +66187,7 @@ var DocumentStore = class extends Writable {
66077
66187
  },
66078
66188
  ...stuff
66079
66189
  },
66080
- artifact: this.#artifact,
66190
+ artifact: this.artifact,
66081
66191
  lastVariables: this.#lastVariables,
66082
66192
  cacheParams
66083
66193
  });
@@ -66371,18 +66481,16 @@ var HoudiniClient = class {
66371
66481
  this.url = url;
66372
66482
  }
66373
66483
  observe({
66374
- artifact,
66375
- cache = true,
66376
- initialValue,
66377
- fetching = false
66484
+ enableCache = true,
66485
+ fetching = false,
66486
+ ...rest
66378
66487
  }) {
66379
66488
  return new DocumentStore({
66380
66489
  client: this,
66381
- artifact,
66382
66490
  plugins: createPluginHooks(this.plugins),
66383
- cache,
66384
- initialValue,
66385
- fetching
66491
+ fetching,
66492
+ enableCache,
66493
+ ...rest
66386
66494
  });
66387
66495
  }
66388
66496
  };
@@ -67422,7 +67530,7 @@ function deepMerge2(filepath, ...targets) {
67422
67530
  }
67423
67531
 
67424
67532
  // src/lib/parse.ts
67425
- async function parseJS(str, config) {
67533
+ function parseJS(str, config) {
67426
67534
  const defaultConfig = {
67427
67535
  plugins: ["typescript", "importAssertions"],
67428
67536
  sourceType: "module"
@@ -67736,6 +67844,7 @@ async function find_graphql(config, parsedScript, walker) {
67736
67844
  }
67737
67845
  export {
67738
67846
  ArtifactKind,
67847
+ Cache,
67739
67848
  CachePolicy,
67740
67849
  CompiledFragmentKind,
67741
67850
  CompiledMutationKind,
@@ -67772,6 +67881,7 @@ export {
67772
67881
  getRootType,
67773
67882
  hashDocument,
67774
67883
  houdini_mode,
67884
+ isPending,
67775
67885
  keyFieldsForType,
67776
67886
  mutation,
67777
67887
  operation_requires_variables,
@@ -8,6 +8,7 @@ import type { Layer, LayerID } from './storage';
8
8
  import { InMemoryStorage } from './storage';
9
9
  import { InMemorySubscriptions, type FieldSelection } from './subscription';
10
10
  export declare class Cache {
11
+ #private;
11
12
  _internal_unstable: CacheInternal;
12
13
  constructor({ disabled, ...config }?: ConfigFile & {
13
14
  disabled?: boolean;
@@ -33,7 +34,7 @@ export declare class Cache {
33
34
  subscribe(spec: SubscriptionSpec, variables?: {}): void;
34
35
  unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
35
36
  list(name: string, parentID?: string, allLists?: boolean): ListCollection;
36
- delete(id: string): void;
37
+ delete(id: string, layer?: Layer): void;
37
38
  setConfig(config: ConfigFile): void;
38
39
  markTypeStale(options?: {
39
40
  type: string;
@@ -46,6 +47,9 @@ export declare class Cache {
46
47
  }): void;
47
48
  getFieldTime(id: string, field: string): number | null | undefined;
48
49
  config(): ConfigFile;
50
+ serialize(): string;
51
+ hydrate(...args: Parameters<InMemoryStorage['hydrate']>): void;
52
+ clearLayer(layerID: Layer['id']): void;
49
53
  }
50
54
  declare class CacheInternal {
51
55
  private _disabled;
@@ -21,7 +21,7 @@ export declare class ListManager {
21
21
  filters?: List['filters'];
22
22
  abstract?: boolean;
23
23
  }): void;
24
- removeIDFromAllLists(id: string): void;
24
+ removeIDFromAllLists(id: string, layer?: Layer): void;
25
25
  deleteField(parentID: string, field: string): void;
26
26
  }
27
27
  export declare class List {
@@ -54,8 +54,8 @@ export declare class List {
54
54
  layer?: Layer;
55
55
  }): void;
56
56
  addToList(selection: SubscriptionSelection, data: {}, variables: {} | undefined, where: 'first' | 'last', layer?: Layer): void;
57
- removeID(id: string, variables?: {}): true | undefined;
58
- remove(data: {}, variables?: {}): true | undefined;
57
+ removeID(id: string, variables?: {}, layer?: Layer): true | undefined;
58
+ remove(data: {}, variables?: {}, layer?: Layer): true | undefined;
59
59
  listType(data: {
60
60
  __typename?: string;
61
61
  }): string;
@@ -8,8 +8,8 @@ export declare class InMemoryStorage {
8
8
  get nextRank(): number;
9
9
  createLayer(optimistic?: boolean): Layer;
10
10
  insert(id: string, field: string, location: OperationLocations, target: string): void;
11
- remove(id: string, field: string, target: string): void;
12
- delete(id: string): void;
11
+ remove(id: string, field: string, target: string, layerToUser?: Layer): void;
12
+ delete(id: string, layerToUser?: Layer): void;
13
13
  deleteField(id: string, field: string): void;
14
14
  getLayer(id: number): Layer;
15
15
  replaceID(replacement: {
@@ -25,6 +25,12 @@ export declare class InMemoryStorage {
25
25
  writeField(id: string, field: string, value: GraphQLValue): number;
26
26
  resolveLayer(id: number): void;
27
27
  get topLayer(): Layer;
28
+ serialize(): string;
29
+ hydrate(args?: {
30
+ rank: number;
31
+ fields: EntityFieldMap;
32
+ links: LinkMap;
33
+ }, layer?: Layer): void;
28
34
  }
29
35
  export declare class Layer {
30
36
  readonly id: LayerID;
@@ -10,6 +10,7 @@ export declare class InMemorySubscriptions {
10
10
  private subscribers;
11
11
  private referenceCounts;
12
12
  private keyVersions;
13
+ activeFields(parent: string): string[];
13
14
  add({ parent, spec, selection, variables, parentType, }: {
14
15
  parent: string;
15
16
  parentType?: string;
@@ -1,21 +1,27 @@
1
1
  import type { HoudiniClient } from '.';
2
+ import type { Cache } from '../cache/cache';
2
3
  import type { Layer } from '../cache/storage';
3
4
  import type { ConfigFile } from '../lib/config';
4
5
  import { Writable } from '../lib/store';
5
6
  import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies, GraphQLVariables } from '../lib/types';
6
7
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends GraphQLVariables> extends Writable<QueryResult<_Data, _Input>> {
7
8
  #private;
9
+ readonly artifact: DocumentArtifact;
8
10
  pendingPromise: {
9
11
  then: (val: any) => void;
10
12
  } | null;
11
- constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
13
+ serverSideFallback?: boolean;
14
+ constructor({ artifact, plugins, pipeline, client, cache, enableCache, initialValue, initialVariables, fetching, }: {
12
15
  artifact: DocumentArtifact;
13
16
  plugins?: ClientHooks[];
14
17
  pipeline?: ClientHooks[];
15
18
  client: HoudiniClient | null;
16
- cache?: boolean;
19
+ cache?: Cache;
20
+ enableCache?: boolean;
17
21
  initialValue?: _Data | null;
18
22
  fetching?: boolean;
23
+ serverSideFallback?: boolean;
24
+ initialVariables?: _Input;
19
25
  });
20
26
  send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
21
27
  cleanup(): Promise<void>;
@@ -51,6 +57,7 @@ export type ClientPluginContext = {
51
57
  disableRead?: boolean;
52
58
  disableSubscriptions?: boolean;
53
59
  applyUpdates?: string[];
60
+ serverSideFallback?: boolean;
54
61
  };
55
62
  stuff: App.Stuff;
56
63
  };
@@ -1,4 +1,5 @@
1
1
  /// <reference path="../../../../../houdini.d.ts" />
2
+ import type { Cache } from '../cache/cache';
2
3
  import type { DocumentArtifact, GraphQLVariables, GraphQLObject, NestedList } from '../lib/types';
3
4
  import type { ClientHooks, ClientPlugin } from './documentStore';
4
5
  import { DocumentStore } from './documentStore';
@@ -12,10 +13,12 @@ export type HoudiniClientConstructorArgs = {
12
13
  pipeline?: NestedList<ClientPlugin>;
13
14
  throwOnError?: ThrowOnErrorParams;
14
15
  };
15
- export type ObserveParams<_Data extends GraphQLObject, _Artifact extends DocumentArtifact = DocumentArtifact> = {
16
+ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends DocumentArtifact = DocumentArtifact, _Input extends GraphQLVariables = GraphQLVariables> = {
16
17
  artifact: _Artifact;
17
- cache?: boolean;
18
+ enableCache?: boolean;
19
+ cache?: Cache;
18
20
  initialValue?: _Data | null;
21
+ initialVariables?: _Input;
19
22
  fetching?: boolean;
20
23
  };
21
24
  export declare class HoudiniClient {
@@ -23,6 +26,6 @@ export declare class HoudiniClient {
23
26
  readonly plugins: ClientPlugin[];
24
27
  readonly throwOnError_operations: ThrowOnErrorOperations[];
25
28
  constructor({ url, fetchParams, plugins, pipeline, throwOnError, }: HoudiniClientConstructorArgs);
26
- observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ artifact, cache, initialValue, fetching, }: ObserveParams<_Data>): DocumentStore<_Data, _Input>;
29
+ observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
27
30
  }
28
31
  export declare function createPluginHooks(plugins: ClientPlugin[]): ClientHooks[];
@@ -6,3 +6,4 @@ export * from './scalars';
6
6
  export * from './types';
7
7
  export * from './store';
8
8
  export * from './key';
9
+ export * from './lru';