@inneropen/marvin-sdk 4.1.0 → 4.2.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/dist/{chunk-VS6R3V3K.js → chunk-HFNIFS2A.js} +33 -16
- package/dist/{index-CX4jvPAA.d.cts → index-BEEbnrXV.d.cts} +481 -43
- package/dist/{index-CX4jvPAA.d.ts → index-BEEbnrXV.d.ts} +481 -43
- package/dist/index.cjs +34 -16
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -1
- package/dist/{marvin-6keK-yvS.d.cts → marvin-BiXcixLB.d.cts} +52 -34
- package/dist/{marvin-Cndwz82G.d.ts → marvin-BjJXe-YT.d.ts} +52 -34
- package/dist/platform.d.cts +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/publish.cjs +33 -16
- package/dist/publish.d.cts +3 -3
- package/dist/publish.d.ts +3 -3
- package/dist/publish.js +4 -2
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -135,6 +135,12 @@ var init_config = __esm({
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
// src/entries/entry.ts
|
|
138
|
+
function isFullEntryData(raw) {
|
|
139
|
+
if (!raw || typeof raw !== "object") return false;
|
|
140
|
+
const record = raw;
|
|
141
|
+
if ("assetSlugs" in record || "resourceSlugs" in record) return false;
|
|
142
|
+
return Array.isArray(record.assets) || Array.isArray(record.resources);
|
|
143
|
+
}
|
|
138
144
|
var Entry;
|
|
139
145
|
var init_entry = __esm({
|
|
140
146
|
"src/entries/entry.ts"() {
|
|
@@ -337,19 +343,21 @@ var init_entries = __esm({
|
|
|
337
343
|
}
|
|
338
344
|
http;
|
|
339
345
|
workspaceSlug;
|
|
340
|
-
/**
|
|
341
|
-
* Get all published entries
|
|
342
|
-
*/
|
|
343
346
|
async list(options = {}) {
|
|
344
347
|
const queryString = this.http.buildQueryString({
|
|
345
348
|
entry_type: options.entryType,
|
|
346
349
|
collection: options.collection,
|
|
347
350
|
limit: options.limit,
|
|
348
|
-
offset: options.offset
|
|
351
|
+
offset: options.offset,
|
|
352
|
+
expand: options.expand
|
|
349
353
|
});
|
|
350
354
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
351
355
|
const response = await this.http.fetch(endpoint);
|
|
352
|
-
|
|
356
|
+
const data = response.data || [];
|
|
357
|
+
if (options.expand === "full" && data.every(isFullEntryData)) {
|
|
358
|
+
return data.map((entry) => new Entry(entry));
|
|
359
|
+
}
|
|
360
|
+
return data.map(toListEntry);
|
|
353
361
|
}
|
|
354
362
|
/**
|
|
355
363
|
* Get a single entry by slug
|
|
@@ -395,6 +403,7 @@ var init_collections = __esm({
|
|
|
395
403
|
"src/collections/collections.ts"() {
|
|
396
404
|
"use strict";
|
|
397
405
|
init_collection();
|
|
406
|
+
init_entry();
|
|
398
407
|
init_errors();
|
|
399
408
|
CollectionsModule = class {
|
|
400
409
|
constructor(http, workspaceSlug) {
|
|
@@ -427,18 +436,25 @@ var init_collections = __esm({
|
|
|
427
436
|
throw error;
|
|
428
437
|
}
|
|
429
438
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
439
|
+
async entries(slug, options = {}) {
|
|
440
|
+
if (options.expand !== "full") {
|
|
441
|
+
const collection = await this.get(slug);
|
|
442
|
+
return Array.isArray(collection) ? collection : collection.entries;
|
|
443
|
+
}
|
|
444
|
+
let data;
|
|
445
|
+
try {
|
|
446
|
+
data = await this.http.fetch(
|
|
447
|
+
`/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
|
|
448
|
+
);
|
|
449
|
+
} catch (error) {
|
|
450
|
+
if (error instanceof MarvinNotFoundError) return [];
|
|
451
|
+
throw error;
|
|
452
|
+
}
|
|
453
|
+
const entries = data.entries ?? [];
|
|
454
|
+
if (entries.every(isFullEntryData)) {
|
|
455
|
+
return data.entries.map((entry) => new Entry(entry));
|
|
440
456
|
}
|
|
441
|
-
return
|
|
457
|
+
return new Collection(data).entries;
|
|
442
458
|
}
|
|
443
459
|
/**
|
|
444
460
|
* Try multiple collection slugs in fallback order.
|
|
@@ -888,6 +904,7 @@ export {
|
|
|
888
904
|
createConfigFromEnv,
|
|
889
905
|
config_exports,
|
|
890
906
|
init_config,
|
|
907
|
+
isFullEntryData,
|
|
891
908
|
Entry,
|
|
892
909
|
init_entry,
|
|
893
910
|
Collection,
|