@datocms/cma-client 5.1.5 → 5.1.6

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.
Files changed (49) hide show
  1. package/dist/cjs/fieldTypes/gallery.js +0 -2
  2. package/dist/cjs/fieldTypes/gallery.js.map +1 -1
  3. package/dist/cjs/fieldTypes/links.js +0 -2
  4. package/dist/cjs/fieldTypes/links.js.map +1 -1
  5. package/dist/cjs/fieldTypes/rich_text.js +0 -4
  6. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  7. package/dist/cjs/generated/Client.js +1 -1
  8. package/dist/cjs/generated/resources/Item.js +2 -2
  9. package/dist/cjs/generated/resources/Item.js.map +1 -1
  10. package/dist/cjs/utilities/fieldValue.js +14 -9
  11. package/dist/cjs/utilities/fieldValue.js.map +1 -1
  12. package/dist/cjs/utilities/schemaRepository.js +64 -0
  13. package/dist/cjs/utilities/schemaRepository.js.map +1 -1
  14. package/dist/esm/fieldTypes/gallery.js +0 -2
  15. package/dist/esm/fieldTypes/gallery.js.map +1 -1
  16. package/dist/esm/fieldTypes/links.d.ts +1 -1
  17. package/dist/esm/fieldTypes/links.js +0 -2
  18. package/dist/esm/fieldTypes/links.js.map +1 -1
  19. package/dist/esm/fieldTypes/rich_text.js +0 -4
  20. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  21. package/dist/esm/generated/ApiTypes.d.ts +743 -5
  22. package/dist/esm/generated/Client.js +1 -1
  23. package/dist/esm/generated/RawApiTypes.d.ts +743 -5
  24. package/dist/esm/generated/resources/Item.js +2 -2
  25. package/dist/esm/generated/resources/Item.js.map +1 -1
  26. package/dist/esm/utilities/fieldValue.d.ts +18 -19
  27. package/dist/esm/utilities/fieldValue.js +14 -9
  28. package/dist/esm/utilities/fieldValue.js.map +1 -1
  29. package/dist/esm/utilities/itemDefinition.d.ts +27 -14
  30. package/dist/esm/utilities/schemaRepository.d.ts +64 -0
  31. package/dist/esm/utilities/schemaRepository.js +64 -0
  32. package/dist/esm/utilities/schemaRepository.js.map +1 -1
  33. package/dist/types/fieldTypes/links.d.ts +1 -1
  34. package/dist/types/generated/ApiTypes.d.ts +743 -5
  35. package/dist/types/generated/RawApiTypes.d.ts +743 -5
  36. package/dist/types/utilities/fieldValue.d.ts +18 -19
  37. package/dist/types/utilities/itemDefinition.d.ts +27 -14
  38. package/dist/types/utilities/schemaRepository.d.ts +64 -0
  39. package/package.json +4 -4
  40. package/src/fieldTypes/gallery.ts +0 -1
  41. package/src/fieldTypes/links.ts +1 -2
  42. package/src/fieldTypes/rich_text.ts +0 -4
  43. package/src/generated/ApiTypes.ts +743 -5
  44. package/src/generated/Client.ts +1 -1
  45. package/src/generated/RawApiTypes.ts +743 -5
  46. package/src/generated/resources/Item.ts +2 -2
  47. package/src/utilities/fieldValue.ts +96 -79
  48. package/src/utilities/itemDefinition.ts +99 -72
  49. package/src/utilities/schemaRepository.ts +64 -0
@@ -6750,13 +6750,751 @@ export type BuildEventSelfTargetSchema = {
6750
6750
  data: BuildEvent;
6751
6751
  };
6752
6752
  /**
6753
- * DatoCMS stores the individual pieces of content you create from a model as records, which are much like table rows in a database. For backward-compatibility reasons, the API refers to records as "items".
6753
+ * DatoCMS stores the individual pieces of content you create from a model as records (for backwards compatibility the API calls these `item`). The shape of a record’s attributes depends on the fields defined by that record’s model — see the [Object payload](#object-payload) section for the full object payload documentation.
6754
6754
  *
6755
- * You can learn how the records are structured at the API level, and everything that is necessary to interact with the records through CMA in the following detail sections:
6755
+ * ```json
6756
+ * // A simple record
6757
+ * {
6758
+ * "id": "A4gkL_8pTZmcyJ-IlIEd2w",
6759
+ * "type": "item",
6760
+ * "attributes": {
6761
+ * "title": "My Blog Post",
6762
+ * "publication_date": "2024-01-15"
6763
+ * },
6764
+ * "relationships": {
6765
+ * "item_type": {
6766
+ * "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" }
6767
+ * }
6768
+ * }
6769
+ * }
6770
+ * ```
6771
+ *
6772
+ * > [!PROTIP] 📘 New to content modeling?
6773
+ * > Check out the [Content Modeling Guide](/docs/content-modelling) to understand how to design models, fields, and relationships before diving into API usage.
6774
+ *
6775
+ * ---
6776
+ *
6777
+ * ## Field types overview
6778
+ *
6779
+ * ###### Scalar fields
6780
+ * These store basic data types (ie. strings, numbers, booleans):
6781
+ *
6782
+ * <details>
6783
+ * <summary>Single-line string</summary>
6784
+ *
6785
+ * The field accepts `String` values or `null`.
6786
+ *
6787
+ * </details>
6788
+ *
6789
+ * <details>
6790
+ * <summary>Slug</summary>
6791
+ *
6792
+ * The field accepts `String` values or `null`.
6793
+ * </details>
6794
+ *
6795
+ * <details>
6796
+ * <summary>Multi-line text</summary>
6797
+ *
6798
+ * The field accepts simple `String` values (can include newlines) or `null`
6799
+ * </details>
6800
+ *
6801
+ * <details>
6802
+ * <summary>Boolean</summary>
6803
+ *
6804
+ * The field accepts simple `Boolean` values or `null`.
6805
+ * </details>
6806
+ *
6807
+ * <details>
6808
+ * <summary>Integer</summary>
6809
+ *
6810
+ * The field accepts simple `Integer` values or `null`.
6811
+ * </details>
6812
+ *
6813
+ * <details>
6814
+ * <summary>Float</summary>
6815
+ *
6816
+ * The field accepts simple `Float` values or `null`.
6817
+ *
6818
+ * </details>
6819
+ *
6820
+ * <details>
6821
+ * <summary>Date</summary>
6822
+ *
6823
+ * The field accepts `String` values in ISO 8601 date format (ie. `"2015-12-29"`) or `null`.
6824
+ *
6825
+ * </details>
6826
+ *
6827
+ * <details>
6828
+ * <summary>Date time</summary>
6829
+ *
6830
+ * The field accepts `String` values in ISO 8601 date-time format (ie. `"2020-04-17T16:34:31.981+01:00"`) or `null`.
6831
+ *
6832
+ * If you're on [legacy timezone management](/product-updates/improved-timezone-management), remember that when sending an ISO8601 datetime you should keep in mind that the system will ignore any provided timezone, and will use the project's timezone instead.
6833
+ * </details>
6834
+ *
6835
+ * <details>
6836
+ * <summary>JSON</summary>
6837
+ *
6838
+ * The field accepts `String` values that are valid JSON or `null`.
6839
+ *
6840
+ * **Note**: Must be a JSON-serialized string, not a JavaScript object!
6841
+ *
6842
+ * </details>
6843
+ *
6844
+ * ###### Object Fields
6845
+ * These require structured objects:
6846
+ *
6847
+ * <details>
6848
+ * <summary>Color</summary>
6849
+ *
6850
+ * The field accepts an object with the following properties, or `null`:
6851
+ *
6852
+ * | Property | Required | Type |
6853
+ * | -------- | -------- | --------------------------- |
6854
+ * | `red` | ✅ | `Integer` between 0 and 255 |
6855
+ * | `green` | ✅ | `Integer` between 0 and 255 |
6856
+ * | `blue` | ✅ | `Integer` between 0 and 255 |
6857
+ * | `alpha` | ✅ | `Integer` between 0 and 255 |
6858
+ *
6859
+ * </details>
6860
+ *
6861
+ *
6862
+ * <details>
6863
+ * <summary>Location</summary>
6864
+ *
6865
+ * The field accepts an object with the following properties, or `null`:
6866
+ *
6867
+ * | Property | Required | Type |
6868
+ * | ----------- | -------- | ----------------------------- |
6869
+ * | `latitude` | ✅ | `Float` between -90.0 to 90 |
6870
+ * | `longitude` | ✅ | `Float` between -180.0 to 180 |
6871
+ *
6872
+ * </details>
6873
+ *
6874
+ * <details>
6875
+ * <summary>SEO</summary>
6876
+ *
6877
+ * The field accepts an object with the following properties, or `null`:
6878
+ *
6879
+ * | Property | Required | Type | Description |
6880
+ * | -------------- | -------- | ------------------------------------ | ----------------------------------------------- |
6881
+ * | `title` | | `String` | Title meta tag (max. 320 characters) |
6882
+ * | `description` | | `String` | Description meta tag (max. 320 characters) |
6883
+ * | `image` | | `Upload ID` | Asset to be used for social shares |
6884
+ * | `twitter_card` | | `"summary"`, `"summary_large_image"` | Type of Twitter card to use |
6885
+ * | `no_index` | | `Boolean` | Whether the noindex meta tag should be returned |
6886
+ *
6887
+ * </details>
6888
+ *
6889
+ * <details>
6890
+ * <summary>External video</summary>
6891
+ *
6892
+ * The field accepts an object with the following properties, or `null`:
6893
+ *
6894
+ * | Property | Required | Type | Description | Example |
6895
+ * | --------------- | -------- | ------------------------------------ | -------------------------------------------------- | ---------------------------------------------------- |
6896
+ * | `provider` | ✅ | `"youtube"`, `"vimeo"`, `"facebook"` | External video provider | `"youtube"` |
6897
+ * | `provider_uid` | ✅ | `String` | Unique identifier of the video within the provider | `"vUdGBEb1i9g"` |
6898
+ * | `url` | ✅ | `URL` | URL of the video | `"https://www.youtube.com/watch?v=qJhobECFQYk"` |
6899
+ * | `width` | ✅ | `Integer` | Video width | `459` |
6900
+ * | `height` | ✅ | `Integer` | Video height | `344` |
6901
+ * | `thumbnail_url` | ✅ | `URL` | URL for the video thumb | `"https://i.ytimg.com/vi/vUdGBEb1i9g/hqdefault.jpg"` |
6902
+ * | `title` | ✅ | `String` | Title of the video | `"Next.js Conf Booth Welcoming!"` |
6903
+ *
6904
+ * </details>
6905
+ *
6906
+ * ###### Reference Fields
6907
+ *
6908
+ * These point to other resources (either assets or other records):
6756
6909
  *
6757
- * * [List/filter records](https://www.datocms.com/docs/content-management-api/resources/item/instances)
6758
- * * [Create new records](https://www.datocms.com/docs/content-management-api/resources/item/create)
6759
- * * [Update existing records](https://www.datocms.com/docs/content-management-api/resources/item/update)
6910
+ * <details>
6911
+ * <summary>Single-asset</summary>
6912
+ *
6913
+ * The field accepts an object with the following properties, or `null`:
6914
+ *
6915
+ * | Property | Required | Type | Description | Example |
6916
+ * | ------------- | -------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
6917
+ * | `upload_id` | ✅ | `Upload ID` | ID of an asset | `"dhVR2HqgRVCTGFi0bWqLqA"` |
6918
+ * | `title` | | `String` | Title for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`) | `"From my trip to Italy"` |
6919
+ * | `alt` | | `String` | Alternate text for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`) | `"Florence skyline"` |
6920
+ * | `focal_point` | | `{ x: Float, y: Float }`, `null` | Focal point for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`). Values must be expressed as `Float` between 0 and 1. Focal point can only be specified for image assets. | `{ "x": 0.34, "y": 0.45 }` |
6921
+ * | `custom_data` | | `Record<String, String>` | An object containing custom keys that you can use on your frontend projects | `{ "watermark_image": "true" }` |
6922
+ *
6923
+ * **API responses**: Always returns asset ID only (use separate asset API for details)
6924
+ *
6925
+ * </details>
6926
+ *
6927
+ * <details>
6928
+ * <summary>Asset gallery</summary>
6929
+ *
6930
+ * This field accepts an `Array` of objects with the following properties, or `null`:
6931
+ *
6932
+ * | Property | Required | Type | Description | Example |
6933
+ * | ------------- | -------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
6934
+ * | `upload_id` | ✅ | `Upload ID` | ID of an asset | `"dhVR2HqgRVCTGFi0bWqLqA"` |
6935
+ * | `title` | | `String` | Title for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`) | `"Gallery Image Title"` |
6936
+ * | `alt` | | `String` | Alternate text for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`) | `"Gallery image description"` |
6937
+ * | `focal_point` | | `{ x: Float, y: Float }`, `null` | Focal point for the asset, if you want to override the asset's default value (see Upload `default_field_metadata`). Values must be expressed as `Float` between 0 and 1. Focal point can only be specified for image assets. | `{ "x": 0.34, "y": 0.45 }` |
6938
+ * | `custom_data` | | `Record<String, String>` | An object containing custom keys that you can use on your frontend projects | `{ "watermark_image": "true" }` |
6939
+ *
6940
+ * **API responses**: Always returns array of asset IDs only
6941
+ *
6942
+ * </details>
6943
+ *
6944
+ * <details>
6945
+ * <summary>Single link</summary>
6946
+ *
6947
+ * This field accepts a `String` representing the ID of the linked record, or `null`. See [Link Fields Guide](/docs/content-modelling/links) for relationship modeling concepts.
6948
+ *
6949
+ * **API responses**: Always returns record ID only
6950
+ *
6951
+ * </details>
6952
+ *
6953
+ * <details>
6954
+ * <summary>Multiple links</summary>
6955
+ *
6956
+ * This field accepts an `Array<String>` representing the IDs of the linked records, or `null`. See [Link Fields Guide](/docs/content-modelling/links) for relationship modeling concepts.
6957
+ *
6958
+ * **API responses**: Always returns array of record IDs only
6959
+ *
6960
+ * </details>
6961
+ *
6962
+ * ###### Block Fields
6963
+ *
6964
+ * These are special fields that contain **blocks within records**:
6965
+ *
6966
+ * | Field Type | What it contains |
6967
+ * | ------------------- | ------------------------------------------------------------------------------------------------------------------------- |
6968
+ * | **Modular content** | An array of blocks, perfect for building dynamic page sections |
6969
+ * | **Single block** | A single block instance or `null` |
6970
+ * | **Structured text** | A rich text document that can have blocks embedded within the flow of content ([DAST format](/docs/structured-text/dast)) |
6971
+ *
6972
+ * Blocks are **records within records** - they're separate items that live inside fields of other records.
6973
+ *
6974
+ * > [!PROTIP] 📚 Content Modeling Context
6975
+ * > To understand when and how to design blocks vs models, see [Blocks Guide](/docs/content-modelling/blocks). For field-specific concepts, see [Modular Content](/docs/content-modelling/modular-content) and [Structured Text](/docs/content-modelling/structured-text).
6976
+ *
6977
+ * Blocks inside those fields are unique because they can be represented in two different ways depending on the context: as a lightweight reference (an ID) or as a full content object. Understanding this duality is key to working with them effectively:
6978
+ *
6979
+ * * **Block ID (Lightweight Reference)**: A simple `String` that uniquely identifies the block (ie. `"dhVR2HqgRVCTGFi_0bWqLqA"`). This is useful when you only need to know *which* block is there, not what's inside it.
6980
+ *
6981
+ * * **Block Object (Full Content)**: The complete record object for the block, containing its own `id`, `type`, `attributes`, and `relationships`. This is used when you need to read or modify the block's actual content.
6982
+ *
6983
+ * ```json
6984
+ * {
6985
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
6986
+ * "type": "item",
6987
+ * "attributes": {
6988
+ * "title": "Block Title",
6989
+ * "content": "Block content..."
6990
+ * },
6991
+ * "relationships": {
6992
+ * "item_type": {
6993
+ * "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" }
6994
+ * }
6995
+ * }
6996
+ * }
6997
+ * ```
6998
+ *
6999
+ * <details>
7000
+ * <summary>Modular Content</summary>
7001
+ *
7002
+ * A Modular Content field holds an array of blocks.
7003
+ *
7004
+ * **As an array of IDs:**
7005
+ * ```json
7006
+ * {
7007
+ * "content_blocks": [
7008
+ * "dhVR2HqgRVCTGFi_0bWqLqA",
7009
+ * "kL9mN3pQrStUvWxYzAbCdE"
7010
+ * ]
7011
+ * }
7012
+ * ```
7013
+ *
7014
+ * **As an array of full objects:**
7015
+ *
7016
+ * ```json
7017
+ * {
7018
+ * "content_blocks": [
7019
+ * {
7020
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
7021
+ * "type": "item",
7022
+ * "attributes": { "title": "Hero Section", "content": "Welcome to our site" },
7023
+ * "relationships": { "item_type": { "data": { "id": "...", "type": "item_type" } } }
7024
+ * },
7025
+ * {
7026
+ * "id": "kL9mN3pQrStUvWxYzAbCdE",
7027
+ * "type": "item",
7028
+ * "attributes": { "title": "Image Gallery", "images": [...] },
7029
+ * "relationships": { "item_type": { "data": { "id": "...", "type": "item_type" } } }
7030
+ * }
7031
+ * ]
7032
+ * }
7033
+ * ```
7034
+ * </details>
7035
+ *
7036
+ * <details>
7037
+ * <summary>Single Block</summary>
7038
+ *
7039
+ * A Single Block field holds exactly one block, or `null`.
7040
+ *
7041
+ * **As an ID:**
7042
+ * ```json
7043
+ * {
7044
+ * "featured_block": "dhVR2HqgRVCTGFi_0bWqLqA"
7045
+ * }
7046
+ * ```
7047
+ *
7048
+ * **As an full object:**
7049
+ *
7050
+ * ```json
7051
+ * {
7052
+ * "featured_block": {
7053
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
7054
+ * "type": "item",
7055
+ * "attributes": { "title": "Featured Content", "summary": "A summary..." },
7056
+ * "relationships": { "item_type": { "data": { "id": "...", "type": "item_type" } } }
7057
+ * }
7058
+ * }
7059
+ * ```
7060
+ * </details>
7061
+ *
7062
+ * <details>
7063
+ * <summary>Structured Text</summary>
7064
+ *
7065
+ * A Structured Text field can contain blocks within its document structure ([DAST format](/docs/structured-text/dast)). The item property of a `block` or `inlineBlock` node will hold either the ID or the full object.
7066
+ *
7067
+ * **With block IDs:**
7068
+ *
7069
+ * ```json
7070
+ * {
7071
+ * "rich_text_content": {
7072
+ * "schema": "dast",
7073
+ * "document": {
7074
+ * "type": "root",
7075
+ * "children": [
7076
+ * {
7077
+ * "type": "paragraph",
7078
+ * "children": [{ "type": "span", "value": "Text before block." }]
7079
+ * },
7080
+ * {
7081
+ * "type": "block",
7082
+ * "item": "dhVR2HqgRVCTGFi_0bWqLqA"
7083
+ * }
7084
+ * ]
7085
+ * }
7086
+ * }
7087
+ * }
7088
+ * ```
7089
+ *
7090
+ * **With full objects:**
7091
+ *
7092
+ * ```json
7093
+ * {
7094
+ * "rich_text_content": {
7095
+ * "schema": "dast",
7096
+ * "document": {
7097
+ * "type": "root",
7098
+ * "children": [
7099
+ * {
7100
+ * "type": "paragraph",
7101
+ * "children": [{ "type": "span", "value": "Text before block." }]
7102
+ * },
7103
+ * {
7104
+ * "type": "block",
7105
+ * "item": {
7106
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
7107
+ * "type": "item",
7108
+ * "attributes": { "title": "Embedded Block", "content": "..." },
7109
+ * "relationships": { "item_type": { "data": { "id": "...", "type": "item_type" } } }
7110
+ * }
7111
+ * }
7112
+ * ]
7113
+ * }
7114
+ * }
7115
+ * }
7116
+ * ```
7117
+ * </details>
7118
+ *
7119
+ * ---
7120
+ *
7121
+ * ## API response modes: Regular vs. Nested
7122
+ *
7123
+ * When fetching record data, the API gives you control over how block fields are represented in the response. These two modes, **Regular** and **Nested**, are available on the following endpoints:
7124
+ *
7125
+ * * [Retrieve a single record (`GET /items/:id`)](/docs/content-management-api/resources/item/self)
7126
+ * * [Retrieve multiple records (`GET /items`)](/docs/content-management-api/resources/item/instances)
7127
+ * * [Retrieve records referenced by a record (`GET /items/:id/references`)](/docs/content-management-api/resources/item/references)
7128
+ * * [Retrieve records linked to an asset (`GET /upload/:id/references`)](/docs/content-management-api/resources/upload/references)
7129
+ *
7130
+ * ###### Regular mode (default)
7131
+ *
7132
+ * By default, the API returns block fields as IDs only. This is efficient and fast, making it ideal for listings or when you don't need the blocks' content immediately.
7133
+ *
7134
+ * ```json
7135
+ * GET /items/A4gkL_8pTZmcyJ-IlIEd2w
7136
+ *
7137
+ * {
7138
+ * "id": "A4gkL_8pTZmcyJ-IlIEd2w",
7139
+ * "type": "item",
7140
+ * "attributes": {
7141
+ * "title": "My Blog Post",
7142
+ * "content_blocks": ["dhVR2HqgRVCTGFi_0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE"],
7143
+ * "featured_block": "nZ8xY2vWqTuJkL3mNcBeFg"
7144
+ * }
7145
+ * }
7146
+ * ```
7147
+ *
7148
+ * ###### Nested mode (`?nested=true`)
7149
+ *
7150
+ * The same endpoint, when passing the `?nested=true` option, returns **block fields as full objects**. This is essential when you need to display or edit the content within the blocks.
7151
+ *
7152
+ * ```json
7153
+ * GET /items/A4gkL_8pTZmcyJ-IlIEd2w?nested=true
7154
+ *
7155
+ * {
7156
+ * "id": "A4gkL_8pTZmcyJ-IlIEd2w",
7157
+ * "type": "item",
7158
+ * "attributes": {
7159
+ * "title": "My Blog Post",
7160
+ * "content_blocks": [
7161
+ * {
7162
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
7163
+ * "type": "item",
7164
+ * "attributes": { "title": "Hero Section", "content": "Welcome to our site" },
7165
+ * "relationships": { ... }
7166
+ * },
7167
+ * {
7168
+ * "id": "kL9mN3pQrStUvWxYzAbCdE",
7169
+ * "type": "item",
7170
+ * "attributes": { "title": "Image Gallery", "images": [...] },
7171
+ * "relationships": { ... }
7172
+ * }
7173
+ * ],
7174
+ * "featured_block": {
7175
+ * "id": "nZ8xY2vWqTuJkL3mNcBeFg",
7176
+ * "type": "item",
7177
+ * "attributes": { ... },
7178
+ * "relationships": { ... }
7179
+ * }
7180
+ * }
7181
+ * }
7182
+ * ```
7183
+ *
7184
+ * > [!WARNING] Block Fields vs. Other Reference Fields
7185
+ * > Block fields are the **only** field type that change representation between modes! Asset and link fields always return IDs. To get full details for assets or linked records, you need to make separate API calls using their IDs.
7186
+ *
7187
+ * ###### When to use each mode?
7188
+ *
7189
+ * | Use "Regular Mode" when... | Use "Nested Mode" when... |
7190
+ * | -------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
7191
+ * | Listing many records or building navigation. | Displaying or editing block content, as it provides the actual content needed. |
7192
+ * | You only need to know which blocks exist. | You need to read the actual block content for display or updates. |
7193
+ * | Building navigation | Preparing to update blocks |
7194
+ * | Performance is critical; it's faster because it returns smaller responses (block IDs instead of full content). | You are building content editing interfaces where usability is more important than raw speed. |
7195
+ *
7196
+ *
7197
+ * ---
7198
+ *
7199
+ * ## Creating and updating blocks
7200
+ *
7201
+ * Working with blocks follows one fundamental constraint:
7202
+ *
7203
+ * **You cannot create, edit, or delete blocks directly. You must always update the parent record that contains them.**
7204
+ *
7205
+ * This ensures data integrity. To create/modify blocks, you send a payload to the parent record's endpoint, using a mix of Block IDs and Block Objects to describe the desired changes.
7206
+ *
7207
+ * ###### Key rules for block operations
7208
+ *
7209
+ * 1. **To create a new block**: Provide the **full object**, including `type`, `attributes`, and the `relationships.item_type` which specifies the Block Model being used.
7210
+ * 2. **To update an existing block**: Provide the **full object**, including its `id` and the changed `attributes`. You only need to include the specific attributes that you want to change - unchanged attributes will be preserved. You don't need to specify `relationships.item_type`.
7211
+ * 3. **To keep an existing block unchanged**: Simply provide its **Block ID** string. This is the most efficient way to handle unchanged blocks.
7212
+ * 4. **To delete a block**: Omit it from the payload. For a Modular Content array, remove its ID. For a Single Block field, set the value to `null`.
7213
+ * 5. **To reorder blocks** (in Modular Content): Send an array of Block IDs in the new desired order.
7214
+ *
7215
+ *
7216
+ * The following examples show how to apply these rules.
7217
+ *
7218
+ * <details>
7219
+ * <summary>Working with Modular Content Fields</summary>
7220
+ *
7221
+ * **Current state** (from a regular API response):
7222
+ * ```json
7223
+ * {
7224
+ * "content_blocks": ["dhVR2HqgRVCTGFi_0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE", "fG8hI1jKlMnOpQrStUvWxY"]
7225
+ * }
7226
+ * ```
7227
+ *
7228
+ * **To update the second block and reorder the others:**
7229
+ * ```json
7230
+ * {
7231
+ * "content_blocks": [
7232
+ * "fG8hI1jKlMnOpQrStUvWxY", // Reordered: kept as ID
7233
+ * {
7234
+ * "id": "kL9mN3pQrStUvWxYzAbCdE", // Updated: sent as object
7235
+ * "type": "item",
7236
+ * "attributes": { "title": "Updated Title" }
7237
+ * },
7238
+ * "dhVR2HqgRVCTGFi_0bWqLqA" // Reordered: kept as ID
7239
+ * ]
7240
+ * }
7241
+ * ```
7242
+ *
7243
+ * **To add a new block at the end and remove the first block:**
7244
+ * ```json
7245
+ * {
7246
+ * "content_blocks": [
7247
+ * "kL9mN3pQrStUvWxYzAbCdE", // Kept as ID
7248
+ * "fG8hI1jKlMnOpQrStUvWxY", // Kept as ID
7249
+ * {
7250
+ * "type": "item", // New block: sent as object with relationships
7251
+ * "attributes": { "title": "A Brand New Block" },
7252
+ * "relationships": {
7253
+ * "item_type": {
7254
+ * "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" }
7255
+ * }
7256
+ * }
7257
+ * }
7258
+ * ]
7259
+ * }
7260
+ * ```
7261
+ *
7262
+ * </details>
7263
+ *
7264
+ * <details>
7265
+ * <summary>Working with Single Block Fields</summary>
7266
+ *
7267
+ * **Current state** (from a regular API response):
7268
+ * ```json
7269
+ * {
7270
+ * "hero_block": "dhVR2HqgRVCTGFi_0bWqLqA"
7271
+ * }
7272
+ * ```
7273
+ *
7274
+ * **To update the block's content:**
7275
+ * ```json
7276
+ * {
7277
+ * "hero_block": {
7278
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA",
7279
+ * "type": "item",
7280
+ * "attributes": { "title": "Updated Hero Title" }
7281
+ * }
7282
+ * }
7283
+ * ```
7284
+ *
7285
+ * **To replace it with a new block:**
7286
+ * ```json
7287
+ * {
7288
+ * "hero_block": {
7289
+ * "type": "item",
7290
+ * "attributes": { "title": "New Hero Block" },
7291
+ * "relationships": {
7292
+ * "item_type": {
7293
+ * "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" }
7294
+ * }
7295
+ * }
7296
+ * }
7297
+ * }
7298
+ * ```
7299
+ *
7300
+ * **To remove (delete) the block:**
7301
+ * ```json
7302
+ * {
7303
+ * "hero_block": null
7304
+ * }
7305
+ * ```
7306
+ * </details>
7307
+ *
7308
+ * <details>
7309
+ * <summary>Working with Structured Text Fields</summary>
7310
+ *
7311
+ * Updating blocks within Structured Text follows the same pattern: you replace the `item`'s ID with a full object for the block you want to change.
7312
+ *
7313
+ * **Current state** (from a regular API response):
7314
+ * ```json
7315
+ * {
7316
+ * "rich_content": {
7317
+ * "schema": "dast",
7318
+ * "document": {
7319
+ * "type": "root",
7320
+ * "children": [
7321
+ * { "type": "block", "item": "dhVR2HqgRVCTGFi_0bWqLqA" },
7322
+ * { "type": "paragraph", "children": [{ "type": "span", "value": "Some text." }] }
7323
+ * ]
7324
+ * }
7325
+ * }
7326
+ * }
7327
+ * ```
7328
+ *
7329
+ * **To update the block's content:**
7330
+ * ```json
7331
+ * {
7332
+ * "rich_content": {
7333
+ * "schema": "dast",
7334
+ * "document": {
7335
+ * "type": "root",
7336
+ * "children": [
7337
+ * {
7338
+ * "type": "block",
7339
+ * "item": {
7340
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA", // The block to update
7341
+ * "type": "item",
7342
+ * "attributes": { "title": "Updated DAST Block Title" }
7343
+ * }
7344
+ * },
7345
+ * { "type": "paragraph", "children": [{ "type": "span", "value": "Some text." }] }
7346
+ * ]
7347
+ * }
7348
+ * }
7349
+ * }
7350
+ * ```
7351
+ * </details>
7352
+ *
7353
+ * ###### Deeply-nested blocks
7354
+ *
7355
+ * Blocks can contain other blocks, creating hierarchies multiple levels deep. **The same principles apply recursively.** When you fetch a record with `?nested=true`, the API will expand nested blocks at all levels.
7356
+ *
7357
+ * When updating, you are always sending a payload to the top-level parent record, but you can specify changes to deeply nested blocks using the same ID vs. object rules.
7358
+ *
7359
+ * <details>
7360
+ * <summary>Example: Updating a nested block</summary>
7361
+ *
7362
+ * Imagine a "Wrapper" block that contains a Modular Content field with "Child" blocks inside it. To update "Child Block 1" while leaving "Child Block 2" untouched:
7363
+ *
7364
+ * ```json
7365
+ * // This payload is sent to the top-level record containing the "Parent Block"
7366
+ * {
7367
+ * "wrapper_block": {
7368
+ * "id": "dhVR2HqgRVCTGFi_0bWqLqA", // ID of the parent block being updated
7369
+ * "type": "item",
7370
+ * "attributes": {
7371
+ * "nested_content": [
7372
+ * {
7373
+ * "id": "kL9mN3pQrStUvWxYzAbCdE", // ID of the nested block being updated
7374
+ * "type": "item",
7375
+ * "attributes": { "title": "Updated Child Block 1" }
7376
+ * },
7377
+ * "fG8hI1jKlMnOpQrStUvWxY" // Unchanged nested block, sent as ID
7378
+ * ],
7379
+ * // You can skip any attribute that does not need to change
7380
+ * }
7381
+ * }
7382
+ * }
7383
+ * ```
7384
+ * </details>
7385
+ *
7386
+ * ---
7387
+ *
7388
+ * ## Localization
7389
+ *
7390
+ * Localization allows you to store different versions of your content for different languages or regions. When you mark a field as "localizable" in your model, its structure in the API changes to accommodate multiple values.
7391
+ *
7392
+ * The fundamental change is that the field's value is no longer a single piece of data but an **object keyed by locale codes**.
7393
+ *
7394
+ * For example, a simple non-localized `title` field looks like this:
7395
+ * ```json
7396
+ * {
7397
+ * "title": "Hello World"
7398
+ * }
7399
+ * ```
7400
+ *
7401
+ * When localized, it becomes an object containing a value for each configured locale:
7402
+ * ```json
7403
+ * {
7404
+ * "title": {
7405
+ * "en": "Hello World",
7406
+ * "it": "Ciao Mondo",
7407
+ * "fr": "Bonjour le Monde"
7408
+ * }
7409
+ * }
7410
+ * ```
7411
+ * This principle applies to **every type of field**, from simple strings to **Modular Content**, **Single Block**, and **Structured Text** fields. For instance, a localized Modular Content field will contain a separate array of blocks for each language. This powerful feature allows you to have completely different block structures for each locale.
7412
+ *
7413
+ * <details>
7414
+ * <summary>Example: Localized Modular Content field</summary>
7415
+ *
7416
+ * In a `regular` API response, you would see different arrays of block IDs for each locale.
7417
+ *
7418
+ * ```json
7419
+ * {
7420
+ * "content_blocks": {
7421
+ * "en": ["dhVR2HqgRVCTGFi0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE"],
7422
+ * "it": ["fG8hI1jKlMnOpQrStUvWxY", "dhVR2HqgRVCTGFi0bWqLqA"]
7423
+ * }
7424
+ * }
7425
+ * ```
7426
+ * </details>
7427
+ *
7428
+ * <details>
7429
+ * <summary>Example: Localized Single Block field</summary>
7430
+ * A different block can be assigned to each locale.
7431
+ *
7432
+ * ```json
7433
+ * {
7434
+ * "hero_block": {
7435
+ * "en": "dhVR2HqgRVCTGFi0bWqLqA",
7436
+ * "it": "kL9mN3pQrStUvWxYzAbCdE"
7437
+ * }
7438
+ * }
7439
+ * ```
7440
+ * </details>
7441
+ *
7442
+ * <details>
7443
+ * <summary>Example: Localized Structured Text field</summary>
7444
+ *
7445
+ * The entire DAST document is localized, allowing for different text and different embedded blocks per locale.
7446
+ *
7447
+ * ```json
7448
+ * {
7449
+ * "rich_content": {
7450
+ * "en": {
7451
+ * "schema": "dast",
7452
+ * "document": {
7453
+ * "type": "root",
7454
+ * "children": [{ "type": "block", "item": "dhVR2HqgRVCTGFi0bWqLqA" }]
7455
+ * }
7456
+ * },
7457
+ * "it": {
7458
+ * "schema": "dast",
7459
+ * "document": {
7460
+ * "type": "root",
7461
+ * "children": [{ "type": "block", "item": "kL9mN3pQrStUvWxYzAbCdE" }]
7462
+ * }
7463
+ * }
7464
+ * }
7465
+ * }
7466
+ * ```
7467
+ * </details>
7468
+ *
7469
+ * When reading or writing localized content, there are a few key rules to follow to ensure data integrity.
7470
+ *
7471
+ * ###### Locale consistency
7472
+ * Within a single record, all localized fields must have a consistent set of locales. You cannot have a `title` with English and Italian, and a `description` with English and French in the same record.
7473
+ *
7474
+ * ```json
7475
+ * // ❌ This will FAIL due to inconsistent locales ("it" vs "fr")
7476
+ * {
7477
+ * "title": { "en": "Title", "it": "Titolo" },
7478
+ * "description": { "en": "Description", "fr": "Description" }
7479
+ * }
7480
+ *
7481
+ * // ✅ This is VALID because locales are consistent across all fields
7482
+ * {
7483
+ * "title": { "en": "Title", "it": "Titolo" },
7484
+ * "description": { "en": "Description", "it": "Descrizione" }
7485
+ * }
7486
+ * ```
7487
+ *
7488
+ * ###### Required locales
7489
+ *
7490
+ * Your model can be configured to require that all project's locales are always present ([`attributes.all_locales_required`](/docs/content-management-api/resources/item-type#object-payload)). If that's the case, when creating or updating a record, you must provide a value for all required locales.
7491
+ *
7492
+ * ```json
7493
+ * // ❌ This will FAIL if all locales are required for the model
7494
+ * {
7495
+ * "title": { "en": "Title" }
7496
+ * }
7497
+ * ```
6760
7498
  *
6761
7499
  *
6762
7500
  * This interface was referenced by `DatoApi`'s JSON-Schema