@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/platform.js CHANGED
@@ -1124,53 +1124,40 @@ var EmailTemplatesClient = class {
1124
1124
  http;
1125
1125
  /**
1126
1126
  * List all email templates for the workspace
1127
- * @param groupId - Workspace ID
1128
1127
  */
1129
1128
  async list(groupId) {
1130
1129
  return this.http.get(`/api/platform/workspaces/${groupId}/email-templates`);
1131
1130
  }
1132
1131
  /**
1133
1132
  * Get a specific email template
1134
- * @param groupId - Workspace ID
1135
- * @param templateId - Template ID
1136
1133
  */
1137
1134
  async get(groupId, templateId) {
1138
1135
  return this.http.get(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`);
1139
1136
  }
1140
1137
  /**
1141
1138
  * Create a new email template
1142
- * @param groupId - Workspace ID
1143
- * @param data - Template data
1144
1139
  */
1145
1140
  async create(groupId, data) {
1146
1141
  return this.http.post(`/api/platform/workspaces/${groupId}/email-templates`, data);
1147
1142
  }
1148
1143
  /**
1149
1144
  * Update an email template
1150
- * @param groupId - Workspace ID
1151
- * @param templateId - Template ID
1152
- * @param data - Updated template data
1153
1145
  */
1154
1146
  async update(groupId, templateId, data) {
1155
1147
  return this.http.patch(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`, data);
1156
1148
  }
1157
1149
  /**
1158
1150
  * Delete an email template
1159
- * @param groupId - Workspace ID
1160
- * @param templateId - Template ID
1161
1151
  */
1162
1152
  async delete(groupId, templateId) {
1163
1153
  await this.http.delete(`/api/platform/workspaces/${groupId}/email-templates/${templateId}`);
1164
1154
  }
1165
1155
  /**
1166
1156
  * Send a test email using a template
1167
- * @param groupId - Workspace ID
1168
- * @param templateId - Template ID
1169
- * @param recipientEmail - Test recipient email address
1170
1157
  */
1171
1158
  async sendTest(groupId, templateId, recipientEmail) {
1172
1159
  return this.http.post(`/api/platform/workspaces/${groupId}/email-templates/${templateId}/test`, {
1173
- recipient_email: recipientEmail
1160
+ email: recipientEmail
1174
1161
  });
1175
1162
  }
1176
1163
  };
package/dist/publish.cjs CHANGED
@@ -724,113 +724,66 @@ var MarvinHttpClient = class extends HttpClient {
724
724
 
725
725
  // src/entries/entry.ts
726
726
  var Entry = class {
727
- constructor(data, http, workspaceSlug) {
728
- this.data = data;
729
- this.http = http;
730
- this.workspaceSlug = workspaceSlug;
731
- }
732
- data;
733
- http;
734
- workspaceSlug;
735
- // Expose all entry data as properties
736
- get id() {
737
- return this.data.id;
727
+ constructor(raw) {
728
+ this.raw = raw;
738
729
  }
730
+ raw;
739
731
  get title() {
740
- return this.data.title;
732
+ return this.raw.title;
741
733
  }
742
734
  get slug() {
743
- return this.data.slug;
735
+ return this.raw.slug;
744
736
  }
745
737
  get summary() {
746
- return this.data.summary;
747
- }
748
- get description() {
749
- return this.data.description;
738
+ return this.raw.summary;
750
739
  }
751
- /**
752
- * @deprecated Use field('body') or dataJson instead. Will be removed in v3.0.0
753
- */
754
- get contentMarkdown() {
755
- return this.data.contentMarkdown;
740
+ get entryType() {
741
+ return this.raw.entryType;
756
742
  }
757
- /**
758
- * Schema-driven content data (replaces contentMarkdown in v2.0.0).
759
- * Access specific fields using the field() helper method.
760
- * @since 2.0.0
761
- */
762
- get dataJson() {
763
- return this.data.dataJson;
743
+ get entryTypeInfo() {
744
+ return this.raw.entryTypeInfo;
764
745
  }
765
- get metadata() {
766
- return this.data.metadata;
746
+ get data() {
747
+ return this.raw.data;
767
748
  }
768
- get status() {
769
- return this.data.status;
749
+ get metadataJson() {
750
+ return this.raw.metadataJson;
770
751
  }
771
752
  get publishedAt() {
772
- return this.data.publishedAt;
753
+ return this.raw.publishedAt;
773
754
  }
774
- get createdAt() {
775
- return this.data.createdAt;
755
+ get order() {
756
+ return this.raw.order;
776
757
  }
777
- get updatedAt() {
778
- return this.data.updatedAt;
758
+ get assets() {
759
+ return this.raw.assets;
779
760
  }
780
- get entryTypeId() {
781
- return this.data.entryTypeId;
761
+ get collections() {
762
+ return this.raw.collections;
782
763
  }
783
- get entryType() {
784
- return this.data.entryType;
764
+ get resources() {
765
+ return this.raw.resources;
785
766
  }
786
- /**
787
- * Get entry assets
788
- */
789
- get assets() {
790
- return this.data.assets || [];
767
+ asset(role) {
768
+ return this.raw.assets.find((a) => a.role === role);
791
769
  }
792
- /**
793
- * Get entry collections
794
- */
795
- get collections() {
796
- return this.data.collections || [];
770
+ assetsByRole(role) {
771
+ return this.raw.assets.filter((a) => a.role === role);
772
+ }
773
+ resource(role) {
774
+ return this.raw.resources.find((r) => r.role === role);
775
+ }
776
+ resourcesByRole(role) {
777
+ return this.raw.resources.filter((r) => r.role === role);
797
778
  }
798
- /**
799
- * Get a specific field value from the entry's schema-driven content (dataJson).
800
- *
801
- * @param key - Field key as defined in the entry type's schema
802
- * @returns The field value, or undefined if not present
803
- * @since 2.0.0
804
- *
805
- * @example
806
- * ```typescript
807
- * const entry = await client.entries.get('my-entry');
808
- * const body = entry.field('body'); // Get markdown body
809
- * const difficulty = entry.field('difficulty'); // Get difficulty level
810
- * const heroImage = entry.field('heroImage'); // Get hero image UUID
811
- * ```
812
- */
813
779
  field(key) {
814
- return this.data.dataJson?.[key];
780
+ return this.raw.data[key];
815
781
  }
816
- /**
817
- * Get all fields from the entry's schema-driven content.
818
- * @since 2.0.0
819
- */
820
782
  get fields() {
821
- return this.data.dataJson || {};
822
- }
823
- /**
824
- * Get related entries (future)
825
- */
826
- async relatedEntries() {
827
- throw new Error("Related entries not yet implemented");
783
+ return this.raw.data;
828
784
  }
829
- /**
830
- * Get raw entry data
831
- */
832
785
  toJSON() {
833
- return this.data;
786
+ return this.raw;
834
787
  }
835
788
  };
836
789
 
@@ -851,7 +804,6 @@ var EntriesModule = class {
851
804
  collection: options.collection,
852
805
  limit: options.limit,
853
806
  offset: options.offset
854
- // Don't send status - backend always returns published
855
807
  });
856
808
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
857
809
  const response = await this.http.fetch(endpoint);
@@ -865,7 +817,7 @@ var EntriesModule = class {
865
817
  try {
866
818
  const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
867
819
  const data = await this.http.fetch(endpoint);
868
- return new Entry(data, this.http, this.workspaceSlug);
820
+ return new Entry(data);
869
821
  } catch (error) {
870
822
  if (error instanceof MarvinNotFoundError) {
871
823
  return null;
@@ -895,18 +847,10 @@ var EntriesModule = class {
895
847
 
896
848
  // src/collections/collection.ts
897
849
  var Collection = class {
898
- constructor(data, http, workspaceSlug) {
850
+ constructor(data) {
899
851
  this.data = data;
900
- this.http = http;
901
- this.workspaceSlug = workspaceSlug;
902
852
  }
903
853
  data;
904
- http;
905
- workspaceSlug;
906
- // Expose all collection data as properties
907
- get id() {
908
- return this.data.id;
909
- }
910
854
  get name() {
911
855
  return this.data.name;
912
856
  }
@@ -916,48 +860,21 @@ var Collection = class {
916
860
  get description() {
917
861
  return this.data.description;
918
862
  }
919
- get icon() {
920
- return this.data.icon;
921
- }
922
- get color() {
923
- return this.data.color;
924
- }
925
- get sortOrder() {
926
- return this.data.sortOrder;
927
- }
928
863
  get isSmart() {
929
864
  return this.data.isSmart;
930
865
  }
931
866
  get smartRules() {
932
867
  return this.data.smartRules;
933
868
  }
934
- get createdAt() {
935
- return this.data.createdAt;
869
+ get metadataJson() {
870
+ return this.data.metadataJson;
936
871
  }
937
- get updatedAt() {
938
- return this.data.updatedAt;
872
+ get entryCount() {
873
+ return this.data.entryCount;
939
874
  }
940
- /**
941
- * Get all entries in this collection
942
- */
943
- async entries() {
944
- return this.data.entries || [];
945
- }
946
- /**
947
- * Get assets in this collection (future)
948
- */
949
- async assets() {
950
- throw new Error("Collection assets not yet implemented");
951
- }
952
- /**
953
- * Get collection metadata (future)
954
- */
955
- async metadata() {
956
- throw new Error("Collection metadata not yet implemented");
875
+ get entries() {
876
+ return this.data.entries;
957
877
  }
958
- /**
959
- * Get raw collection data
960
- */
961
878
  toJSON() {
962
879
  return this.data;
963
880
  }
@@ -987,7 +904,7 @@ var CollectionsModule = class {
987
904
  try {
988
905
  const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
989
906
  const data = await this.http.fetch(endpoint);
990
- return new Collection(data, this.http, this.workspaceSlug);
907
+ return new Collection(data);
991
908
  } catch (error) {
992
909
  if (error instanceof MarvinNotFoundError) {
993
910
  return null;
@@ -1004,21 +921,11 @@ var CollectionsModule = class {
1004
921
  if (!collection) {
1005
922
  return [];
1006
923
  }
1007
- return collection.entries();
924
+ return collection.entries;
1008
925
  }
1009
926
  /**
1010
927
  * Try multiple collection slugs in fallback order
1011
928
  * Returns the first collection that exists and has entries
1012
- *
1013
- * @param slugs - Collection slugs to try in order
1014
- * @param options - Options for fallback behavior
1015
- * @returns Entries from the first matching collection, or empty array
1016
- *
1017
- * @example
1018
- * ```ts
1019
- * // Try bench-notes, then journal, then blog
1020
- * const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
1021
- * ```
1022
929
  */
1023
930
  async fallback(slugs, options = {}) {
1024
931
  const { requireEntries = true } = options;
@@ -1028,7 +935,7 @@ var CollectionsModule = class {
1028
935
  if (!collection) {
1029
936
  continue;
1030
937
  }
1031
- const entries = await collection.entries();
938
+ const entries = collection.entries;
1032
939
  if (!requireEntries || entries.length > 0) {
1033
940
  return entries;
1034
941
  }
@@ -1090,18 +997,10 @@ var AssetsModule = class {
1090
997
 
1091
998
  // src/resources/resource.ts
1092
999
  var Resource = class {
1093
- constructor(data, http, workspaceSlug) {
1000
+ constructor(data) {
1094
1001
  this.data = data;
1095
- this.http = http;
1096
- this.workspaceSlug = workspaceSlug;
1097
1002
  }
1098
1003
  data;
1099
- http;
1100
- workspaceSlug;
1101
- // Expose all resource data as properties
1102
- get id() {
1103
- return this.data.id;
1104
- }
1105
1004
  get name() {
1106
1005
  return this.data.name;
1107
1006
  }
@@ -1120,31 +1019,12 @@ var Resource = class {
1120
1019
  get url() {
1121
1020
  return this.data.url;
1122
1021
  }
1123
- get metadata() {
1124
- return this.data.metadata;
1125
- }
1126
- get createdAt() {
1127
- return this.data.createdAt;
1022
+ get metadataJson() {
1023
+ return this.data.metadataJson;
1128
1024
  }
1129
- get updatedAt() {
1130
- return this.data.updatedAt;
1131
- }
1132
- /**
1133
- * Get all entries that reference this resource
1134
- */
1135
- async entries() {
1136
- const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
1137
- return this.http.fetch(endpoint);
1138
- }
1139
- /**
1140
- * Get assets related to this resource (future)
1141
- */
1142
- async assets() {
1143
- throw new Error("Resource assets not yet implemented");
1025
+ get entries() {
1026
+ return this.data.entries;
1144
1027
  }
1145
- /**
1146
- * Get raw resource data
1147
- */
1148
1028
  toJSON() {
1149
1029
  return this.data;
1150
1030
  }
@@ -1177,14 +1057,14 @@ var ResourcesModule = class {
1177
1057
  async get(slug) {
1178
1058
  const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
1179
1059
  const data = await this.http.fetch(endpoint);
1180
- return new Resource(data, this.http, this.workspaceSlug);
1060
+ return new Resource(data);
1181
1061
  }
1182
1062
  /**
1183
- * Get entries that reference this resource
1063
+ * Get entry slugs that reference this resource
1184
1064
  */
1185
1065
  async entries(slug) {
1186
1066
  const resource = await this.get(slug);
1187
- return resource.entries();
1067
+ return resource.entries;
1188
1068
  }
1189
1069
  };
1190
1070
 
@@ -1248,18 +1128,15 @@ var Workspace = class {
1248
1128
  const endpoint = `/api/publish/${this._slug}`;
1249
1129
  return this.http.fetch(endpoint);
1250
1130
  }
1251
- /**
1252
- * Get workspace settings (future)
1253
- */
1254
- async settings() {
1255
- throw new Error("Workspace settings not yet implemented");
1256
- }
1257
1131
  };
1258
1132
 
1259
1133
  // src/client/marvin.ts
1260
1134
  var MarvinClient = class {
1135
+ http;
1136
+ cache;
1137
+ workspace;
1138
+ initialized = false;
1261
1139
  constructor(config) {
1262
- this.config = config;
1263
1140
  validateConfig(config);
1264
1141
  this.http = new MarvinHttpClient(config);
1265
1142
  this.cache = new MarvinCache(config.cacheDuration);
@@ -1268,11 +1145,6 @@ var MarvinClient = class {
1268
1145
  this.initialize();
1269
1146
  }
1270
1147
  }
1271
- config;
1272
- http;
1273
- cache;
1274
- workspace;
1275
- initialized = false;
1276
1148
  /**
1277
1149
  * Initialize the SDK
1278
1150
  * Preloads site configuration and metadata
@@ -1382,16 +1254,6 @@ var MarvinClient = class {
1382
1254
  /**
1383
1255
  * Try multiple collection slugs in fallback order
1384
1256
  * Returns entries from the first collection that exists and has content
1385
- *
1386
- * @param slugs - Collection slugs to try in order
1387
- * @param options - Options for fallback behavior
1388
- * @returns Entries from the first matching collection, or empty array
1389
- *
1390
- * @example
1391
- * ```ts
1392
- * // Try bench-notes, then journal, then blog
1393
- * const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
1394
- * ```
1395
1257
  */
1396
1258
  async collectionFallback(slugs, options) {
1397
1259
  return this.workspace.collections.fallback(slugs, options);
@@ -1401,21 +1263,18 @@ var MarvinClient = class {
1401
1263
  // ======================
1402
1264
  /**
1403
1265
  * @deprecated Use workspace.site or marvin.site instead
1404
- * Get site configuration
1405
1266
  */
1406
1267
  async getSite() {
1407
1268
  return this.workspace.loadSite();
1408
1269
  }
1409
1270
  /**
1410
1271
  * @deprecated Use workspace.entries.list() instead
1411
- * Get all published entries
1412
1272
  */
1413
1273
  async getEntries(options) {
1414
1274
  return this.workspace.entries.list(options);
1415
1275
  }
1416
1276
  /**
1417
1277
  * @deprecated Use workspace.entries.get() instead
1418
- * Get a single published entry by slug
1419
1278
  */
1420
1279
  async getEntry(slug) {
1421
1280
  const entry = await this.workspace.entries.get(slug);
@@ -1426,14 +1285,12 @@ var MarvinClient = class {
1426
1285
  }
1427
1286
  /**
1428
1287
  * @deprecated Use workspace.collections.list() instead
1429
- * Get all collections
1430
1288
  */
1431
1289
  async getCollections() {
1432
1290
  return this.workspace.collections.list();
1433
1291
  }
1434
1292
  /**
1435
1293
  * @deprecated Use workspace.collections.get() instead
1436
- * Get a single collection by slug
1437
1294
  */
1438
1295
  async getCollection(slug) {
1439
1296
  const collection = await this.workspace.collections.get(slug);
@@ -1444,28 +1301,24 @@ var MarvinClient = class {
1444
1301
  }
1445
1302
  /**
1446
1303
  * @deprecated Use workspace.collections.entries() instead
1447
- * Get all entries in a collection
1448
1304
  */
1449
1305
  async getCollectionEntries(slug) {
1450
1306
  return this.workspace.collections.entries(slug);
1451
1307
  }
1452
1308
  /**
1453
1309
  * @deprecated Use workspace.assets.list() instead
1454
- * Get all published assets
1455
1310
  */
1456
1311
  async getAssets(options) {
1457
1312
  return this.workspace.assets.list(options);
1458
1313
  }
1459
1314
  /**
1460
1315
  * @deprecated Use workspace.resources.list() instead
1461
- * Get all published resources
1462
1316
  */
1463
1317
  async getResources(options) {
1464
1318
  return this.workspace.resources.list(options);
1465
1319
  }
1466
1320
  /**
1467
1321
  * @deprecated Use workspace.resources.get() instead
1468
- * Get a single resource by slug
1469
1322
  */
1470
1323
  async getResource(slug) {
1471
1324
  const resource = await this.workspace.resources.get(slug);
@@ -1473,7 +1326,6 @@ var MarvinClient = class {
1473
1326
  }
1474
1327
  /**
1475
1328
  * @deprecated Use workspace.resources.entries() instead
1476
- * Get entries that reference a resource
1477
1329
  */
1478
1330
  async getResourceEntries(slug) {
1479
1331
  return this.workspace.resources.entries(slug);
@@ -1,6 +1,6 @@
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';
3
- export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite } from './types/index.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
+ 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-BLIrbIHf.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-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';
3
- export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite } from './types/index.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
+ 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-BLIrbIHf.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-SGZG7U7V.js";
15
+ } from "./chunk-L4LJWRA7.js";
16
16
  import {
17
17
  BearerTokenAuth,
18
18
  HttpClient,