@madewithremy/admin 0.1.29 → 0.1.31

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.js CHANGED
@@ -196,6 +196,27 @@ function threadsGet(ctx, threadId) {
196
196
  );
197
197
  }
198
198
 
199
+ // src/ops/tasks.ts
200
+ var tasks_exports = {};
201
+ __export(tasks_exports, {
202
+ get: () => get,
203
+ list: () => list
204
+ });
205
+ function list(ctx, params = {}) {
206
+ return call(
207
+ ctx,
208
+ "GET",
209
+ `/_internal/v2/apps/${ctx.appId}/task-traces${qs(params)}`
210
+ );
211
+ }
212
+ function get(ctx, traceId) {
213
+ return call(
214
+ ctx,
215
+ "GET",
216
+ `/_internal/v2/apps/${ctx.appId}/task-traces/${seg(traceId)}`
217
+ );
218
+ }
219
+
199
220
  // src/ops/analytics.ts
200
221
  var analytics_exports = {};
201
222
  __export(analytics_exports, {
@@ -285,12 +306,12 @@ function publish(ctx, params) {
285
306
  // src/ops/crashes.ts
286
307
  var crashes_exports = {};
287
308
  __export(crashes_exports, {
288
- get: () => get,
289
- list: () => list,
309
+ get: () => get2,
310
+ list: () => list2,
290
311
  occurrences: () => occurrences,
291
312
  stats: () => stats
292
313
  });
293
- function list(ctx, params = {}) {
314
+ function list2(ctx, params = {}) {
294
315
  return call(
295
316
  ctx,
296
317
  "GET",
@@ -304,7 +325,7 @@ function occurrences(ctx, fingerprint, params = {}) {
304
325
  `/_internal/v2/apps/${ctx.appId}/frontend-errors/${seg(fingerprint)}/events${qs(params)}`
305
326
  );
306
327
  }
307
- function get(ctx, eventId) {
328
+ function get2(ctx, eventId) {
308
329
  return call(
309
330
  ctx,
310
331
  "GET",
@@ -322,10 +343,10 @@ function stats(ctx, params = {}) {
322
343
  // src/ops/cron.ts
323
344
  var cron_exports = {};
324
345
  __export(cron_exports, {
325
- list: () => list2,
346
+ list: () => list3,
326
347
  run: () => run
327
348
  });
328
- function list2(ctx, params = {}) {
349
+ function list3(ctx, params = {}) {
329
350
  return call(
330
351
  ctx,
331
352
  "GET",
@@ -383,11 +404,15 @@ __export(dataSources_exports, {
383
404
  count: () => count,
384
405
  create: () => create,
385
406
  deleteSource: () => deleteSource,
407
+ dictionary: () => dictionary,
386
408
  documents: () => documents,
387
409
  drop: () => drop,
388
- list: () => list3,
410
+ entities: () => entities,
411
+ link: () => link,
412
+ list: () => list4,
389
413
  move: () => move,
390
414
  promote: () => promote,
415
+ pushDictionary: () => pushDictionary,
391
416
  revectorize: () => revectorize,
392
417
  rm: () => rm,
393
418
  rmWhere: () => rmWhere,
@@ -525,7 +550,7 @@ var summarize = (d) => ({
525
550
  ...d.errorMessage ? { error: d.errorMessage } : {}
526
551
  });
527
552
  async function addDocument(ctx, params) {
528
- const { slug, filename, content, metadata, onProgress } = params;
553
+ const { slug, filename, content, metadata, entities: entities2, onProgress } = params;
529
554
  const contentHash = createHash("sha256").update(content).digest("hex");
530
555
  const token = await call(
531
556
  ctx,
@@ -535,7 +560,8 @@ async function addDocument(ctx, params) {
535
560
  slug,
536
561
  filename,
537
562
  contentHash,
538
- ...metadata ? { metadata } : {}
563
+ ...metadata ? { metadata } : {},
564
+ ...entities2 ? { entities: entities2 } : {}
539
565
  }
540
566
  );
541
567
  if (token.alreadyCurrent) {
@@ -561,7 +587,8 @@ async function addDocument(ctx, params) {
561
587
  contentHash,
562
588
  contentType: token.contentType,
563
589
  size: content.length,
564
- ...metadata ? { metadata } : {}
590
+ ...metadata ? { metadata } : {},
591
+ ...entities2 ? { entities: entities2 } : {}
565
592
  }
566
593
  );
567
594
  return {
@@ -616,7 +643,7 @@ async function waitForCandidate(ctx, params) {
616
643
  const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
617
644
  const outcome = await pollUntil(
618
645
  async () => {
619
- const { dataSources } = await list3(ctx);
646
+ const { dataSources } = await list4(ctx);
620
647
  const source = dataSources.find((s) => s.slug === params.slug);
621
648
  if (!source) {
622
649
  throw new Error(`Data source "${params.slug}" not found.`);
@@ -698,7 +725,7 @@ async function allDocuments(ctx, params) {
698
725
  }
699
726
  return out;
700
727
  }
701
- function list3(ctx) {
728
+ function list4(ctx) {
702
729
  return call(ctx, "GET", base(ctx.appId));
703
730
  }
704
731
  function search(ctx, params) {
@@ -738,6 +765,20 @@ function count(ctx, params) {
738
765
  ...candidate ? { candidate: true } : {}
739
766
  });
740
767
  }
768
+ function entities(ctx, params) {
769
+ const { slug, filter, limit, candidate } = params;
770
+ return call(
771
+ ctx,
772
+ "POST",
773
+ `${base(ctx.appId)}/entities`,
774
+ {
775
+ slug,
776
+ ...filter ? { filter } : {},
777
+ ...limit !== void 0 ? { limit } : {},
778
+ ...candidate ? { candidate: true } : {}
779
+ }
780
+ );
781
+ }
741
782
  function configGet(ctx, slug) {
742
783
  return call(
743
784
  ctx,
@@ -788,7 +829,7 @@ async function waitForMove(ctx, params) {
788
829
  const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS;
789
830
  const outcome = await pollUntil(
790
831
  async () => {
791
- const { dataSources } = await list3(ctx);
832
+ const { dataSources } = await list4(ctx);
792
833
  const source2 = dataSources.find((s) => s.slug === params.slug);
793
834
  if (!source2) {
794
835
  throw new Error(`Data source "${params.slug}" not found.`);
@@ -899,6 +940,67 @@ function deleteSource(ctx, slug) {
899
940
  { slug }
900
941
  );
901
942
  }
943
+ var DICTIONARY_PAGE_ENTRIES = 1e4;
944
+ var DICTIONARY_PAGE_BYTES = 4e6;
945
+ async function pushDictionary(ctx, params) {
946
+ const { slug, entries } = params;
947
+ const stage = await call(
948
+ ctx,
949
+ "POST",
950
+ `${base(ctx.appId)}/dictionary/stage`,
951
+ {
952
+ slug,
953
+ ...params.linkerVersion !== void 0 ? { linkerVersion: params.linkerVersion } : {}
954
+ }
955
+ );
956
+ const perPage = Math.min(
957
+ DICTIONARY_PAGE_ENTRIES,
958
+ stage.pageMaxEntries || DICTIONARY_PAGE_ENTRIES
959
+ );
960
+ let pages2 = 0;
961
+ let start2 = 0;
962
+ while (start2 < entries.length) {
963
+ let end = start2;
964
+ let bytes = 0;
965
+ while (end < entries.length && end - start2 < perPage) {
966
+ const size = JSON.stringify(entries[end]).length;
967
+ if (end > start2 && bytes + size > DICTIONARY_PAGE_BYTES) {
968
+ break;
969
+ }
970
+ bytes += size;
971
+ end += 1;
972
+ }
973
+ await call(ctx, "POST", `${base(ctx.appId)}/dictionary/page`, {
974
+ slug,
975
+ stageId: stage.stageId,
976
+ page: pages2,
977
+ entries: entries.slice(start2, end)
978
+ });
979
+ pages2 += 1;
980
+ start2 = end;
981
+ params.onProgress?.(start2, entries.length);
982
+ }
983
+ return call(
984
+ ctx,
985
+ "POST",
986
+ `${base(ctx.appId)}/dictionary/commit`,
987
+ { slug, stageId: stage.stageId, pages: pages2 }
988
+ );
989
+ }
990
+ function dictionary(ctx, params) {
991
+ return call(
992
+ ctx,
993
+ "POST",
994
+ `${base(ctx.appId)}/dictionary`,
995
+ { slug: params.slug }
996
+ );
997
+ }
998
+ function link(ctx, params) {
999
+ return call(ctx, "POST", `${base(ctx.appId)}/link`, {
1000
+ slug: params.slug,
1001
+ text: params.text
1002
+ });
1003
+ }
902
1004
 
903
1005
  // src/ops/dataSourceJobs.ts
904
1006
  var dataSourceJobs_exports = {};
@@ -907,8 +1009,8 @@ __export(dataSourceJobs_exports, {
907
1009
  approve: () => approve,
908
1010
  cancel: () => cancel,
909
1011
  describeProgress: () => describeProgress,
910
- get: () => get2,
911
- list: () => list4,
1012
+ get: () => get3,
1013
+ list: () => list5,
912
1014
  pause: () => pause,
913
1015
  resume: () => resume,
914
1016
  retry: () => retry,
@@ -944,14 +1046,14 @@ async function uploadManifest(ctx, params) {
944
1046
  await uploadDirect(token.upload, params.content, "manifest.jsonl");
945
1047
  return { key: token.key };
946
1048
  }
947
- function list4(ctx, params) {
1049
+ function list5(ctx, params) {
948
1050
  return call(
949
1051
  ctx,
950
1052
  "GET",
951
1053
  `${base2(ctx.appId)}${qs({ slug: params?.slug })}`
952
1054
  );
953
1055
  }
954
- function get2(ctx, params) {
1056
+ function get3(ctx, params) {
955
1057
  return call(
956
1058
  ctx,
957
1059
  "GET",
@@ -1015,7 +1117,7 @@ function waitForJob(ctx, params) {
1015
1117
  async function settle(ctx, params, isSettled) {
1016
1118
  const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS2;
1017
1119
  const outcome = await pollUntil(
1018
- async () => (await get2(ctx, { id: params.id })).job,
1120
+ async () => (await get3(ctx, { id: params.id })).job,
1019
1121
  isSettled,
1020
1122
  {
1021
1123
  timeoutMs,
@@ -1075,7 +1177,7 @@ var dataSourceConnectors_exports = {};
1075
1177
  __export(dataSourceConnectors_exports, {
1076
1178
  connect: () => connect,
1077
1179
  disconnect: () => disconnect,
1078
- get: () => get3,
1180
+ get: () => get4,
1079
1181
  sync: () => sync
1080
1182
  });
1081
1183
  function base3(appId) {
@@ -1110,7 +1212,7 @@ function connect(ctx, params) {
1110
1212
  }
1111
1213
  );
1112
1214
  }
1113
- function get3(ctx, params) {
1215
+ function get4(ctx, params) {
1114
1216
  return call(
1115
1217
  ctx,
1116
1218
  "GET",
@@ -1182,7 +1284,7 @@ async function waitForHydration(ctx, params) {
1182
1284
  const timeoutMs = params.timeoutMs ?? DEFAULT_WAIT_TIMEOUT_MS3;
1183
1285
  const outcome = await pollUntil(
1184
1286
  async () => {
1185
- const { dataSources } = await list3(ctx);
1287
+ const { dataSources } = await list4(ctx);
1186
1288
  const source2 = dataSources.find((s) => s.slug === params.slug);
1187
1289
  if (!source2) {
1188
1290
  throw new Error(`Data source "${params.slug}" not found.`);
@@ -1454,6 +1556,7 @@ function quarantine(ctx, params) {
1454
1556
  "GET",
1455
1557
  `${base5(ctx.appId)}/jobs/${params.id}/quarantine${qs({
1456
1558
  ...params.kind ? { kind: params.kind } : {},
1559
+ ...params.stage ? { stage: params.stage } : {},
1457
1560
  ...params.reason ? { reason: params.reason } : {},
1458
1561
  ...params.cursor ? { cursor: params.cursor } : {},
1459
1562
  ...params.limit !== void 0 ? { limit: params.limit } : {}
@@ -1496,18 +1599,18 @@ var releases_exports = {};
1496
1599
  __export(releases_exports, {
1497
1600
  byCommit: () => byCommit,
1498
1601
  dashboardLive: () => dashboardLive,
1499
- get: () => get4,
1500
- list: () => list5,
1602
+ get: () => get5,
1603
+ list: () => list6,
1501
1604
  waitForCommit: () => waitForCommit
1502
1605
  });
1503
- function list5(ctx, params = {}) {
1606
+ function list6(ctx, params = {}) {
1504
1607
  return call(
1505
1608
  ctx,
1506
1609
  "GET",
1507
1610
  `/_internal/v2/apps/${ctx.appId}/releases${qs({ limit: params.limit })}`
1508
1611
  );
1509
1612
  }
1510
- function get4(ctx, releaseId) {
1613
+ function get5(ctx, releaseId) {
1511
1614
  return call(
1512
1615
  ctx,
1513
1616
  "GET",
@@ -1546,6 +1649,13 @@ function summarizeRelease(release) {
1546
1649
  publishedAt: release.publishedAt ?? null,
1547
1650
  ...release.previewUrl ? { previewUrl: release.previewUrl } : {}
1548
1651
  };
1652
+ const readers = (release.dataSources ?? []).filter((d) => d.reader);
1653
+ if (readers.length > 0 && release.status === "live") {
1654
+ summary2.readers = readers.map((d) => ({
1655
+ slug: d.slug,
1656
+ unread: d.readerUnread ?? 0
1657
+ }));
1658
+ }
1549
1659
  if (release.status !== "failed") {
1550
1660
  return summary2;
1551
1661
  }
@@ -1658,10 +1768,10 @@ __export(domains_exports, {
1658
1768
  customRemove: () => customRemove,
1659
1769
  customRetry: () => customRetry,
1660
1770
  findHostname: () => findHostname,
1661
- get: () => get5,
1771
+ get: () => get6,
1662
1772
  set: () => set
1663
1773
  });
1664
- function get5(ctx) {
1774
+ function get6(ctx) {
1665
1775
  return call(
1666
1776
  ctx,
1667
1777
  "GET",
@@ -1742,9 +1852,9 @@ __export(email_exports, {
1742
1852
  batch: () => batch2,
1743
1853
  batches: () => batches,
1744
1854
  checkDomain: () => checkDomain,
1745
- get: () => get6,
1855
+ get: () => get7,
1746
1856
  inbox: () => inbox,
1747
- list: () => list6,
1857
+ list: () => list7,
1748
1858
  listDomains: () => listDomains,
1749
1859
  removeDomain: () => removeDomain,
1750
1860
  stats: () => stats2,
@@ -1779,14 +1889,14 @@ async function resolveDomainId(ctx, direction, domain) {
1779
1889
  }
1780
1890
  return match.id;
1781
1891
  }
1782
- function list6(ctx, params = {}) {
1892
+ function list7(ctx, params = {}) {
1783
1893
  return call(
1784
1894
  ctx,
1785
1895
  "GET",
1786
1896
  `/_internal/v2/apps/${ctx.appId}/outbound-email/messages${qs(params)}`
1787
1897
  );
1788
1898
  }
1789
- function get6(ctx, messageId) {
1899
+ function get7(ctx, messageId) {
1790
1900
  return call(
1791
1901
  ctx,
1792
1902
  "GET",
@@ -1978,9 +2088,9 @@ var infra_exports = {};
1978
2088
  __export(infra_exports, {
1979
2089
  DEFAULT_WAIT_TIMEOUT_MS: () => DEFAULT_WAIT_TIMEOUT_MS4,
1980
2090
  destroy: () => destroy,
1981
- get: () => get7,
2091
+ get: () => get8,
1982
2092
  hibernate: () => hibernate,
1983
- list: () => list7,
2093
+ list: () => list8,
1984
2094
  logs: () => logs,
1985
2095
  provision: () => provision,
1986
2096
  rename: () => rename,
@@ -1993,14 +2103,14 @@ var POLL_MS5 = 3e3;
1993
2103
  function base6(appId) {
1994
2104
  return `/_internal/v2/apps/${appId}/infra`;
1995
2105
  }
1996
- function list7(ctx, params) {
2106
+ function list8(ctx, params) {
1997
2107
  return call(
1998
2108
  ctx,
1999
2109
  "GET",
2000
2110
  `${base6(ctx.appId)}${params?.includeDestroyed ? "?includeDestroyed=true" : ""}`
2001
2111
  );
2002
2112
  }
2003
- function get7(ctx, params) {
2113
+ function get8(ctx, params) {
2004
2114
  return call(
2005
2115
  ctx,
2006
2116
  "GET",
@@ -2070,7 +2180,7 @@ async function waitForPhase(ctx, params) {
2070
2180
  const wanted = new Set(params.phases);
2071
2181
  const arrived = (resource2) => wanted.has(resource2.phase) && (params.until?.(resource2) ?? true);
2072
2182
  const outcome = await pollUntil(
2073
- async () => (await get7(ctx, { id: params.id })).resource,
2183
+ async () => (await get8(ctx, { id: params.id })).resource,
2074
2184
  (resource2) => arrived(resource2) || resource2.phase === "failed",
2075
2185
  {
2076
2186
  timeoutMs,
@@ -2113,8 +2223,8 @@ __export(issues_exports, {
2113
2223
  del: () => del,
2114
2224
  edit: () => edit,
2115
2225
  filed: () => filed,
2116
- get: () => get8,
2117
- list: () => list8,
2226
+ get: () => get9,
2227
+ list: () => list9,
2118
2228
  reopen: () => reopen
2119
2229
  });
2120
2230
  function authorship(ctx) {
@@ -2129,7 +2239,7 @@ function listQuery(params) {
2129
2239
  cursor: params.cursor
2130
2240
  });
2131
2241
  }
2132
- function list8(ctx, params = {}) {
2242
+ function list9(ctx, params = {}) {
2133
2243
  return call(
2134
2244
  ctx,
2135
2245
  "GET",
@@ -2143,7 +2253,7 @@ function filed(ctx, params = {}) {
2143
2253
  `/_internal/v2/apps/${ctx.appId}/issues/filed${listQuery(params)}`
2144
2254
  );
2145
2255
  }
2146
- function get8(ctx, number) {
2256
+ function get9(ctx, number) {
2147
2257
  return call(
2148
2258
  ctx,
2149
2259
  "GET",
@@ -2360,9 +2470,9 @@ function grade(ctx, runId) {
2360
2470
  var methods_exports = {};
2361
2471
  __export(methods_exports, {
2362
2472
  invoke: () => invoke,
2363
- list: () => list9
2473
+ list: () => list10
2364
2474
  });
2365
- async function list9(ctx) {
2475
+ async function list10(ctx) {
2366
2476
  const dashboard = await call(
2367
2477
  ctx,
2368
2478
  "GET",
@@ -2525,19 +2635,19 @@ async function exportVideo(_ctx, params) {
2525
2635
  // src/ops/requests.ts
2526
2636
  var requests_exports = {};
2527
2637
  __export(requests_exports, {
2528
- get: () => get9,
2529
- list: () => list10,
2638
+ get: () => get10,
2639
+ list: () => list11,
2530
2640
  statsForMethod: () => statsForMethod,
2531
2641
  statsSummary: () => statsSummary
2532
2642
  });
2533
- function list10(ctx, params = {}) {
2643
+ function list11(ctx, params = {}) {
2534
2644
  return call(
2535
2645
  ctx,
2536
2646
  "GET",
2537
2647
  `/_internal/v2/apps/${ctx.appId}/requests${qs(params)}`
2538
2648
  );
2539
2649
  }
2540
- function get9(ctx, requestId) {
2650
+ function get10(ctx, requestId) {
2541
2651
  return call(
2542
2652
  ctx,
2543
2653
  "GET",
@@ -2563,18 +2673,18 @@ function statsForMethod(ctx, methodId, params = {}) {
2563
2673
  var secrets_exports = {};
2564
2674
  __export(secrets_exports, {
2565
2675
  del: () => del2,
2566
- get: () => get10,
2567
- list: () => list11,
2676
+ get: () => get11,
2677
+ list: () => list12,
2568
2678
  set: () => set2
2569
2679
  });
2570
- function list11(ctx) {
2680
+ function list12(ctx) {
2571
2681
  return call(
2572
2682
  ctx,
2573
2683
  "GET",
2574
2684
  `/_internal/v2/apps/${ctx.appId}/secrets`
2575
2685
  );
2576
2686
  }
2577
- function get10(ctx, key) {
2687
+ function get11(ctx, key) {
2578
2688
  return call(
2579
2689
  ctx,
2580
2690
  "GET",
@@ -2630,11 +2740,11 @@ function updateSettings(ctx, partial) {
2630
2740
  var users_exports = {};
2631
2741
  __export(users_exports, {
2632
2742
  createApiKey: () => createApiKey,
2633
- list: () => list12,
2743
+ list: () => list13,
2634
2744
  revokeApiKey: () => revokeApiKey,
2635
2745
  setRole: () => setRole
2636
2746
  });
2637
- function list12(ctx, params = {}) {
2747
+ function list13(ctx, params = {}) {
2638
2748
  return call(
2639
2749
  ctx,
2640
2750
  "GET",
@@ -2802,7 +2912,7 @@ function resolveOptions(options) {
2802
2912
  // loadWorkspaceAppId throws its own precise message if there's no
2803
2913
  // mindstudio.json to fall back to.
2804
2914
  appId: options.appId ?? loadWorkspaceAppId(),
2805
- baseUrl: options.baseUrl ?? process.env["API_BASE_URL"] ?? DEFAULT_BASE_URL
2915
+ baseUrl: options.baseUrl ?? process.env["MINDSTUDIO_BASE_URL"] ?? DEFAULT_BASE_URL
2806
2916
  };
2807
2917
  }
2808
2918
  function buildClient(ctx) {
@@ -2825,6 +2935,7 @@ function buildClient(ctx) {
2825
2935
  });
2826
2936
  },
2827
2937
  agent: bindOps(agent_exports, ctx),
2938
+ tasks: bindOps(tasks_exports, ctx),
2828
2939
  analytics: bindOps(analytics_exports, ctx),
2829
2940
  events: bindOps(events_exports, ctx),
2830
2941
  crashes: bindOps(crashes_exports, ctx),