@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -1
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -8
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -685
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -34
  10. package/dist/better-auth/client.d.ts +6 -5
  11. package/dist/better-auth/client.js +28 -5
  12. package/dist/better-auth/index.d.ts +19 -17
  13. package/dist/better-auth/index.js +180 -144
  14. package/dist/client-61ldOHMz.js +503 -0
  15. package/dist/client-7PCoxVhZ.js +28 -0
  16. package/dist/client-B7rZQ8Zi.d.ts +272 -0
  17. package/dist/client-BGGd_cpV.d.ts +103 -0
  18. package/dist/client-BoIuyx4S.js +273 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-BxtZt405.js +305 -0
  21. package/dist/client-ByN3EQdk.js +83 -0
  22. package/dist/client-CAghoGD_.js +53 -0
  23. package/dist/client-C_pHsPlj.js +81 -0
  24. package/dist/client-D0eBxh8j.d.ts +284 -0
  25. package/dist/client-D6gs61w8.d.ts +53 -0
  26. package/dist/client-DDw5yz_h.d.ts +53 -0
  27. package/dist/client-Dxg8_DIH.d.ts +71 -0
  28. package/dist/client-aMR4CRB8.d.ts +211 -0
  29. package/dist/client-lk6wBu_0.d.ts +48 -0
  30. package/dist/client-wEVKLdly.js +55 -0
  31. package/dist/client-zF1RG2uA.js +86 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +103 -86
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-aml9oQpX.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +3047 -2967
  38. package/dist/eav/coerce.d.ts +3 -1
  39. package/dist/eav/coerce.js +72 -46
  40. package/dist/eav/index.d.ts +72 -100
  41. package/dist/eav/index.js +158 -126
  42. package/dist/eav/migrate.d.ts +112 -109
  43. package/dist/eav/migrate.js +230 -196
  44. package/dist/eav/schema.d.ts +111 -150
  45. package/dist/eav/schema.js +624 -603
  46. package/dist/encoding-Bwfm3iaE.js +21 -0
  47. package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -6
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -25
  52. package/dist/http-client-BZc2mngq.js +386 -0
  53. package/dist/index-1j_738qk.d.ts +470 -0
  54. package/dist/index-CeOLGdyL.d.ts +169 -0
  55. package/dist/index.d.ts +6 -230
  56. package/dist/index.js +119 -71
  57. package/dist/logout/index.d.ts +56 -53
  58. package/dist/logout/index.js +232 -289
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -6
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -6
  63. package/dist/query-xWqtfkvR.js +35 -0
  64. package/dist/react/hooks.d.ts +157 -100
  65. package/dist/react/hooks.js +862 -406
  66. package/dist/sse-parser-FMjxM7sY.js +86 -0
  67. package/dist/terms/index.d.ts +3 -79
  68. package/dist/terms/index.js +3 -6
  69. package/dist/testing/index.d.ts +52 -104
  70. package/dist/testing/index.js +94 -72
  71. package/dist/types-B-SMkH6s.d.ts +26 -0
  72. package/dist/types-BXDcoJHG.d.ts +131 -0
  73. package/dist/types-BrghN2rJ.d.ts +105 -0
  74. package/dist/types-DjDRszNj.js +11 -0
  75. package/dist/webhooks/index.d.ts +77 -50
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +121 -8
  78. package/docs/errors.md +19 -0
  79. package/docs/files.md +165 -7
  80. package/package.json +7 -6
  81. package/dist/chunk-2LSCQHAU.js +0 -21
  82. package/dist/chunk-4U4ZPPL4.js +0 -599
  83. package/dist/chunk-55KHY5GH.js +0 -96
  84. package/dist/chunk-C5VTRZWX.js +0 -458
  85. package/dist/chunk-F7BXBTZI.js +0 -54
  86. package/dist/chunk-FJUCWXX3.js +0 -350
  87. package/dist/chunk-H33OTQEN.js +0 -112
  88. package/dist/chunk-L4DHB36G.js +0 -75
  89. package/dist/chunk-OG7R3UAR.js +0 -105
  90. package/dist/chunk-PF24XU54.js +0 -32
  91. package/dist/chunk-QN3QD67K.js +0 -49
  92. package/dist/chunk-REIKXSMY.js +0 -7
  93. package/dist/chunk-UGBBXCZE.js +0 -157
  94. package/dist/chunk-UVT2E6KD.js +0 -81
  95. package/dist/chunk-YPLT3RFL.js +0 -63
  96. package/dist/chunk-YTKSAWV2.js +0 -463
  97. package/dist/client-BkcO-0C2.d.ts +0 -216
  98. package/dist/client-CN5_tNOC.d.ts +0 -147
  99. package/dist/client-DttyeM_h.d.ts +0 -102
  100. package/dist/config-CtxyJsDR.d.ts +0 -397
  101. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  102. package/dist/types-6E3ZLL9X.d.ts +0 -24
  103. package/dist/types-DskYLVb8.d.ts +0 -104
  104. package/dist/types-ckmDDW3N.d.ts +0 -129
@@ -0,0 +1,503 @@
1
+ import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
2
+ import { t as buildQuery } from "./query-xWqtfkvR.js";
3
+
4
+ //#region src/eav/cache.ts
5
+ var SchemaCache = class {
6
+ cache = /* @__PURE__ */ new Map();
7
+ ttl;
8
+ constructor(ttlMs = 300 * 1e3) {
9
+ this.ttl = ttlMs;
10
+ }
11
+ get(key) {
12
+ const entry = this.cache.get(key);
13
+ if (!entry) return void 0;
14
+ if (Date.now() > entry.expiresAt) {
15
+ this.cache.delete(key);
16
+ return;
17
+ }
18
+ return entry.data;
19
+ }
20
+ set(key, data) {
21
+ this.cache.set(key, {
22
+ data,
23
+ expiresAt: Date.now() + this.ttl
24
+ });
25
+ }
26
+ /**
27
+ * Invalidate cache entries.
28
+ *
29
+ * - No argument: clears the entire cache.
30
+ * - String: prefix match against keys (e.g. `"entity:"` matches all
31
+ * per-entity caches, `"entities"` matches only the top-level list).
32
+ */
33
+ invalidate(pattern) {
34
+ if (!pattern) {
35
+ this.cache.clear();
36
+ return;
37
+ }
38
+ for (const key of Array.from(this.cache.keys())) if (key === pattern || key.startsWith(pattern)) this.cache.delete(key);
39
+ }
40
+ };
41
+
42
+ //#endregion
43
+ //#region src/eav/client.ts
44
+ function createReoptEavClient(config) {
45
+ const http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/eav`);
46
+ let entityNameMap = null;
47
+ let entityMapPromise = null;
48
+ const schemaCache = new SchemaCache();
49
+ function invalidateEntityCaches() {
50
+ entityNameMap = null;
51
+ entityMapPromise = null;
52
+ schemaCache.invalidate("entities");
53
+ schemaCache.invalidate("entity:");
54
+ }
55
+ async function resolveEntityId(entityName) {
56
+ if (!entityNameMap) {
57
+ if (!entityMapPromise) entityMapPromise = client.entities.list().then((entities) => new Map(entities.map((e) => [e.name, e.id]))).catch((err) => {
58
+ entityMapPromise = null;
59
+ throw err;
60
+ });
61
+ entityNameMap = await entityMapPromise;
62
+ }
63
+ const id = entityNameMap.get(entityName);
64
+ if (!id) throw new Error(`ReoptSDK: Entity "${entityName}" not found on server. Run schema sync or check the entity name.`);
65
+ return id;
66
+ }
67
+ const MAX_BULK = 100;
68
+ function assertBulkSize(count, op) {
69
+ if (count > MAX_BULK) throw new Error(`ReoptSDK: ${op} accepts at most ${MAX_BULK} records per call (got ${count}). Split into smaller batches.`);
70
+ if (count === 0) throw new Error(`ReoptSDK: ${op} requires at least one record.`);
71
+ }
72
+ const client = {
73
+ entities: {
74
+ async list() {
75
+ const cached = schemaCache.get("entities");
76
+ if (cached) return cached;
77
+ const res = await http.fetch("GET", "/entities");
78
+ schemaCache.set("entities", res.data);
79
+ return res.data;
80
+ },
81
+ async create(input) {
82
+ const res = await http.fetch("POST", "/entities", input);
83
+ invalidateEntityCaches();
84
+ return res.data;
85
+ },
86
+ async get(entityId) {
87
+ const cacheKey = `entity:${entityId}`;
88
+ const cached = schemaCache.get(cacheKey);
89
+ if (cached) return cached;
90
+ const res = await http.fetch("GET", `/entities/${entityId}`);
91
+ schemaCache.set(cacheKey, res.data);
92
+ return res.data;
93
+ },
94
+ async update(entityId, input) {
95
+ const res = await http.fetch("PUT", `/entities/${entityId}`, input);
96
+ invalidateEntityCaches();
97
+ return res.data;
98
+ },
99
+ async delete(entityId) {
100
+ await http.fetch("DELETE", `/entities/${entityId}`);
101
+ invalidateEntityCaches();
102
+ }
103
+ },
104
+ attributes: {
105
+ async create(entityId, input) {
106
+ const res = await http.fetch("POST", `/entities/${entityId}/attributes`, input);
107
+ schemaCache.invalidate("entity:");
108
+ return res.data;
109
+ },
110
+ async update(entityId, attributeId, input) {
111
+ const res = await http.fetch("PUT", `/entities/${entityId}/attributes/${attributeId}`, input);
112
+ schemaCache.invalidate("entity:");
113
+ return res.data;
114
+ },
115
+ async delete(entityId, attributeId) {
116
+ await http.fetch("DELETE", `/entities/${entityId}/attributes/${attributeId}`);
117
+ schemaCache.invalidate("entity:");
118
+ }
119
+ },
120
+ records: {
121
+ /** List records with pagination, filtering, and sorting.
122
+ * @example
123
+ * ```ts
124
+ * const result = await eav.records.list(entityId, {
125
+ * authUserId: userId,
126
+ * filters: [{ attributeId: "status-attr-id", operator: "eq", value: "active" }],
127
+ * sortBy: "createdAt",
128
+ * sortOrder: "desc",
129
+ * page: 1,
130
+ * limit: 50,
131
+ * });
132
+ * ```
133
+ */
134
+ async list(entityId, query) {
135
+ const qs = buildQuery(query ?? {});
136
+ return (await http.fetch("GET", `/entities/${entityId}/records${qs}`)).data;
137
+ },
138
+ /** Create a new record with attribute values.
139
+ * @example
140
+ * ```ts
141
+ * const record = await eav.records.create(entityId, {
142
+ * authUserId: userId,
143
+ * values: { [attrs.name]: "John", [attrs.email]: "john@example.com" },
144
+ * });
145
+ * ```
146
+ */
147
+ async create(entityId, input) {
148
+ return (await http.fetch("POST", `/entities/${entityId}/records`, input)).data;
149
+ },
150
+ /** Get a single record by ID.
151
+ * @example
152
+ * ```ts
153
+ * const record = await eav.records.get(entityId, recordId);
154
+ * ```
155
+ */
156
+ async get(entityId, recordId) {
157
+ return (await http.fetch("GET", `/entities/${entityId}/records/${recordId}`)).data;
158
+ },
159
+ /** Update a record's attribute values. Only specified values are changed.
160
+ * @example
161
+ * ```ts
162
+ * const updated = await eav.records.update(entityId, recordId, {
163
+ * values: { [attrs.status]: "completed" },
164
+ * });
165
+ * ```
166
+ */
167
+ async update(entityId, recordId, input) {
168
+ return (await http.fetch("PATCH", `/entities/${entityId}/records/${recordId}`, input)).data;
169
+ },
170
+ /** Delete a single record by ID. */
171
+ async delete(entityId, recordId) {
172
+ await http.fetch("DELETE", `/entities/${entityId}/records/${recordId}`);
173
+ },
174
+ /** Count records matching filters without fetching bodies.
175
+ * @example
176
+ * ```ts
177
+ * // Count active tasks
178
+ * const count = await eav.records.count(entityId, {
179
+ * authUserId: userId,
180
+ * filters: [{ attributeId: attrs.deleted_at, operator: "is_null" }],
181
+ * });
182
+ * ```
183
+ */
184
+ async count(entityId, query) {
185
+ const qs = buildQuery(query ?? {});
186
+ return (await http.fetch("GET", `/entities/${entityId}/records/count${qs}`)).data.total;
187
+ },
188
+ /** Delete multiple records by ID (max 100). Returns count of deleted records. */
189
+ async bulkDelete(entityId, ids) {
190
+ assertBulkSize(ids.length, "bulkDelete");
191
+ return (await http.fetch("DELETE", `/entities/${entityId}/records`, { ids })).data.count;
192
+ },
193
+ /** Update multiple records in a single transaction (max 100).
194
+ * @example
195
+ * ```ts
196
+ * const updated = await eav.records.bulkUpdate(entityId, [
197
+ * { id: "record-1", values: { [attrs.is_active]: false } },
198
+ * { id: "record-2", values: { [attrs.is_active]: false } },
199
+ * ]);
200
+ * ```
201
+ */
202
+ async bulkUpdate(entityId, updates) {
203
+ assertBulkSize(updates.length, "bulkUpdate");
204
+ return (await http.fetch("PATCH", `/entities/${entityId}/records`, { updates })).data;
205
+ },
206
+ /** Find a single record matching filters. Returns null if not found.
207
+ * Prefer this over list() + filter when you need exactly one record.
208
+ * @example
209
+ * ```ts
210
+ * // Find setting by key
211
+ * const record = await eav.records.findOne(entityId, {
212
+ * authUserId: userId,
213
+ * filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
214
+ * });
215
+ * ```
216
+ */
217
+ async findOne(entityId, query) {
218
+ return (await client.records.list(entityId, {
219
+ ...query,
220
+ page: 1,
221
+ limit: 1
222
+ })).records[0] ?? null;
223
+ },
224
+ /** Find a record by filters -- update if exists, create if not. Atomic operation.
225
+ * @returns `{ data: EavRecord, created: boolean }`
226
+ * @example
227
+ * ```ts
228
+ * // Upsert a user setting
229
+ * const { data, created } = await eav.records.upsert(entityId, {
230
+ * authUserId: userId,
231
+ * filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
232
+ * values: { [attrs.key]: "theme", [attrs.value]: "dark" },
233
+ * });
234
+ * ```
235
+ */
236
+ async upsert(entityId, input) {
237
+ const res = await http.fetch("PUT", `/entities/${entityId}/records/upsert`, input);
238
+ return {
239
+ data: res.data.record,
240
+ created: res.data.created
241
+ };
242
+ },
243
+ /** Create multiple records in a single transaction (max 100).
244
+ * @example
245
+ * ```ts
246
+ * const records = await eav.records.bulkCreate(entityId, [
247
+ * { values: { [attrs.name]: "Alice" } },
248
+ * { values: { [attrs.name]: "Bob" } },
249
+ * ]);
250
+ * ```
251
+ */
252
+ async bulkCreate(entityId, records) {
253
+ assertBulkSize(records.length, "bulkCreate");
254
+ return (await http.fetch("POST", `/entities/${entityId}/records/bulk`, { records })).data;
255
+ },
256
+ /** Delete all records matching filters. Returns count of deleted records.
257
+ * @example
258
+ * ```ts
259
+ * // Delete all inactive records
260
+ * const count = await eav.records.deleteWhere(entityId, {
261
+ * authUserId: userId,
262
+ * filters: [{ attributeId: attrs.status, operator: "eq", value: "inactive" }],
263
+ * });
264
+ * ```
265
+ */
266
+ async deleteWhere(entityId, input) {
267
+ return (await http.fetch("POST", `/entities/${entityId}/records/delete-where`, input)).data.count;
268
+ },
269
+ /** Iterate all records across pages as an AsyncGenerator.
270
+ * @example
271
+ * ```ts
272
+ * // Stream all records
273
+ * for await (const record of eav.records.listAll(entityId, { authUserId: userId })) {
274
+ * process.stdout.write(".");
275
+ * }
276
+ *
277
+ * // Or collect to array
278
+ * import { collectAll } from "@reopt-ai/brandapp-sdk/eav";
279
+ * const all = await collectAll(eav.records.listAll(entityId));
280
+ * ```
281
+ */
282
+ async *listAll(entityId, query) {
283
+ let page = 1;
284
+ const limit = query?.limit ?? 100;
285
+ while (true) {
286
+ const res = await client.records.list(entityId, {
287
+ ...query,
288
+ page,
289
+ limit
290
+ });
291
+ for (const record of res.records) yield record;
292
+ if (page >= res.totalPages) break;
293
+ page++;
294
+ }
295
+ },
296
+ /**
297
+ * Backfill records by streaming through pages, calling `transform` per
298
+ * record, and applying `update` for each non-null result.
299
+ *
300
+ * Designed for the "expand-contract" middle step of an EAV migration —
301
+ * e.g. copy values from a soon-to-be-deleted attribute to a new one.
302
+ *
303
+ * @example
304
+ * ```ts
305
+ * await sdk.eav.records.backfill(entityId, {
306
+ * filters: [{ attributeId: levelAttrId, operator: "is_null" }],
307
+ * concurrency: 10,
308
+ * transform: (r) => ({ level: r.values.tier ?? "free" }),
309
+ * onProgress: ({ processed, total }) =>
310
+ * console.log(`${processed}/${total}`),
311
+ * });
312
+ * ```
313
+ *
314
+ * Failed updates are collected in `result.failed[]` rather than aborting
315
+ * the run — inspect that array after the call to retry or escalate.
316
+ */
317
+ async backfill(entityId, opts) {
318
+ const concurrency = Math.max(1, opts.concurrency ?? 5);
319
+ const pageSize = Math.min(Math.max(1, opts.pageSize ?? 100), 100);
320
+ const batchSize = Math.min(Math.max(1, opts.batchSize ?? MAX_BULK), MAX_BULK);
321
+ const total = await client.records.count(entityId, {
322
+ authUserId: opts.authUserId,
323
+ filters: opts.filters
324
+ });
325
+ let updated = 0;
326
+ let skipped = 0;
327
+ const failed = [];
328
+ let processed = 0;
329
+ const emit = () => {
330
+ opts.onProgress?.({
331
+ processed,
332
+ total,
333
+ updated,
334
+ skipped,
335
+ failed: failed.length
336
+ });
337
+ };
338
+ const applyOne = async (item) => {
339
+ try {
340
+ await client.records.update(entityId, item.id, { values: item.values });
341
+ updated++;
342
+ } catch (err) {
343
+ failed.push({
344
+ recordId: item.id,
345
+ error: err instanceof Error ? err.message : String(err)
346
+ });
347
+ }
348
+ };
349
+ const flush = async (items) => {
350
+ try {
351
+ await client.records.bulkUpdate(entityId, items);
352
+ updated += items.length;
353
+ } catch {
354
+ for (const item of items) await applyOne(item);
355
+ } finally {
356
+ processed += items.length;
357
+ emit();
358
+ }
359
+ };
360
+ const inFlight = /* @__PURE__ */ new Set();
361
+ let buffer = [];
362
+ const scheduleFlush = () => {
363
+ const items = buffer;
364
+ buffer = [];
365
+ const task = flush(items).finally(() => {
366
+ inFlight.delete(task);
367
+ });
368
+ inFlight.add(task);
369
+ };
370
+ for await (const record of client.records.listAll(entityId, {
371
+ authUserId: opts.authUserId,
372
+ filters: opts.filters,
373
+ sortBy: opts.sortBy ?? "createdAt",
374
+ sortOrder: opts.sortOrder ?? "asc",
375
+ limit: pageSize
376
+ })) {
377
+ const next = opts.transform(record);
378
+ if (next === null || next === void 0) {
379
+ skipped++;
380
+ processed++;
381
+ emit();
382
+ continue;
383
+ }
384
+ buffer.push({
385
+ id: record.id,
386
+ values: next
387
+ });
388
+ if (buffer.length >= batchSize) {
389
+ scheduleFlush();
390
+ if (inFlight.size >= concurrency) await Promise.race(inFlight);
391
+ }
392
+ }
393
+ if (buffer.length > 0) scheduleFlush();
394
+ await Promise.all(inFlight);
395
+ return {
396
+ total,
397
+ updated,
398
+ skipped,
399
+ failed
400
+ };
401
+ }
402
+ },
403
+ users: { async getRecords(authUserId, query) {
404
+ const qs = buildQuery(query ?? {});
405
+ return (await http.fetch("GET", `/users/${authUserId}/records${qs}`)).data;
406
+ } },
407
+ /**
408
+ * Fetch the server's current EAV schema fingerprint (Phase C, RFC-0005).
409
+ *
410
+ * Pair with `verifyEavSchema(localHash, client)` to detect drift between
411
+ * a deployed bundle and the live schema. Cacheable for ~60s — the server
412
+ * recomputes on every schema mutation.
413
+ */
414
+ async schemaHash() {
415
+ return (await http.fetch("GET", "/schema-hash")).data;
416
+ },
417
+ /** Create a type-safe entity-scoped client. Resolves entity name to ID automatically.
418
+ * Requires `schema` in SDK config for type inference.
419
+ * @example
420
+ * ```ts
421
+ * const contacts = sdk.eav.entity("contacts");
422
+ * const record = await contacts.records.create({
423
+ * values: { name: "John", email: "john@example.com" }, // typed!
424
+ * });
425
+ * ```
426
+ */
427
+ entity(name) {
428
+ const entityName = config.schema ? config.schema.entities[name].name : name;
429
+ return {
430
+ entityName,
431
+ records: {
432
+ async list(query) {
433
+ const id = await resolveEntityId(entityName);
434
+ return client.records.list(id, query);
435
+ },
436
+ async findOne(query) {
437
+ const id = await resolveEntityId(entityName);
438
+ return client.records.findOne(id, query);
439
+ },
440
+ async create(input) {
441
+ const id = await resolveEntityId(entityName);
442
+ return client.records.create(id, input);
443
+ },
444
+ async upsert(input) {
445
+ const id = await resolveEntityId(entityName);
446
+ return client.records.upsert(id, input);
447
+ },
448
+ async get(recordId) {
449
+ const id = await resolveEntityId(entityName);
450
+ return client.records.get(id, recordId);
451
+ },
452
+ async update(recordId, input) {
453
+ const id = await resolveEntityId(entityName);
454
+ return client.records.update(id, recordId, input);
455
+ },
456
+ async delete(recordId) {
457
+ const id = await resolveEntityId(entityName);
458
+ return client.records.delete(id, recordId);
459
+ },
460
+ async count(query) {
461
+ const id = await resolveEntityId(entityName);
462
+ return client.records.count(id, query);
463
+ },
464
+ async bulkCreate(records) {
465
+ const id = await resolveEntityId(entityName);
466
+ return client.records.bulkCreate(id, records);
467
+ },
468
+ async bulkDelete(ids) {
469
+ const id = await resolveEntityId(entityName);
470
+ return client.records.bulkDelete(id, ids);
471
+ },
472
+ async bulkUpdate(updates) {
473
+ const id = await resolveEntityId(entityName);
474
+ return client.records.bulkUpdate(id, updates);
475
+ },
476
+ async deleteWhere(input) {
477
+ const id = await resolveEntityId(entityName);
478
+ return client.records.deleteWhere(id, input);
479
+ },
480
+ async *listAll(query) {
481
+ const id = await resolveEntityId(entityName);
482
+ yield* client.records.listAll(id, query);
483
+ },
484
+ async backfill(opts) {
485
+ const id = await resolveEntityId(entityName);
486
+ return client.records.backfill(id, opts);
487
+ }
488
+ }
489
+ };
490
+ },
491
+ /** Clear the entity name → ID cache and schema cache. Call after creating/deleting entities externally. */
492
+ invalidateCache() {
493
+ entityNameMap = null;
494
+ entityMapPromise = null;
495
+ schemaCache.invalidate();
496
+ }
497
+ };
498
+ return client;
499
+ }
500
+
501
+ //#endregion
502
+ export { createReoptEavClient as t };
503
+ //# sourceMappingURL=client-61ldOHMz.js.map
@@ -0,0 +1,28 @@
1
+ import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
2
+
3
+ //#region src/push/client.ts
4
+ var ReoptPushClient = class {
5
+ http;
6
+ constructor(config) {
7
+ this.http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/push`);
8
+ }
9
+ /** Register (or refresh) the signed-in customer's device push token. */
10
+ async registerDeviceToken(input, accessToken) {
11
+ return (await this.http.fetch("POST", "/me/tokens", input, { bearerToken: accessToken })).data;
12
+ }
13
+ /** Unregister a device token by `token` or `deviceId` (own tokens only). */
14
+ async unregisterDeviceToken(input, accessToken) {
15
+ return (await this.http.fetch("DELETE", "/me/tokens", input, { bearerToken: accessToken })).data;
16
+ }
17
+ /** List the signed-in customer's registered devices (no raw tokens). */
18
+ async listDevices(accessToken) {
19
+ return (await this.http.fetch("GET", "/me/tokens", void 0, { bearerToken: accessToken })).data;
20
+ }
21
+ };
22
+ function createReoptPushClient(config) {
23
+ return new ReoptPushClient(config);
24
+ }
25
+
26
+ //#endregion
27
+ export { createReoptPushClient as n, ReoptPushClient as t };
28
+ //# sourceMappingURL=client-7PCoxVhZ.js.map