@granular-software/sdk 0.4.26 → 0.4.28

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.mjs CHANGED
@@ -4907,9 +4907,24 @@ var Session = class {
4907
4907
  * Get domain documentation for LLMs. Returns types (preferred) or fallback.
4908
4908
  */
4909
4909
  async getDomainDocumentation() {
4910
- const types = await this.getDomainTypes();
4911
- if (types && (types.includes("export declare class") || types.includes("export async function"))) {
4912
- return types;
4910
+ const [types, docs] = await Promise.all([
4911
+ this.getDomainTypes(),
4912
+ this.getDomainDocs()
4913
+ ]);
4914
+ const normalizedTypes = types.trim();
4915
+ const normalizedDocs = docs.trim();
4916
+ if (normalizedTypes && (normalizedTypes.includes("export declare class") || normalizedTypes.includes("export async function"))) {
4917
+ if (!normalizedDocs) {
4918
+ return normalizedTypes;
4919
+ }
4920
+ return [
4921
+ normalizedTypes,
4922
+ "Generated usage notes from ./sandbox-tools docs:",
4923
+ normalizedDocs
4924
+ ].join("\n\n");
4925
+ }
4926
+ if (normalizedDocs) {
4927
+ return normalizedDocs;
4913
4928
  }
4914
4929
  const summary = await this.getDomain();
4915
4930
  return this.generateFallbackDocs(summary);
@@ -9719,10 +9734,15 @@ external_exports.union([
9719
9734
  scalarType: external_exports.string().optional()
9720
9735
  }).strict()
9721
9736
  ]);
9737
+ external_exports.union([
9738
+ external_exports.boolean(),
9739
+ external_exports.object({
9740
+ enabled: external_exports.boolean().optional(),
9741
+ phonetic: external_exports.boolean().optional()
9742
+ }).strict()
9743
+ ]);
9722
9744
  external_exports.object({
9723
- operator: external_exports.enum(
9724
- [...VALIDATION_RULE_OPERATORS]
9725
- ),
9745
+ operator: external_exports.enum([...VALIDATION_RULE_OPERATORS]),
9726
9746
  stringValue: external_exports.string().optional(),
9727
9747
  numberValue: external_exports.number().optional(),
9728
9748
  booleanValue: external_exports.boolean().optional(),
@@ -9815,12 +9835,18 @@ function collectMetamodelSummarySelections(packages) {
9815
9835
  const propertyFields = [];
9816
9836
  const methodFields = [];
9817
9837
  for (const metamodelPackage of packages) {
9818
- pushUnique(classFields, metamodelPackage.summary.selections?.classFields || []);
9838
+ pushUnique(
9839
+ classFields,
9840
+ metamodelPackage.summary.selections?.classFields || []
9841
+ );
9819
9842
  pushUnique(
9820
9843
  propertyFields,
9821
9844
  metamodelPackage.summary.selections?.propertyFields || []
9822
9845
  );
9823
- pushUnique(methodFields, metamodelPackage.summary.selections?.methodFields || []);
9846
+ pushUnique(
9847
+ methodFields,
9848
+ metamodelPackage.summary.selections?.methodFields || []
9849
+ );
9824
9850
  }
9825
9851
  return {
9826
9852
  classFields: unique(classFields),
@@ -9908,7 +9934,11 @@ function createMetamodelRegistry(metamodelPackages) {
9908
9934
  return collectMetamodelSummarySelections(packages);
9909
9935
  },
9910
9936
  applyClassSummaryReaders(rawClass, classSummary) {
9911
- return applyMetamodelSummaryReadersToClass(packages, rawClass, classSummary);
9937
+ return applyMetamodelSummaryReadersToClass(
9938
+ packages,
9939
+ rawClass,
9940
+ classSummary
9941
+ );
9912
9942
  },
9913
9943
  applyPropertySummaryReaders(rawProperty, propertySummary) {
9914
9944
  return applyMetamodelSummaryReadersToProperty(
@@ -9918,7 +9948,11 @@ function createMetamodelRegistry(metamodelPackages) {
9918
9948
  );
9919
9949
  },
9920
9950
  applyMethodSummaryReaders(rawMethod, methodSummary) {
9921
- return applyMetamodelSummaryReadersToMethod(packages, rawMethod, methodSummary);
9951
+ return applyMetamodelSummaryReadersToMethod(
9952
+ packages,
9953
+ rawMethod,
9954
+ methodSummary
9955
+ );
9922
9956
  },
9923
9957
  applyClassIR(classIR, classSummary) {
9924
9958
  return applyMetamodelClassIR(packages, classIR, classSummary);
@@ -9966,6 +10000,10 @@ function mergeClassSummaryPatch(target, patch) {
9966
10000
  }
9967
10001
  function mergePropertySummaryPatch(target, patch) {
9968
10002
  pushUnique(target.notes, patch.notes || []);
10003
+ if (patch.searchable !== void 0) target.searchable = patch.searchable;
10004
+ if (patch.searchablePhonetic !== void 0) {
10005
+ target.searchablePhonetic = patch.searchablePhonetic;
10006
+ }
9969
10007
  if (patch.required !== void 0) target.required = patch.required;
9970
10008
  if (patch.enumRule !== void 0) target.enumRule = patch.enumRule;
9971
10009
  if (patch.filterBy !== void 0) target.filterBy = patch.filterBy;
@@ -9977,9 +10015,11 @@ function mergeMethodSummaryPatch(target, patch) {
9977
10015
  if (patch.effectKey !== void 0) target.effectKey = patch.effectKey;
9978
10016
  if (patch.description !== void 0) target.description = patch.description;
9979
10017
  if (patch.inputSchema !== void 0) target.inputSchema = patch.inputSchema;
9980
- if (patch.outputSchema !== void 0) target.outputSchema = patch.outputSchema;
10018
+ if (patch.outputSchema !== void 0)
10019
+ target.outputSchema = patch.outputSchema;
9981
10020
  if (patch.metamodels !== void 0) target.metamodels = patch.metamodels;
9982
- if (patch.effectBehaviors !== void 0) target.effectBehaviors = patch.effectBehaviors;
10021
+ if (patch.effectBehaviors !== void 0)
10022
+ target.effectBehaviors = patch.effectBehaviors;
9983
10023
  if (patch.static !== void 0) target.static = patch.static;
9984
10024
  }
9985
10025
  function toPascalCase(value) {
@@ -10485,12 +10525,20 @@ function defaultFilterOperators(scalarType) {
10485
10525
  switch ((scalarType || "").toLowerCase()) {
10486
10526
  case "number":
10487
10527
  case "date":
10488
- return ["equal_to", "greater_than", "less_than", "not_null"];
10528
+ return [
10529
+ "equal_to",
10530
+ "greater_than",
10531
+ "greater_than_or_equal_to",
10532
+ "less_than",
10533
+ "less_than_or_equal_to",
10534
+ "not_null"
10535
+ ];
10489
10536
  case "boolean":
10490
- return ["equal_to", "not_null"];
10537
+ return ["equal_to", "true", "false", "not_null"];
10491
10538
  default:
10492
10539
  return [
10493
10540
  "equal_to",
10541
+ "in",
10494
10542
  "contains",
10495
10543
  "not_contains",
10496
10544
  "starts_with",
@@ -10499,16 +10547,26 @@ function defaultFilterOperators(scalarType) {
10499
10547
  ];
10500
10548
  }
10501
10549
  }
10550
+ function supportsDefaultFilterBy(scalarType) {
10551
+ return ["string", "number", "boolean", "date"].includes(
10552
+ String(scalarType || "").toLowerCase()
10553
+ );
10554
+ }
10502
10555
  function normalizeFilterByInput(filterBy, scalarType) {
10503
- if (!filterBy) return null;
10556
+ if (filterBy === false) return null;
10557
+ if (filterBy === void 0) {
10558
+ if (!supportsDefaultFilterBy(scalarType)) return null;
10559
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10560
+ }
10504
10561
  if (filterBy === true) {
10505
- return { operators: defaultFilterOperators(scalarType) };
10562
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10506
10563
  }
10507
10564
  if (Array.isArray(filterBy)) {
10508
- return { operators: filterBy };
10565
+ return { operators: filterBy, scalarType };
10509
10566
  }
10510
10567
  return {
10511
- operators: filterBy.operators
10568
+ operators: filterBy.operators,
10569
+ scalarType: filterBy.scalarType || scalarType
10512
10570
  };
10513
10571
  }
10514
10572
  function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
@@ -10519,7 +10577,7 @@ function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
10519
10577
  label: `set filterBy on ${fieldPath}`,
10520
10578
  query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_filter_by(operators: ${JSON.stringify(
10521
10579
  normalized.operators
10522
- )}) { operators } } }`
10580
+ )}${normalized.scalarType ? `, scalar_type: ${JSON.stringify(normalized.scalarType)}` : ""}) { operators } } }`
10523
10581
  }
10524
10582
  ];
10525
10583
  }
@@ -10529,7 +10587,7 @@ var filterByMetamodelPackage = defineMetamodelPackage({
10529
10587
  fieldRows: [
10530
10588
  {
10531
10589
  key: "filterBy",
10532
- description: "Exposes filter operators for generated query surfaces. Accepts `true`, an operator array, or `{ operators, scalarType }`."
10590
+ description: "Exposes filter operators for generated query surfaces. Scalar fields are filterable by default; set `filterBy: false` to opt out, or override with `true`, an operator array, or `{ operators, scalarType }`."
10533
10591
  }
10534
10592
  ]
10535
10593
  },
@@ -10793,6 +10851,123 @@ var requiredMetamodelPackage = defineMetamodelPackage({
10793
10851
  }
10794
10852
  });
10795
10853
 
10854
+ // ../metamodel-searchable/src/index.ts
10855
+ function supportsDefaultSearchable(scalarType) {
10856
+ return String(scalarType || "").toLowerCase() === "string";
10857
+ }
10858
+ function normalizeSearchableInput(searchable, scalarType) {
10859
+ if (!supportsDefaultSearchable(scalarType)) return null;
10860
+ if (typeof searchable === "boolean" || searchable === void 0) {
10861
+ return {
10862
+ enabled: searchable !== false,
10863
+ phonetic: false
10864
+ };
10865
+ }
10866
+ const enabled = searchable.enabled !== false;
10867
+ return {
10868
+ enabled,
10869
+ phonetic: enabled && searchable.phonetic === true
10870
+ };
10871
+ }
10872
+ function buildSearchableFieldMutations(fieldPath, searchable, scalarType) {
10873
+ const normalized = normalizeSearchableInput(searchable, scalarType);
10874
+ if (normalized === null) return [];
10875
+ return [
10876
+ {
10877
+ label: `set searchable on ${fieldPath}`,
10878
+ query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_searchable(enabled: ${normalized.enabled}, phonetic: ${normalized.phonetic}) { enabled phonetic } } }`
10879
+ }
10880
+ ];
10881
+ }
10882
+ var searchableMetamodelPackage = defineMetamodelPackage({
10883
+ id: "searchable",
10884
+ docs: {
10885
+ fieldRows: [
10886
+ {
10887
+ key: "searchable",
10888
+ description: "Controls full-text search exposure for string fields. String fields are searchable by default; set `searchable: false` to opt out, or use `searchable: { phonetic: true }` to keep the field searchable while enabling FalkorDB phonetic matching for class-wide search."
10889
+ }
10890
+ ]
10891
+ },
10892
+ graphql: {
10893
+ typeDefs: [
10894
+ `
10895
+ type SearchableMetamodel {
10896
+ model: Model!
10897
+ enabled: Boolean!
10898
+ phonetic: Boolean!
10899
+ }
10900
+
10901
+ extend type Model {
10902
+ searchable: SearchableMetamodel
10903
+ }
10904
+
10905
+ extend type ModelMutation {
10906
+ set_searchable(enabled: Boolean!, phonetic: Boolean): SearchableMetamodel
10907
+ }
10908
+ `
10909
+ ],
10910
+ createResolvers({ run }) {
10911
+ return {
10912
+ SearchableMetamodel: {
10913
+ model: (value) => value.model,
10914
+ enabled: (value) => value.enabled !== false,
10915
+ phonetic: (value) => value.phonetic === true
10916
+ },
10917
+ Model: {
10918
+ searchable: async (ant) => await run(ant.searchable())
10919
+ },
10920
+ ModelMutation: {
10921
+ set_searchable: async (ant, { enabled, phonetic }) => {
10922
+ return {
10923
+ model: await run(ant.set_searchable(enabled, phonetic === true)),
10924
+ enabled,
10925
+ phonetic: phonetic === true
10926
+ };
10927
+ }
10928
+ }
10929
+ };
10930
+ }
10931
+ },
10932
+ manifest: {
10933
+ buildFieldMutations(fieldPath, spec) {
10934
+ return buildSearchableFieldMutations(
10935
+ fieldPath,
10936
+ spec.searchable,
10937
+ spec.type
10938
+ );
10939
+ }
10940
+ },
10941
+ summary: {
10942
+ selections: {
10943
+ propertyFields: [`searchable { enabled phonetic }`]
10944
+ },
10945
+ readPropertySummary(rawProperty) {
10946
+ if (typeof rawProperty.searchable?.enabled !== "boolean") {
10947
+ return {};
10948
+ }
10949
+ return {
10950
+ searchable: rawProperty.searchable.enabled,
10951
+ searchablePhonetic: rawProperty.searchable.phonetic === true
10952
+ };
10953
+ }
10954
+ },
10955
+ domain: {
10956
+ applyToPropertyIR(propertyIR, propertySummary) {
10957
+ if (String(propertySummary.type || "").toLowerCase() !== "string" || propertySummary.searchable === false) {
10958
+ return propertyIR;
10959
+ }
10960
+ return {
10961
+ ...propertyIR,
10962
+ docs: [
10963
+ ...propertyIR.docs,
10964
+ propertySummary.searchablePhonetic ? "Searchable via `search` using FalkorDB full-text query syntax with phonetic matching enabled." : "Searchable via `search` using FalkorDB full-text query syntax."
10965
+ ]
10966
+ };
10967
+ }
10968
+ }
10969
+ });
10970
+
10796
10971
  // ../metamodel-state-machine/src/index.ts
10797
10972
  function normalizeStateMachines(values) {
10798
10973
  return (values || []).map((machine) => {
@@ -11373,6 +11548,7 @@ var DEFAULT_METAMODEL_PACKAGES = [
11373
11548
  requiredMetamodelPackage,
11374
11549
  enumMetamodelPackage,
11375
11550
  filterByMetamodelPackage,
11551
+ searchableMetamodelPackage,
11376
11552
  validationRuleMetamodelPackage,
11377
11553
  stateMachineMetamodelPackage,
11378
11554
  effectBehaviorsMetamodelPackage