@inneropen/marvin-sdk 2.0.1 → 3.0.1

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