@inneropen/marvin-sdk 4.1.0 → 4.2.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.
@@ -135,6 +135,12 @@ var init_config = __esm({
135
135
  });
136
136
 
137
137
  // src/entries/entry.ts
138
+ function isFullEntryData(raw) {
139
+ if (!raw || typeof raw !== "object") return false;
140
+ const record = raw;
141
+ if ("assetSlugs" in record || "resourceSlugs" in record) return false;
142
+ return Array.isArray(record.assets) || Array.isArray(record.resources);
143
+ }
138
144
  var Entry;
139
145
  var init_entry = __esm({
140
146
  "src/entries/entry.ts"() {
@@ -337,19 +343,21 @@ var init_entries = __esm({
337
343
  }
338
344
  http;
339
345
  workspaceSlug;
340
- /**
341
- * Get all published entries
342
- */
343
346
  async list(options = {}) {
344
347
  const queryString = this.http.buildQueryString({
345
348
  entry_type: options.entryType,
346
349
  collection: options.collection,
347
350
  limit: options.limit,
348
- offset: options.offset
351
+ offset: options.offset,
352
+ expand: options.expand
349
353
  });
350
354
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
351
355
  const response = await this.http.fetch(endpoint);
352
- return (response.data || []).map(toListEntry);
356
+ const data = response.data || [];
357
+ if (options.expand === "full" && data.every(isFullEntryData)) {
358
+ return data.map((entry) => new Entry(entry));
359
+ }
360
+ return data.map(toListEntry);
353
361
  }
354
362
  /**
355
363
  * Get a single entry by slug
@@ -395,6 +403,7 @@ var init_collections = __esm({
395
403
  "src/collections/collections.ts"() {
396
404
  "use strict";
397
405
  init_collection();
406
+ init_entry();
398
407
  init_errors();
399
408
  CollectionsModule = class {
400
409
  constructor(http, workspaceSlug) {
@@ -427,18 +436,25 @@ var init_collections = __esm({
427
436
  throw error;
428
437
  }
429
438
  }
430
- /**
431
- * Get entries in a collection with junction context surfaced directly.
432
- * Each entry has role/position/junctionMetadata from this collection's junction,
433
- * and collections reduced to slugs of other memberships.
434
- * Returns empty array if collection is not found.
435
- */
436
- async entries(slug) {
437
- const collection = await this.get(slug);
438
- if (Array.isArray(collection)) {
439
- return collection;
439
+ async entries(slug, options = {}) {
440
+ if (options.expand !== "full") {
441
+ const collection = await this.get(slug);
442
+ return Array.isArray(collection) ? collection : collection.entries;
443
+ }
444
+ let data;
445
+ try {
446
+ data = await this.http.fetch(
447
+ `/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
448
+ );
449
+ } catch (error) {
450
+ if (error instanceof MarvinNotFoundError) return [];
451
+ throw error;
452
+ }
453
+ const entries = data.entries ?? [];
454
+ if (entries.every(isFullEntryData)) {
455
+ return data.entries.map((entry) => new Entry(entry));
440
456
  }
441
- return collection.entries;
457
+ return new Collection(data).entries;
442
458
  }
443
459
  /**
444
460
  * Try multiple collection slugs in fallback order.
@@ -888,6 +904,7 @@ export {
888
904
  createConfigFromEnv,
889
905
  config_exports,
890
906
  init_config,
907
+ isFullEntryData,
891
908
  Entry,
892
909
  init_entry,
893
910
  Collection,