@nohead/sdk 0.4.0 → 0.5.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,26 @@ 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.5.0
9
+
10
+ - **Breaking:** field migrations are created under their collection:
11
+ `migrations.create(collection, { field_id, ...changes, dry_run? })`
12
+ (`POST /v1/collections/{collection_id}/migrations`) replaces
13
+ `fields.migrate(field, ...)`. It returns a preview for a dry run and the
14
+ `FieldMigration` otherwise, as before. `FieldMigrateParams` is
15
+ `MigrationCreateParams`, with `field_id`.
16
+ - **Breaking:** `drafts.list` no longer takes `record_id`; a record's drafts
17
+ are `records.drafts(record)`.
18
+ - **Breaking:** `assets.list`'s `content_type` is one MIME type or `type/*`
19
+ wildcard as a string, or several as a list (sent as
20
+ `filter[content_type][in]`). A comma-separated string no longer lists
21
+ several types: pass a list.
22
+ - **Breaking:** `auditEvents.list` sorts by `created_at` or `-created_at`
23
+ (the default), not `id`, and records no longer sort by `id`.
24
+ - Webhook events always carry `actor` and `via` (now required in
25
+ `WebhookEventPayload`), and `Via` no longer has `import` or `migration`,
26
+ which were never sent.
27
+
8
28
  ## 0.4.0
9
29
 
10
30
  - **Breaking:** a field's `api_key` is its `key` (in fields, their aliases,
package/README.md CHANGED
@@ -118,7 +118,7 @@ await nohead.drafts.merge(draft.id) // or drafts.schedule(draft.id, { merge_at }
118
118
 
119
119
  - A record has at most one draft; starting a second is a `ConflictError` (detail code `draft_exists`, with its `draft_id`).
120
120
  - A merge changes content only: a live record stays live, an unpublished one unpublished. Publishing a live record with a pending draft is a `ConflictError` (`draft_pending`).
121
- - `records.drafts(id)` lists a record's draft, and `drafts.list(collection, { record_id })` a collection's (`record_id` takes up to 100 IDs).
121
+ - `records.drafts(id)` lists a record's draft, and `drafts.list(collection)` a collection's.
122
122
  - `drafts.discard` deletes one for good.
123
123
  - Drafts take the type of their data as records do: `drafts.get<Post>(id)` is a `Nohead.Draft<Post>` (also exported as `NoheadDraft`).
124
124
 
@@ -315,11 +315,15 @@ await nohead.fields.create("posts", {
315
315
  })
316
316
 
317
317
  // Changes that rewrite records go through a migration; preview first
318
- const preview = await nohead.fields.migrate("fld_…", {
318
+ const preview = await nohead.migrations.create("posts", {
319
+ field_id: "fld_…",
319
320
  type: "long_text",
320
321
  dry_run: true,
321
322
  })
322
- const migration = await nohead.fields.migrate("fld_…", { type: "long_text" })
323
+ const migration = await nohead.migrations.create("posts", {
324
+ field_id: "fld_…",
325
+ type: "long_text",
326
+ })
323
327
  await nohead.migrations.get(migration.id)
324
328
  ```
325
329
 
@@ -370,8 +374,8 @@ response.headers.get("RateLimit-Remaining")
370
374
  | `collections` | `list`, `get`, `create`, `update`, `delete`, `restore`, `schema` |
371
375
  | `collections.schemaChanges` | `list`, `get` |
372
376
  | `collections.searchIndex` | `get`, `rebuild` |
373
- | `fields` | `list`, `get`, `create`, `update`, `delete`, `restore`, `order`, `reorder`, `removeAlias`, `migrate` |
374
- | `migrations` | `list`, `get`, `cancel` |
377
+ | `fields` | `list`, `get`, `create`, `update`, `delete`, `restore`, `order`, `reorder`, `removeAlias` |
378
+ | `migrations` | `create`, `list`, `get`, `cancel` |
375
379
  | `assets` | `upload`, `createUpload`, `complete`, `list`, `get`, `delete`, `restore`, `purge`, `usage`, `imageUrl`, `downloadUrl` |
376
380
  | `webhooks` | `list`, `get`, `create`, `update`, `delete`, `restore`, `rotateSecret`, `test`, `unwrap` |
377
381
  | `webhooks.secrets` | `list`, `retire` |
@@ -132,10 +132,6 @@ export declare const OPERATIONS: {
132
132
  readonly method: "GET";
133
133
  readonly path: "/v1/collections/{collection_id}/fields";
134
134
  };
135
- readonly fields_migrate: {
136
- readonly method: "POST";
137
- readonly path: "/v1/fields/{field_id}/migrations";
138
- };
139
135
  readonly fields_remove_alias: {
140
136
  readonly method: "DELETE";
141
137
  readonly path: "/v1/fields/{field_id}/aliases/{alias}";
@@ -164,6 +160,10 @@ export declare const OPERATIONS: {
164
160
  readonly method: "POST";
165
161
  readonly path: "/v1/migrations/{migration_id}/cancel";
166
162
  };
163
+ readonly migrations_create: {
164
+ readonly method: "POST";
165
+ readonly path: "/v1/collections/{collection_id}/migrations";
166
+ };
167
167
  readonly migrations_get: {
168
168
  readonly method: "GET";
169
169
  readonly path: "/v1/migrations/{migration_id}";
@@ -459,10 +459,6 @@ export interface Operations {
459
459
  data: T.FieldsListData;
460
460
  response: T.FieldsListResponse;
461
461
  };
462
- fields_migrate: {
463
- data: T.FieldsMigrateData;
464
- response: T.FieldsMigrateResponse;
465
- };
466
462
  fields_remove_alias: {
467
463
  data: T.FieldsRemoveAliasData;
468
464
  response: T.FieldsRemoveAliasResponse;
@@ -491,6 +487,10 @@ export interface Operations {
491
487
  data: T.MigrationsCancelData;
492
488
  response: T.MigrationsCancelResponse;
493
489
  };
490
+ migrations_create: {
491
+ data: T.MigrationsCreateData;
492
+ response: T.MigrationsCreateResponse;
493
+ };
494
494
  migrations_get: {
495
495
  data: T.MigrationsGetData;
496
496
  response: T.MigrationsGetResponse;
@@ -32,7 +32,6 @@ export const OPERATIONS = {
32
32
  fields_get: { method: "GET", path: "/v1/fields/{field_id}" },
33
33
  fields_get_order: { method: "GET", path: "/v1/collections/{collection_id}/field-order" },
34
34
  fields_list: { method: "GET", path: "/v1/collections/{collection_id}/fields" },
35
- fields_migrate: { method: "POST", path: "/v1/fields/{field_id}/migrations" },
36
35
  fields_remove_alias: { method: "DELETE", path: "/v1/fields/{field_id}/aliases/{alias}" },
37
36
  fields_reorder: { method: "PUT", path: "/v1/collections/{collection_id}/field-order" },
38
37
  fields_restore: { method: "POST", path: "/v1/fields/{field_id}/restore" },
@@ -40,6 +39,7 @@ export const OPERATIONS = {
40
39
  health_check: { method: "GET", path: "/v1/health" },
41
40
  me_get: { method: "GET", path: "/v1/me" },
42
41
  migrations_cancel: { method: "POST", path: "/v1/migrations/{migration_id}/cancel" },
42
+ migrations_create: { method: "POST", path: "/v1/collections/{collection_id}/migrations" },
43
43
  migrations_get: { method: "GET", path: "/v1/migrations/{migration_id}" },
44
44
  migrations_list: { method: "GET", path: "/v1/collections/{collection_id}/migrations" },
45
45
  projects_search: { method: "GET", path: "/v1/projects/{project_id}/search" },
@@ -683,9 +683,13 @@ export type FieldDefinition = {
683
683
  required: boolean;
684
684
  };
685
685
  /**
686
- * The parts of the definition to change; omitted parts stay as they are.
686
+ * The field, and the parts of its definition to change; omitted parts stay as they are.
687
687
  */
688
688
  export type FieldMigrationRequest = {
689
+ /**
690
+ * One of the collection's fields (`422` otherwise).
691
+ */
692
+ field_id: string;
689
693
  type?: FieldType;
690
694
  /**
691
695
  * The complete new configuration. When the type changes and this is omitted, only `description`, `searchable`, `filterable` and `sortable` carry over.
@@ -870,9 +874,9 @@ export type TimeFilter = {
870
874
  lt?: string;
871
875
  };
872
876
  /**
873
- * The client a change came through; `scheduler` for scheduled changes. `import` and `migration` are not sent yet.
877
+ * The client a change came through; `scheduler` for scheduled changes.
874
878
  */
875
- export type Via = 'ui' | 'api' | 'cli' | 'sdk' | 'import' | 'migration' | 'system' | 'scheduler';
879
+ export type Via = 'ui' | 'api' | 'cli' | 'sdk' | 'system' | 'scheduler';
876
880
  /**
877
881
  * Changes to a record's content that wait until they are merged into
878
882
  * it, now or at `schedule.merge_at`. Content only: whether the record
@@ -1365,16 +1369,16 @@ export type WebhookEventPayload = {
1365
1369
  created_at: Timestamp;
1366
1370
  project_id: string;
1367
1371
  /**
1368
- * Who made the change. Always sent.
1372
+ * Who made the change.
1369
1373
  */
1370
- actor?: Actor;
1374
+ actor: Actor;
1371
1375
  /**
1372
- * The client the change came through (null when not known). Always
1373
- * sent. An integration that writes back can skip changes made with its own
1374
- * API key (`actor`).
1376
+ * The client the change came through (null when not known). An
1377
+ * integration that writes back can skip changes made with its own API
1378
+ * key (`actor`).
1375
1379
  *
1376
1380
  */
1377
- via?: null | Via;
1381
+ via: null | Via;
1378
1382
  data: RecordEventData | DraftEventData | AssetEventData | SchemaEventData | FieldAliasEventData | WebhookTestEventData;
1379
1383
  };
1380
1384
  /**
@@ -1700,7 +1704,7 @@ export type RecordRevisionFilter = {
1700
1704
  actor_id?: string;
1701
1705
  created_at?: TimeFilter;
1702
1706
  };
1703
- export type AuditEventSort = 'id' | '-id';
1707
+ export type AuditEventSort = 'created_at' | '-created_at';
1704
1708
  /**
1705
1709
  * Page size.
1706
1710
  */
@@ -1717,14 +1721,20 @@ export type DeletedFilter = {
1717
1721
  };
1718
1722
  /**
1719
1723
  * `filter[deleted]=true` lists deleted assets instead.
1720
- * `filter[content_type]` lists only assets of those types: comma-separated
1721
- * MIME types or `type*` wildcards, for example the ones an asset field
1722
- * accepts (its `accepted_types`).
1724
+ * `filter[content_type]` lists only assets of a type: a MIME type or a
1725
+ * `type*` wildcard, or several with
1726
+ * `filter[content_type][in]=image*,application/pdf`, for example the
1727
+ * ones an asset field accepts (its `accepted_types`).
1723
1728
  *
1724
1729
  */
1725
1730
  export type AssetFilter = {
1726
1731
  deleted?: 'true' | 'false';
1727
- content_type?: string;
1732
+ content_type?: string | {
1733
+ /**
1734
+ * Up to 50 comma-separated MIME types or `type*` wildcards.
1735
+ */
1736
+ in: string;
1737
+ };
1728
1738
  };
1729
1739
  /**
1730
1740
  * The revision you last read (the record's, or the draft's for a draft), e.g. `"7"`. Stale writes fail with 412.
@@ -1794,8 +1804,8 @@ export type RecordsListData = {
1794
1804
  [key: string]: RecordFilterValue;
1795
1805
  };
1796
1806
  /**
1797
- * `id`, `created_at`, `updated_at`, `published_at` (unpublished
1798
- * records first), or the key of a text, number, boolean, date or
1807
+ * `created_at`, `updated_at`, `published_at` (unpublished records
1808
+ * first), or the key of a text, number, boolean, date or
1799
1809
  * enum field with one value (records without a value last, in both
1800
1810
  * directions; text by code point). `-` for descending.
1801
1811
  *
@@ -3195,14 +3205,6 @@ export type DraftsListData = {
3195
3205
  collection_id: string;
3196
3206
  };
3197
3207
  query?: {
3198
- filter?: {
3199
- record_id?: string | {
3200
- /**
3201
- * Up to 100 comma-separated record IDs.
3202
- */
3203
- in: string;
3204
- };
3205
- };
3206
3208
  sort?: 'updated_at' | '-updated_at';
3207
3209
  /**
3208
3210
  * Page size.
@@ -4878,7 +4880,7 @@ export type MigrationsListResponses = {
4878
4880
  200: FieldMigrationList;
4879
4881
  };
4880
4882
  export type MigrationsListResponse = MigrationsListResponses[keyof MigrationsListResponses];
4881
- export type FieldsMigrateData = {
4883
+ export type MigrationsCreateData = {
4882
4884
  body: FieldMigrationRequest;
4883
4885
  headers?: {
4884
4886
  /**
@@ -4907,14 +4909,17 @@ export type FieldsMigrateData = {
4907
4909
  'Nohead-Change-Note'?: string;
4908
4910
  };
4909
4911
  path: {
4910
- field_id: string;
4912
+ /**
4913
+ * Collection ID, or the collection slug when authenticating with an API key.
4914
+ */
4915
+ collection_id: string;
4911
4916
  };
4912
4917
  query?: {
4913
4918
  dry_run?: boolean;
4914
4919
  };
4915
- url: '/v1/fields/{field_id}/migrations';
4920
+ url: '/v1/collections/{collection_id}/migrations';
4916
4921
  };
4917
- export type FieldsMigrateErrors = {
4922
+ export type MigrationsCreateErrors = {
4918
4923
  /**
4919
4924
  * The request was malformed: unparseable JSON, an invalid query parameter, or a body key the operation doesn't take (detail code `unknown_parameter`, naming the key).
4920
4925
  */
@@ -4948,8 +4953,8 @@ export type FieldsMigrateErrors = {
4948
4953
  */
4949
4954
  429: Error;
4950
4955
  };
4951
- export type FieldsMigrateError = FieldsMigrateErrors[keyof FieldsMigrateErrors];
4952
- export type FieldsMigrateResponses = {
4956
+ export type MigrationsCreateError = MigrationsCreateErrors[keyof MigrationsCreateErrors];
4957
+ export type MigrationsCreateResponses = {
4953
4958
  /**
4954
4959
  * A preview (dry runs only).
4955
4960
  */
@@ -4959,7 +4964,7 @@ export type FieldsMigrateResponses = {
4959
4964
  */
4960
4965
  202: FieldMigration;
4961
4966
  };
4962
- export type FieldsMigrateResponse = FieldsMigrateResponses[keyof FieldsMigrateResponses];
4967
+ export type MigrationsCreateResponse = MigrationsCreateResponses[keyof MigrationsCreateResponses];
4963
4968
  export type MigrationsGetData = {
4964
4969
  body?: never;
4965
4970
  path: {
@@ -5080,14 +5085,20 @@ export type AssetsListData = {
5080
5085
  cursor?: string;
5081
5086
  /**
5082
5087
  * `filter[deleted]=true` lists deleted assets instead.
5083
- * `filter[content_type]` lists only assets of those types: comma-separated
5084
- * MIME types or `type*` wildcards, for example the ones an asset field
5085
- * accepts (its `accepted_types`).
5088
+ * `filter[content_type]` lists only assets of a type: a MIME type or a
5089
+ * `type*` wildcard, or several with
5090
+ * `filter[content_type][in]=image*,application/pdf`, for example the
5091
+ * ones an asset field accepts (its `accepted_types`).
5086
5092
  *
5087
5093
  */
5088
5094
  filter?: {
5089
5095
  deleted?: 'true' | 'false';
5090
- content_type?: string;
5096
+ content_type?: string | {
5097
+ /**
5098
+ * Up to 50 comma-separated MIME types or `type*` wildcards.
5099
+ */
5100
+ in: string;
5101
+ };
5091
5102
  };
5092
5103
  };
5093
5104
  url: '/v1/projects/{project_id}/assets';
@@ -6725,7 +6736,7 @@ export type AuditEventsListData = {
6725
6736
  actor_id?: string;
6726
6737
  created_at?: TimeFilter;
6727
6738
  };
6728
- sort?: 'id' | '-id';
6739
+ sort?: 'created_at' | '-created_at';
6729
6740
  };
6730
6741
  url: '/v1/projects/{project_id}/audit-events';
6731
6742
  };
@@ -38,7 +38,7 @@ export declare class Assets extends Resource {
38
38
  createUpload(params: AssetUploadCreate, options?: RequestOptions): APIPromise<AssetWithUpload>;
39
39
  /** Checks an uploaded file and marks the asset `ready`. */
40
40
  complete(asset: string, options?: RequestOptions): APIPromise<Asset>;
41
- list(params?: AssetListParams, options?: RequestOptions): PagePromise<Asset>;
41
+ list({ content_type, ...params }?: AssetListParams, options?: RequestOptions): PagePromise<Asset>;
42
42
  get(asset: string, options?: RequestOptions): APIPromise<Asset>;
43
43
  /**
44
44
  * Soft-deletes the asset: `restore` brings it back until its
@@ -74,8 +74,15 @@ export class Assets extends Resource {
74
74
  complete(asset, options) {
75
75
  return this.core.request("assets_complete", { path: { asset_id: asset } }, options);
76
76
  }
77
- list(params = {}, options) {
78
- return this.core.paginate("assets_list", { query: listQuery(params, ["deleted", "content_type"]) }, options);
77
+ list({ content_type, ...params } = {}, options) {
78
+ return this.core.paginate("assets_list", {
79
+ query: listQuery({
80
+ ...params,
81
+ content_type: Array.isArray(content_type)
82
+ ? { in: content_type }
83
+ : content_type,
84
+ }, ["deleted", "content_type"]),
85
+ }, options);
79
86
  }
80
87
  get(asset, options) {
81
88
  return this.core.request("assets_get", { path: { asset_id: asset } }, options);
@@ -19,11 +19,10 @@ export declare class Drafts extends Resource {
19
19
  */
20
20
  create<D = RecordData>(record: string, params?: DraftCreateParams<D>, options?: RequestOptions): APIPromise<NoheadDraft<D>>;
21
21
  /**
22
- * A collection's drafts, most recently changed first. `record_id` narrows
23
- * them to one record, or to several (1 to 100; an empty list is a
24
- * `TypeError`, since it would match no record).
22
+ * A collection's drafts, most recently changed first. One record's draft
23
+ * is `records.drafts(record)`.
25
24
  */
26
- list<D = RecordData>(collection: string, { record_id, ...params }?: DraftListParams, options?: RequestOptions): PagePromise<NoheadDraft<D>>;
25
+ list<D = RecordData>(collection: string, params?: DraftListParams, options?: RequestOptions): PagePromise<NoheadDraft<D>>;
27
26
  /** With `data` as the record reads after the merge, for previews. */
28
27
  get<D = RecordData>(draft: string, params?: DraftGetParams, options?: RequestOptions): APIPromise<NoheadDraft<D>>;
29
28
  /** Sets the given fields (`null` clears one), as a record update does. */
@@ -17,22 +17,11 @@ export class Drafts extends Resource {
17
17
  return this.core.request("drafts_create", { path: { record_id: record }, body: params }, options);
18
18
  }
19
19
  /**
20
- * A collection's drafts, most recently changed first. `record_id` narrows
21
- * them to one record, or to several (1 to 100; an empty list is a
22
- * `TypeError`, since it would match no record).
20
+ * A collection's drafts, most recently changed first. One record's draft
21
+ * is `records.drafts(record)`.
23
22
  */
24
- list(collection, { record_id, ...params } = {}, options) {
25
- if (Array.isArray(record_id) && record_id.length === 0)
26
- throw new TypeError("record_id needs at least one record ID");
27
- const filter = record_id === undefined
28
- ? undefined
29
- : {
30
- record_id: Array.isArray(record_id) ? { in: record_id } : record_id,
31
- };
32
- return this.core.paginate("drafts_list", {
33
- path: { collection_id: collection },
34
- query: { ...params, ...(filter && { filter }) },
35
- }, options);
23
+ list(collection, params = {}, options) {
24
+ return this.core.paginate("drafts_list", { path: { collection_id: collection }, query: params }, options);
36
25
  }
37
26
  /** With `data` as the record reads after the merge, for previews. */
38
27
  get(draft, params = {}, options) {
@@ -1,7 +1,7 @@
1
1
  import type { APIPromise, PagePromise } from "../api-promise.ts";
2
2
  import type { RequestOptions, WriteOptions } from "../core.ts";
3
3
  import type { Collection, FieldOrder, CollectionCreate, CollectionUpdate, Field, FieldCreate, FieldMigration, FieldMigrationPreview, FieldUpdate, Schema, SchemaChange, SchemaChangeDetail, SearchIndex } from "../generated/types.gen.ts";
4
- import type { DeletedListParams, DryRunParams, FieldMigrateParams, FieldReorderParams, ListParams, SchemaParams } from "../types.ts";
4
+ import type { DeletedListParams, DryRunParams, FieldReorderParams, ListParams, MigrationCreateParams, SchemaParams } from "../types.ts";
5
5
  import { Resource } from "./resource.ts";
6
6
  /** Collections of the key's project. `collection` is an ID or slug. */
7
7
  export declare class Collections extends Resource {
@@ -39,7 +39,7 @@ export declare class Fields extends Resource {
39
39
  get(field: string, options?: RequestOptions): APIPromise<Field>;
40
40
  /**
41
41
  * Renames, describes or loosens a field. Changes that rewrite record
42
- * values (type, `multiple`, tighter rules) are `migrate`.
42
+ * values (type, `multiple`, tighter rules) are `migrations.create`.
43
43
  */
44
44
  update(field: string, params: FieldUpdate, options?: WriteOptions): APIPromise<Field>;
45
45
  /**
@@ -54,17 +54,18 @@ export declare class Fields extends Resource {
54
54
  reorder(collection: string, params: FieldReorderParams, options?: WriteOptions): APIPromise<FieldOrder>;
55
55
  /** Stops accepting a renamed field's old API key before its 6 months end. */
56
56
  removeAlias(field: string, alias: string, options?: RequestOptions): APIPromise<Field>;
57
+ }
58
+ /** Field migrations. While one runs, its collection is read-only. */
59
+ export declare class Migrations extends Resource {
57
60
  /**
58
- * Starts a field migration (type, `multiple`, tighter configuration or a
59
- * backfill) that rewrites every record. With `dry_run`, previews it.
61
+ * Starts a migration of one of the collection's fields (`field_id`): a
62
+ * type, `multiple`, tighter configuration or a backfill, which rewrites
63
+ * every record. With `dry_run`, previews it.
60
64
  */
61
- migrate(field: string, params: FieldMigrateParams & {
65
+ create(collection: string, params: MigrationCreateParams & {
62
66
  dry_run: true;
63
67
  }, options?: WriteOptions): APIPromise<FieldMigrationPreview>;
64
- migrate(field: string, params: FieldMigrateParams & DryRunParams, options?: WriteOptions): APIPromise<FieldMigration>;
65
- }
66
- /** Field migrations. While one runs, its collection is read-only. */
67
- export declare class Migrations extends Resource {
68
+ create(collection: string, params: MigrationCreateParams & DryRunParams, options?: WriteOptions): APIPromise<FieldMigration>;
68
69
  list(collection: string, params?: ListParams, options?: RequestOptions): PagePromise<FieldMigration>;
69
70
  get(migration: string, options?: RequestOptions): APIPromise<FieldMigration>;
70
71
  cancel(migration: string, options?: RequestOptions): APIPromise<FieldMigration>;
@@ -66,7 +66,7 @@ export class Fields extends Resource {
66
66
  }
67
67
  /**
68
68
  * Renames, describes or loosens a field. Changes that rewrite record
69
- * values (type, `multiple`, tighter rules) are `migrate`.
69
+ * values (type, `multiple`, tighter rules) are `migrations.create`.
70
70
  */
71
71
  update(field, params, options) {
72
72
  return this.core.request("fields_update", { path: { field_id: field }, body: params }, options);
@@ -93,12 +93,12 @@ export class Fields extends Resource {
93
93
  removeAlias(field, alias, options) {
94
94
  return this.core.request("fields_remove_alias", { path: { field_id: field, alias } }, options);
95
95
  }
96
- migrate(field, { dry_run, ...body }, options) {
97
- return this.core.request("fields_migrate", { path: { field_id: field }, query: { dry_run }, body }, options);
98
- }
99
96
  }
100
97
  /** Field migrations. While one runs, its collection is read-only. */
101
98
  export class Migrations extends Resource {
99
+ create(collection, { dry_run, ...body }, options) {
100
+ return this.core.request("migrations_create", { path: { collection_id: collection }, query: { dry_run }, body }, options);
101
+ }
102
102
  list(collection, params = {}, options) {
103
103
  return this.core.paginate("migrations_list", { path: { collection_id: collection }, query: params }, options);
104
104
  }
package/dist/types.d.ts CHANGED
@@ -88,8 +88,6 @@ export interface DraftGetParams {
88
88
  expand?: string[];
89
89
  }
90
90
  export interface DraftListParams extends ListParams {
91
- /** One record's draft, or several records' (up to 100). */
92
- record_id?: string | string[];
93
91
  sort?: "updated_at" | "-updated_at";
94
92
  }
95
93
  export interface DraftScheduleParams {
@@ -155,9 +153,9 @@ export interface DeletedListParams extends ListParams {
155
153
  }
156
154
  export interface AssetListParams extends DeletedListParams {
157
155
  /**
158
- * Only assets of these MIME types or `type/*` wildcards, e.g.
159
- * `["image/*", "application/pdf"]`, such as an asset field's
160
- * `accepted_types`.
156
+ * Only assets of a MIME type or `type/*` wildcard (`"image/*"`), or of any
157
+ * of several: `["image/*", "application/pdf"]`, such as an asset
158
+ * field's `accepted_types`.
161
159
  */
162
160
  content_type?: string | string[];
163
161
  }
@@ -165,7 +163,8 @@ export interface SchemaParams {
165
163
  /** A past schema version; the current one otherwise. */
166
164
  version?: number;
167
165
  }
168
- export type FieldMigrateParams = G.FieldMigrationRequest;
166
+ /** `field_id`, one of the collection's fields, and the parts of its definition to change. */
167
+ export type MigrationCreateParams = G.FieldMigrationRequest;
169
168
  export interface FieldReorderParams {
170
169
  /** Every active field of the collection, once each, in the new order. */
171
170
  field_ids: string[];
@@ -188,7 +187,8 @@ export interface AuditEventFilter {
188
187
  }
189
188
  export interface AuditEventListParams extends ListParams {
190
189
  filter?: AuditEventFilter;
191
- sort?: "id" | "-id";
190
+ /** Newest first by default (`-created_at`). */
191
+ sort?: "created_at" | "-created_at";
192
192
  }
193
193
  /** The metadata of a search page: also an estimate of the total hits. */
194
194
  export type SearchMeta = G.SearchResults["meta"];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.4.0";
1
+ export declare const VERSION = "0.5.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.4.0";
1
+ export const VERSION = "0.5.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nohead/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Official TypeScript SDK for the Nohead API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://nohead.io",