@flink-app/contentone-plugin 0.12.1-alpha.9 → 0.13.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @flink-app/contentone-plugin
2
+
3
+ ## 0.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Migrate to pnpm and streamlines build process.
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
1
  {
2
- "name": "@flink-app/contentone-plugin",
3
- "version": "0.12.1-alpha.9",
4
- "description": "Flink plugin that enables easy to use communication with content one",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\"",
7
- "prepare": "tsc"
8
- },
9
- "author": "johan@frost.se",
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "license": "MIT",
14
- "types": "dist/index.d.ts",
15
- "main": "dist/index.js",
16
- "dependencies": {
17
- "form-data": "^2.5.1",
18
- "got": "^9.6.0"
19
- },
20
- "devDependencies": {
21
- "@flink-app/flink": "^0.12.1-alpha.9",
22
- "@types/got": "^9.6.0",
23
- "@types/node": "22.13.10",
24
- "ts-node": "^9.1.1",
25
- "typescript": "5.4.5"
26
- },
27
- "gitHead": "3007ad036607014176930446fde56203bde8d6f5"
28
- }
2
+ "name": "@flink-app/contentone-plugin",
3
+ "version": "0.13.0",
4
+ "description": "Flink plugin that enables easy to use communication with content one",
5
+ "author": "johan@frost.se",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "license": "MIT",
10
+ "types": "dist/index.d.ts",
11
+ "main": "dist/index.js",
12
+ "dependencies": {
13
+ "form-data": "^2.5.1",
14
+ "got": "^9.6.0"
15
+ },
16
+ "devDependencies": {
17
+ "@types/got": "^9.6.0",
18
+ "@types/node": "22.13.10",
19
+ "ts-node": "^10.9.2",
20
+ "@flink-app/flink": "0.13.0"
21
+ },
22
+ "gitHead": "4243e3b3cd6d4e1ca001a61baa8436bf2bbe4113",
23
+ "scripts": {
24
+ "test": "echo \"Error: no test specified\"",
25
+ "build": "tsc",
26
+ "clean": "rimraf dist .flink"
27
+ }
28
+ }
package/readme.md CHANGED
@@ -1,244 +1,498 @@
1
- # Flink API Docs
1
+ # @flink-app/contentone-plugin
2
2
 
3
- A FLINK plugin that makes it easy to consume data from Content One.
3
+ A Flink plugin for integrating with Content One CMS (Aquro). This plugin provides a simple and type-safe way to consume content from Content One collections, execute management actions, and upload files to the Content One CDN.
4
4
 
5
- The plugin also makes it possible to call ContentOne actions.
5
+ ## Features
6
6
 
7
- ## Installation
7
+ - Retrieve documents from Content One collections
8
+ - List and query collection documents with filtering and pagination
9
+ - Execute Content One management actions
10
+ - Upload files to Content One CDN with image processing options
11
+ - Support for multiple collections and CDN configurations
12
+ - Environment switching (Production/Staging)
13
+ - Document relation resolution
14
+ - Language-specific content retrieval
15
+ - Full TypeScript support with generic types
16
+ - Direct API calls without pre-configuration
8
17
 
9
- Install plugin to your flink app project:
18
+ ## Installation
10
19
 
11
- ```
12
- npm i -S @flink-app/contentone-plugin
20
+ ```bash
21
+ npm install @flink-app/contentone-plugin
13
22
  ```
14
23
 
15
- Add and configure plugin in your app startup (probable the `index.ts` in root project):
24
+ ## Usage
16
25
 
17
- ```
18
- import { ContentOneClient, ContentOneManagementAction, contentOnePlugin } from "@flink-app/contentone-plugin"
26
+ ### Basic Setup
27
+
28
+ ```typescript
29
+ import { FlinkApp } from "@flink-app/flink";
30
+ import {
31
+ contentOnePlugin,
32
+ ContentOneClient,
33
+ ContentOneManagementAction,
34
+ ContentOneCDN,
35
+ } from "@flink-app/contentone-plugin";
19
36
 
20
37
  function start() {
21
38
  new FlinkApp<AppContext>({
22
39
  name: "My app",
23
40
  plugins: [
24
- // Register plugin
25
41
  contentOnePlugin({
26
- collections : {
27
- "Collection1" : new ContentOneClient({
28
- collection : "collectionid",
29
- token : "token.."
42
+ collections: {
43
+ NewsItems: new ContentOneClient({
44
+ collection: "collection_id_here",
45
+ token: "your_token_here",
46
+ }),
47
+ Products: new ContentOneClient({
48
+ collection: "another_collection_id",
49
+ token: "your_token_here",
30
50
  }),
31
- "Collection2" : new ContentOneClient({
32
- collection : "collectionid",
33
- token : "token.."
34
- })
35
51
  },
36
- actions : {
37
- "action1" : new ContentOneManagementAction({
38
- actionId : "action1",
39
- apiKey : "apikey"
40
- })
52
+ actions: {
53
+ SendEmail: new ContentOneManagementAction({
54
+ actionId: "send_email_action_id",
55
+ apiKey: "your_api_key_here",
56
+ }),
41
57
  },
42
- cdns : {
43
- "photos" : new ContentOneCDN({
44
- token : "file_archive_token"
45
- })
46
- }
47
-
48
- })
58
+ cdns: {
59
+ photos: new ContentOneCDN({
60
+ token: "file_archive_token",
61
+ }),
62
+ },
63
+ baseUrl: "https://cdb.aquro.com", // optional
64
+ managementBaseUrl: "https://api-cm.aquro.com", // optional
65
+ }),
49
66
  ],
50
67
  }).start();
51
68
  }
52
-
53
69
  ```
54
70
 
55
- Finally add plugin context type as generic argument to your application context (probable the `Ctx.ts` in root project)
71
+ ### Add Plugin Context to Your Application
56
72
 
57
- ```
73
+ ```typescript
58
74
  import { contentOnePluginContext } from "@flink-app/contentone-plugin";
59
75
 
60
- export interface Ctx extends FlinkContext<contentOnePluginContext> {
61
- repos: {};
76
+ export interface AppContext extends FlinkContext<contentOnePluginContext> {
77
+ repos: {
78
+ // your repos
79
+ };
62
80
  }
63
-
64
81
  ```
65
82
 
66
- ## Collections
83
+ ## Configuration Options
67
84
 
68
- Collections can be called for `get`,`list` and `query` actions.
85
+ - `collections` (optional): Object mapping collection names to `ContentOneClient` instances
86
+ - `actions` (optional): Object mapping action names to `ContentOneManagementAction` instances
87
+ - `cdns` (optional): Object mapping CDN names to `ContentOneCDN` instances
88
+ - `baseUrl` (optional): Content One API base URL (defaults to `https://cdb.aquro.com`)
89
+ - `managementBaseUrl` (optional): Content One Management API base URL (defaults to `https://api-cm.aquro.com`)
69
90
 
70
- ### get
91
+ ## Working with Collections
71
92
 
72
- ```
73
- const document = (await ctx.plugins.contentOne.collections.NewsItems.get("documentid")).document
74
- ```
93
+ ### Get a Single Document
75
94
 
76
- The following optional options can also be specified:
95
+ ```typescript
96
+ const document = (await ctx.plugins.contentOne.collections.NewsItems.get("document_id")).document;
97
+ ```
77
98
 
78
- | Options | Description |
79
- | ----------- | ------------------------------------------------- | ---------------------------------- |
80
- | language | Language code (ISO 639-1) to get the documents in |
81
- | environment | "Production" | "Staging", |
82
- | resolve | "yes" | "no" - Resolving related documents |
99
+ With options:
83
100
 
84
- ```
85
- const document = (await ctx.plugins.contentOne.collections.NewsItems.get("documentid"), { language : "en" }).document
101
+ ```typescript
102
+ const document = (
103
+ await ctx.plugins.contentOne.collections.NewsItems.get("document_id", {
104
+ language: "en",
105
+ environment: "Production",
106
+ resolve: "yes",
107
+ })
108
+ ).document;
86
109
  ```
87
110
 
88
- ### list
111
+ ### List Documents
89
112
 
113
+ ```typescript
114
+ const documents = (await ctx.plugins.contentOne.collections.NewsItems.list()).documents;
90
115
  ```
91
- const documents = (await ctx.plugins.contentOne.collections.NewsItems.list()).documents
116
+
117
+ With pagination and sorting:
118
+
119
+ ```typescript
120
+ const documents = (
121
+ await ctx.plugins.contentOne.collections.NewsItems.list({
122
+ skip: 0,
123
+ limit: 50,
124
+ sort: "createdDate",
125
+ sort_direction: "desc",
126
+ language: "en",
127
+ environment: "Production",
128
+ resolve: "yes",
129
+ })
130
+ ).documents;
92
131
  ```
93
132
 
94
- The following optional options can also be specified:
133
+ ### Query Documents
95
134
 
96
- | Options | Description |
97
- | -------------- | ------------------------------------------------- | ---------------------------------- |
98
- | language | Language code (ISO 639-1) to get the documents in |
99
- | environment | "Production" | "Staging", |
100
- | resolve | "yes" | "no" - Resolving related documents |
101
- | skip | Skip a number of documents, defaults to 0 |
102
- | limit | Maximum of documents returned, defaults to 10 000 |
103
- | sort | Field to sort the documents by |
104
- | sort_direction | "asc" | "desc" |
135
+ Execute a named query with arguments:
105
136
 
106
- ```
107
- const document = (await ctx.plugins.contentOne.collections.NewsItems.get("documentid"), { skip : 100 }).document
137
+ ```typescript
138
+ const documents = (
139
+ await ctx.plugins.contentOne.collections.NewsItems.query("GetNewsByCategory", {
140
+ category: "Technology",
141
+ })
142
+ ).documents;
108
143
  ```
109
144
 
110
- ### query
145
+ With options:
111
146
 
112
- ```
113
- const documents = (await ctx.plugins.contentOne.collections.NewsItems.query("QueryName", { Arg : "Hello" })).documents
147
+ ```typescript
148
+ const documents = (
149
+ await ctx.plugins.contentOne.collections.NewsItems.query(
150
+ "GetNewsByCategory",
151
+ {
152
+ category: "Technology",
153
+ },
154
+ {
155
+ limit: 20,
156
+ sort: "publishDate",
157
+ sort_direction: "desc",
158
+ }
159
+ )
160
+ ).documents;
114
161
  ```
115
162
 
116
- The following optional options can also be specified:
163
+ ## Request Options
117
164
 
118
- | Options | Description |
119
- | -------------- | ------------------------------------------------- | ---------------------------------- |
120
- | language | Language code (ISO 639-1) to get the documents in |
121
- | environment | "Production" | "Staging", |
122
- | resolve | "yes" | "no" - Resolving related documents |
123
- | skip | Skip a number of documents, defaults to 0 |
124
- | limit | Maximum of documents returned, defaults to 10 000 |
125
- | sort | Field to sort the documents by |
126
- | sort_direction | "asc" | "desc" |
165
+ ### Common Options
127
166
 
128
- ```
129
- const documents = (await ctx.plugins.contentOne.collections.NewsItems.query("QueryName", { Arg : "Hello" }, { limit : 1000 })).documents
130
- ```
167
+ Available for `get`, `list`, and `query`:
131
168
 
132
- ## Actions
169
+ - `language` (string): Language code (ISO 639-1) to retrieve documents in (e.g., "en", "sv")
170
+ - `environment` ("Production" | "Staging"): Which environment to fetch from
171
+ - `resolve` ("yes" | "no"): Whether to resolve related documents
133
172
 
134
- Content One actions can easily be called;
173
+ ### List and Query Options
135
174
 
136
- ```
137
- const resp = ctx.plugins.contentOne.actions.ActionName.execute({ Arg : "Hello" });
138
- ```
175
+ Additional options for `list` and `query`:
139
176
 
140
- ## Files
177
+ - `skip` (number): Number of documents to skip (default: 0)
178
+ - `limit` (number): Maximum documents to return (default: 10,000)
179
+ - `sort` (string): Field name to sort by
180
+ - `sort_direction` ("asc" | "desc"): Sort direction
141
181
 
142
- Content One have a built in File Archive and with this plugin you might easily upload files:
182
+ ## TypeScript Type Safety
143
183
 
144
- First configure your cdn:connections on plugin initilization. Then simply call the upload function:
184
+ Use generic types to get typed document responses:
145
185
 
146
- ```
147
- const resp = await ctx.plugins.contentOne.cdns.photos.upload("/tmp/file.png", {} )
186
+ ```typescript
187
+ interface NewsItem {
188
+ _id: string;
189
+ title: string;
190
+ content: string;
191
+ publishDate: string;
192
+ category: string;
193
+ }
148
194
 
195
+ // Single document
196
+ const document = (
197
+ await ctx.plugins.contentOne.collections.NewsItems.get<NewsItem>("document_id")
198
+ ).document;
199
+ // document is typed as NewsItem
200
+
201
+ // Multiple documents
202
+ const documents = (
203
+ await ctx.plugins.contentOne.collections.NewsItems.list<NewsItem>()
204
+ ).documents;
205
+ // documents is typed as NewsItem[]
149
206
  ```
150
207
 
151
- The following options can be specified
208
+ ## Management Actions
152
209
 
153
- #### folderId
210
+ ### Execute Pre-configured Actions
154
211
 
155
- Folter to save the file to. Normally leave empty and default folder for the token will be used.
212
+ ```typescript
213
+ const response = await ctx.plugins.contentOne.actions.SendEmail.execute({
214
+ to: "user@example.com",
215
+ subject: "Hello",
216
+ body: "Welcome to our service",
217
+ });
156
218
 
157
- #### image_rotate
219
+ if (response.status === "success") {
220
+ console.log("Email sent:", response.data);
221
+ }
222
+ ```
158
223
 
159
- Set to 90,180,270 or auto to rotate the image, normally set it to auto and the image will be rotated based on the exif data of the image.
224
+ ### Execute Actions Directly
160
225
 
161
- #### image_resize_width
226
+ Without pre-configuration:
162
227
 
163
- Specify a width if you like to resize the image to a specific width
228
+ ```typescript
229
+ const response = await ctx.plugins.contentOne.management.action(
230
+ "action_id",
231
+ "api_key",
232
+ {
233
+ arg1: "value1",
234
+ arg2: "value2",
235
+ }
236
+ );
237
+ ```
164
238
 
165
- #### image_resize_height
239
+ ### Typed Action Responses
166
240
 
167
- Specify a height if you like to resize the image to a specific height
241
+ ```typescript
242
+ interface EmailResponse {
243
+ messageId: string;
244
+ status: string;
245
+ }
168
246
 
169
- #### image_resize_max
247
+ const response = await ctx.plugins.contentOne.actions.SendEmail.execute<EmailResponse>({
248
+ to: "user@example.com",
249
+ subject: "Hello",
250
+ });
170
251
 
171
- If set to "yes" the image will be as big as possible, but never bigger then the specified width and height (and still keeping the aspect ratio)
252
+ if (response.status === "success") {
253
+ console.log("Message ID:", response.data.messageId);
254
+ }
255
+ ```
172
256
 
173
- #### image_resize_crop
257
+ ## File Upload (CDN)
174
258
 
175
- Make the size of the resized image exacly the specified size, and crop image if required.
259
+ ### Upload Files with Pre-configured CDN
176
260
 
177
- #### image_thumb
261
+ ```typescript
262
+ const result = await ctx.plugins.contentOne.cdns.photos.upload("/tmp/photo.jpg", {
263
+ image_rotate: "auto",
264
+ image_resize_width: 1200,
265
+ image_resize_max: "yes",
266
+ image_thumb: "yes",
267
+ image_thumb_width: 200,
268
+ image_thumb_height: 200,
269
+ });
178
270
 
179
- Set to yes to also generate a thumbnail
271
+ if (result.status === "success") {
272
+ console.log("File URL:", result.file.Url);
273
+ console.log("Thumbnail URL:", result.file.Thumbnail);
274
+ }
275
+ ```
180
276
 
181
- #### image_thumb_width
277
+ ### Upload Files Directly
182
278
 
183
- Specify width of thumbnail
279
+ Without pre-configuration:
184
280
 
185
- #### image_thumb_height
281
+ ```typescript
282
+ const result = await ctx.plugins.contentOne.cdnClient.upload("/tmp/photo.jpg", "file_archive_token", {
283
+ image_rotate: "auto",
284
+ image_resize_width: 1200,
285
+ });
286
+ ```
186
287
 
187
- Specify height of thumbnail
288
+ ### Upload Options
188
289
 
189
- ### Response
290
+ - `folderId` (string): Folder to save the file to
291
+ - `image_rotate` ("90" | "180" | "270" | "auto"): Rotate image (auto uses EXIF data)
292
+ - `image_resize_width` (number): Resize to specific width
293
+ - `image_resize_height` (number): Resize to specific height
294
+ - `image_resize_max` ("yes" | "no"): Keep aspect ratio, fit within dimensions
295
+ - `image_resize_crop` ("center" | "attention"): Crop strategy for exact dimensions
296
+ - `image_thumb` ("yes" | "no"): Generate thumbnail
297
+ - `image_thumb_width` (number): Thumbnail width
298
+ - `image_thumb_height` (number): Thumbnail height
190
299
 
191
- When uploading a file you will get a response back looking something like this:
300
+ ### Upload Response
192
301
 
193
- ```
302
+ ```typescript
194
303
  {
195
- status: 'success',
304
+ status: "success" | "fail",
196
305
  file: {
197
- _id: '60e461887be82613ad95b39c',
198
- ProjectID: '5a980fb80459493b3378c9a2',
199
- Local_FileName: 'watermark.png',
200
- CDN_FileName: 'ef32c174d9c94caf8d5490626d62952a.png',
201
- Url: 'https://aqurocm.blob.core.windows.net/5a980fb80459493b3378c9a2-f7dd9134781541f6adacbdd654091847/ef32c174d9c94caf8d5490626d62952a.png',
202
- Type: 'Image',
203
- Size: 26888,
204
- CreatedDate: '2021-07-06T13:58:32.920Z',
205
- Thumbnail: 'https://aqurocm.blob.core.windows.net/5a980fb80459493b3378c9a2-f7dd9134781541f6adacbdd654091847/db275bd42fe345499fded27a66bf59ce.png',
206
- ThumbnailCDN_Filename: 'db275bd42fe345499fded27a66bf59ce.png',
207
- FolderID: '5a9811ac0459493b3378c9b6'
306
+ _id: string;
307
+ ProjectID: string;
308
+ Local_FileName: string;
309
+ CDN_FileName: string;
310
+ Url: string;
311
+ Type: string;
312
+ Size: number;
313
+ CreatedDate: string;
314
+ FolderID: string;
315
+ Thumbnail?: string;
316
+ ThumbnailCDN_Filename?: string;
208
317
  }
209
318
  }
210
319
  ```
211
320
 
212
- ## Direct collection calls
321
+ ## Direct API Calls
213
322
 
214
- Direct calls to a collection can be made without configured by the initializing code. To do this use the getClient method:
323
+ The plugin supports direct API calls without pre-configuration:
215
324
 
325
+ ### Direct Collection Access
326
+
327
+ ```typescript
328
+ const document = (
329
+ await ctx.plugins.contentOne.getClient({
330
+ token: "token",
331
+ collection: "collection_id",
332
+ }).get("document_id")
333
+ ).document;
216
334
  ```
217
- const document = (await ctx.plugins.contentOne.getClient({ token : "token", "collection" : "collectionid"}).get("documentid")).document
218
- ```
219
335
 
220
- ## Direct action calls
336
+ ### Direct Action Execution
337
+
338
+ ```typescript
339
+ const response = await ctx.plugins.contentOne.management.action(
340
+ "action_id",
341
+ "api_key",
342
+ {
343
+ argument: "value",
344
+ }
345
+ );
346
+ ```
221
347
 
222
- Direct calls to a actions can be made without configured by the initializing code. To do this use the management.action method:
348
+ ### Direct CDN Upload
223
349
 
350
+ ```typescript
351
+ const result = await ctx.plugins.contentOne.cdnClient.upload(
352
+ "./file.txt",
353
+ "token",
354
+ {}
355
+ );
224
356
  ```
225
- const resp = (await ctx.plugins.contentOne.management.action("actionid", "apikey", {})).data;
357
+
358
+ ## Complete Example
359
+
360
+ ```typescript
361
+ import { FlinkApp } from "@flink-app/flink";
362
+ import {
363
+ contentOnePlugin,
364
+ ContentOneClient,
365
+ ContentOneManagementAction,
366
+ ContentOneCDN,
367
+ } from "@flink-app/contentone-plugin";
368
+
369
+ interface Article {
370
+ _id: string;
371
+ title: string;
372
+ content: string;
373
+ author: string;
374
+ publishedAt: string;
375
+ }
376
+
377
+ const plugin = contentOnePlugin({
378
+ collections: {
379
+ Articles: new ContentOneClient({
380
+ collection: "articles_collection_id",
381
+ token: process.env.CONTENTONE_TOKEN!,
382
+ debug: true, // Enable logging
383
+ }),
384
+ },
385
+ actions: {
386
+ PublishArticle: new ContentOneManagementAction({
387
+ actionId: "publish_article",
388
+ apiKey: process.env.CONTENTONE_API_KEY!,
389
+ }),
390
+ },
391
+ cdns: {
392
+ images: new ContentOneCDN({
393
+ token: process.env.CONTENTONE_CDN_TOKEN!,
394
+ }),
395
+ },
396
+ });
397
+
398
+ // Later in your handler or job:
399
+ async function publishArticle(ctx: AppContext, articleId: string) {
400
+ // Get the article
401
+ const article = (
402
+ await ctx.plugins.contentOne.collections.Articles.get<Article>(articleId, {
403
+ language: "en",
404
+ environment: "Production",
405
+ })
406
+ ).document;
407
+
408
+ // Execute publish action
409
+ const result = await ctx.plugins.contentOne.actions.PublishArticle.execute({
410
+ articleId: article._id,
411
+ publishDate: new Date().toISOString(),
412
+ });
413
+
414
+ return result;
415
+ }
416
+
417
+ async function uploadArticleImage(ctx: AppContext, imagePath: string) {
418
+ const upload = await ctx.plugins.contentOne.cdns.images.upload(imagePath, {
419
+ image_rotate: "auto",
420
+ image_resize_width: 1200,
421
+ image_resize_max: "yes",
422
+ image_thumb: "yes",
423
+ image_thumb_width: 300,
424
+ image_thumb_height: 200,
425
+ });
426
+
427
+ if (upload.status === "success") {
428
+ return {
429
+ imageUrl: upload.file.Url,
430
+ thumbnailUrl: upload.file.Thumbnail,
431
+ };
432
+ }
433
+
434
+ throw new Error("Upload failed");
435
+ }
226
436
  ```
227
437
 
228
- ## Direct CDN calls
438
+ ## Error Handling
229
439
 
230
- Direct calls to a CDN client can also be made without configuring it first:
440
+ Always wrap API calls in try-catch blocks:
231
441
 
442
+ ```typescript
443
+ try {
444
+ const document = (
445
+ await ctx.plugins.contentOne.collections.NewsItems.get("document_id")
446
+ ).document;
447
+ } catch (error) {
448
+ console.error("Failed to fetch document:", error);
449
+ // Handle error appropriately
450
+ }
232
451
  ```
233
- const resp = await ctx.plugins.contentOne.cdns.photos.upload("./file.txt", "token", { })
452
+
453
+ ## Debug Mode
454
+
455
+ Enable debug mode for a collection to log all API requests and responses:
456
+
457
+ ```typescript
458
+ new ContentOneClient({
459
+ collection: "collection_id",
460
+ token: "token",
461
+ debug: true, // Logs all requests and responses
462
+ });
234
463
  ```
235
464
 
236
- ## Typed calls
465
+ ## API Response Types
237
466
 
238
- Each of these calls can specify the type on the returned document or documents by setting the type as a generic argument.
467
+ ### Document Response
239
468
 
469
+ ```typescript
470
+ {
471
+ status: "success" | "error",
472
+ document: T,
473
+ message?: string
474
+ }
240
475
  ```
241
- const document = (await ctx.plugins.contentOne.collections.NewsItems.get<Type>("documentid")).document
242
476
 
477
+ ### Document List Response
243
478
 
479
+ ```typescript
480
+ {
481
+ status: "success" | "error",
482
+ documents: T[],
483
+ message?: string
484
+ }
485
+ ```
486
+
487
+ ### Action Response
488
+
489
+ ```typescript
490
+ {
491
+ status: "success" | "error",
492
+ data: T
493
+ }
244
494
  ```
495
+
496
+ ## License
497
+
498
+ MIT
package/tsconfig.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "noEmit": false,
16
16
  "declaration": true,
17
17
  "experimentalDecorators": true,
18
- "checkJs": true,
18
+ "checkJs": false,
19
19
  "outDir": "dist"
20
20
  },
21
21
  "include": ["./src/*"],