@inneropen/marvin-sdk 1.0.0
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/QUICKSTART.md +408 -0
- package/README.md +721 -0
- package/dist/index.cjs +859 -0
- package/dist/index.d.cts +430 -0
- package/dist/index.d.ts +430 -0
- package/dist/index.js +846 -0
- package/dist/types/index.cjs +18 -0
- package/dist/types/index.d.cts +120 -0
- package/dist/types/index.d.ts +120 -0
- package/dist/types/index.js +0 -0
- package/examples.md +961 -0
- package/package.json +73 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { MarvinResource, MarvinEntry, MarvinAsset, MarvinCollection, MarvinEntryType, MarvinSite, GetResourcesOptions as GetResourcesOptions$1 } from './types/index.cjs';
|
|
2
|
+
export { GetAssetsOptions, GetEntriesOptions, MarvinPublishResponse } from './types/index.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Marvin SDK Configuration
|
|
6
|
+
*/
|
|
7
|
+
interface MarvinConfig {
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
siteClientToken: string;
|
|
10
|
+
workspaceSlug: string;
|
|
11
|
+
/** Enable automatic initialization on client creation */
|
|
12
|
+
autoInitialize?: boolean;
|
|
13
|
+
/** Cache duration in milliseconds (default: 5 minutes) */
|
|
14
|
+
cacheDuration?: number;
|
|
15
|
+
}
|
|
16
|
+
declare function createConfigFromEnv(overrides?: Partial<MarvinConfig>): MarvinConfig;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HTTP Client for Marvin API
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
declare class MarvinHttpClient {
|
|
23
|
+
private config;
|
|
24
|
+
constructor(config: MarvinConfig);
|
|
25
|
+
fetch<T>(endpoint: string): Promise<T>;
|
|
26
|
+
buildQueryString(params: Record<string, string | number | undefined>): string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Resource - Rich object representing a single resource
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
declare class Resource {
|
|
34
|
+
private data;
|
|
35
|
+
private http;
|
|
36
|
+
private workspaceSlug;
|
|
37
|
+
constructor(data: MarvinResource, http: MarvinHttpClient, workspaceSlug: string);
|
|
38
|
+
get id(): string;
|
|
39
|
+
get name(): string;
|
|
40
|
+
get slug(): string;
|
|
41
|
+
get resourceType(): string | undefined;
|
|
42
|
+
get description(): string | undefined;
|
|
43
|
+
get externalId(): string | undefined;
|
|
44
|
+
get url(): string | undefined;
|
|
45
|
+
get metadata(): Record<string, unknown> | undefined;
|
|
46
|
+
get createdAt(): string;
|
|
47
|
+
get updatedAt(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get all entries that reference this resource
|
|
50
|
+
*/
|
|
51
|
+
entries(): Promise<MarvinEntry[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get assets related to this resource (future)
|
|
54
|
+
*/
|
|
55
|
+
assets(): Promise<MarvinAsset[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Get raw resource data
|
|
58
|
+
*/
|
|
59
|
+
toJSON(): MarvinResource;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resources Module - Manage resources
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
interface GetResourcesOptions {
|
|
67
|
+
resourceType?: string;
|
|
68
|
+
limit?: number;
|
|
69
|
+
offset?: number;
|
|
70
|
+
}
|
|
71
|
+
declare class ResourcesModule {
|
|
72
|
+
private http;
|
|
73
|
+
private workspaceSlug;
|
|
74
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
75
|
+
/**
|
|
76
|
+
* Get all published resources
|
|
77
|
+
*/
|
|
78
|
+
list(options?: GetResourcesOptions): Promise<MarvinResource[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Get a single resource by slug
|
|
81
|
+
*/
|
|
82
|
+
get(slug: string): Promise<Resource>;
|
|
83
|
+
/**
|
|
84
|
+
* Get entries that reference this resource
|
|
85
|
+
*/
|
|
86
|
+
entries(slug: string): Promise<MarvinEntry[]>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Assets Module - Manage assets
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
interface GetAssetsOptions {
|
|
94
|
+
type?: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
offset?: number;
|
|
97
|
+
}
|
|
98
|
+
declare class AssetsModule {
|
|
99
|
+
private http;
|
|
100
|
+
private workspaceSlug;
|
|
101
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
102
|
+
/**
|
|
103
|
+
* Get all published assets
|
|
104
|
+
*/
|
|
105
|
+
list(options?: GetAssetsOptions): Promise<MarvinAsset[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Convenience: Get all images
|
|
108
|
+
*/
|
|
109
|
+
images(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Convenience: Get all videos
|
|
112
|
+
*/
|
|
113
|
+
videos(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Convenience: Get all documents
|
|
116
|
+
*/
|
|
117
|
+
documents(options?: Omit<GetAssetsOptions, 'type'>): Promise<MarvinAsset[]>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Collection - Rich object representing a single collection
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
declare class Collection {
|
|
125
|
+
private data;
|
|
126
|
+
private http;
|
|
127
|
+
private workspaceSlug;
|
|
128
|
+
constructor(data: MarvinCollection, http: MarvinHttpClient, workspaceSlug: string);
|
|
129
|
+
get id(): string;
|
|
130
|
+
get name(): string;
|
|
131
|
+
get slug(): string;
|
|
132
|
+
get description(): string | undefined;
|
|
133
|
+
get icon(): string | undefined;
|
|
134
|
+
get color(): string | undefined;
|
|
135
|
+
get sortOrder(): number;
|
|
136
|
+
get isSmart(): boolean;
|
|
137
|
+
get smartRules(): Record<string, unknown> | undefined;
|
|
138
|
+
get createdAt(): string;
|
|
139
|
+
get updatedAt(): string;
|
|
140
|
+
/**
|
|
141
|
+
* Get all entries in this collection
|
|
142
|
+
*/
|
|
143
|
+
entries(): Promise<MarvinEntry[]>;
|
|
144
|
+
/**
|
|
145
|
+
* Get assets in this collection (future)
|
|
146
|
+
*/
|
|
147
|
+
assets(): Promise<MarvinAsset[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Get collection metadata (future)
|
|
150
|
+
*/
|
|
151
|
+
metadata(): Promise<any>;
|
|
152
|
+
/**
|
|
153
|
+
* Get raw collection data
|
|
154
|
+
*/
|
|
155
|
+
toJSON(): MarvinCollection;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Collections Module - Manage collections
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
declare class CollectionsModule {
|
|
163
|
+
private http;
|
|
164
|
+
private workspaceSlug;
|
|
165
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
166
|
+
/**
|
|
167
|
+
* Get all collections
|
|
168
|
+
*/
|
|
169
|
+
list(): Promise<MarvinCollection[]>;
|
|
170
|
+
/**
|
|
171
|
+
* Get a single collection by slug
|
|
172
|
+
*/
|
|
173
|
+
get(slug: string): Promise<Collection>;
|
|
174
|
+
/**
|
|
175
|
+
* Get entries in a collection
|
|
176
|
+
*/
|
|
177
|
+
entries(slug: string): Promise<MarvinEntry[]>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare class Entry {
|
|
181
|
+
private data;
|
|
182
|
+
private http;
|
|
183
|
+
private workspaceSlug;
|
|
184
|
+
constructor(data: MarvinEntry, http: MarvinHttpClient, workspaceSlug: string);
|
|
185
|
+
get id(): string;
|
|
186
|
+
get title(): string;
|
|
187
|
+
get slug(): string;
|
|
188
|
+
get summary(): string | undefined;
|
|
189
|
+
get description(): string | undefined;
|
|
190
|
+
get contentMarkdown(): string | undefined;
|
|
191
|
+
get metadata(): Record<string, unknown> | undefined;
|
|
192
|
+
get status(): string;
|
|
193
|
+
get publishedAt(): string | undefined;
|
|
194
|
+
get createdAt(): string;
|
|
195
|
+
get updatedAt(): string;
|
|
196
|
+
get entryTypeId(): string;
|
|
197
|
+
get entryType(): MarvinEntryType | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* Get entry assets
|
|
200
|
+
*/
|
|
201
|
+
get assets(): MarvinAsset[];
|
|
202
|
+
/**
|
|
203
|
+
* Get entry collections
|
|
204
|
+
*/
|
|
205
|
+
get collections(): MarvinCollection[];
|
|
206
|
+
/**
|
|
207
|
+
* Get related entries (future)
|
|
208
|
+
*/
|
|
209
|
+
relatedEntries(): Promise<MarvinEntry[]>;
|
|
210
|
+
/**
|
|
211
|
+
* Get raw entry data
|
|
212
|
+
*/
|
|
213
|
+
toJSON(): MarvinEntry;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Entries Module - Manage entries
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
interface GetEntriesOptions {
|
|
221
|
+
entryType?: string;
|
|
222
|
+
collection?: string;
|
|
223
|
+
limit?: number;
|
|
224
|
+
offset?: number;
|
|
225
|
+
status?: string;
|
|
226
|
+
}
|
|
227
|
+
declare class EntriesModule {
|
|
228
|
+
private http;
|
|
229
|
+
private workspaceSlug;
|
|
230
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
231
|
+
/**
|
|
232
|
+
* Get all published entries
|
|
233
|
+
*/
|
|
234
|
+
list(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
|
|
235
|
+
/**
|
|
236
|
+
* Get a single entry by slug
|
|
237
|
+
*/
|
|
238
|
+
get(slug: string): Promise<Entry>;
|
|
239
|
+
/**
|
|
240
|
+
* Convenience: Get all pages
|
|
241
|
+
*/
|
|
242
|
+
pages(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
|
|
243
|
+
/**
|
|
244
|
+
* Convenience: Get all blog posts
|
|
245
|
+
*/
|
|
246
|
+
posts(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Convenience: Get all projects
|
|
249
|
+
*/
|
|
250
|
+
projects(options?: Omit<GetEntriesOptions, 'entryType'>): Promise<MarvinEntry[]>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Workspace - First-class object representing a Marvin workspace
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
declare class Workspace {
|
|
258
|
+
private http;
|
|
259
|
+
private _site;
|
|
260
|
+
private _slug;
|
|
261
|
+
entries: EntriesModule;
|
|
262
|
+
collections: CollectionsModule;
|
|
263
|
+
assets: AssetsModule;
|
|
264
|
+
resources: ResourcesModule;
|
|
265
|
+
constructor(http: MarvinHttpClient, slug: string);
|
|
266
|
+
/**
|
|
267
|
+
* Get workspace slug
|
|
268
|
+
*/
|
|
269
|
+
get slug(): string;
|
|
270
|
+
/**
|
|
271
|
+
* Get site configuration (cached after first load)
|
|
272
|
+
*/
|
|
273
|
+
get site(): MarvinSite | null;
|
|
274
|
+
/**
|
|
275
|
+
* Load site configuration
|
|
276
|
+
*/
|
|
277
|
+
loadSite(): Promise<MarvinSite>;
|
|
278
|
+
/**
|
|
279
|
+
* Get workspace info (name and slug only)
|
|
280
|
+
*/
|
|
281
|
+
getInfo(): Promise<{
|
|
282
|
+
slug: string;
|
|
283
|
+
name: string;
|
|
284
|
+
}>;
|
|
285
|
+
/**
|
|
286
|
+
* Get workspace settings (future)
|
|
287
|
+
*/
|
|
288
|
+
settings(): Promise<any>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
declare class MarvinClient {
|
|
292
|
+
private config;
|
|
293
|
+
private http;
|
|
294
|
+
private cache;
|
|
295
|
+
private workspace;
|
|
296
|
+
private initialized;
|
|
297
|
+
constructor(config: MarvinConfig);
|
|
298
|
+
/**
|
|
299
|
+
* Initialize the SDK
|
|
300
|
+
* Preloads site configuration and metadata
|
|
301
|
+
*/
|
|
302
|
+
initialize(): Promise<void>;
|
|
303
|
+
/**
|
|
304
|
+
* Get the workspace object
|
|
305
|
+
*/
|
|
306
|
+
getWorkspace(): Promise<Workspace>;
|
|
307
|
+
/**
|
|
308
|
+
* Get site configuration (cached)
|
|
309
|
+
*/
|
|
310
|
+
get site(): MarvinSite | null;
|
|
311
|
+
/**
|
|
312
|
+
* Get workspace info (name and slug)
|
|
313
|
+
*/
|
|
314
|
+
getWorkspaceInfo(): Promise<{
|
|
315
|
+
slug: string;
|
|
316
|
+
name: string;
|
|
317
|
+
}>;
|
|
318
|
+
/**
|
|
319
|
+
* Get entries module
|
|
320
|
+
*/
|
|
321
|
+
get entries(): EntriesModule;
|
|
322
|
+
/**
|
|
323
|
+
* Get collections module
|
|
324
|
+
*/
|
|
325
|
+
get collections(): CollectionsModule;
|
|
326
|
+
/**
|
|
327
|
+
* Get assets module
|
|
328
|
+
*/
|
|
329
|
+
get assets(): AssetsModule;
|
|
330
|
+
/**
|
|
331
|
+
* Get resources module
|
|
332
|
+
*/
|
|
333
|
+
get resources(): ResourcesModule;
|
|
334
|
+
/**
|
|
335
|
+
* Get a single entry by slug
|
|
336
|
+
*/
|
|
337
|
+
entry(slug: string): Promise<Entry>;
|
|
338
|
+
/**
|
|
339
|
+
* Get a single collection by slug
|
|
340
|
+
*/
|
|
341
|
+
collection(slug: string): Promise<Collection>;
|
|
342
|
+
/**
|
|
343
|
+
* Get all pages
|
|
344
|
+
*/
|
|
345
|
+
pages(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
|
|
346
|
+
/**
|
|
347
|
+
* Get all blog posts
|
|
348
|
+
*/
|
|
349
|
+
posts(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
|
|
350
|
+
/**
|
|
351
|
+
* Get all projects
|
|
352
|
+
*/
|
|
353
|
+
projects(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
|
|
354
|
+
/**
|
|
355
|
+
* Get a single resource by slug
|
|
356
|
+
*/
|
|
357
|
+
resource(slug: string): Promise<Resource>;
|
|
358
|
+
/**
|
|
359
|
+
* @deprecated Use workspace.site or marvin.site instead
|
|
360
|
+
* Get site configuration
|
|
361
|
+
*/
|
|
362
|
+
getSite(): Promise<MarvinSite>;
|
|
363
|
+
/**
|
|
364
|
+
* @deprecated Use workspace.entries.list() instead
|
|
365
|
+
* Get all published entries
|
|
366
|
+
*/
|
|
367
|
+
getEntries(options?: GetEntriesOptions): Promise<MarvinEntry[]>;
|
|
368
|
+
/**
|
|
369
|
+
* @deprecated Use workspace.entries.get() instead
|
|
370
|
+
* Get a single published entry by slug
|
|
371
|
+
*/
|
|
372
|
+
getEntry(slug: string): Promise<MarvinEntry>;
|
|
373
|
+
/**
|
|
374
|
+
* @deprecated Use workspace.collections.list() instead
|
|
375
|
+
* Get all collections
|
|
376
|
+
*/
|
|
377
|
+
getCollections(): Promise<MarvinCollection[]>;
|
|
378
|
+
/**
|
|
379
|
+
* @deprecated Use workspace.collections.get() instead
|
|
380
|
+
* Get a single collection by slug
|
|
381
|
+
*/
|
|
382
|
+
getCollection(slug: string): Promise<MarvinCollection>;
|
|
383
|
+
/**
|
|
384
|
+
* @deprecated Use workspace.collections.entries() instead
|
|
385
|
+
* Get all entries in a collection
|
|
386
|
+
*/
|
|
387
|
+
getCollectionEntries(slug: string): Promise<MarvinEntry[]>;
|
|
388
|
+
/**
|
|
389
|
+
* @deprecated Use workspace.assets.list() instead
|
|
390
|
+
* Get all published assets
|
|
391
|
+
*/
|
|
392
|
+
getAssets(options?: GetAssetsOptions): Promise<MarvinAsset[]>;
|
|
393
|
+
/**
|
|
394
|
+
* @deprecated Use workspace.resources.list() instead
|
|
395
|
+
* Get all published resources
|
|
396
|
+
*/
|
|
397
|
+
getResources(options?: GetResourcesOptions$1): Promise<MarvinResource[]>;
|
|
398
|
+
/**
|
|
399
|
+
* @deprecated Use workspace.resources.get() instead
|
|
400
|
+
* Get a single resource by slug
|
|
401
|
+
*/
|
|
402
|
+
getResource(slug: string): Promise<MarvinResource>;
|
|
403
|
+
/**
|
|
404
|
+
* @deprecated Use workspace.resources.entries() instead
|
|
405
|
+
* Get entries that reference a resource
|
|
406
|
+
*/
|
|
407
|
+
getResourceEntries(slug: string): Promise<MarvinEntry[]>;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Create a Marvin client instance from environment variables
|
|
412
|
+
*
|
|
413
|
+
* @param config - Optional configuration overrides
|
|
414
|
+
* @returns Configured Marvin client
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* // From environment variables
|
|
419
|
+
* const marvin = createMarvinClient();
|
|
420
|
+
*
|
|
421
|
+
* // With overrides
|
|
422
|
+
* const marvin = createMarvinClient({
|
|
423
|
+
* apiUrl: 'https://marvin.example.com',
|
|
424
|
+
* autoInitialize: true
|
|
425
|
+
* });
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
declare function createMarvinClient(config?: Partial<MarvinConfig>): MarvinClient;
|
|
429
|
+
|
|
430
|
+
export { Collection, Entry, GetResourcesOptions$1 as GetResourcesOptions, MarvinAsset, MarvinClient, MarvinCollection, type MarvinConfig, MarvinEntry, MarvinEntryType, MarvinResource, MarvinSite, Resource, Workspace, createConfigFromEnv, createMarvinClient };
|