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

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/publish.cjs CHANGED
@@ -410,7 +410,7 @@ var HttpClient = class {
410
410
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
411
411
  const startTime = Date.now();
412
412
  if (this.debug) {
413
- this.logger.log(`[Marvin] ${method} ${url}`);
413
+ this.logger.log(`[Marvin SDK] ${method} ${url}`);
414
414
  }
415
415
  try {
416
416
  const response = await fetch(url, {
@@ -424,7 +424,7 @@ var HttpClient = class {
424
424
  const duration = Date.now() - startTime;
425
425
  if (this.debug) {
426
426
  this.logger.log(
427
- `[Marvin] ${response.status} ${response.statusText} (${duration}ms)`
427
+ `[Marvin SDK] ${response.status} ${response.statusText} (${duration}ms)`
428
428
  );
429
429
  }
430
430
  if (response.status === 401 && this.auth.handleUnauthorized) {
@@ -434,7 +434,7 @@ var HttpClient = class {
434
434
  const errorText = await response.text().catch(() => "");
435
435
  if (this.debug) {
436
436
  this.logger.error(
437
- `[Marvin] Error response: ${response.status} ${response.statusText}`,
437
+ `[Marvin SDK] Error response: ${response.status} ${response.statusText}`,
438
438
  errorText ? `Body: ${errorText}` : ""
439
439
  );
440
440
  }
@@ -444,7 +444,7 @@ var HttpClient = class {
444
444
  const delay = this.calculateRetryDelay(retryAttempt);
445
445
  if (this.debug) {
446
446
  this.logger.warn(
447
- `[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
447
+ `[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
448
448
  );
449
449
  }
450
450
  await this.sleep(delay);
@@ -483,7 +483,7 @@ var HttpClient = class {
483
483
  const data = await response.json();
484
484
  if (this.debug) {
485
485
  const sanitized = this.sanitizeForLogging(data);
486
- this.logger.log("[Marvin] Response:", JSON.stringify(sanitized, null, 2));
486
+ this.logger.log("[Marvin SDK] Response:", JSON.stringify(sanitized, null, 2));
487
487
  }
488
488
  return data;
489
489
  } catch (error) {
@@ -497,7 +497,7 @@ var HttpClient = class {
497
497
  const delay = this.calculateRetryDelay(retryAttempt);
498
498
  if (this.debug) {
499
499
  this.logger.warn(
500
- `[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
500
+ `[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
501
501
  );
502
502
  }
503
503
  await this.sleep(delay);
@@ -756,13 +756,22 @@ var Entry = class {
756
756
  return this.raw.order;
757
757
  }
758
758
  get assets() {
759
- return this.raw.assets;
759
+ return (this.raw.assets ?? []).map(({ asset, role, position, metadataJson }) => ({
760
+ ...asset,
761
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
762
+ }));
760
763
  }
761
764
  get collections() {
762
- return this.raw.collections;
765
+ return (this.raw.collections ?? []).map(({ collection, role, position, metadataJson }) => ({
766
+ collection,
767
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
768
+ }));
763
769
  }
764
770
  get resources() {
765
- return this.raw.resources;
771
+ return (this.raw.resources ?? []).map(({ resource, role, position, metadataJson }) => ({
772
+ ...resource,
773
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
774
+ }));
766
775
  }
767
776
  field(key) {
768
777
  return this.raw.data[key];
@@ -776,6 +785,16 @@ var Entry = class {
776
785
  };
777
786
 
778
787
  // src/entries/entries.ts
788
+ function toListEntry(raw) {
789
+ const { collections, ...rest } = raw;
790
+ return {
791
+ ...rest,
792
+ collections: (collections ?? []).map(({ collection, role, position, metadataJson }) => ({
793
+ collection,
794
+ entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
795
+ }))
796
+ };
797
+ }
779
798
  var EntriesModule = class {
780
799
  constructor(http, workspaceSlug) {
781
800
  this.http = http;
@@ -795,7 +814,7 @@ var EntriesModule = class {
795
814
  });
796
815
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
797
816
  const response = await this.http.fetch(endpoint);
798
- return response.data || [];
817
+ return (response.data || []).map(toListEntry);
799
818
  }
800
819
  /**
801
820
  * Get a single entry by slug
@@ -860,8 +879,33 @@ var Collection = class {
860
879
  get entryCount() {
861
880
  return this.data.entryCount;
862
881
  }
882
+ /**
883
+ * Entries with junction context for this collection surfaced directly.
884
+ * - role, position, junctionMetadata: from this collection's junction record
885
+ * - collections: slugs of other collections the entry belongs to
886
+ */
863
887
  get entries() {
864
- return this.data.entries;
888
+ return this.data.entries.map((entry) => {
889
+ const { collections, ...rest } = entry;
890
+ const junction = collections.find((ec) => ec.collection.slug === this.data.slug);
891
+ const entryMetadata = {
892
+ role: junction?.role ?? null,
893
+ position: junction?.position ?? 0,
894
+ metadataJson: junction?.metadataJson ?? null
895
+ };
896
+ const collection = {
897
+ slug: this.data.slug,
898
+ name: this.data.name,
899
+ description: this.data.description,
900
+ metadataJson: this.data.metadataJson,
901
+ entryMetadata
902
+ };
903
+ return {
904
+ ...rest,
905
+ collection,
906
+ collectionSlugs: collections.map((ec) => ec.collection.slug)
907
+ };
908
+ });
865
909
  }
866
910
  toJSON() {
867
911
  return this.data;
@@ -885,8 +929,8 @@ var CollectionsModule = class {
885
929
  return response.data || [];
886
930
  }
887
931
  /**
888
- * Get a single collection by slug
889
- * Returns null if collection is not found (404)
932
+ * Get a single collection by slug.
933
+ * Returns an empty array if the collection is not found (404).
890
934
  */
891
935
  async get(slug) {
892
936
  try {
@@ -895,32 +939,34 @@ var CollectionsModule = class {
895
939
  return new Collection(data);
896
940
  } catch (error) {
897
941
  if (error instanceof MarvinNotFoundError) {
898
- return null;
942
+ return [];
899
943
  }
900
944
  throw error;
901
945
  }
902
946
  }
903
947
  /**
904
- * Get entries in a collection
905
- * Returns empty array if collection is not found
948
+ * Get entries in a collection with junction context surfaced directly.
949
+ * Each entry has role/position/junctionMetadata from this collection's junction,
950
+ * and collections reduced to slugs of other memberships.
951
+ * Returns empty array if collection is not found.
906
952
  */
907
953
  async entries(slug) {
908
954
  const collection = await this.get(slug);
909
- if (!collection) {
910
- return [];
955
+ if (Array.isArray(collection)) {
956
+ return collection;
911
957
  }
912
958
  return collection.entries;
913
959
  }
914
960
  /**
915
- * Try multiple collection slugs in fallback order
916
- * Returns the first collection that exists and has entries
961
+ * Try multiple collection slugs in fallback order.
962
+ * Returns entries from the first collection that exists and has entries.
917
963
  */
918
964
  async fallback(slugs, options = {}) {
919
965
  const { requireEntries = true } = options;
920
966
  for (const slug of slugs) {
921
967
  try {
922
968
  const collection = await this.get(slug);
923
- if (!collection) {
969
+ if (Array.isArray(collection)) {
924
970
  continue;
925
971
  }
926
972
  const entries = collection.entries;
@@ -1066,7 +1112,8 @@ var RenderersModule = class {
1066
1112
  workspaceSlug;
1067
1113
  async list() {
1068
1114
  const endpoint = `/api/publish/${this.workspaceSlug}/entry-types`;
1069
- return this.http.fetch(endpoint);
1115
+ const all = await this.http.fetch(endpoint);
1116
+ return all.filter((et) => et.isRendered);
1070
1117
  }
1071
1118
  };
1072
1119
 
@@ -1282,7 +1329,7 @@ var MarvinClient = class {
1282
1329
  */
1283
1330
  async getCollection(slug) {
1284
1331
  const collection = await this.workspace.collections.get(slug);
1285
- if (!collection) {
1332
+ if (Array.isArray(collection)) {
1286
1333
  return null;
1287
1334
  }
1288
1335
  return collection.toJSON();
@@ -1,6 +1,6 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-BLhk8ZKO.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-BLhk8ZKO.cjs';
3
- export { G as GetAssetsOptions, a as GetEntriesOptions, b as GetResourcesOptions, M as MarvinAsset, c as MarvinCollection, d as MarvinEntry, e as MarvinEntryListItem, f as MarvinEntryType, g as MarvinPublishResponse, h as MarvinResource, i as MarvinSite, P as PublishedAssetRead, j as PublishedCollectionSummary, k as PublishedEntryAsset, l as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-D4PQGrOK.cjs';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-RZZj02LS.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-RZZj02LS.cjs';
3
+ export { G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, 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, S as SiteConfiguration, W as WorkspaceInfo } from './index-BVm5dIcw.cjs';
4
4
  export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-CdF3IHM1.cjs';
5
5
 
6
6
  /**
package/dist/publish.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-DWlYHd6f.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-DWlYHd6f.js';
3
- export { G as GetAssetsOptions, a as GetEntriesOptions, b as GetResourcesOptions, M as MarvinAsset, c as MarvinCollection, d as MarvinEntry, e as MarvinEntryListItem, f as MarvinEntryType, g as MarvinPublishResponse, h as MarvinResource, i as MarvinSite, P as PublishedAssetRead, j as PublishedCollectionSummary, k as PublishedEntryAsset, l as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-D4PQGrOK.js';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-BZ4meaB-.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-BZ4meaB-.js';
3
+ export { G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, 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, S as SiteConfiguration, W as WorkspaceInfo } from './index-BVm5dIcw.js';
4
4
  export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-CdF3IHM1.js';
5
5
 
6
6
  /**
package/dist/publish.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  init_marvin,
13
13
  init_resource,
14
14
  init_workspace
15
- } from "./chunk-R3EZI43S.js";
15
+ } from "./chunk-YHBF2SB3.js";
16
16
  import {
17
17
  BearerTokenAuth,
18
18
  HttpClient,
@@ -32,7 +32,7 @@ import {
32
32
  isPaginatedResponse,
33
33
  offsetToPage,
34
34
  pageToOffset
35
- } from "./chunk-WJC4X7TB.js";
35
+ } from "./chunk-SVH7AMMY.js";
36
36
 
37
37
  // src/publish.ts
38
38
  init_marvin();
@@ -1 +1 @@
1
- export { o as AssetAttachment, p as AssetUploadRequest, A as AuthToken, E as EntryResourceRead, G as GetAssetsOptions, a as GetEntriesOptions, b as GetResourcesOptions, M as MarvinAsset, q as MarvinClientConfig, c as MarvinCollection, d as MarvinEntry, e as MarvinEntryListItem, f as MarvinEntryType, g as MarvinPublishResponse, h as MarvinResource, i as MarvinSite, P as PublishedAssetRead, j as PublishedCollectionSummary, k as PublishedEntryAsset, l as PublishedEntryResource, m as PublishedEntryType, R as ResourceAttachment, S as SiteConfiguration, W as WorkspaceInfo } from '../index-D4PQGrOK.cjs';
1
+ export { s as AssetAttachment, t as AssetUploadRequest, A as AuthToken, u as CollectionAttachment, C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, v as EntryCollectionRead, d as EntryResource, G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, L as ListEntry, M as MarvinAsset, w as MarvinClientConfig, 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, x as PublishedEntryCollection, p as PublishedEntryResource, q as PublishedEntryType, y as PublishedResourceSummary, R as ResourceAttachment, S as SiteConfiguration, W as WorkspaceInfo } from '../index-BVm5dIcw.cjs';
@@ -1 +1 @@
1
- export { o as AssetAttachment, p as AssetUploadRequest, A as AuthToken, E as EntryResourceRead, G as GetAssetsOptions, a as GetEntriesOptions, b as GetResourcesOptions, M as MarvinAsset, q as MarvinClientConfig, c as MarvinCollection, d as MarvinEntry, e as MarvinEntryListItem, f as MarvinEntryType, g as MarvinPublishResponse, h as MarvinResource, i as MarvinSite, P as PublishedAssetRead, j as PublishedCollectionSummary, k as PublishedEntryAsset, l as PublishedEntryResource, m as PublishedEntryType, R as ResourceAttachment, S as SiteConfiguration, W as WorkspaceInfo } from '../index-D4PQGrOK.js';
1
+ export { s as AssetAttachment, t as AssetUploadRequest, A as AuthToken, u as CollectionAttachment, C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, v as EntryCollectionRead, d as EntryResource, G as GetAssetsOptions, e as GetEntriesOptions, f as GetResourcesOptions, L as ListEntry, M as MarvinAsset, w as MarvinClientConfig, 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, x as PublishedEntryCollection, p as PublishedEntryResource, q as PublishedEntryType, y as PublishedResourceSummary, R as ResourceAttachment, S as SiteConfiguration, W as WorkspaceInfo } from '../index-BVm5dIcw.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneropen/marvin-sdk",
3
- "version": "3.2.0-next.1",
3
+ "version": "3.2.0-next.10",
4
4
  "description": "Official TypeScript SDK for Marvin CMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",