@resistdesign/voltra 3.0.0-alpha.7 → 3.0.0-alpha.8

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/api/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { D as DAC, a as Indexing, b as ORM, c as Routing } from '../index-DbLgMAxB.js';
1
+ export { D as DAC, a as Indexing, b as ORM, c as Routing } from '../index-t9LXRpCu.js';
2
2
  import '@aws-sdk/client-dynamodb';
3
3
  import '@aws-sdk/client-s3';
4
4
  import '../SearchTypes-DjN6YQzE.js';
package/api/index.js CHANGED
@@ -90,21 +90,48 @@ __export(Indexing_exports, {
90
90
  });
91
91
 
92
92
  // src/api/Indexing/cursor.ts
93
+ var textEncoder = new TextEncoder();
94
+ var textDecoder = new TextDecoder();
95
+ function base64UrlFromBytes(bytes) {
96
+ let base64;
97
+ if (typeof globalThis.Buffer !== "undefined") {
98
+ base64 = globalThis.Buffer.from(bytes).toString("base64");
99
+ } else {
100
+ let bin = "";
101
+ for (let i = 0; i < bytes.length; i += 1) {
102
+ bin += String.fromCharCode(bytes[i]);
103
+ }
104
+ base64 = btoa(bin);
105
+ }
106
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
107
+ }
108
+ function bytesFromBase64Url(input) {
109
+ const base64 = input.replace(/-/g, "+").replace(/_/g, "/");
110
+ const padded = base64.padEnd(
111
+ base64.length + (4 - base64.length % 4) % 4,
112
+ "="
113
+ );
114
+ if (typeof globalThis.Buffer !== "undefined") {
115
+ return new Uint8Array(globalThis.Buffer.from(padded, "base64"));
116
+ }
117
+ const bin = atob(padded);
118
+ const bytes = new Uint8Array(bin.length);
119
+ for (let i = 0; i < bin.length; i += 1) {
120
+ bytes[i] = bin.charCodeAt(i);
121
+ }
122
+ return bytes;
123
+ }
93
124
  function encodeCursor(payload) {
94
- return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
125
+ const json = JSON.stringify(payload);
126
+ const bytes = textEncoder.encode(json);
127
+ return base64UrlFromBytes(bytes);
95
128
  }
96
129
  function decodeCursor(cursor) {
97
- const base64 = cursor.replace(/-/g, "+").replace(/_/g, "/");
98
- const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
99
- let decoded;
100
- try {
101
- decoded = Buffer.from(padded, "base64").toString("utf8");
102
- } catch (error) {
103
- throw new Error("Invalid cursor encoding.");
104
- }
105
130
  try {
131
+ const bytes = bytesFromBase64Url(cursor);
132
+ const decoded = textDecoder.decode(bytes);
106
133
  return JSON.parse(decoded);
107
- } catch (error) {
134
+ } catch {
108
135
  throw new Error("Invalid cursor payload.");
109
136
  }
110
137
  }
@@ -128,7 +155,11 @@ function decodePlanner(payload) {
128
155
  if (!payload?.p) {
129
156
  return void 0;
130
157
  }
131
- return { primaryToken: payload.p, statsVersion: payload.sv, sorting: payload.s ?? "docIdAsc" };
158
+ return {
159
+ primaryToken: payload.p,
160
+ statsVersion: payload.sv,
161
+ sorting: payload.s ?? "docIdAsc"
162
+ };
132
163
  }
133
164
  function normalizeDocId(value) {
134
165
  if (value === void 0 || value === null) {
@@ -183,7 +214,12 @@ function encodeExactCursor(state) {
183
214
  }
184
215
  const plan = encodePlanner(state.plan);
185
216
  if (!plan && verificationPending === void 0 && verificationOffset === void 0) {
186
- return encodePayload({ v: 1, t: "exact", lossyLastDocId, verificationLastDocId });
217
+ return encodePayload({
218
+ v: 1,
219
+ t: "exact",
220
+ lossyLastDocId,
221
+ verificationLastDocId
222
+ });
187
223
  }
188
224
  return encodePayload({
189
225
  v: 3,
@@ -204,7 +240,9 @@ function decodeExactCursor(cursor) {
204
240
  throw new Error("Expected exact cursor payload.");
205
241
  }
206
242
  const payloadV3 = payload;
207
- const normalizedVerificationPending = normalizeDocIdList(payloadV3.verificationPending);
243
+ const normalizedVerificationPending = normalizeDocIdList(
244
+ payloadV3.verificationPending
245
+ );
208
246
  return {
209
247
  lossy: payload.lossyLastDocId === void 0 ? void 0 : { lastDocId: normalizeDocId(payload.lossyLastDocId) },
210
248
  verification: payload.verificationLastDocId === void 0 ? normalizedVerificationPending || payloadV3.verificationOffset !== void 0 ? {
@@ -475,7 +475,7 @@ declare function searchExact({ query, indexField, limit, cursor, backend, limits
475
475
  /**
476
476
  * The supported ordering strategy for cursors.
477
477
  * */
478
- type SortingStrategy = 'docIdAsc';
478
+ type SortingStrategy = "docIdAsc";
479
479
  /**
480
480
  * Cursor planner metadata used to resume searches efficiently.
481
481
  * */
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as API } from './index-DbLgMAxB.js';
1
+ export { i as API } from './index-t9LXRpCu.js';
2
2
  export { i as App } from './index-IokxSNxm.js';
3
3
  export { i as IaC } from './index-BjFkoQmK.js';
4
4
  export { i as Common } from './index-sIX5qe0K.js';
package/index.js CHANGED
@@ -105,21 +105,48 @@ __export(Indexing_exports, {
105
105
  });
106
106
 
107
107
  // src/api/Indexing/cursor.ts
108
+ var textEncoder = new TextEncoder();
109
+ var textDecoder = new TextDecoder();
110
+ function base64UrlFromBytes(bytes) {
111
+ let base64;
112
+ if (typeof globalThis.Buffer !== "undefined") {
113
+ base64 = globalThis.Buffer.from(bytes).toString("base64");
114
+ } else {
115
+ let bin = "";
116
+ for (let i = 0; i < bytes.length; i += 1) {
117
+ bin += String.fromCharCode(bytes[i]);
118
+ }
119
+ base64 = btoa(bin);
120
+ }
121
+ return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
122
+ }
123
+ function bytesFromBase64Url(input) {
124
+ const base64 = input.replace(/-/g, "+").replace(/_/g, "/");
125
+ const padded = base64.padEnd(
126
+ base64.length + (4 - base64.length % 4) % 4,
127
+ "="
128
+ );
129
+ if (typeof globalThis.Buffer !== "undefined") {
130
+ return new Uint8Array(globalThis.Buffer.from(padded, "base64"));
131
+ }
132
+ const bin = atob(padded);
133
+ const bytes = new Uint8Array(bin.length);
134
+ for (let i = 0; i < bin.length; i += 1) {
135
+ bytes[i] = bin.charCodeAt(i);
136
+ }
137
+ return bytes;
138
+ }
108
139
  function encodeCursor(payload) {
109
- return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
140
+ const json = JSON.stringify(payload);
141
+ const bytes = textEncoder.encode(json);
142
+ return base64UrlFromBytes(bytes);
110
143
  }
111
144
  function decodeCursor(cursor) {
112
- const base64 = cursor.replace(/-/g, "+").replace(/_/g, "/");
113
- const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
114
- let decoded;
115
- try {
116
- decoded = Buffer.from(padded, "base64").toString("utf8");
117
- } catch (error) {
118
- throw new Error("Invalid cursor encoding.");
119
- }
120
145
  try {
146
+ const bytes = bytesFromBase64Url(cursor);
147
+ const decoded = textDecoder.decode(bytes);
121
148
  return JSON.parse(decoded);
122
- } catch (error) {
149
+ } catch {
123
150
  throw new Error("Invalid cursor payload.");
124
151
  }
125
152
  }
@@ -143,7 +170,11 @@ function decodePlanner(payload) {
143
170
  if (!payload?.p) {
144
171
  return void 0;
145
172
  }
146
- return { primaryToken: payload.p, statsVersion: payload.sv, sorting: payload.s ?? "docIdAsc" };
173
+ return {
174
+ primaryToken: payload.p,
175
+ statsVersion: payload.sv,
176
+ sorting: payload.s ?? "docIdAsc"
177
+ };
147
178
  }
148
179
  function normalizeDocId(value) {
149
180
  if (value === void 0 || value === null) {
@@ -198,7 +229,12 @@ function encodeExactCursor(state) {
198
229
  }
199
230
  const plan = encodePlanner(state.plan);
200
231
  if (!plan && verificationPending === void 0 && verificationOffset === void 0) {
201
- return encodePayload({ v: 1, t: "exact", lossyLastDocId, verificationLastDocId });
232
+ return encodePayload({
233
+ v: 1,
234
+ t: "exact",
235
+ lossyLastDocId,
236
+ verificationLastDocId
237
+ });
202
238
  }
203
239
  return encodePayload({
204
240
  v: 3,
@@ -219,7 +255,9 @@ function decodeExactCursor(cursor) {
219
255
  throw new Error("Expected exact cursor payload.");
220
256
  }
221
257
  const payloadV3 = payload;
222
- const normalizedVerificationPending = normalizeDocIdList(payloadV3.verificationPending);
258
+ const normalizedVerificationPending = normalizeDocIdList(
259
+ payloadV3.verificationPending
260
+ );
223
261
  return {
224
262
  lossy: payload.lossyLastDocId === void 0 ? void 0 : { lastDocId: normalizeDocId(payload.lossyLastDocId) },
225
263
  verification: payload.verificationLastDocId === void 0 ? normalizedVerificationPending || payloadV3.verificationOffset !== void 0 ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resistdesign/voltra",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.8",
4
4
  "description": "With our powers combined!",
5
5
  "homepage": "https://voltra.app",
6
6
  "repository": "git@github.com:resistdesign/voltra.git",