@inneropen/marvin-sdk 4.1.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/index.cjs CHANGED
@@ -510,6 +510,9 @@ var init_HttpClient = __esm({
510
510
  errorText
511
511
  );
512
512
  }
513
+ if (options?.responseType === "binary") {
514
+ return await this.readBinary(response, method, endpoint);
515
+ }
513
516
  const data = await this.readBody(response, method, endpoint);
514
517
  if (this.debug && data !== void 0) {
515
518
  const sanitized = this.sanitizeForLogging(data);
@@ -555,12 +558,34 @@ var init_HttpClient = __esm({
555
558
  );
556
559
  }
557
560
  }
561
+ /** A successful response's bytes; a 204/205 is an empty array. A failed read is a network error. */
562
+ async readBinary(response, method, endpoint) {
563
+ const contentType = response.headers.get("content-type");
564
+ if (response.status === 204 || response.status === 205) {
565
+ return { data: new Uint8Array(0), contentType };
566
+ }
567
+ try {
568
+ return { data: new Uint8Array(await response.arrayBuffer()), contentType };
569
+ } catch (error) {
570
+ const cause = error instanceof Error ? error : void 0;
571
+ throw new MarvinNetworkError(
572
+ `Reading the ${response.status} response to ${method} ${endpoint} failed: ${cause?.message ?? String(error)}`,
573
+ cause
574
+ );
575
+ }
576
+ }
558
577
  /**
559
578
  * GET request
560
579
  */
561
580
  async get(endpoint, params) {
562
581
  return this.request("GET", endpoint, { params });
563
582
  }
583
+ /**
584
+ * GET a binary body (a file download). Follows redirects; retried like any GET.
585
+ */
586
+ async getBinary(endpoint, params) {
587
+ return this.request("GET", endpoint, { params, responseType: "binary" });
588
+ }
564
589
  /**
565
590
  * POST request
566
591
  */
@@ -915,6 +940,12 @@ var init_http2 = __esm({
915
940
  });
916
941
 
917
942
  // src/entries/entry.ts
943
+ function isFullEntryData(raw) {
944
+ if (!raw || typeof raw !== "object") return false;
945
+ const record = raw;
946
+ if ("assetSlugs" in record || "resourceSlugs" in record) return false;
947
+ return Array.isArray(record.assets) || Array.isArray(record.resources);
948
+ }
918
949
  var Entry;
919
950
  var init_entry = __esm({
920
951
  "src/entries/entry.ts"() {
@@ -987,6 +1018,11 @@ var init_entry = __esm({
987
1018
  });
988
1019
 
989
1020
  // src/entries/entries.ts
1021
+ function csv(value) {
1022
+ if (value === void 0) return void 0;
1023
+ const joined = (Array.isArray(value) ? value : [value]).map((v) => v.trim()).filter(Boolean).join(",");
1024
+ return joined || void 0;
1025
+ }
990
1026
  function toListEntry(raw) {
991
1027
  const { collections, ...rest } = raw;
992
1028
  return {
@@ -1010,19 +1046,24 @@ var init_entries = __esm({
1010
1046
  }
1011
1047
  http;
1012
1048
  workspaceSlug;
1013
- /**
1014
- * Get all published entries
1015
- */
1016
1049
  async list(options = {}) {
1017
1050
  const queryString = this.http.buildQueryString({
1018
1051
  entry_type: options.entryType,
1019
1052
  collection: options.collection,
1053
+ tag: csv(options.tag),
1054
+ slug: csv(options.slug),
1055
+ updated_since: options.updatedSince instanceof Date ? options.updatedSince.toISOString() : options.updatedSince,
1020
1056
  limit: options.limit,
1021
- offset: options.offset
1057
+ offset: options.offset,
1058
+ expand: options.expand
1022
1059
  });
1023
1060
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
1024
1061
  const response = await this.http.fetch(endpoint);
1025
- return (response.data || []).map(toListEntry);
1062
+ const data = response.data || [];
1063
+ if (options.expand === "full" && data.every(isFullEntryData)) {
1064
+ return data.map((entry) => new Entry(entry));
1065
+ }
1066
+ return data.map(toListEntry);
1026
1067
  }
1027
1068
  /**
1028
1069
  * Get a single entry by slug
@@ -1134,6 +1175,7 @@ var init_collections = __esm({
1134
1175
  "src/collections/collections.ts"() {
1135
1176
  "use strict";
1136
1177
  init_collection();
1178
+ init_entry();
1137
1179
  init_errors();
1138
1180
  CollectionsModule = class {
1139
1181
  constructor(http, workspaceSlug) {
@@ -1166,18 +1208,25 @@ var init_collections = __esm({
1166
1208
  throw error;
1167
1209
  }
1168
1210
  }
1169
- /**
1170
- * Get entries in a collection with junction context surfaced directly.
1171
- * Each entry has role/position/junctionMetadata from this collection's junction,
1172
- * and collections reduced to slugs of other memberships.
1173
- * Returns empty array if collection is not found.
1174
- */
1175
- async entries(slug) {
1176
- const collection = await this.get(slug);
1177
- if (Array.isArray(collection)) {
1178
- return collection;
1211
+ async entries(slug, options = {}) {
1212
+ if (options.expand !== "full") {
1213
+ const collection = await this.get(slug);
1214
+ return Array.isArray(collection) ? collection : collection.entries;
1179
1215
  }
1180
- return collection.entries;
1216
+ let data;
1217
+ try {
1218
+ data = await this.http.fetch(
1219
+ `/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
1220
+ );
1221
+ } catch (error) {
1222
+ if (error instanceof MarvinNotFoundError) return [];
1223
+ throw error;
1224
+ }
1225
+ const entries = data.entries ?? [];
1226
+ if (entries.every(isFullEntryData)) {
1227
+ return data.entries.map((entry) => new Entry(entry));
1228
+ }
1229
+ return new Collection(data).entries;
1181
1230
  }
1182
1231
  /**
1183
1232
  * Try multiple collection slugs in fallback order.
@@ -1237,6 +1286,14 @@ var init_assets = __esm({
1237
1286
  const endpoint = `/api/publish/${this.workspaceSlug}/assets/${slugOrId}`;
1238
1287
  return this.http.fetch(endpoint);
1239
1288
  }
1289
+ /**
1290
+ * Download a published asset's file by slug: its bytes and content type. The file route
1291
+ * redirects to storage; the redirect is followed. Needs the `read:assets` permission.
1292
+ */
1293
+ async download(slug) {
1294
+ const validSlug = this.http.validatePathParam(slug, "asset slug");
1295
+ return this.http.getBinary(`/api/publish/${this.workspaceSlug}/assets/${validSlug}/file`);
1296
+ }
1240
1297
  /**
1241
1298
  * Convenience: Get all images
1242
1299
  */
@@ -1665,6 +1722,7 @@ __export(index_exports, {
1665
1722
  createMarvinClient: () => createMarvinClient,
1666
1723
  createPaginatedResponse: () => createPaginatedResponse,
1667
1724
  extractData: () => extractData,
1725
+ isFullEntryData: () => isFullEntryData,
1668
1726
  isPaginatedResponse: () => isPaginatedResponse,
1669
1727
  offsetToPage: () => offsetToPage,
1670
1728
  pageToOffset: () => pageToOffset
@@ -1766,6 +1824,7 @@ function createMarvinClient(config) {
1766
1824
  createMarvinClient,
1767
1825
  createPaginatedResponse,
1768
1826
  extractData,
1827
+ isFullEntryData,
1769
1828
  isPaginatedResponse,
1770
1829
  offsetToPage,
1771
1830
  pageToOffset
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-6keK-yvS.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 isPaginatedResponse, q as offsetToPage, r as pageToOffset } from './marvin-6keK-yvS.cjs';
3
- import { H as HttpClient } from './HttpClient-B_rEmJuO.cjs';
4
- export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-B_rEmJuO.cjs';
5
- import { A as AuthToken$1 } from './index-CX4jvPAA.cjs';
6
- export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, L as ListEntry, M as MarvinAsset, g as MarvinCollection, h as MarvinEntry, i as MarvinEntryListItem, j as MarvinEntryType, k as MarvinPublishResponse, l as MarvinResource, m as MarvinSite, P as PublishedAssetRead, n as PublishedCollectionSummary, o as PublishedEntryAsset, p as PublishedEntryResource, q as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-CX4jvPAA.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
+ import { H as HttpClient } from './HttpClient-DXMNOPqu.cjs';
4
+ export { A as AuthStrategy, B as BearerTokenAuth, a as BinaryResponse, b as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-DXMNOPqu.cjs';
5
+ import { A as AuthToken$1 } from './index-BEEbnrXV.cjs';
6
+ export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, 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 PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.cjs';
7
7
 
8
8
  /**
9
9
  * Authentication & User Registration
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-Cndwz82G.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 isPaginatedResponse, q as offsetToPage, r as pageToOffset } from './marvin-Cndwz82G.js';
3
- import { H as HttpClient } from './HttpClient-B_rEmJuO.js';
4
- export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-B_rEmJuO.js';
5
- import { A as AuthToken$1 } from './index-CX4jvPAA.js';
6
- export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, L as ListEntry, M as MarvinAsset, g as MarvinCollection, h as MarvinEntry, i as MarvinEntryListItem, j as MarvinEntryType, k as MarvinPublishResponse, l as MarvinResource, m as MarvinSite, P as PublishedAssetRead, n as PublishedCollectionSummary, o as PublishedEntryAsset, p as PublishedEntryResource, q as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-CX4jvPAA.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
+ import { H as HttpClient } from './HttpClient-DXMNOPqu.js';
4
+ export { A as AuthStrategy, B as BearerTokenAuth, a as BinaryResponse, b as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-DXMNOPqu.js';
5
+ import { A as AuthToken$1 } from './index-BEEbnrXV.js';
6
+ export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, 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 PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.js';
7
7
 
8
8
  /**
9
9
  * Authentication & User Registration
package/dist/index.js CHANGED
@@ -12,8 +12,9 @@ import {
12
12
  init_marvin,
13
13
  init_resource,
14
14
  init_workspace,
15
+ isFullEntryData,
15
16
  marvin_exports
16
- } from "./chunk-VS6R3V3K.js";
17
+ } from "./chunk-KXI2FQSO.js";
17
18
  import {
18
19
  BearerTokenAuth,
19
20
  HttpClient,
@@ -36,7 +37,7 @@ import {
36
37
  offsetToPage,
37
38
  pageToOffset,
38
39
  validateEmail
39
- } from "./chunk-DSVYCVQD.js";
40
+ } from "./chunk-LTX3MAUE.js";
40
41
 
41
42
  // src/index.ts
42
43
  init_marvin();
@@ -134,6 +135,7 @@ export {
134
135
  createMarvinClient,
135
136
  createPaginatedResponse,
136
137
  extractData,
138
+ isFullEntryData,
137
139
  isPaginatedResponse,
138
140
  offsetToPage,
139
141
  pageToOffset
@@ -1,5 +1,5 @@
1
- import { q as PublishedEntryType, l as MarvinResource, M as MarvinAsset, g as MarvinCollection, a as CollectionEntry, n as PublishedCollectionSummary, h as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, L as ListEntry, m as MarvinSite, f as GetResourcesOptions$1 } from './index-CX4jvPAA.cjs';
2
- import { H as HttpClient } from './HttpClient-B_rEmJuO.cjs';
1
+ import { s as PublishedEntryType, n as MarvinResource, M as MarvinAsset, h as MarvinCollection, a as CollectionEntry, j as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, p as PublishedCollectionSummary, e as ExpandOptions, L as ListEntry, o as MarvinSite, g as GetResourcesOptions$1 } from './index-BEEbnrXV.js';
2
+ import { H as HttpClient, a as BinaryResponse } from './HttpClient-DXMNOPqu.js';
3
3
 
4
4
  /**
5
5
  * Marvin SDK Configuration
@@ -274,6 +274,11 @@ declare class AssetsModule {
274
274
  * Get a single published asset by slug or ID
275
275
  */
276
276
  get(slugOrId: string): Promise<MarvinAsset>;
277
+ /**
278
+ * Download a published asset's file by slug: its bytes and content type. The file route
279
+ * redirects to storage; the redirect is followed. Needs the `read:assets` permission.
280
+ */
281
+ download(slug: string): Promise<BinaryResponse>;
277
282
  /**
278
283
  * Convenience: Get all images
279
284
  */
@@ -316,42 +321,15 @@ declare class Collection {
316
321
  }
317
322
 
318
323
  /**
319
- * Collections Module - Manage collections
324
+ * Entry - Rich object representing a single entry
320
325
  */
321
326
 
322
- declare class CollectionsModule {
323
- private http;
324
- private workspaceSlug;
325
- constructor(http: MarvinHttpClient, workspaceSlug: string);
326
- /**
327
- * Get all collections
328
- */
329
- list(): Promise<PublishedCollectionSummary[]>;
330
- /**
331
- * Get a single collection by slug.
332
- * Returns an empty array if the collection is not found (404).
333
- */
334
- get(slug: string): Promise<Collection | []>;
335
- /**
336
- * Get entries in a collection with junction context surfaced directly.
337
- * Each entry has role/position/junctionMetadata from this collection's junction,
338
- * and collections reduced to slugs of other memberships.
339
- * Returns empty array if collection is not found.
340
- */
341
- entries(slug: string): Promise<CollectionEntry[]>;
342
- /**
343
- * Try multiple collection slugs in fallback order.
344
- * Returns entries from the first collection that exists and has entries.
345
- */
346
- fallback(slugs: string[], options?: {
347
- requireEntries?: boolean;
348
- }): Promise<CollectionEntry[]>;
349
- }
350
-
351
327
  /**
352
- * Entry - Rich object representing a single entry
328
+ * True for a full entry as the API sends it (`PublishedEntryRead`): `assets[]` placements and no
329
+ * `assetSlugs`/`resourceSlugs`. A list item (`PublishedEntryListItem`) has only the slugs. Lets an
330
+ * `expand: 'full'` read tell an expanded response from an older server's list items.
353
331
  */
354
-
332
+ declare function isFullEntryData(raw: unknown): raw is MarvinEntry;
355
333
  declare class Entry {
356
334
  private raw;
357
335
  constructor(raw: MarvinEntry);
@@ -389,6 +367,46 @@ declare class Entry {
389
367
  toJSON(): MarvinEntry;
390
368
  }
391
369
 
370
+ /**
371
+ * Collections Module - Manage collections
372
+ */
373
+
374
+ declare class CollectionsModule {
375
+ private http;
376
+ private workspaceSlug;
377
+ constructor(http: MarvinHttpClient, workspaceSlug: string);
378
+ /**
379
+ * Get all collections
380
+ */
381
+ list(): Promise<PublishedCollectionSummary[]>;
382
+ /**
383
+ * Get a single collection by slug.
384
+ * Returns an empty array if the collection is not found (404).
385
+ */
386
+ get(slug: string): Promise<Collection | []>;
387
+ /**
388
+ * Get entries in a collection with junction context surfaced directly.
389
+ * Each entry has role/position/junctionMetadata from this collection's junction,
390
+ * and collections reduced to slugs of other memberships.
391
+ * Returns empty array if collection is not found.
392
+ *
393
+ * With `{ expand: 'full' }` the whole collection comes back as full entries in one request:
394
+ * `Entry` objects, the same as `entry(slug)` returns, each with its `order` in this collection
395
+ * and every membership under `collections`. A server without `expand` support (or a collection
396
+ * past the server's expand cap) returns list items instead; those come back as
397
+ * `CollectionEntry[]`, exactly as without the option, so check with `instanceof Entry`.
398
+ */
399
+ entries(slug: string): Promise<CollectionEntry[]>;
400
+ entries(slug: string, options?: ExpandOptions): Promise<Entry[] | CollectionEntry[]>;
401
+ /**
402
+ * Try multiple collection slugs in fallback order.
403
+ * Returns entries from the first collection that exists and has entries.
404
+ */
405
+ fallback(slugs: string[], options?: {
406
+ requireEntries?: boolean;
407
+ }): Promise<CollectionEntry[]>;
408
+ }
409
+
392
410
  /**
393
411
  * Entries Module - Manage entries
394
412
  */
@@ -396,6 +414,12 @@ declare class Entry {
396
414
  interface GetEntriesOptions {
397
415
  entryType?: string;
398
416
  collection?: string;
417
+ /** Only entries carrying any of these tag slugs. */
418
+ tag?: string | string[];
419
+ /** Only entries with these slugs. */
420
+ slug?: string | string[];
421
+ /** Only entries updated at or after this time (ISO 8601, or a Date). */
422
+ updatedSince?: string | Date;
399
423
  limit?: number;
400
424
  offset?: number;
401
425
  status?: string;
@@ -406,8 +430,13 @@ declare class EntriesModule {
406
430
  constructor(http: MarvinHttpClient, workspaceSlug: string);
407
431
  /**
408
432
  * Get all published entries
433
+ *
434
+ * With `{ expand: 'full' }` each entry on the page comes back as a full `Entry` (the
435
+ * single-entry read), so no per-entry reads are needed. A server without `expand` support
436
+ * returns list items instead; those come back as `ListEntry[]`, as without the option.
409
437
  */
410
438
  list(options?: GetEntriesOptions): Promise<ListEntry[]>;
439
+ list(options: GetEntriesOptions & ExpandOptions): Promise<Entry[] | ListEntry[]>;
411
440
  /**
412
441
  * Get a single entry by slug
413
442
  * Returns null if entry is not found (404)
@@ -580,4 +609,4 @@ declare class MarvinClient {
580
609
  getResourceEntries(slug: string): Promise<string[]>;
581
610
  }
582
611
 
583
- export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isPaginatedResponse as p, offsetToPage as q, pageToOffset as r };
612
+ export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isFullEntryData as p, isPaginatedResponse as q, offsetToPage as r, pageToOffset as s };
@@ -1,5 +1,5 @@
1
- import { q as PublishedEntryType, l as MarvinResource, M as MarvinAsset, g as MarvinCollection, a as CollectionEntry, n as PublishedCollectionSummary, h as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, L as ListEntry, m as MarvinSite, f as GetResourcesOptions$1 } from './index-CX4jvPAA.js';
2
- import { H as HttpClient } from './HttpClient-B_rEmJuO.js';
1
+ import { s as PublishedEntryType, n as MarvinResource, M as MarvinAsset, h as MarvinCollection, a as CollectionEntry, j as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, p as PublishedCollectionSummary, e as ExpandOptions, L as ListEntry, o as MarvinSite, g as GetResourcesOptions$1 } from './index-BEEbnrXV.cjs';
2
+ import { H as HttpClient, a as BinaryResponse } from './HttpClient-DXMNOPqu.cjs';
3
3
 
4
4
  /**
5
5
  * Marvin SDK Configuration
@@ -274,6 +274,11 @@ declare class AssetsModule {
274
274
  * Get a single published asset by slug or ID
275
275
  */
276
276
  get(slugOrId: string): Promise<MarvinAsset>;
277
+ /**
278
+ * Download a published asset's file by slug: its bytes and content type. The file route
279
+ * redirects to storage; the redirect is followed. Needs the `read:assets` permission.
280
+ */
281
+ download(slug: string): Promise<BinaryResponse>;
277
282
  /**
278
283
  * Convenience: Get all images
279
284
  */
@@ -316,42 +321,15 @@ declare class Collection {
316
321
  }
317
322
 
318
323
  /**
319
- * Collections Module - Manage collections
324
+ * Entry - Rich object representing a single entry
320
325
  */
321
326
 
322
- declare class CollectionsModule {
323
- private http;
324
- private workspaceSlug;
325
- constructor(http: MarvinHttpClient, workspaceSlug: string);
326
- /**
327
- * Get all collections
328
- */
329
- list(): Promise<PublishedCollectionSummary[]>;
330
- /**
331
- * Get a single collection by slug.
332
- * Returns an empty array if the collection is not found (404).
333
- */
334
- get(slug: string): Promise<Collection | []>;
335
- /**
336
- * Get entries in a collection with junction context surfaced directly.
337
- * Each entry has role/position/junctionMetadata from this collection's junction,
338
- * and collections reduced to slugs of other memberships.
339
- * Returns empty array if collection is not found.
340
- */
341
- entries(slug: string): Promise<CollectionEntry[]>;
342
- /**
343
- * Try multiple collection slugs in fallback order.
344
- * Returns entries from the first collection that exists and has entries.
345
- */
346
- fallback(slugs: string[], options?: {
347
- requireEntries?: boolean;
348
- }): Promise<CollectionEntry[]>;
349
- }
350
-
351
327
  /**
352
- * Entry - Rich object representing a single entry
328
+ * True for a full entry as the API sends it (`PublishedEntryRead`): `assets[]` placements and no
329
+ * `assetSlugs`/`resourceSlugs`. A list item (`PublishedEntryListItem`) has only the slugs. Lets an
330
+ * `expand: 'full'` read tell an expanded response from an older server's list items.
353
331
  */
354
-
332
+ declare function isFullEntryData(raw: unknown): raw is MarvinEntry;
355
333
  declare class Entry {
356
334
  private raw;
357
335
  constructor(raw: MarvinEntry);
@@ -389,6 +367,46 @@ declare class Entry {
389
367
  toJSON(): MarvinEntry;
390
368
  }
391
369
 
370
+ /**
371
+ * Collections Module - Manage collections
372
+ */
373
+
374
+ declare class CollectionsModule {
375
+ private http;
376
+ private workspaceSlug;
377
+ constructor(http: MarvinHttpClient, workspaceSlug: string);
378
+ /**
379
+ * Get all collections
380
+ */
381
+ list(): Promise<PublishedCollectionSummary[]>;
382
+ /**
383
+ * Get a single collection by slug.
384
+ * Returns an empty array if the collection is not found (404).
385
+ */
386
+ get(slug: string): Promise<Collection | []>;
387
+ /**
388
+ * Get entries in a collection with junction context surfaced directly.
389
+ * Each entry has role/position/junctionMetadata from this collection's junction,
390
+ * and collections reduced to slugs of other memberships.
391
+ * Returns empty array if collection is not found.
392
+ *
393
+ * With `{ expand: 'full' }` the whole collection comes back as full entries in one request:
394
+ * `Entry` objects, the same as `entry(slug)` returns, each with its `order` in this collection
395
+ * and every membership under `collections`. A server without `expand` support (or a collection
396
+ * past the server's expand cap) returns list items instead; those come back as
397
+ * `CollectionEntry[]`, exactly as without the option, so check with `instanceof Entry`.
398
+ */
399
+ entries(slug: string): Promise<CollectionEntry[]>;
400
+ entries(slug: string, options?: ExpandOptions): Promise<Entry[] | CollectionEntry[]>;
401
+ /**
402
+ * Try multiple collection slugs in fallback order.
403
+ * Returns entries from the first collection that exists and has entries.
404
+ */
405
+ fallback(slugs: string[], options?: {
406
+ requireEntries?: boolean;
407
+ }): Promise<CollectionEntry[]>;
408
+ }
409
+
392
410
  /**
393
411
  * Entries Module - Manage entries
394
412
  */
@@ -396,6 +414,12 @@ declare class Entry {
396
414
  interface GetEntriesOptions {
397
415
  entryType?: string;
398
416
  collection?: string;
417
+ /** Only entries carrying any of these tag slugs. */
418
+ tag?: string | string[];
419
+ /** Only entries with these slugs. */
420
+ slug?: string | string[];
421
+ /** Only entries updated at or after this time (ISO 8601, or a Date). */
422
+ updatedSince?: string | Date;
399
423
  limit?: number;
400
424
  offset?: number;
401
425
  status?: string;
@@ -406,8 +430,13 @@ declare class EntriesModule {
406
430
  constructor(http: MarvinHttpClient, workspaceSlug: string);
407
431
  /**
408
432
  * Get all published entries
433
+ *
434
+ * With `{ expand: 'full' }` each entry on the page comes back as a full `Entry` (the
435
+ * single-entry read), so no per-entry reads are needed. A server without `expand` support
436
+ * returns list items instead; those come back as `ListEntry[]`, as without the option.
409
437
  */
410
438
  list(options?: GetEntriesOptions): Promise<ListEntry[]>;
439
+ list(options: GetEntriesOptions & ExpandOptions): Promise<Entry[] | ListEntry[]>;
411
440
  /**
412
441
  * Get a single entry by slug
413
442
  * Returns null if entry is not found (404)
@@ -580,4 +609,4 @@ declare class MarvinClient {
580
609
  getResourceEntries(slug: string): Promise<string[]>;
581
610
  }
582
611
 
583
- export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isPaginatedResponse as p, offsetToPage as q, pageToOffset as r };
612
+ export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isFullEntryData as p, isPaginatedResponse as q, offsetToPage as r, pageToOffset as s };