@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/{chunk-SGZG7U7V.js → chunk-L4LJWRA7.js} +60 -208
- package/dist/index-BLIrbIHf.d.cts +3409 -0
- package/dist/index-BLIrbIHf.d.ts +3409 -0
- package/dist/index.cjs +59 -207
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{marvin-BAslemIz.d.cts → marvin-BhI__9Cj.d.cts} +120 -159
- package/dist/{marvin-BmbMUJXh.d.ts → marvin-C_TihjE2.d.ts} +120 -159
- package/dist/platform.cjs +1 -14
- package/dist/platform.d.cts +28 -3520
- package/dist/platform.d.ts +28 -3520
- package/dist/platform.js +1 -14
- package/dist/publish.cjs +59 -207
- package/dist/publish.d.cts +3 -3
- package/dist/publish.d.ts +3 -3
- package/dist/publish.js +1 -1
- package/dist/types/index.d.cts +1 -213
- package/dist/types/index.d.ts +1 -213
- package/package.json +1 -1
|
@@ -141,113 +141,66 @@ var init_entry = __esm({
|
|
|
141
141
|
"src/entries/entry.ts"() {
|
|
142
142
|
"use strict";
|
|
143
143
|
Entry = class {
|
|
144
|
-
constructor(
|
|
145
|
-
this.
|
|
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.
|
|
149
|
+
return this.raw.title;
|
|
158
150
|
}
|
|
159
151
|
get slug() {
|
|
160
|
-
return this.
|
|
152
|
+
return this.raw.slug;
|
|
161
153
|
}
|
|
162
154
|
get summary() {
|
|
163
|
-
return this.
|
|
164
|
-
}
|
|
165
|
-
get description() {
|
|
166
|
-
return this.data.description;
|
|
155
|
+
return this.raw.summary;
|
|
167
156
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*/
|
|
171
|
-
get contentMarkdown() {
|
|
172
|
-
return this.data.contentMarkdown;
|
|
157
|
+
get entryType() {
|
|
158
|
+
return this.raw.entryType;
|
|
173
159
|
}
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
183
|
-
return this.data
|
|
163
|
+
get data() {
|
|
164
|
+
return this.raw.data;
|
|
184
165
|
}
|
|
185
|
-
get
|
|
186
|
-
return this.
|
|
166
|
+
get metadataJson() {
|
|
167
|
+
return this.raw.metadataJson;
|
|
187
168
|
}
|
|
188
169
|
get publishedAt() {
|
|
189
|
-
return this.
|
|
170
|
+
return this.raw.publishedAt;
|
|
190
171
|
}
|
|
191
|
-
get
|
|
192
|
-
return this.
|
|
172
|
+
get order() {
|
|
173
|
+
return this.raw.order;
|
|
193
174
|
}
|
|
194
|
-
get
|
|
195
|
-
return this.
|
|
175
|
+
get assets() {
|
|
176
|
+
return this.raw.assets;
|
|
196
177
|
}
|
|
197
|
-
get
|
|
198
|
-
return this.
|
|
178
|
+
get collections() {
|
|
179
|
+
return this.raw.collections;
|
|
199
180
|
}
|
|
200
|
-
get
|
|
201
|
-
return this.
|
|
181
|
+
get resources() {
|
|
182
|
+
return this.raw.resources;
|
|
202
183
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return this.
|
|
184
|
+
asset(role) {
|
|
185
|
+
return this.raw.assets.find((a) => a.role === role);
|
|
186
|
+
}
|
|
187
|
+
assetsByRole(role) {
|
|
188
|
+
return this.raw.assets.filter((a) => a.role === role);
|
|
189
|
+
}
|
|
190
|
+
resource(role) {
|
|
191
|
+
return this.raw.resources.find((r) => r.role === role);
|
|
192
|
+
}
|
|
193
|
+
resourcesByRole(role) {
|
|
194
|
+
return this.raw.resources.filter((r) => r.role === role);
|
|
208
195
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Get entry collections
|
|
211
|
-
*/
|
|
212
|
-
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
|
-
*/
|
|
230
196
|
field(key) {
|
|
231
|
-
return this.data
|
|
197
|
+
return this.raw.data[key];
|
|
232
198
|
}
|
|
233
|
-
/**
|
|
234
|
-
* Get all fields from the entry's schema-driven content.
|
|
235
|
-
* @since 2.0.0
|
|
236
|
-
*/
|
|
237
199
|
get fields() {
|
|
238
|
-
return this.data
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Get related entries (future)
|
|
242
|
-
*/
|
|
243
|
-
async relatedEntries() {
|
|
244
|
-
throw new Error("Related entries not yet implemented");
|
|
200
|
+
return this.raw.data;
|
|
245
201
|
}
|
|
246
|
-
/**
|
|
247
|
-
* Get raw entry data
|
|
248
|
-
*/
|
|
249
202
|
toJSON() {
|
|
250
|
-
return this.
|
|
203
|
+
return this.raw;
|
|
251
204
|
}
|
|
252
205
|
};
|
|
253
206
|
}
|
|
@@ -259,18 +212,10 @@ var init_collection = __esm({
|
|
|
259
212
|
"src/collections/collection.ts"() {
|
|
260
213
|
"use strict";
|
|
261
214
|
Collection = class {
|
|
262
|
-
constructor(data
|
|
215
|
+
constructor(data) {
|
|
263
216
|
this.data = data;
|
|
264
|
-
this.http = http;
|
|
265
|
-
this.workspaceSlug = workspaceSlug;
|
|
266
217
|
}
|
|
267
218
|
data;
|
|
268
|
-
http;
|
|
269
|
-
workspaceSlug;
|
|
270
|
-
// Expose all collection data as properties
|
|
271
|
-
get id() {
|
|
272
|
-
return this.data.id;
|
|
273
|
-
}
|
|
274
219
|
get name() {
|
|
275
220
|
return this.data.name;
|
|
276
221
|
}
|
|
@@ -280,48 +225,21 @@ var init_collection = __esm({
|
|
|
280
225
|
get description() {
|
|
281
226
|
return this.data.description;
|
|
282
227
|
}
|
|
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
228
|
get isSmart() {
|
|
293
229
|
return this.data.isSmart;
|
|
294
230
|
}
|
|
295
231
|
get smartRules() {
|
|
296
232
|
return this.data.smartRules;
|
|
297
233
|
}
|
|
298
|
-
get
|
|
299
|
-
return this.data.
|
|
300
|
-
}
|
|
301
|
-
get updatedAt() {
|
|
302
|
-
return this.data.updatedAt;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Get all entries in this collection
|
|
306
|
-
*/
|
|
307
|
-
async entries() {
|
|
308
|
-
return this.data.entries || [];
|
|
234
|
+
get metadataJson() {
|
|
235
|
+
return this.data.metadataJson;
|
|
309
236
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
*/
|
|
313
|
-
async assets() {
|
|
314
|
-
throw new Error("Collection assets not yet implemented");
|
|
237
|
+
get entryCount() {
|
|
238
|
+
return this.data.entryCount;
|
|
315
239
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
*/
|
|
319
|
-
async metadata() {
|
|
320
|
-
throw new Error("Collection metadata not yet implemented");
|
|
240
|
+
get entries() {
|
|
241
|
+
return this.data.entries;
|
|
321
242
|
}
|
|
322
|
-
/**
|
|
323
|
-
* Get raw collection data
|
|
324
|
-
*/
|
|
325
243
|
toJSON() {
|
|
326
244
|
return this.data;
|
|
327
245
|
}
|
|
@@ -335,18 +253,10 @@ var init_resource = __esm({
|
|
|
335
253
|
"src/resources/resource.ts"() {
|
|
336
254
|
"use strict";
|
|
337
255
|
Resource = class {
|
|
338
|
-
constructor(data
|
|
256
|
+
constructor(data) {
|
|
339
257
|
this.data = data;
|
|
340
|
-
this.http = http;
|
|
341
|
-
this.workspaceSlug = workspaceSlug;
|
|
342
258
|
}
|
|
343
259
|
data;
|
|
344
|
-
http;
|
|
345
|
-
workspaceSlug;
|
|
346
|
-
// Expose all resource data as properties
|
|
347
|
-
get id() {
|
|
348
|
-
return this.data.id;
|
|
349
|
-
}
|
|
350
260
|
get name() {
|
|
351
261
|
return this.data.name;
|
|
352
262
|
}
|
|
@@ -365,31 +275,12 @@ var init_resource = __esm({
|
|
|
365
275
|
get url() {
|
|
366
276
|
return this.data.url;
|
|
367
277
|
}
|
|
368
|
-
get
|
|
369
|
-
return this.data.
|
|
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);
|
|
278
|
+
get metadataJson() {
|
|
279
|
+
return this.data.metadataJson;
|
|
383
280
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
*/
|
|
387
|
-
async assets() {
|
|
388
|
-
throw new Error("Resource assets not yet implemented");
|
|
281
|
+
get entries() {
|
|
282
|
+
return this.data.entries;
|
|
389
283
|
}
|
|
390
|
-
/**
|
|
391
|
-
* Get raw resource data
|
|
392
|
-
*/
|
|
393
284
|
toJSON() {
|
|
394
285
|
return this.data;
|
|
395
286
|
}
|
|
@@ -420,7 +311,6 @@ var init_entries = __esm({
|
|
|
420
311
|
collection: options.collection,
|
|
421
312
|
limit: options.limit,
|
|
422
313
|
offset: options.offset
|
|
423
|
-
// Don't send status - backend always returns published
|
|
424
314
|
});
|
|
425
315
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
426
316
|
const response = await this.http.fetch(endpoint);
|
|
@@ -434,7 +324,7 @@ var init_entries = __esm({
|
|
|
434
324
|
try {
|
|
435
325
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
|
|
436
326
|
const data = await this.http.fetch(endpoint);
|
|
437
|
-
return new Entry(data
|
|
327
|
+
return new Entry(data);
|
|
438
328
|
} catch (error) {
|
|
439
329
|
if (error instanceof MarvinNotFoundError) {
|
|
440
330
|
return null;
|
|
@@ -494,7 +384,7 @@ var init_collections = __esm({
|
|
|
494
384
|
try {
|
|
495
385
|
const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
|
|
496
386
|
const data = await this.http.fetch(endpoint);
|
|
497
|
-
return new Collection(data
|
|
387
|
+
return new Collection(data);
|
|
498
388
|
} catch (error) {
|
|
499
389
|
if (error instanceof MarvinNotFoundError) {
|
|
500
390
|
return null;
|
|
@@ -511,21 +401,11 @@ var init_collections = __esm({
|
|
|
511
401
|
if (!collection) {
|
|
512
402
|
return [];
|
|
513
403
|
}
|
|
514
|
-
return collection.entries
|
|
404
|
+
return collection.entries;
|
|
515
405
|
}
|
|
516
406
|
/**
|
|
517
407
|
* Try multiple collection slugs in fallback order
|
|
518
408
|
* 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
409
|
*/
|
|
530
410
|
async fallback(slugs, options = {}) {
|
|
531
411
|
const { requireEntries = true } = options;
|
|
@@ -535,7 +415,7 @@ var init_collections = __esm({
|
|
|
535
415
|
if (!collection) {
|
|
536
416
|
continue;
|
|
537
417
|
}
|
|
538
|
-
const entries =
|
|
418
|
+
const entries = collection.entries;
|
|
539
419
|
if (!requireEntries || entries.length > 0) {
|
|
540
420
|
return entries;
|
|
541
421
|
}
|
|
@@ -635,14 +515,14 @@ var init_resources = __esm({
|
|
|
635
515
|
async get(slug) {
|
|
636
516
|
const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
|
|
637
517
|
const data = await this.http.fetch(endpoint);
|
|
638
|
-
return new Resource(data
|
|
518
|
+
return new Resource(data);
|
|
639
519
|
}
|
|
640
520
|
/**
|
|
641
|
-
* Get
|
|
521
|
+
* Get entry slugs that reference this resource
|
|
642
522
|
*/
|
|
643
523
|
async entries(slug) {
|
|
644
524
|
const resource = await this.get(slug);
|
|
645
|
-
return resource.entries
|
|
525
|
+
return resource.entries;
|
|
646
526
|
}
|
|
647
527
|
};
|
|
648
528
|
}
|
|
@@ -723,12 +603,6 @@ var init_workspace = __esm({
|
|
|
723
603
|
const endpoint = `/api/publish/${this._slug}`;
|
|
724
604
|
return this.http.fetch(endpoint);
|
|
725
605
|
}
|
|
726
|
-
/**
|
|
727
|
-
* Get workspace settings (future)
|
|
728
|
-
*/
|
|
729
|
-
async settings() {
|
|
730
|
-
throw new Error("Workspace settings not yet implemented");
|
|
731
|
-
}
|
|
732
606
|
};
|
|
733
607
|
}
|
|
734
608
|
});
|
|
@@ -773,8 +647,11 @@ var init_marvin = __esm({
|
|
|
773
647
|
init_core();
|
|
774
648
|
init_workspace();
|
|
775
649
|
MarvinClient = class {
|
|
650
|
+
http;
|
|
651
|
+
cache;
|
|
652
|
+
workspace;
|
|
653
|
+
initialized = false;
|
|
776
654
|
constructor(config) {
|
|
777
|
-
this.config = config;
|
|
778
655
|
validateConfig(config);
|
|
779
656
|
this.http = new MarvinHttpClient(config);
|
|
780
657
|
this.cache = new MarvinCache(config.cacheDuration);
|
|
@@ -783,11 +660,6 @@ var init_marvin = __esm({
|
|
|
783
660
|
this.initialize();
|
|
784
661
|
}
|
|
785
662
|
}
|
|
786
|
-
config;
|
|
787
|
-
http;
|
|
788
|
-
cache;
|
|
789
|
-
workspace;
|
|
790
|
-
initialized = false;
|
|
791
663
|
/**
|
|
792
664
|
* Initialize the SDK
|
|
793
665
|
* Preloads site configuration and metadata
|
|
@@ -897,16 +769,6 @@ var init_marvin = __esm({
|
|
|
897
769
|
/**
|
|
898
770
|
* Try multiple collection slugs in fallback order
|
|
899
771
|
* 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
772
|
*/
|
|
911
773
|
async collectionFallback(slugs, options) {
|
|
912
774
|
return this.workspace.collections.fallback(slugs, options);
|
|
@@ -916,21 +778,18 @@ var init_marvin = __esm({
|
|
|
916
778
|
// ======================
|
|
917
779
|
/**
|
|
918
780
|
* @deprecated Use workspace.site or marvin.site instead
|
|
919
|
-
* Get site configuration
|
|
920
781
|
*/
|
|
921
782
|
async getSite() {
|
|
922
783
|
return this.workspace.loadSite();
|
|
923
784
|
}
|
|
924
785
|
/**
|
|
925
786
|
* @deprecated Use workspace.entries.list() instead
|
|
926
|
-
* Get all published entries
|
|
927
787
|
*/
|
|
928
788
|
async getEntries(options) {
|
|
929
789
|
return this.workspace.entries.list(options);
|
|
930
790
|
}
|
|
931
791
|
/**
|
|
932
792
|
* @deprecated Use workspace.entries.get() instead
|
|
933
|
-
* Get a single published entry by slug
|
|
934
793
|
*/
|
|
935
794
|
async getEntry(slug) {
|
|
936
795
|
const entry = await this.workspace.entries.get(slug);
|
|
@@ -941,14 +800,12 @@ var init_marvin = __esm({
|
|
|
941
800
|
}
|
|
942
801
|
/**
|
|
943
802
|
* @deprecated Use workspace.collections.list() instead
|
|
944
|
-
* Get all collections
|
|
945
803
|
*/
|
|
946
804
|
async getCollections() {
|
|
947
805
|
return this.workspace.collections.list();
|
|
948
806
|
}
|
|
949
807
|
/**
|
|
950
808
|
* @deprecated Use workspace.collections.get() instead
|
|
951
|
-
* Get a single collection by slug
|
|
952
809
|
*/
|
|
953
810
|
async getCollection(slug) {
|
|
954
811
|
const collection = await this.workspace.collections.get(slug);
|
|
@@ -959,28 +816,24 @@ var init_marvin = __esm({
|
|
|
959
816
|
}
|
|
960
817
|
/**
|
|
961
818
|
* @deprecated Use workspace.collections.entries() instead
|
|
962
|
-
* Get all entries in a collection
|
|
963
819
|
*/
|
|
964
820
|
async getCollectionEntries(slug) {
|
|
965
821
|
return this.workspace.collections.entries(slug);
|
|
966
822
|
}
|
|
967
823
|
/**
|
|
968
824
|
* @deprecated Use workspace.assets.list() instead
|
|
969
|
-
* Get all published assets
|
|
970
825
|
*/
|
|
971
826
|
async getAssets(options) {
|
|
972
827
|
return this.workspace.assets.list(options);
|
|
973
828
|
}
|
|
974
829
|
/**
|
|
975
830
|
* @deprecated Use workspace.resources.list() instead
|
|
976
|
-
* Get all published resources
|
|
977
831
|
*/
|
|
978
832
|
async getResources(options) {
|
|
979
833
|
return this.workspace.resources.list(options);
|
|
980
834
|
}
|
|
981
835
|
/**
|
|
982
836
|
* @deprecated Use workspace.resources.get() instead
|
|
983
|
-
* Get a single resource by slug
|
|
984
837
|
*/
|
|
985
838
|
async getResource(slug) {
|
|
986
839
|
const resource = await this.workspace.resources.get(slug);
|
|
@@ -988,7 +841,6 @@ var init_marvin = __esm({
|
|
|
988
841
|
}
|
|
989
842
|
/**
|
|
990
843
|
* @deprecated Use workspace.resources.entries() instead
|
|
991
|
-
* Get entries that reference a resource
|
|
992
844
|
*/
|
|
993
845
|
async getResourceEntries(slug) {
|
|
994
846
|
return this.workspace.resources.entries(slug);
|