@nohead/sdk 0.1.0 → 0.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.
package/dist/core.js CHANGED
@@ -3,6 +3,12 @@ import { AbortError, ConnectionError, NoheadError, TimeoutError, apiError, retry
3
3
  import { OPERATIONS, } from "./generated/operations.gen.js";
4
4
  import { VERSION } from "./version.js";
5
5
  export const DEFAULT_BASE_URL = "https://api.nohead.io";
6
+ /**
7
+ * The string with lone surrogates (half an emoji, from cutting a string)
8
+ * replaced by U+FFFD, as `String.prototype.toWellFormed` does, so
9
+ * `encodeURIComponent` can encode it.
10
+ */
11
+ const wellFormed = (text) => text.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g, "\uFFFD");
6
12
  const RETRYABLE_STATUSES = new Set([429, 500, 502, 503, 504]);
7
13
  const MAX_RETRY_AFTER_SECONDS = 60;
8
14
  const warnedDeprecations = new Set();
@@ -15,6 +21,7 @@ export class Core {
15
21
  #maxRetries;
16
22
  #timeout;
17
23
  #warnings;
24
+ #onRetry;
18
25
  #projectId;
19
26
  constructor(options) {
20
27
  const env = environment();
@@ -24,13 +31,13 @@ export class Core {
24
31
  throw new NoheadError("Missing API key: pass `apiKey` or set NOHEAD_API_KEY");
25
32
  }
26
33
  this.#apiKey = apiKey;
27
- this.#baseUrl = (options.baseUrl ??
28
- (env.NOHEAD_API_URL || DEFAULT_BASE_URL)).replace(/\/+$/, "");
34
+ this.#baseUrl = withoutTrailingSlashes(options.baseUrl ?? (env.NOHEAD_API_URL || DEFAULT_BASE_URL));
29
35
  this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
30
36
  this.#headers = options.headers ?? {};
31
37
  this.#maxRetries = options.maxRetries ?? 2;
32
38
  this.#timeout = options.timeout ?? 60_000;
33
39
  this.#warnings = options.warnings ?? true;
40
+ this.#onRetry = options.onRetry;
34
41
  if (options.projectId)
35
42
  this.#projectId = Promise.resolve(options.projectId);
36
43
  }
@@ -68,18 +75,21 @@ export class Core {
68
75
  ? (options.maxRetries ?? this.#maxRetries)
69
76
  : 0;
70
77
  for (let attempt = 0;; attempt++) {
78
+ let failed;
71
79
  try {
72
80
  const { response } = await this.#attempt(url, init, options, false);
73
81
  if (!RETRYABLE_STATUSES.has(response.status) || attempt >= maxRetries) {
74
82
  return response;
75
83
  }
84
+ failed = { status: response.status };
76
85
  }
77
86
  catch (error) {
78
87
  if (!(error instanceof ConnectionError) || attempt >= maxRetries) {
79
88
  throw error;
80
89
  }
90
+ failed = { error };
81
91
  }
82
- await sleep(backoff(attempt), options.signal);
92
+ await this.#retry(url, attempt, backoff(attempt), failed, options.signal);
83
93
  }
84
94
  }
85
95
  async #send(operation, input, options) {
@@ -104,8 +114,10 @@ export class Core {
104
114
  : options.ifMatch;
105
115
  headers["If-Match"] = `"${revision}"`;
106
116
  }
117
+ // Percent-encoded UTF-8: header values are bytes, and fetch refuses
118
+ // anything past Latin-1 (the API decodes it).
107
119
  if (options.changeNote)
108
- headers["Nohead-Change-Note"] = options.changeNote;
120
+ headers["Nohead-Change-Note"] = encodeURIComponent(wellFormed(options.changeNote));
109
121
  Object.assign(headers, options.headers);
110
122
  const init = {
111
123
  method,
@@ -122,7 +134,7 @@ export class Core {
122
134
  if (!(error instanceof ConnectionError) || attempt >= maxRetries) {
123
135
  throw error;
124
136
  }
125
- await sleep(backoff(attempt), options.signal);
137
+ await this.#retry(url.toString(), attempt, backoff(attempt), { error }, options.signal);
126
138
  continue;
127
139
  }
128
140
  const { response, body } = result;
@@ -134,9 +146,13 @@ export class Core {
134
146
  const delay = retryDelay(error, attempt, maxRetries);
135
147
  if (delay === undefined)
136
148
  throw error;
137
- await sleep(delay, options.signal);
149
+ await this.#retry(url.toString(), attempt, delay, { status: response.status, error }, options.signal);
138
150
  }
139
151
  }
152
+ #retry(url, attempt, delay, failed, signal) {
153
+ this.#onRetry?.({ attempt: attempt + 1, delay, url, ...failed });
154
+ return sleep(delay, signal);
155
+ }
140
156
  async #attempt(url, init, options, readBody) {
141
157
  const timeout = options.timeout ?? this.#timeout;
142
158
  const timer = AbortSignal.timeout(timeout);
@@ -243,8 +259,9 @@ async function parseBody(response) {
243
259
  }
244
260
  /**
245
261
  * Query parameters as the API reads them: objects become `key[sub]=…`
246
- * (`filter[status]=published`), arrays are comma-separated
247
- * (`expand=author,tags`), dates are ISO 8601.
262
+ * (`filter[price][lt]=50`), arrays are comma-separated (`expand=author,tags`)
263
+ * with `\,` for a comma inside a value and `\\` for a backslash, dates are
264
+ * ISO 8601.
248
265
  */
249
266
  export function appendQuery(params, value, key) {
250
267
  if (value === undefined || value === null)
@@ -253,8 +270,10 @@ export function appendQuery(params, value, key) {
253
270
  params.append(key, value.toISOString());
254
271
  }
255
272
  else if (Array.isArray(value)) {
256
- if (value.length > 0)
257
- params.append(key, value.map(scalar).join(","));
273
+ // Missing items are left out, as missing values are.
274
+ const items = value.filter((item) => item !== undefined && item !== null);
275
+ if (items.length > 0)
276
+ params.append(key, items.map((item) => scalar(item).replace(/[\\,]/g, "\\$&")).join(","));
258
277
  }
259
278
  else if (typeof value === "object") {
260
279
  for (const [name, inner] of Object.entries(value)) {
@@ -284,6 +303,13 @@ function runtimeVersion() {
284
303
  return `node/${g.process.versions.node}`;
285
304
  return undefined;
286
305
  }
306
+ /** `url` without trailing slashes; a loop, as a regex backtracks on long runs of them. */
307
+ function withoutTrailingSlashes(url) {
308
+ let end = url.length;
309
+ while (end > 0 && url[end - 1] === "/")
310
+ end--;
311
+ return url.slice(0, end);
312
+ }
287
313
  function environment() {
288
314
  const process = globalThis.process;
289
315
  return process?.env ?? {};
package/dist/errors.d.ts CHANGED
@@ -8,8 +8,11 @@ export declare class APIError extends NoheadError {
8
8
  name: string;
9
9
  /** The HTTP status. */
10
10
  readonly status: number;
11
- /** The error `type`, e.g. `validation_error`; undefined if the body had none. */
12
- readonly type: ErrorType | undefined;
11
+ /**
12
+ * The error `type`, e.g. `validation_error`; undefined if the body had
13
+ * none. A type newer than this SDK is kept as its string.
14
+ */
15
+ readonly type: ErrorType | (string & {}) | undefined;
13
16
  /** The request's ID (`req_…`), for support requests and logs. */
14
17
  readonly requestId: string | undefined;
15
18
  /** Field-level details, e.g. `[{ field: "title", code: "required", … }]`. */
package/dist/errors.js CHANGED
@@ -7,7 +7,10 @@ export class APIError extends NoheadError {
7
7
  name = "APIError";
8
8
  /** The HTTP status. */
9
9
  status;
10
- /** The error `type`, e.g. `validation_error`; undefined if the body had none. */
10
+ /**
11
+ * The error `type`, e.g. `validation_error`; undefined if the body had
12
+ * none. A type newer than this SDK is kept as its string.
13
+ */
11
14
  type;
12
15
  /** The request's ID (`req_…`), for support requests and logs. */
13
16
  requestId;
@@ -97,7 +100,10 @@ export class UploadError extends NoheadError {
97
100
  export class WebhookVerificationError extends NoheadError {
98
101
  name = "WebhookVerificationError";
99
102
  }
100
- const CLASSES = {
103
+ // By error `type`, one class for each the SDK knows. A Map, so a lookup finds
104
+ // only these: a plain object would also find Object.prototype's
105
+ // (`constructor`, `toString`).
106
+ const CLASSES = new Map(Object.entries({
101
107
  invalid_request: InvalidRequestError,
102
108
  authentication_error: AuthenticationError,
103
109
  plan_limit_exceeded: PlanLimitExceededError,
@@ -109,11 +115,11 @@ const CLASSES = {
109
115
  rate_limited: RateLimitError,
110
116
  internal_error: InternalServerError,
111
117
  service_unavailable: ServiceUnavailableError,
112
- };
118
+ }));
113
119
  /** The error for a response, by its `type`, or by status when it has none. */
114
120
  export function apiError(status, body, headers) {
115
121
  const type = errorEnvelope(body)?.type;
116
- const Class = (type && CLASSES[type]) ||
122
+ const Class = (type && CLASSES.get(type)) ||
117
123
  (status === 503
118
124
  ? ServiceUnavailableError
119
125
  : status >= 500
@@ -133,12 +139,20 @@ export function retryAfterSeconds(headers) {
133
139
  ? undefined
134
140
  : Math.max(0, (date - Date.now()) / 1000);
135
141
  }
142
+ // The error envelope's fields that have the right type: a proxy or gateway
143
+ // in front of the API may answer with any JSON.
136
144
  function errorEnvelope(body) {
137
- if (typeof body !== "object" || body === null || !("error" in body)) {
145
+ if (!isObject(body) || !isObject(body.error))
138
146
  return undefined;
139
- }
140
- const error = body.error;
141
- return typeof error === "object" && error !== null
142
- ? error
143
- : undefined;
144
- }
147
+ const { type, message, request_id, details } = body.error;
148
+ return {
149
+ type: typeof type === "string" ? type : undefined,
150
+ message: typeof message === "string" ? message : undefined,
151
+ request_id: typeof request_id === "string" ? request_id : undefined,
152
+ // Only objects: currentRevision reads each detail's fields.
153
+ details: Array.isArray(details)
154
+ ? details.filter(isObject)
155
+ : undefined,
156
+ };
157
+ }
158
+ const isObject = (value) => typeof value === "object" && value !== null;
@@ -24,15 +24,23 @@ export declare const OPERATIONS: {
24
24
  readonly method: "GET";
25
25
  readonly path: "/v1/projects/{project_id}/assets";
26
26
  };
27
+ readonly assets_purge: {
28
+ readonly method: "POST";
29
+ readonly path: "/v1/assets/{asset_id}/purge";
30
+ };
27
31
  readonly assets_restore: {
28
32
  readonly method: "POST";
29
33
  readonly path: "/v1/assets/{asset_id}/restore";
30
34
  };
31
35
  readonly assets_upload: {
32
36
  readonly method: "POST";
33
- readonly path: "/v1/projects/{project_id}/assets/uploads";
37
+ readonly path: "/v1/projects/{project_id}/assets";
38
+ };
39
+ readonly assets_usage: {
40
+ readonly method: "GET";
41
+ readonly path: "/v1/assets/{asset_id}/usage";
34
42
  };
35
- readonly audit_events_list_for_project: {
43
+ readonly audit_events_list: {
36
44
  readonly method: "GET";
37
45
  readonly path: "/v1/projects/{project_id}/audit-events";
38
46
  };
@@ -68,6 +76,38 @@ export declare const OPERATIONS: {
68
76
  readonly method: "PATCH";
69
77
  readonly path: "/v1/collections/{collection_id}";
70
78
  };
79
+ readonly drafts_create: {
80
+ readonly method: "POST";
81
+ readonly path: "/v1/records/{record_id}/drafts";
82
+ };
83
+ readonly drafts_discard: {
84
+ readonly method: "DELETE";
85
+ readonly path: "/v1/drafts/{draft_id}";
86
+ };
87
+ readonly drafts_get: {
88
+ readonly method: "GET";
89
+ readonly path: "/v1/drafts/{draft_id}";
90
+ };
91
+ readonly drafts_list: {
92
+ readonly method: "GET";
93
+ readonly path: "/v1/collections/{collection_id}/drafts";
94
+ };
95
+ readonly drafts_merge: {
96
+ readonly method: "POST";
97
+ readonly path: "/v1/drafts/{draft_id}/merge";
98
+ };
99
+ readonly drafts_schedule: {
100
+ readonly method: "PUT";
101
+ readonly path: "/v1/drafts/{draft_id}/schedule";
102
+ };
103
+ readonly drafts_unschedule: {
104
+ readonly method: "DELETE";
105
+ readonly path: "/v1/drafts/{draft_id}/schedule";
106
+ };
107
+ readonly drafts_update: {
108
+ readonly method: "PATCH";
109
+ readonly path: "/v1/drafts/{draft_id}";
110
+ };
71
111
  readonly feature_flags_list: {
72
112
  readonly method: "GET";
73
113
  readonly path: "/v1/feature-flags";
@@ -80,6 +120,14 @@ export declare const OPERATIONS: {
80
120
  readonly method: "DELETE";
81
121
  readonly path: "/v1/fields/{field_id}";
82
122
  };
123
+ readonly fields_get: {
124
+ readonly method: "GET";
125
+ readonly path: "/v1/fields/{field_id}";
126
+ };
127
+ readonly fields_get_order: {
128
+ readonly method: "GET";
129
+ readonly path: "/v1/collections/{collection_id}/field-order";
130
+ };
83
131
  readonly fields_list: {
84
132
  readonly method: "GET";
85
133
  readonly path: "/v1/collections/{collection_id}/fields";
@@ -93,8 +141,8 @@ export declare const OPERATIONS: {
93
141
  readonly path: "/v1/fields/{field_id}/aliases/{alias}";
94
142
  };
95
143
  readonly fields_reorder: {
96
- readonly method: "POST";
97
- readonly path: "/v1/collections/{collection_id}/fields/reorder";
144
+ readonly method: "PUT";
145
+ readonly path: "/v1/collections/{collection_id}/field-order";
98
146
  };
99
147
  readonly fields_restore: {
100
148
  readonly method: "POST";
@@ -128,6 +176,10 @@ export declare const OPERATIONS: {
128
176
  readonly method: "GET";
129
177
  readonly path: "/v1/projects/{project_id}/search";
130
178
  };
179
+ readonly record_drafts_list: {
180
+ readonly method: "GET";
181
+ readonly path: "/v1/records/{record_id}/drafts";
182
+ };
131
183
  readonly record_revisions_get: {
132
184
  readonly method: "GET";
133
185
  readonly path: "/v1/records/{record_id}/revisions/{revision}";
@@ -142,7 +194,7 @@ export declare const OPERATIONS: {
142
194
  };
143
195
  readonly records_bulk: {
144
196
  readonly method: "POST";
145
- readonly path: "/v1/collections/{collection_id}/records/bulk";
197
+ readonly path: "/v1/collections/{collection_id}/record-batches";
146
198
  };
147
199
  readonly records_count: {
148
200
  readonly method: "GET";
@@ -164,13 +216,21 @@ export declare const OPERATIONS: {
164
216
  readonly method: "GET";
165
217
  readonly path: "/v1/records/{record_id}";
166
218
  };
219
+ readonly records_get_publication: {
220
+ readonly method: "GET";
221
+ readonly path: "/v1/records/{record_id}/publication";
222
+ };
223
+ readonly records_get_schedule: {
224
+ readonly method: "GET";
225
+ readonly path: "/v1/records/{record_id}/schedule";
226
+ };
167
227
  readonly records_list: {
168
228
  readonly method: "GET";
169
229
  readonly path: "/v1/collections/{collection_id}/records";
170
230
  };
171
231
  readonly records_publish: {
172
232
  readonly method: "POST";
173
- readonly path: "/v1/records/{record_id}/publish";
233
+ readonly path: "/v1/records/{record_id}/publication";
174
234
  };
175
235
  readonly records_restore: {
176
236
  readonly method: "POST";
@@ -181,8 +241,8 @@ export declare const OPERATIONS: {
181
241
  readonly path: "/v1/records/{record_id}/schedule";
182
242
  };
183
243
  readonly records_unpublish: {
184
- readonly method: "POST";
185
- readonly path: "/v1/records/{record_id}/unpublish";
244
+ readonly method: "DELETE";
245
+ readonly path: "/v1/records/{record_id}/publication";
186
246
  };
187
247
  readonly records_unschedule: {
188
248
  readonly method: "DELETE";
@@ -192,6 +252,10 @@ export declare const OPERATIONS: {
192
252
  readonly method: "PATCH";
193
253
  readonly path: "/v1/records/{record_id}";
194
254
  };
255
+ readonly scheduled_changes_list: {
256
+ readonly method: "GET";
257
+ readonly path: "/v1/collections/{collection_id}/scheduled-changes";
258
+ };
195
259
  readonly schema_changes_get: {
196
260
  readonly method: "GET";
197
261
  readonly path: "/v1/collections/{collection_id}/schema-changes/{schema_change_id}";
@@ -220,6 +284,14 @@ export declare const OPERATIONS: {
220
284
  readonly method: "POST";
221
285
  readonly path: "/v1/webhook-deliveries/{delivery_id}/retry";
222
286
  };
287
+ readonly webhook_secrets_list: {
288
+ readonly method: "GET";
289
+ readonly path: "/v1/webhooks/{webhook_id}/secrets";
290
+ };
291
+ readonly webhook_secrets_retire: {
292
+ readonly method: "DELETE";
293
+ readonly path: "/v1/webhook-secrets/{secret_id}";
294
+ };
223
295
  readonly webhooks_create: {
224
296
  readonly method: "POST";
225
297
  readonly path: "/v1/projects/{project_id}/webhooks";
@@ -236,9 +308,13 @@ export declare const OPERATIONS: {
236
308
  readonly method: "GET";
237
309
  readonly path: "/v1/projects/{project_id}/webhooks";
238
310
  };
311
+ readonly webhooks_restore: {
312
+ readonly method: "POST";
313
+ readonly path: "/v1/webhooks/{webhook_id}/restore";
314
+ };
239
315
  readonly webhooks_rotate_secret: {
240
316
  readonly method: "POST";
241
- readonly path: "/v1/webhooks/{webhook_id}/rotate-secret";
317
+ readonly path: "/v1/webhooks/{webhook_id}/secrets";
242
318
  };
243
319
  readonly webhooks_test: {
244
320
  readonly method: "POST";
@@ -275,6 +351,10 @@ export interface Operations {
275
351
  data: T.AssetsListData;
276
352
  response: T.AssetsListResponse;
277
353
  };
354
+ assets_purge: {
355
+ data: T.AssetsPurgeData;
356
+ response: T.AssetsPurgeResponse;
357
+ };
278
358
  assets_restore: {
279
359
  data: T.AssetsRestoreData;
280
360
  response: T.AssetsRestoreResponse;
@@ -283,9 +363,13 @@ export interface Operations {
283
363
  data: T.AssetsUploadData;
284
364
  response: T.AssetsUploadResponse;
285
365
  };
286
- audit_events_list_for_project: {
287
- data: T.AuditEventsListForProjectData;
288
- response: T.AuditEventsListForProjectResponse;
366
+ assets_usage: {
367
+ data: T.AssetsUsageData;
368
+ response: T.AssetsUsageResponse;
369
+ };
370
+ audit_events_list: {
371
+ data: T.AuditEventsListData;
372
+ response: T.AuditEventsListResponse;
289
373
  };
290
374
  collections_create: {
291
375
  data: T.CollectionsCreateData;
@@ -319,6 +403,38 @@ export interface Operations {
319
403
  data: T.CollectionsUpdateData;
320
404
  response: T.CollectionsUpdateResponse;
321
405
  };
406
+ drafts_create: {
407
+ data: T.DraftsCreateData;
408
+ response: T.DraftsCreateResponse;
409
+ };
410
+ drafts_discard: {
411
+ data: T.DraftsDiscardData;
412
+ response: T.DraftsDiscardResponse;
413
+ };
414
+ drafts_get: {
415
+ data: T.DraftsGetData;
416
+ response: T.DraftsGetResponse;
417
+ };
418
+ drafts_list: {
419
+ data: T.DraftsListData;
420
+ response: T.DraftsListResponse;
421
+ };
422
+ drafts_merge: {
423
+ data: T.DraftsMergeData;
424
+ response: T.DraftsMergeResponse;
425
+ };
426
+ drafts_schedule: {
427
+ data: T.DraftsScheduleData;
428
+ response: T.DraftsScheduleResponse;
429
+ };
430
+ drafts_unschedule: {
431
+ data: T.DraftsUnscheduleData;
432
+ response: T.DraftsUnscheduleResponse;
433
+ };
434
+ drafts_update: {
435
+ data: T.DraftsUpdateData;
436
+ response: T.DraftsUpdateResponse;
437
+ };
322
438
  feature_flags_list: {
323
439
  data: T.FeatureFlagsListData;
324
440
  response: T.FeatureFlagsListResponse;
@@ -331,6 +447,14 @@ export interface Operations {
331
447
  data: T.FieldsDeleteData;
332
448
  response: T.FieldsDeleteResponse;
333
449
  };
450
+ fields_get: {
451
+ data: T.FieldsGetData;
452
+ response: T.FieldsGetResponse;
453
+ };
454
+ fields_get_order: {
455
+ data: T.FieldsGetOrderData;
456
+ response: T.FieldsGetOrderResponse;
457
+ };
334
458
  fields_list: {
335
459
  data: T.FieldsListData;
336
460
  response: T.FieldsListResponse;
@@ -379,6 +503,10 @@ export interface Operations {
379
503
  data: T.ProjectsSearchData;
380
504
  response: T.ProjectsSearchResponse;
381
505
  };
506
+ record_drafts_list: {
507
+ data: T.RecordDraftsListData;
508
+ response: T.RecordDraftsListResponse;
509
+ };
382
510
  record_revisions_get: {
383
511
  data: T.RecordRevisionsGetData;
384
512
  response: T.RecordRevisionsGetResponse;
@@ -415,6 +543,14 @@ export interface Operations {
415
543
  data: T.RecordsGetData;
416
544
  response: T.RecordsGetResponse;
417
545
  };
546
+ records_get_publication: {
547
+ data: T.RecordsGetPublicationData;
548
+ response: T.RecordsGetPublicationResponse;
549
+ };
550
+ records_get_schedule: {
551
+ data: T.RecordsGetScheduleData;
552
+ response: T.RecordsGetScheduleResponse;
553
+ };
418
554
  records_list: {
419
555
  data: T.RecordsListData;
420
556
  response: T.RecordsListResponse;
@@ -443,6 +579,10 @@ export interface Operations {
443
579
  data: T.RecordsUpdateData;
444
580
  response: T.RecordsUpdateResponse;
445
581
  };
582
+ scheduled_changes_list: {
583
+ data: T.ScheduledChangesListData;
584
+ response: T.ScheduledChangesListResponse;
585
+ };
446
586
  schema_changes_get: {
447
587
  data: T.SchemaChangesGetData;
448
588
  response: T.SchemaChangesGetResponse;
@@ -471,6 +611,14 @@ export interface Operations {
471
611
  data: T.WebhookDeliveriesRetryData;
472
612
  response: T.WebhookDeliveriesRetryResponse;
473
613
  };
614
+ webhook_secrets_list: {
615
+ data: T.WebhookSecretsListData;
616
+ response: T.WebhookSecretsListResponse;
617
+ };
618
+ webhook_secrets_retire: {
619
+ data: T.WebhookSecretsRetireData;
620
+ response: T.WebhookSecretsRetireResponse;
621
+ };
474
622
  webhooks_create: {
475
623
  data: T.WebhooksCreateData;
476
624
  response: T.WebhooksCreateResponse;
@@ -487,6 +635,10 @@ export interface Operations {
487
635
  data: T.WebhooksListData;
488
636
  response: T.WebhooksListResponse;
489
637
  };
638
+ webhooks_restore: {
639
+ data: T.WebhooksRestoreData;
640
+ response: T.WebhooksRestoreResponse;
641
+ };
490
642
  webhooks_rotate_secret: {
491
643
  data: T.WebhooksRotateSecretData;
492
644
  response: T.WebhooksRotateSecretResponse;
@@ -5,9 +5,11 @@ export const OPERATIONS = {
5
5
  assets_get: { method: "GET", path: "/v1/assets/{asset_id}" },
6
6
  assets_image_url: { method: "GET", path: "/v1/assets/{asset_id}/image-url" },
7
7
  assets_list: { method: "GET", path: "/v1/projects/{project_id}/assets" },
8
+ assets_purge: { method: "POST", path: "/v1/assets/{asset_id}/purge" },
8
9
  assets_restore: { method: "POST", path: "/v1/assets/{asset_id}/restore" },
9
- assets_upload: { method: "POST", path: "/v1/projects/{project_id}/assets/uploads" },
10
- audit_events_list_for_project: { method: "GET", path: "/v1/projects/{project_id}/audit-events" },
10
+ assets_upload: { method: "POST", path: "/v1/projects/{project_id}/assets" },
11
+ assets_usage: { method: "GET", path: "/v1/assets/{asset_id}/usage" },
12
+ audit_events_list: { method: "GET", path: "/v1/projects/{project_id}/audit-events" },
11
13
  collections_create: { method: "POST", path: "/v1/projects/{project_id}/collections" },
12
14
  collections_delete: { method: "DELETE", path: "/v1/collections/{collection_id}" },
13
15
  collections_get: { method: "GET", path: "/v1/collections/{collection_id}" },
@@ -16,13 +18,23 @@ export const OPERATIONS = {
16
18
  collections_restore: { method: "POST", path: "/v1/collections/{collection_id}/restore" },
17
19
  collections_search: { method: "GET", path: "/v1/collections/{collection_id}/search" },
18
20
  collections_update: { method: "PATCH", path: "/v1/collections/{collection_id}" },
21
+ drafts_create: { method: "POST", path: "/v1/records/{record_id}/drafts" },
22
+ drafts_discard: { method: "DELETE", path: "/v1/drafts/{draft_id}" },
23
+ drafts_get: { method: "GET", path: "/v1/drafts/{draft_id}" },
24
+ drafts_list: { method: "GET", path: "/v1/collections/{collection_id}/drafts" },
25
+ drafts_merge: { method: "POST", path: "/v1/drafts/{draft_id}/merge" },
26
+ drafts_schedule: { method: "PUT", path: "/v1/drafts/{draft_id}/schedule" },
27
+ drafts_unschedule: { method: "DELETE", path: "/v1/drafts/{draft_id}/schedule" },
28
+ drafts_update: { method: "PATCH", path: "/v1/drafts/{draft_id}" },
19
29
  feature_flags_list: { method: "GET", path: "/v1/feature-flags" },
20
30
  fields_create: { method: "POST", path: "/v1/collections/{collection_id}/fields" },
21
31
  fields_delete: { method: "DELETE", path: "/v1/fields/{field_id}" },
32
+ fields_get: { method: "GET", path: "/v1/fields/{field_id}" },
33
+ fields_get_order: { method: "GET", path: "/v1/collections/{collection_id}/field-order" },
22
34
  fields_list: { method: "GET", path: "/v1/collections/{collection_id}/fields" },
23
35
  fields_migrate: { method: "POST", path: "/v1/fields/{field_id}/migrations" },
24
36
  fields_remove_alias: { method: "DELETE", path: "/v1/fields/{field_id}/aliases/{alias}" },
25
- fields_reorder: { method: "POST", path: "/v1/collections/{collection_id}/fields/reorder" },
37
+ fields_reorder: { method: "PUT", path: "/v1/collections/{collection_id}/field-order" },
26
38
  fields_restore: { method: "POST", path: "/v1/fields/{field_id}/restore" },
27
39
  fields_update: { method: "PATCH", path: "/v1/fields/{field_id}" },
28
40
  health_check: { method: "GET", path: "/v1/health" },
@@ -31,22 +43,26 @@ export const OPERATIONS = {
31
43
  migrations_get: { method: "GET", path: "/v1/migrations/{migration_id}" },
32
44
  migrations_list: { method: "GET", path: "/v1/collections/{collection_id}/migrations" },
33
45
  projects_search: { method: "GET", path: "/v1/projects/{project_id}/search" },
46
+ record_drafts_list: { method: "GET", path: "/v1/records/{record_id}/drafts" },
34
47
  record_revisions_get: { method: "GET", path: "/v1/records/{record_id}/revisions/{revision}" },
35
48
  record_revisions_list: { method: "GET", path: "/v1/records/{record_id}/revisions" },
36
49
  record_revisions_revert: { method: "POST", path: "/v1/records/{record_id}/revisions/{revision}/revert" },
37
- records_bulk: { method: "POST", path: "/v1/collections/{collection_id}/records/bulk" },
50
+ records_bulk: { method: "POST", path: "/v1/collections/{collection_id}/record-batches" },
38
51
  records_count: { method: "GET", path: "/v1/collections/{collection_id}/records/count" },
39
52
  records_create: { method: "POST", path: "/v1/collections/{collection_id}/records" },
40
53
  records_delete: { method: "DELETE", path: "/v1/records/{record_id}" },
41
54
  records_diff: { method: "GET", path: "/v1/records/{record_id}/diff" },
42
55
  records_get: { method: "GET", path: "/v1/records/{record_id}" },
56
+ records_get_publication: { method: "GET", path: "/v1/records/{record_id}/publication" },
57
+ records_get_schedule: { method: "GET", path: "/v1/records/{record_id}/schedule" },
43
58
  records_list: { method: "GET", path: "/v1/collections/{collection_id}/records" },
44
- records_publish: { method: "POST", path: "/v1/records/{record_id}/publish" },
59
+ records_publish: { method: "POST", path: "/v1/records/{record_id}/publication" },
45
60
  records_restore: { method: "POST", path: "/v1/records/{record_id}/restore" },
46
61
  records_schedule: { method: "PUT", path: "/v1/records/{record_id}/schedule" },
47
- records_unpublish: { method: "POST", path: "/v1/records/{record_id}/unpublish" },
62
+ records_unpublish: { method: "DELETE", path: "/v1/records/{record_id}/publication" },
48
63
  records_unschedule: { method: "DELETE", path: "/v1/records/{record_id}/schedule" },
49
64
  records_update: { method: "PATCH", path: "/v1/records/{record_id}" },
65
+ scheduled_changes_list: { method: "GET", path: "/v1/collections/{collection_id}/scheduled-changes" },
50
66
  schema_changes_get: { method: "GET", path: "/v1/collections/{collection_id}/schema-changes/{schema_change_id}" },
51
67
  schema_changes_list: { method: "GET", path: "/v1/collections/{collection_id}/schema-changes" },
52
68
  search_index_get: { method: "GET", path: "/v1/collections/{collection_id}/search-index" },
@@ -54,11 +70,14 @@ export const OPERATIONS = {
54
70
  webhook_deliveries_get: { method: "GET", path: "/v1/webhook-deliveries/{delivery_id}" },
55
71
  webhook_deliveries_list: { method: "GET", path: "/v1/webhooks/{webhook_id}/deliveries" },
56
72
  webhook_deliveries_retry: { method: "POST", path: "/v1/webhook-deliveries/{delivery_id}/retry" },
73
+ webhook_secrets_list: { method: "GET", path: "/v1/webhooks/{webhook_id}/secrets" },
74
+ webhook_secrets_retire: { method: "DELETE", path: "/v1/webhook-secrets/{secret_id}" },
57
75
  webhooks_create: { method: "POST", path: "/v1/projects/{project_id}/webhooks" },
58
76
  webhooks_delete: { method: "DELETE", path: "/v1/webhooks/{webhook_id}" },
59
77
  webhooks_get: { method: "GET", path: "/v1/webhooks/{webhook_id}" },
60
78
  webhooks_list: { method: "GET", path: "/v1/projects/{project_id}/webhooks" },
61
- webhooks_rotate_secret: { method: "POST", path: "/v1/webhooks/{webhook_id}/rotate-secret" },
79
+ webhooks_restore: { method: "POST", path: "/v1/webhooks/{webhook_id}/restore" },
80
+ webhooks_rotate_secret: { method: "POST", path: "/v1/webhooks/{webhook_id}/secrets" },
62
81
  webhooks_test: { method: "POST", path: "/v1/webhooks/{webhook_id}/test" },
63
82
  webhooks_update: { method: "PATCH", path: "/v1/webhooks/{webhook_id}" },
64
83
  };
@@ -1 +1 @@
1
- export type { AccessReview, Actor, ApiKey, ApiKeyCreate, ApiKeyList, ApiKeyProperties, ApiKeyScope, ApiKeyWithToken, Asset, AssetList, AssetUpload, AssetUploadCreate, AuditEvent, AuditEventList, Billing, BillingCheckout, BillingPlan, BillingPortal, BillingSession, BillingSubscription, BulkRecordsRequest, BulkRecordsResult, Change, ChangeVia, Collection, CollectionCreate, CollectionList, CollectionUpdate, DownloadUrl, Error, ErrorDetail, ErrorType, FeatureFlags, Field, FieldCreate, FieldDefinition, FieldList, FieldMigration, FieldMigrationCounts, FieldMigrationList, FieldMigrationPreview, FieldMigrationRequest, FieldType, FieldUpdate, Health, ImageUrl, Invitation, InvitationCreate, InvitationList, ListMeta, MeUpdate, Membership, MembershipList, MembershipUpdate, NullableTimestamp, Organization, OrganizationCreate, OrganizationList, OrganizationUpdate, Permission, Principal, Project, ProjectCreate, ProjectList, ProjectUpdate, PublishedOnly, RecordCount, RecordData, RecordDiff, RecordList, RecordRevision, RecordRevisionDetail, RecordRevisionList, RecordRevisionProperties, RecordSchedule, RecordScheduleUpdate, RecordWrite, Redaction, RequestId, RevertPreview, Role, Schema, SchemaChange, SchemaChangeDetail, SchemaChangeList, SchemaChangeProperties, SchemaDefinition, SearchIndex, SearchResults, Timestamp, Usage, UsageMetric, Via, Webhook, WebhookCreate, WebhookDelivery, WebhookDeliveryDetail, WebhookDeliveryList, WebhookDeliveryProperties, WebhookEventPayload, WebhookEventType, WebhookList, WebhookProperties, WebhookUpdate, WebhookWithSecret, } from "./types.gen.ts";
1
+ export type { Actor, ApiKeyScope, Asset, AssetEventData, AssetList, AssetProperties, AssetUploadCreate, AssetUploadTarget, AssetUsage, AssetWithUpload, AuditEvent, AuditEventList, Change, Collection, CollectionCreate, CollectionList, CollectionUpdate, DownloadUrl, Draft, DraftCreate, DraftEventData, DraftList, DraftSchedule, DraftScheduleUpdate, Error, ErrorDetail, ErrorType, FeatureFlags, Field, FieldAliasEventData, FieldCreate, FieldDefinition, FieldList, FieldMigration, FieldMigrationCounts, FieldMigrationList, FieldMigrationPreview, FieldMigrationRequest, FieldOrder, FieldType, FieldUpdate, Health, ImageUrl, ListMeta, MergedDraft, NullableTimestamp, Principal, PublishedOnly, RecordBatch, RecordBatchRequest, RecordCount, RecordData, RecordDiff, RecordEventData, RecordFilterValue, RecordList, RecordPublication, RecordRevision, RecordRevisionDetail, RecordRevisionList, RecordRevisionOperation, RecordRevisionProperties, RecordSchedule, RecordScheduleUpdate, RecordWrite, RequestId, RevertPreview, ScheduledChange, ScheduledChangeList, Schema, SchemaChange, SchemaChangeDetail, SchemaChangeList, SchemaChangeProperties, SchemaDefinition, SchemaEventData, SearchIndex, SearchResults, TimeFilter, Timestamp, Via, Webhook, WebhookCreate, WebhookDelivery, WebhookDeliveryDetail, WebhookDeliveryList, WebhookDeliveryProperties, WebhookEventPayload, WebhookEventType, WebhookList, WebhookProperties, WebhookSecret, WebhookSecretList, WebhookSecretProperties, WebhookSecretWithValue, WebhookSubscription, WebhookTestEventData, WebhookUpdate, WebhookWithSecret, } from "./types.gen.ts";