houdini 1.1.2 → 1.1.4-react.0

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 (41) hide show
  1. package/build/cmd-cjs/index.js +230 -158
  2. package/build/cmd-esm/index.js +230 -158
  3. package/build/codegen-cjs/index.js +217 -156
  4. package/build/codegen-esm/index.js +217 -156
  5. package/build/lib/config.d.ts +1 -0
  6. package/build/lib/parse.d.ts +2 -1
  7. package/build/lib/types.d.ts +4 -1
  8. package/build/lib-cjs/index.js +178 -146
  9. package/build/lib-esm/index.js +178 -146
  10. package/build/runtime/client/documentStore.d.ts +3 -0
  11. package/build/runtime/client/index.d.ts +1 -1
  12. package/build/runtime/lib/pageInfo.d.ts +7 -0
  13. package/build/runtime/lib/pagination.d.ts +29 -0
  14. package/build/runtime/lib/types.d.ts +46 -0
  15. package/build/runtime-cjs/client/documentStore.d.ts +3 -0
  16. package/build/runtime-cjs/client/documentStore.js +11 -6
  17. package/build/runtime-cjs/client/index.d.ts +1 -1
  18. package/build/runtime-cjs/client/plugins/cache.js +6 -3
  19. package/build/runtime-cjs/client/plugins/fragment.js +8 -1
  20. package/build/runtime-cjs/client/plugins/query.js +2 -1
  21. package/build/runtime-cjs/lib/pageInfo.d.ts +7 -0
  22. package/build/runtime-cjs/lib/pageInfo.js +79 -0
  23. package/build/runtime-cjs/lib/pagination.d.ts +29 -0
  24. package/build/runtime-cjs/lib/pagination.js +231 -0
  25. package/build/runtime-cjs/lib/types.d.ts +46 -0
  26. package/build/runtime-esm/client/documentStore.d.ts +3 -0
  27. package/build/runtime-esm/client/documentStore.js +11 -6
  28. package/build/runtime-esm/client/index.d.ts +1 -1
  29. package/build/runtime-esm/client/plugins/cache.js +6 -3
  30. package/build/runtime-esm/client/plugins/fragment.js +8 -1
  31. package/build/runtime-esm/client/plugins/query.js +2 -1
  32. package/build/runtime-esm/lib/pageInfo.d.ts +7 -0
  33. package/build/runtime-esm/lib/pageInfo.js +52 -0
  34. package/build/runtime-esm/lib/pagination.d.ts +29 -0
  35. package/build/runtime-esm/lib/pagination.js +206 -0
  36. package/build/runtime-esm/lib/types.d.ts +46 -0
  37. package/build/test-cjs/index.js +224 -155
  38. package/build/test-esm/index.js +224 -155
  39. package/build/vite-cjs/index.js +228 -156
  40. package/build/vite-esm/index.js +228 -156
  41. package/package.json +1 -1
@@ -2406,7 +2406,7 @@ var require_visitor = __commonJS({
2406
2406
  Object.defineProperty(exports, "__esModule", {
2407
2407
  value: true
2408
2408
  });
2409
- exports.visit = visit2;
2409
+ exports.visit = visit3;
2410
2410
  exports.visitInParallel = visitInParallel;
2411
2411
  exports.getVisitFn = getVisitFn;
2412
2412
  exports.BREAK = exports.QueryDocumentKeys = void 0;
@@ -2469,7 +2469,7 @@ var require_visitor = __commonJS({
2469
2469
  exports.QueryDocumentKeys = QueryDocumentKeys;
2470
2470
  var BREAK = Object.freeze({});
2471
2471
  exports.BREAK = BREAK;
2472
- function visit2(root, visitor) {
2472
+ function visit3(root, visitor) {
2473
2473
  var visitorKeys = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : QueryDocumentKeys;
2474
2474
  var stack = void 0;
2475
2475
  var inArray = Array.isArray(root);
@@ -42024,6 +42024,109 @@ var require_lib3 = __commonJS({
42024
42024
  }
42025
42025
  });
42026
42026
 
42027
+ // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
42028
+ var require_cjs = __commonJS({
42029
+ "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module) {
42030
+ "use strict";
42031
+ var isMergeableObject = function isMergeableObject2(value) {
42032
+ return isNonNullObject(value) && !isSpecial(value);
42033
+ };
42034
+ function isNonNullObject(value) {
42035
+ return !!value && typeof value === "object";
42036
+ }
42037
+ function isSpecial(value) {
42038
+ var stringValue = Object.prototype.toString.call(value);
42039
+ return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
42040
+ }
42041
+ var canUseSymbol = typeof Symbol === "function" && Symbol.for;
42042
+ var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
42043
+ function isReactElement(value) {
42044
+ return value.$$typeof === REACT_ELEMENT_TYPE;
42045
+ }
42046
+ function emptyTarget(val) {
42047
+ return Array.isArray(val) ? [] : {};
42048
+ }
42049
+ function cloneUnlessOtherwiseSpecified(value, options) {
42050
+ return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
42051
+ }
42052
+ function defaultArrayMerge(target, source, options) {
42053
+ return target.concat(source).map(function(element) {
42054
+ return cloneUnlessOtherwiseSpecified(element, options);
42055
+ });
42056
+ }
42057
+ function getMergeFunction(key, options) {
42058
+ if (!options.customMerge) {
42059
+ return deepmerge;
42060
+ }
42061
+ var customMerge = options.customMerge(key);
42062
+ return typeof customMerge === "function" ? customMerge : deepmerge;
42063
+ }
42064
+ function getEnumerableOwnPropertySymbols(target) {
42065
+ return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
42066
+ return target.propertyIsEnumerable(symbol);
42067
+ }) : [];
42068
+ }
42069
+ function getKeys(target) {
42070
+ return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
42071
+ }
42072
+ function propertyIsOnObject(object, property) {
42073
+ try {
42074
+ return property in object;
42075
+ } catch (_) {
42076
+ return false;
42077
+ }
42078
+ }
42079
+ function propertyIsUnsafe(target, key) {
42080
+ return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
42081
+ }
42082
+ function mergeObject(target, source, options) {
42083
+ var destination = {};
42084
+ if (options.isMergeableObject(target)) {
42085
+ getKeys(target).forEach(function(key) {
42086
+ destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
42087
+ });
42088
+ }
42089
+ getKeys(source).forEach(function(key) {
42090
+ if (propertyIsUnsafe(target, key)) {
42091
+ return;
42092
+ }
42093
+ if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
42094
+ destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
42095
+ } else {
42096
+ destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
42097
+ }
42098
+ });
42099
+ return destination;
42100
+ }
42101
+ function deepmerge(target, source, options) {
42102
+ options = options || {};
42103
+ options.arrayMerge = options.arrayMerge || defaultArrayMerge;
42104
+ options.isMergeableObject = options.isMergeableObject || isMergeableObject;
42105
+ options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
42106
+ var sourceIsArray = Array.isArray(source);
42107
+ var targetIsArray = Array.isArray(target);
42108
+ var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
42109
+ if (!sourceAndTargetTypesMatch) {
42110
+ return cloneUnlessOtherwiseSpecified(source, options);
42111
+ } else if (sourceIsArray) {
42112
+ return options.arrayMerge(target, source, options);
42113
+ } else {
42114
+ return mergeObject(target, source, options);
42115
+ }
42116
+ }
42117
+ deepmerge.all = function deepmergeAll(array, options) {
42118
+ if (!Array.isArray(array)) {
42119
+ throw new Error("first argument should be an array");
42120
+ }
42121
+ return array.reduce(function(prev, next) {
42122
+ return deepmerge(prev, next, options);
42123
+ }, {});
42124
+ };
42125
+ var deepmerge_1 = deepmerge;
42126
+ module.exports = deepmerge_1;
42127
+ }
42128
+ });
42129
+
42027
42130
  // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
42028
42131
  var require_tslib = __commonJS({
42029
42132
  "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module) {
@@ -44293,7 +44396,7 @@ var require_path_visitor = __commonJS({
44293
44396
  }
44294
44397
  return target;
44295
44398
  }
44296
- PathVisitor.visit = function visit2(node, methods) {
44399
+ PathVisitor.visit = function visit3(node, methods) {
44297
44400
  return PathVisitor.fromMethodsObject(methods).visit(node);
44298
44401
  };
44299
44402
  var PVp = PathVisitor.prototype;
@@ -44484,7 +44587,7 @@ var require_path_visitor = __commonJS({
44484
44587
  this.needToCallTraverse = false;
44485
44588
  return visitChildren(path2, PathVisitor.fromMethodsObject(newVisitor || this.visitor));
44486
44589
  };
44487
- sharedContextProtoMethods.visit = function visit2(path2, newVisitor) {
44590
+ sharedContextProtoMethods.visit = function visit3(path2, newVisitor) {
44488
44591
  if (!(this instanceof this.Context)) {
44489
44592
  throw new Error("");
44490
44593
  }
@@ -45877,7 +45980,7 @@ var require_main = __commonJS({
45877
45980
  var someField = _a.someField;
45878
45981
  var Type = _a.Type;
45879
45982
  var use = _a.use;
45880
- var visit2 = _a.visit;
45983
+ var visit3 = _a.visit;
45881
45984
  exports.astNodesAreEquivalent = astNodesAreEquivalent;
45882
45985
  exports.builders = builders;
45883
45986
  exports.builtInTypes = builtInTypes;
@@ -45894,7 +45997,7 @@ var require_main = __commonJS({
45894
45997
  exports.someField = someField;
45895
45998
  exports.Type = Type;
45896
45999
  exports.use = use;
45897
- exports.visit = visit2;
46000
+ exports.visit = visit3;
45898
46001
  Object.assign(namedTypes_1.namedTypes, n);
45899
46002
  }
45900
46003
  });
@@ -58356,109 +58459,6 @@ var require_main2 = __commonJS({
58356
58459
  }
58357
58460
  });
58358
58461
 
58359
- // ../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js
58360
- var require_cjs = __commonJS({
58361
- "../../node_modules/.pnpm/deepmerge@4.2.2/node_modules/deepmerge/dist/cjs.js"(exports, module) {
58362
- "use strict";
58363
- var isMergeableObject = function isMergeableObject2(value) {
58364
- return isNonNullObject(value) && !isSpecial(value);
58365
- };
58366
- function isNonNullObject(value) {
58367
- return !!value && typeof value === "object";
58368
- }
58369
- function isSpecial(value) {
58370
- var stringValue = Object.prototype.toString.call(value);
58371
- return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
58372
- }
58373
- var canUseSymbol = typeof Symbol === "function" && Symbol.for;
58374
- var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;
58375
- function isReactElement(value) {
58376
- return value.$$typeof === REACT_ELEMENT_TYPE;
58377
- }
58378
- function emptyTarget(val) {
58379
- return Array.isArray(val) ? [] : {};
58380
- }
58381
- function cloneUnlessOtherwiseSpecified(value, options) {
58382
- return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
58383
- }
58384
- function defaultArrayMerge(target, source, options) {
58385
- return target.concat(source).map(function(element) {
58386
- return cloneUnlessOtherwiseSpecified(element, options);
58387
- });
58388
- }
58389
- function getMergeFunction(key, options) {
58390
- if (!options.customMerge) {
58391
- return deepmerge;
58392
- }
58393
- var customMerge = options.customMerge(key);
58394
- return typeof customMerge === "function" ? customMerge : deepmerge;
58395
- }
58396
- function getEnumerableOwnPropertySymbols(target) {
58397
- return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
58398
- return target.propertyIsEnumerable(symbol);
58399
- }) : [];
58400
- }
58401
- function getKeys(target) {
58402
- return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
58403
- }
58404
- function propertyIsOnObject(object, property) {
58405
- try {
58406
- return property in object;
58407
- } catch (_) {
58408
- return false;
58409
- }
58410
- }
58411
- function propertyIsUnsafe(target, key) {
58412
- return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
58413
- }
58414
- function mergeObject(target, source, options) {
58415
- var destination = {};
58416
- if (options.isMergeableObject(target)) {
58417
- getKeys(target).forEach(function(key) {
58418
- destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
58419
- });
58420
- }
58421
- getKeys(source).forEach(function(key) {
58422
- if (propertyIsUnsafe(target, key)) {
58423
- return;
58424
- }
58425
- if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
58426
- destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
58427
- } else {
58428
- destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
58429
- }
58430
- });
58431
- return destination;
58432
- }
58433
- function deepmerge(target, source, options) {
58434
- options = options || {};
58435
- options.arrayMerge = options.arrayMerge || defaultArrayMerge;
58436
- options.isMergeableObject = options.isMergeableObject || isMergeableObject;
58437
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
58438
- var sourceIsArray = Array.isArray(source);
58439
- var targetIsArray = Array.isArray(target);
58440
- var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
58441
- if (!sourceAndTargetTypesMatch) {
58442
- return cloneUnlessOtherwiseSpecified(source, options);
58443
- } else if (sourceIsArray) {
58444
- return options.arrayMerge(target, source, options);
58445
- } else {
58446
- return mergeObject(target, source, options);
58447
- }
58448
- }
58449
- deepmerge.all = function deepmergeAll(array, options) {
58450
- if (!Array.isArray(array)) {
58451
- throw new Error("first argument should be an array");
58452
- }
58453
- return array.reduce(function(prev, next) {
58454
- return deepmerge(prev, next, options);
58455
- }, {});
58456
- };
58457
- var deepmerge_1 = deepmerge;
58458
- module.exports = deepmerge_1;
58459
- }
58460
- });
58461
-
58462
58462
  // src/lib/pipeline.ts
58463
58463
  async function runPipeline(config, pipeline2, target) {
58464
58464
  for (const transform of pipeline2) {
@@ -65548,11 +65548,12 @@ var cachePolicy = ({
65548
65548
  network(ctx, { initialValue, next, resolve: resolve2, marshalVariables: marshalVariables2 }) {
65549
65549
  const { policy, artifact } = ctx;
65550
65550
  let useCache = false;
65551
- if (enabled && artifact.kind === ArtifactKind.Query && !ctx.cacheParams?.disableRead) {
65551
+ if (enabled && (artifact.kind === ArtifactKind.Query || artifact.kind === ArtifactKind.Fragment) && !ctx.cacheParams?.disableRead) {
65552
65552
  if (policy !== CachePolicy.NetworkOnly) {
65553
65553
  const value = localCache.read({
65554
65554
  selection: artifact.selection,
65555
- variables: marshalVariables2(ctx)
65555
+ variables: marshalVariables2(ctx),
65556
+ parent: ctx.stuff?.parentID
65556
65557
  });
65557
65558
  const allowed = !value.partial || artifact.kind === ArtifactKind.Query && artifact.partial;
65558
65559
  if (policy === CachePolicy.CacheOnly) {
@@ -65588,7 +65589,9 @@ var cachePolicy = ({
65588
65589
  localCache._internal_unstable.collectGarbage();
65589
65590
  }, 0);
65590
65591
  }
65591
- setFetching(!useCache);
65592
+ if (!ctx.stuff?.silenceLoading) {
65593
+ setFetching(!useCache);
65594
+ }
65592
65595
  return next(ctx);
65593
65596
  },
65594
65597
  afterNetwork(ctx, { resolve: resolve2, value, marshalVariables: marshalVariables2 }) {
@@ -65668,10 +65671,11 @@ var query = documentPlugin(ArtifactKind.Query, function() {
65668
65671
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
65669
65672
  }
65670
65673
  lastVariables = { ...marshalVariables2(ctx) };
65674
+ const variables = lastVariables;
65671
65675
  subscriptionSpec = {
65672
65676
  rootType: ctx.artifact.rootType,
65673
65677
  selection: ctx.artifact.selection,
65674
- variables: () => lastVariables,
65678
+ variables: () => variables,
65675
65679
  set: (newValue) => {
65676
65680
  resolve2(ctx, {
65677
65681
  data: newValue,
@@ -65700,12 +65704,17 @@ var query = documentPlugin(ArtifactKind.Query, function() {
65700
65704
  // src/runtime/client/plugins/fragment.ts
65701
65705
  var fragment = documentPlugin(ArtifactKind.Fragment, function() {
65702
65706
  let subscriptionSpec = null;
65707
+ let lastReference = null;
65703
65708
  return {
65704
65709
  start(ctx, { next, resolve: resolve2, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
65705
65710
  if (!ctx.stuff.parentID) {
65706
65711
  return next(ctx);
65707
65712
  }
65708
- if (variablesChanged2(ctx) && !ctx.cacheParams?.disableSubscriptions) {
65713
+ const currentReference = {
65714
+ parent: ctx.stuff.parentID,
65715
+ variables: marshalVariables2(ctx)
65716
+ };
65717
+ if (!ctx.cacheParams?.disableSubscriptions && (!deepEquals(lastReference, currentReference) || variablesChanged2(ctx))) {
65709
65718
  if (subscriptionSpec) {
65710
65719
  cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
65711
65720
  }
@@ -65728,6 +65737,7 @@ var fragment = documentPlugin(ArtifactKind.Fragment, function() {
65728
65737
  }
65729
65738
  };
65730
65739
  cache_default.subscribe(subscriptionSpec, variables);
65740
+ lastReference = currentReference;
65731
65741
  }
65732
65742
  next(ctx);
65733
65743
  },
@@ -65928,6 +65938,7 @@ var DocumentStore = class extends Writable {
65928
65938
  #plugins;
65929
65939
  #lastVariables;
65930
65940
  #lastContext = null;
65941
+ pendingPromise = null;
65931
65942
  constructor({
65932
65943
  artifact,
65933
65944
  plugins: plugins2,
@@ -66000,7 +66011,7 @@ var DocumentStore = class extends Writable {
66000
66011
  const draft = context.draft();
66001
66012
  draft.variables = variables ?? null;
66002
66013
  context = context.apply(draft, false);
66003
- return await new Promise((resolve2, reject) => {
66014
+ const promise = new Promise((resolve2, reject) => {
66004
66015
  const state = {
66005
66016
  setup,
66006
66017
  currentStep: 0,
@@ -66009,12 +66020,17 @@ var DocumentStore = class extends Writable {
66009
66020
  promise: {
66010
66021
  resolved: false,
66011
66022
  resolve: resolve2,
66012
- reject
66023
+ reject,
66024
+ then: (...args) => promise.then(...args)
66013
66025
  },
66014
66026
  context
66015
66027
  };
66028
+ if (this.pendingPromise === null) {
66029
+ this.pendingPromise = state.promise;
66030
+ }
66016
66031
  this.#step("forward", state);
66017
66032
  });
66033
+ return await promise;
66018
66034
  }
66019
66035
  async cleanup() {
66020
66036
  for (const plugin2 of this.#plugins) {
@@ -66133,16 +66149,15 @@ var DocumentStore = class extends Writable {
66133
66149
  value
66134
66150
  );
66135
66151
  }
66152
+ if (!ctx.silenceEcho || value.data !== this.state.data) {
66153
+ this.set(value);
66154
+ }
66136
66155
  if (!ctx.promise.resolved) {
66137
66156
  ctx.promise.resolve(value);
66138
66157
  ctx.promise.resolved = true;
66139
66158
  }
66140
66159
  this.#lastContext = ctx.context.draft();
66141
66160
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
66142
- if (ctx.silenceEcho && value.data === this.state.data) {
66143
- return;
66144
- }
66145
- this.set(value);
66146
66161
  }
66147
66162
  };
66148
66163
  var ClientPluginContextWrapper = class {
@@ -66760,6 +66775,17 @@ var Config = class {
66760
66775
  }, []) ?? [];
66761
66776
  return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
66762
66777
  }
66778
+ needsRefetchArtifact(document) {
66779
+ let needsArtifact = false;
66780
+ graphql2.visit(document, {
66781
+ Directive: (node) => {
66782
+ if ([this.paginateDirective].includes(node.name.value)) {
66783
+ needsArtifact = true;
66784
+ }
66785
+ }
66786
+ });
66787
+ return needsArtifact;
66788
+ }
66763
66789
  #fragmentVariableMaps;
66764
66790
  registerFragmentVariablesHash({
66765
66791
  hash,
@@ -67255,13 +67281,40 @@ var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
67255
67281
 
67256
67282
  // src/lib/parse.ts
67257
67283
  var import_parser = __toESM(require_lib3(), 1);
67258
- async function parseJS(str) {
67284
+
67285
+ // src/lib/deepMerge.ts
67286
+ var import_deepmerge = __toESM(require_cjs(), 1);
67287
+ function deepMerge(filepath, ...targets) {
67288
+ try {
67289
+ if (targets.length === 1) {
67290
+ return targets[0];
67291
+ } else if (targets.length === 2) {
67292
+ return (0, import_deepmerge.default)(targets[0], targets[1], {
67293
+ arrayMerge: (source, update) => [...new Set(source.concat(update))]
67294
+ });
67295
+ }
67296
+ return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
67297
+ } catch (e2) {
67298
+ throw new HoudiniError({
67299
+ filepath,
67300
+ message: "could not merge: " + JSON.stringify(targets, null, 4),
67301
+ description: e2.message
67302
+ });
67303
+ }
67304
+ }
67305
+
67306
+ // src/lib/parse.ts
67307
+ async function parseJS(str, config) {
67308
+ const defaultConfig = {
67309
+ plugins: ["typescript"],
67310
+ sourceType: "module"
67311
+ };
67259
67312
  return {
67260
67313
  start: 0,
67261
- script: (0, import_parser.parse)(str || "", {
67262
- plugins: ["typescript"],
67263
- sourceType: "module"
67264
- }).program,
67314
+ script: (0, import_parser.parse)(
67315
+ str || "",
67316
+ config ? deepMerge("", defaultConfig, config) : defaultConfig
67317
+ ).program,
67265
67318
  end: str.length
67266
67319
  };
67267
67320
  }
@@ -67329,27 +67382,6 @@ async function cleanupFiles(pathFolder, listOfObj) {
67329
67382
  return allFilesNotInList;
67330
67383
  }
67331
67384
 
67332
- // src/lib/deepMerge.ts
67333
- var import_deepmerge = __toESM(require_cjs(), 1);
67334
- function deepMerge(filepath, ...targets) {
67335
- try {
67336
- if (targets.length === 1) {
67337
- return targets[0];
67338
- } else if (targets.length === 2) {
67339
- return (0, import_deepmerge.default)(targets[0], targets[1], {
67340
- arrayMerge: (source, update) => [...new Set(source.concat(update))]
67341
- });
67342
- }
67343
- return deepMerge(filepath, targets[0], deepMerge(filepath, ...targets.slice(1)));
67344
- } catch (e2) {
67345
- throw new HoudiniError({
67346
- filepath,
67347
- message: "could not merge: " + targets,
67348
- description: e2.message
67349
- });
67350
- }
67351
- }
67352
-
67353
67385
  // src/lib/detectTools.ts
67354
67386
  async function detectFromPackageJSON(cwd) {
67355
67387
  try {
@@ -5,6 +5,9 @@ import { Writable } from '../lib/store';
5
5
  import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
+ pendingPromise: {
9
+ then: (val: any) => void;
10
+ } | null;
8
11
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
9
12
  artifact: DocumentArtifact;
10
13
  plugins?: ClientHooks[];
@@ -3,7 +3,7 @@ import type { DocumentArtifact, GraphQLObject, NestedList } from '../lib/types';
3
3
  import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
- export { DocumentStore, type ClientPlugin } from './documentStore';
6
+ export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
7
7
  export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;
@@ -0,0 +1,7 @@
1
+ import type { GraphQLObject, PageInfo } from './types';
2
+ export declare function nullPageInfo(): PageInfo;
3
+ export declare function missingPageSizeError(fnName: string): {
4
+ message: string;
5
+ };
6
+ export declare function extractPageInfo(data: any, path: string[]): PageInfo;
7
+ export declare function countPage<_Data extends GraphQLObject>(source: string[], value: _Data | null): number;
@@ -0,0 +1,29 @@
1
+ import type { SendParams } from '../client/documentStore';
2
+ import { FetchParams } from './types';
3
+ import type { CursorHandlers, FetchFn, GraphQLObject, QueryArtifact, QueryResult } from './types';
4
+ export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends Record<string, any>>({ artifact, storeName, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, getSession, }: {
5
+ artifact: QueryArtifact;
6
+ storeName: string;
7
+ getState: () => _Data | null;
8
+ getVariables: () => _Input;
9
+ getSession: () => Promise<App.Session>;
10
+ fetch: FetchFn<_Data, _Input>;
11
+ fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
12
+ }): CursorHandlers<_Data, _Input>;
13
+ export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends {}>({ artifact, storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, getSession, }: {
14
+ artifact: QueryArtifact;
15
+ fetch: FetchFn<_Data, _Input>;
16
+ fetchUpdate: (arg: SendParams) => ReturnType<FetchFn<_Data, _Input>>;
17
+ storeName: string;
18
+ getState: () => _Data | null;
19
+ getVariables: () => _Input;
20
+ getSession: () => Promise<App.Session>;
21
+ }): {
22
+ loadNextPage: ({ limit, offset, fetch, metadata, }?: {
23
+ limit?: number | undefined;
24
+ offset?: number | undefined;
25
+ fetch?: typeof fetch | undefined;
26
+ metadata?: {} | undefined;
27
+ }) => Promise<void>;
28
+ fetch(params?: FetchParams<_Input>): Promise<QueryResult<_Data, _Input>>;
29
+ };
@@ -25,6 +25,7 @@ declare global {
25
25
  };
26
26
  optimisticResponse?: GraphQLObject;
27
27
  parentID?: string;
28
+ silenceLoading?: boolean;
28
29
  }
29
30
  }
30
31
  }
@@ -193,6 +194,51 @@ export type ValueOf<Parent> = Parent[keyof Parent];
193
194
  export declare const fragmentKey = " $fragments";
194
195
  export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
195
196
  export type ValueMap = Record<string, ValueNode>;
197
+ export type FetchParams<_Input> = {
198
+ variables?: _Input;
199
+ /**
200
+ * The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
201
+ * a request will always be sent, even if the variables are the same as the last call
202
+ * to fetch.
203
+ */
204
+ policy?: CachePolicies;
205
+ /**
206
+ * An object that will be passed to the fetch function.
207
+ * You can do what you want with it!
208
+ */
209
+ metadata?: App.Metadata;
210
+ };
211
+ export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: FetchParams<_Input>) => Promise<QueryResult<_Data, _Input>>;
212
+ export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
213
+ loadNextPage: (args?: {
214
+ first?: number;
215
+ after?: string;
216
+ fetch?: typeof globalThis.fetch;
217
+ metadata?: {};
218
+ }) => Promise<void>;
219
+ loadPreviousPage: (args?: {
220
+ last?: number;
221
+ before?: string;
222
+ fetch?: typeof globalThis.fetch;
223
+ metadata?: {};
224
+ }) => Promise<void>;
225
+ fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
226
+ };
227
+ export type OffsetHandlers<_Data extends GraphQLObject, _Input> = {
228
+ loadNextPage: (args?: {
229
+ limit?: number;
230
+ offset?: number;
231
+ metadata?: {};
232
+ fetch?: typeof globalThis.fetch;
233
+ }) => Promise<void>;
234
+ fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
235
+ };
236
+ export type PageInfo = {
237
+ startCursor: string | null;
238
+ endCursor: string | null;
239
+ hasNextPage: boolean;
240
+ hasPreviousPage: boolean;
241
+ };
196
242
  interface IntValueNode {
197
243
  readonly kind: 'IntValue';
198
244
  readonly value: string;
@@ -5,6 +5,9 @@ import { Writable } from '../lib/store';
5
5
  import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
+ pendingPromise: {
9
+ then: (val: any) => void;
10
+ } | null;
8
11
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
9
12
  artifact: DocumentArtifact;
10
13
  plugins?: ClientHooks[];
@@ -38,6 +38,7 @@ class DocumentStore extends import_store.Writable {
38
38
  #plugins;
39
39
  #lastVariables;
40
40
  #lastContext = null;
41
+ pendingPromise = null;
41
42
  constructor({
42
43
  artifact,
43
44
  plugins,
@@ -110,7 +111,7 @@ class DocumentStore extends import_store.Writable {
110
111
  const draft = context.draft();
111
112
  draft.variables = variables ?? null;
112
113
  context = context.apply(draft, false);
113
- return await new Promise((resolve, reject) => {
114
+ const promise = new Promise((resolve, reject) => {
114
115
  const state = {
115
116
  setup,
116
117
  currentStep: 0,
@@ -119,12 +120,17 @@ class DocumentStore extends import_store.Writable {
119
120
  promise: {
120
121
  resolved: false,
121
122
  resolve,
122
- reject
123
+ reject,
124
+ then: (...args) => promise.then(...args)
123
125
  },
124
126
  context
125
127
  };
128
+ if (this.pendingPromise === null) {
129
+ this.pendingPromise = state.promise;
130
+ }
126
131
  this.#step("forward", state);
127
132
  });
133
+ return await promise;
128
134
  }
129
135
  async cleanup() {
130
136
  for (const plugin of this.#plugins) {
@@ -243,16 +249,15 @@ class DocumentStore extends import_store.Writable {
243
249
  value
244
250
  );
245
251
  }
252
+ if (!ctx.silenceEcho || value.data !== this.state.data) {
253
+ this.set(value);
254
+ }
246
255
  if (!ctx.promise.resolved) {
247
256
  ctx.promise.resolve(value);
248
257
  ctx.promise.resolved = true;
249
258
  }
250
259
  this.#lastContext = ctx.context.draft();
251
260
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
252
- if (ctx.silenceEcho && value.data === this.state.data) {
253
- return;
254
- }
255
- this.set(value);
256
261
  }
257
262
  }
258
263
  class ClientPluginContextWrapper {
@@ -3,7 +3,7 @@ import type { DocumentArtifact, GraphQLObject, NestedList } from '../lib/types';
3
3
  import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
- export { DocumentStore, type ClientPlugin } from './documentStore';
6
+ export { DocumentStore, type ClientPlugin, type SendParams } from './documentStore';
7
7
  export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;