@inneropen/marvin-sdk 3.1.0 → 3.2.0-next.10
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-WJC4X7TB.js → chunk-SVH7AMMY.js} +6 -6
- package/dist/{chunk-L4LJWRA7.js → chunk-YHBF2SB3.js} +65 -30
- package/dist/{index-BLIrbIHf.d.cts → index-BVm5dIcw.d.cts} +289 -84
- package/dist/{index-BLIrbIHf.d.ts → index-BVm5dIcw.d.ts} +289 -84
- package/dist/index.cjs +70 -35
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/{marvin-C_TihjE2.d.ts → marvin-BZ4meaB-.d.ts} +32 -77
- package/dist/{marvin-BhI__9Cj.d.cts → marvin-RZZj02LS.d.cts} +32 -77
- package/dist/platform.cjs +17 -6
- package/dist/platform.d.cts +8 -1
- package/dist/platform.d.ts +8 -1
- package/dist/platform.js +12 -1
- package/dist/publish.cjs +70 -35
- package/dist/publish.d.cts +3 -3
- package/dist/publish.d.ts +3 -3
- package/dist/publish.js +2 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -270,7 +270,7 @@ var init_HttpClient = __esm({
|
|
|
270
270
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
271
271
|
const startTime = Date.now();
|
|
272
272
|
if (this.debug) {
|
|
273
|
-
this.logger.log(`[Marvin] ${method} ${url}`);
|
|
273
|
+
this.logger.log(`[Marvin SDK] ${method} ${url}`);
|
|
274
274
|
}
|
|
275
275
|
try {
|
|
276
276
|
const response = await fetch(url, {
|
|
@@ -284,7 +284,7 @@ var init_HttpClient = __esm({
|
|
|
284
284
|
const duration = Date.now() - startTime;
|
|
285
285
|
if (this.debug) {
|
|
286
286
|
this.logger.log(
|
|
287
|
-
`[Marvin] ${response.status} ${response.statusText} (${duration}ms)`
|
|
287
|
+
`[Marvin SDK] ${response.status} ${response.statusText} (${duration}ms)`
|
|
288
288
|
);
|
|
289
289
|
}
|
|
290
290
|
if (response.status === 401 && this.auth.handleUnauthorized) {
|
|
@@ -294,7 +294,7 @@ var init_HttpClient = __esm({
|
|
|
294
294
|
const errorText = await response.text().catch(() => "");
|
|
295
295
|
if (this.debug) {
|
|
296
296
|
this.logger.error(
|
|
297
|
-
`[Marvin] Error response: ${response.status} ${response.statusText}`,
|
|
297
|
+
`[Marvin SDK] Error response: ${response.status} ${response.statusText}`,
|
|
298
298
|
errorText ? `Body: ${errorText}` : ""
|
|
299
299
|
);
|
|
300
300
|
}
|
|
@@ -304,7 +304,7 @@ var init_HttpClient = __esm({
|
|
|
304
304
|
const delay = this.calculateRetryDelay(retryAttempt);
|
|
305
305
|
if (this.debug) {
|
|
306
306
|
this.logger.warn(
|
|
307
|
-
`[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
|
|
307
|
+
`[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (status: ${response.status})`
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
310
|
await this.sleep(delay);
|
|
@@ -343,7 +343,7 @@ var init_HttpClient = __esm({
|
|
|
343
343
|
const data = await response.json();
|
|
344
344
|
if (this.debug) {
|
|
345
345
|
const sanitized = this.sanitizeForLogging(data);
|
|
346
|
-
this.logger.log("[Marvin] Response:", JSON.stringify(sanitized, null, 2));
|
|
346
|
+
this.logger.log("[Marvin SDK] Response:", JSON.stringify(sanitized, null, 2));
|
|
347
347
|
}
|
|
348
348
|
return data;
|
|
349
349
|
} catch (error) {
|
|
@@ -357,7 +357,7 @@ var init_HttpClient = __esm({
|
|
|
357
357
|
const delay = this.calculateRetryDelay(retryAttempt);
|
|
358
358
|
if (this.debug) {
|
|
359
359
|
this.logger.warn(
|
|
360
|
-
`[Marvin] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
|
|
360
|
+
`[Marvin SDK] Retry ${retryAttempt + 1}/${this.retryConfig.maxRetries} after ${delay}ms (network error)`
|
|
361
361
|
);
|
|
362
362
|
}
|
|
363
363
|
await this.sleep(delay);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
__export,
|
|
8
8
|
init_core,
|
|
9
9
|
init_errors
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SVH7AMMY.js";
|
|
11
11
|
|
|
12
12
|
// src/client/config.ts
|
|
13
13
|
var config_exports = {};
|
|
@@ -173,25 +173,22 @@ var init_entry = __esm({
|
|
|
173
173
|
return this.raw.order;
|
|
174
174
|
}
|
|
175
175
|
get assets() {
|
|
176
|
-
return this.raw.assets
|
|
176
|
+
return (this.raw.assets ?? []).map(({ asset, role, position, metadataJson }) => ({
|
|
177
|
+
...asset,
|
|
178
|
+
entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
|
|
179
|
+
}));
|
|
177
180
|
}
|
|
178
181
|
get collections() {
|
|
179
|
-
return this.raw.collections
|
|
182
|
+
return (this.raw.collections ?? []).map(({ collection, role, position, metadataJson }) => ({
|
|
183
|
+
collection,
|
|
184
|
+
entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
|
|
185
|
+
}));
|
|
180
186
|
}
|
|
181
187
|
get resources() {
|
|
182
|
-
return this.raw.resources
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
assetsByRole(role) {
|
|
188
|
-
return this.raw.assets.filter((a) => a.role === role);
|
|
189
|
-
}
|
|
190
|
-
resource(role) {
|
|
191
|
-
return this.raw.resources.find((r) => r.role === role);
|
|
192
|
-
}
|
|
193
|
-
resourcesByRole(role) {
|
|
194
|
-
return this.raw.resources.filter((r) => r.role === role);
|
|
188
|
+
return (this.raw.resources ?? []).map(({ resource, role, position, metadataJson }) => ({
|
|
189
|
+
...resource,
|
|
190
|
+
entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
|
|
191
|
+
}));
|
|
195
192
|
}
|
|
196
193
|
field(key) {
|
|
197
194
|
return this.raw.data[key];
|
|
@@ -237,8 +234,33 @@ var init_collection = __esm({
|
|
|
237
234
|
get entryCount() {
|
|
238
235
|
return this.data.entryCount;
|
|
239
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* Entries with junction context for this collection surfaced directly.
|
|
239
|
+
* - role, position, junctionMetadata: from this collection's junction record
|
|
240
|
+
* - collections: slugs of other collections the entry belongs to
|
|
241
|
+
*/
|
|
240
242
|
get entries() {
|
|
241
|
-
return this.data.entries
|
|
243
|
+
return this.data.entries.map((entry) => {
|
|
244
|
+
const { collections, ...rest } = entry;
|
|
245
|
+
const junction = collections.find((ec) => ec.collection.slug === this.data.slug);
|
|
246
|
+
const entryMetadata = {
|
|
247
|
+
role: junction?.role ?? null,
|
|
248
|
+
position: junction?.position ?? 0,
|
|
249
|
+
metadataJson: junction?.metadataJson ?? null
|
|
250
|
+
};
|
|
251
|
+
const collection = {
|
|
252
|
+
slug: this.data.slug,
|
|
253
|
+
name: this.data.name,
|
|
254
|
+
description: this.data.description,
|
|
255
|
+
metadataJson: this.data.metadataJson,
|
|
256
|
+
entryMetadata
|
|
257
|
+
};
|
|
258
|
+
return {
|
|
259
|
+
...rest,
|
|
260
|
+
collection,
|
|
261
|
+
collectionSlugs: collections.map((ec) => ec.collection.slug)
|
|
262
|
+
};
|
|
263
|
+
});
|
|
242
264
|
}
|
|
243
265
|
toJSON() {
|
|
244
266
|
return this.data;
|
|
@@ -289,6 +311,16 @@ var init_resource = __esm({
|
|
|
289
311
|
});
|
|
290
312
|
|
|
291
313
|
// src/entries/entries.ts
|
|
314
|
+
function toListEntry(raw) {
|
|
315
|
+
const { collections, ...rest } = raw;
|
|
316
|
+
return {
|
|
317
|
+
...rest,
|
|
318
|
+
collections: (collections ?? []).map(({ collection, role, position, metadataJson }) => ({
|
|
319
|
+
collection,
|
|
320
|
+
entryMetadata: { role: role ?? null, position, metadataJson: metadataJson ?? null }
|
|
321
|
+
}))
|
|
322
|
+
};
|
|
323
|
+
}
|
|
292
324
|
var EntriesModule;
|
|
293
325
|
var init_entries = __esm({
|
|
294
326
|
"src/entries/entries.ts"() {
|
|
@@ -314,7 +346,7 @@ var init_entries = __esm({
|
|
|
314
346
|
});
|
|
315
347
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
316
348
|
const response = await this.http.fetch(endpoint);
|
|
317
|
-
return response.data || [];
|
|
349
|
+
return (response.data || []).map(toListEntry);
|
|
318
350
|
}
|
|
319
351
|
/**
|
|
320
352
|
* Get a single entry by slug
|
|
@@ -377,8 +409,8 @@ var init_collections = __esm({
|
|
|
377
409
|
return response.data || [];
|
|
378
410
|
}
|
|
379
411
|
/**
|
|
380
|
-
* Get a single collection by slug
|
|
381
|
-
* Returns
|
|
412
|
+
* Get a single collection by slug.
|
|
413
|
+
* Returns an empty array if the collection is not found (404).
|
|
382
414
|
*/
|
|
383
415
|
async get(slug) {
|
|
384
416
|
try {
|
|
@@ -387,32 +419,34 @@ var init_collections = __esm({
|
|
|
387
419
|
return new Collection(data);
|
|
388
420
|
} catch (error) {
|
|
389
421
|
if (error instanceof MarvinNotFoundError) {
|
|
390
|
-
return
|
|
422
|
+
return [];
|
|
391
423
|
}
|
|
392
424
|
throw error;
|
|
393
425
|
}
|
|
394
426
|
}
|
|
395
427
|
/**
|
|
396
|
-
* Get entries in a collection
|
|
397
|
-
*
|
|
428
|
+
* Get entries in a collection with junction context surfaced directly.
|
|
429
|
+
* Each entry has role/position/junctionMetadata from this collection's junction,
|
|
430
|
+
* and collections reduced to slugs of other memberships.
|
|
431
|
+
* Returns empty array if collection is not found.
|
|
398
432
|
*/
|
|
399
433
|
async entries(slug) {
|
|
400
434
|
const collection = await this.get(slug);
|
|
401
|
-
if (
|
|
402
|
-
return
|
|
435
|
+
if (Array.isArray(collection)) {
|
|
436
|
+
return collection;
|
|
403
437
|
}
|
|
404
438
|
return collection.entries;
|
|
405
439
|
}
|
|
406
440
|
/**
|
|
407
|
-
* Try multiple collection slugs in fallback order
|
|
408
|
-
* Returns the first collection that exists and has entries
|
|
441
|
+
* Try multiple collection slugs in fallback order.
|
|
442
|
+
* Returns entries from the first collection that exists and has entries.
|
|
409
443
|
*/
|
|
410
444
|
async fallback(slugs, options = {}) {
|
|
411
445
|
const { requireEntries = true } = options;
|
|
412
446
|
for (const slug of slugs) {
|
|
413
447
|
try {
|
|
414
448
|
const collection = await this.get(slug);
|
|
415
|
-
if (
|
|
449
|
+
if (Array.isArray(collection)) {
|
|
416
450
|
continue;
|
|
417
451
|
}
|
|
418
452
|
const entries = collection.entries;
|
|
@@ -542,7 +576,8 @@ var init_renderers = __esm({
|
|
|
542
576
|
workspaceSlug;
|
|
543
577
|
async list() {
|
|
544
578
|
const endpoint = `/api/publish/${this.workspaceSlug}/entry-types`;
|
|
545
|
-
|
|
579
|
+
const all = await this.http.fetch(endpoint);
|
|
580
|
+
return all.filter((et) => et.isRendered);
|
|
546
581
|
}
|
|
547
582
|
};
|
|
548
583
|
}
|
|
@@ -809,7 +844,7 @@ var init_marvin = __esm({
|
|
|
809
844
|
*/
|
|
810
845
|
async getCollection(slug) {
|
|
811
846
|
const collection = await this.workspace.collections.get(slug);
|
|
812
|
-
if (
|
|
847
|
+
if (Array.isArray(collection)) {
|
|
813
848
|
return null;
|
|
814
849
|
}
|
|
815
850
|
return collection.toJSON();
|