@nicia-ai/typegraph 0.11.0 → 0.11.1

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/dist/index.cjs CHANGED
@@ -579,6 +579,10 @@ function baseFieldBuilder(field2) {
579
579
  function stringField(field2) {
580
580
  return {
581
581
  ...baseFieldBuilder(field2),
582
+ gt: (value) => comparison("gt", field2, value),
583
+ gte: (value) => comparison("gte", field2, value),
584
+ lt: (value) => comparison("lt", field2, value),
585
+ lte: (value) => comparison("lte", field2, value),
582
586
  contains: (pattern) => stringOp("contains", field2, pattern),
583
587
  startsWith: (pattern) => stringOp("startsWith", field2, pattern),
584
588
  endsWith: (pattern) => stringOp("endsWith", field2, pattern),
@@ -4936,6 +4940,10 @@ var FieldAccessTracker = class {
4936
4940
  #fields = /* @__PURE__ */ new Map();
4937
4941
  record(alias, field2, isSystemField) {
4938
4942
  const key = `${alias}\0${field2}`;
4943
+ const existing = this.#fields.get(key);
4944
+ if (existing !== void 0 && existing.isSystemField && !isSystemField) {
4945
+ return;
4946
+ }
4939
4947
  this.#fields.set(key, { alias, field: field2, isSystemField });
4940
4948
  }
4941
4949
  getAccessedFields() {
@@ -6617,6 +6625,10 @@ var ExecutableQuery = class _ExecutableQuery {
6617
6625
  #recordOrderByFieldsForPagination(tracker) {
6618
6626
  for (const spec of this.#state.orderBy) {
6619
6627
  const field2 = spec.field;
6628
+ if (field2.path.length === 1 && field2.path[0] !== "props" && field2.jsonPointer === void 0) {
6629
+ tracker.record(field2.alias, field2.path[0], true);
6630
+ continue;
6631
+ }
6620
6632
  if (field2.path.length !== 1 || field2.path[0] !== "props") {
6621
6633
  return false;
6622
6634
  }
@@ -6657,7 +6669,19 @@ var ExecutableQuery = class _ExecutableQuery {
6657
6669
  const alias = spec.field.alias;
6658
6670
  const jsonPointer2 = spec.field.jsonPointer;
6659
6671
  if (jsonPointer2 === void 0) {
6660
- throw new MissingSelectiveFieldError(alias, "orderBy");
6672
+ if (spec.field.path.length !== 1) {
6673
+ throw new MissingSelectiveFieldError(alias, "orderBy");
6674
+ }
6675
+ const fieldName = spec.field.path[0];
6676
+ const outputName2 = outputNameByAliasField.get(
6677
+ `${alias}\0${fieldName}`
6678
+ );
6679
+ if (outputName2 === void 0) {
6680
+ throw new MissingSelectiveFieldError(alias, fieldName);
6681
+ }
6682
+ const aliasObject2 = this.#getOrCreateAliasObject(cursorContext, alias);
6683
+ aliasObject2[fieldName] = nullToUndefined2(row[outputName2]);
6684
+ continue;
6661
6685
  }
6662
6686
  const segments = chunkP5CNM325_cjs.parseJsonPointer(jsonPointer2);
6663
6687
  if (segments.length === 0) {
@@ -6680,14 +6704,7 @@ var ExecutableQuery = class _ExecutableQuery {
6680
6704
  continue;
6681
6705
  }
6682
6706
  }
6683
- let aliasObject;
6684
- const existing = cursorContext[alias];
6685
- if (typeof existing === "object" && existing !== null) {
6686
- aliasObject = existing;
6687
- } else {
6688
- aliasObject = {};
6689
- cursorContext[alias] = aliasObject;
6690
- }
6707
+ const aliasObject = this.#getOrCreateAliasObject(cursorContext, alias);
6691
6708
  const kindNames = this.#getNodeKindNamesForAlias(alias);
6692
6709
  const typeInfo = kindNames ? this.#config.schemaIntrospector.getSharedFieldTypeInfo(
6693
6710
  kindNames,
@@ -6714,6 +6731,15 @@ var ExecutableQuery = class _ExecutableQuery {
6714
6731
  }
6715
6732
  return cursorContext;
6716
6733
  }
6734
+ #getOrCreateAliasObject(cursorContext, alias) {
6735
+ const existing = cursorContext[alias];
6736
+ if (typeof existing === "object" && existing !== null) {
6737
+ return existing;
6738
+ }
6739
+ const created = {};
6740
+ cursorContext[alias] = created;
6741
+ return created;
6742
+ }
6717
6743
  #getNodeKindNamesForAlias(alias) {
6718
6744
  if (alias === this.#state.startAlias) {
6719
6745
  return this.#state.startKinds;
@@ -7541,9 +7567,12 @@ var QueryBuilder = class _QueryBuilder {
7541
7567
  * Orders results.
7542
7568
  */
7543
7569
  orderBy(alias, field2, direction = "asc") {
7544
- const kindNames = this.#getKindNamesForAlias(alias);
7545
- const typeInfo = kindNames ? this.#config.schemaIntrospector.getSharedFieldTypeInfo(kindNames, field2) : void 0;
7546
- const orderSpec = {
7570
+ const isSystem = field2 === "id" || field2 === "kind";
7571
+ const typeInfo = isSystem ? void 0 : this.#getOrderByTypeInfo(alias, field2);
7572
+ const orderSpec = isSystem ? {
7573
+ field: fieldRef(alias, [field2], { valueType: "string" }),
7574
+ direction
7575
+ } : {
7547
7576
  field: fieldRef(alias, ["props"], {
7548
7577
  jsonPointer: chunkP5CNM325_cjs.jsonPointer([field2]),
7549
7578
  valueType: typeInfo?.valueType,
@@ -7557,6 +7586,10 @@ var QueryBuilder = class _QueryBuilder {
7557
7586
  };
7558
7587
  return new _QueryBuilder(this.#config, newState);
7559
7588
  }
7589
+ #getOrderByTypeInfo(alias, field2) {
7590
+ const kindNames = this.#getKindNamesForAlias(alias);
7591
+ return kindNames ? this.#config.schemaIntrospector.getSharedFieldTypeInfo(kindNames, field2) : void 0;
7592
+ }
7560
7593
  /**
7561
7594
  * Limits the number of results.
7562
7595
  */