@inneropen/marvin-sdk 4.2.0 → 4.3.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.
package/dist/platform.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  MarvinValidationError,
4
4
  SessionAuth,
5
5
  init_core
6
- } from "./chunk-DSVYCVQD.js";
6
+ } from "./chunk-LTX3MAUE.js";
7
7
 
8
8
  // src/platform/client.ts
9
9
  init_core();
@@ -20,6 +20,12 @@ var EntriesModule = class {
20
20
  async list() {
21
21
  return this.http.get("/api/platform/entries");
22
22
  }
23
+ /**
24
+ * Entry counts by status, zero-filled, plus `total` (what the sidebar's inbox badge reads).
25
+ */
26
+ async counts() {
27
+ return this.http.get("/api/platform/entries/counts");
28
+ }
23
29
  /**
24
30
  * Get a single entry by ID
25
31
  */
@@ -73,6 +79,38 @@ var EntriesModule = class {
73
79
  const validCollectionId = this.http.validatePathParam(collectionId, "collection ID");
74
80
  return this.http.delete(`/api/platform/entries/${validEntryId}/collections/${validCollectionId}`);
75
81
  }
82
+ /**
83
+ * Apply the entry's staged AI suggestion (`suggestionJson`) and clear it — the approval half of
84
+ * AI write-back. Returns the updated entry.
85
+ */
86
+ async applySuggestion(id) {
87
+ const validId = this.http.validatePathParam(id, "entry ID");
88
+ return this.http.post(`/api/platform/entries/${validId}/apply-suggestion`, {});
89
+ }
90
+ /**
91
+ * Discard the entry's staged AI suggestion without applying it.
92
+ */
93
+ async rejectSuggestion(id) {
94
+ const validId = this.http.validatePathParam(id, "entry ID");
95
+ return this.http.post(`/api/platform/entries/${validId}/reject-suggestion`, {});
96
+ }
97
+ /**
98
+ * Approve an AI-suggested asset on an entry: it becomes a normal attached asset (and reaches
99
+ * published output).
100
+ */
101
+ async approveSuggestedAsset(entryId, assetId) {
102
+ const e = this.http.validatePathParam(entryId, "entry ID");
103
+ const a = this.http.validatePathParam(assetId, "asset ID");
104
+ return this.http.post(`/api/platform/entries/${e}/suggested-assets/${a}/approve`, {});
105
+ }
106
+ /**
107
+ * Reject an AI-suggested asset: unlink it, and delete the asset if nothing else uses it.
108
+ */
109
+ async rejectSuggestedAsset(entryId, assetId) {
110
+ const e = this.http.validatePathParam(entryId, "entry ID");
111
+ const a = this.http.validatePathParam(assetId, "asset ID");
112
+ return this.http.post(`/api/platform/entries/${e}/suggested-assets/${a}/reject`, {});
113
+ }
76
114
  };
77
115
 
78
116
  // src/platform/collections.ts
@@ -113,6 +151,22 @@ var CollectionsModule = class {
113
151
  smartRules: rules
114
152
  });
115
153
  }
154
+ /**
155
+ * Preview unsaved smart-collection rules: how many items they match (`total`) and the first
156
+ * `limit` of them (default 10, at most 50), evaluated by the same code that materializes
157
+ * membership on save. Saves nothing. Needs EDITOR.
158
+ */
159
+ async preview(request) {
160
+ return this.http.post("/api/platform/collections/preview", request);
161
+ }
162
+ /**
163
+ * A collection's members, whatever it groups — entries, assets or resources — as
164
+ * `{id, label, slug, type}`, ordered by label.
165
+ */
166
+ async members(id) {
167
+ const validId = this.http.validatePathParam(id, "collection ID");
168
+ return this.http.get(`/api/platform/collections/${validId}/members`);
169
+ }
116
170
  /**
117
171
  * Update a collection
118
172
  */
@@ -286,6 +340,20 @@ var ResourcesModule = class {
286
340
  async getEntries(id) {
287
341
  return this.http.get(`/api/platform/resources/${id}/entries`);
288
342
  }
343
+ /**
344
+ * Apply the resource's staged AI suggestion (`suggestionJson`) and clear it. Needs EDITOR.
345
+ */
346
+ async applySuggestion(id) {
347
+ const validId = this.http.validatePathParam(id, "resource ID");
348
+ return this.http.post(`/api/platform/resources/${validId}/apply-suggestion`, {});
349
+ }
350
+ /**
351
+ * Discard the resource's staged AI suggestion without applying it. Needs EDITOR.
352
+ */
353
+ async rejectSuggestion(id) {
354
+ const validId = this.http.validatePathParam(id, "resource ID");
355
+ return this.http.post(`/api/platform/resources/${validId}/reject-suggestion`, {});
356
+ }
289
357
  };
290
358
 
291
359
  // src/platform/assets.ts
@@ -401,11 +469,19 @@ var AssetsModule = class {
401
469
  return this.http.delete(`/api/platform/assets/${validId}`);
402
470
  }
403
471
  /**
404
- * Fetch the raw file for an asset
472
+ * Download an asset's file: its bytes and content type. A redirect to storage is followed.
405
473
  */
406
- async getFile(id) {
474
+ async download(id) {
407
475
  const validId = this.http.validatePathParam(id, "asset ID");
408
- return this.http.get(`/api/platform/assets/${validId}/file`);
476
+ return this.http.getBinary(`/api/platform/assets/${validId}/file`);
477
+ }
478
+ /**
479
+ * Fetch the raw file for an asset.
480
+ * @deprecated Use {@link download}, which is typed. (Before 4.3 this resolved to `undefined` for
481
+ * any file that wasn't JSON; it now returns the same `BinaryResponse` as `download`.)
482
+ */
483
+ async getFile(id) {
484
+ return this.download(id);
409
485
  }
410
486
  /**
411
487
  * Get download URL for an asset file
@@ -416,6 +492,20 @@ var AssetsModule = class {
416
492
  const base = baseUrl || (typeof window !== "undefined" && window.location ? window.location.origin : "");
417
493
  return `${base}/api/platform/assets/${validId}/file`;
418
494
  }
495
+ /**
496
+ * Apply the asset's staged AI suggestion (`suggestionJson`) and clear it. Needs EDITOR.
497
+ */
498
+ async applySuggestion(id) {
499
+ const validId = this.http.validatePathParam(id, "asset ID");
500
+ return this.http.post(`/api/platform/assets/${validId}/apply-suggestion`, {});
501
+ }
502
+ /**
503
+ * Discard the asset's staged AI suggestion without applying it. Needs EDITOR.
504
+ */
505
+ async rejectSuggestion(id) {
506
+ const validId = this.http.validatePathParam(id, "asset ID");
507
+ return this.http.post(`/api/platform/assets/${validId}/reject-suggestion`, {});
508
+ }
419
509
  };
420
510
 
421
511
  // src/platform/apiClients.ts
@@ -666,6 +756,13 @@ var WorkspacesModule = class {
666
756
  async getStats() {
667
757
  return this.http.get("/api/platform/stats");
668
758
  }
759
+ /**
760
+ * The current workspace's dashboard: recent activity and the "needs attention" counts (inbox,
761
+ * drafts, entries needing review, pending AI suggestions, failures in the last 7 days).
762
+ */
763
+ async getDashboard() {
764
+ return this.http.get("/api/platform/stats/dashboard");
765
+ }
669
766
  /**
670
767
  * List available workspace backups
671
768
  */
@@ -2364,6 +2461,10 @@ var IncomingWebhooksModule = class {
2364
2461
  async list() {
2365
2462
  return this.http.get("/api/incoming-webhooks");
2366
2463
  }
2464
+ /** The signature schemes a webhook can pick (`signatureScheme`). */
2465
+ async signatureSchemes() {
2466
+ return this.http.get("/api/incoming-webhooks/signature-schemes");
2467
+ }
2367
2468
  async get(id) {
2368
2469
  const validId = this.http.validatePathParam(id, "incoming webhook id");
2369
2470
  return this.http.get(`/api/incoming-webhooks/${validId}`);
@@ -2392,6 +2493,59 @@ var IncomingWebhooksModule = class {
2392
2493
  }
2393
2494
  };
2394
2495
 
2496
+ // src/platform/blueprints.ts
2497
+ var BASE2 = "/api/groups/blueprints";
2498
+ var BlueprintsModule = class {
2499
+ constructor(http) {
2500
+ this.http = http;
2501
+ }
2502
+ http;
2503
+ query(options = {}) {
2504
+ return this.http.buildQueryString({ source: options.source, integration_id: options.integrationId });
2505
+ }
2506
+ /** The catalog, annotated with what this workspace can do about each blueprint. */
2507
+ async list(options = {}) {
2508
+ return this.http.get(BASE2, {
2509
+ kind: options.kind,
2510
+ category: options.category,
2511
+ source: options.source,
2512
+ integration_id: options.integrationId
2513
+ });
2514
+ }
2515
+ /** Category names in catalog order: core's first, then each provider's. */
2516
+ async categories() {
2517
+ return this.http.get(`${BASE2}/categories`);
2518
+ }
2519
+ /** One blueprint, including its payload. */
2520
+ async get(slug, options = {}) {
2521
+ const validSlug = this.http.validatePathParam(slug, "blueprint slug");
2522
+ return this.http.get(`${BASE2}/${validSlug}`, { source: options.source });
2523
+ }
2524
+ /**
2525
+ * Create this blueprint's object in the workspace if it isn't there yet. `params` fills the
2526
+ * parameters the blueprint declares, e.g. `{ entry_type: 'post' }`. Needs ADMIN.
2527
+ */
2528
+ async apply(slug, params, options = {}) {
2529
+ const validSlug = this.http.validatePathParam(slug, "blueprint slug");
2530
+ return this.http.post(`${BASE2}/${validSlug}/apply${this.query(options)}`, params);
2531
+ }
2532
+ /**
2533
+ * Apply several blueprints at once; entry types are created before the collections and tasks that
2534
+ * use them, whatever the order here. `params` is keyed by blueprint slug. Needs ADMIN.
2535
+ */
2536
+ async applyMany(slugs, params, options = {}) {
2537
+ return this.http.post(`${BASE2}/apply${this.query(options)}`, {
2538
+ slugs,
2539
+ ...params ? { params } : {}
2540
+ });
2541
+ }
2542
+ /** Replace an applied workflow's steps with what its integration declares now. Needs ADMIN. */
2543
+ async update(slug, params, options = {}) {
2544
+ const validSlug = this.http.validatePathParam(slug, "blueprint slug");
2545
+ return this.http.post(`${BASE2}/${validSlug}/update${this.query(options)}`, params);
2546
+ }
2547
+ };
2548
+
2395
2549
  // src/platform/site.ts
2396
2550
  var REBUILD = "/api/platform/site/rebuild";
2397
2551
  var SiteModule = class {
@@ -2458,6 +2612,8 @@ var PlatformClient = class extends HttpClient {
2458
2612
  automations;
2459
2613
  // Incoming (ingress) webhooks — tokened endpoints that drop events on the bus.
2460
2614
  incomingWebhooks;
2615
+ /** Blueprint catalog: browse and apply collections, entry types, tasks and workflows */
2616
+ blueprints;
2461
2617
  // Site — request a rebuild of the workspace's static site and read its status.
2462
2618
  site;
2463
2619
  // Admin modules
@@ -2502,6 +2658,7 @@ var PlatformClient = class extends HttpClient {
2502
2658
  this.ai = new AIModule(this);
2503
2659
  this.automations = new AutomationsModule(this);
2504
2660
  this.incomingWebhooks = new IncomingWebhooksModule(this);
2661
+ this.blueprints = new BlueprintsModule(this);
2505
2662
  this.site = new SiteModule(this);
2506
2663
  this.adminUsers = new AdminUsersModule(this);
2507
2664
  this.adminSystem = new AdminSystemModule(this);
@@ -2536,6 +2693,7 @@ export {
2536
2693
  AssetsModule,
2537
2694
  AuthModule,
2538
2695
  AutomationsModule,
2696
+ BlueprintsModule,
2539
2697
  CollectionsModule,
2540
2698
  EmailEventSubscriptionsModule,
2541
2699
  EmailTemplatesClient,
package/dist/publish.cjs CHANGED
@@ -524,6 +524,9 @@ var HttpClient = class _HttpClient {
524
524
  errorText
525
525
  );
526
526
  }
527
+ if (options?.responseType === "binary") {
528
+ return await this.readBinary(response, method, endpoint);
529
+ }
527
530
  const data = await this.readBody(response, method, endpoint);
528
531
  if (this.debug && data !== void 0) {
529
532
  const sanitized = this.sanitizeForLogging(data);
@@ -569,12 +572,34 @@ var HttpClient = class _HttpClient {
569
572
  );
570
573
  }
571
574
  }
575
+ /** A successful response's bytes; a 204/205 is an empty array. A failed read is a network error. */
576
+ async readBinary(response, method, endpoint) {
577
+ const contentType = response.headers.get("content-type");
578
+ if (response.status === 204 || response.status === 205) {
579
+ return { data: new Uint8Array(0), contentType };
580
+ }
581
+ try {
582
+ return { data: new Uint8Array(await response.arrayBuffer()), contentType };
583
+ } catch (error) {
584
+ const cause = error instanceof Error ? error : void 0;
585
+ throw new MarvinNetworkError(
586
+ `Reading the ${response.status} response to ${method} ${endpoint} failed: ${cause?.message ?? String(error)}`,
587
+ cause
588
+ );
589
+ }
590
+ }
572
591
  /**
573
592
  * GET request
574
593
  */
575
594
  async get(endpoint, params) {
576
595
  return this.request("GET", endpoint, { params });
577
596
  }
597
+ /**
598
+ * GET a binary body (a file download). Follows redirects; retried like any GET.
599
+ */
600
+ async getBinary(endpoint, params) {
601
+ return this.request("GET", endpoint, { params, responseType: "binary" });
602
+ }
578
603
  /**
579
604
  * POST request
580
605
  */
@@ -847,6 +872,11 @@ var Entry = class {
847
872
  };
848
873
 
849
874
  // src/entries/entries.ts
875
+ function csv(value) {
876
+ if (value === void 0) return void 0;
877
+ const joined = (Array.isArray(value) ? value : [value]).map((v) => v.trim()).filter(Boolean).join(",");
878
+ return joined || void 0;
879
+ }
850
880
  function toListEntry(raw) {
851
881
  const { collections, ...rest } = raw;
852
882
  return {
@@ -868,6 +898,9 @@ var EntriesModule = class {
868
898
  const queryString = this.http.buildQueryString({
869
899
  entry_type: options.entryType,
870
900
  collection: options.collection,
901
+ tag: csv(options.tag),
902
+ slug: csv(options.slug),
903
+ updated_since: options.updatedSince instanceof Date ? options.updatedSince.toISOString() : options.updatedSince,
871
904
  limit: options.limit,
872
905
  offset: options.offset,
873
906
  expand: options.expand
@@ -1080,6 +1113,14 @@ var AssetsModule = class {
1080
1113
  const endpoint = `/api/publish/${this.workspaceSlug}/assets/${slugOrId}`;
1081
1114
  return this.http.fetch(endpoint);
1082
1115
  }
1116
+ /**
1117
+ * Download a published asset's file by slug: its bytes and content type. The file route
1118
+ * redirects to storage; the redirect is followed. Needs the `read:assets` permission.
1119
+ */
1120
+ async download(slug) {
1121
+ const validSlug = this.http.validatePathParam(slug, "asset slug");
1122
+ return this.http.getBinary(`/api/publish/${this.workspaceSlug}/assets/${validSlug}/file`);
1123
+ }
1083
1124
  /**
1084
1125
  * Convenience: Get all images
1085
1126
  */
@@ -1,7 +1,7 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-BiXcixLB.cjs';
2
- export { C as Collection, E as Entry, b as MarvinApiError, c as MarvinAuthError, d as MarvinCache, e as MarvinConfigError, f as MarvinError, g as MarvinNetworkError, h as MarvinNotFoundError, i as MarvinServerError, j as MarvinValidationError, P as PaginatedResponse, k as PaginationMeta, l as PaginationParams, R as Resource, W as Workspace, m as createConfigFromEnv, n as createPaginatedResponse, o as extractData, p as isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BiXcixLB.cjs';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-gZtGa576.cjs';
2
+ export { C as Collection, E as Entry, b as MarvinApiError, c as MarvinAuthError, d as MarvinCache, e as MarvinConfigError, f as MarvinError, g as MarvinNetworkError, h as MarvinNotFoundError, i as MarvinServerError, j as MarvinValidationError, P as PaginatedResponse, k as PaginationMeta, l as PaginationParams, R as Resource, W as Workspace, m as createConfigFromEnv, n as createPaginatedResponse, o as extractData, p as isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-gZtGa576.cjs';
3
3
  export { e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.cjs';
4
- export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-B_rEmJuO.cjs';
4
+ export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, b as HttpClientConfig } from './HttpClient-DXMNOPqu.cjs';
5
5
 
6
6
  /**
7
7
  * Publishing API Entry Point
package/dist/publish.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-BjJXe-YT.js';
2
- export { C as Collection, E as Entry, b as MarvinApiError, c as MarvinAuthError, d as MarvinCache, e as MarvinConfigError, f as MarvinError, g as MarvinNetworkError, h as MarvinNotFoundError, i as MarvinServerError, j as MarvinValidationError, P as PaginatedResponse, k as PaginationMeta, l as PaginationParams, R as Resource, W as Workspace, m as createConfigFromEnv, n as createPaginatedResponse, o as extractData, p as isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BjJXe-YT.js';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-CdsjwIyH.js';
2
+ export { C as Collection, E as Entry, b as MarvinApiError, c as MarvinAuthError, d as MarvinCache, e as MarvinConfigError, f as MarvinError, g as MarvinNetworkError, h as MarvinNotFoundError, i as MarvinServerError, j as MarvinValidationError, P as PaginatedResponse, k as PaginationMeta, l as PaginationParams, R as Resource, W as Workspace, m as createConfigFromEnv, n as createPaginatedResponse, o as extractData, p as isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-CdsjwIyH.js';
3
3
  export { e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.js';
4
- export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-B_rEmJuO.js';
4
+ export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, b as HttpClientConfig } from './HttpClient-DXMNOPqu.js';
5
5
 
6
6
  /**
7
7
  * Publishing API Entry Point
package/dist/publish.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  init_resource,
14
14
  init_workspace,
15
15
  isFullEntryData
16
- } from "./chunk-HFNIFS2A.js";
16
+ } from "./chunk-KXI2FQSO.js";
17
17
  import {
18
18
  BearerTokenAuth,
19
19
  HttpClient,
@@ -33,7 +33,7 @@ import {
33
33
  isPaginatedResponse,
34
34
  offsetToPage,
35
35
  pageToOffset
36
- } from "./chunk-DSVYCVQD.js";
36
+ } from "./chunk-LTX3MAUE.js";
37
37
 
38
38
  // src/publish.ts
39
39
  init_marvin();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneropen/marvin-sdk",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Official TypeScript SDK for Marvin CMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",