@inneropen/marvin-sdk 2.0.0-next.18 → 2.0.0-next.3

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.
@@ -1,980 +0,0 @@
1
- import {
2
- BearerTokenAuth,
3
- HttpClient,
4
- MarvinCache,
5
- MarvinNotFoundError,
6
- __esm,
7
- __export,
8
- init_core,
9
- init_errors
10
- } from "./chunk-WJC4X7TB.js";
11
-
12
- // src/client/config.ts
13
- var config_exports = {};
14
- __export(config_exports, {
15
- createConfigFromEnv: () => createConfigFromEnv,
16
- validateConfig: () => validateConfig
17
- });
18
- function validateConfig(config) {
19
- const receivedKeys = Object.keys(config).join(", ");
20
- if (!config.apiUrl) {
21
- throw new Error(
22
- `Missing required config: 'apiUrl'
23
-
24
- The API URL is the base URL of your Marvin server.
25
-
26
- Examples:
27
- - Production: https://marvin.example.com
28
- - Development: http://localhost:8080
29
-
30
- Solutions:
31
- 1. Set environment variable: MARVIN_API_URL=https://marvin.example.com
32
- 2. Pass directly: createMarvinClient({ apiUrl: 'https://marvin.example.com' })
33
-
34
- Received config keys: ${receivedKeys || "(none)"}`
35
- );
36
- }
37
- if (!config.siteClientToken) {
38
- throw new Error(
39
- `Missing required config: 'siteClientToken'
40
-
41
- The site client token provides read-only access to published content.
42
-
43
- How to get it:
44
- 1. Log into Marvin admin panel
45
- 2. Navigate to: Settings \u2192 API Clients
46
- 3. Copy the token for your workspace
47
-
48
- Examples:
49
- - site_client_abc123xyz
50
- - sc_1234567890abcdef
51
-
52
- Solutions:
53
- 1. Set environment variable: MARVIN_SITE_CLIENT_TOKEN=site_client_abc123
54
- 2. Pass directly: createMarvinClient({ siteClientToken: 'site_client_abc123' })
55
-
56
- Received config keys: ${receivedKeys}`
57
- );
58
- }
59
- if (!config.workspaceSlug) {
60
- throw new Error(
61
- `Missing required config: 'workspaceSlug'
62
-
63
- The workspace slug identifies which workspace to access.
64
-
65
- Examples:
66
- - my-blog
67
- - company-website
68
- - acme-corp
69
-
70
- How to find it:
71
- 1. Check your workspace URL: https://marvin.example.com/workspace/[slug]
72
- 2. Or find it in: Settings \u2192 General \u2192 Workspace Slug
73
-
74
- Solutions:
75
- 1. Set environment variable: MARVIN_WORKSPACE_SLUG=my-blog
76
- 2. Pass directly: createMarvinClient({ workspaceSlug: 'my-blog' })
77
-
78
- Received config keys: ${receivedKeys}`
79
- );
80
- }
81
- if (config.apiUrl) {
82
- try {
83
- new URL(config.apiUrl);
84
- } catch {
85
- throw new Error(
86
- `Invalid 'apiUrl' format: "${config.apiUrl}"
87
-
88
- The API URL must be a valid HTTP or HTTPS URL.
89
-
90
- Valid examples:
91
- \u2713 https://marvin.example.com
92
- \u2713 http://localhost:8080
93
- \u2713 https://api.marvin.io
94
-
95
- Invalid examples:
96
- \u2717 marvin.example.com (missing protocol)
97
- \u2717 ftp://marvin.example.com (wrong protocol)
98
- \u2717 /api (not a full URL)`
99
- );
100
- }
101
- const url = new URL(config.apiUrl);
102
- if (!["http:", "https:"].includes(url.protocol)) {
103
- throw new Error(
104
- `Invalid 'apiUrl' protocol: "${url.protocol}"
105
-
106
- Only HTTP and HTTPS protocols are supported.
107
-
108
- Your URL: ${config.apiUrl}
109
- Change to: ${config.apiUrl.replace(url.protocol, "https:")}`
110
- );
111
- }
112
- }
113
- }
114
- function createConfigFromEnv(overrides) {
115
- return {
116
- apiUrl: overrides?.apiUrl || process.env.MARVIN_API_URL || "",
117
- siteClientToken: overrides?.siteClientToken || process.env.MARVIN_SITE_CLIENT_TOKEN || "",
118
- workspaceSlug: overrides?.workspaceSlug || process.env.MARVIN_WORKSPACE_SLUG || "",
119
- autoInitialize: overrides?.autoInitialize ?? false,
120
- cacheDuration: overrides?.cacheDuration ?? 5 * 60 * 1e3,
121
- // 5 minutes
122
- debug: overrides?.debug ?? process.env.MARVIN_DEBUG === "true",
123
- logger: overrides?.logger ?? console
124
- };
125
- }
126
- var init_config = __esm({
127
- "src/client/config.ts"() {
128
- "use strict";
129
- }
130
- });
131
-
132
- // src/entries/entry.ts
133
- var Entry;
134
- var init_entry = __esm({
135
- "src/entries/entry.ts"() {
136
- "use strict";
137
- Entry = class {
138
- constructor(data, http, workspaceSlug) {
139
- this.data = data;
140
- this.http = http;
141
- this.workspaceSlug = workspaceSlug;
142
- }
143
- data;
144
- http;
145
- workspaceSlug;
146
- // Expose all entry data as properties
147
- get id() {
148
- return this.data.id;
149
- }
150
- get title() {
151
- return this.data.title;
152
- }
153
- get slug() {
154
- return this.data.slug;
155
- }
156
- get summary() {
157
- return this.data.summary;
158
- }
159
- get description() {
160
- return this.data.description;
161
- }
162
- /**
163
- * @deprecated Use field('body') or dataJson instead. Will be removed in v3.0.0
164
- */
165
- get contentMarkdown() {
166
- return this.data.contentMarkdown;
167
- }
168
- /**
169
- * Schema-driven content data (replaces contentMarkdown in v2.0.0).
170
- * Access specific fields using the field() helper method.
171
- * @since 2.0.0
172
- */
173
- get dataJson() {
174
- return this.data.dataJson;
175
- }
176
- get metadata() {
177
- return this.data.metadata;
178
- }
179
- get status() {
180
- return this.data.status;
181
- }
182
- get publishedAt() {
183
- return this.data.publishedAt;
184
- }
185
- get createdAt() {
186
- return this.data.createdAt;
187
- }
188
- get updatedAt() {
189
- return this.data.updatedAt;
190
- }
191
- get entryTypeId() {
192
- return this.data.entryTypeId;
193
- }
194
- get entryType() {
195
- return this.data.entryType;
196
- }
197
- /**
198
- * Get entry assets
199
- */
200
- get assets() {
201
- return this.data.assets || [];
202
- }
203
- /**
204
- * Get entry collections
205
- */
206
- get collections() {
207
- return this.data.collections || [];
208
- }
209
- /**
210
- * Get a specific field value from the entry's schema-driven content (dataJson).
211
- *
212
- * @param key - Field key as defined in the entry type's schema
213
- * @returns The field value, or undefined if not present
214
- * @since 2.0.0
215
- *
216
- * @example
217
- * ```typescript
218
- * const entry = await client.entries.get('my-entry');
219
- * const body = entry.field('body'); // Get markdown body
220
- * const difficulty = entry.field('difficulty'); // Get difficulty level
221
- * const heroImage = entry.field('heroImage'); // Get hero image UUID
222
- * ```
223
- */
224
- field(key) {
225
- return this.data.dataJson?.[key];
226
- }
227
- /**
228
- * Get all fields from the entry's schema-driven content.
229
- * @since 2.0.0
230
- */
231
- get fields() {
232
- return this.data.dataJson || {};
233
- }
234
- /**
235
- * Get related entries (future)
236
- */
237
- async relatedEntries() {
238
- throw new Error("Related entries not yet implemented");
239
- }
240
- /**
241
- * Get raw entry data
242
- */
243
- toJSON() {
244
- return this.data;
245
- }
246
- };
247
- }
248
- });
249
-
250
- // src/collections/collection.ts
251
- var Collection;
252
- var init_collection = __esm({
253
- "src/collections/collection.ts"() {
254
- "use strict";
255
- Collection = class {
256
- constructor(data, http, workspaceSlug) {
257
- this.data = data;
258
- this.http = http;
259
- this.workspaceSlug = workspaceSlug;
260
- }
261
- data;
262
- http;
263
- workspaceSlug;
264
- // Expose all collection data as properties
265
- get id() {
266
- return this.data.id;
267
- }
268
- get name() {
269
- return this.data.name;
270
- }
271
- get slug() {
272
- return this.data.slug;
273
- }
274
- get description() {
275
- return this.data.description;
276
- }
277
- get icon() {
278
- return this.data.icon;
279
- }
280
- get color() {
281
- return this.data.color;
282
- }
283
- get sortOrder() {
284
- return this.data.sortOrder;
285
- }
286
- get isSmart() {
287
- return this.data.isSmart;
288
- }
289
- get smartRules() {
290
- return this.data.smartRules;
291
- }
292
- get createdAt() {
293
- return this.data.createdAt;
294
- }
295
- get updatedAt() {
296
- return this.data.updatedAt;
297
- }
298
- /**
299
- * Get all entries in this collection
300
- */
301
- async entries() {
302
- return this.data.entries || [];
303
- }
304
- /**
305
- * Get assets in this collection (future)
306
- */
307
- async assets() {
308
- throw new Error("Collection assets not yet implemented");
309
- }
310
- /**
311
- * Get collection metadata (future)
312
- */
313
- async metadata() {
314
- throw new Error("Collection metadata not yet implemented");
315
- }
316
- /**
317
- * Get raw collection data
318
- */
319
- toJSON() {
320
- return this.data;
321
- }
322
- };
323
- }
324
- });
325
-
326
- // src/resources/resource.ts
327
- var Resource;
328
- var init_resource = __esm({
329
- "src/resources/resource.ts"() {
330
- "use strict";
331
- Resource = class {
332
- constructor(data, http, workspaceSlug) {
333
- this.data = data;
334
- this.http = http;
335
- this.workspaceSlug = workspaceSlug;
336
- }
337
- data;
338
- http;
339
- workspaceSlug;
340
- // Expose all resource data as properties
341
- get id() {
342
- return this.data.id;
343
- }
344
- get name() {
345
- return this.data.name;
346
- }
347
- get slug() {
348
- return this.data.slug;
349
- }
350
- get resourceType() {
351
- return this.data.resourceType;
352
- }
353
- get description() {
354
- return this.data.description;
355
- }
356
- get externalId() {
357
- return this.data.externalId;
358
- }
359
- get url() {
360
- return this.data.url;
361
- }
362
- get metadata() {
363
- return this.data.metadata;
364
- }
365
- get createdAt() {
366
- return this.data.createdAt;
367
- }
368
- get updatedAt() {
369
- return this.data.updatedAt;
370
- }
371
- /**
372
- * Get all entries that reference this resource
373
- */
374
- async entries() {
375
- const endpoint = `/api/publish/${this.workspaceSlug}/resources/${this.data.slug}/entries`;
376
- return this.http.fetch(endpoint);
377
- }
378
- /**
379
- * Get assets related to this resource (future)
380
- */
381
- async assets() {
382
- throw new Error("Resource assets not yet implemented");
383
- }
384
- /**
385
- * Get raw resource data
386
- */
387
- toJSON() {
388
- return this.data;
389
- }
390
- };
391
- }
392
- });
393
-
394
- // src/entries/entries.ts
395
- var EntriesModule;
396
- var init_entries = __esm({
397
- "src/entries/entries.ts"() {
398
- "use strict";
399
- init_entry();
400
- init_errors();
401
- EntriesModule = class {
402
- constructor(http, workspaceSlug) {
403
- this.http = http;
404
- this.workspaceSlug = workspaceSlug;
405
- }
406
- http;
407
- workspaceSlug;
408
- /**
409
- * Get all published entries
410
- */
411
- async list(options = {}) {
412
- const queryString = this.http.buildQueryString({
413
- entry_type: options.entryType,
414
- collection: options.collection,
415
- limit: options.limit,
416
- offset: options.offset
417
- // Don't send status - backend always returns published
418
- });
419
- const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
420
- const response = await this.http.fetch(endpoint);
421
- return response.data || [];
422
- }
423
- /**
424
- * Get a single entry by slug
425
- * Returns null if entry is not found (404)
426
- */
427
- async get(slug) {
428
- try {
429
- const endpoint = `/api/publish/${this.workspaceSlug}/entries/${slug}`;
430
- const data = await this.http.fetch(endpoint);
431
- return new Entry(data, this.http, this.workspaceSlug);
432
- } catch (error) {
433
- if (error instanceof MarvinNotFoundError) {
434
- return null;
435
- }
436
- throw error;
437
- }
438
- }
439
- /**
440
- * Convenience: Get all pages
441
- */
442
- async pages(options) {
443
- return this.list({ ...options, entryType: "page" });
444
- }
445
- /**
446
- * Convenience: Get all blog posts
447
- */
448
- async posts(options) {
449
- return this.list({ ...options, entryType: "blog" });
450
- }
451
- /**
452
- * Convenience: Get all projects
453
- */
454
- async projects(options) {
455
- return this.list({ ...options, entryType: "project" });
456
- }
457
- };
458
- }
459
- });
460
-
461
- // src/collections/collections.ts
462
- var CollectionsModule;
463
- var init_collections = __esm({
464
- "src/collections/collections.ts"() {
465
- "use strict";
466
- init_collection();
467
- init_errors();
468
- CollectionsModule = class {
469
- constructor(http, workspaceSlug) {
470
- this.http = http;
471
- this.workspaceSlug = workspaceSlug;
472
- }
473
- http;
474
- workspaceSlug;
475
- /**
476
- * Get all collections
477
- */
478
- async list() {
479
- const endpoint = `/api/publish/${this.workspaceSlug}/collections`;
480
- const response = await this.http.fetch(endpoint);
481
- return response.data || [];
482
- }
483
- /**
484
- * Get a single collection by slug
485
- * Returns null if collection is not found (404)
486
- */
487
- async get(slug) {
488
- try {
489
- const endpoint = `/api/publish/${this.workspaceSlug}/collections/${slug}`;
490
- const data = await this.http.fetch(endpoint);
491
- return new Collection(data, this.http, this.workspaceSlug);
492
- } catch (error) {
493
- if (error instanceof MarvinNotFoundError) {
494
- return null;
495
- }
496
- throw error;
497
- }
498
- }
499
- /**
500
- * Get entries in a collection
501
- * Returns empty array if collection is not found
502
- */
503
- async entries(slug) {
504
- const collection = await this.get(slug);
505
- if (!collection) {
506
- return [];
507
- }
508
- return collection.entries();
509
- }
510
- /**
511
- * Try multiple collection slugs in fallback order
512
- * Returns the first collection that exists and has entries
513
- *
514
- * @param slugs - Collection slugs to try in order
515
- * @param options - Options for fallback behavior
516
- * @returns Entries from the first matching collection, or empty array
517
- *
518
- * @example
519
- * ```ts
520
- * // Try bench-notes, then journal, then blog
521
- * const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
522
- * ```
523
- */
524
- async fallback(slugs, options = {}) {
525
- const { requireEntries = true } = options;
526
- for (const slug of slugs) {
527
- try {
528
- const collection = await this.get(slug);
529
- if (!collection) {
530
- continue;
531
- }
532
- const entries = await collection.entries();
533
- if (!requireEntries || entries.length > 0) {
534
- return entries;
535
- }
536
- } catch (error) {
537
- continue;
538
- }
539
- }
540
- return [];
541
- }
542
- };
543
- }
544
- });
545
-
546
- // src/assets/assets.ts
547
- var AssetsModule;
548
- var init_assets = __esm({
549
- "src/assets/assets.ts"() {
550
- "use strict";
551
- AssetsModule = class {
552
- constructor(http, workspaceSlug) {
553
- this.http = http;
554
- this.workspaceSlug = workspaceSlug;
555
- }
556
- http;
557
- workspaceSlug;
558
- /**
559
- * Get all published assets
560
- */
561
- async list(options = {}) {
562
- const queryString = this.http.buildQueryString({
563
- type: options.type,
564
- limit: options.limit,
565
- offset: options.offset
566
- });
567
- const endpoint = `/api/publish/${this.workspaceSlug}/assets${queryString}`;
568
- const response = await this.http.fetch(endpoint);
569
- return response.data || [];
570
- }
571
- /**
572
- * Get a single published asset by slug or ID
573
- */
574
- async get(slugOrId) {
575
- const endpoint = `/api/publish/${this.workspaceSlug}/assets/${slugOrId}`;
576
- return this.http.fetch(endpoint);
577
- }
578
- /**
579
- * Convenience: Get all images
580
- */
581
- async images(options) {
582
- return this.list({ ...options, type: "image" });
583
- }
584
- /**
585
- * Convenience: Get all videos
586
- */
587
- async videos(options) {
588
- return this.list({ ...options, type: "video" });
589
- }
590
- /**
591
- * Convenience: Get all documents
592
- */
593
- async documents(options) {
594
- return this.list({ ...options, type: "document" });
595
- }
596
- };
597
- }
598
- });
599
-
600
- // src/resources/resources.ts
601
- var ResourcesModule;
602
- var init_resources = __esm({
603
- "src/resources/resources.ts"() {
604
- "use strict";
605
- init_resource();
606
- ResourcesModule = class {
607
- constructor(http, workspaceSlug) {
608
- this.http = http;
609
- this.workspaceSlug = workspaceSlug;
610
- }
611
- http;
612
- workspaceSlug;
613
- /**
614
- * Get all published resources
615
- */
616
- async list(options = {}) {
617
- const queryString = this.http.buildQueryString({
618
- resource_type: options.resourceType,
619
- limit: options.limit,
620
- offset: options.offset
621
- });
622
- const endpoint = `/api/publish/${this.workspaceSlug}/resources${queryString}`;
623
- const response = await this.http.fetch(endpoint);
624
- return response.data || [];
625
- }
626
- /**
627
- * Get a single resource by slug
628
- */
629
- async get(slug) {
630
- const endpoint = `/api/publish/${this.workspaceSlug}/resources/${slug}`;
631
- const data = await this.http.fetch(endpoint);
632
- return new Resource(data, this.http, this.workspaceSlug);
633
- }
634
- /**
635
- * Get entries that reference this resource
636
- */
637
- async entries(slug) {
638
- const resource = await this.get(slug);
639
- return resource.entries();
640
- }
641
- };
642
- }
643
- });
644
-
645
- // src/workspaces/workspace.ts
646
- var Workspace;
647
- var init_workspace = __esm({
648
- "src/workspaces/workspace.ts"() {
649
- "use strict";
650
- init_entries();
651
- init_collections();
652
- init_assets();
653
- init_resources();
654
- Workspace = class {
655
- constructor(http, slug) {
656
- this.http = http;
657
- this._slug = slug;
658
- this.entries = new EntriesModule(http, slug);
659
- this.collections = new CollectionsModule(http, slug);
660
- this.assets = new AssetsModule(http, slug);
661
- this.resources = new ResourcesModule(http, slug);
662
- }
663
- http;
664
- _site = null;
665
- _slug;
666
- entries;
667
- collections;
668
- assets;
669
- resources;
670
- /**
671
- * Get workspace slug
672
- */
673
- get slug() {
674
- return this._slug;
675
- }
676
- /**
677
- * Get site configuration (cached after first load)
678
- */
679
- get site() {
680
- return this._site;
681
- }
682
- /**
683
- * Load site configuration
684
- */
685
- async loadSite() {
686
- const endpoint = `/api/publish/${this._slug}/site`;
687
- this._site = await this.http.fetch(endpoint);
688
- return this._site;
689
- }
690
- /**
691
- * Get workspace info (name and slug only)
692
- */
693
- async getInfo() {
694
- const endpoint = `/api/publish/${this._slug}`;
695
- return this.http.fetch(endpoint);
696
- }
697
- /**
698
- * Get workspace settings (future)
699
- */
700
- async settings() {
701
- throw new Error("Workspace settings not yet implemented");
702
- }
703
- };
704
- }
705
- });
706
-
707
- // src/client/http.ts
708
- var MarvinHttpClient;
709
- var init_http = __esm({
710
- "src/client/http.ts"() {
711
- "use strict";
712
- init_core();
713
- MarvinHttpClient = class extends HttpClient {
714
- constructor(config) {
715
- super({
716
- baseUrl: config.apiUrl,
717
- auth: new BearerTokenAuth(config.siteClientToken),
718
- credentials: "same-origin",
719
- debug: config.debug,
720
- logger: config.logger
721
- });
722
- }
723
- /**
724
- * Fetch endpoint (backward compatibility)
725
- */
726
- async fetch(endpoint) {
727
- return this.get(endpoint);
728
- }
729
- };
730
- }
731
- });
732
-
733
- // src/client/marvin.ts
734
- var marvin_exports = {};
735
- __export(marvin_exports, {
736
- MarvinClient: () => MarvinClient
737
- });
738
- var MarvinClient;
739
- var init_marvin = __esm({
740
- "src/client/marvin.ts"() {
741
- "use strict";
742
- init_config();
743
- init_http();
744
- init_core();
745
- init_workspace();
746
- MarvinClient = class {
747
- constructor(config) {
748
- this.config = config;
749
- validateConfig(config);
750
- this.http = new MarvinHttpClient(config);
751
- this.cache = new MarvinCache(config.cacheDuration);
752
- this.workspace = new Workspace(this.http, config.workspaceSlug);
753
- if (config.autoInitialize) {
754
- this.initialize();
755
- }
756
- }
757
- config;
758
- http;
759
- cache;
760
- workspace;
761
- initialized = false;
762
- /**
763
- * Initialize the SDK
764
- * Preloads site configuration and metadata
765
- */
766
- async initialize() {
767
- if (this.initialized) return;
768
- try {
769
- await this.workspace.loadSite();
770
- this.initialized = true;
771
- } catch (error) {
772
- console.warn("Marvin SDK initialization warning:", error);
773
- }
774
- }
775
- // ======================
776
- // Workspace-First API
777
- // ======================
778
- /**
779
- * Get the workspace object
780
- */
781
- async getWorkspace() {
782
- if (!this.initialized) {
783
- await this.initialize();
784
- }
785
- return this.workspace;
786
- }
787
- /**
788
- * Get site configuration (cached)
789
- */
790
- get site() {
791
- return this.workspace.site;
792
- }
793
- /**
794
- * Get workspace info (name and slug)
795
- */
796
- async getWorkspaceInfo() {
797
- return this.workspace.getInfo();
798
- }
799
- /**
800
- * Get entries module
801
- */
802
- get entries() {
803
- return this.workspace.entries;
804
- }
805
- /**
806
- * Get collections module
807
- */
808
- get collections() {
809
- return this.workspace.collections;
810
- }
811
- /**
812
- * Get assets module
813
- */
814
- get assets() {
815
- return this.workspace.assets;
816
- }
817
- /**
818
- * Get resources module
819
- */
820
- get resources() {
821
- return this.workspace.resources;
822
- }
823
- // ======================
824
- // Convenience Methods
825
- // ======================
826
- /**
827
- * Get a single entry by slug
828
- */
829
- async entry(slug) {
830
- return this.workspace.entries.get(slug);
831
- }
832
- /**
833
- * Get a single collection by slug
834
- */
835
- async collection(slug) {
836
- return this.workspace.collections.get(slug);
837
- }
838
- /**
839
- * Get all pages
840
- */
841
- async pages(options) {
842
- return this.workspace.entries.pages(options);
843
- }
844
- /**
845
- * Get all blog posts
846
- */
847
- async posts(options) {
848
- return this.workspace.entries.posts(options);
849
- }
850
- /**
851
- * Get all projects
852
- */
853
- async projects(options) {
854
- return this.workspace.entries.projects(options);
855
- }
856
- /**
857
- * Get a single resource by slug
858
- */
859
- async resource(slug) {
860
- return this.workspace.resources.get(slug);
861
- }
862
- /**
863
- * Try multiple collection slugs in fallback order
864
- * Returns entries from the first collection that exists and has content
865
- *
866
- * @param slugs - Collection slugs to try in order
867
- * @param options - Options for fallback behavior
868
- * @returns Entries from the first matching collection, or empty array
869
- *
870
- * @example
871
- * ```ts
872
- * // Try bench-notes, then journal, then blog
873
- * const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
874
- * ```
875
- */
876
- async collectionFallback(slugs, options) {
877
- return this.workspace.collections.fallback(slugs, options);
878
- }
879
- // ======================
880
- // Backwards-Compatible Publishing API
881
- // ======================
882
- /**
883
- * @deprecated Use workspace.site or marvin.site instead
884
- * Get site configuration
885
- */
886
- async getSite() {
887
- return this.workspace.loadSite();
888
- }
889
- /**
890
- * @deprecated Use workspace.entries.list() instead
891
- * Get all published entries
892
- */
893
- async getEntries(options) {
894
- return this.workspace.entries.list(options);
895
- }
896
- /**
897
- * @deprecated Use workspace.entries.get() instead
898
- * Get a single published entry by slug
899
- */
900
- async getEntry(slug) {
901
- const entry = await this.workspace.entries.get(slug);
902
- if (!entry) {
903
- return null;
904
- }
905
- return entry.toJSON();
906
- }
907
- /**
908
- * @deprecated Use workspace.collections.list() instead
909
- * Get all collections
910
- */
911
- async getCollections() {
912
- return this.workspace.collections.list();
913
- }
914
- /**
915
- * @deprecated Use workspace.collections.get() instead
916
- * Get a single collection by slug
917
- */
918
- async getCollection(slug) {
919
- const collection = await this.workspace.collections.get(slug);
920
- if (!collection) {
921
- return null;
922
- }
923
- return collection.toJSON();
924
- }
925
- /**
926
- * @deprecated Use workspace.collections.entries() instead
927
- * Get all entries in a collection
928
- */
929
- async getCollectionEntries(slug) {
930
- return this.workspace.collections.entries(slug);
931
- }
932
- /**
933
- * @deprecated Use workspace.assets.list() instead
934
- * Get all published assets
935
- */
936
- async getAssets(options) {
937
- return this.workspace.assets.list(options);
938
- }
939
- /**
940
- * @deprecated Use workspace.resources.list() instead
941
- * Get all published resources
942
- */
943
- async getResources(options) {
944
- return this.workspace.resources.list(options);
945
- }
946
- /**
947
- * @deprecated Use workspace.resources.get() instead
948
- * Get a single resource by slug
949
- */
950
- async getResource(slug) {
951
- const resource = await this.workspace.resources.get(slug);
952
- return resource.toJSON();
953
- }
954
- /**
955
- * @deprecated Use workspace.resources.entries() instead
956
- * Get entries that reference a resource
957
- */
958
- async getResourceEntries(slug) {
959
- return this.workspace.resources.entries(slug);
960
- }
961
- };
962
- }
963
- });
964
-
965
- export {
966
- createConfigFromEnv,
967
- config_exports,
968
- init_config,
969
- Entry,
970
- init_entry,
971
- Collection,
972
- init_collection,
973
- Resource,
974
- init_resource,
975
- Workspace,
976
- init_workspace,
977
- MarvinClient,
978
- marvin_exports,
979
- init_marvin
980
- };