@reopt-ai/brandapp-sdk 3.1.0 → 3.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +147 -0
  2. package/README.md +39 -14
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -7
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -671
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -33
  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 -133
  14. package/dist/client-B1q5P8rv.js +83 -0
  15. package/dist/client-B9QHVhdM.js +77 -0
  16. package/dist/client-BGGd_cpV.d.ts +103 -0
  17. package/dist/client-BJcy1V1a.js +140 -0
  18. package/dist/client-Beivhucf.js +55 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-D-yNxNfk.js +28 -0
  21. package/dist/client-D0eBxh8j.d.ts +284 -0
  22. package/dist/client-D3RHHUUW.d.ts +207 -0
  23. package/dist/client-D6gs61w8.d.ts +53 -0
  24. package/dist/client-DBnK7ooQ.js +86 -0
  25. package/dist/client-DDw5yz_h.d.ts +53 -0
  26. package/dist/client-DPmoKuR9.js +305 -0
  27. package/dist/client-DsdakibF.js +503 -0
  28. package/dist/client-Dxg8_DIH.d.ts +71 -0
  29. package/dist/client-EbhUIhHq.js +53 -0
  30. package/dist/client-lk6wBu_0.d.ts +48 -0
  31. package/dist/client-p49ol9pg.d.ts +124 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +105 -84
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-Cw0a3-C8.js +487 -0
  36. package/dist/dev/index.d.ts +2 -509
  37. package/dist/dev/index.js +2740 -2873
  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 -125
  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-DIAS8Rsl.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -5
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -24
  52. package/dist/http-client-QKUvvirs.js +386 -0
  53. package/dist/index-DrVaKfhs.d.ts +456 -0
  54. package/dist/index-Z6OGcurJ.d.ts +169 -0
  55. package/dist/index.d.ts +6 -221
  56. package/dist/index.js +119 -70
  57. package/dist/logout/index.d.ts +109 -0
  58. package/dist/logout/index.js +264 -0
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -5
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -5
  63. package/dist/query-BvbCiGWb.js +35 -0
  64. package/dist/react/hooks.d.ts +97 -95
  65. package/dist/react/hooks.js +742 -356
  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 -5
  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 -47
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +179 -2
  78. package/docs/dev-server.md +19 -18
  79. package/docs/errors.md +72 -15
  80. package/docs/logout.md +166 -0
  81. package/package.json +10 -5
  82. package/dist/chunk-2Q654O63.js +0 -350
  83. package/dist/chunk-F7BXBTZI.js +0 -54
  84. package/dist/chunk-IJOXTBIE.js +0 -599
  85. package/dist/chunk-JWXUVQRC.js +0 -157
  86. package/dist/chunk-L4DHB36G.js +0 -75
  87. package/dist/chunk-MRQY45U5.js +0 -465
  88. package/dist/chunk-N5JVE4WX.js +0 -449
  89. package/dist/chunk-O3PUWIDJ.js +0 -105
  90. package/dist/chunk-POLKEOYH.js +0 -63
  91. package/dist/chunk-R5CCGDUH.js +0 -49
  92. package/dist/chunk-RBHP7IZF.js +0 -96
  93. package/dist/chunk-REIKXSMY.js +0 -7
  94. package/dist/chunk-T7YTITRJ.js +0 -112
  95. package/dist/chunk-V73GORO3.js +0 -81
  96. package/dist/chunk-VRNBYSWU.js +0 -32
  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
@@ -1,54 +0,0 @@
1
- // src/core/abort.ts
2
- function createManagedAbort(opts) {
3
- const { timeoutMs, external, idle = false } = opts;
4
- const controller = new AbortController();
5
- let timer;
6
- let finished = false;
7
- let timedOut = false;
8
- const arm = () => {
9
- timer = setTimeout(() => {
10
- timedOut = true;
11
- controller.abort();
12
- }, timeoutMs);
13
- };
14
- const disarm = () => {
15
- if (timer !== void 0) {
16
- clearTimeout(timer);
17
- timer = void 0;
18
- }
19
- };
20
- const onExternalAbort = () => {
21
- disarm();
22
- controller.abort();
23
- };
24
- if (external) {
25
- if (external.aborted) {
26
- controller.abort();
27
- finished = true;
28
- } else {
29
- external.addEventListener("abort", onExternalAbort, { once: true });
30
- }
31
- }
32
- if (!finished) arm();
33
- return {
34
- signal: controller.signal,
35
- kick() {
36
- if (!idle || finished) return;
37
- disarm();
38
- arm();
39
- },
40
- cleanup() {
41
- if (finished) return;
42
- finished = true;
43
- disarm();
44
- external?.removeEventListener("abort", onExternalAbort);
45
- },
46
- get timedOut() {
47
- return timedOut;
48
- }
49
- };
50
- }
51
-
52
- export { createManagedAbort };
53
- //# sourceMappingURL=chunk-F7BXBTZI.js.map
54
- //# sourceMappingURL=chunk-F7BXBTZI.js.map
@@ -1,599 +0,0 @@
1
- import { buildQuery } from './chunk-VRNBYSWU.js';
2
- import { BaseHttpClient } from './chunk-N5JVE4WX.js';
3
-
4
- // src/eav/cache.ts
5
- var SchemaCache = class {
6
- cache = /* @__PURE__ */ new Map();
7
- ttl;
8
- constructor(ttlMs = 5 * 60 * 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 void 0;
17
- }
18
- return entry.data;
19
- }
20
- set(key, data) {
21
- this.cache.set(key, { data, expiresAt: Date.now() + this.ttl });
22
- }
23
- /**
24
- * Invalidate cache entries.
25
- *
26
- * - No argument: clears the entire cache.
27
- * - String: prefix match against keys (e.g. `"entity:"` matches all
28
- * per-entity caches, `"entities"` matches only the top-level list).
29
- */
30
- invalidate(pattern) {
31
- if (!pattern) {
32
- this.cache.clear();
33
- return;
34
- }
35
- for (const key of Array.from(this.cache.keys())) {
36
- if (key === pattern || key.startsWith(pattern)) this.cache.delete(key);
37
- }
38
- }
39
- };
40
-
41
- // src/eav/client.ts
42
- function createReoptEavClient(config) {
43
- const http = new BaseHttpClient(
44
- config,
45
- `/api/v1/brandapp/${config.brandappId}/eav`
46
- );
47
- let entityNameMap = null;
48
- let entityMapPromise = null;
49
- const schemaCache = new SchemaCache();
50
- function invalidateEntityCaches() {
51
- entityNameMap = null;
52
- entityMapPromise = null;
53
- schemaCache.invalidate("entities");
54
- schemaCache.invalidate("entity:");
55
- }
56
- async function resolveEntityId(entityName) {
57
- if (!entityNameMap) {
58
- if (!entityMapPromise) {
59
- entityMapPromise = client.entities.list().then((entities) => new Map(entities.map((e) => [e.name, e.id]))).catch((err) => {
60
- entityMapPromise = null;
61
- throw err;
62
- });
63
- }
64
- entityNameMap = await entityMapPromise;
65
- }
66
- const id = entityNameMap.get(entityName);
67
- if (!id) {
68
- throw new Error(
69
- `ReoptSDK: Entity "${entityName}" not found on server. Run schema sync or check the entity name.`
70
- );
71
- }
72
- return id;
73
- }
74
- const MAX_BULK = 100;
75
- function assertBulkSize(count, op) {
76
- if (count > MAX_BULK) {
77
- throw new Error(
78
- `ReoptSDK: ${op} accepts at most ${MAX_BULK} records per call (got ${count}). Split into smaller batches.`
79
- );
80
- }
81
- if (count === 0) {
82
- throw new Error(`ReoptSDK: ${op} requires at least one record.`);
83
- }
84
- }
85
- const client = {
86
- entities: {
87
- async list() {
88
- const cached = schemaCache.get("entities");
89
- if (cached) return cached;
90
- const res = await http.fetch(
91
- "GET",
92
- "/entities"
93
- );
94
- schemaCache.set("entities", res.data);
95
- return res.data;
96
- },
97
- async create(input) {
98
- const res = await http.fetch(
99
- "POST",
100
- "/entities",
101
- input
102
- );
103
- invalidateEntityCaches();
104
- return res.data;
105
- },
106
- async get(entityId) {
107
- const cacheKey = `entity:${entityId}`;
108
- const cached = schemaCache.get(cacheKey);
109
- if (cached) return cached;
110
- const res = await http.fetch("GET", `/entities/${entityId}`);
111
- schemaCache.set(cacheKey, res.data);
112
- return res.data;
113
- },
114
- async update(entityId, input) {
115
- const res = await http.fetch(
116
- "PUT",
117
- `/entities/${entityId}`,
118
- input
119
- );
120
- invalidateEntityCaches();
121
- return res.data;
122
- },
123
- async delete(entityId) {
124
- await http.fetch("DELETE", `/entities/${entityId}`);
125
- invalidateEntityCaches();
126
- }
127
- },
128
- attributes: {
129
- async create(entityId, input) {
130
- const res = await http.fetch(
131
- "POST",
132
- `/entities/${entityId}/attributes`,
133
- input
134
- );
135
- schemaCache.invalidate("entity:");
136
- return res.data;
137
- },
138
- async update(entityId, attributeId, input) {
139
- const res = await http.fetch(
140
- "PUT",
141
- `/entities/${entityId}/attributes/${attributeId}`,
142
- input
143
- );
144
- schemaCache.invalidate("entity:");
145
- return res.data;
146
- },
147
- async delete(entityId, attributeId) {
148
- await http.fetch(
149
- "DELETE",
150
- `/entities/${entityId}/attributes/${attributeId}`
151
- );
152
- schemaCache.invalidate("entity:");
153
- }
154
- },
155
- records: {
156
- /** List records with pagination, filtering, and sorting.
157
- * @example
158
- * ```ts
159
- * const result = await eav.records.list(entityId, {
160
- * authUserId: userId,
161
- * filters: [{ attributeId: "status-attr-id", operator: "eq", value: "active" }],
162
- * sortBy: "createdAt",
163
- * sortOrder: "desc",
164
- * page: 1,
165
- * limit: 50,
166
- * });
167
- * ```
168
- */
169
- async list(entityId, query) {
170
- const qs = buildQuery(query ?? {});
171
- const res = await http.fetch(
172
- "GET",
173
- `/entities/${entityId}/records${qs}`
174
- );
175
- return res.data;
176
- },
177
- /** Create a new record with attribute values.
178
- * @example
179
- * ```ts
180
- * const record = await eav.records.create(entityId, {
181
- * authUserId: userId,
182
- * values: { [attrs.name]: "John", [attrs.email]: "john@example.com" },
183
- * });
184
- * ```
185
- */
186
- async create(entityId, input) {
187
- const res = await http.fetch(
188
- "POST",
189
- `/entities/${entityId}/records`,
190
- input
191
- );
192
- return res.data;
193
- },
194
- /** Get a single record by ID.
195
- * @example
196
- * ```ts
197
- * const record = await eav.records.get(entityId, recordId);
198
- * ```
199
- */
200
- async get(entityId, recordId) {
201
- const res = await http.fetch(
202
- "GET",
203
- `/entities/${entityId}/records/${recordId}`
204
- );
205
- return res.data;
206
- },
207
- /** Update a record's attribute values. Only specified values are changed.
208
- * @example
209
- * ```ts
210
- * const updated = await eav.records.update(entityId, recordId, {
211
- * values: { [attrs.status]: "completed" },
212
- * });
213
- * ```
214
- */
215
- async update(entityId, recordId, input) {
216
- const res = await http.fetch(
217
- "PATCH",
218
- `/entities/${entityId}/records/${recordId}`,
219
- input
220
- );
221
- return res.data;
222
- },
223
- /** Delete a single record by ID. */
224
- async delete(entityId, recordId) {
225
- await http.fetch("DELETE", `/entities/${entityId}/records/${recordId}`);
226
- },
227
- /** Count records matching filters without fetching bodies.
228
- * @example
229
- * ```ts
230
- * // Count active tasks
231
- * const count = await eav.records.count(entityId, {
232
- * authUserId: userId,
233
- * filters: [{ attributeId: attrs.deleted_at, operator: "is_null" }],
234
- * });
235
- * ```
236
- */
237
- async count(entityId, query) {
238
- const qs = buildQuery(query ?? {});
239
- const res = await http.fetch(
240
- "GET",
241
- `/entities/${entityId}/records/count${qs}`
242
- );
243
- return res.data.total;
244
- },
245
- /** Delete multiple records by ID (max 100). Returns count of deleted records. */
246
- async bulkDelete(entityId, ids) {
247
- assertBulkSize(ids.length, "bulkDelete");
248
- const res = await http.fetch(
249
- "DELETE",
250
- `/entities/${entityId}/records`,
251
- { ids }
252
- );
253
- return res.data.count;
254
- },
255
- /** Update multiple records in a single transaction (max 100).
256
- * @example
257
- * ```ts
258
- * const updated = await eav.records.bulkUpdate(entityId, [
259
- * { id: "record-1", values: { [attrs.is_active]: false } },
260
- * { id: "record-2", values: { [attrs.is_active]: false } },
261
- * ]);
262
- * ```
263
- */
264
- async bulkUpdate(entityId, updates) {
265
- assertBulkSize(updates.length, "bulkUpdate");
266
- const res = await http.fetch(
267
- "PATCH",
268
- `/entities/${entityId}/records`,
269
- { updates }
270
- );
271
- return res.data;
272
- },
273
- /** Find a single record matching filters. Returns null if not found.
274
- * Prefer this over list() + filter when you need exactly one record.
275
- * @example
276
- * ```ts
277
- * // Find setting by key
278
- * const record = await eav.records.findOne(entityId, {
279
- * authUserId: userId,
280
- * filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
281
- * });
282
- * ```
283
- */
284
- async findOne(entityId, query) {
285
- const res = await client.records.list(entityId, {
286
- ...query,
287
- page: 1,
288
- limit: 1
289
- });
290
- return res.records[0] ?? null;
291
- },
292
- /** Find a record by filters -- update if exists, create if not. Atomic operation.
293
- * @returns `{ data: EavRecord, created: boolean }`
294
- * @example
295
- * ```ts
296
- * // Upsert a user setting
297
- * const { data, created } = await eav.records.upsert(entityId, {
298
- * authUserId: userId,
299
- * filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
300
- * values: { [attrs.key]: "theme", [attrs.value]: "dark" },
301
- * });
302
- * ```
303
- */
304
- async upsert(entityId, input) {
305
- const res = await http.fetch("PUT", `/entities/${entityId}/records/upsert`, input);
306
- return { data: res.data.record, created: res.data.created };
307
- },
308
- /** Create multiple records in a single transaction (max 100).
309
- * @example
310
- * ```ts
311
- * const records = await eav.records.bulkCreate(entityId, [
312
- * { values: { [attrs.name]: "Alice" } },
313
- * { values: { [attrs.name]: "Bob" } },
314
- * ]);
315
- * ```
316
- */
317
- async bulkCreate(entityId, records) {
318
- assertBulkSize(records.length, "bulkCreate");
319
- const res = await http.fetch(
320
- "POST",
321
- `/entities/${entityId}/records/bulk`,
322
- { records }
323
- );
324
- return res.data;
325
- },
326
- /** Delete all records matching filters. Returns count of deleted records.
327
- * @example
328
- * ```ts
329
- * // Delete all inactive records
330
- * const count = await eav.records.deleteWhere(entityId, {
331
- * authUserId: userId,
332
- * filters: [{ attributeId: attrs.status, operator: "eq", value: "inactive" }],
333
- * });
334
- * ```
335
- */
336
- async deleteWhere(entityId, input) {
337
- const res = await http.fetch(
338
- "POST",
339
- `/entities/${entityId}/records/delete-where`,
340
- input
341
- );
342
- return res.data.count;
343
- },
344
- /** Iterate all records across pages as an AsyncGenerator.
345
- * @example
346
- * ```ts
347
- * // Stream all records
348
- * for await (const record of eav.records.listAll(entityId, { authUserId: userId })) {
349
- * process.stdout.write(".");
350
- * }
351
- *
352
- * // Or collect to array
353
- * import { collectAll } from "@reopt-ai/brandapp-sdk/eav";
354
- * const all = await collectAll(eav.records.listAll(entityId));
355
- * ```
356
- */
357
- async *listAll(entityId, query) {
358
- let page = 1;
359
- const limit = query?.limit ?? 100;
360
- while (true) {
361
- const res = await client.records.list(entityId, {
362
- ...query,
363
- page,
364
- limit
365
- });
366
- for (const record of res.records) {
367
- yield record;
368
- }
369
- if (page >= res.totalPages) break;
370
- page++;
371
- }
372
- },
373
- /**
374
- * Backfill records by streaming through pages, calling `transform` per
375
- * record, and applying `update` for each non-null result.
376
- *
377
- * Designed for the "expand-contract" middle step of an EAV migration —
378
- * e.g. copy values from a soon-to-be-deleted attribute to a new one.
379
- *
380
- * @example
381
- * ```ts
382
- * await sdk.eav.records.backfill(entityId, {
383
- * filters: [{ attributeId: levelAttrId, operator: "is_null" }],
384
- * concurrency: 10,
385
- * transform: (r) => ({ level: r.values.tier ?? "free" }),
386
- * onProgress: ({ processed, total }) =>
387
- * console.log(`${processed}/${total}`),
388
- * });
389
- * ```
390
- *
391
- * Failed updates are collected in `result.failed[]` rather than aborting
392
- * the run — inspect that array after the call to retry or escalate.
393
- */
394
- async backfill(entityId, opts) {
395
- const concurrency = Math.max(1, opts.concurrency ?? 5);
396
- const pageSize = Math.min(Math.max(1, opts.pageSize ?? 100), 100);
397
- const batchSize = Math.min(
398
- Math.max(1, opts.batchSize ?? MAX_BULK),
399
- MAX_BULK
400
- );
401
- const total = await client.records.count(entityId, {
402
- authUserId: opts.authUserId,
403
- filters: opts.filters
404
- });
405
- let updated = 0;
406
- let skipped = 0;
407
- const failed = [];
408
- let processed = 0;
409
- const emit = () => {
410
- opts.onProgress?.({
411
- processed,
412
- total,
413
- updated,
414
- skipped,
415
- failed: failed.length
416
- });
417
- };
418
- const applyOne = async (item) => {
419
- try {
420
- await client.records.update(entityId, item.id, {
421
- values: item.values
422
- });
423
- updated++;
424
- } catch (err) {
425
- failed.push({
426
- recordId: item.id,
427
- error: err instanceof Error ? err.message : String(err)
428
- });
429
- }
430
- };
431
- const flush = async (items) => {
432
- try {
433
- await client.records.bulkUpdate(entityId, items);
434
- updated += items.length;
435
- } catch {
436
- for (const item of items) await applyOne(item);
437
- } finally {
438
- processed += items.length;
439
- emit();
440
- }
441
- };
442
- const inFlight = /* @__PURE__ */ new Set();
443
- let buffer = [];
444
- const scheduleFlush = () => {
445
- const items = buffer;
446
- buffer = [];
447
- const task = flush(items).finally(() => {
448
- inFlight.delete(task);
449
- });
450
- inFlight.add(task);
451
- };
452
- for await (const record of client.records.listAll(entityId, {
453
- authUserId: opts.authUserId,
454
- filters: opts.filters,
455
- sortBy: opts.sortBy ?? "createdAt",
456
- sortOrder: opts.sortOrder ?? "asc",
457
- limit: pageSize
458
- })) {
459
- const next = opts.transform(record);
460
- if (next === null || next === void 0) {
461
- skipped++;
462
- processed++;
463
- emit();
464
- continue;
465
- }
466
- buffer.push({ id: record.id, values: next });
467
- if (buffer.length >= batchSize) {
468
- scheduleFlush();
469
- if (inFlight.size >= concurrency) {
470
- await Promise.race(inFlight);
471
- }
472
- }
473
- }
474
- if (buffer.length > 0) scheduleFlush();
475
- await Promise.all(inFlight);
476
- return { total, updated, skipped, failed };
477
- }
478
- },
479
- users: {
480
- async getRecords(authUserId, query) {
481
- const qs = buildQuery(query ?? {});
482
- const res = await http.fetch(
483
- "GET",
484
- `/users/${authUserId}/records${qs}`
485
- );
486
- return res.data;
487
- }
488
- },
489
- /**
490
- * Fetch the server's current EAV schema fingerprint (Phase C, RFC-0005).
491
- *
492
- * Pair with `verifyEavSchema(localHash, client)` to detect drift between
493
- * a deployed bundle and the live schema. Cacheable for ~60s — the server
494
- * recomputes on every schema mutation.
495
- */
496
- async schemaHash() {
497
- const res = await http.fetch("GET", "/schema-hash");
498
- return res.data;
499
- },
500
- /** Create a type-safe entity-scoped client. Resolves entity name to ID automatically.
501
- * Requires `schema` in SDK config for type inference.
502
- * @example
503
- * ```ts
504
- * const contacts = sdk.eav.entity("contacts");
505
- * const record = await contacts.records.create({
506
- * values: { name: "John", email: "john@example.com" }, // typed!
507
- * });
508
- * ```
509
- */
510
- entity(name) {
511
- const entityName = config.schema ? config.schema.entities[name].name : name;
512
- return {
513
- entityName,
514
- records: {
515
- async list(query) {
516
- const id = await resolveEntityId(entityName);
517
- return client.records.list(id, query);
518
- },
519
- async findOne(query) {
520
- const id = await resolveEntityId(entityName);
521
- return client.records.findOne(id, query);
522
- },
523
- async create(input) {
524
- const id = await resolveEntityId(entityName);
525
- return client.records.create(
526
- id,
527
- input
528
- );
529
- },
530
- async upsert(input) {
531
- const id = await resolveEntityId(entityName);
532
- return client.records.upsert(
533
- id,
534
- input
535
- );
536
- },
537
- async get(recordId) {
538
- const id = await resolveEntityId(entityName);
539
- return client.records.get(id, recordId);
540
- },
541
- async update(recordId, input) {
542
- const id = await resolveEntityId(entityName);
543
- return client.records.update(
544
- id,
545
- recordId,
546
- input
547
- );
548
- },
549
- async delete(recordId) {
550
- const id = await resolveEntityId(entityName);
551
- return client.records.delete(id, recordId);
552
- },
553
- async count(query) {
554
- const id = await resolveEntityId(entityName);
555
- return client.records.count(id, query);
556
- },
557
- async bulkCreate(records) {
558
- const id = await resolveEntityId(entityName);
559
- return client.records.bulkCreate(
560
- id,
561
- records
562
- );
563
- },
564
- async bulkDelete(ids) {
565
- const id = await resolveEntityId(entityName);
566
- return client.records.bulkDelete(id, ids);
567
- },
568
- async bulkUpdate(updates) {
569
- const id = await resolveEntityId(entityName);
570
- return client.records.bulkUpdate(id, updates);
571
- },
572
- async deleteWhere(input) {
573
- const id = await resolveEntityId(entityName);
574
- return client.records.deleteWhere(id, input);
575
- },
576
- async *listAll(query) {
577
- const id = await resolveEntityId(entityName);
578
- yield* client.records.listAll(id, query);
579
- },
580
- async backfill(opts) {
581
- const id = await resolveEntityId(entityName);
582
- return client.records.backfill(id, opts);
583
- }
584
- }
585
- };
586
- },
587
- /** Clear the entity name → ID cache and schema cache. Call after creating/deleting entities externally. */
588
- invalidateCache() {
589
- entityNameMap = null;
590
- entityMapPromise = null;
591
- schemaCache.invalidate();
592
- }
593
- };
594
- return client;
595
- }
596
-
597
- export { createReoptEavClient };
598
- //# sourceMappingURL=chunk-IJOXTBIE.js.map
599
- //# sourceMappingURL=chunk-IJOXTBIE.js.map