@inneropen/marvin-sdk 3.2.0-next.1 → 3.2.0-next.11

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.
@@ -270,7 +270,7 @@ var init_HttpClient = __esm({
270
270
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
271
271
  const startTime = Date.now();
272
272
  if (this.debug) {
273
- this.logger.log(`[Marvin] ${method} ${url}`);
273
+ this.logger.log(`[Marvin SDK] ${method} ${url}`);
274
274
  }
275
275
  try {
276
276
  const response = await fetch(url, {
@@ -284,7 +284,7 @@ var init_HttpClient = __esm({
284
284
  const duration = Date.now() - startTime;
285
285
  if (this.debug) {
286
286
  this.logger.log(
287
- `[Marvin] ${response.status} ${response.statusText} (${duration}ms)`
287
+ `[Marvin SDK] ${response.status} ${response.statusText} (${duration}ms)`
288
288
  );
289
289
  }
290
290
  if (response.status === 401 && this.auth.handleUnauthorized) {
@@ -294,7 +294,7 @@ var init_HttpClient = __esm({
294
294
  const errorText = await response.text().catch(() => "");
295
295
  if (this.debug) {
296
296
  this.logger.error(
297
- `[Marvin] Error response: ${response.status} ${response.statusText}`,
297
+ `[Marvin SDK] Error response: ${response.status} ${response.statusText}`,
298
298
  errorText ? `Body: ${errorText}` : ""
299
299
  );
300
300
  }
@@ -304,7 +304,7 @@ var init_HttpClient = __esm({
304
304
  const delay = this.calculateRetryDelay(retryAttempt);
305
305
  if (this.debug) {
306
306
  this.logger.warn(
307
- `[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
307
+ `[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
308
308
  );
309
309
  }
310
310
  await this.sleep(delay);
@@ -343,7 +343,7 @@ var init_HttpClient = __esm({
343
343
  const data = await response.json();
344
344
  if (this.debug) {
345
345
  const sanitized = this.sanitizeForLogging(data);
346
- this.logger.log("[Marvin] Response:", JSON.stringify(sanitized, null, 2));
346
+ this.logger.log("[Marvin SDK] Response:", JSON.stringify(sanitized, null, 2));
347
347
  }
348
348
  return data;
349
349
  } catch (error) {
@@ -357,7 +357,7 @@ var init_HttpClient = __esm({
357
357
  const delay = this.calculateRetryDelay(retryAttempt);
358
358
  if (this.debug) {
359
359
  this.logger.warn(
360
- `[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
360
+ `[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
361
361
  );
362
362
  }
363
363
  await this.sleep(delay);
@@ -7,7 +7,7 @@ import {
7
7
  __export,
8
8
  init_core,
9
9
  init_errors
10
- } from "./chunk-WJC4X7TB.js";
10
+ } from "./chunk-SVH7AMMY.js";
11
11
 
12
12
  // src/client/config.ts
13
13
  var config_exports = {};
@@ -173,13 +173,22 @@ var init_entry = __esm({
173
173
  return this.raw.order;
174
174
  }
175
175
  get assets() {
176
- return this.raw.assets;
176
+ return (this.raw.assets ?? []).map(({ asset, role, position, metadataJson }) => ({
177
+ ...asset,
178
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
179
+ }));
177
180
  }
178
181
  get collections() {
179
- return this.raw.collections;
182
+ return (this.raw.collections ?? []).map(({ collection, role, position, metadataJson }) => ({
183
+ collection,
184
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
185
+ }));
180
186
  }
181
187
  get resources() {
182
- return this.raw.resources;
188
+ return (this.raw.resources ?? []).map(({ resource, role, position, metadataJson }) => ({
189
+ ...resource,
190
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
191
+ }));
183
192
  }
184
193
  field(key) {
185
194
  return this.raw.data[key];
@@ -225,8 +234,33 @@ var init_collection = __esm({
225
234
  get entryCount() {
226
235
  return this.data.entryCount;
227
236
  }
237
+ /**
238
+ * Entries with junction context for this collection surfaced directly.
239
+ * - role, position, junctionMetadata: from this collection's junction record
240
+ * - collections: slugs of other collections the entry belongs to
241
+ */
228
242
  get entries() {
229
- return this.data.entries;
243
+ return this.data.entries.map((entry) => {
244
+ const { collections, ...rest } = entry;
245
+ const junction = collections.find((ec) => ec.collection.slug === this.data.slug);
246
+ const entryMetadata = {
247
+ role: junction?.role ?? null,
248
+ position: junction?.position ?? 0,
249
+ metadataJson: junction?.metadataJson ?? null
250
+ };
251
+ const collection = {
252
+ slug: this.data.slug,
253
+ name: this.data.name,
254
+ description: this.data.description,
255
+ metadataJson: this.data.metadataJson,
256
+ entryMetadata
257
+ };
258
+ return {
259
+ ...rest,
260
+ collection,
261
+ collectionSlugs: collections.map((ec) => ec.collection.slug)
262
+ };
263
+ });
230
264
  }
231
265
  toJSON() {
232
266
  return this.data;
@@ -277,6 +311,16 @@ var init_resource = __esm({
277
311
  });
278
312
 
279
313
  // src/entries/entries.ts
314
+ function toListEntry(raw) {
315
+ const { collections, ...rest } = raw;
316
+ return {
317
+ ...rest,
318
+ collections: (collections ?? []).map(({ collection, role, position, metadataJson }) => ({
319
+ collection,
320
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
321
+ }))
322
+ };
323
+ }
280
324
  var EntriesModule;
281
325
  var init_entries = __esm({
282
326
  "src/entries/entries.ts"() {
@@ -302,7 +346,7 @@ var init_entries = __esm({
302
346
  });
303
347
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
304
348
  const response = await this.http.fetch(endpoint);
305
- return response.data || [];
349
+ return (response.data || []).map(toListEntry);
306
350
  }
307
351
  /**
308
352
  * Get a single entry by slug
@@ -365,8 +409,8 @@ var init_collections = __esm({
365
409
  return response.data || [];
366
410
  }
367
411
  /**
368
- * Get a single collection by slug
369
- * Returns null if collection is not found (404)
412
+ * Get a single collection by slug.
413
+ * Returns an empty array if the collection is not found (404).
370
414
  */
371
415
  async get(slug) {
372
416
  try {
@@ -375,32 +419,34 @@ var init_collections = __esm({
375
419
  return new Collection(data);
376
420
  } catch (error) {
377
421
  if (error instanceof MarvinNotFoundError) {
378
- return null;
422
+ return [];
379
423
  }
380
424
  throw error;
381
425
  }
382
426
  }
383
427
  /**
384
- * Get entries in a collection
385
- * Returns empty array if collection is not found
428
+ * Get entries in a collection with junction context surfaced directly.
429
+ * Each entry has role/position/junctionMetadata from this collection's junction,
430
+ * and collections reduced to slugs of other memberships.
431
+ * Returns empty array if collection is not found.
386
432
  */
387
433
  async entries(slug) {
388
434
  const collection = await this.get(slug);
389
- if (!collection) {
390
- return [];
435
+ if (Array.isArray(collection)) {
436
+ return collection;
391
437
  }
392
438
  return collection.entries;
393
439
  }
394
440
  /**
395
- * Try multiple collection slugs in fallback order
396
- * Returns the first collection that exists and has entries
441
+ * Try multiple collection slugs in fallback order.
442
+ * Returns entries from the first collection that exists and has entries.
397
443
  */
398
444
  async fallback(slugs, options = {}) {
399
445
  const { requireEntries = true } = options;
400
446
  for (const slug of slugs) {
401
447
  try {
402
448
  const collection = await this.get(slug);
403
- if (!collection) {
449
+ if (Array.isArray(collection)) {
404
450
  continue;
405
451
  }
406
452
  const entries = collection.entries;
@@ -530,7 +576,8 @@ var init_renderers = __esm({
530
576
  workspaceSlug;
531
577
  async list() {
532
578
  const endpoint = `/api/publish/${this.workspaceSlug}/entry-types`;
533
- return this.http.fetch(endpoint);
579
+ const all = await this.http.fetch(endpoint);
580
+ return all.filter((et) => et.isRendered);
534
581
  }
535
582
  };
536
583
  }
@@ -797,7 +844,7 @@ var init_marvin = __esm({
797
844
  */
798
845
  async getCollection(slug) {
799
846
  const collection = await this.workspace.collections.get(slug);
800
- if (!collection) {
847
+ if (Array.isArray(collection)) {
801
848
  return null;
802
849
  }
803
850
  return collection.toJSON();
@@ -250,10 +250,6 @@ interface components {
250
250
  role?: string | null;
251
251
  /** Position */
252
252
  position?: number | null;
253
- /** Caption */
254
- caption?: string | null;
255
- /** Focal Point */
256
- focal_point?: string | null;
257
253
  /** Metadata */
258
254
  metadata?: {
259
255
  [key: string]: unknown;
@@ -306,8 +302,8 @@ interface components {
306
302
  publicUrl?: string | null;
307
303
  /** Description */
308
304
  description?: string | null;
309
- /** Metadata */
310
- metadata_?: {
305
+ /** Metadatajson */
306
+ metadataJson?: {
311
307
  [key: string]: unknown;
312
308
  } | null;
313
309
  /**
@@ -411,6 +407,20 @@ interface components {
411
407
  /** Isuptodate */
412
408
  isUpToDate: boolean;
413
409
  };
410
+ /** CollectionAttachment */
411
+ CollectionAttachment: {
412
+ /**
413
+ * Collection Id
414
+ * Format: uuid4
415
+ */
416
+ collection_id: string;
417
+ /** Role */
418
+ role?: string | null;
419
+ /** Metadata */
420
+ metadata?: {
421
+ [key: string]: unknown;
422
+ } | null;
423
+ };
414
424
  /**
415
425
  * CollectionCreate
416
426
  * @description Schema for creating a new collection.
@@ -744,10 +754,6 @@ interface components {
744
754
  * @default 0
745
755
  */
746
756
  position: number;
747
- /** Focalpoint */
748
- focalPoint?: string | null;
749
- /** Caption */
750
- caption?: string | null;
751
757
  /** Placementmetadata */
752
758
  placementMetadata?: {
753
759
  [key: string]: unknown;
@@ -794,8 +800,8 @@ interface components {
794
800
  publicUrl?: string | null;
795
801
  /** Description */
796
802
  description?: string | null;
797
- /** Metadata */
798
- metadata_?: {
803
+ /** Metadatajson */
804
+ metadataJson?: {
799
805
  [key: string]: unknown;
800
806
  } | null;
801
807
  /**
@@ -804,6 +810,36 @@ interface components {
804
810
  */
805
811
  uploadedBy: string;
806
812
  };
813
+ /**
814
+ * EntryCollectionRead
815
+ * @description Collection summary with entry-specific placement details.
816
+ */
817
+ EntryCollectionRead: {
818
+ /**
819
+ * Id
820
+ * Format: uuid4
821
+ */
822
+ id: string;
823
+ /** Name */
824
+ name: string;
825
+ /** Slug */
826
+ slug: string;
827
+ /** Icon */
828
+ icon?: string | null;
829
+ /** Color */
830
+ color?: string | null;
831
+ /** Role */
832
+ role?: string | null;
833
+ /** Placementmetadata */
834
+ placementMetadata?: {
835
+ [key: string]: unknown;
836
+ } | null;
837
+ /**
838
+ * Sortorder
839
+ * @default 0
840
+ */
841
+ sortOrder: number;
842
+ };
807
843
  /**
808
844
  * EntryCreate
809
845
  * @description Schema for creating an entry.
@@ -852,6 +888,8 @@ interface components {
852
888
  } | null;
853
889
  /** Collectionids */
854
890
  collectionIds?: string[] | null;
891
+ /** Collectionattachments */
892
+ collectionAttachments?: components["schemas"]["CollectionAttachment"][] | null;
855
893
  /** Assetids */
856
894
  assetIds?: string[] | null;
857
895
  /** Resourceids */
@@ -947,7 +985,7 @@ interface components {
947
985
  * Collections
948
986
  * @default []
949
987
  */
950
- collections: string[];
988
+ collections: components["schemas"]["EntryCollectionRead"][];
951
989
  /** Order */
952
990
  order?: number | null;
953
991
  };
@@ -958,10 +996,6 @@ interface components {
958
996
  EntryResourceRead: {
959
997
  /** Role */
960
998
  role?: string | null;
961
- /** Quantity */
962
- quantity?: string | null;
963
- /** Unit */
964
- unit?: string | null;
965
999
  /**
966
1000
  * Position
967
1001
  * @default 0
@@ -1225,6 +1259,8 @@ interface components {
1225
1259
  } | null;
1226
1260
  /** Collection Ids */
1227
1261
  collection_ids?: string[] | null;
1262
+ /** Collection Attachments */
1263
+ collection_attachments?: components["schemas"]["CollectionAttachment"][] | null;
1228
1264
  /** Asset Ids */
1229
1265
  asset_ids?: string[] | null;
1230
1266
  /** Resource Ids */
@@ -2226,6 +2262,8 @@ interface components {
2226
2262
  slug: string;
2227
2263
  /** Name */
2228
2264
  name: string;
2265
+ /** Description */
2266
+ description?: string | null;
2229
2267
  /** Metadatajson */
2230
2268
  metadataJson?: {
2231
2269
  [key: string]: unknown;
@@ -2263,16 +2301,30 @@ interface components {
2263
2301
  * @default 0
2264
2302
  */
2265
2303
  position: number;
2266
- /** Focalpoint */
2267
- focalPoint?: string | null;
2268
- /** Caption */
2269
- caption?: string | null;
2270
2304
  /** Metadatajson */
2271
2305
  metadataJson?: {
2272
2306
  [key: string]: unknown;
2273
2307
  } | null;
2274
2308
  asset: components["schemas"]["PublishedAssetRead"];
2275
2309
  };
2310
+ /**
2311
+ * PublishedEntryCollection
2312
+ * @description A collection as used by a specific entry — relationship context + collection data.
2313
+ */
2314
+ PublishedEntryCollection: {
2315
+ /** Role */
2316
+ role?: string | null;
2317
+ /**
2318
+ * Position
2319
+ * @default 0
2320
+ */
2321
+ position: number;
2322
+ /** Metadatajson */
2323
+ metadataJson?: {
2324
+ [key: string]: unknown;
2325
+ } | null;
2326
+ collection: components["schemas"]["PublishedCollectionSummary"];
2327
+ };
2276
2328
  /**
2277
2329
  * PublishedEntryListItem
2278
2330
  * @description Minimal entry schema for list responses.
@@ -2298,7 +2350,7 @@ interface components {
2298
2350
  * Collections
2299
2351
  * @default []
2300
2352
  */
2301
- collections: string[];
2353
+ collections: components["schemas"]["PublishedEntryCollection"][];
2302
2354
  /**
2303
2355
  * Assetslugs
2304
2356
  * @default []
@@ -2351,7 +2403,7 @@ interface components {
2351
2403
  * Collections
2352
2404
  * @default []
2353
2405
  */
2354
- collections: components["schemas"]["PublishedCollectionSummary"][];
2406
+ collections: components["schemas"]["PublishedEntryCollection"][];
2355
2407
  /**
2356
2408
  * Resources
2357
2409
  * @default []
@@ -2372,10 +2424,6 @@ interface components {
2372
2424
  PublishedEntryResource: {
2373
2425
  /** Role */
2374
2426
  role?: string | null;
2375
- /** Quantity */
2376
- quantity?: string | null;
2377
- /** Unit */
2378
- unit?: string | null;
2379
2427
  /**
2380
2428
  * Position
2381
2429
  * @default 0
@@ -2533,10 +2581,6 @@ interface components {
2533
2581
  resource_id: string;
2534
2582
  /** Role */
2535
2583
  role?: string | null;
2536
- /** Quantity */
2537
- quantity?: string | null;
2538
- /** Unit */
2539
- unit?: string | null;
2540
2584
  /** Position */
2541
2585
  position?: number | null;
2542
2586
  /** Metadata */
@@ -2588,8 +2632,8 @@ interface components {
2588
2632
  url?: string | null;
2589
2633
  /** Externalid */
2590
2634
  externalId?: string | null;
2591
- /** Metadata */
2592
- metadata?: {
2635
+ /** Metadatajson */
2636
+ metadataJson?: {
2593
2637
  [key: string]: unknown;
2594
2638
  } | null;
2595
2639
  /**
@@ -2889,6 +2933,18 @@ interface components {
2889
2933
  */
2890
2934
  unlocked: number;
2891
2935
  };
2936
+ /**
2937
+ * UpdateEntryCollectionRequest
2938
+ * @description Schema for updating junction fields on an entry-collection relationship.
2939
+ */
2940
+ UpdateEntryCollectionRequest: {
2941
+ /** Role */
2942
+ role?: string | null;
2943
+ /** Metadatajson */
2944
+ metadataJson?: {
2945
+ [key: string]: unknown;
2946
+ } | null;
2947
+ };
2892
2948
  /**
2893
2949
  * UserCreate
2894
2950
  * @description Schema for creating a new user.
@@ -3445,15 +3501,74 @@ type MarvinEntryListItem = components['schemas']['PublishedEntryListItem'];
3445
3501
  type PublishedEntryType = components['schemas']['PublishedEntryTypeRead'];
3446
3502
  type MarvinCollection = components['schemas']['PublishedCollectionRead'];
3447
3503
  type PublishedCollectionSummary = components['schemas']['PublishedCollectionSummary'];
3504
+ type PublishedEntryCollection = components['schemas']['PublishedEntryCollection'];
3448
3505
  type MarvinAsset = components['schemas']['PublishedAssetRead'];
3449
3506
  type PublishedAssetRead = components['schemas']['PublishedAssetRead'];
3450
3507
  type PublishedEntryAsset = components['schemas']['PublishedEntryAsset'];
3451
3508
  type MarvinResource = components['schemas']['PublishedResourceSummary'];
3509
+ type PublishedResourceSummary = components['schemas']['PublishedResourceSummary'];
3452
3510
  type PublishedEntryResource = components['schemas']['PublishedEntryResource'];
3453
3511
  type AssetAttachment = components['schemas']['AssetAttachment'];
3512
+ type CollectionAttachment = components['schemas']['CollectionAttachment'];
3454
3513
  type ResourceAttachment = components['schemas']['ResourceAttachment'];
3455
- type EntryResourceRead = components['schemas']['EntryResourceRead'];
3514
+ type EntryCollectionRead = components['schemas']['EntryCollectionRead'];
3456
3515
  type MarvinEntryType = components['schemas']['EntryTypeRead'];
3516
+ /** Entry-specific relationship data within a collection */
3517
+ interface CollectionEntryMetadata {
3518
+ role: string | null;
3519
+ position: number;
3520
+ metadataJson: Record<string, unknown> | null;
3521
+ }
3522
+ /** The collection context when an entry is fetched through a specific collection */
3523
+ interface CollectionContext {
3524
+ slug: string;
3525
+ name: string;
3526
+ description?: string | null;
3527
+ metadataJson?: Record<string, unknown> | null;
3528
+ /** This entry's relationship to the collection (role, position, junction metadata) */
3529
+ entryMetadata: CollectionEntryMetadata;
3530
+ }
3531
+ /**
3532
+ * An entry as returned when fetched through a specific collection.
3533
+ * - `collection`: the collection you queried through, with its junction context
3534
+ * - `collectionSlugs`: slugs of other collections this entry also belongs to
3535
+ */
3536
+ interface CollectionEntry extends Omit<MarvinEntryListItem, 'collections'> {
3537
+ collection: CollectionContext;
3538
+ /** All collection slugs this entry belongs to, including the one queried through */
3539
+ collectionSlugs: string[];
3540
+ }
3541
+ /**
3542
+ * A collection membership as it appears on an entry.
3543
+ * - `collection`: the collection's own fields (slug, name, description, metadataJson, sortOrder)
3544
+ * - `entryMetadata`: the entry's relationship to this collection (role, position, metadataJson)
3545
+ */
3546
+ interface EntryCollectionContext {
3547
+ collection: PublishedCollectionSummary;
3548
+ entryMetadata: CollectionEntryMetadata;
3549
+ }
3550
+ /**
3551
+ * An entry as returned from the general entries list.
3552
+ * Same as MarvinEntryListItem but with collections transformed to EntryCollectionContext[]
3553
+ * so the entryMetadata naming convention is consistent across all entry contexts.
3554
+ */
3555
+ interface ListEntry extends Omit<MarvinEntryListItem, 'collections'> {
3556
+ collections: EntryCollectionContext[];
3557
+ }
3558
+ /**
3559
+ * An asset as it appears on an entry — includes the asset's own fields
3560
+ * plus `entryMetadata` for the entry's relationship to this asset.
3561
+ */
3562
+ interface EntryAsset extends PublishedAssetRead {
3563
+ entryMetadata: CollectionEntryMetadata;
3564
+ }
3565
+ /**
3566
+ * A resource as it appears on an entry — includes the resource's own fields
3567
+ * plus `entryMetadata` for the entry's relationship to this resource.
3568
+ */
3569
+ interface EntryResource extends PublishedResourceSummary {
3570
+ entryMetadata: CollectionEntryMetadata;
3571
+ }
3457
3572
  interface AssetUploadRequest {
3458
3573
  slug: string;
3459
3574
  name: string;
@@ -3496,4 +3611,4 @@ interface AuthToken {
3496
3611
  tokenType: string;
3497
3612
  }
3498
3613
 
3499
- export type { AuthToken as A, EntryResourceRead as E, GetAssetsOptions as G, MarvinAsset as M, PublishedAssetRead as P, ResourceAttachment as R, SiteConfiguration as S, WorkspaceInfo as W, GetEntriesOptions as a, GetResourcesOptions as b, MarvinCollection as c, MarvinEntry as d, MarvinEntryListItem as e, MarvinEntryType as f, MarvinPublishResponse as g, MarvinResource as h, MarvinSite as i, PublishedCollectionSummary as j, PublishedEntryAsset as k, PublishedEntryResource as l, PublishedEntryType as m, components as n, AssetAttachment as o, AssetUploadRequest as p, MarvinClientConfig as q };
3614
+ export type { AuthToken as A, CollectionContext as C, EntryAsset as E, GetAssetsOptions as G, ListEntry as L, MarvinAsset as M, PublishedAssetRead as P, ResourceAttachment as R, SiteConfiguration as S, WorkspaceInfo as W, CollectionEntry as a, CollectionEntryMetadata as b, EntryCollectionContext as c, EntryResource as d, GetEntriesOptions as e, GetResourcesOptions as f, MarvinCollection as g, MarvinEntry as h, MarvinEntryListItem as i, MarvinEntryType as j, MarvinPublishResponse as k, MarvinResource as l, MarvinSite as m, PublishedCollectionSummary as n, PublishedEntryAsset as o, PublishedEntryResource as p, PublishedEntryType as q, components as r, AssetAttachment as s, AssetUploadRequest as t, CollectionAttachment as u, EntryCollectionRead as v, MarvinClientConfig as w, PublishedEntryCollection as x, PublishedResourceSummary as y };