@inneropen/marvin-sdk 2.0.0-next.23 → 2.0.0-next.24
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-CIFRKLJS.js → chunk-DCTX4NSF.js} +24 -126
- package/dist/index.cjs +24 -126
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{marvin-ixVRMtIS.d.cts → marvin-CwB9ybc8.d.cts} +32 -101
- package/dist/{marvin-B6kWCfmU.d.ts → marvin-KVTEthgH.d.ts} +32 -101
- package/dist/platform.cjs +1 -14
- package/dist/platform.d.cts +27 -189
- package/dist/platform.d.ts +27 -189
- package/dist/platform.js +1 -14
- package/dist/publish.cjs +24 -126
- 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 +58 -65
- package/dist/types/index.d.ts +58 -65
- package/package.json +1 -1
|
@@ -141,14 +141,10 @@ var init_entry = __esm({
|
|
|
141
141
|
"src/entries/entry.ts"() {
|
|
142
142
|
"use strict";
|
|
143
143
|
Entry = class {
|
|
144
|
-
constructor(raw
|
|
144
|
+
constructor(raw) {
|
|
145
145
|
this.raw = raw;
|
|
146
|
-
this.http = http;
|
|
147
|
-
this.workspaceSlug = workspaceSlug;
|
|
148
146
|
}
|
|
149
147
|
raw;
|
|
150
|
-
http;
|
|
151
|
-
workspaceSlug;
|
|
152
148
|
get title() {
|
|
153
149
|
return this.raw.title;
|
|
154
150
|
}
|
|
@@ -191,9 +187,6 @@ var init_entry = __esm({
|
|
|
191
187
|
get fields() {
|
|
192
188
|
return this.raw.data;
|
|
193
189
|
}
|
|
194
|
-
async relatedEntries() {
|
|
195
|
-
throw new Error("Related entries not yet implemented");
|
|
196
|
-
}
|
|
197
190
|
toJSON() {
|
|
198
191
|
return this.raw;
|
|
199
192
|
}
|
|
@@ -207,18 +200,10 @@ var init_collection = __esm({
|
|
|
207
200
|
"src/collections/collection.ts"() {
|
|
208
201
|
"use strict";
|
|
209
202
|
Collection = class {
|
|
210
|
-
constructor(data
|
|
203
|
+
constructor(data) {
|
|
211
204
|
this.data = data;
|
|
212
|
-
this.http = http;
|
|
213
|
-
this.workspaceSlug = workspaceSlug;
|
|
214
205
|
}
|
|
215
206
|
data;
|
|
216
|
-
http;
|
|
217
|
-
workspaceSlug;
|
|
218
|
-
// Expose all collection data as properties
|
|
219
|
-
get id() {
|
|
220
|
-
return this.data.id;
|
|
221
|
-
}
|
|
222
207
|
get name() {
|
|
223
208
|
return this.data.name;
|
|
224
209
|
}
|
|
@@ -228,48 +213,21 @@ var init_collection = __esm({
|
|
|
228
213
|
get description() {
|
|
229
214
|
return this.data.description;
|
|
230
215
|
}
|
|
231
|
-
get icon() {
|
|
232
|
-
return this.data.icon;
|
|
233
|
-
}
|
|
234
|
-
get color() {
|
|
235
|
-
return this.data.color;
|
|
236
|
-
}
|
|
237
|
-
get sortOrder() {
|
|
238
|
-
return this.data.sortOrder;
|
|
239
|
-
}
|
|
240
216
|
get isSmart() {
|
|
241
217
|
return this.data.isSmart;
|
|
242
218
|
}
|
|
243
219
|
get smartRules() {
|
|
244
220
|
return this.data.smartRules;
|
|
245
221
|
}
|
|
246
|
-
get
|
|
247
|
-
return this.data.
|
|
248
|
-
}
|
|
249
|
-
get updatedAt() {
|
|
250
|
-
return this.data.updatedAt;
|
|
222
|
+
get metadataJson() {
|
|
223
|
+
return this.data.metadataJson;
|
|
251
224
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*/
|
|
255
|
-
async entries() {
|
|
256
|
-
return this.data.entries || [];
|
|
225
|
+
get entryCount() {
|
|
226
|
+
return this.data.entryCount;
|
|
257
227
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*/
|
|
261
|
-
async assets() {
|
|
262
|
-
throw new Error("Collection assets not yet implemented");
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Get collection metadata (future)
|
|
266
|
-
*/
|
|
267
|
-
async metadata() {
|
|
268
|
-
throw new Error("Collection metadata not yet implemented");
|
|
228
|
+
get entries() {
|
|
229
|
+
return this.data.entries;
|
|
269
230
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Get raw collection data
|
|
272
|
-
*/
|
|
273
231
|
toJSON() {
|
|
274
232
|
return this.data;
|
|
275
233
|
}
|
|
@@ -283,18 +241,10 @@ var init_resource = __esm({
|
|
|
283
241
|
"src/resources/resource.ts"() {
|
|
284
242
|
"use strict";
|
|
285
243
|
Resource = class {
|
|
286
|
-
constructor(data
|
|
244
|
+
constructor(data) {
|
|
287
245
|
this.data = data;
|
|
288
|
-
this.http = http;
|
|
289
|
-
this.workspaceSlug = workspaceSlug;
|
|
290
246
|
}
|
|
291
247
|
data;
|
|
292
|
-
http;
|
|
293
|
-
workspaceSlug;
|
|
294
|
-
// Expose all resource data as properties
|
|
295
|
-
get id() {
|
|
296
|
-
return this.data.id;
|
|
297
|
-
}
|
|
298
248
|
get name() {
|
|
299
249
|
return this.data.name;
|
|
300
250
|
}
|
|
@@ -313,31 +263,12 @@ var init_resource = __esm({
|
|
|
313
263
|
get url() {
|
|
314
264
|
return this.data.url;
|
|
315
265
|
}
|
|
316
|
-
get
|
|
317
|
-
return this.data.
|
|
318
|
-
}
|
|
319
|
-
get createdAt() {
|
|
320
|
-
return this.data.createdAt;
|
|
321
|
-
}
|
|
322
|
-
get updatedAt() {
|
|
323
|
-
return this.data.updatedAt;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Get all entries that reference this resource
|
|
327
|
-
*/
|
|
328
|
-
async entries() {
|
|
329
|
-
const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
|
|
330
|
-
return this.http.fetch(endpoint);
|
|
266
|
+
get metadataJson() {
|
|
267
|
+
return this.data.metadataJson;
|
|
331
268
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
*/
|
|
335
|
-
async assets() {
|
|
336
|
-
throw new Error("Resource assets not yet implemented");
|
|
269
|
+
get entries() {
|
|
270
|
+
return this.data.entries;
|
|
337
271
|
}
|
|
338
|
-
/**
|
|
339
|
-
* Get raw resource data
|
|
340
|
-
*/
|
|
341
272
|
toJSON() {
|
|
342
273
|
return this.data;
|
|
343
274
|
}
|
|
@@ -368,7 +299,6 @@ var init_entries = __esm({
|
|
|
368
299
|
collection: options.collection,
|
|
369
300
|
limit: options.limit,
|
|
370
301
|
offset: options.offset
|
|
371
|
-
// Don't send status - backend always returns published
|
|
372
302
|
});
|
|
373
303
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
374
304
|
const response = await this.http.fetch(endpoint);
|
|
@@ -382,7 +312,7 @@ var init_entries = __esm({
|
|
|
382
312
|
try {
|
|
383
313
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
|
|
384
314
|
const data = await this.http.fetch(endpoint);
|
|
385
|
-
return new Entry(data
|
|
315
|
+
return new Entry(data);
|
|
386
316
|
} catch (error) {
|
|
387
317
|
if (error instanceof MarvinNotFoundError) {
|
|
388
318
|
return null;
|
|
@@ -442,7 +372,7 @@ var init_collections = __esm({
|
|
|
442
372
|
try {
|
|
443
373
|
const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
|
|
444
374
|
const data = await this.http.fetch(endpoint);
|
|
445
|
-
return new Collection(data
|
|
375
|
+
return new Collection(data);
|
|
446
376
|
} catch (error) {
|
|
447
377
|
if (error instanceof MarvinNotFoundError) {
|
|
448
378
|
return null;
|
|
@@ -459,21 +389,11 @@ var init_collections = __esm({
|
|
|
459
389
|
if (!collection) {
|
|
460
390
|
return [];
|
|
461
391
|
}
|
|
462
|
-
return collection.entries
|
|
392
|
+
return collection.entries;
|
|
463
393
|
}
|
|
464
394
|
/**
|
|
465
395
|
* Try multiple collection slugs in fallback order
|
|
466
396
|
* Returns the first collection that exists and has entries
|
|
467
|
-
*
|
|
468
|
-
* @param slugs - Collection slugs to try in order
|
|
469
|
-
* @param options - Options for fallback behavior
|
|
470
|
-
* @returns Entries from the first matching collection, or empty array
|
|
471
|
-
*
|
|
472
|
-
* @example
|
|
473
|
-
* ```ts
|
|
474
|
-
* // Try bench-notes, then journal, then blog
|
|
475
|
-
* const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
|
|
476
|
-
* ```
|
|
477
397
|
*/
|
|
478
398
|
async fallback(slugs, options = {}) {
|
|
479
399
|
const { requireEntries = true } = options;
|
|
@@ -483,7 +403,7 @@ var init_collections = __esm({
|
|
|
483
403
|
if (!collection) {
|
|
484
404
|
continue;
|
|
485
405
|
}
|
|
486
|
-
const entries =
|
|
406
|
+
const entries = collection.entries;
|
|
487
407
|
if (!requireEntries || entries.length > 0) {
|
|
488
408
|
return entries;
|
|
489
409
|
}
|
|
@@ -583,14 +503,14 @@ var init_resources = __esm({
|
|
|
583
503
|
async get(slug) {
|
|
584
504
|
const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
|
|
585
505
|
const data = await this.http.fetch(endpoint);
|
|
586
|
-
return new Resource(data
|
|
506
|
+
return new Resource(data);
|
|
587
507
|
}
|
|
588
508
|
/**
|
|
589
|
-
* Get
|
|
509
|
+
* Get entry slugs that reference this resource
|
|
590
510
|
*/
|
|
591
511
|
async entries(slug) {
|
|
592
512
|
const resource = await this.get(slug);
|
|
593
|
-
return resource.entries
|
|
513
|
+
return resource.entries;
|
|
594
514
|
}
|
|
595
515
|
};
|
|
596
516
|
}
|
|
@@ -721,8 +641,11 @@ var init_marvin = __esm({
|
|
|
721
641
|
init_core();
|
|
722
642
|
init_workspace();
|
|
723
643
|
MarvinClient = class {
|
|
644
|
+
http;
|
|
645
|
+
cache;
|
|
646
|
+
workspace;
|
|
647
|
+
initialized = false;
|
|
724
648
|
constructor(config) {
|
|
725
|
-
this.config = config;
|
|
726
649
|
validateConfig(config);
|
|
727
650
|
this.http = new MarvinHttpClient(config);
|
|
728
651
|
this.cache = new MarvinCache(config.cacheDuration);
|
|
@@ -731,11 +654,6 @@ var init_marvin = __esm({
|
|
|
731
654
|
this.initialize();
|
|
732
655
|
}
|
|
733
656
|
}
|
|
734
|
-
config;
|
|
735
|
-
http;
|
|
736
|
-
cache;
|
|
737
|
-
workspace;
|
|
738
|
-
initialized = false;
|
|
739
657
|
/**
|
|
740
658
|
* Initialize the SDK
|
|
741
659
|
* Preloads site configuration and metadata
|
|
@@ -845,16 +763,6 @@ var init_marvin = __esm({
|
|
|
845
763
|
/**
|
|
846
764
|
* Try multiple collection slugs in fallback order
|
|
847
765
|
* Returns entries from the first collection that exists and has content
|
|
848
|
-
*
|
|
849
|
-
* @param slugs - Collection slugs to try in order
|
|
850
|
-
* @param options - Options for fallback behavior
|
|
851
|
-
* @returns Entries from the first matching collection, or empty array
|
|
852
|
-
*
|
|
853
|
-
* @example
|
|
854
|
-
* ```ts
|
|
855
|
-
* // Try bench-notes, then journal, then blog
|
|
856
|
-
* const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
|
|
857
|
-
* ```
|
|
858
766
|
*/
|
|
859
767
|
async collectionFallback(slugs, options) {
|
|
860
768
|
return this.workspace.collections.fallback(slugs, options);
|
|
@@ -864,21 +772,18 @@ var init_marvin = __esm({
|
|
|
864
772
|
// ======================
|
|
865
773
|
/**
|
|
866
774
|
* @deprecated Use workspace.site or marvin.site instead
|
|
867
|
-
* Get site configuration
|
|
868
775
|
*/
|
|
869
776
|
async getSite() {
|
|
870
777
|
return this.workspace.loadSite();
|
|
871
778
|
}
|
|
872
779
|
/**
|
|
873
780
|
* @deprecated Use workspace.entries.list() instead
|
|
874
|
-
* Get all published entries
|
|
875
781
|
*/
|
|
876
782
|
async getEntries(options) {
|
|
877
783
|
return this.workspace.entries.list(options);
|
|
878
784
|
}
|
|
879
785
|
/**
|
|
880
786
|
* @deprecated Use workspace.entries.get() instead
|
|
881
|
-
* Get a single published entry by slug
|
|
882
787
|
*/
|
|
883
788
|
async getEntry(slug) {
|
|
884
789
|
const entry = await this.workspace.entries.get(slug);
|
|
@@ -889,14 +794,12 @@ var init_marvin = __esm({
|
|
|
889
794
|
}
|
|
890
795
|
/**
|
|
891
796
|
* @deprecated Use workspace.collections.list() instead
|
|
892
|
-
* Get all collections
|
|
893
797
|
*/
|
|
894
798
|
async getCollections() {
|
|
895
799
|
return this.workspace.collections.list();
|
|
896
800
|
}
|
|
897
801
|
/**
|
|
898
802
|
* @deprecated Use workspace.collections.get() instead
|
|
899
|
-
* Get a single collection by slug
|
|
900
803
|
*/
|
|
901
804
|
async getCollection(slug) {
|
|
902
805
|
const collection = await this.workspace.collections.get(slug);
|
|
@@ -907,28 +810,24 @@ var init_marvin = __esm({
|
|
|
907
810
|
}
|
|
908
811
|
/**
|
|
909
812
|
* @deprecated Use workspace.collections.entries() instead
|
|
910
|
-
* Get all entries in a collection
|
|
911
813
|
*/
|
|
912
814
|
async getCollectionEntries(slug) {
|
|
913
815
|
return this.workspace.collections.entries(slug);
|
|
914
816
|
}
|
|
915
817
|
/**
|
|
916
818
|
* @deprecated Use workspace.assets.list() instead
|
|
917
|
-
* Get all published assets
|
|
918
819
|
*/
|
|
919
820
|
async getAssets(options) {
|
|
920
821
|
return this.workspace.assets.list(options);
|
|
921
822
|
}
|
|
922
823
|
/**
|
|
923
824
|
* @deprecated Use workspace.resources.list() instead
|
|
924
|
-
* Get all published resources
|
|
925
825
|
*/
|
|
926
826
|
async getResources(options) {
|
|
927
827
|
return this.workspace.resources.list(options);
|
|
928
828
|
}
|
|
929
829
|
/**
|
|
930
830
|
* @deprecated Use workspace.resources.get() instead
|
|
931
|
-
* Get a single resource by slug
|
|
932
831
|
*/
|
|
933
832
|
async getResource(slug) {
|
|
934
833
|
const resource = await this.workspace.resources.get(slug);
|
|
@@ -936,7 +835,6 @@ var init_marvin = __esm({
|
|
|
936
835
|
}
|
|
937
836
|
/**
|
|
938
837
|
* @deprecated Use workspace.resources.entries() instead
|
|
939
|
-
* Get entries that reference a resource
|
|
940
838
|
*/
|
|
941
839
|
async getResourceEntries(slug) {
|
|
942
840
|
return this.workspace.resources.entries(slug);
|
package/dist/index.cjs
CHANGED
|
@@ -869,14 +869,10 @@ var init_entry = __esm({
|
|
|
869
869
|
"src/entries/entry.ts"() {
|
|
870
870
|
"use strict";
|
|
871
871
|
Entry = class {
|
|
872
|
-
constructor(raw
|
|
872
|
+
constructor(raw) {
|
|
873
873
|
this.raw = raw;
|
|
874
|
-
this.http = http;
|
|
875
|
-
this.workspaceSlug = workspaceSlug;
|
|
876
874
|
}
|
|
877
875
|
raw;
|
|
878
|
-
http;
|
|
879
|
-
workspaceSlug;
|
|
880
876
|
get title() {
|
|
881
877
|
return this.raw.title;
|
|
882
878
|
}
|
|
@@ -919,9 +915,6 @@ var init_entry = __esm({
|
|
|
919
915
|
get fields() {
|
|
920
916
|
return this.raw.data;
|
|
921
917
|
}
|
|
922
|
-
async relatedEntries() {
|
|
923
|
-
throw new Error("Related entries not yet implemented");
|
|
924
|
-
}
|
|
925
918
|
toJSON() {
|
|
926
919
|
return this.raw;
|
|
927
920
|
}
|
|
@@ -952,7 +945,6 @@ var init_entries = __esm({
|
|
|
952
945
|
collection: options.collection,
|
|
953
946
|
limit: options.limit,
|
|
954
947
|
offset: options.offset
|
|
955
|
-
// Don't send status - backend always returns published
|
|
956
948
|
});
|
|
957
949
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
958
950
|
const response = await this.http.fetch(endpoint);
|
|
@@ -966,7 +958,7 @@ var init_entries = __esm({
|
|
|
966
958
|
try {
|
|
967
959
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
|
|
968
960
|
const data = await this.http.fetch(endpoint);
|
|
969
|
-
return new Entry(data
|
|
961
|
+
return new Entry(data);
|
|
970
962
|
} catch (error) {
|
|
971
963
|
if (error instanceof MarvinNotFoundError) {
|
|
972
964
|
return null;
|
|
@@ -1002,18 +994,10 @@ var init_collection = __esm({
|
|
|
1002
994
|
"src/collections/collection.ts"() {
|
|
1003
995
|
"use strict";
|
|
1004
996
|
Collection = class {
|
|
1005
|
-
constructor(data
|
|
997
|
+
constructor(data) {
|
|
1006
998
|
this.data = data;
|
|
1007
|
-
this.http = http;
|
|
1008
|
-
this.workspaceSlug = workspaceSlug;
|
|
1009
999
|
}
|
|
1010
1000
|
data;
|
|
1011
|
-
http;
|
|
1012
|
-
workspaceSlug;
|
|
1013
|
-
// Expose all collection data as properties
|
|
1014
|
-
get id() {
|
|
1015
|
-
return this.data.id;
|
|
1016
|
-
}
|
|
1017
1001
|
get name() {
|
|
1018
1002
|
return this.data.name;
|
|
1019
1003
|
}
|
|
@@ -1023,48 +1007,21 @@ var init_collection = __esm({
|
|
|
1023
1007
|
get description() {
|
|
1024
1008
|
return this.data.description;
|
|
1025
1009
|
}
|
|
1026
|
-
get icon() {
|
|
1027
|
-
return this.data.icon;
|
|
1028
|
-
}
|
|
1029
|
-
get color() {
|
|
1030
|
-
return this.data.color;
|
|
1031
|
-
}
|
|
1032
|
-
get sortOrder() {
|
|
1033
|
-
return this.data.sortOrder;
|
|
1034
|
-
}
|
|
1035
1010
|
get isSmart() {
|
|
1036
1011
|
return this.data.isSmart;
|
|
1037
1012
|
}
|
|
1038
1013
|
get smartRules() {
|
|
1039
1014
|
return this.data.smartRules;
|
|
1040
1015
|
}
|
|
1041
|
-
get
|
|
1042
|
-
return this.data.
|
|
1043
|
-
}
|
|
1044
|
-
get updatedAt() {
|
|
1045
|
-
return this.data.updatedAt;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Get all entries in this collection
|
|
1049
|
-
*/
|
|
1050
|
-
async entries() {
|
|
1051
|
-
return this.data.entries || [];
|
|
1016
|
+
get metadataJson() {
|
|
1017
|
+
return this.data.metadataJson;
|
|
1052
1018
|
}
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
*/
|
|
1056
|
-
async assets() {
|
|
1057
|
-
throw new Error("Collection assets not yet implemented");
|
|
1019
|
+
get entryCount() {
|
|
1020
|
+
return this.data.entryCount;
|
|
1058
1021
|
}
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
*/
|
|
1062
|
-
async metadata() {
|
|
1063
|
-
throw new Error("Collection metadata not yet implemented");
|
|
1022
|
+
get entries() {
|
|
1023
|
+
return this.data.entries;
|
|
1064
1024
|
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Get raw collection data
|
|
1067
|
-
*/
|
|
1068
1025
|
toJSON() {
|
|
1069
1026
|
return this.data;
|
|
1070
1027
|
}
|
|
@@ -1102,7 +1059,7 @@ var init_collections = __esm({
|
|
|
1102
1059
|
try {
|
|
1103
1060
|
const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
|
|
1104
1061
|
const data = await this.http.fetch(endpoint);
|
|
1105
|
-
return new Collection(data
|
|
1062
|
+
return new Collection(data);
|
|
1106
1063
|
} catch (error) {
|
|
1107
1064
|
if (error instanceof MarvinNotFoundError) {
|
|
1108
1065
|
return null;
|
|
@@ -1119,21 +1076,11 @@ var init_collections = __esm({
|
|
|
1119
1076
|
if (!collection) {
|
|
1120
1077
|
return [];
|
|
1121
1078
|
}
|
|
1122
|
-
return collection.entries
|
|
1079
|
+
return collection.entries;
|
|
1123
1080
|
}
|
|
1124
1081
|
/**
|
|
1125
1082
|
* Try multiple collection slugs in fallback order
|
|
1126
1083
|
* Returns the first collection that exists and has entries
|
|
1127
|
-
*
|
|
1128
|
-
* @param slugs - Collection slugs to try in order
|
|
1129
|
-
* @param options - Options for fallback behavior
|
|
1130
|
-
* @returns Entries from the first matching collection, or empty array
|
|
1131
|
-
*
|
|
1132
|
-
* @example
|
|
1133
|
-
* ```ts
|
|
1134
|
-
* // Try bench-notes, then journal, then blog
|
|
1135
|
-
* const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
|
|
1136
|
-
* ```
|
|
1137
1084
|
*/
|
|
1138
1085
|
async fallback(slugs, options = {}) {
|
|
1139
1086
|
const { requireEntries = true } = options;
|
|
@@ -1143,7 +1090,7 @@ var init_collections = __esm({
|
|
|
1143
1090
|
if (!collection) {
|
|
1144
1091
|
continue;
|
|
1145
1092
|
}
|
|
1146
|
-
const entries =
|
|
1093
|
+
const entries = collection.entries;
|
|
1147
1094
|
if (!requireEntries || entries.length > 0) {
|
|
1148
1095
|
return entries;
|
|
1149
1096
|
}
|
|
@@ -1217,18 +1164,10 @@ var init_resource = __esm({
|
|
|
1217
1164
|
"src/resources/resource.ts"() {
|
|
1218
1165
|
"use strict";
|
|
1219
1166
|
Resource = class {
|
|
1220
|
-
constructor(data
|
|
1167
|
+
constructor(data) {
|
|
1221
1168
|
this.data = data;
|
|
1222
|
-
this.http = http;
|
|
1223
|
-
this.workspaceSlug = workspaceSlug;
|
|
1224
1169
|
}
|
|
1225
1170
|
data;
|
|
1226
|
-
http;
|
|
1227
|
-
workspaceSlug;
|
|
1228
|
-
// Expose all resource data as properties
|
|
1229
|
-
get id() {
|
|
1230
|
-
return this.data.id;
|
|
1231
|
-
}
|
|
1232
1171
|
get name() {
|
|
1233
1172
|
return this.data.name;
|
|
1234
1173
|
}
|
|
@@ -1247,31 +1186,12 @@ var init_resource = __esm({
|
|
|
1247
1186
|
get url() {
|
|
1248
1187
|
return this.data.url;
|
|
1249
1188
|
}
|
|
1250
|
-
get
|
|
1251
|
-
return this.data.
|
|
1252
|
-
}
|
|
1253
|
-
get createdAt() {
|
|
1254
|
-
return this.data.createdAt;
|
|
1255
|
-
}
|
|
1256
|
-
get updatedAt() {
|
|
1257
|
-
return this.data.updatedAt;
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* Get all entries that reference this resource
|
|
1261
|
-
*/
|
|
1262
|
-
async entries() {
|
|
1263
|
-
const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
|
|
1264
|
-
return this.http.fetch(endpoint);
|
|
1189
|
+
get metadataJson() {
|
|
1190
|
+
return this.data.metadataJson;
|
|
1265
1191
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
*/
|
|
1269
|
-
async assets() {
|
|
1270
|
-
throw new Error("Resource assets not yet implemented");
|
|
1192
|
+
get entries() {
|
|
1193
|
+
return this.data.entries;
|
|
1271
1194
|
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Get raw resource data
|
|
1274
|
-
*/
|
|
1275
1195
|
toJSON() {
|
|
1276
1196
|
return this.data;
|
|
1277
1197
|
}
|
|
@@ -1311,14 +1231,14 @@ var init_resources = __esm({
|
|
|
1311
1231
|
async get(slug) {
|
|
1312
1232
|
const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
|
|
1313
1233
|
const data = await this.http.fetch(endpoint);
|
|
1314
|
-
return new Resource(data
|
|
1234
|
+
return new Resource(data);
|
|
1315
1235
|
}
|
|
1316
1236
|
/**
|
|
1317
|
-
* Get
|
|
1237
|
+
* Get entry slugs that reference this resource
|
|
1318
1238
|
*/
|
|
1319
1239
|
async entries(slug) {
|
|
1320
1240
|
const resource = await this.get(slug);
|
|
1321
|
-
return resource.entries
|
|
1241
|
+
return resource.entries;
|
|
1322
1242
|
}
|
|
1323
1243
|
};
|
|
1324
1244
|
}
|
|
@@ -1423,8 +1343,11 @@ var init_marvin = __esm({
|
|
|
1423
1343
|
init_core();
|
|
1424
1344
|
init_workspace();
|
|
1425
1345
|
MarvinClient = class {
|
|
1346
|
+
http;
|
|
1347
|
+
cache;
|
|
1348
|
+
workspace;
|
|
1349
|
+
initialized = false;
|
|
1426
1350
|
constructor(config) {
|
|
1427
|
-
this.config = config;
|
|
1428
1351
|
validateConfig(config);
|
|
1429
1352
|
this.http = new MarvinHttpClient(config);
|
|
1430
1353
|
this.cache = new MarvinCache(config.cacheDuration);
|
|
@@ -1433,11 +1356,6 @@ var init_marvin = __esm({
|
|
|
1433
1356
|
this.initialize();
|
|
1434
1357
|
}
|
|
1435
1358
|
}
|
|
1436
|
-
config;
|
|
1437
|
-
http;
|
|
1438
|
-
cache;
|
|
1439
|
-
workspace;
|
|
1440
|
-
initialized = false;
|
|
1441
1359
|
/**
|
|
1442
1360
|
* Initialize the SDK
|
|
1443
1361
|
* Preloads site configuration and metadata
|
|
@@ -1547,16 +1465,6 @@ var init_marvin = __esm({
|
|
|
1547
1465
|
/**
|
|
1548
1466
|
* Try multiple collection slugs in fallback order
|
|
1549
1467
|
* Returns entries from the first collection that exists and has content
|
|
1550
|
-
*
|
|
1551
|
-
* @param slugs - Collection slugs to try in order
|
|
1552
|
-
* @param options - Options for fallback behavior
|
|
1553
|
-
* @returns Entries from the first matching collection, or empty array
|
|
1554
|
-
*
|
|
1555
|
-
* @example
|
|
1556
|
-
* ```ts
|
|
1557
|
-
* // Try bench-notes, then journal, then blog
|
|
1558
|
-
* const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
|
|
1559
|
-
* ```
|
|
1560
1468
|
*/
|
|
1561
1469
|
async collectionFallback(slugs, options) {
|
|
1562
1470
|
return this.workspace.collections.fallback(slugs, options);
|
|
@@ -1566,21 +1474,18 @@ var init_marvin = __esm({
|
|
|
1566
1474
|
// ======================
|
|
1567
1475
|
/**
|
|
1568
1476
|
* @deprecated Use workspace.site or marvin.site instead
|
|
1569
|
-
* Get site configuration
|
|
1570
1477
|
*/
|
|
1571
1478
|
async getSite() {
|
|
1572
1479
|
return this.workspace.loadSite();
|
|
1573
1480
|
}
|
|
1574
1481
|
/**
|
|
1575
1482
|
* @deprecated Use workspace.entries.list() instead
|
|
1576
|
-
* Get all published entries
|
|
1577
1483
|
*/
|
|
1578
1484
|
async getEntries(options) {
|
|
1579
1485
|
return this.workspace.entries.list(options);
|
|
1580
1486
|
}
|
|
1581
1487
|
/**
|
|
1582
1488
|
* @deprecated Use workspace.entries.get() instead
|
|
1583
|
-
* Get a single published entry by slug
|
|
1584
1489
|
*/
|
|
1585
1490
|
async getEntry(slug) {
|
|
1586
1491
|
const entry = await this.workspace.entries.get(slug);
|
|
@@ -1591,14 +1496,12 @@ var init_marvin = __esm({
|
|
|
1591
1496
|
}
|
|
1592
1497
|
/**
|
|
1593
1498
|
* @deprecated Use workspace.collections.list() instead
|
|
1594
|
-
* Get all collections
|
|
1595
1499
|
*/
|
|
1596
1500
|
async getCollections() {
|
|
1597
1501
|
return this.workspace.collections.list();
|
|
1598
1502
|
}
|
|
1599
1503
|
/**
|
|
1600
1504
|
* @deprecated Use workspace.collections.get() instead
|
|
1601
|
-
* Get a single collection by slug
|
|
1602
1505
|
*/
|
|
1603
1506
|
async getCollection(slug) {
|
|
1604
1507
|
const collection = await this.workspace.collections.get(slug);
|
|
@@ -1609,28 +1512,24 @@ var init_marvin = __esm({
|
|
|
1609
1512
|
}
|
|
1610
1513
|
/**
|
|
1611
1514
|
* @deprecated Use workspace.collections.entries() instead
|
|
1612
|
-
* Get all entries in a collection
|
|
1613
1515
|
*/
|
|
1614
1516
|
async getCollectionEntries(slug) {
|
|
1615
1517
|
return this.workspace.collections.entries(slug);
|
|
1616
1518
|
}
|
|
1617
1519
|
/**
|
|
1618
1520
|
* @deprecated Use workspace.assets.list() instead
|
|
1619
|
-
* Get all published assets
|
|
1620
1521
|
*/
|
|
1621
1522
|
async getAssets(options) {
|
|
1622
1523
|
return this.workspace.assets.list(options);
|
|
1623
1524
|
}
|
|
1624
1525
|
/**
|
|
1625
1526
|
* @deprecated Use workspace.resources.list() instead
|
|
1626
|
-
* Get all published resources
|
|
1627
1527
|
*/
|
|
1628
1528
|
async getResources(options) {
|
|
1629
1529
|
return this.workspace.resources.list(options);
|
|
1630
1530
|
}
|
|
1631
1531
|
/**
|
|
1632
1532
|
* @deprecated Use workspace.resources.get() instead
|
|
1633
|
-
* Get a single resource by slug
|
|
1634
1533
|
*/
|
|
1635
1534
|
async getResource(slug) {
|
|
1636
1535
|
const resource = await this.workspace.resources.get(slug);
|
|
@@ -1638,7 +1537,6 @@ var init_marvin = __esm({
|
|
|
1638
1537
|
}
|
|
1639
1538
|
/**
|
|
1640
1539
|
* @deprecated Use workspace.resources.entries() instead
|
|
1641
|
-
* Get entries that reference a resource
|
|
1642
1540
|
*/
|
|
1643
1541
|
async getResourceEntries(slug) {
|
|
1644
1542
|
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-
|
|
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-
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-CwB9ybc8.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-CwB9ybc8.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
5
|
import { AuthToken as AuthToken$1 } from './types/index.cjs';
|
|
6
|
-
export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite, PublishedAssetRead, PublishedCollectionSummary, PublishedEntryType, PublishedResourceRead } from './types/index.cjs';
|
|
6
|
+
export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryListItem, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite, PublishedAssetRead, PublishedCollectionSummary, PublishedEntryType, PublishedResourceRead } from './types/index.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Authentication & User Registration
|