@gemina/sdk 0.3.1 → 0.4.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/index.cjs CHANGED
@@ -6623,11 +6623,70 @@ function RetrievalFiltersDTOToJSONTyped(value, ignoreDiscriminator = false) {
6623
6623
  };
6624
6624
  }
6625
6625
 
6626
+ // src/generated/models/Value.ts
6627
+ function instanceOfValue(value) {
6628
+ return true;
6629
+ }
6630
+ function ValueFromJSON(json) {
6631
+ return ValueFromJSONTyped(json, false);
6632
+ }
6633
+ function ValueFromJSONTyped(json, ignoreDiscriminator) {
6634
+ return json;
6635
+ }
6636
+ function ValueToJSON(json) {
6637
+ return ValueToJSONTyped(json, false);
6638
+ }
6639
+ function ValueToJSONTyped(value, ignoreDiscriminator = false) {
6640
+ return value;
6641
+ }
6642
+
6643
+ // src/generated/models/StructuredFilterDTO.ts
6644
+ var StructuredFilterDTOOpEnum = {
6645
+ Eq: "eq",
6646
+ Neq: "neq",
6647
+ Gt: "gt",
6648
+ Lt: "lt",
6649
+ Contains: "contains",
6650
+ Exists: "exists"
6651
+ };
6652
+ function instanceOfStructuredFilterDTO(value) {
6653
+ if (!("op" in value) || value["op"] === void 0) return false;
6654
+ if (!("path" in value) || value["path"] === void 0) return false;
6655
+ return true;
6656
+ }
6657
+ function StructuredFilterDTOFromJSON(json) {
6658
+ return StructuredFilterDTOFromJSONTyped(json, false);
6659
+ }
6660
+ function StructuredFilterDTOFromJSONTyped(json, ignoreDiscriminator) {
6661
+ if (json == null) {
6662
+ return json;
6663
+ }
6664
+ return {
6665
+ "op": json["op"],
6666
+ "path": json["path"],
6667
+ "value": json["value"] == null ? void 0 : ValueFromJSON(json["value"])
6668
+ };
6669
+ }
6670
+ function StructuredFilterDTOToJSON(json) {
6671
+ return StructuredFilterDTOToJSONTyped(json, false);
6672
+ }
6673
+ function StructuredFilterDTOToJSONTyped(value, ignoreDiscriminator = false) {
6674
+ if (value == null) {
6675
+ return value;
6676
+ }
6677
+ return {
6678
+ "op": value["op"],
6679
+ "path": value["path"],
6680
+ "value": ValueToJSON(value["value"])
6681
+ };
6682
+ }
6683
+
6626
6684
  // src/generated/models/AggregateMetricDTO.ts
6627
6685
  var AggregateMetricDTOFieldEnum = {
6628
6686
  TotalAmount: "total_amount",
6629
6687
  NetAmount: "net_amount",
6630
- VatAmount: "vat_amount"
6688
+ VatAmount: "vat_amount",
6689
+ MeasurableQuantity: "measurable_quantity"
6631
6690
  };
6632
6691
  var AggregateMetricDTOOpEnum = {
6633
6692
  Sum: "sum",
@@ -6676,7 +6735,8 @@ var RetrievalAggregateInDTOGroupByEnum = {
6676
6735
  PaymentMethod: "payment_method",
6677
6736
  EndUserId: "end_user_id",
6678
6737
  Month: "month",
6679
- Year: "year"
6738
+ Year: "year",
6739
+ MeasurableUom: "measurable_uom"
6680
6740
  };
6681
6741
  function instanceOfRetrievalAggregateInDTO(value) {
6682
6742
  if (!("metrics" in value) || value["metrics"] === void 0) return false;
@@ -6693,6 +6753,7 @@ function RetrievalAggregateInDTOFromJSONTyped(json, ignoreDiscriminator) {
6693
6753
  "filters": json["filters"] == null ? void 0 : RetrievalFiltersDTOFromJSON(json["filters"]),
6694
6754
  "groupBy": json["groupBy"] == null ? void 0 : json["groupBy"],
6695
6755
  "limit": json["limit"] == null ? void 0 : json["limit"],
6756
+ "lineFilters": json["lineFilters"] == null ? void 0 : json["lineFilters"].map(StructuredFilterDTOFromJSON),
6696
6757
  "metrics": json["metrics"].map(AggregateMetricDTOFromJSON)
6697
6758
  };
6698
6759
  }
@@ -6707,6 +6768,7 @@ function RetrievalAggregateInDTOToJSONTyped(value, ignoreDiscriminator = false)
6707
6768
  "filters": RetrievalFiltersDTOToJSON(value["filters"]),
6708
6769
  "groupBy": value["groupBy"],
6709
6770
  "limit": value["limit"],
6771
+ "lineFilters": value["lineFilters"] == null ? void 0 : value["lineFilters"].map(StructuredFilterDTOToJSON),
6710
6772
  "metrics": value["metrics"].map(AggregateMetricDTOToJSON)
6711
6773
  };
6712
6774
  }
@@ -6772,7 +6834,9 @@ function AggregateMetaDTOFromJSONTyped(json, ignoreDiscriminator) {
6772
6834
  return {
6773
6835
  "count": json["count"],
6774
6836
  "currencyGroupingAdded": json["currencyGroupingAdded"] == null ? void 0 : json["currencyGroupingAdded"],
6775
- "duplicatesIgnored": json["duplicatesIgnored"] == null ? void 0 : json["duplicatesIgnored"]
6837
+ "duplicatesIgnored": json["duplicatesIgnored"] == null ? void 0 : json["duplicatesIgnored"],
6838
+ "linesWithoutUnitData": json["linesWithoutUnitData"] == null ? void 0 : json["linesWithoutUnitData"],
6839
+ "uomGroupingAdded": json["uomGroupingAdded"] == null ? void 0 : json["uomGroupingAdded"]
6776
6840
  };
6777
6841
  }
6778
6842
  function AggregateMetaDTOToJSON(json) {
@@ -6785,7 +6849,9 @@ function AggregateMetaDTOToJSONTyped(value, ignoreDiscriminator = false) {
6785
6849
  return {
6786
6850
  "count": value["count"],
6787
6851
  "currencyGroupingAdded": value["currencyGroupingAdded"],
6788
- "duplicatesIgnored": value["duplicatesIgnored"]
6852
+ "duplicatesIgnored": value["duplicatesIgnored"],
6853
+ "linesWithoutUnitData": value["linesWithoutUnitData"],
6854
+ "uomGroupingAdded": value["uomGroupingAdded"]
6789
6855
  };
6790
6856
  }
6791
6857
 
@@ -6894,64 +6960,6 @@ function RetrievalFieldsOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
6894
6960
  };
6895
6961
  }
6896
6962
 
6897
- // src/generated/models/Value.ts
6898
- function instanceOfValue(value) {
6899
- return true;
6900
- }
6901
- function ValueFromJSON(json) {
6902
- return ValueFromJSONTyped(json, false);
6903
- }
6904
- function ValueFromJSONTyped(json, ignoreDiscriminator) {
6905
- return json;
6906
- }
6907
- function ValueToJSON(json) {
6908
- return ValueToJSONTyped(json, false);
6909
- }
6910
- function ValueToJSONTyped(value, ignoreDiscriminator = false) {
6911
- return value;
6912
- }
6913
-
6914
- // src/generated/models/StructuredFilterDTO.ts
6915
- var StructuredFilterDTOOpEnum = {
6916
- Eq: "eq",
6917
- Neq: "neq",
6918
- Gt: "gt",
6919
- Lt: "lt",
6920
- Contains: "contains",
6921
- Exists: "exists"
6922
- };
6923
- function instanceOfStructuredFilterDTO(value) {
6924
- if (!("op" in value) || value["op"] === void 0) return false;
6925
- if (!("path" in value) || value["path"] === void 0) return false;
6926
- return true;
6927
- }
6928
- function StructuredFilterDTOFromJSON(json) {
6929
- return StructuredFilterDTOFromJSONTyped(json, false);
6930
- }
6931
- function StructuredFilterDTOFromJSONTyped(json, ignoreDiscriminator) {
6932
- if (json == null) {
6933
- return json;
6934
- }
6935
- return {
6936
- "op": json["op"],
6937
- "path": json["path"],
6938
- "value": json["value"] == null ? void 0 : ValueFromJSON(json["value"])
6939
- };
6940
- }
6941
- function StructuredFilterDTOToJSON(json) {
6942
- return StructuredFilterDTOToJSONTyped(json, false);
6943
- }
6944
- function StructuredFilterDTOToJSONTyped(value, ignoreDiscriminator = false) {
6945
- if (value == null) {
6946
- return value;
6947
- }
6948
- return {
6949
- "op": value["op"],
6950
- "path": value["path"],
6951
- "value": ValueToJSON(value["value"])
6952
- };
6953
- }
6954
-
6955
6963
  // src/generated/models/RetrievalQueryInDTO.ts
6956
6964
  var RetrievalQueryInDTOModeEnum = {
6957
6965
  Structured: "structured",
@@ -10067,6 +10075,51 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
10067
10075
  ResponseStatus.Empty,
10068
10076
  ResponseStatus.Failed
10069
10077
  ]);
10078
+ var FTYP_BRAND_FORMATS = {
10079
+ heic: { ext: ".heic", type: "image/heic" },
10080
+ heix: { ext: ".heic", type: "image/heic" },
10081
+ mif1: { ext: ".heif", type: "image/heif" },
10082
+ heim: { ext: ".heif", type: "image/heif" },
10083
+ heis: { ext: ".heif", type: "image/heif" },
10084
+ avif: { ext: ".avif", type: "image/avif" },
10085
+ // avis (animated AVIF) is deliberately mapped, unlike the HEIF sequence
10086
+ // brands: the API accepts animated AVIF and processes its first frame.
10087
+ avis: { ext: ".avif", type: "image/avif" }
10088
+ };
10089
+ function sniffFormat(bytes) {
10090
+ const ascii = (start, end) => bytes.length >= end ? String.fromCharCode(...bytes.subarray(start, end)) : "";
10091
+ if (ascii(0, 4) === "%PDF") return { ext: ".pdf", type: "application/pdf" };
10092
+ if (bytes[0] === 137 && ascii(1, 4) === "PNG") return { ext: ".png", type: "image/png" };
10093
+ if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255) {
10094
+ return { ext: ".jpg", type: "image/jpeg" };
10095
+ }
10096
+ if (ascii(0, 4) === "GIF8") return { ext: ".gif", type: "image/gif" };
10097
+ if (ascii(0, 4) === "RIFF" && ascii(8, 12) === "WEBP") {
10098
+ return { ext: ".webp", type: "image/webp" };
10099
+ }
10100
+ if (ascii(4, 8) === "ftyp") return FTYP_BRAND_FORMATS[ascii(8, 12)];
10101
+ return void 0;
10102
+ }
10103
+ function hasUsefulType(type) {
10104
+ return type !== "" && type !== "application/octet-stream";
10105
+ }
10106
+ async function normalizeBlobSource(source) {
10107
+ if (typeof File === "undefined") {
10108
+ return source;
10109
+ }
10110
+ const isFile = source instanceof File;
10111
+ if (isFile && hasUsefulType(source.type)) {
10112
+ return source;
10113
+ }
10114
+ const head = new Uint8Array(await source.slice(0, 32).arrayBuffer());
10115
+ const sniffed = sniffFormat(head);
10116
+ if (sniffed === void 0) {
10117
+ return source;
10118
+ }
10119
+ const name = isFile && source.name !== "" ? source.name : `document${sniffed.ext}`;
10120
+ const type = hasUsefulType(source.type) ? source.type : sniffed.type;
10121
+ return new File([source], name, { type });
10122
+ }
10070
10123
  function defaultSleep(seconds) {
10071
10124
  return new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
10072
10125
  }
@@ -10231,7 +10284,7 @@ var GeminaClient = class _GeminaClient {
10231
10284
  if (typeof Blob !== "undefined" && source instanceof Blob) {
10232
10285
  try {
10233
10286
  submitted = await this.documents.createDocumentProcessingRequest({
10234
- file: source,
10287
+ file: await normalizeBlobSource(source),
10235
10288
  externalId,
10236
10289
  extractionTypes,
10237
10290
  templateId: options.templateId,
@@ -10352,7 +10405,7 @@ async function asProcessingErrorIfFailedResult(error) {
10352
10405
  }
10353
10406
 
10354
10407
  // src/version.ts
10355
- var VERSION = "0.3.1";
10408
+ var VERSION = "0.4.0";
10356
10409
  // Annotate the CommonJS export names for ESM import in node:
10357
10410
  0 && (module.exports = {
10358
10411
  AggregateMetaDTOFromJSON,