@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
package/dist/index.cjs
CHANGED
|
@@ -915,6 +915,12 @@ var init_http2 = __esm({
|
|
|
915
915
|
});
|
|
916
916
|
|
|
917
917
|
// src/entries/entry.ts
|
|
918
|
+
function isFullEntryData(raw) {
|
|
919
|
+
if (!raw || typeof raw !== "object") return false;
|
|
920
|
+
const record = raw;
|
|
921
|
+
if ("assetSlugs" in record || "resourceSlugs" in record) return false;
|
|
922
|
+
return Array.isArray(record.assets) || Array.isArray(record.resources);
|
|
923
|
+
}
|
|
918
924
|
var Entry;
|
|
919
925
|
var init_entry = __esm({
|
|
920
926
|
"src/entries/entry.ts"() {
|
|
@@ -1010,19 +1016,21 @@ var init_entries = __esm({
|
|
|
1010
1016
|
}
|
|
1011
1017
|
http;
|
|
1012
1018
|
workspaceSlug;
|
|
1013
|
-
/**
|
|
1014
|
-
* Get all published entries
|
|
1015
|
-
*/
|
|
1016
1019
|
async list(options = {}) {
|
|
1017
1020
|
const queryString = this.http.buildQueryString({
|
|
1018
1021
|
entry_type: options.entryType,
|
|
1019
1022
|
collection: options.collection,
|
|
1020
1023
|
limit: options.limit,
|
|
1021
|
-
offset: options.offset
|
|
1024
|
+
offset: options.offset,
|
|
1025
|
+
expand: options.expand
|
|
1022
1026
|
});
|
|
1023
1027
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
1024
1028
|
const response = await this.http.fetch(endpoint);
|
|
1025
|
-
|
|
1029
|
+
const data = response.data || [];
|
|
1030
|
+
if (options.expand === "full" && data.every(isFullEntryData)) {
|
|
1031
|
+
return data.map((entry) => new Entry(entry));
|
|
1032
|
+
}
|
|
1033
|
+
return data.map(toListEntry);
|
|
1026
1034
|
}
|
|
1027
1035
|
/**
|
|
1028
1036
|
* Get a single entry by slug
|
|
@@ -1134,6 +1142,7 @@ var init_collections = __esm({
|
|
|
1134
1142
|
"src/collections/collections.ts"() {
|
|
1135
1143
|
"use strict";
|
|
1136
1144
|
init_collection();
|
|
1145
|
+
init_entry();
|
|
1137
1146
|
init_errors();
|
|
1138
1147
|
CollectionsModule = class {
|
|
1139
1148
|
constructor(http, workspaceSlug) {
|
|
@@ -1166,18 +1175,25 @@ var init_collections = __esm({
|
|
|
1166
1175
|
throw error;
|
|
1167
1176
|
}
|
|
1168
1177
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1178
|
+
async entries(slug, options = {}) {
|
|
1179
|
+
if (options.expand !== "full") {
|
|
1180
|
+
const collection = await this.get(slug);
|
|
1181
|
+
return Array.isArray(collection) ? collection : collection.entries;
|
|
1182
|
+
}
|
|
1183
|
+
let data;
|
|
1184
|
+
try {
|
|
1185
|
+
data = await this.http.fetch(
|
|
1186
|
+
`/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
|
|
1187
|
+
);
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
if (error instanceof MarvinNotFoundError) return [];
|
|
1190
|
+
throw error;
|
|
1191
|
+
}
|
|
1192
|
+
const entries = data.entries ?? [];
|
|
1193
|
+
if (entries.every(isFullEntryData)) {
|
|
1194
|
+
return data.entries.map((entry) => new Entry(entry));
|
|
1179
1195
|
}
|
|
1180
|
-
return
|
|
1196
|
+
return new Collection(data).entries;
|
|
1181
1197
|
}
|
|
1182
1198
|
/**
|
|
1183
1199
|
* Try multiple collection slugs in fallback order.
|
|
@@ -1665,6 +1681,7 @@ __export(index_exports, {
|
|
|
1665
1681
|
createMarvinClient: () => createMarvinClient,
|
|
1666
1682
|
createPaginatedResponse: () => createPaginatedResponse,
|
|
1667
1683
|
extractData: () => extractData,
|
|
1684
|
+
isFullEntryData: () => isFullEntryData,
|
|
1668
1685
|
isPaginatedResponse: () => isPaginatedResponse,
|
|
1669
1686
|
offsetToPage: () => offsetToPage,
|
|
1670
1687
|
pageToOffset: () => pageToOffset
|
|
@@ -1766,6 +1783,7 @@ function createMarvinClient(config) {
|
|
|
1766
1783
|
createMarvinClient,
|
|
1767
1784
|
createPaginatedResponse,
|
|
1768
1785
|
extractData,
|
|
1786
|
+
isFullEntryData,
|
|
1769
1787
|
isPaginatedResponse,
|
|
1770
1788
|
offsetToPage,
|
|
1771
1789
|
pageToOffset
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as MarvinConfig, a as MarvinClient } from './marvin-
|
|
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
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-BiXcixLB.cjs';
|
|
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 isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BiXcixLB.cjs';
|
|
3
3
|
import { H as HttpClient } from './HttpClient-B_rEmJuO.cjs';
|
|
4
4
|
export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-B_rEmJuO.cjs';
|
|
5
|
-
import { A as AuthToken$1 } from './index-
|
|
6
|
-
export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, G as GetAssetsOptions,
|
|
5
|
+
import { A as AuthToken$1 } from './index-BEEbnrXV.cjs';
|
|
6
|
+
export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, s as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Authentication & User Registration
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { M as MarvinConfig, a as MarvinClient } from './marvin-
|
|
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
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-BjJXe-YT.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 isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BjJXe-YT.js';
|
|
3
3
|
import { H as HttpClient } from './HttpClient-B_rEmJuO.js';
|
|
4
4
|
export { A as AuthStrategy, B as BearerTokenAuth, a as HttpClientConfig, N as NoAuth, S as SessionAuth } from './HttpClient-B_rEmJuO.js';
|
|
5
|
-
import { A as AuthToken$1 } from './index-
|
|
6
|
-
export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, G as GetAssetsOptions,
|
|
5
|
+
import { A as AuthToken$1 } from './index-BEEbnrXV.js';
|
|
6
|
+
export { C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, s as PublishedEntryType, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Authentication & User Registration
|
package/dist/index.js
CHANGED
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
init_marvin,
|
|
13
13
|
init_resource,
|
|
14
14
|
init_workspace,
|
|
15
|
+
isFullEntryData,
|
|
15
16
|
marvin_exports
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-HFNIFS2A.js";
|
|
17
18
|
import {
|
|
18
19
|
BearerTokenAuth,
|
|
19
20
|
HttpClient,
|
|
@@ -134,6 +135,7 @@ export {
|
|
|
134
135
|
createMarvinClient,
|
|
135
136
|
createPaginatedResponse,
|
|
136
137
|
extractData,
|
|
138
|
+
isFullEntryData,
|
|
137
139
|
isPaginatedResponse,
|
|
138
140
|
offsetToPage,
|
|
139
141
|
pageToOffset
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as PublishedEntryType, n as MarvinResource, M as MarvinAsset, h as MarvinCollection, a as CollectionEntry, j as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, p as PublishedCollectionSummary, e as ExpandOptions, L as ListEntry, o as MarvinSite, g as GetResourcesOptions$1 } from './index-BEEbnrXV.cjs';
|
|
2
2
|
import { H as HttpClient } from './HttpClient-B_rEmJuO.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -316,42 +316,15 @@ declare class Collection {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
/**
|
|
319
|
-
*
|
|
319
|
+
* Entry - Rich object representing a single entry
|
|
320
320
|
*/
|
|
321
321
|
|
|
322
|
-
declare class CollectionsModule {
|
|
323
|
-
private http;
|
|
324
|
-
private workspaceSlug;
|
|
325
|
-
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
326
|
-
/**
|
|
327
|
-
* Get all collections
|
|
328
|
-
*/
|
|
329
|
-
list(): Promise<PublishedCollectionSummary[]>;
|
|
330
|
-
/**
|
|
331
|
-
* Get a single collection by slug.
|
|
332
|
-
* Returns an empty array if the collection is not found (404).
|
|
333
|
-
*/
|
|
334
|
-
get(slug: string): Promise<Collection | []>;
|
|
335
|
-
/**
|
|
336
|
-
* Get entries in a collection with junction context surfaced directly.
|
|
337
|
-
* Each entry has role/position/junctionMetadata from this collection's junction,
|
|
338
|
-
* and collections reduced to slugs of other memberships.
|
|
339
|
-
* Returns empty array if collection is not found.
|
|
340
|
-
*/
|
|
341
|
-
entries(slug: string): Promise<CollectionEntry[]>;
|
|
342
|
-
/**
|
|
343
|
-
* Try multiple collection slugs in fallback order.
|
|
344
|
-
* Returns entries from the first collection that exists and has entries.
|
|
345
|
-
*/
|
|
346
|
-
fallback(slugs: string[], options?: {
|
|
347
|
-
requireEntries?: boolean;
|
|
348
|
-
}): Promise<CollectionEntry[]>;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
322
|
/**
|
|
352
|
-
*
|
|
323
|
+
* True for a full entry as the API sends it (`PublishedEntryRead`): `assets[]` placements and no
|
|
324
|
+
* `assetSlugs`/`resourceSlugs`. A list item (`PublishedEntryListItem`) has only the slugs. Lets an
|
|
325
|
+
* `expand: 'full'` read tell an expanded response from an older server's list items.
|
|
353
326
|
*/
|
|
354
|
-
|
|
327
|
+
declare function isFullEntryData(raw: unknown): raw is MarvinEntry;
|
|
355
328
|
declare class Entry {
|
|
356
329
|
private raw;
|
|
357
330
|
constructor(raw: MarvinEntry);
|
|
@@ -389,6 +362,46 @@ declare class Entry {
|
|
|
389
362
|
toJSON(): MarvinEntry;
|
|
390
363
|
}
|
|
391
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Collections Module - Manage collections
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
declare class CollectionsModule {
|
|
370
|
+
private http;
|
|
371
|
+
private workspaceSlug;
|
|
372
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
373
|
+
/**
|
|
374
|
+
* Get all collections
|
|
375
|
+
*/
|
|
376
|
+
list(): Promise<PublishedCollectionSummary[]>;
|
|
377
|
+
/**
|
|
378
|
+
* Get a single collection by slug.
|
|
379
|
+
* Returns an empty array if the collection is not found (404).
|
|
380
|
+
*/
|
|
381
|
+
get(slug: string): Promise<Collection | []>;
|
|
382
|
+
/**
|
|
383
|
+
* Get entries in a collection with junction context surfaced directly.
|
|
384
|
+
* Each entry has role/position/junctionMetadata from this collection's junction,
|
|
385
|
+
* and collections reduced to slugs of other memberships.
|
|
386
|
+
* Returns empty array if collection is not found.
|
|
387
|
+
*
|
|
388
|
+
* With `{ expand: 'full' }` the whole collection comes back as full entries in one request:
|
|
389
|
+
* `Entry` objects, the same as `entry(slug)` returns, each with its `order` in this collection
|
|
390
|
+
* and every membership under `collections`. A server without `expand` support (or a collection
|
|
391
|
+
* past the server's expand cap) returns list items instead; those come back as
|
|
392
|
+
* `CollectionEntry[]`, exactly as without the option, so check with `instanceof Entry`.
|
|
393
|
+
*/
|
|
394
|
+
entries(slug: string): Promise<CollectionEntry[]>;
|
|
395
|
+
entries(slug: string, options?: ExpandOptions): Promise<Entry[] | CollectionEntry[]>;
|
|
396
|
+
/**
|
|
397
|
+
* Try multiple collection slugs in fallback order.
|
|
398
|
+
* Returns entries from the first collection that exists and has entries.
|
|
399
|
+
*/
|
|
400
|
+
fallback(slugs: string[], options?: {
|
|
401
|
+
requireEntries?: boolean;
|
|
402
|
+
}): Promise<CollectionEntry[]>;
|
|
403
|
+
}
|
|
404
|
+
|
|
392
405
|
/**
|
|
393
406
|
* Entries Module - Manage entries
|
|
394
407
|
*/
|
|
@@ -406,8 +419,13 @@ declare class EntriesModule {
|
|
|
406
419
|
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
407
420
|
/**
|
|
408
421
|
* Get all published entries
|
|
422
|
+
*
|
|
423
|
+
* With `{ expand: 'full' }` each entry on the page comes back as a full `Entry` (the
|
|
424
|
+
* single-entry read), so no per-entry reads are needed. A server without `expand` support
|
|
425
|
+
* returns list items instead; those come back as `ListEntry[]`, as without the option.
|
|
409
426
|
*/
|
|
410
427
|
list(options?: GetEntriesOptions): Promise<ListEntry[]>;
|
|
428
|
+
list(options: GetEntriesOptions & ExpandOptions): Promise<Entry[] | ListEntry[]>;
|
|
411
429
|
/**
|
|
412
430
|
* Get a single entry by slug
|
|
413
431
|
* Returns null if entry is not found (404)
|
|
@@ -580,4 +598,4 @@ declare class MarvinClient {
|
|
|
580
598
|
getResourceEntries(slug: string): Promise<string[]>;
|
|
581
599
|
}
|
|
582
600
|
|
|
583
|
-
export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o,
|
|
601
|
+
export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isFullEntryData as p, isPaginatedResponse as q, offsetToPage as r, pageToOffset as s };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as PublishedEntryType, n as MarvinResource, M as MarvinAsset, h as MarvinCollection, a as CollectionEntry, j as MarvinEntry, E as EntryAsset, c as EntryCollectionContext, d as EntryResource, p as PublishedCollectionSummary, e as ExpandOptions, L as ListEntry, o as MarvinSite, g as GetResourcesOptions$1 } from './index-BEEbnrXV.js';
|
|
2
2
|
import { H as HttpClient } from './HttpClient-B_rEmJuO.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -316,42 +316,15 @@ declare class Collection {
|
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
/**
|
|
319
|
-
*
|
|
319
|
+
* Entry - Rich object representing a single entry
|
|
320
320
|
*/
|
|
321
321
|
|
|
322
|
-
declare class CollectionsModule {
|
|
323
|
-
private http;
|
|
324
|
-
private workspaceSlug;
|
|
325
|
-
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
326
|
-
/**
|
|
327
|
-
* Get all collections
|
|
328
|
-
*/
|
|
329
|
-
list(): Promise<PublishedCollectionSummary[]>;
|
|
330
|
-
/**
|
|
331
|
-
* Get a single collection by slug.
|
|
332
|
-
* Returns an empty array if the collection is not found (404).
|
|
333
|
-
*/
|
|
334
|
-
get(slug: string): Promise<Collection | []>;
|
|
335
|
-
/**
|
|
336
|
-
* Get entries in a collection with junction context surfaced directly.
|
|
337
|
-
* Each entry has role/position/junctionMetadata from this collection's junction,
|
|
338
|
-
* and collections reduced to slugs of other memberships.
|
|
339
|
-
* Returns empty array if collection is not found.
|
|
340
|
-
*/
|
|
341
|
-
entries(slug: string): Promise<CollectionEntry[]>;
|
|
342
|
-
/**
|
|
343
|
-
* Try multiple collection slugs in fallback order.
|
|
344
|
-
* Returns entries from the first collection that exists and has entries.
|
|
345
|
-
*/
|
|
346
|
-
fallback(slugs: string[], options?: {
|
|
347
|
-
requireEntries?: boolean;
|
|
348
|
-
}): Promise<CollectionEntry[]>;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
322
|
/**
|
|
352
|
-
*
|
|
323
|
+
* True for a full entry as the API sends it (`PublishedEntryRead`): `assets[]` placements and no
|
|
324
|
+
* `assetSlugs`/`resourceSlugs`. A list item (`PublishedEntryListItem`) has only the slugs. Lets an
|
|
325
|
+
* `expand: 'full'` read tell an expanded response from an older server's list items.
|
|
353
326
|
*/
|
|
354
|
-
|
|
327
|
+
declare function isFullEntryData(raw: unknown): raw is MarvinEntry;
|
|
355
328
|
declare class Entry {
|
|
356
329
|
private raw;
|
|
357
330
|
constructor(raw: MarvinEntry);
|
|
@@ -389,6 +362,46 @@ declare class Entry {
|
|
|
389
362
|
toJSON(): MarvinEntry;
|
|
390
363
|
}
|
|
391
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Collections Module - Manage collections
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
declare class CollectionsModule {
|
|
370
|
+
private http;
|
|
371
|
+
private workspaceSlug;
|
|
372
|
+
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
373
|
+
/**
|
|
374
|
+
* Get all collections
|
|
375
|
+
*/
|
|
376
|
+
list(): Promise<PublishedCollectionSummary[]>;
|
|
377
|
+
/**
|
|
378
|
+
* Get a single collection by slug.
|
|
379
|
+
* Returns an empty array if the collection is not found (404).
|
|
380
|
+
*/
|
|
381
|
+
get(slug: string): Promise<Collection | []>;
|
|
382
|
+
/**
|
|
383
|
+
* Get entries in a collection with junction context surfaced directly.
|
|
384
|
+
* Each entry has role/position/junctionMetadata from this collection's junction,
|
|
385
|
+
* and collections reduced to slugs of other memberships.
|
|
386
|
+
* Returns empty array if collection is not found.
|
|
387
|
+
*
|
|
388
|
+
* With `{ expand: 'full' }` the whole collection comes back as full entries in one request:
|
|
389
|
+
* `Entry` objects, the same as `entry(slug)` returns, each with its `order` in this collection
|
|
390
|
+
* and every membership under `collections`. A server without `expand` support (or a collection
|
|
391
|
+
* past the server's expand cap) returns list items instead; those come back as
|
|
392
|
+
* `CollectionEntry[]`, exactly as without the option, so check with `instanceof Entry`.
|
|
393
|
+
*/
|
|
394
|
+
entries(slug: string): Promise<CollectionEntry[]>;
|
|
395
|
+
entries(slug: string, options?: ExpandOptions): Promise<Entry[] | CollectionEntry[]>;
|
|
396
|
+
/**
|
|
397
|
+
* Try multiple collection slugs in fallback order.
|
|
398
|
+
* Returns entries from the first collection that exists and has entries.
|
|
399
|
+
*/
|
|
400
|
+
fallback(slugs: string[], options?: {
|
|
401
|
+
requireEntries?: boolean;
|
|
402
|
+
}): Promise<CollectionEntry[]>;
|
|
403
|
+
}
|
|
404
|
+
|
|
392
405
|
/**
|
|
393
406
|
* Entries Module - Manage entries
|
|
394
407
|
*/
|
|
@@ -406,8 +419,13 @@ declare class EntriesModule {
|
|
|
406
419
|
constructor(http: MarvinHttpClient, workspaceSlug: string);
|
|
407
420
|
/**
|
|
408
421
|
* Get all published entries
|
|
422
|
+
*
|
|
423
|
+
* With `{ expand: 'full' }` each entry on the page comes back as a full `Entry` (the
|
|
424
|
+
* single-entry read), so no per-entry reads are needed. A server without `expand` support
|
|
425
|
+
* returns list items instead; those come back as `ListEntry[]`, as without the option.
|
|
409
426
|
*/
|
|
410
427
|
list(options?: GetEntriesOptions): Promise<ListEntry[]>;
|
|
428
|
+
list(options: GetEntriesOptions & ExpandOptions): Promise<Entry[] | ListEntry[]>;
|
|
411
429
|
/**
|
|
412
430
|
* Get a single entry by slug
|
|
413
431
|
* Returns null if entry is not found (404)
|
|
@@ -580,4 +598,4 @@ declare class MarvinClient {
|
|
|
580
598
|
getResourceEntries(slug: string): Promise<string[]>;
|
|
581
599
|
}
|
|
582
600
|
|
|
583
|
-
export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o,
|
|
601
|
+
export { Collection as C, Entry as E, type MarvinConfig as M, type PaginatedResponse as P, Resource as R, Workspace as W, MarvinClient as a, MarvinApiError as b, MarvinAuthError as c, MarvinCache as d, MarvinConfigError as e, MarvinError as f, MarvinNetworkError as g, MarvinNotFoundError as h, MarvinServerError as i, MarvinValidationError as j, type PaginationMeta as k, type PaginationParams as l, createConfigFromEnv as m, createPaginatedResponse as n, extractData as o, isFullEntryData as p, isPaginatedResponse as q, offsetToPage as r, pageToOffset as s };
|
package/dist/platform.d.cts
CHANGED
package/dist/platform.d.ts
CHANGED
package/dist/publish.cjs
CHANGED
|
@@ -169,6 +169,7 @@ __export(publish_exports, {
|
|
|
169
169
|
createMarvinClient: () => createMarvinClient,
|
|
170
170
|
createPaginatedResponse: () => createPaginatedResponse,
|
|
171
171
|
extractData: () => extractData,
|
|
172
|
+
isFullEntryData: () => isFullEntryData,
|
|
172
173
|
isPaginatedResponse: () => isPaginatedResponse,
|
|
173
174
|
offsetToPage: () => offsetToPage,
|
|
174
175
|
pageToOffset: () => pageToOffset
|
|
@@ -774,6 +775,12 @@ var MarvinHttpClient = class extends HttpClient {
|
|
|
774
775
|
};
|
|
775
776
|
|
|
776
777
|
// src/entries/entry.ts
|
|
778
|
+
function isFullEntryData(raw) {
|
|
779
|
+
if (!raw || typeof raw !== "object") return false;
|
|
780
|
+
const record = raw;
|
|
781
|
+
if ("assetSlugs" in record || "resourceSlugs" in record) return false;
|
|
782
|
+
return Array.isArray(record.assets) || Array.isArray(record.resources);
|
|
783
|
+
}
|
|
777
784
|
var Entry = class {
|
|
778
785
|
constructor(raw) {
|
|
779
786
|
this.raw = raw;
|
|
@@ -857,19 +864,21 @@ var EntriesModule = class {
|
|
|
857
864
|
}
|
|
858
865
|
http;
|
|
859
866
|
workspaceSlug;
|
|
860
|
-
/**
|
|
861
|
-
* Get all published entries
|
|
862
|
-
*/
|
|
863
867
|
async list(options = {}) {
|
|
864
868
|
const queryString = this.http.buildQueryString({
|
|
865
869
|
entry_type: options.entryType,
|
|
866
870
|
collection: options.collection,
|
|
867
871
|
limit: options.limit,
|
|
868
|
-
offset: options.offset
|
|
872
|
+
offset: options.offset,
|
|
873
|
+
expand: options.expand
|
|
869
874
|
});
|
|
870
875
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
871
876
|
const response = await this.http.fetch(endpoint);
|
|
872
|
-
|
|
877
|
+
const data = response.data || [];
|
|
878
|
+
if (options.expand === "full" && data.every(isFullEntryData)) {
|
|
879
|
+
return data.map((entry) => new Entry(entry));
|
|
880
|
+
}
|
|
881
|
+
return data.map(toListEntry);
|
|
873
882
|
}
|
|
874
883
|
/**
|
|
875
884
|
* Get a single entry by slug
|
|
@@ -999,18 +1008,25 @@ var CollectionsModule = class {
|
|
|
999
1008
|
throw error;
|
|
1000
1009
|
}
|
|
1001
1010
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1011
|
+
async entries(slug, options = {}) {
|
|
1012
|
+
if (options.expand !== "full") {
|
|
1013
|
+
const collection = await this.get(slug);
|
|
1014
|
+
return Array.isArray(collection) ? collection : collection.entries;
|
|
1015
|
+
}
|
|
1016
|
+
let data;
|
|
1017
|
+
try {
|
|
1018
|
+
data = await this.http.fetch(
|
|
1019
|
+
`/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
|
|
1020
|
+
);
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
if (error instanceof MarvinNotFoundError) return [];
|
|
1023
|
+
throw error;
|
|
1024
|
+
}
|
|
1025
|
+
const entries = data.entries ?? [];
|
|
1026
|
+
if (entries.every(isFullEntryData)) {
|
|
1027
|
+
return data.entries.map((entry) => new Entry(entry));
|
|
1012
1028
|
}
|
|
1013
|
-
return
|
|
1029
|
+
return new Collection(data).entries;
|
|
1014
1030
|
}
|
|
1015
1031
|
/**
|
|
1016
1032
|
* Try multiple collection slugs in fallback order.
|
|
@@ -1449,6 +1465,7 @@ function createMarvinClient(config) {
|
|
|
1449
1465
|
createMarvinClient,
|
|
1450
1466
|
createPaginatedResponse,
|
|
1451
1467
|
extractData,
|
|
1468
|
+
isFullEntryData,
|
|
1452
1469
|
isPaginatedResponse,
|
|
1453
1470
|
offsetToPage,
|
|
1454
1471
|
pageToOffset
|
package/dist/publish.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as MarvinConfig, a as MarvinClient } from './marvin-
|
|
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
|
|
3
|
-
export { G as GetAssetsOptions,
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-BiXcixLB.cjs';
|
|
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 isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BiXcixLB.cjs';
|
|
3
|
+
export { e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.cjs';
|
|
4
4
|
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-B_rEmJuO.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as MarvinConfig, a as MarvinClient } from './marvin-
|
|
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
|
|
3
|
-
export { G as GetAssetsOptions,
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-BjJXe-YT.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 isFullEntryData, q as isPaginatedResponse, r as offsetToPage, s as pageToOffset } from './marvin-BjJXe-YT.js';
|
|
3
|
+
export { e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, M as MarvinAsset, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, r as PublishedEntryResource, S as SiteConfiguration, W as WorkspaceInfo } from './index-BEEbnrXV.js';
|
|
4
4
|
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, a as HttpClientConfig } from './HttpClient-B_rEmJuO.js';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/publish.js
CHANGED
|
@@ -11,8 +11,9 @@ import {
|
|
|
11
11
|
init_entry,
|
|
12
12
|
init_marvin,
|
|
13
13
|
init_resource,
|
|
14
|
-
init_workspace
|
|
15
|
-
|
|
14
|
+
init_workspace,
|
|
15
|
+
isFullEntryData
|
|
16
|
+
} from "./chunk-HFNIFS2A.js";
|
|
16
17
|
import {
|
|
17
18
|
BearerTokenAuth,
|
|
18
19
|
HttpClient,
|
|
@@ -69,6 +70,7 @@ export {
|
|
|
69
70
|
createMarvinClient,
|
|
70
71
|
createPaginatedResponse,
|
|
71
72
|
extractData,
|
|
73
|
+
isFullEntryData,
|
|
72
74
|
isPaginatedResponse,
|
|
73
75
|
offsetToPage,
|
|
74
76
|
pageToOffset
|
package/dist/types/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { u as AssetAttachment, v as AssetUploadRequest, A as AuthToken, w as CollectionAttachment, C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, x as EntryCollectionRead, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, M as MarvinAsset, y as MarvinClientConfig, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, z as PublishedEntryCollection, r as PublishedEntryResource, s as PublishedEntryType, B as PublishedResourceSummary, R as ResourceAttachment, S as SiteConfiguration, D as SiteSeo, F as SiteSeoVerification, W as WorkspaceInfo } from '../index-BEEbnrXV.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { u as AssetAttachment, v as AssetUploadRequest, A as AuthToken, w as CollectionAttachment, C as CollectionContext, a as CollectionEntry, b as CollectionEntryMetadata, E as EntryAsset, c as EntryCollectionContext, x as EntryCollectionRead, d as EntryResource, e as ExpandOptions, G as GetAssetsOptions, f as GetEntriesOptions, g as GetResourcesOptions, L as ListEntry, M as MarvinAsset, y as MarvinClientConfig, h as MarvinCollection, i as MarvinCollectionExpanded, j as MarvinEntry, k as MarvinEntryListItem, l as MarvinEntryType, m as MarvinPublishResponse, n as MarvinResource, o as MarvinSite, P as PublishedAssetRead, p as PublishedCollectionSummary, q as PublishedEntryAsset, z as PublishedEntryCollection, r as PublishedEntryResource, s as PublishedEntryType, B as PublishedResourceSummary, R as ResourceAttachment, S as SiteConfiguration, D as SiteSeo, F as SiteSeoVerification, W as WorkspaceInfo } from '../index-BEEbnrXV.js';
|