@inneropen/marvin-sdk 3.0.0 → 3.0.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.
@@ -141,113 +141,54 @@ var init_entry = __esm({
141
141
  "src/entries/entry.ts"() {
142
142
  "use strict";
143
143
  Entry = class {
144
- constructor(data, http, workspaceSlug) {
145
- this.data = data;
146
- this.http = http;
147
- this.workspaceSlug = workspaceSlug;
148
- }
149
- data;
150
- http;
151
- workspaceSlug;
152
- // Expose all entry data as properties
153
- get id() {
154
- return this.data.id;
144
+ constructor(raw) {
145
+ this.raw = raw;
155
146
  }
147
+ raw;
156
148
  get title() {
157
- return this.data.title;
149
+ return this.raw.title;
158
150
  }
159
151
  get slug() {
160
- return this.data.slug;
152
+ return this.raw.slug;
161
153
  }
162
154
  get summary() {
163
- return this.data.summary;
164
- }
165
- get description() {
166
- return this.data.description;
155
+ return this.raw.summary;
167
156
  }
168
- /**
169
- * @deprecated Use field('body') or dataJson instead. Will be removed in v3.0.0
170
- */
171
- get contentMarkdown() {
172
- return this.data.contentMarkdown;
157
+ get entryType() {
158
+ return this.raw.entryType;
173
159
  }
174
- /**
175
- * Schema-driven content data (replaces contentMarkdown in v2.0.0).
176
- * Access specific fields using the field() helper method.
177
- * @since 2.0.0
178
- */
179
- get dataJson() {
180
- return this.data.dataJson;
160
+ get entryTypeInfo() {
161
+ return this.raw.entryTypeInfo;
181
162
  }
182
- get metadata() {
183
- return this.data.metadata;
163
+ get data() {
164
+ return this.raw.data;
184
165
  }
185
- get status() {
186
- return this.data.status;
166
+ get metadataJson() {
167
+ return this.raw.metadataJson;
187
168
  }
188
169
  get publishedAt() {
189
- return this.data.publishedAt;
190
- }
191
- get createdAt() {
192
- return this.data.createdAt;
170
+ return this.raw.publishedAt;
193
171
  }
194
- get updatedAt() {
195
- return this.data.updatedAt;
172
+ get order() {
173
+ return this.raw.order;
196
174
  }
197
- get entryTypeId() {
198
- return this.data.entryTypeId;
199
- }
200
- get entryType() {
201
- return this.data.entryType;
202
- }
203
- /**
204
- * Get entry assets
205
- */
206
175
  get assets() {
207
- return this.data.assets || [];
176
+ return this.raw.assets;
208
177
  }
209
- /**
210
- * Get entry collections
211
- */
212
178
  get collections() {
213
- return this.data.collections || [];
214
- }
215
- /**
216
- * Get a specific field value from the entry's schema-driven content (dataJson).
217
- *
218
- * @param key - Field key as defined in the entry type's schema
219
- * @returns The field value, or undefined if not present
220
- * @since 2.0.0
221
- *
222
- * @example
223
- * ```typescript
224
- * const entry = await client.entries.get('my-entry');
225
- * const body = entry.field('body'); // Get markdown body
226
- * const difficulty = entry.field('difficulty'); // Get difficulty level
227
- * const heroImage = entry.field('heroImage'); // Get hero image UUID
228
- * ```
229
- */
179
+ return this.raw.collections;
180
+ }
181
+ get resources() {
182
+ return this.raw.resources;
183
+ }
230
184
  field(key) {
231
- return this.data.dataJson?.[key];
185
+ return this.raw.data[key];
232
186
  }
233
- /**
234
- * Get all fields from the entry's schema-driven content.
235
- * @since 2.0.0
236
- */
237
187
  get fields() {
238
- return this.data.dataJson || {};
239
- }
240
- /**
241
- * Get related entries (future)
242
- */
243
- async relatedEntries() {
244
- throw new Error("Related entries not yet implemented");
188
+ return this.raw.data;
245
189
  }
246
- /**
247
- * Get raw entry data
248
- */
249
190
  toJSON() {
250
- return this.data;
191
+ return this.raw;
251
192
  }
252
193
  };
253
194
  }
@@ -259,18 +200,10 @@ var init_collection = __esm({
259
200
  "src/collections/collection.ts"() {
260
201
  "use strict";
261
202
  Collection = class {
262
- constructor(data, http, workspaceSlug) {
203
+ constructor(data) {
263
204
  this.data = data;
264
- this.http = http;
265
- this.workspaceSlug = workspaceSlug;
266
205
  }
267
206
  data;
268
- http;
269
- workspaceSlug;
270
- // Expose all collection data as properties
271
- get id() {
272
- return this.data.id;
273
- }
274
207
  get name() {
275
208
  return this.data.name;
276
209
  }
@@ -280,48 +213,21 @@ var init_collection = __esm({
280
213
  get description() {
281
214
  return this.data.description;
282
215
  }
283
- get icon() {
284
- return this.data.icon;
285
- }
286
- get color() {
287
- return this.data.color;
288
- }
289
- get sortOrder() {
290
- return this.data.sortOrder;
291
- }
292
216
  get isSmart() {
293
217
  return this.data.isSmart;
294
218
  }
295
219
  get smartRules() {
296
220
  return this.data.smartRules;
297
221
  }
298
- get createdAt() {
299
- return this.data.createdAt;
222
+ get metadataJson() {
223
+ return this.data.metadataJson;
300
224
  }
301
- get updatedAt() {
302
- return this.data.updatedAt;
225
+ get entryCount() {
226
+ return this.data.entryCount;
303
227
  }
304
- /**
305
- * Get all entries in this collection
306
- */
307
- async entries() {
308
- return this.data.entries || [];
309
- }
310
- /**
311
- * Get assets in this collection (future)
312
- */
313
- async assets() {
314
- throw new Error("Collection assets not yet implemented");
315
- }
316
- /**
317
- * Get collection metadata (future)
318
- */
319
- async metadata() {
320
- throw new Error("Collection metadata not yet implemented");
228
+ get entries() {
229
+ return this.data.entries;
321
230
  }
322
- /**
323
- * Get raw collection data
324
- */
325
231
  toJSON() {
326
232
  return this.data;
327
233
  }
@@ -335,18 +241,10 @@ var init_resource = __esm({
335
241
  "src/resources/resource.ts"() {
336
242
  "use strict";
337
243
  Resource = class {
338
- constructor(data, http, workspaceSlug) {
244
+ constructor(data) {
339
245
  this.data = data;
340
- this.http = http;
341
- this.workspaceSlug = workspaceSlug;
342
246
  }
343
247
  data;
344
- http;
345
- workspaceSlug;
346
- // Expose all resource data as properties
347
- get id() {
348
- return this.data.id;
349
- }
350
248
  get name() {
351
249
  return this.data.name;
352
250
  }
@@ -365,31 +263,12 @@ var init_resource = __esm({
365
263
  get url() {
366
264
  return this.data.url;
367
265
  }
368
- get metadata() {
369
- return this.data.metadata;
370
- }
371
- get createdAt() {
372
- return this.data.createdAt;
373
- }
374
- get updatedAt() {
375
- return this.data.updatedAt;
376
- }
377
- /**
378
- * Get all entries that reference this resource
379
- */
380
- async entries() {
381
- const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
382
- return this.http.fetch(endpoint);
266
+ get metadataJson() {
267
+ return this.data.metadataJson;
383
268
  }
384
- /**
385
- * Get assets related to this resource (future)
386
- */
387
- async assets() {
388
- throw new Error("Resource assets not yet implemented");
269
+ get entries() {
270
+ return this.data.entries;
389
271
  }
390
- /**
391
- * Get raw resource data
392
- */
393
272
  toJSON() {
394
273
  return this.data;
395
274
  }
@@ -420,7 +299,6 @@ var init_entries = __esm({
420
299
  collection: options.collection,
421
300
  limit: options.limit,
422
301
  offset: options.offset
423
- // Don't send status - backend always returns published
424
302
  });
425
303
  const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
426
304
  const response = await this.http.fetch(endpoint);
@@ -434,7 +312,7 @@ var init_entries = __esm({
434
312
  try {
435
313
  const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
436
314
  const data = await this.http.fetch(endpoint);
437
- return new Entry(data, this.http, this.workspaceSlug);
315
+ return new Entry(data);
438
316
  } catch (error) {
439
317
  if (error instanceof MarvinNotFoundError) {
440
318
  return null;
@@ -494,7 +372,7 @@ var init_collections = __esm({
494
372
  try {
495
373
  const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
496
374
  const data = await this.http.fetch(endpoint);
497
- return new Collection(data, this.http, this.workspaceSlug);
375
+ return new Collection(data);
498
376
  } catch (error) {
499
377
  if (error instanceof MarvinNotFoundError) {
500
378
  return null;
@@ -511,21 +389,11 @@ var init_collections = __esm({
511
389
  if (!collection) {
512
390
  return [];
513
391
  }
514
- return collection.entries();
392
+ return collection.entries;
515
393
  }
516
394
  /**
517
395
  * Try multiple collection slugs in fallback order
518
396
  * Returns the first collection that exists and has entries
519
- *
520
- * @param slugs - Collection slugs to try in order
521
- * @param options - Options for fallback behavior
522
- * @returns Entries from the first matching collection, or empty array
523
- *
524
- * @example
525
- * ```ts
526
- * // Try bench-notes, then journal, then blog
527
- * const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
528
- * ```
529
397
  */
530
398
  async fallback(slugs, options = {}) {
531
399
  const { requireEntries = true } = options;
@@ -535,7 +403,7 @@ var init_collections = __esm({
535
403
  if (!collection) {
536
404
  continue;
537
405
  }
538
- const entries = await collection.entries();
406
+ const entries = collection.entries;
539
407
  if (!requireEntries || entries.length > 0) {
540
408
  return entries;
541
409
  }
@@ -635,14 +503,14 @@ var init_resources = __esm({
635
503
  async get(slug) {
636
504
  const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
637
505
  const data = await this.http.fetch(endpoint);
638
- return new Resource(data, this.http, this.workspaceSlug);
506
+ return new Resource(data);
639
507
  }
640
508
  /**
641
- * Get entries that reference this resource
509
+ * Get entry slugs that reference this resource
642
510
  */
643
511
  async entries(slug) {
644
512
  const resource = await this.get(slug);
645
- return resource.entries();
513
+ return resource.entries;
646
514
  }
647
515
  };
648
516
  }
@@ -723,12 +591,6 @@ var init_workspace = __esm({
723
591
  const endpoint = `/api/publish/${this._slug}`;
724
592
  return this.http.fetch(endpoint);
725
593
  }
726
- /**
727
- * Get workspace settings (future)
728
- */
729
- async settings() {
730
- throw new Error("Workspace settings not yet implemented");
731
- }
732
594
  };
733
595
  }
734
596
  });
@@ -773,8 +635,11 @@ var init_marvin = __esm({
773
635
  init_core();
774
636
  init_workspace();
775
637
  MarvinClient = class {
638
+ http;
639
+ cache;
640
+ workspace;
641
+ initialized = false;
776
642
  constructor(config) {
777
- this.config = config;
778
643
  validateConfig(config);
779
644
  this.http = new MarvinHttpClient(config);
780
645
  this.cache = new MarvinCache(config.cacheDuration);
@@ -783,11 +648,6 @@ var init_marvin = __esm({
783
648
  this.initialize();
784
649
  }
785
650
  }
786
- config;
787
- http;
788
- cache;
789
- workspace;
790
- initialized = false;
791
651
  /**
792
652
  * Initialize the SDK
793
653
  * Preloads site configuration and metadata
@@ -897,16 +757,6 @@ var init_marvin = __esm({
897
757
  /**
898
758
  * Try multiple collection slugs in fallback order
899
759
  * Returns entries from the first collection that exists and has content
900
- *
901
- * @param slugs - Collection slugs to try in order
902
- * @param options - Options for fallback behavior
903
- * @returns Entries from the first matching collection, or empty array
904
- *
905
- * @example
906
- * ```ts
907
- * // Try bench-notes, then journal, then blog
908
- * const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
909
- * ```
910
760
  */
911
761
  async collectionFallback(slugs, options) {
912
762
  return this.workspace.collections.fallback(slugs, options);
@@ -916,21 +766,18 @@ var init_marvin = __esm({
916
766
  // ======================
917
767
  /**
918
768
  * @deprecated Use workspace.site or marvin.site instead
919
- * Get site configuration
920
769
  */
921
770
  async getSite() {
922
771
  return this.workspace.loadSite();
923
772
  }
924
773
  /**
925
774
  * @deprecated Use workspace.entries.list() instead
926
- * Get all published entries
927
775
  */
928
776
  async getEntries(options) {
929
777
  return this.workspace.entries.list(options);
930
778
  }
931
779
  /**
932
780
  * @deprecated Use workspace.entries.get() instead
933
- * Get a single published entry by slug
934
781
  */
935
782
  async getEntry(slug) {
936
783
  const entry = await this.workspace.entries.get(slug);
@@ -941,14 +788,12 @@ var init_marvin = __esm({
941
788
  }
942
789
  /**
943
790
  * @deprecated Use workspace.collections.list() instead
944
- * Get all collections
945
791
  */
946
792
  async getCollections() {
947
793
  return this.workspace.collections.list();
948
794
  }
949
795
  /**
950
796
  * @deprecated Use workspace.collections.get() instead
951
- * Get a single collection by slug
952
797
  */
953
798
  async getCollection(slug) {
954
799
  const collection = await this.workspace.collections.get(slug);
@@ -959,28 +804,24 @@ var init_marvin = __esm({
959
804
  }
960
805
  /**
961
806
  * @deprecated Use workspace.collections.entries() instead
962
- * Get all entries in a collection
963
807
  */
964
808
  async getCollectionEntries(slug) {
965
809
  return this.workspace.collections.entries(slug);
966
810
  }
967
811
  /**
968
812
  * @deprecated Use workspace.assets.list() instead
969
- * Get all published assets
970
813
  */
971
814
  async getAssets(options) {
972
815
  return this.workspace.assets.list(options);
973
816
  }
974
817
  /**
975
818
  * @deprecated Use workspace.resources.list() instead
976
- * Get all published resources
977
819
  */
978
820
  async getResources(options) {
979
821
  return this.workspace.resources.list(options);
980
822
  }
981
823
  /**
982
824
  * @deprecated Use workspace.resources.get() instead
983
- * Get a single resource by slug
984
825
  */
985
826
  async getResource(slug) {
986
827
  const resource = await this.workspace.resources.get(slug);
@@ -988,7 +829,6 @@ var init_marvin = __esm({
988
829
  }
989
830
  /**
990
831
  * @deprecated Use workspace.resources.entries() instead
991
- * Get entries that reference a resource
992
832
  */
993
833
  async getResourceEntries(slug) {
994
834
  return this.workspace.resources.entries(slug);