@nohead/sdk 0.4.0 → 0.6.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.
@@ -574,11 +574,15 @@ export type Collection = {
574
574
  */
575
575
  purge_after: NullableTimestamp;
576
576
  /**
577
- * Whether API keys can search the collection (`GET /v1/collections/{collection_id}/search`).
578
- * Every collection is indexed; members can search it in the web app either way.
577
+ * Whether the project's search tokens (made in the web app) find
578
+ * its published records, from a browser or a backend. Off by
579
+ * default: every field of those records becomes readable by anyone
580
+ * with a token, so turn it on only for collections whose published
581
+ * records are public. A change reaches search tokens within
582
+ * seconds.
579
583
  *
580
584
  */
581
- search_enabled: boolean;
585
+ public_search: boolean;
582
586
  /**
583
587
  * Active fields in position order.
584
588
  */
@@ -587,17 +591,17 @@ export type Collection = {
587
591
  updated_at: Timestamp;
588
592
  };
589
593
  export type CollectionCreate = {
590
- search_enabled?: boolean;
591
594
  name: string;
592
595
  slug: string;
593
596
  description?: string | null;
597
+ public_search?: boolean;
594
598
  fields?: Array<FieldCreate>;
595
599
  };
596
600
  export type CollectionUpdate = {
597
- search_enabled?: boolean;
598
601
  name?: string;
599
602
  slug?: string;
600
603
  description?: string | null;
604
+ public_search?: boolean;
601
605
  };
602
606
  export type CollectionList = {
603
607
  data: Array<Collection>;
@@ -612,7 +616,10 @@ export type SchemaDefinition = {
612
616
  slug: string;
613
617
  description: string | null;
614
618
  deleted_at: NullableTimestamp;
615
- search_enabled?: boolean;
619
+ /**
620
+ * Absent from schemas before the setting existed (off).
621
+ */
622
+ public_search?: boolean;
616
623
  fields: Array<{
617
624
  id: string;
618
625
  name: string;
@@ -683,9 +690,13 @@ export type FieldDefinition = {
683
690
  required: boolean;
684
691
  };
685
692
  /**
686
- * The parts of the definition to change; omitted parts stay as they are.
693
+ * The field, and the parts of its definition to change; omitted parts stay as they are.
687
694
  */
688
695
  export type FieldMigrationRequest = {
696
+ /**
697
+ * One of the collection's fields (`422` otherwise).
698
+ */
699
+ field_id: string;
689
700
  type?: FieldType;
690
701
  /**
691
702
  * The complete new configuration. When the type changes and this is omitted, only `description`, `searchable`, `filterable` and `sortable` carry over.
@@ -870,9 +881,9 @@ export type TimeFilter = {
870
881
  lt?: string;
871
882
  };
872
883
  /**
873
- * The client a change came through; `scheduler` for scheduled changes. `import` and `migration` are not sent yet.
884
+ * The client a change came through; `scheduler` for scheduled changes.
874
885
  */
875
- export type Via = 'ui' | 'api' | 'cli' | 'sdk' | 'import' | 'migration' | 'system' | 'scheduler';
886
+ export type Via = 'ui' | 'api' | 'cli' | 'sdk' | 'mcp' | 'system' | 'scheduler';
876
887
  /**
877
888
  * Changes to a record's content that wait until they are merged into
878
889
  * it, now or at `schedule.merge_at`. Content only: whether the record
@@ -1018,6 +1029,16 @@ export type Record = {
1018
1029
  export type RecordWrite = {
1019
1030
  data: RecordData;
1020
1031
  };
1032
+ export type RecordCreate = {
1033
+ data: RecordData;
1034
+ /**
1035
+ * The key of a `unique` field (a slug, or a field with `unique` on)
1036
+ * whose value `data` includes: update the record that has it, or
1037
+ * create one.
1038
+ *
1039
+ */
1040
+ upsert_on?: string;
1041
+ };
1021
1042
  export type RecordList = {
1022
1043
  data: Array<Record>;
1023
1044
  meta: ListMeta;
@@ -1136,9 +1157,11 @@ export type SearchIndex = {
1136
1157
  object: 'search_index';
1137
1158
  collection_id: string;
1138
1159
  /**
1139
- * The collection's `search_enabled`; the index is kept up to date either way.
1160
+ * The index's name in the search engine, which search tokens search
1161
+ * (`indexUid` in Meilisearch's search API). Opaque; it never changes.
1162
+ *
1140
1163
  */
1141
- enabled: boolean;
1164
+ index: string;
1142
1165
  /**
1143
1166
  * `building` until first built; `stale` from the change that queues a rebuild until it has run; `failed` if the last rebuild failed (it is retried).
1144
1167
  */
@@ -1153,7 +1176,7 @@ export type SearchIndex = {
1153
1176
  * (`record.*`, `draft.*`, `collection.*`, `field.*`, `asset.*`) or `*` for all.
1154
1177
  *
1155
1178
  */
1156
- export type WebhookEventType = 'record.created' | 'record.updated' | 'record.published' | 'record.unpublished' | 'record.deleted' | 'record.restored' | 'record.reverted' | 'record.redacted' | 'record.scheduled' | 'record.unscheduled' | 'record.schedule_failed' | 'draft.created' | 'draft.updated' | 'draft.discarded' | 'draft.scheduled' | 'draft.unscheduled' | 'draft.schedule_failed' | 'collection.created' | 'collection.updated' | 'collection.deleted' | 'collection.restored' | 'collection.fields_reordered' | 'field.created' | 'field.updated' | 'field.deleted' | 'field.restored' | 'field.migrated' | 'field.alias_removed' | 'asset.created' | 'asset.deleted' | 'asset.restored' | 'asset.purged';
1179
+ export type WebhookEventType = 'record.created' | 'record.updated' | 'record.published' | 'record.unpublished' | 'record.deleted' | 'record.restored' | 'record.reverted' | 'record.redacted' | 'record.scheduled' | 'record.unscheduled' | 'record.schedule_failed' | 'draft.created' | 'draft.updated' | 'draft.discarded' | 'draft.scheduled' | 'draft.unscheduled' | 'draft.schedule_failed' | 'collection.created' | 'collection.updated' | 'collection.deleted' | 'collection.restored' | 'collection.fields_reordered' | 'field.created' | 'field.updated' | 'field.deleted' | 'field.restored' | 'field.migrated' | 'field.alias_removed' | 'asset.created' | 'asset.updated' | 'asset.deleted' | 'asset.restored' | 'asset.purged';
1157
1180
  export type WebhookSubscription = WebhookEventType | 'record.*' | 'draft.*' | 'collection.*' | 'field.*' | 'asset.*' | '*';
1158
1181
  export type Webhook = WebhookProperties;
1159
1182
  export type WebhookProperties = {
@@ -1365,16 +1388,16 @@ export type WebhookEventPayload = {
1365
1388
  created_at: Timestamp;
1366
1389
  project_id: string;
1367
1390
  /**
1368
- * Who made the change. Always sent.
1391
+ * Who made the change.
1369
1392
  */
1370
- actor?: Actor;
1393
+ actor: Actor;
1371
1394
  /**
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`).
1395
+ * The client the change came through (null when not known). An
1396
+ * integration that writes back can skip changes made with its own API
1397
+ * key (`actor`).
1375
1398
  *
1376
1399
  */
1377
- via?: null | Via;
1400
+ via: null | Via;
1378
1401
  data: RecordEventData | DraftEventData | AssetEventData | SchemaEventData | FieldAliasEventData | WebhookTestEventData;
1379
1402
  };
1380
1403
  /**
@@ -1457,14 +1480,28 @@ export type WebhookTestEventData = {
1457
1480
  webhook: null | Webhook;
1458
1481
  };
1459
1482
  export type Asset = AssetProperties;
1483
+ export type AssetUpdate = {
1484
+ /**
1485
+ * Control characters are removed and path separators become `_`, as on upload.
1486
+ */
1487
+ filename?: string;
1488
+ /**
1489
+ * Surrounding whitespace is removed; empty or null clears it.
1490
+ */
1491
+ alt?: string | null;
1492
+ };
1460
1493
  export type AssetProperties = {
1461
1494
  id: string;
1462
1495
  object: 'asset';
1463
1496
  project_id: string;
1464
1497
  /**
1465
- * The original filename, any Unicode.
1498
+ * The filename, any Unicode, as uploaded unless renamed since. Downloads use it.
1466
1499
  */
1467
1500
  filename: string;
1501
+ /**
1502
+ * Alternative text, saying what an image shows; null until set. The default wherever the asset is used.
1503
+ */
1504
+ alt: string | null;
1468
1505
  content_type: string;
1469
1506
  byte_size: number;
1470
1507
  /**
@@ -1485,7 +1522,20 @@ export type AssetProperties = {
1485
1522
  */
1486
1523
  purge_after: NullableTimestamp;
1487
1524
  /**
1488
- * A signed URL of a small rendition (fits in 640×640, WebP), for ready images, deleted ones included until they are purged; null otherwise.
1525
+ * The URL of the whole image, for ready images (JPEG, PNG, GIF, WebP
1526
+ * or AVIF), deleted ones included until they are purged; null
1527
+ * otherwise. Image URLs are open and never expire. For a rendition,
1528
+ * write [imgproxy processing options](https://docs.imgproxy.net/usage/processing)
1529
+ * before `/plain/`, and a format after `@`: for example
1530
+ * `https://images.nohead.io/rs:fill:800:600/g:sm/plain/…@webp`. Renditions
1531
+ * are at most 4096 pixels a side, from originals of at most 50
1532
+ * megapixels. Options that would return the file as stored (`raw`,
1533
+ * `skip_processing`, `strip_metadata`) are refused.
1534
+ *
1535
+ */
1536
+ image_url: string | null;
1537
+ /**
1538
+ * The URL of a small rendition (fits in 640×640, WebP), for ready images, deleted ones included until they are purged; null otherwise.
1489
1539
  */
1490
1540
  preview_url: string | null;
1491
1541
  uploaded_at: NullableTimestamp;
@@ -1496,16 +1546,6 @@ export type AssetList = {
1496
1546
  data: Array<Asset>;
1497
1547
  meta: ListMeta;
1498
1548
  };
1499
- export type ImageUrl = {
1500
- object: 'image_url';
1501
- asset_id: string;
1502
- url: string;
1503
- width: number | null;
1504
- height: number | null;
1505
- fit: 'contain' | 'cover' | 'fill';
1506
- format: 'original' | 'webp' | 'avif' | 'jpeg' | 'png';
1507
- quality: number | null;
1508
- };
1509
1549
  export type AssetUsage = {
1510
1550
  object: 'asset_usage';
1511
1551
  asset_id: string;
@@ -1628,6 +1668,7 @@ export type WebhookId = string;
1628
1668
  export type DeliveryId = string;
1629
1669
  export type RecordId = string;
1630
1670
  export type DraftId = string;
1671
+ export type RevisionId = string;
1631
1672
  /**
1632
1673
  * Per-record revision number.
1633
1674
  */
@@ -1700,7 +1741,7 @@ export type RecordRevisionFilter = {
1700
1741
  actor_id?: string;
1701
1742
  created_at?: TimeFilter;
1702
1743
  };
1703
- export type AuditEventSort = 'id' | '-id';
1744
+ export type AuditEventSort = 'created_at' | '-created_at';
1704
1745
  /**
1705
1746
  * Page size.
1706
1747
  */
@@ -1717,14 +1758,20 @@ export type DeletedFilter = {
1717
1758
  };
1718
1759
  /**
1719
1760
  * `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`).
1761
+ * `filter[content_type]` lists only assets of a type: a MIME type or a
1762
+ * `type*` wildcard, or several with
1763
+ * `filter[content_type][in]=image*,application/pdf`, for example the
1764
+ * ones an asset field accepts (its `accepted_types`).
1723
1765
  *
1724
1766
  */
1725
1767
  export type AssetFilter = {
1726
1768
  deleted?: 'true' | 'false';
1727
- content_type?: string;
1769
+ content_type?: string | {
1770
+ /**
1771
+ * Up to 50 comma-separated MIME types or `type*` wildcards.
1772
+ */
1773
+ in: string;
1774
+ };
1728
1775
  };
1729
1776
  /**
1730
1777
  * 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 +1841,8 @@ export type RecordsListData = {
1794
1841
  [key: string]: RecordFilterValue;
1795
1842
  };
1796
1843
  /**
1797
- * `id`, `created_at`, `updated_at`, `published_at` (unpublished
1798
- * records first), or the key of a text, number, boolean, date or
1844
+ * `created_at`, `updated_at`, `published_at` (unpublished records
1845
+ * first), or the key of a text, number, boolean, date or
1799
1846
  * enum field with one value (records without a value last, in both
1800
1847
  * directions; text by code point). `-` for descending.
1801
1848
  *
@@ -1851,7 +1898,7 @@ export type RecordsListResponses = {
1851
1898
  };
1852
1899
  export type RecordsListResponse = RecordsListResponses[keyof RecordsListResponses];
1853
1900
  export type RecordsCreateData = {
1854
- body: RecordWrite;
1901
+ body: RecordCreate;
1855
1902
  headers?: {
1856
1903
  /**
1857
1904
  * A unique value (1-255 printable ASCII characters) that makes retrying
@@ -1863,6 +1910,10 @@ export type RecordsCreateData = {
1863
1910
  *
1864
1911
  */
1865
1912
  'Idempotency-Key'?: string;
1913
+ /**
1914
+ * The revision you last read (the record's, or the draft's for a draft), e.g. `"7"`. Stale writes fail with 412.
1915
+ */
1916
+ 'If-Match'?: string;
1866
1917
  /**
1867
1918
  * First-party client identifier recorded in history (e.g. `cli/0.3.1`). Informational only.
1868
1919
  */
@@ -1914,6 +1965,12 @@ export type RecordsCreateErrors = {
1914
1965
  * The request conflicts with current state.
1915
1966
  */
1916
1967
  409: Error;
1968
+ /**
1969
+ * The resource changed since the revision given in `If-Match`. Nothing was
1970
+ * written; `details` includes the current revision.
1971
+ *
1972
+ */
1973
+ 412: Error;
1917
1974
  /**
1918
1975
  * The request failed validation.
1919
1976
  */
@@ -1929,6 +1986,10 @@ export type RecordsCreateErrors = {
1929
1986
  };
1930
1987
  export type RecordsCreateError = RecordsCreateErrors[keyof RecordsCreateErrors];
1931
1988
  export type RecordsCreateResponses = {
1989
+ /**
1990
+ * The record.
1991
+ */
1992
+ 200: Record;
1932
1993
  /**
1933
1994
  * The created record.
1934
1995
  */
@@ -2932,6 +2993,48 @@ export type RecordRevisionsGetResponses = {
2932
2993
  200: RecordRevisionDetail;
2933
2994
  };
2934
2995
  export type RecordRevisionsGetResponse = RecordRevisionsGetResponses[keyof RecordRevisionsGetResponses];
2996
+ export type RevisionsGetData = {
2997
+ body?: never;
2998
+ path: {
2999
+ revision_id: string;
3000
+ };
3001
+ query?: never;
3002
+ url: '/v1/revisions/{revision_id}';
3003
+ };
3004
+ export type RevisionsGetErrors = {
3005
+ /**
3006
+ * 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).
3007
+ */
3008
+ 400: Error;
3009
+ /**
3010
+ * Authentication is missing or invalid.
3011
+ */
3012
+ 401: Error;
3013
+ /**
3014
+ * The caller is not allowed to perform this action.
3015
+ */
3016
+ 403: Error;
3017
+ /**
3018
+ * The resource does not exist or is not visible to the caller.
3019
+ */
3020
+ 404: Error;
3021
+ /**
3022
+ * Too many requests for this API key or user (or, with failing
3023
+ * credentials, this IP address). A published-only key is counted per
3024
+ * client IP. Wait `Retry-After` seconds; retries with the same `Idempotency-Key`
3025
+ * are safe.
3026
+ *
3027
+ */
3028
+ 429: Error;
3029
+ };
3030
+ export type RevisionsGetError = RevisionsGetErrors[keyof RevisionsGetErrors];
3031
+ export type RevisionsGetResponses = {
3032
+ /**
3033
+ * The revision with its snapshot and changes.
3034
+ */
3035
+ 200: RecordRevisionDetail;
3036
+ };
3037
+ export type RevisionsGetResponse = RevisionsGetResponses[keyof RevisionsGetResponses];
2935
3038
  export type RecordRevisionsRevertData = {
2936
3039
  body?: never;
2937
3040
  headers?: {
@@ -3195,14 +3298,6 @@ export type DraftsListData = {
3195
3298
  collection_id: string;
3196
3299
  };
3197
3300
  query?: {
3198
- filter?: {
3199
- record_id?: string | {
3200
- /**
3201
- * Up to 100 comma-separated record IDs.
3202
- */
3203
- in: string;
3204
- };
3205
- };
3206
3301
  sort?: 'updated_at' | '-updated_at';
3207
3302
  /**
3208
3303
  * Page size.
@@ -4878,7 +4973,7 @@ export type MigrationsListResponses = {
4878
4973
  200: FieldMigrationList;
4879
4974
  };
4880
4975
  export type MigrationsListResponse = MigrationsListResponses[keyof MigrationsListResponses];
4881
- export type FieldsMigrateData = {
4976
+ export type MigrationsCreateData = {
4882
4977
  body: FieldMigrationRequest;
4883
4978
  headers?: {
4884
4979
  /**
@@ -4907,14 +5002,17 @@ export type FieldsMigrateData = {
4907
5002
  'Nohead-Change-Note'?: string;
4908
5003
  };
4909
5004
  path: {
4910
- field_id: string;
5005
+ /**
5006
+ * Collection ID, or the collection slug when authenticating with an API key.
5007
+ */
5008
+ collection_id: string;
4911
5009
  };
4912
5010
  query?: {
4913
5011
  dry_run?: boolean;
4914
5012
  };
4915
- url: '/v1/fields/{field_id}/migrations';
5013
+ url: '/v1/collections/{collection_id}/migrations';
4916
5014
  };
4917
- export type FieldsMigrateErrors = {
5015
+ export type MigrationsCreateErrors = {
4918
5016
  /**
4919
5017
  * 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
5018
  */
@@ -4948,8 +5046,8 @@ export type FieldsMigrateErrors = {
4948
5046
  */
4949
5047
  429: Error;
4950
5048
  };
4951
- export type FieldsMigrateError = FieldsMigrateErrors[keyof FieldsMigrateErrors];
4952
- export type FieldsMigrateResponses = {
5049
+ export type MigrationsCreateError = MigrationsCreateErrors[keyof MigrationsCreateErrors];
5050
+ export type MigrationsCreateResponses = {
4953
5051
  /**
4954
5052
  * A preview (dry runs only).
4955
5053
  */
@@ -4959,7 +5057,7 @@ export type FieldsMigrateResponses = {
4959
5057
  */
4960
5058
  202: FieldMigration;
4961
5059
  };
4962
- export type FieldsMigrateResponse = FieldsMigrateResponses[keyof FieldsMigrateResponses];
5060
+ export type MigrationsCreateResponse = MigrationsCreateResponses[keyof MigrationsCreateResponses];
4963
5061
  export type MigrationsGetData = {
4964
5062
  body?: never;
4965
5063
  path: {
@@ -5080,14 +5178,20 @@ export type AssetsListData = {
5080
5178
  cursor?: string;
5081
5179
  /**
5082
5180
  * `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`).
5181
+ * `filter[content_type]` lists only assets of a type: a MIME type or a
5182
+ * `type*` wildcard, or several with
5183
+ * `filter[content_type][in]=image*,application/pdf`, for example the
5184
+ * ones an asset field accepts (its `accepted_types`).
5086
5185
  *
5087
5186
  */
5088
5187
  filter?: {
5089
5188
  deleted?: 'true' | 'false';
5090
- content_type?: string;
5189
+ content_type?: string | {
5190
+ /**
5191
+ * Up to 50 comma-separated MIME types or `type*` wildcards.
5192
+ */
5193
+ in: string;
5194
+ };
5091
5195
  };
5092
5196
  };
5093
5197
  url: '/v1/projects/{project_id}/assets';
@@ -5368,24 +5472,31 @@ export type AssetsGetResponses = {
5368
5472
  200: Asset;
5369
5473
  };
5370
5474
  export type AssetsGetResponse = AssetsGetResponses[keyof AssetsGetResponses];
5371
- export type AssetsImageUrlData = {
5372
- body?: never;
5373
- path: {
5374
- asset_id: string;
5375
- };
5376
- query?: {
5377
- width?: number;
5378
- height?: number;
5475
+ export type AssetsUpdateData = {
5476
+ body: AssetUpdate;
5477
+ headers?: {
5478
+ /**
5479
+ * A unique value (1-255 printable ASCII characters) that makes retrying
5480
+ * this request safe. The first response (below 500) is stored for 24
5481
+ * hours per user or API key; retries with the same key and the same
5482
+ * request get it again with an `Idempotent-Replayed: true` header. The
5483
+ * same key with a different request is refused with `400`; a retry while
5484
+ * the first request is still running gets `409`.
5485
+ *
5486
+ */
5487
+ 'Idempotency-Key'?: string;
5379
5488
  /**
5380
- * `contain` fits inside width × height; `cover` fills it, cropping; `fill` stretches to it.
5489
+ * First-party client identifier recorded in history (e.g. `cli/0.3.1`). Informational only.
5381
5490
  */
5382
- fit?: 'contain' | 'cover' | 'fill';
5383
- format?: 'original' | 'webp' | 'avif' | 'jpeg' | 'png';
5384
- quality?: number;
5491
+ 'Nohead-Client'?: string;
5492
+ };
5493
+ path: {
5494
+ asset_id: string;
5385
5495
  };
5386
- url: '/v1/assets/{asset_id}/image-url';
5496
+ query?: never;
5497
+ url: '/v1/assets/{asset_id}';
5387
5498
  };
5388
- export type AssetsImageUrlErrors = {
5499
+ export type AssetsUpdateErrors = {
5389
5500
  /**
5390
5501
  * 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).
5391
5502
  */
@@ -5418,19 +5529,15 @@ export type AssetsImageUrlErrors = {
5418
5529
  *
5419
5530
  */
5420
5531
  429: Error;
5421
- /**
5422
- * The service is temporarily unavailable.
5423
- */
5424
- 503: Error;
5425
5532
  };
5426
- export type AssetsImageUrlError = AssetsImageUrlErrors[keyof AssetsImageUrlErrors];
5427
- export type AssetsImageUrlResponses = {
5533
+ export type AssetsUpdateError = AssetsUpdateErrors[keyof AssetsUpdateErrors];
5534
+ export type AssetsUpdateResponses = {
5428
5535
  /**
5429
- * The image URL.
5536
+ * The asset.
5430
5537
  */
5431
- 200: ImageUrl;
5538
+ 200: Asset;
5432
5539
  };
5433
- export type AssetsImageUrlResponse = AssetsImageUrlResponses[keyof AssetsImageUrlResponses];
5540
+ export type AssetsUpdateResponse = AssetsUpdateResponses[keyof AssetsUpdateResponses];
5434
5541
  export type AssetsDownloadUrlData = {
5435
5542
  body?: never;
5436
5543
  path: {
@@ -6725,7 +6832,7 @@ export type AuditEventsListData = {
6725
6832
  actor_id?: string;
6726
6833
  created_at?: TimeFilter;
6727
6834
  };
6728
- sort?: 'id' | '-id';
6835
+ sort?: 'created_at' | '-created_at';
6729
6836
  };
6730
6837
  url: '/v1/projects/{project_id}/audit-events';
6731
6838
  };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Image renditions without a request (`@nohead/sdk/images`). Image URLs are
3
+ * open: an image asset's `image_url` serves the whole image, and any of
4
+ * imgproxy's processing options written into it transform it
5
+ * (https://docs.imgproxy.net/usage/processing). No dependencies, so it suits
6
+ * browser bundles and frameworks' image components.
7
+ *
8
+ * imageUrl(asset, { width: 800, height: 600, fit: "cover", format: "webp" })
9
+ */
10
+ export interface ImageOptions {
11
+ width?: number;
12
+ height?: number;
13
+ /** `contain` fits inside the box (the default), `cover` fills it, cropping, `fill` stretches to it. */
14
+ fit?: "contain" | "cover" | "fill";
15
+ format?: "webp" | "avif" | "jpeg" | "png";
16
+ /** 1 to 100. */
17
+ quality?: number;
18
+ /** Pixel density: 2 for a 2x screen. */
19
+ dpr?: number;
20
+ /** What a crop keeps, as imgproxy's gravity: `sm` (smart), `ce`, `no`, or `fp:0.5:0.3` (a focal point). */
21
+ gravity?: string;
22
+ /** Any other processing options, as written in a URL: `["bl:2", "sh:0.5"]`. */
23
+ options?: string[];
24
+ }
25
+ /** An image asset, or its `image_url`. */
26
+ export type ImageSource = string | {
27
+ image_url: string | null;
28
+ };
29
+ /** A rendition of an image: its `image_url` with these options. */
30
+ export declare function imageUrl(image: ImageSource, options?: ImageOptions): string;
31
+ /** Whether a URL is a Nohead image's: the loaders leave any other alone. */
32
+ export declare function isImageUrl(src: unknown): src is string;
33
+ /**
34
+ * A Next.js image loader. In a file named by `images.loaderFile` in
35
+ * next.config: `export { nextImageLoader as default } from "@nohead/sdk/images"`,
36
+ * then `<Image src={asset.image_url} width={…} height={…} alt={asset.alt} />`.
37
+ * Other images (the site's own) are left as they are.
38
+ */
39
+ export declare function nextImageLoader({ src, width, quality, }: {
40
+ src: string;
41
+ width: number;
42
+ quality?: number;
43
+ }): string;
44
+ /**
45
+ * An Astro image service (an external one: Astro never fetches the image).
46
+ * In a module named by `image.service.entrypoint` in astro.config:
47
+ * `export { astroImageService as default } from "@nohead/sdk/images"`.
48
+ * Other images (the site's own, imported or remote) are served as they are.
49
+ */
50
+ export declare const astroImageService: {
51
+ getURL(options: {
52
+ src: unknown;
53
+ width?: number;
54
+ height?: number;
55
+ format?: string;
56
+ quality?: number | string;
57
+ fit?: string;
58
+ }): string;
59
+ };
60
+ /**
61
+ * Nuxt Image's custom provider (`getImage`). In a file named as a provider
62
+ * in nuxt.config's `image.providers`: on Nuxt Image 2,
63
+ * `export { nuxtImageProvider as default } from "@nohead/sdk/images"`; on
64
+ * Nuxt Image 1, `export { getImage } from "@nohead/sdk/images"`. Other
65
+ * images are left as they are.
66
+ */
67
+ export declare function getImage(src: string, { modifiers }?: {
68
+ modifiers?: Record<string, unknown>;
69
+ }): {
70
+ url: string;
71
+ };
72
+ /** Nuxt Image 2's provider: what its `defineProvider({ getImage })` returns. */
73
+ export declare const nuxtImageProvider: () => {
74
+ getImage: typeof getImage;
75
+ };