@inneropen/marvin-sdk 2.0.0-next.13 → 2.0.0-next.15

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/index.d.ts CHANGED
@@ -1,608 +1,9 @@
1
- import { MarvinResource, MarvinEntry, MarvinAsset, MarvinCollection, MarvinEntryType, MarvinSite, GetResourcesOptions as GetResourcesOptions$1 } from './types/index.js';
2
- export { GetAssetsOptions, GetEntriesOptions, MarvinPublishResponse } from './types/index.js';
3
- import { H as HttpClient } from './HttpClient-BX5Gqd0w.js';
4
- export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-BX5Gqd0w.js';
5
-
6
- /**
7
- * Marvin SDK Configuration
8
- */
9
- interface MarvinConfig {
10
- apiUrl: string;
11
- siteClientToken: string;
12
- workspaceSlug: string;
13
- /** Enable automatic initialization on client creation */
14
- autoInitialize?: boolean;
15
- /** Cache duration in milliseconds (default: 5 minutes) */
16
- cacheDuration?: number;
17
- /** Enable debug logging for HTTP requests and responses */
18
- debug?: boolean;
19
- /** Custom logger function (defaults to console) */
20
- logger?: {
21
- log: (message: string, ...args: unknown[]) => void;
22
- warn: (message: string, ...args: unknown[]) => void;
23
- error: (message: string, ...args: unknown[]) => void;
24
- };
25
- }
26
- declare function createConfigFromEnv(overrides?: Partial<MarvinConfig>): MarvinConfig;
27
-
28
- /**
29
- * Base error class for all Marvin SDK errors
30
- */
31
- declare class MarvinError extends Error {
32
- readonly code?: string | undefined;
33
- readonly statusCode?: number | undefined;
34
- constructor(message: string, code?: string | undefined, statusCode?: number | undefined);
35
- }
36
- /**
37
- * HTTP/API request errors
38
- */
39
- declare class MarvinApiError extends MarvinError {
40
- readonly statusCode: number;
41
- readonly endpoint: string;
42
- readonly responseBody?: string | undefined;
43
- constructor(message: string, statusCode: number, endpoint: string, responseBody?: string | undefined);
44
- static fromResponse(status: number, statusText: string, endpoint: string, body?: string): MarvinApiError;
45
- }
46
- /**
47
- * Authentication/authorization errors
48
- */
49
- declare class MarvinAuthError extends MarvinError {
50
- constructor(message: string, statusCode?: number);
51
- }
52
- /**
53
- * Configuration errors
54
- */
55
- declare class MarvinConfigError extends MarvinError {
56
- constructor(message: string);
57
- }
58
- /**
59
- * Validation errors
60
- */
61
- declare class MarvinValidationError extends MarvinError {
62
- readonly field?: string | undefined;
63
- constructor(message: string, field?: string | undefined);
64
- }
65
- /**
66
- * Resource not found errors (404)
67
- */
68
- declare class MarvinNotFoundError extends MarvinError {
69
- readonly endpoint: string;
70
- constructor(message: string, endpoint: string);
71
- }
72
- /**
73
- * Network/connectivity errors
74
- */
75
- declare class MarvinNetworkError extends MarvinError {
76
- readonly originalError?: Error | undefined;
77
- constructor(message: string, originalError?: Error | undefined);
78
- }
79
- /**
80
- * Server errors (5xx)
81
- */
82
- declare class MarvinServerError extends MarvinError {
83
- readonly endpoint: string;
84
- constructor(message: string, statusCode: number, endpoint: string);
85
- }
86
-
87
- /**
88
- * Pagination response types and helpers
89
- */
90
- interface PaginationMeta {
91
- total?: number;
92
- page?: number;
93
- limit?: number;
94
- offset?: number;
95
- hasMore?: boolean;
96
- }
97
- interface PaginatedResponse<T> {
98
- data: T[];
99
- meta?: PaginationMeta;
100
- }
101
- interface PaginationParams {
102
- limit?: number;
103
- offset?: number;
104
- page?: number;
105
- }
106
- /**
107
- * Create a paginated response
108
- */
109
- declare function createPaginatedResponse<T>(data: T[], meta?: PaginationMeta): PaginatedResponse<T>;
110
- /**
111
- * Extract data from paginated response
112
- */
113
- declare function extractData<T>(response: PaginatedResponse<T> | T[]): T[];
114
- /**
115
- * Check if response is paginated
116
- */
117
- declare function isPaginatedResponse<T>(response: PaginatedResponse<T> | T[]): response is PaginatedResponse<T>;
118
- /**
119
- * Calculate pagination offset from page number
120
- */
121
- declare function pageToOffset(page: number, limit: number): number;
122
- /**
123
- * Calculate page number from offset
124
- */
125
- declare function offsetToPage(offset: number, limit: number): number;
126
-
127
- /**
128
- * Simple in-memory cache for SDK data
129
- */
130
- declare class MarvinCache {
131
- private duration;
132
- private cache;
133
- constructor(duration?: number);
134
- get<T>(key: string): T | undefined;
135
- set<T>(key: string, data: T): void;
136
- has(key: string): boolean;
137
- clear(): void;
138
- delete(key: string): void;
139
- }
140
-
141
- /**
142
- * HTTP Client for Marvin Publishing API
143
- *
144
- * Wrapper around core HttpClient for Publishing API specifics
145
- */
146
-
147
- declare class MarvinHttpClient extends HttpClient {
148
- constructor(config: MarvinConfig);
149
- /**
150
- * Fetch endpoint (backward compatibility)
151
- */
152
- fetch<T>(endpoint: string): Promise<T>;
153
- }
154
-
155
- /**
156
- * Resource - Rich object representing a single resource
157
- */
158
-
159
- declare class Resource {
160
- private data;
161
- private http;
162
- private workspaceSlug;
163
- constructor(data: MarvinResource, http: MarvinHttpClient, workspaceSlug: string);
164
- get id(): string;
165
- get name(): string;
166
- get slug(): string;
167
- get resourceType(): string | undefined;
168
- get description(): string | undefined;
169
- get externalId(): string | undefined;
170
- get url(): string | undefined;
171
- get metadata(): Record<string, unknown> | undefined;
172
- get createdAt(): string;
173
- get updatedAt(): string;
174
- /**
175
- * Get all entries that reference this resource
176
- */
177
- entries(): Promise<MarvinEntry[]>;
178
- /**
179
- * Get assets related to this resource (future)
180
- */
181
- assets(): Promise<MarvinAsset[]>;
182
- /**
183
- * Get raw resource data
184
- */
185
- toJSON(): MarvinResource;
186
- }
187
-
188
- /**
189
- * Resources Module - Manage resources
190
- */
191
-
192
- interface GetResourcesOptions {
193
- resourceType?: string;
194
- limit?: number;
195
- offset?: number;
196
- }
197
- declare class ResourcesModule {
198
- private http;
199
- private workspaceSlug;
200
- constructor(http: MarvinHttpClient, workspaceSlug: string);
201
- /**
202
- * Get all published resources
203
- */
204
- list(options?: GetResourcesOptions): Promise<MarvinResource[]>;
205
- /**
206
- * Get a single resource by slug
207
- */
208
- get(slug: string): Promise<Resource>;
209
- /**
210
- * Get entries that reference this resource
211
- */
212
- entries(slug: string): Promise<MarvinEntry[]>;
213
- }
214
-
215
- /**
216
- * Assets Module - Manage assets
217
- */
218
-
219
- interface GetAssetsOptions {
220
- type?: string;
221
- limit?: number;
222
- offset?: number;
223
- }
224
- declare class AssetsModule {
225
- private http;
226
- private workspaceSlug;
227
- constructor(http: MarvinHttpClient, workspaceSlug: string);
228
- /**
229
- * Get all published assets
230
- */
231
- list(options?: GetAssetsOptions): Promise<MarvinAsset[]>;
232
- /**
233
- * Get a single published asset by slug or ID
234
- */
235
- get(slugOrId: string): Promise<MarvinAsset>;
236
- /**
237
- * Convenience: Get all images
238
- */
239
- images(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
240
- /**
241
- * Convenience: Get all videos
242
- */
243
- videos(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
244
- /**
245
- * Convenience: Get all documents
246
- */
247
- documents(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
248
- }
249
-
250
- /**
251
- * Collection - Rich object representing a single collection
252
- */
253
-
254
- declare class Collection {
255
- private data;
256
- private http;
257
- private workspaceSlug;
258
- constructor(data: MarvinCollection, http: MarvinHttpClient, workspaceSlug: string);
259
- get id(): string;
260
- get name(): string;
261
- get slug(): string;
262
- get description(): string | undefined;
263
- get icon(): string | undefined;
264
- get color(): string | undefined;
265
- get sortOrder(): number;
266
- get isSmart(): boolean;
267
- get smartRules(): Record<string, unknown> | undefined;
268
- get createdAt(): string;
269
- get updatedAt(): string;
270
- /**
271
- * Get all entries in this collection
272
- */
273
- entries(): Promise<MarvinEntry[]>;
274
- /**
275
- * Get assets in this collection (future)
276
- */
277
- assets(): Promise<MarvinAsset[]>;
278
- /**
279
- * Get collection metadata (future)
280
- */
281
- metadata(): Promise<any>;
282
- /**
283
- * Get raw collection data
284
- */
285
- toJSON(): MarvinCollection;
286
- }
287
-
288
- /**
289
- * Collections Module - Manage collections
290
- */
291
-
292
- declare class CollectionsModule {
293
- private http;
294
- private workspaceSlug;
295
- constructor(http: MarvinHttpClient, workspaceSlug: string);
296
- /**
297
- * Get all collections
298
- */
299
- list(): Promise<MarvinCollection[]>;
300
- /**
301
- * Get a single collection by slug
302
- * Returns null if collection is not found (404)
303
- */
304
- get(slug: string): Promise<Collection | null>;
305
- /**
306
- * Get entries in a collection
307
- * Returns empty array if collection is not found
308
- */
309
- entries(slug: string): Promise<MarvinEntry[]>;
310
- /**
311
- * Try multiple collection slugs in fallback order
312
- * Returns the first collection that exists and has entries
313
- *
314
- * @param slugs - Collection slugs to try in order
315
- * @param options - Options for fallback behavior
316
- * @returns Entries from the first matching collection, or empty array
317
- *
318
- * @example
319
- * ```ts
320
- * // Try bench-notes, then journal, then blog
321
- * const entries = await collections.fallback(['bench-notes', 'journal', 'blog']);
322
- * ```
323
- */
324
- fallback(slugs: string[], options?: {
325
- requireEntries?: boolean;
326
- }): Promise<MarvinEntry[]>;
327
- }
328
-
329
- declare class Entry {
330
- private data;
331
- private http;
332
- private workspaceSlug;
333
- constructor(data: MarvinEntry, http: MarvinHttpClient, workspaceSlug: string);
334
- get id(): string;
335
- get title(): string;
336
- get slug(): string;
337
- get summary(): string | undefined;
338
- get description(): string | undefined;
339
- /**
340
- * @deprecated Use field('body') or dataJson instead. Will be removed in v3.0.0
341
- */
342
- get contentMarkdown(): string | undefined;
343
- /**
344
- * Schema-driven content data (replaces contentMarkdown in v2.0.0).
345
- * Access specific fields using the field() helper method.
346
- * @since 2.0.0
347
- */
348
- get dataJson(): Record<string, unknown> | undefined;
349
- get metadata(): Record<string, unknown> | undefined;
350
- get status(): string;
351
- get publishedAt(): string | undefined;
352
- get createdAt(): string;
353
- get updatedAt(): string;
354
- get entryTypeId(): string;
355
- get entryType(): MarvinEntryType | undefined;
356
- /**
357
- * Get entry assets
358
- */
359
- get assets(): MarvinAsset[];
360
- /**
361
- * Get entry collections
362
- */
363
- get collections(): MarvinCollection[];
364
- /**
365
- * Get a specific field value from the entry's schema-driven content (dataJson).
366
- *
367
- * @param key - Field key as defined in the entry type's schema
368
- * @returns The field value, or undefined if not present
369
- * @since 2.0.0
370
- *
371
- * @example
372
- * ```typescript
373
- * const entry = await client.entries.get('my-entry');
374
- * const body = entry.field('body'); // Get markdown body
375
- * const difficulty = entry.field('difficulty'); // Get difficulty level
376
- * const heroImage = entry.field('heroImage'); // Get hero image UUID
377
- * ```
378
- */
379
- field<T = unknown>(key: string): T | undefined;
380
- /**
381
- * Get all fields from the entry's schema-driven content.
382
- * @since 2.0.0
383
- */
384
- get fields(): Record<string, unknown>;
385
- /**
386
- * Get related entries (future)
387
- */
388
- relatedEntries(): Promise<MarvinEntry[]>;
389
- /**
390
- * Get raw entry data
391
- */
392
- toJSON(): MarvinEntry;
393
- }
394
-
395
- /**
396
- * Entries Module - Manage entries
397
- */
398
-
399
- interface GetEntriesOptions {
400
- entryType?: string;
401
- collection?: string;
402
- limit?: number;
403
- offset?: number;
404
- status?: string;
405
- }
406
- declare class EntriesModule {
407
- private http;
408
- private workspaceSlug;
409
- constructor(http: MarvinHttpClient, workspaceSlug: string);
410
- /**
411
- * Get all published entries
412
- */
413
- list(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
414
- /**
415
- * Get a single entry by slug
416
- * Returns null if entry is not found (404)
417
- */
418
- get(slug: string): Promise<Entry | null>;
419
- /**
420
- * Convenience: Get all pages
421
- */
422
- pages(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
423
- /**
424
- * Convenience: Get all blog posts
425
- */
426
- posts(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
427
- /**
428
- * Convenience: Get all projects
429
- */
430
- projects(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
431
- }
432
-
433
- /**
434
- * Workspace - First-class object representing a Marvin workspace
435
- */
436
-
437
- declare class Workspace {
438
- private http;
439
- private _site;
440
- private _slug;
441
- entries: EntriesModule;
442
- collections: CollectionsModule;
443
- assets: AssetsModule;
444
- resources: ResourcesModule;
445
- constructor(http: MarvinHttpClient, slug: string);
446
- /**
447
- * Get workspace slug
448
- */
449
- get slug(): string;
450
- /**
451
- * Get site configuration (cached after first load)
452
- */
453
- get site(): MarvinSite | null;
454
- /**
455
- * Load site configuration
456
- */
457
- loadSite(): Promise<MarvinSite>;
458
- /**
459
- * Get workspace info (name and slug only)
460
- */
461
- getInfo(): Promise<{
462
- slug: string;
463
- name: string;
464
- }>;
465
- /**
466
- * Get workspace settings (future)
467
- */
468
- settings(): Promise<any>;
469
- }
470
-
471
- declare class MarvinClient {
472
- private config;
473
- private http;
474
- private cache;
475
- private workspace;
476
- private initialized;
477
- constructor(config: MarvinConfig);
478
- /**
479
- * Initialize the SDK
480
- * Preloads site configuration and metadata
481
- */
482
- initialize(): Promise<void>;
483
- /**
484
- * Get the workspace object
485
- */
486
- getWorkspace(): Promise<Workspace>;
487
- /**
488
- * Get site configuration (cached)
489
- */
490
- get site(): MarvinSite | null;
491
- /**
492
- * Get workspace info (name and slug)
493
- */
494
- getWorkspaceInfo(): Promise<{
495
- slug: string;
496
- name: string;
497
- }>;
498
- /**
499
- * Get entries module
500
- */
501
- get entries(): EntriesModule;
502
- /**
503
- * Get collections module
504
- */
505
- get collections(): CollectionsModule;
506
- /**
507
- * Get assets module
508
- */
509
- get assets(): AssetsModule;
510
- /**
511
- * Get resources module
512
- */
513
- get resources(): ResourcesModule;
514
- /**
515
- * Get a single entry by slug
516
- */
517
- entry(slug: string): Promise<Entry | null>;
518
- /**
519
- * Get a single collection by slug
520
- */
521
- collection(slug: string): Promise<Collection | null>;
522
- /**
523
- * Get all pages
524
- */
525
- pages(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
526
- /**
527
- * Get all blog posts
528
- */
529
- posts(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
530
- /**
531
- * Get all projects
532
- */
533
- projects(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
534
- /**
535
- * Get a single resource by slug
536
- */
537
- resource(slug: string): Promise<Resource>;
538
- /**
539
- * Try multiple collection slugs in fallback order
540
- * Returns entries from the first collection that exists and has content
541
- *
542
- * @param slugs - Collection slugs to try in order
543
- * @param options - Options for fallback behavior
544
- * @returns Entries from the first matching collection, or empty array
545
- *
546
- * @example
547
- * ```ts
548
- * // Try bench-notes, then journal, then blog
549
- * const entries = await client.collectionFallback(['bench-notes', 'journal', 'blog']);
550
- * ```
551
- */
552
- collectionFallback(slugs: string[], options?: {
553
- requireEntries?: boolean;
554
- }): Promise<MarvinEntry[]>;
555
- /**
556
- * @deprecated Use workspace.site or marvin.site instead
557
- * Get site configuration
558
- */
559
- getSite(): Promise<MarvinSite>;
560
- /**
561
- * @deprecated Use workspace.entries.list() instead
562
- * Get all published entries
563
- */
564
- getEntries(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
565
- /**
566
- * @deprecated Use workspace.entries.get() instead
567
- * Get a single published entry by slug
568
- */
569
- getEntry(slug: string): Promise<MarvinEntry | null>;
570
- /**
571
- * @deprecated Use workspace.collections.list() instead
572
- * Get all collections
573
- */
574
- getCollections(): Promise<MarvinCollection[]>;
575
- /**
576
- * @deprecated Use workspace.collections.get() instead
577
- * Get a single collection by slug
578
- */
579
- getCollection(slug: string): Promise<MarvinCollection | null>;
580
- /**
581
- * @deprecated Use workspace.collections.entries() instead
582
- * Get all entries in a collection
583
- */
584
- getCollectionEntries(slug: string): Promise<MarvinEntry[]>;
585
- /**
586
- * @deprecated Use workspace.assets.list() instead
587
- * Get all published assets
588
- */
589
- getAssets(options?: GetAssetsOptions): Promise<MarvinAsset[]>;
590
- /**
591
- * @deprecated Use workspace.resources.list() instead
592
- * Get all published resources
593
- */
594
- getResources(options?: GetResourcesOptions$1): Promise<MarvinResource[]>;
595
- /**
596
- * @deprecated Use workspace.resources.get() instead
597
- * Get a single resource by slug
598
- */
599
- getResource(slug: string): Promise<MarvinResource>;
600
- /**
601
- * @deprecated Use workspace.resources.entries() instead
602
- * Get entries that reference a resource
603
- */
604
- getResourceEntries(slug: string): Promise<MarvinEntry[]>;
605
- }
1
+ import { M as MarvinConfig, a as MarvinClient } from './marvin-g7dayc83.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-g7dayc83.js';
3
+ import { H as HttpClient } from './HttpClient-CdF3IHM1.js';
4
+ export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-CdF3IHM1.js';
5
+ import { AuthToken as AuthToken$1 } from './types/index.js';
6
+ export { GetAssetsOptions, GetEntriesOptions, GetResourcesOptions, MarvinAsset, MarvinCollection, MarvinEntry, MarvinEntryType, MarvinPublishResponse, MarvinResource, MarvinSite } from './types/index.js';
606
7
 
607
8
  /**
608
9
  * Authentication & User Registration
@@ -633,9 +34,18 @@ interface LoginRequest {
633
34
  username: string;
634
35
  password: string;
635
36
  }
636
- interface AuthToken {
637
- accessToken: string;
638
- tokenType: string;
37
+ type AuthToken = AuthToken$1;
38
+ interface UserRegistrationResponse {
39
+ id: string;
40
+ username: string;
41
+ email: string;
42
+ full_name: string;
43
+ group?: string;
44
+ advanced?: boolean;
45
+ private?: boolean;
46
+ is_active: boolean;
47
+ created_at: string;
48
+ updated_at: string;
639
49
  }
640
50
  declare class AuthClient extends HttpClient {
641
51
  constructor(apiUrl: string);
@@ -643,7 +53,7 @@ declare class AuthClient extends HttpClient {
643
53
  * Register a new user
644
54
  * Returns the created user object
645
55
  */
646
- register(data: UserRegistration): Promise<any>;
56
+ register(data: UserRegistration): Promise<UserRegistrationResponse>;
647
57
  /**
648
58
  * Request password reset (sends email with token)
649
59
  */
@@ -687,4 +97,4 @@ declare function createAuthClient(apiUrl: string): AuthClient;
687
97
  */
688
98
  declare function createMarvinClient(config?: Partial<MarvinConfig>): MarvinClient;
689
99
 
690
- export { AuthClient, type AuthToken, Collection, Entry, type ForgotPasswordRequest, GetResourcesOptions$1 as GetResourcesOptions, HttpClient, type LoginRequest, MarvinApiError, MarvinAsset, MarvinAuthError, MarvinCache, MarvinClient, MarvinCollection, type MarvinConfig, MarvinConfigError, MarvinEntry, MarvinEntryType, MarvinError, MarvinNetworkError, MarvinNotFoundError, MarvinResource, MarvinServerError, MarvinSite, MarvinValidationError, type PaginatedResponse, type PaginationMeta, type PaginationParams, type ResetPasswordRequest, Resource, type UserRegistration, Workspace, createAuthClient, createConfigFromEnv, createMarvinClient, createPaginatedResponse, extractData, isPaginatedResponse, offsetToPage, pageToOffset };
100
+ export { AuthClient, type AuthToken, type ForgotPasswordRequest, HttpClient, type LoginRequest, MarvinClient, MarvinConfig, type ResetPasswordRequest, type UserRegistration, createAuthClient, createMarvinClient };