@inneropen/marvin-sdk 4.1.0 → 4.3.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/{HttpClient-B_rEmJuO.d.cts → HttpClient-DXMNOPqu.d.cts} +17 -1
- package/dist/{HttpClient-B_rEmJuO.d.ts → HttpClient-DXMNOPqu.d.ts} +17 -1
- package/dist/{chunk-VS6R3V3K.js → chunk-KXI2FQSO.js} +50 -17
- package/dist/{chunk-DSVYCVQD.js → chunk-LTX3MAUE.js} +25 -0
- 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 +75 -16
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +4 -2
- package/dist/{marvin-6keK-yvS.d.cts → marvin-CdsjwIyH.d.ts} +64 -35
- package/dist/{marvin-Cndwz82G.d.ts → marvin-gZtGa576.d.cts} +64 -35
- package/dist/platform.cjs +187 -3
- package/dist/platform.d.cts +190 -7
- package/dist/platform.d.ts +190 -7
- package/dist/platform.js +162 -4
- package/dist/publish.cjs +74 -16
- package/dist/publish.d.cts +4 -4
- package/dist/publish.d.ts +4 -4
- package/dist/publish.js +5 -3
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
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
|
|
@@ -523,6 +524,9 @@ var HttpClient = class _HttpClient {
|
|
|
523
524
|
errorText
|
|
524
525
|
);
|
|
525
526
|
}
|
|
527
|
+
if (options?.responseType === "binary") {
|
|
528
|
+
return await this.readBinary(response, method, endpoint);
|
|
529
|
+
}
|
|
526
530
|
const data = await this.readBody(response, method, endpoint);
|
|
527
531
|
if (this.debug && data !== void 0) {
|
|
528
532
|
const sanitized = this.sanitizeForLogging(data);
|
|
@@ -568,12 +572,34 @@ var HttpClient = class _HttpClient {
|
|
|
568
572
|
);
|
|
569
573
|
}
|
|
570
574
|
}
|
|
575
|
+
/** A successful response's bytes; a 204/205 is an empty array. A failed read is a network error. */
|
|
576
|
+
async readBinary(response, method, endpoint) {
|
|
577
|
+
const contentType = response.headers.get("content-type");
|
|
578
|
+
if (response.status === 204 || response.status === 205) {
|
|
579
|
+
return { data: new Uint8Array(0), contentType };
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
return { data: new Uint8Array(await response.arrayBuffer()), contentType };
|
|
583
|
+
} catch (error) {
|
|
584
|
+
const cause = error instanceof Error ? error : void 0;
|
|
585
|
+
throw new MarvinNetworkError(
|
|
586
|
+
`Reading the ${response.status} response to ${method} ${endpoint} failed: ${cause?.message ?? String(error)}`,
|
|
587
|
+
cause
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
571
591
|
/**
|
|
572
592
|
* GET request
|
|
573
593
|
*/
|
|
574
594
|
async get(endpoint, params) {
|
|
575
595
|
return this.request("GET", endpoint, { params });
|
|
576
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* GET a binary body (a file download). Follows redirects; retried like any GET.
|
|
599
|
+
*/
|
|
600
|
+
async getBinary(endpoint, params) {
|
|
601
|
+
return this.request("GET", endpoint, { params, responseType: "binary" });
|
|
602
|
+
}
|
|
577
603
|
/**
|
|
578
604
|
* POST request
|
|
579
605
|
*/
|
|
@@ -774,6 +800,12 @@ var MarvinHttpClient = class extends HttpClient {
|
|
|
774
800
|
};
|
|
775
801
|
|
|
776
802
|
// src/entries/entry.ts
|
|
803
|
+
function isFullEntryData(raw) {
|
|
804
|
+
if (!raw || typeof raw !== "object") return false;
|
|
805
|
+
const record = raw;
|
|
806
|
+
if ("assetSlugs" in record || "resourceSlugs" in record) return false;
|
|
807
|
+
return Array.isArray(record.assets) || Array.isArray(record.resources);
|
|
808
|
+
}
|
|
777
809
|
var Entry = class {
|
|
778
810
|
constructor(raw) {
|
|
779
811
|
this.raw = raw;
|
|
@@ -840,6 +872,11 @@ var Entry = class {
|
|
|
840
872
|
};
|
|
841
873
|
|
|
842
874
|
// src/entries/entries.ts
|
|
875
|
+
function csv(value) {
|
|
876
|
+
if (value === void 0) return void 0;
|
|
877
|
+
const joined = (Array.isArray(value) ? value : [value]).map((v) => v.trim()).filter(Boolean).join(",");
|
|
878
|
+
return joined || void 0;
|
|
879
|
+
}
|
|
843
880
|
function toListEntry(raw) {
|
|
844
881
|
const { collections, ...rest } = raw;
|
|
845
882
|
return {
|
|
@@ -857,19 +894,24 @@ var EntriesModule = class {
|
|
|
857
894
|
}
|
|
858
895
|
http;
|
|
859
896
|
workspaceSlug;
|
|
860
|
-
/**
|
|
861
|
-
* Get all published entries
|
|
862
|
-
*/
|
|
863
897
|
async list(options = {}) {
|
|
864
898
|
const queryString = this.http.buildQueryString({
|
|
865
899
|
entry_type: options.entryType,
|
|
866
900
|
collection: options.collection,
|
|
901
|
+
tag: csv(options.tag),
|
|
902
|
+
slug: csv(options.slug),
|
|
903
|
+
updated_since: options.updatedSince instanceof Date ? options.updatedSince.toISOString() : options.updatedSince,
|
|
867
904
|
limit: options.limit,
|
|
868
|
-
offset: options.offset
|
|
905
|
+
offset: options.offset,
|
|
906
|
+
expand: options.expand
|
|
869
907
|
});
|
|
870
908
|
const endpoint = `/api/publish/${this.workspaceSlug}/entries${queryString}`;
|
|
871
909
|
const response = await this.http.fetch(endpoint);
|
|
872
|
-
|
|
910
|
+
const data = response.data || [];
|
|
911
|
+
if (options.expand === "full" && data.every(isFullEntryData)) {
|
|
912
|
+
return data.map((entry) => new Entry(entry));
|
|
913
|
+
}
|
|
914
|
+
return data.map(toListEntry);
|
|
873
915
|
}
|
|
874
916
|
/**
|
|
875
917
|
* Get a single entry by slug
|
|
@@ -999,18 +1041,25 @@ var CollectionsModule = class {
|
|
|
999
1041
|
throw error;
|
|
1000
1042
|
}
|
|
1001
1043
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
* Returns empty array if collection is not found.
|
|
1007
|
-
*/
|
|
1008
|
-
async entries(slug) {
|
|
1009
|
-
const collection = await this.get(slug);
|
|
1010
|
-
if (Array.isArray(collection)) {
|
|
1011
|
-
return collection;
|
|
1044
|
+
async entries(slug, options = {}) {
|
|
1045
|
+
if (options.expand !== "full") {
|
|
1046
|
+
const collection = await this.get(slug);
|
|
1047
|
+
return Array.isArray(collection) ? collection : collection.entries;
|
|
1012
1048
|
}
|
|
1013
|
-
|
|
1049
|
+
let data;
|
|
1050
|
+
try {
|
|
1051
|
+
data = await this.http.fetch(
|
|
1052
|
+
`/api/publish/${this.workspaceSlug}/collections/${slug}?expand=full`
|
|
1053
|
+
);
|
|
1054
|
+
} catch (error) {
|
|
1055
|
+
if (error instanceof MarvinNotFoundError) return [];
|
|
1056
|
+
throw error;
|
|
1057
|
+
}
|
|
1058
|
+
const entries = data.entries ?? [];
|
|
1059
|
+
if (entries.every(isFullEntryData)) {
|
|
1060
|
+
return data.entries.map((entry) => new Entry(entry));
|
|
1061
|
+
}
|
|
1062
|
+
return new Collection(data).entries;
|
|
1014
1063
|
}
|
|
1015
1064
|
/**
|
|
1016
1065
|
* Try multiple collection slugs in fallback order.
|
|
@@ -1064,6 +1113,14 @@ var AssetsModule = class {
|
|
|
1064
1113
|
const endpoint = `/api/publish/${this.workspaceSlug}/assets/${slugOrId}`;
|
|
1065
1114
|
return this.http.fetch(endpoint);
|
|
1066
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Download a published asset's file by slug: its bytes and content type. The file route
|
|
1118
|
+
* redirects to storage; the redirect is followed. Needs the `read:assets` permission.
|
|
1119
|
+
*/
|
|
1120
|
+
async download(slug) {
|
|
1121
|
+
const validSlug = this.http.validatePathParam(slug, "asset slug");
|
|
1122
|
+
return this.http.getBinary(`/api/publish/${this.workspaceSlug}/assets/${validSlug}/file`);
|
|
1123
|
+
}
|
|
1067
1124
|
/**
|
|
1068
1125
|
* Convenience: Get all images
|
|
1069
1126
|
*/
|
|
@@ -1449,6 +1506,7 @@ function createMarvinClient(config) {
|
|
|
1449
1506
|
createMarvinClient,
|
|
1450
1507
|
createPaginatedResponse,
|
|
1451
1508
|
extractData,
|
|
1509
|
+
isFullEntryData,
|
|
1452
1510
|
isPaginatedResponse,
|
|
1453
1511
|
offsetToPage,
|
|
1454
1512
|
pageToOffset
|
package/dist/publish.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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,
|
|
4
|
-
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient,
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-gZtGa576.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-gZtGa576.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
|
+
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, b as HttpClientConfig } from './HttpClient-DXMNOPqu.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Publishing API Entry Point
|
package/dist/publish.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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,
|
|
4
|
-
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient,
|
|
1
|
+
import { M as MarvinConfig, a as MarvinClient } from './marvin-CdsjwIyH.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-CdsjwIyH.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
|
+
export { A as AuthStrategy, B as BearerTokenAuth, H as HttpClient, b as HttpClientConfig } from './HttpClient-DXMNOPqu.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Publishing API Entry Point
|
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-KXI2FQSO.js";
|
|
16
17
|
import {
|
|
17
18
|
BearerTokenAuth,
|
|
18
19
|
HttpClient,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
isPaginatedResponse,
|
|
33
34
|
offsetToPage,
|
|
34
35
|
pageToOffset
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-LTX3MAUE.js";
|
|
36
37
|
|
|
37
38
|
// src/publish.ts
|
|
38
39
|
init_marvin();
|
|
@@ -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';
|