abra-flexi 0.5.5 → 0.5.7

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
@@ -96,7 +96,7 @@ function parsePropertyValue(propertyType, annot, obj) {
96
96
  return new Date(parseInt(s[0], parseInt(s[1]) - 1));
97
97
  case PropertyType.Numeric: return new big_js.Big(obj).round(annot?.decimals ?? 2);
98
98
  case PropertyType.Logic: return obj.toLowerCase() === "true";
99
- case PropertyType.Blob: return Buffer.from(obj, "base64");
99
+ case PropertyType.Blob: return base64ToBytes(obj);
100
100
  case PropertyType.Array:
101
101
  if (!annot?.itemType) throw new AFError(AFErrorCode.ITEM_TYPE_MISSING, "itemType is required for Array");
102
102
  const myAnnot = { ...annot };
@@ -121,7 +121,7 @@ function serializePropertyValue(propertyType, annot, val) {
121
121
  if (val instanceof big_js.Big) return val.toString();
122
122
  return val;
123
123
  case PropertyType.Logic: return !!val ? "true" : "false";
124
- case PropertyType.Blob: return val.toString("base64");
124
+ case PropertyType.Blob: return bytesToBase64(val);
125
125
  case PropertyType.Array:
126
126
  if (!annot?.itemType) throw new AFError(AFErrorCode.ITEM_TYPE_MISSING, "itemType is required for Array");
127
127
  const myAnnot = { ...annot };
@@ -146,6 +146,22 @@ function dateToLocalIso(date) {
146
146
  const offset = -date.getTimezoneOffset();
147
147
  return `${yyyy}-${mm}-${dd}T${hh}:${mi}:${ss}.${ms}${offset >= 0 ? "+" : "-"}${pad(Math.floor(Math.abs(offset) / 60))}:${pad(Math.abs(offset) % 60)}`;
148
148
  }
149
+ function base64ToBytes(base64) {
150
+ if (typeof Buffer !== "undefined") {
151
+ const buf = Buffer.from(base64, "base64");
152
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
153
+ }
154
+ const binary = atob(base64);
155
+ const bytes = new Uint8Array(binary.length);
156
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
157
+ return bytes;
158
+ }
159
+ function bytesToBase64(bytes) {
160
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
161
+ let binary = "";
162
+ for (let i = 0; i < bytes.byteLength; i++) binary += String.fromCharCode(bytes[i]);
163
+ return btoa(binary);
164
+ }
149
165
  function arraysEqual(a, b) {
150
166
  if (a === b) return true;
151
167
  if (a.length !== b.length) return false;
@@ -66669,7 +66685,7 @@ var AFApiClient = class {
66669
66685
  const detail = options.detail || AFQueryDetail.SUMMARY;
66670
66686
  let furl = options.filter?.toUrlComponent();
66671
66687
  if (furl && !furl.length) furl = void 0;
66672
- let url = this._url + "/c/" + this.company + "/" + entityPath;
66688
+ let url = this._url + "/c/" + this.company + "/" + (options.entityPathPrefix ?? "") + entityPath;
66673
66689
  url += furl ? "/" + furl : "";
66674
66690
  url += "." + ABRA_API_FORMAT;
66675
66691
  url = addParamToUrl(url, "detail", composeDetail(detail));
@@ -66688,6 +66704,8 @@ var AFApiClient = class {
66688
66704
  url = addParamToUrl(url, "ucetniObdobi", options.ucetniObdobi);
66689
66705
  url = addParamToUrl(url, "koncovyMesicRok", options.koncovyMesicRok);
66690
66706
  url = addParamToUrl(url, "pocetMesicu", options.pocetMesicu);
66707
+ url = addParamToUrl(url, "date", options.date);
66708
+ url = addParamToUrl(url, "currency", options.currency);
66691
66709
  console.log(url);
66692
66710
  try {
66693
66711
  const raw$1 = await this._fetch(url, { signal: options.abortController?.signal });
@@ -66839,6 +66857,7 @@ var AFApiClient = class {
66839
66857
  let url = this._url + "/c/" + this.company + "/" + entityPath + ".json";
66840
66858
  console.log(url);
66841
66859
  console.log(data);
66860
+ if (options.removeStitky) data["stitky@removeAll"] = "true";
66842
66861
  try {
66843
66862
  const raw$1 = await this._fetch(url, {
66844
66863
  signal: options.abortController?.signal,
@@ -67012,6 +67031,7 @@ var AFApiClient = class {
67012
67031
  }
67013
67032
  if (!obj) return;
67014
67033
  obj[key] = serializePropertyValue(annot.type, annot, val);
67034
+ if (entity instanceof AFPriloha && key === "content") obj["content@encoding"] = "base64";
67015
67035
  }
67016
67036
  };
67017
67037