@query-farm/vgi 0.8.0 → 0.9.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.
package/dist/types.d.ts CHANGED
@@ -45,6 +45,10 @@ export declare const VGI_VARARGS_TRUE = "true";
45
45
  export declare const VGI_CONST_KEY = "vgi_const";
46
46
  export declare const VGI_CONST_TRUE = "true";
47
47
  export declare const VGI_DOC_KEY = "vgi_doc";
48
+ export declare const VGI_DEFAULT_KEY = "vgi_default";
49
+ export declare const VGI_CHOICES_KEY = "vgi_choices";
50
+ export declare const VGI_RANGE_KEY = "vgi_range";
51
+ export declare const VGI_PATTERN_KEY = "vgi_pattern";
48
52
  export interface TableCardinality {
49
53
  estimate: number | null;
50
54
  max: number | null;
@@ -2850,6 +2850,10 @@ var VGI_VARARGS_TRUE = "true";
2850
2850
  var VGI_CONST_KEY = "vgi_const";
2851
2851
  var VGI_CONST_TRUE = "true";
2852
2852
  var VGI_DOC_KEY = "vgi_doc";
2853
+ var VGI_DEFAULT_KEY = "vgi_default";
2854
+ var VGI_CHOICES_KEY = "vgi_choices";
2855
+ var VGI_RANGE_KEY = "vgi_range";
2856
+ var VGI_PATTERN_KEY = "vgi_pattern";
2853
2857
  var DEFAULT_MAX_WORKERS = 99999;
2854
2858
 
2855
2859
  // src/util/arrow/index.ts
@@ -6985,6 +6989,138 @@ function buildVgiProtocol(config) {
6985
6989
 
6986
6990
  // src/functions/scalar.ts
6987
6991
  init_arrow();
6992
+
6993
+ // src/arguments/argument-spec.ts
6994
+ init_arrow();
6995
+ function safeJson(value) {
6996
+ try {
6997
+ const encoded = JSON.stringify(value);
6998
+ if (encoded === undefined) {
6999
+ return JSON.stringify(String(value));
7000
+ }
7001
+ return encoded;
7002
+ } catch {
7003
+ return JSON.stringify(String(value));
7004
+ }
7005
+ }
7006
+ function formatRange(ge, le, gt, lt) {
7007
+ if (ge === undefined && le === undefined && gt === undefined && lt === undefined) {
7008
+ return;
7009
+ }
7010
+ let low;
7011
+ if (gt !== undefined) {
7012
+ low = `(${gt}`;
7013
+ } else if (ge !== undefined) {
7014
+ low = `[${ge}`;
7015
+ } else {
7016
+ low = "(-inf";
7017
+ }
7018
+ let high;
7019
+ if (lt !== undefined) {
7020
+ high = `${lt})`;
7021
+ } else if (le !== undefined) {
7022
+ high = `${le}]`;
7023
+ } else {
7024
+ high = "+inf)";
7025
+ }
7026
+ return `${low}, ${high}`;
7027
+ }
7028
+ function constraintSpecFields(constraints) {
7029
+ const fields = {};
7030
+ if (constraints === undefined)
7031
+ return fields;
7032
+ if ("default" in constraints && constraints.default !== undefined) {
7033
+ fields.defaultJson = safeJson(constraints.default);
7034
+ }
7035
+ if (constraints.choices !== undefined) {
7036
+ fields.choicesJson = safeJson([...constraints.choices]);
7037
+ }
7038
+ const range = formatRange(constraints.ge, constraints.le, constraints.gt, constraints.lt);
7039
+ if (range !== undefined) {
7040
+ fields.rangeNotation = range;
7041
+ }
7042
+ if (constraints.pattern !== undefined) {
7043
+ fields.pattern = constraints.pattern;
7044
+ }
7045
+ return fields;
7046
+ }
7047
+ function argumentSpecSortKey(spec) {
7048
+ if (typeof spec.position === "number") {
7049
+ return [0, spec.position];
7050
+ }
7051
+ return [1, spec.position];
7052
+ }
7053
+ function argumentSpecsToSchema(specs) {
7054
+ const sorted = [...specs].sort((a, b) => {
7055
+ const ka = argumentSpecSortKey(a);
7056
+ const kb = argumentSpecSortKey(b);
7057
+ if (ka[0] !== kb[0])
7058
+ return ka[0] - kb[0];
7059
+ if (typeof ka[1] === "number" && typeof kb[1] === "number") {
7060
+ return ka[1] - kb[1];
7061
+ }
7062
+ return String(ka[1]).localeCompare(String(kb[1]));
7063
+ });
7064
+ const fields = [];
7065
+ for (const spec of sorted) {
7066
+ const metadata = new Map;
7067
+ if (typeof spec.position === "string") {
7068
+ metadata.set(VGI_ARG_KEY, VGI_ARG_NAMED);
7069
+ }
7070
+ if (spec.isTableInput) {
7071
+ metadata.set(VGI_TYPE_KEY, VGI_TYPE_TABLE);
7072
+ } else if (spec.isAnyType) {
7073
+ metadata.set(VGI_TYPE_KEY, VGI_TYPE_ANY);
7074
+ }
7075
+ if (spec.isVarargs) {
7076
+ metadata.set(VGI_VARARGS_KEY, VGI_VARARGS_TRUE);
7077
+ }
7078
+ if (spec.isConst) {
7079
+ metadata.set(VGI_CONST_KEY, VGI_CONST_TRUE);
7080
+ }
7081
+ if (spec.doc) {
7082
+ metadata.set(VGI_DOC_KEY, spec.doc);
7083
+ }
7084
+ if (spec.defaultJson !== undefined) {
7085
+ metadata.set(VGI_DEFAULT_KEY, spec.defaultJson);
7086
+ }
7087
+ if (spec.choicesJson !== undefined) {
7088
+ metadata.set(VGI_CHOICES_KEY, spec.choicesJson);
7089
+ }
7090
+ if (spec.rangeNotation !== undefined) {
7091
+ metadata.set(VGI_RANGE_KEY, spec.rangeNotation);
7092
+ }
7093
+ if (spec.pattern !== undefined) {
7094
+ metadata.set(VGI_PATTERN_KEY, spec.pattern);
7095
+ }
7096
+ const field3 = field2(spec.name, spec.arrowType, true, metadata.size > 0 ? metadata : undefined);
7097
+ fields.push(field3);
7098
+ }
7099
+ return schema2(fields);
7100
+ }
7101
+ function macroArgumentsSchema(parameters, parameterDefaultValues, parameterDocs) {
7102
+ const docs = parameterDocs ?? {};
7103
+ const defaultTypes = new Map;
7104
+ if (parameterDefaultValues && parameterDefaultValues.length > 0) {
7105
+ const batch = deserializeBatch(parameterDefaultValues);
7106
+ for (const f of batch.schema.fields) {
7107
+ defaultTypes.set(f.name, f.type);
7108
+ }
7109
+ }
7110
+ const fields = [];
7111
+ for (const name of parameters) {
7112
+ const metadata = new Map;
7113
+ const doc = docs[name];
7114
+ if (doc) {
7115
+ metadata.set(VGI_DOC_KEY, doc);
7116
+ }
7117
+ const fieldType = defaultTypes.get(name) ?? nullType2();
7118
+ fields.push(field2(name, fieldType, true, metadata.size > 0 ? metadata : undefined));
7119
+ }
7120
+ return schema2(fields);
7121
+ }
7122
+
7123
+ // src/functions/scalar.ts
6988
7124
  function defineScalarFunction(config) {
6989
7125
  const repr = config.repr ?? "rich";
6990
7126
  const specs = [];
@@ -6998,7 +7134,8 @@ function defineScalarFunction(config) {
6998
7134
  isAnyType: isAny,
6999
7135
  isConst: p.const,
7000
7136
  isVarargs: p.varargs,
7001
- doc: p.doc
7137
+ doc: p.doc,
7138
+ ...constraintSpecFields(p)
7002
7139
  });
7003
7140
  }
7004
7141
  } else {
@@ -7567,72 +7704,6 @@ function defineTableInOutFunction(config) {
7567
7704
  // src/catalog/read-only.ts
7568
7705
  init_arrow();
7569
7706
 
7570
- // src/arguments/argument-spec.ts
7571
- init_arrow();
7572
- function argumentSpecSortKey(spec) {
7573
- if (typeof spec.position === "number") {
7574
- return [0, spec.position];
7575
- }
7576
- return [1, spec.position];
7577
- }
7578
- function argumentSpecsToSchema(specs) {
7579
- const sorted = [...specs].sort((a, b) => {
7580
- const ka = argumentSpecSortKey(a);
7581
- const kb = argumentSpecSortKey(b);
7582
- if (ka[0] !== kb[0])
7583
- return ka[0] - kb[0];
7584
- if (typeof ka[1] === "number" && typeof kb[1] === "number") {
7585
- return ka[1] - kb[1];
7586
- }
7587
- return String(ka[1]).localeCompare(String(kb[1]));
7588
- });
7589
- const fields = [];
7590
- for (const spec of sorted) {
7591
- const metadata = new Map;
7592
- if (typeof spec.position === "string") {
7593
- metadata.set(VGI_ARG_KEY, VGI_ARG_NAMED);
7594
- }
7595
- if (spec.isTableInput) {
7596
- metadata.set(VGI_TYPE_KEY, VGI_TYPE_TABLE);
7597
- } else if (spec.isAnyType) {
7598
- metadata.set(VGI_TYPE_KEY, VGI_TYPE_ANY);
7599
- }
7600
- if (spec.isVarargs) {
7601
- metadata.set(VGI_VARARGS_KEY, VGI_VARARGS_TRUE);
7602
- }
7603
- if (spec.isConst) {
7604
- metadata.set(VGI_CONST_KEY, VGI_CONST_TRUE);
7605
- }
7606
- if (spec.doc) {
7607
- metadata.set(VGI_DOC_KEY, spec.doc);
7608
- }
7609
- const field3 = field2(spec.name, spec.arrowType, true, metadata.size > 0 ? metadata : undefined);
7610
- fields.push(field3);
7611
- }
7612
- return schema2(fields);
7613
- }
7614
- function macroArgumentsSchema(parameters, parameterDefaultValues, parameterDocs) {
7615
- const docs = parameterDocs ?? {};
7616
- const defaultTypes = new Map;
7617
- if (parameterDefaultValues && parameterDefaultValues.length > 0) {
7618
- const batch = deserializeBatch(parameterDefaultValues);
7619
- for (const f of batch.schema.fields) {
7620
- defaultTypes.set(f.name, f.type);
7621
- }
7622
- }
7623
- const fields = [];
7624
- for (const name of parameters) {
7625
- const metadata = new Map;
7626
- const doc = docs[name];
7627
- if (doc) {
7628
- metadata.set(VGI_DOC_KEY, doc);
7629
- }
7630
- const fieldType = defaultTypes.get(name) ?? nullType2();
7631
- fields.push(field2(name, fieldType, true, metadata.size > 0 ? metadata : undefined));
7632
- }
7633
- return schema2(fields);
7634
- }
7635
-
7636
7707
  // src/metadata/resolve.ts
7637
7708
  init_arrow();
7638
7709
  function arrowTypeToName(type) {
@@ -8792,4 +8863,4 @@ export {
8792
8863
  Arguments
8793
8864
  };
8794
8865
 
8795
- //# debugId=0568832FD569353D64756E2164756E21
8866
+ //# debugId=5A27AF075D6D5AD464756E2164756E21