@inneropen/marvin-sdk 1.0.3 → 1.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.
@@ -0,0 +1,342 @@
1
+ import {
2
+ HttpClient,
3
+ SessionAuth,
4
+ init_core
5
+ } from "./chunk-LQOFJMRJ.js";
6
+
7
+ // src/platform/client.ts
8
+ init_core();
9
+
10
+ // src/platform/entries.ts
11
+ var EntriesModule = class {
12
+ constructor(http) {
13
+ this.http = http;
14
+ }
15
+ http;
16
+ /**
17
+ * List all entries
18
+ */
19
+ async list() {
20
+ return this.http.get("/api/platform/entries");
21
+ }
22
+ /**
23
+ * Get a single entry by ID
24
+ */
25
+ async get(id) {
26
+ return this.http.get(`/api/platform/entries/${id}`);
27
+ }
28
+ /**
29
+ * Create a new entry
30
+ */
31
+ async create(data) {
32
+ return this.http.post("/api/platform/entries", data);
33
+ }
34
+ /**
35
+ * Update an entry
36
+ */
37
+ async update(id, data) {
38
+ return this.http.patch(`/api/platform/entries/${id}`, data);
39
+ }
40
+ /**
41
+ * Delete an entry
42
+ */
43
+ async delete(id) {
44
+ return this.http.delete(`/api/platform/entries/${id}`);
45
+ }
46
+ /**
47
+ * Get collections that this entry belongs to
48
+ */
49
+ async listCollections(entryId) {
50
+ return this.http.get(`/api/platform/entries/${entryId}/collections`);
51
+ }
52
+ /**
53
+ * Add entry to a collection
54
+ */
55
+ async addToCollection(entryId, collectionId) {
56
+ return this.http.post(
57
+ `/api/platform/entries/${entryId}/collections/${collectionId}`,
58
+ {}
59
+ );
60
+ }
61
+ /**
62
+ * Remove entry from a collection
63
+ */
64
+ async removeFromCollection(entryId, collectionId) {
65
+ return this.http.delete(`/api/platform/entries/${entryId}/collections/${collectionId}`);
66
+ }
67
+ };
68
+
69
+ // src/platform/collections.ts
70
+ var CollectionsModule = class {
71
+ constructor(http) {
72
+ this.http = http;
73
+ }
74
+ http;
75
+ /**
76
+ * List all collections
77
+ */
78
+ async list() {
79
+ return this.http.get("/api/platform/collections");
80
+ }
81
+ /**
82
+ * Get a single collection by ID
83
+ */
84
+ async get(id) {
85
+ return this.http.get(`/api/platform/collections/${id}`);
86
+ }
87
+ /**
88
+ * Create a new collection
89
+ */
90
+ async create(data) {
91
+ return this.http.post("/api/platform/collections", data);
92
+ }
93
+ /**
94
+ * Update a collection
95
+ */
96
+ async update(id, data) {
97
+ return this.http.patch(`/api/platform/collections/${id}`, data);
98
+ }
99
+ /**
100
+ * Delete a collection
101
+ */
102
+ async delete(id) {
103
+ return this.http.delete(`/api/platform/collections/${id}`);
104
+ }
105
+ };
106
+
107
+ // src/platform/resources.ts
108
+ var ResourcesModule = class {
109
+ constructor(http) {
110
+ this.http = http;
111
+ }
112
+ http;
113
+ /**
114
+ * List all resources
115
+ */
116
+ async list() {
117
+ return this.http.get("/api/platform/resources");
118
+ }
119
+ /**
120
+ * Get a single resource by ID
121
+ */
122
+ async get(id) {
123
+ return this.http.get(`/api/platform/resources/${id}`);
124
+ }
125
+ /**
126
+ * Create a new resource
127
+ */
128
+ async create(data) {
129
+ return this.http.post("/api/platform/resources", data);
130
+ }
131
+ /**
132
+ * Update a resource
133
+ */
134
+ async update(id, data) {
135
+ return this.http.patch(`/api/platform/resources/${id}`, data);
136
+ }
137
+ /**
138
+ * Delete a resource
139
+ */
140
+ async delete(id) {
141
+ return this.http.delete(`/api/platform/resources/${id}`);
142
+ }
143
+ };
144
+
145
+ // src/platform/assets.ts
146
+ var AssetsModule = class {
147
+ constructor(http) {
148
+ this.http = http;
149
+ }
150
+ http;
151
+ /**
152
+ * List all assets
153
+ */
154
+ async list() {
155
+ return this.http.get("/api/platform/assets");
156
+ }
157
+ /**
158
+ * Get a single asset by ID
159
+ */
160
+ async get(id) {
161
+ return this.http.get(`/api/platform/assets/${id}`);
162
+ }
163
+ /**
164
+ * Create a new asset
165
+ */
166
+ async create(data) {
167
+ return this.http.post("/api/platform/assets", data);
168
+ }
169
+ /**
170
+ * Update an asset
171
+ */
172
+ async update(id, data) {
173
+ return this.http.patch(`/api/platform/assets/${id}`, data);
174
+ }
175
+ /**
176
+ * Delete an asset
177
+ */
178
+ async delete(id) {
179
+ return this.http.delete(`/api/platform/assets/${id}`);
180
+ }
181
+ };
182
+
183
+ // src/platform/apiClients.ts
184
+ var APIClientsModule = class {
185
+ constructor(http) {
186
+ this.http = http;
187
+ }
188
+ http;
189
+ /**
190
+ * List all API clients
191
+ */
192
+ async list() {
193
+ return this.http.get("/api/platform/api-clients");
194
+ }
195
+ /**
196
+ * Get a single API client by ID
197
+ */
198
+ async get(id) {
199
+ return this.http.get(`/api/platform/api-clients/${id}`);
200
+ }
201
+ /**
202
+ * Create a new API client (returns client with token)
203
+ */
204
+ async create(data) {
205
+ return this.http.post("/api/platform/api-clients", data);
206
+ }
207
+ /**
208
+ * Update an API client
209
+ */
210
+ async update(id, data) {
211
+ return this.http.patch(`/api/platform/api-clients/${id}`, data);
212
+ }
213
+ /**
214
+ * Delete an API client
215
+ */
216
+ async delete(id) {
217
+ return this.http.delete(`/api/platform/api-clients/${id}`);
218
+ }
219
+ /**
220
+ * Rotate API client token (generates new token, invalidates old one)
221
+ */
222
+ async rotateToken(id) {
223
+ return this.http.post(
224
+ `/api/platform/api-clients/${id}/rotate-token`,
225
+ {}
226
+ );
227
+ }
228
+ /**
229
+ * Preview API client token (show token prefix and metadata without revealing full token)
230
+ */
231
+ async preview(id) {
232
+ return this.http.get(`/api/platform/api-clients/${id}/preview`);
233
+ }
234
+ };
235
+
236
+ // src/platform/entryTypes.ts
237
+ var EntryTypesModule = class {
238
+ constructor(http) {
239
+ this.http = http;
240
+ }
241
+ http;
242
+ /**
243
+ * List all entry types
244
+ */
245
+ async list() {
246
+ return this.http.get("/api/platform/entry-types");
247
+ }
248
+ /**
249
+ * Get a single entry type by ID
250
+ */
251
+ async get(id) {
252
+ return this.http.get(`/api/platform/entry-types/${id}`);
253
+ }
254
+ };
255
+
256
+ // src/platform/workspaceMembers.ts
257
+ var WorkspaceMembersModule = class {
258
+ constructor(http) {
259
+ this.http = http;
260
+ }
261
+ http;
262
+ /**
263
+ * List all members of a workspace
264
+ */
265
+ async list(workspaceId) {
266
+ return this.http.get(
267
+ `/api/platform/workspaces/${workspaceId}/members`
268
+ );
269
+ }
270
+ /**
271
+ * Get a specific workspace member
272
+ */
273
+ async get(workspaceId, userId) {
274
+ return this.http.get(
275
+ `/api/platform/workspaces/${workspaceId}/members/${userId}`
276
+ );
277
+ }
278
+ /**
279
+ * Add a user to a workspace with a specific role
280
+ */
281
+ async add(workspaceId, data) {
282
+ return this.http.post(
283
+ `/api/platform/workspaces/${workspaceId}/members`,
284
+ data
285
+ );
286
+ }
287
+ /**
288
+ * Update a workspace member's role
289
+ */
290
+ async updateRole(workspaceId, userId, data) {
291
+ return this.http.put(
292
+ `/api/platform/workspaces/${workspaceId}/members/${userId}`,
293
+ data
294
+ );
295
+ }
296
+ /**
297
+ * Remove a user from a workspace
298
+ */
299
+ async remove(workspaceId, userId) {
300
+ return this.http.delete(`/api/platform/workspaces/${workspaceId}/members/${userId}`);
301
+ }
302
+ };
303
+
304
+ // src/platform/client.ts
305
+ var PlatformClient = class extends HttpClient {
306
+ entries;
307
+ collections;
308
+ resources;
309
+ assets;
310
+ apiClients;
311
+ entryTypes;
312
+ workspaceMembers;
313
+ constructor(config) {
314
+ const httpConfig = {
315
+ baseUrl: config.apiUrl,
316
+ auth: new SessionAuth(config.userToken),
317
+ credentials: config.credentials || "include"
318
+ };
319
+ super(httpConfig);
320
+ this.entries = new EntriesModule(this);
321
+ this.collections = new CollectionsModule(this);
322
+ this.resources = new ResourcesModule(this);
323
+ this.assets = new AssetsModule(this);
324
+ this.apiClients = new APIClientsModule(this);
325
+ this.entryTypes = new EntryTypesModule(this);
326
+ this.workspaceMembers = new WorkspaceMembersModule(this);
327
+ }
328
+ };
329
+ function createPlatformClient(config) {
330
+ return new PlatformClient(config);
331
+ }
332
+ export {
333
+ APIClientsModule,
334
+ AssetsModule,
335
+ CollectionsModule,
336
+ EntriesModule,
337
+ EntryTypesModule,
338
+ PlatformClient,
339
+ ResourcesModule,
340
+ WorkspaceMembersModule,
341
+ createPlatformClient
342
+ };
@@ -55,6 +55,8 @@ interface MarvinCollection {
55
55
  smartRules?: Record<string, unknown>;
56
56
  createdAt: string;
57
57
  updatedAt: string;
58
+ entryCount?: number;
59
+ entries?: MarvinEntry[];
58
60
  }
59
61
  interface MarvinResource {
60
62
  id: string;
@@ -55,6 +55,8 @@ interface MarvinCollection {
55
55
  smartRules?: Record<string, unknown>;
56
56
  createdAt: string;
57
57
  updatedAt: string;
58
+ entryCount?: number;
59
+ entries?: MarvinEntry[];
58
60
  }
59
61
  interface MarvinResource {
60
62
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneropen/marvin-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.3.0",
4
4
  "description": "Official TypeScript SDK for Marvin CMS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -17,6 +17,11 @@
17
17
  "import": "./dist/index.js",
18
18
  "require": "./dist/index.cjs"
19
19
  },
20
+ "./platform": {
21
+ "types": "./dist/platform.d.ts",
22
+ "import": "./dist/platform.js",
23
+ "require": "./dist/platform.cjs"
24
+ },
20
25
  "./types": {
21
26
  "types": "./dist/types/index.d.ts",
22
27
  "import": "./dist/types/index.js",
@@ -55,8 +60,9 @@
55
60
  },
56
61
  "homepage": "https://github.com/inneropen/marvin-sdk#readme",
57
62
  "scripts": {
58
- "build": "tsup src/index.ts src/types/index.ts --format esm,cjs --dts --clean",
59
- "dev": "tsup src/index.ts src/types/index.ts --format esm,cjs --dts --watch",
63
+ "build": "tsup src/index.ts src/platform.ts src/types/index.ts --format esm,cjs --dts --clean",
64
+ "dev": "tsup src/index.ts src/platform.ts src/types/index.ts --format esm,cjs --dts --watch",
65
+ "generate:types": "openapi-typescript http://localhost:8080/openapi.json -o src/generated/schema.ts",
60
66
  "typecheck": "tsc --noEmit",
61
67
  "prepublishOnly": "npm run build"
62
68
  },
@@ -68,6 +74,7 @@
68
74
  },
69
75
  "devDependencies": {
70
76
  "@types/node": "^26.1.0",
77
+ "openapi-typescript": "^7.13.0",
71
78
  "tsup": "^8.5.1"
72
79
  }
73
80
  }