@nohead/sdk 0.3.0 → 0.4.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.4.0
9
+
10
+ - **Breaking:** a field's `api_key` is its `key` (in fields, their aliases,
11
+ `fields.create` and `fields.update`), as the editor's "Field key" says.
12
+ API keys keep their name.
13
+ - **Breaking:** `collections.schemaChanges.get(schemaChange)` takes the
14
+ schema change's ID alone (`GET /v1/schema-changes/{id}`).
15
+ - **Breaking:** `fields.update` no longer takes `type` or `multiple`; they
16
+ rewrite record values, so they are `fields.migrate`. The API refuses a
17
+ body key an operation doesn't take with `400` (`unknown_parameter`, naming
18
+ it), so a misspelt key no longer passes unnoticed.
19
+ - `Field` and `FieldCreate` are typed per field type: narrowing on
20
+ `field.type` types its `configuration` (`if (field.type === "enum")
21
+ field.configuration.options`), and `EnumFieldConfiguration`,
22
+ `RelationFieldConfiguration`... are exported.
23
+
8
24
  ## 0.3.0
9
25
 
10
26
  - **Breaking:** 0.1.0 and 0.2.0 no longer work with the API: its paths and
package/README.md CHANGED
@@ -306,11 +306,11 @@ Search needs `search_enabled` collections and the `search:read` scope. It pages
306
306
  const posts = await nohead.collections.create({
307
307
  name: "Posts",
308
308
  slug: "posts",
309
- fields: [{ name: "Title", api_key: "title", type: "text", required: true }],
309
+ fields: [{ name: "Title", key: "title", type: "text", required: true }],
310
310
  })
311
311
  await nohead.fields.create("posts", {
312
312
  name: "Summary",
313
- api_key: "summary",
313
+ key: "summary",
314
314
  type: "long_text",
315
315
  })
316
316
 
package/dist/core.js CHANGED
@@ -178,6 +178,11 @@ export class Core {
178
178
  }
179
179
  async #path(template, values = {}) {
180
180
  let path = template;
181
+ const names = [...template.matchAll(/\{(\w+)\}/g)].map(([, name]) => name);
182
+ // A value the template doesn't take is a method out of step with its operation.
183
+ for (const name of Object.keys(values))
184
+ if (!names.includes(name))
185
+ throw new TypeError(`${name} is not a path parameter of ${template}`);
181
186
  for (const [, name] of template.matchAll(/\{(\w+)\}/g)) {
182
187
  let value = values[name];
183
188
  if (value === undefined && name === "project_id") {
@@ -258,7 +258,7 @@ export declare const OPERATIONS: {
258
258
  };
259
259
  readonly schema_changes_get: {
260
260
  readonly method: "GET";
261
- readonly path: "/v1/collections/{collection_id}/schema-changes/{schema_change_id}";
261
+ readonly path: "/v1/schema-changes/{schema_change_id}";
262
262
  };
263
263
  readonly schema_changes_list: {
264
264
  readonly method: "GET";
@@ -63,7 +63,7 @@ export const OPERATIONS = {
63
63
  records_unschedule: { method: "DELETE", path: "/v1/records/{record_id}/schedule" },
64
64
  records_update: { method: "PATCH", path: "/v1/records/{record_id}" },
65
65
  scheduled_changes_list: { method: "GET", path: "/v1/collections/{collection_id}/scheduled-changes" },
66
- schema_changes_get: { method: "GET", path: "/v1/collections/{collection_id}/schema-changes/{schema_change_id}" },
66
+ schema_changes_get: { method: "GET", path: "/v1/schema-changes/{schema_change_id}" },
67
67
  schema_changes_list: { method: "GET", path: "/v1/collections/{collection_id}/schema-changes" },
68
68
  search_index_get: { method: "GET", path: "/v1/collections/{collection_id}/search-index" },
69
69
  search_index_rebuild: { method: "POST", path: "/v1/collections/{collection_id}/search-index/rebuild" },
@@ -1 +1 @@
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";
1
+ export type { Actor, ApiKeyScope, Asset, AssetEventData, AssetField, AssetFieldConfiguration, AssetFieldCreate, AssetList, AssetProperties, AssetUploadCreate, AssetUploadTarget, AssetUsage, AssetWithUpload, AuditEvent, AuditEventList, BooleanField, BooleanFieldConfiguration, BooleanFieldCreate, Change, Collection, CollectionCreate, CollectionList, CollectionUpdate, DateField, DateFieldConfiguration, DateFieldCreate, DecimalField, DecimalFieldConfiguration, DecimalFieldCreate, DownloadUrl, Draft, DraftCreate, DraftEventData, DraftList, DraftSchedule, DraftScheduleUpdate, EnumField, EnumFieldConfiguration, EnumFieldCreate, Error, ErrorDetail, ErrorType, FeatureFlags, Field, FieldAliasEventData, FieldConfiguration, FieldCreate, FieldCreateProperties, FieldDefinition, FieldList, FieldMigration, FieldMigrationCounts, FieldMigrationList, FieldMigrationPreview, FieldMigrationRequest, FieldOrder, FieldProperties, FieldType, FieldUpdate, Health, ImageUrl, IntegerField, IntegerFieldConfiguration, IntegerFieldCreate, JsonField, JsonFieldConfiguration, JsonFieldCreate, ListMeta, LongTextField, LongTextFieldConfiguration, LongTextFieldCreate, MergedDraft, NullableTimestamp, Principal, PublishedOnly, RecordBatch, RecordBatchRequest, RecordCount, RecordData, RecordDiff, RecordEventData, RecordFilterValue, RecordList, RecordPublication, RecordRevision, RecordRevisionDetail, RecordRevisionList, RecordRevisionOperation, RecordRevisionProperties, RecordSchedule, RecordScheduleUpdate, RecordWrite, RelationField, RelationFieldConfiguration, RelationFieldCreate, RequestId, RevertPreview, RichTextField, RichTextFieldConfiguration, RichTextFieldCreate, ScheduledChange, ScheduledChangeList, Schema, SchemaChange, SchemaChangeDetail, SchemaChangeList, SchemaChangeProperties, SchemaDefinition, SchemaEventData, SearchIndex, SearchResults, TextField, TextFieldConfiguration, TextFieldCreate, 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";