@veroxm/sdk 1.7.0 → 1.8.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.8.0
4
+
5
+ - Writes to database content models (public API 2.11): `create`, `update` and `delete` work on a model that allows
6
+ them, with its writable fields. `update(id)` and `delete(id)` take a text key too, and all three take `userId` and
7
+ `ctx` (sent as `?userId=` and `?ctx.<name>=`) for a model limited to the caller's rows, from a project key on your
8
+ server.
9
+
3
10
  ## 1.7.0
4
11
 
5
12
  - Database content models (public API 2.10): `app.content(slug)` reads them like any collection; their entries come
package/dist/content.d.ts CHANGED
@@ -68,15 +68,20 @@ export declare class ContentResource<T = Record<string, unknown>> {
68
68
  get(id: number | string, options?: {
69
69
  timestamps?: boolean;
70
70
  } & Pick<ListOptions, 'userId' | 'ctx'>): Promise<T>;
71
- /** Fields are sent flat (no wrapper). Pass `draft: true` to create without publishing; omit it (or pass false) to publish immediately. */
72
- create(data: Record<string, unknown>): Promise<T>;
71
+ /**
72
+ * Fields are sent flat (no wrapper). Pass `draft: true` to create without publishing; omit it (or pass false) to
73
+ * publish immediately. A database content model that allows creating entries takes its writable fields (and `id` when
74
+ * it takes the key from you); `userId` / `ctx` say whose row it is for a model limited to the caller's rows.
75
+ */
76
+ create(data: Record<string, unknown>, options?: Pick<ListOptions, 'userId' | 'ctx'>): Promise<T>;
73
77
  /**
74
78
  * A partial update -- only the fields present in `data` are changed.
75
79
  * Publish state follows the same rule as create(): omitting `draft` (or
76
80
  * passing `draft: false`) PUBLISHES the record immediately, even if it
77
81
  * was previously a draft and this update doesn't touch content fields.
78
82
  * Pass `draft: true` explicitly to keep (or return) it unpublished.
83
+ * (A database content model has no drafts: its writable fields only.)
79
84
  */
80
- update(id: number, data: Record<string, unknown>): Promise<T>;
81
- delete(id: number): Promise<void>;
85
+ update(id: number | string, data: Record<string, unknown>, options?: Pick<ListOptions, 'userId' | 'ctx'>): Promise<T>;
86
+ delete(id: number | string, options?: Pick<ListOptions, 'userId' | 'ctx'>): Promise<void>;
82
87
  }
package/dist/content.js CHANGED
@@ -66,9 +66,13 @@ export class ContentResource {
66
66
  query: { timestamps: options.timestamps ? '1' : undefined, ...callerQuery(options) },
67
67
  });
68
68
  }
69
- /** Fields are sent flat (no wrapper). Pass `draft: true` to create without publishing; omit it (or pass false) to publish immediately. */
70
- async create(data) {
71
- return this.app.request({ method: 'POST', path: this.root(), json: data });
69
+ /**
70
+ * Fields are sent flat (no wrapper). Pass `draft: true` to create without publishing; omit it (or pass false) to
71
+ * publish immediately. A database content model that allows creating entries takes its writable fields (and `id` when
72
+ * it takes the key from you); `userId` / `ctx` say whose row it is for a model limited to the caller's rows.
73
+ */
74
+ async create(data, options = {}) {
75
+ return this.app.request({ method: 'POST', path: this.root(), query: callerQuery(options), json: data });
72
76
  }
73
77
  /**
74
78
  * A partial update -- only the fields present in `data` are changed.
@@ -76,11 +80,12 @@ export class ContentResource {
76
80
  * passing `draft: false`) PUBLISHES the record immediately, even if it
77
81
  * was previously a draft and this update doesn't touch content fields.
78
82
  * Pass `draft: true` explicitly to keep (or return) it unpublished.
83
+ * (A database content model has no drafts: its writable fields only.)
79
84
  */
80
- async update(id, data) {
81
- return this.app.request({ method: 'PATCH', path: `${this.root()}/${id}`, json: data });
85
+ async update(id, data, options = {}) {
86
+ return this.app.request({ method: 'PATCH', path: `${this.root()}/${encodeURIComponent(String(id))}`, query: callerQuery(options), json: data });
82
87
  }
83
- async delete(id) {
84
- await this.app.request({ method: 'DELETE', path: `${this.root()}/${id}` });
88
+ async delete(id, options = {}) {
89
+ await this.app.request({ method: 'DELETE', path: `${this.root()}/${encodeURIComponent(String(id))}`, query: callerQuery(options) });
85
90
  }
86
91
  }
@@ -544,7 +544,10 @@ export interface paths {
544
544
  */
545
545
  get: operations["listEntries"];
546
546
  put?: never;
547
- /** Create an entry */
547
+ /**
548
+ * Create an entry
549
+ * @description A database content model takes this when it allows creating entries (405 `read_only` otherwise): the key also needs database:<db>:write, `userId=` or `ctx.<name>=` say whose row for a model limited to the caller’s (it is set to them), and the answer is the new entry as read back.
550
+ */
548
551
  post: operations["createEntry"];
549
552
  delete?: never;
550
553
  options?: never;
@@ -580,11 +583,17 @@ export interface paths {
580
583
  get: operations["getEntry"];
581
584
  put?: never;
582
585
  post?: never;
583
- /** Delete an entry */
586
+ /**
587
+ * Delete an entry
588
+ * @description A database content model takes this when it allows deleting entries (405 `read_only` otherwise): the key also needs database:<db>:write, and only the caller’s rows are deleted. A row other rows still point at is 409 `in_use`.
589
+ */
584
590
  delete: operations["deleteEntry"];
585
591
  options?: never;
586
592
  head?: never;
587
- /** Change some fields of an entry */
593
+ /**
594
+ * Change some fields of an entry
595
+ * @description A database content model takes this when it allows changing entries (405 `read_only` otherwise): the key also needs database:<db>:write, only the caller’s rows are changed (404 for any other), and the answer is the entry as read back.
596
+ */
588
597
  patch: operations["updateEntry"];
589
598
  trace?: never;
590
599
  };
@@ -1400,7 +1409,7 @@ export interface components {
1400
1409
  /** @description One locale's entries; omitted = the default locale. */
1401
1410
  locale?: string;
1402
1411
  };
1403
- /** @description Field values by name. `draft: true` keeps the entry unpublished; anything else publishes it. */
1412
+ /** @description Field values by name. `draft: true` keeps the entry unpublished; anything else publishes it. For a database content model that takes writes: only its writable fields (no `draft` or `locale`), and `id` only when the model takes the key from the caller. */
1404
1413
  EntryWrite: {
1405
1414
  [key: string]: unknown;
1406
1415
  };
@@ -3142,7 +3151,10 @@ export interface operations {
3142
3151
  };
3143
3152
  createEntry: {
3144
3153
  parameters: {
3145
- query?: never;
3154
+ query?: {
3155
+ /** @description A database content model limited to the caller's rows: whose (project keys). */
3156
+ userId?: string;
3157
+ };
3146
3158
  header?: never;
3147
3159
  path: {
3148
3160
  /** @description The project's UUID. */
@@ -3173,6 +3185,9 @@ export interface operations {
3173
3185
  405: components["responses"]["E405"];
3174
3186
  409: components["responses"]["E409"];
3175
3187
  429: components["responses"]["E429"];
3188
+ 502: components["responses"]["E502"];
3189
+ 503: components["responses"]["E503"];
3190
+ 504: components["responses"]["E504"];
3176
3191
  };
3177
3192
  };
3178
3193
  searchEntries: {
@@ -3256,13 +3271,17 @@ export interface operations {
3256
3271
  };
3257
3272
  deleteEntry: {
3258
3273
  parameters: {
3259
- query?: never;
3274
+ query?: {
3275
+ /** @description A database content model limited to the caller's rows: whose (project keys). */
3276
+ userId?: string;
3277
+ };
3260
3278
  header?: never;
3261
3279
  path: {
3262
3280
  /** @description The project's UUID. */
3263
3281
  uuid: string;
3264
3282
  slug: string;
3265
- id: number;
3283
+ /** @description The entry's id: a number, or a database content model's key. */
3284
+ id: string;
3266
3285
  };
3267
3286
  cookie?: never;
3268
3287
  };
@@ -3282,18 +3301,26 @@ export interface operations {
3282
3301
  403: components["responses"]["E403"];
3283
3302
  404: components["responses"]["E404"];
3284
3303
  405: components["responses"]["E405"];
3304
+ 409: components["responses"]["E409"];
3285
3305
  429: components["responses"]["E429"];
3306
+ 502: components["responses"]["E502"];
3307
+ 503: components["responses"]["E503"];
3308
+ 504: components["responses"]["E504"];
3286
3309
  };
3287
3310
  };
3288
3311
  updateEntry: {
3289
3312
  parameters: {
3290
- query?: never;
3313
+ query?: {
3314
+ /** @description A database content model limited to the caller's rows: whose (project keys). */
3315
+ userId?: string;
3316
+ };
3291
3317
  header?: never;
3292
3318
  path: {
3293
3319
  /** @description The project's UUID. */
3294
3320
  uuid: string;
3295
3321
  slug: string;
3296
- id: number;
3322
+ /** @description The entry's id: a number, or a database content model's key. */
3323
+ id: string;
3297
3324
  };
3298
3325
  cookie?: never;
3299
3326
  };
@@ -3319,6 +3346,9 @@ export interface operations {
3319
3346
  405: components["responses"]["E405"];
3320
3347
  409: components["responses"]["E409"];
3321
3348
  429: components["responses"]["E429"];
3349
+ 502: components["responses"]["E502"];
3350
+ 503: components["responses"]["E503"];
3351
+ 504: components["responses"]["E504"];
3322
3352
  };
3323
3353
  };
3324
3354
  listMedia: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veroxm/sdk",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "VeroXM client for JavaScript and TypeScript: content, media, experiences, events and the visitor tracker.",
5
5
  "keywords": [
6
6
  "veroxm",