@nohead/sdk 0.3.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 +36 -0
- package/README.md +11 -7
- package/dist/core.js +5 -0
- package/dist/generated/operations.gen.d.ts +9 -9
- package/dist/generated/operations.gen.js +2 -2
- package/dist/generated/schemas.gen.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +585 -208
- package/dist/resources/assets.d.ts +1 -1
- package/dist/resources/assets.js +9 -2
- package/dist/resources/drafts.d.ts +3 -4
- package/dist/resources/drafts.js +4 -15
- package/dist/resources/schema.d.ts +11 -10
- package/dist/resources/schema.js +6 -8
- package/dist/types.d.ts +7 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
package/dist/resources/assets.js
CHANGED
|
@@ -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", {
|
|
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.
|
|
23
|
-
*
|
|
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,
|
|
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. */
|
package/dist/resources/drafts.js
CHANGED
|
@@ -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.
|
|
21
|
-
*
|
|
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,
|
|
25
|
-
|
|
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,
|
|
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 {
|
|
@@ -24,7 +24,7 @@ export declare class Collections extends Resource {
|
|
|
24
24
|
/** A collection's schema history, newest first. */
|
|
25
25
|
export declare class SchemaChanges extends Resource {
|
|
26
26
|
list(collection: string, params?: ListParams, options?: RequestOptions): PagePromise<SchemaChange>;
|
|
27
|
-
get(
|
|
27
|
+
get(schemaChange: string, options?: RequestOptions): APIPromise<SchemaChangeDetail>;
|
|
28
28
|
}
|
|
29
29
|
/** A collection's search index. */
|
|
30
30
|
export declare class SearchIndexes 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 `
|
|
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
|
|
59
|
-
*
|
|
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
|
-
|
|
65
|
+
create(collection: string, params: MigrationCreateParams & {
|
|
62
66
|
dry_run: true;
|
|
63
67
|
}, options?: WriteOptions): APIPromise<FieldMigrationPreview>;
|
|
64
|
-
|
|
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>;
|
package/dist/resources/schema.js
CHANGED
|
@@ -36,10 +36,8 @@ export class SchemaChanges extends Resource {
|
|
|
36
36
|
list(collection, params = {}, options) {
|
|
37
37
|
return this.core.paginate("schema_changes_list", { path: { collection_id: collection }, query: params }, options);
|
|
38
38
|
}
|
|
39
|
-
get(
|
|
40
|
-
return this.core.request("schema_changes_get", {
|
|
41
|
-
path: { collection_id: collection, schema_change_id: schemaChange },
|
|
42
|
-
}, options);
|
|
39
|
+
get(schemaChange, options) {
|
|
40
|
+
return this.core.request("schema_changes_get", { path: { schema_change_id: schemaChange } }, options);
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
/** A collection's search index. */
|
|
@@ -68,7 +66,7 @@ export class Fields extends Resource {
|
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Renames, describes or loosens a field. Changes that rewrite record
|
|
71
|
-
* values (type, `multiple`, tighter rules) are `
|
|
69
|
+
* values (type, `multiple`, tighter rules) are `migrations.create`.
|
|
72
70
|
*/
|
|
73
71
|
update(field, params, options) {
|
|
74
72
|
return this.core.request("fields_update", { path: { field_id: field }, body: params }, options);
|
|
@@ -95,12 +93,12 @@ export class Fields extends Resource {
|
|
|
95
93
|
removeAlias(field, alias, options) {
|
|
96
94
|
return this.core.request("fields_remove_alias", { path: { field_id: field, alias } }, options);
|
|
97
95
|
}
|
|
98
|
-
migrate(field, { dry_run, ...body }, options) {
|
|
99
|
-
return this.core.request("fields_migrate", { path: { field_id: field }, query: { dry_run }, body }, options);
|
|
100
|
-
}
|
|
101
96
|
}
|
|
102
97
|
/** Field migrations. While one runs, its collection is read-only. */
|
|
103
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
|
+
}
|
|
104
102
|
list(collection, params = {}, options) {
|
|
105
103
|
return this.core.paginate("migrations_list", { path: { collection_id: collection }, query: params }, options);
|
|
106
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
|
|
159
|
-
* `["image/*", "application/pdf"]`, such as an asset
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
1
|
+
export declare const VERSION = "0.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.5.0";
|