@nohead/sdk 0.10.0 → 0.12.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
@@ -5,6 +5,22 @@ Changes to `@nohead/sdk` that you can notice. Versions follow
5
5
  releases; a change that could break your code is a major one. Each release's
6
6
  section is its GitHub release's notes.
7
7
 
8
+ ## 0.12.0
9
+
10
+ - `webhooks.create` and `webhooks.update` take `published_only`, and every
11
+ webhook has it: a published-only webhook sends only the events that change
12
+ what a published-only API key reads (a record published, unpublished or
13
+ edited while live, schema changes, changes to assets that published records
14
+ use), and skips drafts, schedules and edits to unpublished records.
15
+ - Audit events have `note`: the change note (`Nohead-Change-Note`) a record
16
+ or schema change was made with, or `null`.
17
+
18
+ ## 0.11.0
19
+
20
+ - `records.diff` takes `richText`, and the client's `richText` now applies to
21
+ it: a rich text field's `before` and `after` read as HTML or Markdown
22
+ instead of documents. A revert preview's `changes` follow `richText` too.
23
+
8
24
  ## 0.10.0
9
25
 
10
26
  - Rich text reads as HTML or Markdown: `richText: "html"` (or `"markdown"`)
package/README.md CHANGED
@@ -14,6 +14,8 @@ for await (const post of nohead.records.list("posts", {
14
14
  }
15
15
  ```
16
16
 
17
+ The key is a project API key: create one under **API keys** in the [web app](https://app.nohead.io), with the **Read records** scope for this example, and set it as `NOHEAD_API_KEY` in your app's environment (or pass it as `apiKey`, under [Configuration](#configuration)). The SDK doesn't read the key that `nohead login` saves for the CLI: give your app a key of its own.
18
+
17
19
  > **Status:** 0.x until the Nohead API launches.
18
20
 
19
21
  ## Contents
@@ -159,7 +161,7 @@ await nohead.drafts.get(draftId, {}, { richText: "markdown" })
159
161
  ```
160
162
 
161
163
  - A rich text field's value is then a string: type it as one in the data's type, as above.
162
- - It applies to the methods that return records or drafts, and to the records they embed with `expand`; a request's `richText` overrides the client's. History (`revisions`) and webhooks keep documents.
164
+ - It applies to the methods that return records or drafts, to the records they embed with `expand`, and to the `before` and `after` of a `diff` or a revert preview's `changes`; a request's `richText` overrides the client's. History (`revisions`) and webhooks keep documents.
163
165
  - A string you write is read as Markdown, so write back Markdown or the document, never the HTML: with `richText: "html"` on the client, writes answer with HTML too.
164
166
 
165
167
  ## Pagination
@@ -98,6 +98,7 @@ export const RICH_TEXT_OPERATIONS = new Set([
98
98
  "records_bulk",
99
99
  "records_create",
100
100
  "records_delete",
101
+ "records_diff",
101
102
  "records_get",
102
103
  "records_list",
103
104
  "records_publish",
@@ -1083,8 +1083,14 @@ export type RecordList = {
1083
1083
  *
1084
1084
  */
1085
1085
  export type Change = {
1086
+ /**
1087
+ * The field's key now, after any rename (its last key if it was deleted); null if the field no longer exists.
1088
+ */
1086
1089
  field?: string | null;
1087
1090
  field_id?: string;
1091
+ /**
1092
+ * Whether the field has been deleted since.
1093
+ */
1088
1094
  field_deleted?: boolean;
1089
1095
  attribute?: 'published_at' | 'deleted_at';
1090
1096
  kind: 'added' | 'changed' | 'removed';
@@ -1141,6 +1147,9 @@ export type RevertPreview = {
1141
1147
  record_id: string;
1142
1148
  to_revision: number;
1143
1149
  data: RecordData;
1150
+ /**
1151
+ * What the revert would change. Rich text values read as `rich_text` asks, like `data`; a change that HTML or Markdown can't show (an underline, in Markdown) reads the same on both sides.
1152
+ */
1144
1153
  changes: Array<Change>;
1145
1154
  };
1146
1155
  export type FeatureFlags = {
@@ -1222,6 +1231,10 @@ export type WebhookProperties = {
1222
1231
  * The subscribed event types and wildcards (`record.*`, or `*` for all).
1223
1232
  */
1224
1233
  event_types: Array<WebhookSubscription>;
1234
+ /**
1235
+ * Send only events that change what a published-only API key can read: a record's change while it is published (or that publishes, unpublishes, deletes or restores it), schema changes, and changes to assets that published records use. Drafts, schedules, history redactions, uploads and purges are never sent. `webhook.test` always is.
1236
+ */
1237
+ published_only: boolean;
1225
1238
  enabled: boolean;
1226
1239
  /**
1227
1240
  * When the webhook was deleted; null unless it is.
@@ -1327,10 +1340,19 @@ export type AuditEvent = {
1327
1340
  * The client the change came through, when known.
1328
1341
  */
1329
1342
  via: null | Via;
1343
+ /**
1344
+ * The change note (`Nohead-Change-Note`) the change was made with,
1345
+ * read from the revision or schema change the event references, so
1346
+ * record and schema events have one when their change did; null
1347
+ * otherwise, and once a revision's history is pruned.
1348
+ *
1349
+ */
1350
+ note: string | null;
1330
1351
  /**
1331
1352
  * Small, action-specific references, e.g. `revision_id` and
1332
1353
  * `collection_id` for record events, `schema_change_id` for schema
1333
- * events, `changed` attribute names for updates. Never content.
1354
+ * events, `changed` attribute names for updates (field keys for a
1355
+ * draft's). Never content.
1334
1356
  *
1335
1357
  */
1336
1358
  metadata: {
@@ -1354,12 +1376,20 @@ export type WebhookCreate = {
1354
1376
  url: string;
1355
1377
  description?: string | null;
1356
1378
  event_types: Array<WebhookSubscription>;
1379
+ /**
1380
+ * Send only events that change what a published-only API key can read (`false` by default). It can't be combined with event types it never sends, such as `draft.*`.
1381
+ */
1382
+ published_only?: boolean;
1357
1383
  enabled?: boolean;
1358
1384
  };
1359
1385
  export type WebhookUpdate = {
1360
1386
  url?: string;
1361
1387
  description?: string | null;
1362
1388
  event_types?: Array<WebhookSubscription>;
1389
+ /**
1390
+ * Send only events that change what a published-only API key can read (`false` by default). It can't be combined with event types it never sends, such as `draft.*`.
1391
+ */
1392
+ published_only?: boolean;
1363
1393
  enabled?: boolean;
1364
1394
  };
1365
1395
  export type WebhookDeliveryProperties = {
@@ -3301,6 +3331,10 @@ export type RecordsDiffData = {
3301
3331
  query: {
3302
3332
  from: number;
3303
3333
  to: number;
3334
+ /**
3335
+ * How rich text values read in `changes`: `document`, the stored ProseMirror JSON document, or written as `html` or `markdown`, as records read with `rich_text`. Record history and webhooks keep documents. A change that HTML or Markdown can't show (an underline, in Markdown) reads the same on both sides. In HTML and Markdown, text from before a field became rich text reads as paragraphs; an older value that is no document of today's vocabulary, or a redacted one, is kept as stored.
3336
+ */
3337
+ rich_text?: 'document' | 'html' | 'markdown';
3304
3338
  };
3305
3339
  url: '/v1/records/{record_id}/diff';
3306
3340
  };
@@ -64,8 +64,11 @@ export declare class Records extends Resource {
64
64
  * Each record succeeds or fails on its own; see `results`.
65
65
  */
66
66
  bulk(collection: string, params: RecordBulkParams, options?: WriteOptions & RichTextOptions): APIPromise<RecordBatch>;
67
- /** The changes between two revisions. */
68
- diff(record: string, params: RecordDiffParams, options?: RequestOptions): APIPromise<RecordDiff>;
67
+ /**
68
+ * The changes between two revisions; with `richText`, rich text fields'
69
+ * `before` and `after` read as HTML or Markdown.
70
+ */
71
+ diff(record: string, params: RecordDiffParams, options?: RichTextOptions): APIPromise<RecordDiff>;
69
72
  /**
70
73
  * Full-text search in one collection, matching its `searchable` fields.
71
74
  * Pages through the first 1,000 hits, most relevant first.
@@ -92,7 +92,10 @@ export class Records extends Resource {
92
92
  bulk(collection, params, options) {
93
93
  return this.core.request("records_bulk", { path: { collection_id: collection }, body: params }, options);
94
94
  }
95
- /** The changes between two revisions. */
95
+ /**
96
+ * The changes between two revisions; with `richText`, rich text fields'
97
+ * `before` and `after` read as HTML or Markdown.
98
+ */
96
99
  diff(record, params, options) {
97
100
  return this.core.request("records_diff", { path: { record_id: record }, query: params }, options);
98
101
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.10.0";
1
+ export declare const VERSION = "0.12.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.10.0";
1
+ export const VERSION = "0.12.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nohead/sdk",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Official TypeScript SDK for the Nohead API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://nohead.io",