@inneropen/marvin-sdk 3.0.0 → 3.1.0-next.1

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
@@ -869,113 +869,66 @@ var init_entry = __esm({
869
869
  "src/entries/entry.ts"() {
870
870
  "use strict";
871
871
  Entry = class {
872
- constructor(data, http, workspaceSlug) {
873
- this.data = data;
874
- this.http = http;
875
- this.workspaceSlug = workspaceSlug;
876
- }
877
- data;
878
- http;
879
- workspaceSlug;
880
- // Expose all entry data as properties
881
- get id() {
882
- return this.data.id;
872
+ constructor(raw) {
873
+ this.raw = raw;
883
874
  }
875
+ raw;
884
876
  get title() {
885
- return this.data.title;
877
+ return this.raw.title;
886
878
  }
887
879
  get slug() {
888
- return this.data.slug;
880
+ return this.raw.slug;
889
881
  }
890
882
  get summary() {
891
- return this.data.summary;
892
- }
893
- get description() {
894
- return this.data.description;
883
+ return this.raw.summary;
895
884
  }
896
- /**
897
- * @deprecated Use field('body') or dataJson instead. Will be removed in v3.0.0
898
- */
899
- get contentMarkdown() {
900
- return this.data.contentMarkdown;
885
+ get entryType() {
886
+ return this.raw.entryType;
901
887
  }
902
- /**
903
- * Schema-driven content data (replaces contentMarkdown in v2.0.0).
904
- * Access specific fields using the field() helper method.
905
- * @since 2.0.0
906
- */
907
- get dataJson() {
908
- return this.data.dataJson;
888
+ get entryTypeInfo() {
889
+ return this.raw.entryTypeInfo;
909
890
  }
910
- get metadata() {
911
- return this.data.metadata;
891
+ get data() {
892
+ return this.raw.data;
912
893
  }
913
- get status() {
914
- return this.data.status;
894
+ get metadataJson() {
895
+ return this.raw.metadataJson;
915
896
  }
916
897
  get publishedAt() {
917
- return this.data.publishedAt;
898
+ return this.raw.publishedAt;
918
899
  }
919
- get createdAt() {
920
- return this.data.createdAt;
900
+ get order() {
901
+ return this.raw.order;
921
902
  }
922
- get updatedAt() {
923
- return this.data.updatedAt;
903
+ get assets() {
904
+ return this.raw.assets;
924
905
  }
925
- get entryTypeId() {
926
- return this.data.entryTypeId;
906
+ get collections() {
907
+ return this.raw.collections;
927
908
  }
928
- get entryType() {
929
- return this.data.entryType;
909
+ get resources() {
910
+ return this.raw.resources;
930
911
  }
931
- /**
932
- * Get entry assets
933
- */
934
- get assets() {
935
- return this.data.assets || [];
912
+ asset(role) {
913
+ return this.raw.assets.find((a) => a.role === role);
936
914
  }
937
- /**
938
- * Get entry collections
939
- */
940
- get collections() {
941
- return this.data.collections || [];
915
+ assetsByRole(role) {
916
+ return this.raw.assets.filter((a) => a.role === role);
917
+ }
918
+ resource(role) {
919
+ return this.raw.resources.find((r) => r.role === role);
920
+ }
921
+ resourcesByRole(role) {
922
+ return this.raw.resources.filter((r) => r.role === role);
942
923
  }
943
- /**
944
- * Get a specific field value from the entry's schema-driven content (dataJson).
945
- *
946
- * @param key - Field key as defined in the entry type's schema
947
- * @returns The field value, or undefined if not present
948
- * @since 2.0.0
949
- *
950
- * @example
951
- * ```typescript
952
- * const entry = await client.entries.get('my-entry');
953
- * const body = entry.field('body'); // Get markdown body
954
- * const difficulty = entry.field('difficulty'); // Get difficulty level
955
- * const heroImage = entry.field('heroImage'); // Get hero image UUID
956
- * ```
957
- */
958
924
  field(key) {
959
- return this.data.dataJson?.[key];
925
+ return this.raw.data[key];
960
926
  }
961
- /**
962
- * Get all fields from the entry's schema-driven content.
963
- * @since 2.0.0
964
- */
965
927
  get fields() {
966
- return this.data.dataJson || {};
967
- }
968
- /**
969
- * Get related entries (future)
970
- */
971
- async relatedEntries() {
972
- throw new Error("Related entries not yet implemented");
928
+ return this.raw.data;
973
929
  }
974
- /**
975
- * Get raw entry data
976
- */
977
930
  toJSON() {
978
- return this.data;
931
+ return this.raw;
979
932
  }
980
933
  };
981
934
  }
@@ -1004,7 +957,6 @@ var init_entries = __esm({
1004
957
  collection: options.collection,
1005
958
  limit: options.limit,
1006
959
  offset: options.offset
1007
- // Don't send status - backend always returns published
1008
960
  });
1009
961
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
1010
962
  const response = await this.http.fetch(endpoint);
@@ -1018,7 +970,7 @@ var init_entries = __esm({
1018
970
  try {
1019
971
  const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
1020
972
  const data = await this.http.fetch(endpoint);
1021
- return new Entry(data, this.http, this.workspaceSlug);
973
+ return new Entry(data);
1022
974
  } catch (error) {
1023
975
  if (error instanceof MarvinNotFoundError) {
1024
976
  return null;
@@ -1054,18 +1006,10 @@ var init_collection = __esm({
1054
1006
  "src/collections/collection.ts"() {
1055
1007
  "use strict";
1056
1008
  Collection = class {
1057
- constructor(data, http, workspaceSlug) {
1009
+ constructor(data) {
1058
1010
  this.data = data;
1059
- this.http = http;
1060
- this.workspaceSlug = workspaceSlug;
1061
1011
  }
1062
1012
  data;
1063
- http;
1064
- workspaceSlug;
1065
- // Expose all collection data as properties
1066
- get id() {
1067
- return this.data.id;
1068
- }
1069
1013
  get name() {
1070
1014
  return this.data.name;
1071
1015
  }
@@ -1075,48 +1019,21 @@ var init_collection = __esm({
1075
1019
  get description() {
1076
1020
  return this.data.description;
1077
1021
  }
1078
- get icon() {
1079
- return this.data.icon;
1080
- }
1081
- get color() {
1082
- return this.data.color;
1083
- }
1084
- get sortOrder() {
1085
- return this.data.sortOrder;
1086
- }
1087
1022
  get isSmart() {
1088
1023
  return this.data.isSmart;
1089
1024
  }
1090
1025
  get smartRules() {
1091
1026
  return this.data.smartRules;
1092
1027
  }
1093
- get createdAt() {
1094
- return this.data.createdAt;
1028
+ get metadataJson() {
1029
+ return this.data.metadataJson;
1095
1030
  }
1096
- get updatedAt() {
1097
- return this.data.updatedAt;
1031
+ get entryCount() {
1032
+ return this.data.entryCount;
1098
1033
  }
1099
- /**
1100
- * Get all entries in this collection
1101
- */
1102
- async entries() {
1103
- return this.data.entries || [];
1104
- }
1105
- /**
1106
- * Get assets in this collection (future)
1107
- */
1108
- async assets() {
1109
- throw new Error("Collection assets not yet implemented");
1110
- }
1111
- /**
1112
- * Get collection metadata (future)
1113
- */
1114
- async metadata() {
1115
- throw new Error("Collection metadata not yet implemented");
1034
+ get entries() {
1035
+ return this.data.entries;
1116
1036
  }
1117
- /**
1118
- * Get raw collection data
1119
- */
1120
1037
  toJSON() {
1121
1038
  return this.data;
1122
1039
  }
@@ -1154,7 +1071,7 @@ var init_collections = __esm({
1154
1071
  try {
1155
1072
  const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
1156
1073
  const data = await this.http.fetch(endpoint);
1157
- return new Collection(data, this.http, this.workspaceSlug);
1074
+ return new Collection(data);
1158
1075
  } catch (error) {
1159
1076
  if (error instanceof MarvinNotFoundError) {
1160
1077
  return null;
@@ -1171,21 +1088,11 @@ var init_collections = __esm({
1171
1088
  if (!collection) {
1172
1089
  return [];
1173
1090
  }
1174
- return collection.entries();
1091
+ return collection.entries;
1175
1092
  }
1176
1093
  /**
1177
1094
  * Try multiple collection slugs in fallback order
1178
1095
  * Returns the first collection that exists and has entries
1179
- *
1180
- * @param slugs - Collection slugs to try in order
1181
- * @param options - Options for fallback behavior
1182
- * @returns Entries from the first matching collection, or empty array
1183
- *
1184
- * @example
1185
- * ```ts
1186
- * // Try bench-notes, then journal, then blog
1187
- * const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
1188
- * ```
1189
1096
  */
1190
1097
  async fallback(slugs, options = {}) {
1191
1098
  const { requireEntries = true } = options;
@@ -1195,7 +1102,7 @@ var init_collections = __esm({
1195
1102
  if (!collection) {
1196
1103
  continue;
1197
1104
  }
1198
- const entries = await collection.entries();
1105
+ const entries = collection.entries;
1199
1106
  if (!requireEntries || entries.length > 0) {
1200
1107
  return entries;
1201
1108
  }
@@ -1269,18 +1176,10 @@ var init_resource = __esm({
1269
1176
  "src/resources/resource.ts"() {
1270
1177
  "use strict";
1271
1178
  Resource = class {
1272
- constructor(data, http, workspaceSlug) {
1179
+ constructor(data) {
1273
1180
  this.data = data;
1274
- this.http = http;
1275
- this.workspaceSlug = workspaceSlug;
1276
1181
  }
1277
1182
  data;
1278
- http;
1279
- workspaceSlug;
1280
- // Expose all resource data as properties
1281
- get id() {
1282
- return this.data.id;
1283
- }
1284
1183
  get name() {
1285
1184
  return this.data.name;
1286
1185
  }
@@ -1299,31 +1198,12 @@ var init_resource = __esm({
1299
1198
  get url() {
1300
1199
  return this.data.url;
1301
1200
  }
1302
- get metadata() {
1303
- return this.data.metadata;
1304
- }
1305
- get createdAt() {
1306
- return this.data.createdAt;
1201
+ get metadataJson() {
1202
+ return this.data.metadataJson;
1307
1203
  }
1308
- get updatedAt() {
1309
- return this.data.updatedAt;
1310
- }
1311
- /**
1312
- * Get all entries that reference this resource
1313
- */
1314
- async entries() {
1315
- const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
1316
- return this.http.fetch(endpoint);
1317
- }
1318
- /**
1319
- * Get assets related to this resource (future)
1320
- */
1321
- async assets() {
1322
- throw new Error("Resource assets not yet implemented");
1204
+ get entries() {
1205
+ return this.data.entries;
1323
1206
  }
1324
- /**
1325
- * Get raw resource data
1326
- */
1327
1207
  toJSON() {
1328
1208
  return this.data;
1329
1209
  }
@@ -1363,14 +1243,14 @@ var init_resources = __esm({
1363
1243
  async get(slug) {
1364
1244
  const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
1365
1245
  const data = await this.http.fetch(endpoint);
1366
- return new Resource(data, this.http, this.workspaceSlug);
1246
+ return new Resource(data);
1367
1247
  }
1368
1248
  /**
1369
- * Get entries that reference this resource
1249
+ * Get entry slugs that reference this resource
1370
1250
  */
1371
1251
  async entries(slug) {
1372
1252
  const resource = await this.get(slug);
1373
- return resource.entries();
1253
+ return resource.entries;
1374
1254
  }
1375
1255
  };
1376
1256
  }
@@ -1451,12 +1331,6 @@ var init_workspace = __esm({
1451
1331
  const endpoint = `/api/publish/${this._slug}`;
1452
1332
  return this.http.fetch(endpoint);
1453
1333
  }
1454
- /**
1455
- * Get workspace settings (future)
1456
- */
1457
- async settings() {
1458
- throw new Error("Workspace settings not yet implemented");
1459
- }
1460
1334
  };
1461
1335
  }
1462
1336
  });
@@ -1475,8 +1349,11 @@ var init_marvin = __esm({
1475
1349
  init_core();
1476
1350
  init_workspace();
1477
1351
  MarvinClient = class {
1352
+ http;
1353
+ cache;
1354
+ workspace;
1355
+ initialized = false;
1478
1356
  constructor(config) {
1479
- this.config = config;
1480
1357
  validateConfig(config);
1481
1358
  this.http = new MarvinHttpClient(config);
1482
1359
  this.cache = new MarvinCache(config.cacheDuration);
@@ -1485,11 +1362,6 @@ var init_marvin = __esm({
1485
1362
  this.initialize();
1486
1363
  }
1487
1364
  }
1488
- config;
1489
- http;
1490
- cache;
1491
- workspace;
1492
- initialized = false;
1493
1365
  /**
1494
1366
  * Initialize the SDK
1495
1367
  * Preloads site configuration and metadata
@@ -1599,16 +1471,6 @@ var init_marvin = __esm({
1599
1471
  /**
1600
1472
  * Try multiple collection slugs in fallback order
1601
1473
  * Returns entries from the first collection that exists and has content
1602
- *
1603
- * @param slugs - Collection slugs to try in order
1604
- * @param options - Options for fallback behavior
1605
- * @returns Entries from the first matching collection, or empty array
1606
- *
1607
- * @example
1608
- * ```ts
1609
- * // Try bench-notes, then journal, then blog
1610
- * const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
1611
- * ```
1612
1474
  */
1613
1475
  async collectionFallback(slugs, options) {
1614
1476
  return this.workspace.collections.fallback(slugs, options);
@@ -1618,21 +1480,18 @@ var init_marvin = __esm({
1618
1480
  // ======================
1619
1481
  /**
1620
1482
  * @deprecated Use workspace.site or marvin.site instead
1621
- * Get site configuration
1622
1483
  */
1623
1484
  async getSite() {
1624
1485
  return this.workspace.loadSite();
1625
1486
  }
1626
1487
  /**
1627
1488
  * @deprecated Use workspace.entries.list() instead
1628
- * Get all published entries
1629
1489
  */
1630
1490
  async getEntries(options) {
1631
1491
  return this.workspace.entries.list(options);
1632
1492
  }
1633
1493
  /**
1634
1494
  * @deprecated Use workspace.entries.get() instead
1635
- * Get a single published entry by slug
1636
1495
  */
1637
1496
  async getEntry(slug) {
1638
1497
  const entry = await this.workspace.entries.get(slug);
@@ -1643,14 +1502,12 @@ var init_marvin = __esm({
1643
1502
  }
1644
1503
  /**
1645
1504
  * @deprecated Use workspace.collections.list() instead
1646
- * Get all collections
1647
1505
  */
1648
1506
  async getCollections() {
1649
1507
  return this.workspace.collections.list();
1650
1508
  }
1651
1509
  /**
1652
1510
  * @deprecated Use workspace.collections.get() instead
1653
- * Get a single collection by slug
1654
1511
  */
1655
1512
  async getCollection(slug) {
1656
1513
  const collection = await this.workspace.collections.get(slug);
@@ -1661,28 +1518,24 @@ var init_marvin = __esm({
1661
1518
  }
1662
1519
  /**
1663
1520
  * @deprecated Use workspace.collections.entries() instead
1664
- * Get all entries in a collection
1665
1521
  */
1666
1522
  async getCollectionEntries(slug) {
1667
1523
  return this.workspace.collections.entries(slug);
1668
1524
  }
1669
1525
  /**
1670
1526
  * @deprecated Use workspace.assets.list() instead
1671
- * Get all published assets
1672
1527
  */
1673
1528
  async getAssets(options) {
1674
1529
  return this.workspace.assets.list(options);
1675
1530
  }
1676
1531
  /**
1677
1532
  * @deprecated Use workspace.resources.list() instead
1678
- * Get all published resources
1679
1533
  */
1680
1534
  async getResources(options) {
1681
1535
  return this.workspace.resources.list(options);
1682
1536
  }
1683
1537
  /**
1684
1538
  * @deprecated Use workspace.resources.get() instead
1685
- * Get a single resource by slug
1686
1539
  */
1687
1540
  async getResource(slug) {
1688
1541
  const resource = await this.workspace.resources.get(slug);
@@ -1690,7 +1543,6 @@ var init_marvin = __esm({
1690
1543
  }
1691
1544
  /**
1692
1545
  * @deprecated Use workspace.resources.entries() instead
1693
- * Get entries that reference a resource
1694
1546
  */
1695
1547
  async getResourceEntries(slug) {
1696
1548
  return this.workspace.resources.entries(slug);
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
- import { M as MarvinConfig, a as MarvinClient } from './marvin-BAslemIz.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-BAslemIz.cjs';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-BhI__9Cj.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-BhI__9Cj.cjs';
3
3
  import { H as HttpClient } from './HttpClient-CdF3IHM1.cjs';
4
4
  export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-CdF3IHM1.cjs';
5
- import { AuthToken as AuthToken$1 } from './types/index.cjs';
6
- export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite, PublishedEntryType } from './types/index.cjs';
5
+ import { A as AuthToken$1 } from './index-BLIrbIHf.cjs';
6
+ 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, m as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BLIrbIHf.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-BmbMUJXh.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-BmbMUJXh.js';
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-C_TihjE2.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-C_TihjE2.js';
3
3
  import { H as HttpClient } from './HttpClient-CdF3IHM1.js';
4
4
  export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-CdF3IHM1.js';
5
- import { AuthToken as AuthToken$1 } from './types/index.js';
6
- export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite, PublishedEntryType } from './types/index.js';
5
+ import { A as AuthToken$1 } from './index-BLIrbIHf.js';
6
+ 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, m as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BLIrbIHf.js';
7
7
 
8
8
  /**
9
9
  * Authentication & User Registration
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  init_resource,
14
14
  init_workspace,
15
15
  marvin_exports
16
- } from "./chunk-SGZG7U7V.js";
16
+ } from "./chunk-L4LJWRA7.js";
17
17
  import {
18
18
  BearerTokenAuth,
19
19
  HttpClient,