@lumibase/sdk 0.19.0 → 0.21.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/index.cjs CHANGED
@@ -27,9 +27,11 @@ __export(index_exports, {
27
27
  checkCdcPipelineHealth: () => checkCdcPipelineHealth,
28
28
  createAgentArtifact: () => createAgentArtifact,
29
29
  createAgentGoal: () => createAgentGoal,
30
+ createBookmark: () => createBookmark,
30
31
  createCdcPipeline: () => createCdcPipeline,
31
32
  createLumiClient: () => createLumiClient,
32
33
  decideAgentApproval: () => decideAgentApproval,
34
+ deleteBookmark: () => deleteBookmark,
33
35
  deleteCdcPipeline: () => deleteCdcPipeline,
34
36
  deployCdc: () => deployCdc,
35
37
  dryRunAccessImport: () => dryRunAccessImport,
@@ -38,6 +40,7 @@ __export(index_exports, {
38
40
  extractSeo: () => extractSeo,
39
41
  generateAgentApp: () => generateAgentApp,
40
42
  generateTypes: () => generateTypes,
43
+ getEffectivePreset: () => getEffectivePreset,
41
44
  graphql: () => graphql,
42
45
  importAccessManifest: () => importAccessManifest,
43
46
  jsonLdScript: () => jsonLdScript,
@@ -47,7 +50,9 @@ __export(index_exports, {
47
50
  listAgentGoals: () => listAgentGoals,
48
51
  listAgentRuns: () => listAgentRuns,
49
52
  listAgentTools: () => listAgentTools,
53
+ listBookmarks: () => listBookmarks,
50
54
  listCdcPipelines: () => listCdcPipelines,
55
+ mediaUrl: () => mediaUrl,
51
56
  publishAgentArtifact: () => publishAgentArtifact,
52
57
  readAgentMemoryContext: () => readAgentMemoryContext,
53
58
  readCdcPipeline: () => readCdcPipeline,
@@ -58,10 +63,12 @@ __export(index_exports, {
58
63
  retryAgentRun: () => retryAgentRun,
59
64
  rollbackAgentArtifact: () => rollbackAgentArtifact,
60
65
  rollbackCdcDeployment: () => rollbackCdcDeployment,
66
+ saveUserView: () => saveUserView,
61
67
  search: () => search,
62
68
  startCdcPipeline: () => startCdcPipeline,
63
69
  stopCdcPipeline: () => stopCdcPipeline,
64
70
  toNextMetadata: () => toNextMetadata,
71
+ updateBookmark: () => updateBookmark,
65
72
  updateCdcPipeline: () => updateCdcPipeline,
66
73
  validateCdcDeploymentEnv: () => validateCdcDeploymentEnv,
67
74
  writeAgentMemory: () => writeAgentMemory
@@ -104,12 +111,52 @@ function toErrorBody(status, body) {
104
111
  function createLumiClient(opts) {
105
112
  const fetcher = opts.fetcher ?? globalThis.fetch;
106
113
  const base = opts.url.replace(/\/$/, "");
107
- async function rawRequest(path, init = {}) {
114
+ let currentToken = opts.token;
115
+ let currentRefreshToken = opts.refreshToken;
116
+ let refreshInFlight = null;
117
+ async function attemptRefresh() {
118
+ if (!currentRefreshToken) return false;
119
+ if (!refreshInFlight) {
120
+ refreshInFlight = (async () => {
121
+ try {
122
+ const res = await fetcher(`${base}/api/v1/auth/refresh`, {
123
+ method: "POST",
124
+ headers: {
125
+ "content-type": "application/json",
126
+ "x-lumi-site": opts.siteId
127
+ },
128
+ // Body transport is CSRF-exempt (the token isn't ambient).
129
+ body: JSON.stringify({ refreshToken: currentRefreshToken })
130
+ });
131
+ if (!res.ok) return false;
132
+ const data = parseResponseBody(await res.text())?.data;
133
+ if (!data?.token || !data.refreshToken) return false;
134
+ currentToken = data.token;
135
+ currentRefreshToken = data.refreshToken;
136
+ try {
137
+ opts.onTokensRefreshed?.({
138
+ token: data.token,
139
+ refreshToken: data.refreshToken,
140
+ refreshTokenExpiresAt: data.refreshTokenExpiresAt
141
+ });
142
+ } catch {
143
+ }
144
+ return true;
145
+ } catch {
146
+ return false;
147
+ } finally {
148
+ refreshInFlight = null;
149
+ }
150
+ })();
151
+ }
152
+ return refreshInFlight;
153
+ }
154
+ async function rawRequest(path, init = {}, retried = false) {
108
155
  const headers = new Headers(init.headers);
109
156
  for (const [key, value] of Object.entries(opts.headers ?? {})) {
110
157
  headers.set(key, value);
111
158
  }
112
- headers.set("authorization", `Bearer ${opts.token}`);
159
+ headers.set("authorization", `Bearer ${currentToken}`);
113
160
  headers.set("x-lumi-site", opts.siteId);
114
161
  if (!headers.has("content-type") && init.body) {
115
162
  headers.set("content-type", "application/json");
@@ -118,6 +165,11 @@ function createLumiClient(opts) {
118
165
  const text = await res.text();
119
166
  const body = parseResponseBody(text);
120
167
  if (!res.ok) {
168
+ if (res.status === 401 && !retried && currentRefreshToken && path !== "/api/v1/auth/refresh") {
169
+ if (await attemptRefresh()) {
170
+ return rawRequest(path, init, true);
171
+ }
172
+ }
121
173
  if (res.status === 401 && opts.onUnauthorized) {
122
174
  try {
123
175
  opts.onUnauthorized();
@@ -130,7 +182,9 @@ function createLumiClient(opts) {
130
182
  }
131
183
  const baseClient = {
132
184
  url: opts.url,
133
- token: opts.token,
185
+ get token() {
186
+ return currentToken;
187
+ },
134
188
  siteId: opts.siteId,
135
189
  fetcher,
136
190
  rawRequest,
@@ -1118,6 +1172,79 @@ function legacyRest() {
1118
1172
  };
1119
1173
  }
1120
1174
 
1175
+ // src/rest/gaps.ts
1176
+ function getEffectivePreset(collection) {
1177
+ return async (client) => {
1178
+ const res = await client.rawRequest(
1179
+ `/api/v1/presets/effective?collection=${encodeURIComponent(collection)}`
1180
+ );
1181
+ return res.data;
1182
+ };
1183
+ }
1184
+ function listBookmarks(collection) {
1185
+ return async (client) => {
1186
+ const res = await client.rawRequest(
1187
+ `/api/v1/presets/bookmarks?collection=${encodeURIComponent(collection)}`
1188
+ );
1189
+ return res.data;
1190
+ };
1191
+ }
1192
+ function saveUserView(input) {
1193
+ return async (client) => {
1194
+ const res = await client.rawRequest("/api/v1/presets", {
1195
+ method: "POST",
1196
+ body: JSON.stringify({ ...input, bookmark: null })
1197
+ });
1198
+ return res.data;
1199
+ };
1200
+ }
1201
+ function createBookmark(input) {
1202
+ return async (client) => {
1203
+ const res = await client.rawRequest("/api/v1/presets", {
1204
+ method: "POST",
1205
+ body: JSON.stringify(input)
1206
+ });
1207
+ return res.data;
1208
+ };
1209
+ }
1210
+ function updateBookmark(id, input) {
1211
+ return async (client) => {
1212
+ const res = await client.rawRequest(`/api/v1/presets/${encodeURIComponent(id)}`, {
1213
+ method: "PATCH",
1214
+ body: JSON.stringify(input)
1215
+ });
1216
+ return res.data;
1217
+ };
1218
+ }
1219
+ function deleteBookmark(id) {
1220
+ return async (client) => {
1221
+ const res = await client.rawRequest(`/api/v1/presets/${encodeURIComponent(id)}`, {
1222
+ method: "DELETE"
1223
+ });
1224
+ return res.data;
1225
+ };
1226
+ }
1227
+ function mediaUrl(key, transform, opts) {
1228
+ return (client) => {
1229
+ const base = client.url.replace(/\/$/, "");
1230
+ const path = `/api/v1/media/${key.split("/").map(encodeURIComponent).join("/")}`;
1231
+ if (!transform) return `${base}${path}`;
1232
+ const qs = new URLSearchParams();
1233
+ if ("preset" in transform) {
1234
+ qs.set("preset", transform.preset);
1235
+ } else {
1236
+ if (transform.width !== void 0) qs.set("width", String(transform.width));
1237
+ if (transform.height !== void 0) qs.set("height", String(transform.height));
1238
+ if (transform.format) qs.set("format", transform.format);
1239
+ if (transform.quality !== void 0) qs.set("quality", String(transform.quality));
1240
+ if (transform.fit) qs.set("fit", transform.fit);
1241
+ if (opts?.sign) qs.set("sig", opts.sign);
1242
+ }
1243
+ const query = qs.toString();
1244
+ return query ? `${base}${path}?${query}` : `${base}${path}`;
1245
+ };
1246
+ }
1247
+
1121
1248
  // src/rest/index.ts
1122
1249
  function search(query, params) {
1123
1250
  return async (client) => {
@@ -1141,6 +1268,7 @@ function readItems(collection, params) {
1141
1268
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
1142
1269
  if (params?.offset !== void 0) qs.set("offset", String(params.offset));
1143
1270
  if (params?.status) qs.set("status", params.status);
1271
+ if (params?.meta) qs.set("meta", params.meta);
1144
1272
  const s = qs.toString();
1145
1273
  const query = s ? `?${s}` : "";
1146
1274
  const res = await client.rawRequest(`/api/v1/items/${collection}${query}`);
@@ -1592,9 +1720,11 @@ function jsonLdScript(item) {
1592
1720
  checkCdcPipelineHealth,
1593
1721
  createAgentArtifact,
1594
1722
  createAgentGoal,
1723
+ createBookmark,
1595
1724
  createCdcPipeline,
1596
1725
  createLumiClient,
1597
1726
  decideAgentApproval,
1727
+ deleteBookmark,
1598
1728
  deleteCdcPipeline,
1599
1729
  deployCdc,
1600
1730
  dryRunAccessImport,
@@ -1603,6 +1733,7 @@ function jsonLdScript(item) {
1603
1733
  extractSeo,
1604
1734
  generateAgentApp,
1605
1735
  generateTypes,
1736
+ getEffectivePreset,
1606
1737
  graphql,
1607
1738
  importAccessManifest,
1608
1739
  jsonLdScript,
@@ -1612,7 +1743,9 @@ function jsonLdScript(item) {
1612
1743
  listAgentGoals,
1613
1744
  listAgentRuns,
1614
1745
  listAgentTools,
1746
+ listBookmarks,
1615
1747
  listCdcPipelines,
1748
+ mediaUrl,
1616
1749
  publishAgentArtifact,
1617
1750
  readAgentMemoryContext,
1618
1751
  readCdcPipeline,
@@ -1623,10 +1756,12 @@ function jsonLdScript(item) {
1623
1756
  retryAgentRun,
1624
1757
  rollbackAgentArtifact,
1625
1758
  rollbackCdcDeployment,
1759
+ saveUserView,
1626
1760
  search,
1627
1761
  startCdcPipeline,
1628
1762
  stopCdcPipeline,
1629
1763
  toNextMetadata,
1764
+ updateBookmark,
1630
1765
  updateCdcPipeline,
1631
1766
  validateCdcDeploymentEnv,
1632
1767
  writeAgentMemory
package/dist/index.d.cts CHANGED
@@ -377,6 +377,12 @@ interface ListItemsParams {
377
377
  limit?: number;
378
378
  offset?: number;
379
379
  status?: string | null;
380
+ /**
381
+ * Controls whether the server computes the `count(*)` total. `'total_count'`
382
+ * (default) returns `meta.total`; `'none'` skips the extra aggregate query
383
+ * for a cheaper list (e.g. infinite scroll) and omits `meta.total`.
384
+ */
385
+ meta?: 'total_count' | 'none';
380
386
  }
381
387
  /** Reserved metadata attributes present on every search hit. */
382
388
  interface SearchHitMeta {
@@ -1365,8 +1371,29 @@ interface LumiClientOptions {
1365
1371
  * is thrown so a host (e.g. Studio) can clear the stale token and route
1366
1372
  * the operator back to the login screen. Errors thrown by the callback
1367
1373
  * are swallowed so they never mask the original `LumiError`.
1374
+ *
1375
+ * When auto-refresh is enabled (see `refreshToken`), `onUnauthorized`
1376
+ * fires only AFTER a refresh attempt has also failed.
1368
1377
  */
1369
1378
  onUnauthorized?: () => void;
1379
+ /**
1380
+ * Rotating refresh token (body transport). When set, a `401` triggers a
1381
+ * single `POST /api/v1/auth/refresh` with this token; on success the new
1382
+ * access token is adopted and the original request is retried once. The
1383
+ * refresh token rotates each call, so the new pair is surfaced via
1384
+ * {@link onTokensRefreshed} for the host to persist. Omit to keep the
1385
+ * legacy behaviour (no retry; `onUnauthorized` fires immediately).
1386
+ */
1387
+ refreshToken?: string;
1388
+ /**
1389
+ * Called after a successful silent refresh with the rotated token pair so
1390
+ * the host can persist them (the old refresh token is now revoked).
1391
+ */
1392
+ onTokensRefreshed?: (tokens: {
1393
+ token: string;
1394
+ refreshToken: string;
1395
+ refreshTokenExpiresAt?: string;
1396
+ }) => void;
1370
1397
  }
1371
1398
  interface LumiResponse<T> {
1372
1399
  data: T;
@@ -1997,6 +2024,66 @@ declare function legacyRest(): <TSchema extends DefaultSchema>(client: LumiClien
1997
2024
  request: <T>(path: string, init?: RequestInit) => Promise<LumiResponse<T>>;
1998
2025
  };
1999
2026
 
2027
+ /**
2028
+ * SDK commands for view presets (presets-inheritance) and media transform URLs
2029
+ * (image-transform-dsl). Each is a command factory `(client) => Promise<T>`
2030
+ * used with `client.request(...)`, matching the rest of the REST module.
2031
+ *
2032
+ * Content-version and translation-memory helpers live in the core SDK
2033
+ * (`client.items(...).versions` and `client.tm`).
2034
+ */
2035
+
2036
+ type PresetScope = "user" | "role" | "global";
2037
+ interface ViewPreset {
2038
+ id: string;
2039
+ bookmark: string | null;
2040
+ collection: string;
2041
+ userId: string | null;
2042
+ roleId: string | null;
2043
+ layout: string;
2044
+ layoutQuery: Record<string, unknown>;
2045
+ layoutOptions: Record<string, unknown>;
2046
+ search: string | null;
2047
+ filter: Record<string, unknown>;
2048
+ icon: string | null;
2049
+ color: string | null;
2050
+ refreshInterval: number;
2051
+ }
2052
+ interface ScopedViewPreset extends ViewPreset {
2053
+ sourceScope: PresetScope;
2054
+ roleDistance?: number;
2055
+ }
2056
+ declare function getEffectivePreset(collection: string): (client: LumiClient) => Promise<ScopedViewPreset | null>;
2057
+ declare function listBookmarks(collection: string): (client: LumiClient) => Promise<ScopedViewPreset[]>;
2058
+ /** Save (or overwrite) the acting user's default view for a collection. */
2059
+ declare function saveUserView(input: Partial<ViewPreset> & {
2060
+ collection: string;
2061
+ }): (client: LumiClient) => Promise<ViewPreset>;
2062
+ declare function createBookmark(input: Partial<ViewPreset> & {
2063
+ collection: string;
2064
+ bookmark: string;
2065
+ }): (client: LumiClient) => Promise<ViewPreset>;
2066
+ declare function updateBookmark(id: string, input: Partial<ViewPreset>): (client: LumiClient) => Promise<ViewPreset>;
2067
+ declare function deleteBookmark(id: string): (client: LumiClient) => Promise<null>;
2068
+ interface MediaTransform {
2069
+ width?: number;
2070
+ height?: number;
2071
+ format?: "webp" | "avif" | "jpeg" | "png";
2072
+ quality?: number;
2073
+ fit?: "cover" | "contain" | "fill" | "inside" | "outside";
2074
+ }
2075
+ /**
2076
+ * Build a delivery URL for a media asset, optionally with a transform. Pass a
2077
+ * `MediaTransform` for inline params, or `{ preset }` to reference a named
2078
+ * server-side preset. Returns a path relative to the API base — the SDK client
2079
+ * resolves it against its configured URL.
2080
+ */
2081
+ declare function mediaUrl(key: string, transform?: MediaTransform | {
2082
+ preset: string;
2083
+ }, opts?: {
2084
+ sign?: string;
2085
+ }): (client: LumiClient) => string;
2086
+
2000
2087
  /**
2001
2088
  * Full-text search via `GET /api/v1/search`. Omit `params.collection` for a
2002
2089
  * cross-collection (global) search that fans out over every collection of the
@@ -2129,4 +2216,4 @@ declare function toNextMetadata(item: unknown): Record<string, unknown>;
2129
2216
  */
2130
2217
  declare function jsonLdScript(item: unknown): string | undefined;
2131
2218
 
2132
- export { ACCESS_EXPORT_SCHEMA, type AIApproval, type AIApprovalStatus, type AIChatResponse, type AIChatStatus, type AIContentAssistResult, type AIConversation, type AIFieldSuggestion, type AIMessage, type AccessConflict, type AccessConflictCheckInput, type AccessConflictReport, type AccessExportApiKey, type AccessExportBindings, type AccessExportManifest, type AccessExportPermission, type AccessExportPolicy, type AccessExportRole, type AccessImportApplyResult, type AccessImportDiff, type AccessImportDiffEntry, type AccessImportDiffSection, type AccessImportDryRunResult, type AccessImportIssue, type AccessImportMode, type AccessImportOptions, type AccessImportSummary, type ActivityResource, type AgentApprovalResource, type AgentArtifactCreateInput, type AgentArtifactResource, type AgentArtifactType, type AgentEvaluationResource, type AgentGenerateAppInput, type AgentGenerateAppResult, type AgentGoalCreateInput, type AgentGoalResource, type AgentMemoryContext, type AgentMemoryResource, type AgentMemoryWriteInput, type AgentRiskLevel, type AgentRunResource, type AgentToolResource, type ApiKeyCreateInput, type ApiKeyPolicyAttachment, type ApiKeyResource, type ApiKeyRoleAttachment, type ApiKeyRotateInput, type ApiKeySecretResult, AudienceClient, type AudienceClientOptions, type AudienceEvent, type AudienceNotification, type Brand, type CdcConnectorType, type CdcDeployInput, type CdcDeploymentResult, type CdcDeploymentStatus, type CdcDeploymentStep, type CdcDeploymentTarget, type CdcEnvValidationResult, type CdcHealthCheckResult, type CdcHealthMetricEntry, type CdcPipelineCreateInput, type CdcPipelineMetrics, type CdcPipelinePatchInput, type CdcPipelineResource, type CdcPipelineStatus, type CdcRollbackResult, type CdcValidateEnvInput, type ChannelEventCallback, type CollectionInput, type CollectionResource, type CompiledPermission, type ConnectionStatus, type ContentVersion, type CreateSCIMTokenParams, type DefaultSchema, type DeliverySeo, type DeploymentResource, type DeploymentTargetResource, type DomainCreateInput, type DomainResource, type DomainVerificationRecord, type ExtensionResource, type FieldDeleteOptions, type FieldInput, type FieldMutationOptions, type FieldRenameInput, type FieldResource, type FileResource, type FlowGraph, type FlowNode, type FlowResource, type FlowRun, type FlowRunResult, type FlowRunStatus, type FlowStatus, type FlowTriggerType, type FolderResource, type GenerateOptions, type GraphQLExtension, type ID, type ItemFilter, type ItemFilterOp, type ItemRow, type ListItemsParams, type ListItemsResponse, type ListMarketplaceExtensionsParams, type Locale, type LumiClient, type LumiClientOptions, LumiError, type LumiErrorBody, type LumiResponse, type MarketplaceExtension, type MarketplaceListResponse, type MaterializeDataResponse, type MaterializeProjection, type MaterializeRefreshResult, type MaterializeRefreshStrategy, type MaterializedCollection, type NotificationCallback, type PermissionAction, type PermissionBundle, type PermissionCheckResult, type PermissionRow, type PolicyDetail, type PolicyResource, type PresenceCallback, type PresenceEntry, type PresetResource, type PrimaryKeyType, RealtimeClient, type RealtimeEvent, type RealtimeEventCallback, type RelationInput, type RelationResource, type RelationType, type RevisionRow, type RoleDetail, type RoleResource, type SCIMTokenCreated, type SCIMTokenMeta, type SCIMTokenRotated, type SchemaApplyInput, type SchemaApplyResult, type SchemaChangedEvent, type SchemaDiff, type SchemaDiffEntry, type SchemaDiffInput, type SchemaDiffRisk, type SchemaRuntimeImpact, type SearchHit, type SearchHitMeta, type SearchParams, type SearchResponse, type SettingResource, type ShareCreateInput, type ShareResource, type ShareSecretResult, type SiteConfigUpdate, type SiteResource, type StatusCallback, type StorageMode, type TeamMemberResource, type TeamResource, type TmEntry, type TmSource, type TmSuggestion, type TranslationResource, type TypegenCollection, type TypegenField, type TypegenManifest, type TypegenRelation, type TypegenSchemaFilters, type UploadConfigResource, type UploadTypeCatalogueEntry, type UserPreferencesPayload, type UserResource, type VersionCompare, type VersionFieldChange, type WebSocketFactory, type WebSocketLike, type WebhookResource, checkCdcPipelineHealth, createAgentArtifact, createAgentGoal, createCdcPipeline, createLumiClient, decideAgentApproval, deleteCdcPipeline, deployCdc, dryRunAccessImport, evaluateAgentArtifact, exportAccessManifest, extractSeo, generateAgentApp, generateTypes, graphql, importAccessManifest, jsonLdScript, legacyRest, listAgentApprovals, listAgentArtifacts, listAgentGoals, listAgentRuns, listAgentTools, listCdcPipelines, publishAgentArtifact, readAgentMemoryContext, readCdcPipeline, readCdcPipelineMetricHistory, readCdcPipelineMetrics, readItem, readItems, retryAgentRun, rollbackAgentArtifact, rollbackCdcDeployment, search, startCdcPipeline, stopCdcPipeline, toNextMetadata, updateCdcPipeline, validateCdcDeploymentEnv, writeAgentMemory };
2219
+ export { ACCESS_EXPORT_SCHEMA, type AIApproval, type AIApprovalStatus, type AIChatResponse, type AIChatStatus, type AIContentAssistResult, type AIConversation, type AIFieldSuggestion, type AIMessage, type AccessConflict, type AccessConflictCheckInput, type AccessConflictReport, type AccessExportApiKey, type AccessExportBindings, type AccessExportManifest, type AccessExportPermission, type AccessExportPolicy, type AccessExportRole, type AccessImportApplyResult, type AccessImportDiff, type AccessImportDiffEntry, type AccessImportDiffSection, type AccessImportDryRunResult, type AccessImportIssue, type AccessImportMode, type AccessImportOptions, type AccessImportSummary, type ActivityResource, type AgentApprovalResource, type AgentArtifactCreateInput, type AgentArtifactResource, type AgentArtifactType, type AgentEvaluationResource, type AgentGenerateAppInput, type AgentGenerateAppResult, type AgentGoalCreateInput, type AgentGoalResource, type AgentMemoryContext, type AgentMemoryResource, type AgentMemoryWriteInput, type AgentRiskLevel, type AgentRunResource, type AgentToolResource, type ApiKeyCreateInput, type ApiKeyPolicyAttachment, type ApiKeyResource, type ApiKeyRoleAttachment, type ApiKeyRotateInput, type ApiKeySecretResult, AudienceClient, type AudienceClientOptions, type AudienceEvent, type AudienceNotification, type Brand, type CdcConnectorType, type CdcDeployInput, type CdcDeploymentResult, type CdcDeploymentStatus, type CdcDeploymentStep, type CdcDeploymentTarget, type CdcEnvValidationResult, type CdcHealthCheckResult, type CdcHealthMetricEntry, type CdcPipelineCreateInput, type CdcPipelineMetrics, type CdcPipelinePatchInput, type CdcPipelineResource, type CdcPipelineStatus, type CdcRollbackResult, type CdcValidateEnvInput, type ChannelEventCallback, type CollectionInput, type CollectionResource, type CompiledPermission, type ConnectionStatus, type ContentVersion, type CreateSCIMTokenParams, type DefaultSchema, type DeliverySeo, type DeploymentResource, type DeploymentTargetResource, type DomainCreateInput, type DomainResource, type DomainVerificationRecord, type ExtensionResource, type FieldDeleteOptions, type FieldInput, type FieldMutationOptions, type FieldRenameInput, type FieldResource, type FileResource, type FlowGraph, type FlowNode, type FlowResource, type FlowRun, type FlowRunResult, type FlowRunStatus, type FlowStatus, type FlowTriggerType, type FolderResource, type GenerateOptions, type GraphQLExtension, type ID, type ItemFilter, type ItemFilterOp, type ItemRow, type ListItemsParams, type ListItemsResponse, type ListMarketplaceExtensionsParams, type Locale, type LumiClient, type LumiClientOptions, LumiError, type LumiErrorBody, type LumiResponse, type MarketplaceExtension, type MarketplaceListResponse, type MaterializeDataResponse, type MaterializeProjection, type MaterializeRefreshResult, type MaterializeRefreshStrategy, type MaterializedCollection, type MediaTransform, type NotificationCallback, type PermissionAction, type PermissionBundle, type PermissionCheckResult, type PermissionRow, type PolicyDetail, type PolicyResource, type PresenceCallback, type PresenceEntry, type PresetResource, type PresetScope, type PrimaryKeyType, RealtimeClient, type RealtimeEvent, type RealtimeEventCallback, type RelationInput, type RelationResource, type RelationType, type RevisionRow, type RoleDetail, type RoleResource, type SCIMTokenCreated, type SCIMTokenMeta, type SCIMTokenRotated, type SchemaApplyInput, type SchemaApplyResult, type SchemaChangedEvent, type SchemaDiff, type SchemaDiffEntry, type SchemaDiffInput, type SchemaDiffRisk, type SchemaRuntimeImpact, type ScopedViewPreset, type SearchHit, type SearchHitMeta, type SearchParams, type SearchResponse, type SettingResource, type ShareCreateInput, type ShareResource, type ShareSecretResult, type SiteConfigUpdate, type SiteResource, type StatusCallback, type StorageMode, type TeamMemberResource, type TeamResource, type TmEntry, type TmSource, type TmSuggestion, type TranslationResource, type TypegenCollection, type TypegenField, type TypegenManifest, type TypegenRelation, type TypegenSchemaFilters, type UploadConfigResource, type UploadTypeCatalogueEntry, type UserPreferencesPayload, type UserResource, type VersionCompare, type VersionFieldChange, type ViewPreset, type WebSocketFactory, type WebSocketLike, type WebhookResource, checkCdcPipelineHealth, createAgentArtifact, createAgentGoal, createBookmark, createCdcPipeline, createLumiClient, decideAgentApproval, deleteBookmark, deleteCdcPipeline, deployCdc, dryRunAccessImport, evaluateAgentArtifact, exportAccessManifest, extractSeo, generateAgentApp, generateTypes, getEffectivePreset, graphql, importAccessManifest, jsonLdScript, legacyRest, listAgentApprovals, listAgentArtifacts, listAgentGoals, listAgentRuns, listAgentTools, listBookmarks, listCdcPipelines, mediaUrl, publishAgentArtifact, readAgentMemoryContext, readCdcPipeline, readCdcPipelineMetricHistory, readCdcPipelineMetrics, readItem, readItems, retryAgentRun, rollbackAgentArtifact, rollbackCdcDeployment, saveUserView, search, startCdcPipeline, stopCdcPipeline, toNextMetadata, updateBookmark, updateCdcPipeline, validateCdcDeploymentEnv, writeAgentMemory };
package/dist/index.d.ts CHANGED
@@ -377,6 +377,12 @@ interface ListItemsParams {
377
377
  limit?: number;
378
378
  offset?: number;
379
379
  status?: string | null;
380
+ /**
381
+ * Controls whether the server computes the `count(*)` total. `'total_count'`
382
+ * (default) returns `meta.total`; `'none'` skips the extra aggregate query
383
+ * for a cheaper list (e.g. infinite scroll) and omits `meta.total`.
384
+ */
385
+ meta?: 'total_count' | 'none';
380
386
  }
381
387
  /** Reserved metadata attributes present on every search hit. */
382
388
  interface SearchHitMeta {
@@ -1365,8 +1371,29 @@ interface LumiClientOptions {
1365
1371
  * is thrown so a host (e.g. Studio) can clear the stale token and route
1366
1372
  * the operator back to the login screen. Errors thrown by the callback
1367
1373
  * are swallowed so they never mask the original `LumiError`.
1374
+ *
1375
+ * When auto-refresh is enabled (see `refreshToken`), `onUnauthorized`
1376
+ * fires only AFTER a refresh attempt has also failed.
1368
1377
  */
1369
1378
  onUnauthorized?: () => void;
1379
+ /**
1380
+ * Rotating refresh token (body transport). When set, a `401` triggers a
1381
+ * single `POST /api/v1/auth/refresh` with this token; on success the new
1382
+ * access token is adopted and the original request is retried once. The
1383
+ * refresh token rotates each call, so the new pair is surfaced via
1384
+ * {@link onTokensRefreshed} for the host to persist. Omit to keep the
1385
+ * legacy behaviour (no retry; `onUnauthorized` fires immediately).
1386
+ */
1387
+ refreshToken?: string;
1388
+ /**
1389
+ * Called after a successful silent refresh with the rotated token pair so
1390
+ * the host can persist them (the old refresh token is now revoked).
1391
+ */
1392
+ onTokensRefreshed?: (tokens: {
1393
+ token: string;
1394
+ refreshToken: string;
1395
+ refreshTokenExpiresAt?: string;
1396
+ }) => void;
1370
1397
  }
1371
1398
  interface LumiResponse<T> {
1372
1399
  data: T;
@@ -1997,6 +2024,66 @@ declare function legacyRest(): <TSchema extends DefaultSchema>(client: LumiClien
1997
2024
  request: <T>(path: string, init?: RequestInit) => Promise<LumiResponse<T>>;
1998
2025
  };
1999
2026
 
2027
+ /**
2028
+ * SDK commands for view presets (presets-inheritance) and media transform URLs
2029
+ * (image-transform-dsl). Each is a command factory `(client) => Promise<T>`
2030
+ * used with `client.request(...)`, matching the rest of the REST module.
2031
+ *
2032
+ * Content-version and translation-memory helpers live in the core SDK
2033
+ * (`client.items(...).versions` and `client.tm`).
2034
+ */
2035
+
2036
+ type PresetScope = "user" | "role" | "global";
2037
+ interface ViewPreset {
2038
+ id: string;
2039
+ bookmark: string | null;
2040
+ collection: string;
2041
+ userId: string | null;
2042
+ roleId: string | null;
2043
+ layout: string;
2044
+ layoutQuery: Record<string, unknown>;
2045
+ layoutOptions: Record<string, unknown>;
2046
+ search: string | null;
2047
+ filter: Record<string, unknown>;
2048
+ icon: string | null;
2049
+ color: string | null;
2050
+ refreshInterval: number;
2051
+ }
2052
+ interface ScopedViewPreset extends ViewPreset {
2053
+ sourceScope: PresetScope;
2054
+ roleDistance?: number;
2055
+ }
2056
+ declare function getEffectivePreset(collection: string): (client: LumiClient) => Promise<ScopedViewPreset | null>;
2057
+ declare function listBookmarks(collection: string): (client: LumiClient) => Promise<ScopedViewPreset[]>;
2058
+ /** Save (or overwrite) the acting user's default view for a collection. */
2059
+ declare function saveUserView(input: Partial<ViewPreset> & {
2060
+ collection: string;
2061
+ }): (client: LumiClient) => Promise<ViewPreset>;
2062
+ declare function createBookmark(input: Partial<ViewPreset> & {
2063
+ collection: string;
2064
+ bookmark: string;
2065
+ }): (client: LumiClient) => Promise<ViewPreset>;
2066
+ declare function updateBookmark(id: string, input: Partial<ViewPreset>): (client: LumiClient) => Promise<ViewPreset>;
2067
+ declare function deleteBookmark(id: string): (client: LumiClient) => Promise<null>;
2068
+ interface MediaTransform {
2069
+ width?: number;
2070
+ height?: number;
2071
+ format?: "webp" | "avif" | "jpeg" | "png";
2072
+ quality?: number;
2073
+ fit?: "cover" | "contain" | "fill" | "inside" | "outside";
2074
+ }
2075
+ /**
2076
+ * Build a delivery URL for a media asset, optionally with a transform. Pass a
2077
+ * `MediaTransform` for inline params, or `{ preset }` to reference a named
2078
+ * server-side preset. Returns a path relative to the API base — the SDK client
2079
+ * resolves it against its configured URL.
2080
+ */
2081
+ declare function mediaUrl(key: string, transform?: MediaTransform | {
2082
+ preset: string;
2083
+ }, opts?: {
2084
+ sign?: string;
2085
+ }): (client: LumiClient) => string;
2086
+
2000
2087
  /**
2001
2088
  * Full-text search via `GET /api/v1/search`. Omit `params.collection` for a
2002
2089
  * cross-collection (global) search that fans out over every collection of the
@@ -2129,4 +2216,4 @@ declare function toNextMetadata(item: unknown): Record<string, unknown>;
2129
2216
  */
2130
2217
  declare function jsonLdScript(item: unknown): string | undefined;
2131
2218
 
2132
- export { ACCESS_EXPORT_SCHEMA, type AIApproval, type AIApprovalStatus, type AIChatResponse, type AIChatStatus, type AIContentAssistResult, type AIConversation, type AIFieldSuggestion, type AIMessage, type AccessConflict, type AccessConflictCheckInput, type AccessConflictReport, type AccessExportApiKey, type AccessExportBindings, type AccessExportManifest, type AccessExportPermission, type AccessExportPolicy, type AccessExportRole, type AccessImportApplyResult, type AccessImportDiff, type AccessImportDiffEntry, type AccessImportDiffSection, type AccessImportDryRunResult, type AccessImportIssue, type AccessImportMode, type AccessImportOptions, type AccessImportSummary, type ActivityResource, type AgentApprovalResource, type AgentArtifactCreateInput, type AgentArtifactResource, type AgentArtifactType, type AgentEvaluationResource, type AgentGenerateAppInput, type AgentGenerateAppResult, type AgentGoalCreateInput, type AgentGoalResource, type AgentMemoryContext, type AgentMemoryResource, type AgentMemoryWriteInput, type AgentRiskLevel, type AgentRunResource, type AgentToolResource, type ApiKeyCreateInput, type ApiKeyPolicyAttachment, type ApiKeyResource, type ApiKeyRoleAttachment, type ApiKeyRotateInput, type ApiKeySecretResult, AudienceClient, type AudienceClientOptions, type AudienceEvent, type AudienceNotification, type Brand, type CdcConnectorType, type CdcDeployInput, type CdcDeploymentResult, type CdcDeploymentStatus, type CdcDeploymentStep, type CdcDeploymentTarget, type CdcEnvValidationResult, type CdcHealthCheckResult, type CdcHealthMetricEntry, type CdcPipelineCreateInput, type CdcPipelineMetrics, type CdcPipelinePatchInput, type CdcPipelineResource, type CdcPipelineStatus, type CdcRollbackResult, type CdcValidateEnvInput, type ChannelEventCallback, type CollectionInput, type CollectionResource, type CompiledPermission, type ConnectionStatus, type ContentVersion, type CreateSCIMTokenParams, type DefaultSchema, type DeliverySeo, type DeploymentResource, type DeploymentTargetResource, type DomainCreateInput, type DomainResource, type DomainVerificationRecord, type ExtensionResource, type FieldDeleteOptions, type FieldInput, type FieldMutationOptions, type FieldRenameInput, type FieldResource, type FileResource, type FlowGraph, type FlowNode, type FlowResource, type FlowRun, type FlowRunResult, type FlowRunStatus, type FlowStatus, type FlowTriggerType, type FolderResource, type GenerateOptions, type GraphQLExtension, type ID, type ItemFilter, type ItemFilterOp, type ItemRow, type ListItemsParams, type ListItemsResponse, type ListMarketplaceExtensionsParams, type Locale, type LumiClient, type LumiClientOptions, LumiError, type LumiErrorBody, type LumiResponse, type MarketplaceExtension, type MarketplaceListResponse, type MaterializeDataResponse, type MaterializeProjection, type MaterializeRefreshResult, type MaterializeRefreshStrategy, type MaterializedCollection, type NotificationCallback, type PermissionAction, type PermissionBundle, type PermissionCheckResult, type PermissionRow, type PolicyDetail, type PolicyResource, type PresenceCallback, type PresenceEntry, type PresetResource, type PrimaryKeyType, RealtimeClient, type RealtimeEvent, type RealtimeEventCallback, type RelationInput, type RelationResource, type RelationType, type RevisionRow, type RoleDetail, type RoleResource, type SCIMTokenCreated, type SCIMTokenMeta, type SCIMTokenRotated, type SchemaApplyInput, type SchemaApplyResult, type SchemaChangedEvent, type SchemaDiff, type SchemaDiffEntry, type SchemaDiffInput, type SchemaDiffRisk, type SchemaRuntimeImpact, type SearchHit, type SearchHitMeta, type SearchParams, type SearchResponse, type SettingResource, type ShareCreateInput, type ShareResource, type ShareSecretResult, type SiteConfigUpdate, type SiteResource, type StatusCallback, type StorageMode, type TeamMemberResource, type TeamResource, type TmEntry, type TmSource, type TmSuggestion, type TranslationResource, type TypegenCollection, type TypegenField, type TypegenManifest, type TypegenRelation, type TypegenSchemaFilters, type UploadConfigResource, type UploadTypeCatalogueEntry, type UserPreferencesPayload, type UserResource, type VersionCompare, type VersionFieldChange, type WebSocketFactory, type WebSocketLike, type WebhookResource, checkCdcPipelineHealth, createAgentArtifact, createAgentGoal, createCdcPipeline, createLumiClient, decideAgentApproval, deleteCdcPipeline, deployCdc, dryRunAccessImport, evaluateAgentArtifact, exportAccessManifest, extractSeo, generateAgentApp, generateTypes, graphql, importAccessManifest, jsonLdScript, legacyRest, listAgentApprovals, listAgentArtifacts, listAgentGoals, listAgentRuns, listAgentTools, listCdcPipelines, publishAgentArtifact, readAgentMemoryContext, readCdcPipeline, readCdcPipelineMetricHistory, readCdcPipelineMetrics, readItem, readItems, retryAgentRun, rollbackAgentArtifact, rollbackCdcDeployment, search, startCdcPipeline, stopCdcPipeline, toNextMetadata, updateCdcPipeline, validateCdcDeploymentEnv, writeAgentMemory };
2219
+ export { ACCESS_EXPORT_SCHEMA, type AIApproval, type AIApprovalStatus, type AIChatResponse, type AIChatStatus, type AIContentAssistResult, type AIConversation, type AIFieldSuggestion, type AIMessage, type AccessConflict, type AccessConflictCheckInput, type AccessConflictReport, type AccessExportApiKey, type AccessExportBindings, type AccessExportManifest, type AccessExportPermission, type AccessExportPolicy, type AccessExportRole, type AccessImportApplyResult, type AccessImportDiff, type AccessImportDiffEntry, type AccessImportDiffSection, type AccessImportDryRunResult, type AccessImportIssue, type AccessImportMode, type AccessImportOptions, type AccessImportSummary, type ActivityResource, type AgentApprovalResource, type AgentArtifactCreateInput, type AgentArtifactResource, type AgentArtifactType, type AgentEvaluationResource, type AgentGenerateAppInput, type AgentGenerateAppResult, type AgentGoalCreateInput, type AgentGoalResource, type AgentMemoryContext, type AgentMemoryResource, type AgentMemoryWriteInput, type AgentRiskLevel, type AgentRunResource, type AgentToolResource, type ApiKeyCreateInput, type ApiKeyPolicyAttachment, type ApiKeyResource, type ApiKeyRoleAttachment, type ApiKeyRotateInput, type ApiKeySecretResult, AudienceClient, type AudienceClientOptions, type AudienceEvent, type AudienceNotification, type Brand, type CdcConnectorType, type CdcDeployInput, type CdcDeploymentResult, type CdcDeploymentStatus, type CdcDeploymentStep, type CdcDeploymentTarget, type CdcEnvValidationResult, type CdcHealthCheckResult, type CdcHealthMetricEntry, type CdcPipelineCreateInput, type CdcPipelineMetrics, type CdcPipelinePatchInput, type CdcPipelineResource, type CdcPipelineStatus, type CdcRollbackResult, type CdcValidateEnvInput, type ChannelEventCallback, type CollectionInput, type CollectionResource, type CompiledPermission, type ConnectionStatus, type ContentVersion, type CreateSCIMTokenParams, type DefaultSchema, type DeliverySeo, type DeploymentResource, type DeploymentTargetResource, type DomainCreateInput, type DomainResource, type DomainVerificationRecord, type ExtensionResource, type FieldDeleteOptions, type FieldInput, type FieldMutationOptions, type FieldRenameInput, type FieldResource, type FileResource, type FlowGraph, type FlowNode, type FlowResource, type FlowRun, type FlowRunResult, type FlowRunStatus, type FlowStatus, type FlowTriggerType, type FolderResource, type GenerateOptions, type GraphQLExtension, type ID, type ItemFilter, type ItemFilterOp, type ItemRow, type ListItemsParams, type ListItemsResponse, type ListMarketplaceExtensionsParams, type Locale, type LumiClient, type LumiClientOptions, LumiError, type LumiErrorBody, type LumiResponse, type MarketplaceExtension, type MarketplaceListResponse, type MaterializeDataResponse, type MaterializeProjection, type MaterializeRefreshResult, type MaterializeRefreshStrategy, type MaterializedCollection, type MediaTransform, type NotificationCallback, type PermissionAction, type PermissionBundle, type PermissionCheckResult, type PermissionRow, type PolicyDetail, type PolicyResource, type PresenceCallback, type PresenceEntry, type PresetResource, type PresetScope, type PrimaryKeyType, RealtimeClient, type RealtimeEvent, type RealtimeEventCallback, type RelationInput, type RelationResource, type RelationType, type RevisionRow, type RoleDetail, type RoleResource, type SCIMTokenCreated, type SCIMTokenMeta, type SCIMTokenRotated, type SchemaApplyInput, type SchemaApplyResult, type SchemaChangedEvent, type SchemaDiff, type SchemaDiffEntry, type SchemaDiffInput, type SchemaDiffRisk, type SchemaRuntimeImpact, type ScopedViewPreset, type SearchHit, type SearchHitMeta, type SearchParams, type SearchResponse, type SettingResource, type ShareCreateInput, type ShareResource, type ShareSecretResult, type SiteConfigUpdate, type SiteResource, type StatusCallback, type StorageMode, type TeamMemberResource, type TeamResource, type TmEntry, type TmSource, type TmSuggestion, type TranslationResource, type TypegenCollection, type TypegenField, type TypegenManifest, type TypegenRelation, type TypegenSchemaFilters, type UploadConfigResource, type UploadTypeCatalogueEntry, type UserPreferencesPayload, type UserResource, type VersionCompare, type VersionFieldChange, type ViewPreset, type WebSocketFactory, type WebSocketLike, type WebhookResource, checkCdcPipelineHealth, createAgentArtifact, createAgentGoal, createBookmark, createCdcPipeline, createLumiClient, decideAgentApproval, deleteBookmark, deleteCdcPipeline, deployCdc, dryRunAccessImport, evaluateAgentArtifact, exportAccessManifest, extractSeo, generateAgentApp, generateTypes, getEffectivePreset, graphql, importAccessManifest, jsonLdScript, legacyRest, listAgentApprovals, listAgentArtifacts, listAgentGoals, listAgentRuns, listAgentTools, listBookmarks, listCdcPipelines, mediaUrl, publishAgentArtifact, readAgentMemoryContext, readCdcPipeline, readCdcPipelineMetricHistory, readCdcPipelineMetrics, readItem, readItems, retryAgentRun, rollbackAgentArtifact, rollbackCdcDeployment, saveUserView, search, startCdcPipeline, stopCdcPipeline, toNextMetadata, updateBookmark, updateCdcPipeline, validateCdcDeploymentEnv, writeAgentMemory };
package/dist/index.js CHANGED
@@ -34,12 +34,52 @@ function toErrorBody(status, body) {
34
34
  function createLumiClient(opts) {
35
35
  const fetcher = opts.fetcher ?? globalThis.fetch;
36
36
  const base = opts.url.replace(/\/$/, "");
37
- async function rawRequest(path, init = {}) {
37
+ let currentToken = opts.token;
38
+ let currentRefreshToken = opts.refreshToken;
39
+ let refreshInFlight = null;
40
+ async function attemptRefresh() {
41
+ if (!currentRefreshToken) return false;
42
+ if (!refreshInFlight) {
43
+ refreshInFlight = (async () => {
44
+ try {
45
+ const res = await fetcher(`${base}/api/v1/auth/refresh`, {
46
+ method: "POST",
47
+ headers: {
48
+ "content-type": "application/json",
49
+ "x-lumi-site": opts.siteId
50
+ },
51
+ // Body transport is CSRF-exempt (the token isn't ambient).
52
+ body: JSON.stringify({ refreshToken: currentRefreshToken })
53
+ });
54
+ if (!res.ok) return false;
55
+ const data = parseResponseBody(await res.text())?.data;
56
+ if (!data?.token || !data.refreshToken) return false;
57
+ currentToken = data.token;
58
+ currentRefreshToken = data.refreshToken;
59
+ try {
60
+ opts.onTokensRefreshed?.({
61
+ token: data.token,
62
+ refreshToken: data.refreshToken,
63
+ refreshTokenExpiresAt: data.refreshTokenExpiresAt
64
+ });
65
+ } catch {
66
+ }
67
+ return true;
68
+ } catch {
69
+ return false;
70
+ } finally {
71
+ refreshInFlight = null;
72
+ }
73
+ })();
74
+ }
75
+ return refreshInFlight;
76
+ }
77
+ async function rawRequest(path, init = {}, retried = false) {
38
78
  const headers = new Headers(init.headers);
39
79
  for (const [key, value] of Object.entries(opts.headers ?? {})) {
40
80
  headers.set(key, value);
41
81
  }
42
- headers.set("authorization", `Bearer ${opts.token}`);
82
+ headers.set("authorization", `Bearer ${currentToken}`);
43
83
  headers.set("x-lumi-site", opts.siteId);
44
84
  if (!headers.has("content-type") && init.body) {
45
85
  headers.set("content-type", "application/json");
@@ -48,6 +88,11 @@ function createLumiClient(opts) {
48
88
  const text = await res.text();
49
89
  const body = parseResponseBody(text);
50
90
  if (!res.ok) {
91
+ if (res.status === 401 && !retried && currentRefreshToken && path !== "/api/v1/auth/refresh") {
92
+ if (await attemptRefresh()) {
93
+ return rawRequest(path, init, true);
94
+ }
95
+ }
51
96
  if (res.status === 401 && opts.onUnauthorized) {
52
97
  try {
53
98
  opts.onUnauthorized();
@@ -60,7 +105,9 @@ function createLumiClient(opts) {
60
105
  }
61
106
  const baseClient = {
62
107
  url: opts.url,
63
- token: opts.token,
108
+ get token() {
109
+ return currentToken;
110
+ },
64
111
  siteId: opts.siteId,
65
112
  fetcher,
66
113
  rawRequest,
@@ -1048,6 +1095,79 @@ function legacyRest() {
1048
1095
  };
1049
1096
  }
1050
1097
 
1098
+ // src/rest/gaps.ts
1099
+ function getEffectivePreset(collection) {
1100
+ return async (client) => {
1101
+ const res = await client.rawRequest(
1102
+ `/api/v1/presets/effective?collection=${encodeURIComponent(collection)}`
1103
+ );
1104
+ return res.data;
1105
+ };
1106
+ }
1107
+ function listBookmarks(collection) {
1108
+ return async (client) => {
1109
+ const res = await client.rawRequest(
1110
+ `/api/v1/presets/bookmarks?collection=${encodeURIComponent(collection)}`
1111
+ );
1112
+ return res.data;
1113
+ };
1114
+ }
1115
+ function saveUserView(input) {
1116
+ return async (client) => {
1117
+ const res = await client.rawRequest("/api/v1/presets", {
1118
+ method: "POST",
1119
+ body: JSON.stringify({ ...input, bookmark: null })
1120
+ });
1121
+ return res.data;
1122
+ };
1123
+ }
1124
+ function createBookmark(input) {
1125
+ return async (client) => {
1126
+ const res = await client.rawRequest("/api/v1/presets", {
1127
+ method: "POST",
1128
+ body: JSON.stringify(input)
1129
+ });
1130
+ return res.data;
1131
+ };
1132
+ }
1133
+ function updateBookmark(id, input) {
1134
+ return async (client) => {
1135
+ const res = await client.rawRequest(`/api/v1/presets/${encodeURIComponent(id)}`, {
1136
+ method: "PATCH",
1137
+ body: JSON.stringify(input)
1138
+ });
1139
+ return res.data;
1140
+ };
1141
+ }
1142
+ function deleteBookmark(id) {
1143
+ return async (client) => {
1144
+ const res = await client.rawRequest(`/api/v1/presets/${encodeURIComponent(id)}`, {
1145
+ method: "DELETE"
1146
+ });
1147
+ return res.data;
1148
+ };
1149
+ }
1150
+ function mediaUrl(key, transform, opts) {
1151
+ return (client) => {
1152
+ const base = client.url.replace(/\/$/, "");
1153
+ const path = `/api/v1/media/${key.split("/").map(encodeURIComponent).join("/")}`;
1154
+ if (!transform) return `${base}${path}`;
1155
+ const qs = new URLSearchParams();
1156
+ if ("preset" in transform) {
1157
+ qs.set("preset", transform.preset);
1158
+ } else {
1159
+ if (transform.width !== void 0) qs.set("width", String(transform.width));
1160
+ if (transform.height !== void 0) qs.set("height", String(transform.height));
1161
+ if (transform.format) qs.set("format", transform.format);
1162
+ if (transform.quality !== void 0) qs.set("quality", String(transform.quality));
1163
+ if (transform.fit) qs.set("fit", transform.fit);
1164
+ if (opts?.sign) qs.set("sig", opts.sign);
1165
+ }
1166
+ const query = qs.toString();
1167
+ return query ? `${base}${path}?${query}` : `${base}${path}`;
1168
+ };
1169
+ }
1170
+
1051
1171
  // src/rest/index.ts
1052
1172
  function search(query, params) {
1053
1173
  return async (client) => {
@@ -1071,6 +1191,7 @@ function readItems(collection, params) {
1071
1191
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
1072
1192
  if (params?.offset !== void 0) qs.set("offset", String(params.offset));
1073
1193
  if (params?.status) qs.set("status", params.status);
1194
+ if (params?.meta) qs.set("meta", params.meta);
1074
1195
  const s = qs.toString();
1075
1196
  const query = s ? `?${s}` : "";
1076
1197
  const res = await client.rawRequest(`/api/v1/items/${collection}${query}`);
@@ -1521,9 +1642,11 @@ export {
1521
1642
  checkCdcPipelineHealth,
1522
1643
  createAgentArtifact,
1523
1644
  createAgentGoal,
1645
+ createBookmark,
1524
1646
  createCdcPipeline,
1525
1647
  createLumiClient,
1526
1648
  decideAgentApproval,
1649
+ deleteBookmark,
1527
1650
  deleteCdcPipeline,
1528
1651
  deployCdc,
1529
1652
  dryRunAccessImport,
@@ -1532,6 +1655,7 @@ export {
1532
1655
  extractSeo,
1533
1656
  generateAgentApp,
1534
1657
  generateTypes,
1658
+ getEffectivePreset,
1535
1659
  graphql,
1536
1660
  importAccessManifest,
1537
1661
  jsonLdScript,
@@ -1541,7 +1665,9 @@ export {
1541
1665
  listAgentGoals,
1542
1666
  listAgentRuns,
1543
1667
  listAgentTools,
1668
+ listBookmarks,
1544
1669
  listCdcPipelines,
1670
+ mediaUrl,
1545
1671
  publishAgentArtifact,
1546
1672
  readAgentMemoryContext,
1547
1673
  readCdcPipeline,
@@ -1552,10 +1678,12 @@ export {
1552
1678
  retryAgentRun,
1553
1679
  rollbackAgentArtifact,
1554
1680
  rollbackCdcDeployment,
1681
+ saveUserView,
1555
1682
  search,
1556
1683
  startCdcPipeline,
1557
1684
  stopCdcPipeline,
1558
1685
  toNextMetadata,
1686
+ updateBookmark,
1559
1687
  updateCdcPipeline,
1560
1688
  validateCdcDeploymentEnv,
1561
1689
  writeAgentMemory
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumibase/sdk",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "LumiBase JS SDK (REST + WebSocket) + typegen core. Isomorphic ESM.",
5
5
  "type": "module",
6
6
  "repository": {