@terminalfour/terminalfour-js 1.0.0-rc.1

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 (253) hide show
  1. package/LICENSE.md +106 -0
  2. package/README.md +169 -0
  3. package/dist/cjs/element-resolver.d.ts +115 -0
  4. package/dist/cjs/element-resolver.d.ts.map +1 -0
  5. package/dist/cjs/element-resolver.js +391 -0
  6. package/dist/cjs/element-resolver.js.map +1 -0
  7. package/dist/cjs/errors.d.ts +21 -0
  8. package/dist/cjs/errors.d.ts.map +1 -0
  9. package/dist/cjs/errors.js +21 -0
  10. package/dist/cjs/errors.js.map +1 -0
  11. package/dist/cjs/handlebars.d.ts +123 -0
  12. package/dist/cjs/handlebars.d.ts.map +1 -0
  13. package/dist/cjs/handlebars.js +306 -0
  14. package/dist/cjs/handlebars.js.map +1 -0
  15. package/dist/cjs/http-client.d.ts +21 -0
  16. package/dist/cjs/http-client.d.ts.map +1 -0
  17. package/dist/cjs/http-client.js +126 -0
  18. package/dist/cjs/http-client.js.map +1 -0
  19. package/dist/cjs/index.d.ts +37 -0
  20. package/dist/cjs/index.d.ts.map +1 -0
  21. package/dist/cjs/index.js +55 -0
  22. package/dist/cjs/index.js.map +1 -0
  23. package/dist/cjs/media-category-ref.d.ts +78 -0
  24. package/dist/cjs/media-category-ref.d.ts.map +1 -0
  25. package/dist/cjs/media-category-ref.js +184 -0
  26. package/dist/cjs/media-category-ref.js.map +1 -0
  27. package/dist/cjs/media-library.d.ts +30 -0
  28. package/dist/cjs/media-library.d.ts.map +1 -0
  29. package/dist/cjs/media-library.js +77 -0
  30. package/dist/cjs/media-library.js.map +1 -0
  31. package/dist/cjs/models/content-item.d.ts +80 -0
  32. package/dist/cjs/models/content-item.d.ts.map +1 -0
  33. package/dist/cjs/models/content-item.js +682 -0
  34. package/dist/cjs/models/content-item.js.map +1 -0
  35. package/dist/cjs/models/media-category-item.d.ts +29 -0
  36. package/dist/cjs/models/media-category-item.d.ts.map +1 -0
  37. package/dist/cjs/models/media-category-item.js +33 -0
  38. package/dist/cjs/models/media-category-item.js.map +1 -0
  39. package/dist/cjs/models/media-item.d.ts +74 -0
  40. package/dist/cjs/models/media-item.d.ts.map +1 -0
  41. package/dist/cjs/models/media-item.js +188 -0
  42. package/dist/cjs/models/media-item.js.map +1 -0
  43. package/dist/cjs/models/section-item.d.ts +58 -0
  44. package/dist/cjs/models/section-item.d.ts.map +1 -0
  45. package/dist/cjs/models/section-item.js +166 -0
  46. package/dist/cjs/models/section-item.js.map +1 -0
  47. package/dist/cjs/package.json +1 -0
  48. package/dist/cjs/resources/channel-resource.d.ts +112 -0
  49. package/dist/cjs/resources/channel-resource.d.ts.map +1 -0
  50. package/dist/cjs/resources/channel-resource.js +107 -0
  51. package/dist/cjs/resources/channel-resource.js.map +1 -0
  52. package/dist/cjs/resources/content-resource.d.ts +50 -0
  53. package/dist/cjs/resources/content-resource.d.ts.map +1 -0
  54. package/dist/cjs/resources/content-resource.js +286 -0
  55. package/dist/cjs/resources/content-resource.js.map +1 -0
  56. package/dist/cjs/resources/content-type-resource.d.ts +283 -0
  57. package/dist/cjs/resources/content-type-resource.d.ts.map +1 -0
  58. package/dist/cjs/resources/content-type-resource.js +970 -0
  59. package/dist/cjs/resources/content-type-resource.js.map +1 -0
  60. package/dist/cjs/resources/group-resource.d.ts +96 -0
  61. package/dist/cjs/resources/group-resource.d.ts.map +1 -0
  62. package/dist/cjs/resources/group-resource.js +213 -0
  63. package/dist/cjs/resources/group-resource.js.map +1 -0
  64. package/dist/cjs/resources/list-resource.d.ts +111 -0
  65. package/dist/cjs/resources/list-resource.d.ts.map +1 -0
  66. package/dist/cjs/resources/list-resource.js +179 -0
  67. package/dist/cjs/resources/list-resource.js.map +1 -0
  68. package/dist/cjs/resources/media-resource.d.ts +69 -0
  69. package/dist/cjs/resources/media-resource.d.ts.map +1 -0
  70. package/dist/cjs/resources/media-resource.js +210 -0
  71. package/dist/cjs/resources/media-resource.js.map +1 -0
  72. package/dist/cjs/resources/media-type-resource.d.ts +70 -0
  73. package/dist/cjs/resources/media-type-resource.d.ts.map +1 -0
  74. package/dist/cjs/resources/media-type-resource.js +195 -0
  75. package/dist/cjs/resources/media-type-resource.js.map +1 -0
  76. package/dist/cjs/resources/navigation-resource.d.ts +664 -0
  77. package/dist/cjs/resources/navigation-resource.d.ts.map +1 -0
  78. package/dist/cjs/resources/navigation-resource.js +2349 -0
  79. package/dist/cjs/resources/navigation-resource.js.map +1 -0
  80. package/dist/cjs/resources/page-layout-resource.d.ts +83 -0
  81. package/dist/cjs/resources/page-layout-resource.d.ts.map +1 -0
  82. package/dist/cjs/resources/page-layout-resource.js +214 -0
  83. package/dist/cjs/resources/page-layout-resource.js.map +1 -0
  84. package/dist/cjs/resources/user-resource.d.ts +126 -0
  85. package/dist/cjs/resources/user-resource.d.ts.map +1 -0
  86. package/dist/cjs/resources/user-resource.js +317 -0
  87. package/dist/cjs/resources/user-resource.js.map +1 -0
  88. package/dist/cjs/section-ref.d.ts +185 -0
  89. package/dist/cjs/section-ref.d.ts.map +1 -0
  90. package/dist/cjs/section-ref.js +813 -0
  91. package/dist/cjs/section-ref.js.map +1 -0
  92. package/dist/cjs/site-structure.d.ts +18 -0
  93. package/dist/cjs/site-structure.d.ts.map +1 -0
  94. package/dist/cjs/site-structure.js +57 -0
  95. package/dist/cjs/site-structure.js.map +1 -0
  96. package/dist/cjs/t4-client.d.ts +121 -0
  97. package/dist/cjs/t4-client.d.ts.map +1 -0
  98. package/dist/cjs/t4-client.js +190 -0
  99. package/dist/cjs/t4-client.js.map +1 -0
  100. package/dist/cjs/type-registry.d.ts +31 -0
  101. package/dist/cjs/type-registry.d.ts.map +1 -0
  102. package/dist/cjs/type-registry.js +76 -0
  103. package/dist/cjs/type-registry.js.map +1 -0
  104. package/dist/cjs/types.d.ts +211 -0
  105. package/dist/cjs/types.d.ts.map +1 -0
  106. package/dist/cjs/types.js +3 -0
  107. package/dist/cjs/types.js.map +1 -0
  108. package/dist/cjs/utils.d.ts +147 -0
  109. package/dist/cjs/utils.d.ts.map +1 -0
  110. package/dist/cjs/utils.js +408 -0
  111. package/dist/cjs/utils.js.map +1 -0
  112. package/dist/esm/element-resolver.d.ts +115 -0
  113. package/dist/esm/element-resolver.d.ts.map +1 -0
  114. package/dist/esm/element-resolver.js +387 -0
  115. package/dist/esm/element-resolver.js.map +1 -0
  116. package/dist/esm/errors.d.ts +21 -0
  117. package/dist/esm/errors.d.ts.map +1 -0
  118. package/dist/esm/errors.js +17 -0
  119. package/dist/esm/errors.js.map +1 -0
  120. package/dist/esm/handlebars.d.ts +123 -0
  121. package/dist/esm/handlebars.d.ts.map +1 -0
  122. package/dist/esm/handlebars.js +300 -0
  123. package/dist/esm/handlebars.js.map +1 -0
  124. package/dist/esm/http-client.d.ts +21 -0
  125. package/dist/esm/http-client.d.ts.map +1 -0
  126. package/dist/esm/http-client.js +122 -0
  127. package/dist/esm/http-client.js.map +1 -0
  128. package/dist/esm/index.d.ts +37 -0
  129. package/dist/esm/index.d.ts.map +1 -0
  130. package/dist/esm/index.js +26 -0
  131. package/dist/esm/index.js.map +1 -0
  132. package/dist/esm/media-category-ref.d.ts +78 -0
  133. package/dist/esm/media-category-ref.d.ts.map +1 -0
  134. package/dist/esm/media-category-ref.js +180 -0
  135. package/dist/esm/media-category-ref.js.map +1 -0
  136. package/dist/esm/media-library.d.ts +30 -0
  137. package/dist/esm/media-library.d.ts.map +1 -0
  138. package/dist/esm/media-library.js +73 -0
  139. package/dist/esm/media-library.js.map +1 -0
  140. package/dist/esm/models/content-item.d.ts +80 -0
  141. package/dist/esm/models/content-item.d.ts.map +1 -0
  142. package/dist/esm/models/content-item.js +676 -0
  143. package/dist/esm/models/content-item.js.map +1 -0
  144. package/dist/esm/models/media-category-item.d.ts +29 -0
  145. package/dist/esm/models/media-category-item.d.ts.map +1 -0
  146. package/dist/esm/models/media-category-item.js +29 -0
  147. package/dist/esm/models/media-category-item.js.map +1 -0
  148. package/dist/esm/models/media-item.d.ts +74 -0
  149. package/dist/esm/models/media-item.d.ts.map +1 -0
  150. package/dist/esm/models/media-item.js +184 -0
  151. package/dist/esm/models/media-item.js.map +1 -0
  152. package/dist/esm/models/section-item.d.ts +58 -0
  153. package/dist/esm/models/section-item.d.ts.map +1 -0
  154. package/dist/esm/models/section-item.js +162 -0
  155. package/dist/esm/models/section-item.js.map +1 -0
  156. package/dist/esm/resources/channel-resource.d.ts +112 -0
  157. package/dist/esm/resources/channel-resource.d.ts.map +1 -0
  158. package/dist/esm/resources/channel-resource.js +102 -0
  159. package/dist/esm/resources/channel-resource.js.map +1 -0
  160. package/dist/esm/resources/content-resource.d.ts +50 -0
  161. package/dist/esm/resources/content-resource.d.ts.map +1 -0
  162. package/dist/esm/resources/content-resource.js +282 -0
  163. package/dist/esm/resources/content-resource.js.map +1 -0
  164. package/dist/esm/resources/content-type-resource.d.ts +283 -0
  165. package/dist/esm/resources/content-type-resource.d.ts.map +1 -0
  166. package/dist/esm/resources/content-type-resource.js +964 -0
  167. package/dist/esm/resources/content-type-resource.js.map +1 -0
  168. package/dist/esm/resources/group-resource.d.ts +96 -0
  169. package/dist/esm/resources/group-resource.d.ts.map +1 -0
  170. package/dist/esm/resources/group-resource.js +208 -0
  171. package/dist/esm/resources/group-resource.js.map +1 -0
  172. package/dist/esm/resources/list-resource.d.ts +111 -0
  173. package/dist/esm/resources/list-resource.d.ts.map +1 -0
  174. package/dist/esm/resources/list-resource.js +174 -0
  175. package/dist/esm/resources/list-resource.js.map +1 -0
  176. package/dist/esm/resources/media-resource.d.ts +69 -0
  177. package/dist/esm/resources/media-resource.d.ts.map +1 -0
  178. package/dist/esm/resources/media-resource.js +206 -0
  179. package/dist/esm/resources/media-resource.js.map +1 -0
  180. package/dist/esm/resources/media-type-resource.d.ts +70 -0
  181. package/dist/esm/resources/media-type-resource.d.ts.map +1 -0
  182. package/dist/esm/resources/media-type-resource.js +190 -0
  183. package/dist/esm/resources/media-type-resource.js.map +1 -0
  184. package/dist/esm/resources/navigation-resource.d.ts +664 -0
  185. package/dist/esm/resources/navigation-resource.d.ts.map +1 -0
  186. package/dist/esm/resources/navigation-resource.js +2344 -0
  187. package/dist/esm/resources/navigation-resource.js.map +1 -0
  188. package/dist/esm/resources/page-layout-resource.d.ts +83 -0
  189. package/dist/esm/resources/page-layout-resource.d.ts.map +1 -0
  190. package/dist/esm/resources/page-layout-resource.js +209 -0
  191. package/dist/esm/resources/page-layout-resource.js.map +1 -0
  192. package/dist/esm/resources/user-resource.d.ts +126 -0
  193. package/dist/esm/resources/user-resource.d.ts.map +1 -0
  194. package/dist/esm/resources/user-resource.js +312 -0
  195. package/dist/esm/resources/user-resource.js.map +1 -0
  196. package/dist/esm/section-ref.d.ts +185 -0
  197. package/dist/esm/section-ref.d.ts.map +1 -0
  198. package/dist/esm/section-ref.js +808 -0
  199. package/dist/esm/section-ref.js.map +1 -0
  200. package/dist/esm/site-structure.d.ts +18 -0
  201. package/dist/esm/site-structure.d.ts.map +1 -0
  202. package/dist/esm/site-structure.js +53 -0
  203. package/dist/esm/site-structure.js.map +1 -0
  204. package/dist/esm/t4-client.d.ts +121 -0
  205. package/dist/esm/t4-client.d.ts.map +1 -0
  206. package/dist/esm/t4-client.js +186 -0
  207. package/dist/esm/t4-client.js.map +1 -0
  208. package/dist/esm/type-registry.d.ts +31 -0
  209. package/dist/esm/type-registry.d.ts.map +1 -0
  210. package/dist/esm/type-registry.js +72 -0
  211. package/dist/esm/type-registry.js.map +1 -0
  212. package/dist/esm/types.d.ts +211 -0
  213. package/dist/esm/types.d.ts.map +1 -0
  214. package/dist/esm/types.js +2 -0
  215. package/dist/esm/types.js.map +1 -0
  216. package/dist/esm/utils.d.ts +147 -0
  217. package/dist/esm/utils.d.ts.map +1 -0
  218. package/dist/esm/utils.js +355 -0
  219. package/dist/esm/utils.js.map +1 -0
  220. package/docs/channels.md +62 -0
  221. package/docs/content-types.md +313 -0
  222. package/docs/content.md +199 -0
  223. package/docs/error-handling.md +86 -0
  224. package/docs/getting-started.md +146 -0
  225. package/docs/groups-and-users.md +167 -0
  226. package/docs/handlebars.md +145 -0
  227. package/docs/lists.md +98 -0
  228. package/docs/media-types.md +111 -0
  229. package/docs/media.md +169 -0
  230. package/docs/navigation/a-to-z.md +62 -0
  231. package/docs/navigation/breadcrumbs.md +67 -0
  232. package/docs/navigation/css-selector.md +53 -0
  233. package/docs/navigation/generate-file.md +48 -0
  234. package/docs/navigation/keyword-search.md +134 -0
  235. package/docs/navigation/language-switcher.md +37 -0
  236. package/docs/navigation/link-menu.md +105 -0
  237. package/docs/navigation/pagination.md +80 -0
  238. package/docs/navigation/previous-next-fulltext.md +43 -0
  239. package/docs/navigation/publish-to-one-file.md +93 -0
  240. package/docs/navigation/related-content.md +79 -0
  241. package/docs/navigation/related-section-branch.md +31 -0
  242. package/docs/navigation/return-to-index.md +35 -0
  243. package/docs/navigation/section-details.md +51 -0
  244. package/docs/navigation/section-iterator.md +33 -0
  245. package/docs/navigation/section-meta-info.md +39 -0
  246. package/docs/navigation/site-map.md +58 -0
  247. package/docs/navigation/top-content.md +80 -0
  248. package/docs/navigation/top-stories.md +47 -0
  249. package/docs/navigation.md +134 -0
  250. package/docs/page-layouts.md +71 -0
  251. package/docs/sections.md +224 -0
  252. package/docs/typescript.md +124 -0
  253. package/package.json +64 -0
@@ -0,0 +1,134 @@
1
+ # Navigation Objects
2
+
3
+ Navigation objects control site navigation during publishing. terminalfour-js supports all 19 types, including each type's configuration and validation rules.
4
+
5
+ ## List and filter navigation objects
6
+
7
+ ```typescript
8
+ const all = await t4.navigation.list();
9
+ for (const navigation of all) {
10
+ console.log(navigation.id, navigation.name, navigation.type, navigation.enabled);
11
+ }
12
+
13
+ const breadcrumbs = await t4.navigation.list({ type: 'breadcrumbs' });
14
+ const sitemaps = await t4.navigation.list({ type: 'site-map' });
15
+ ```
16
+
17
+ Each `NavigationSummary` contains:
18
+
19
+ | Property | Type | Description |
20
+ |---|---|---|
21
+ | `id` | `number` | Navigation object ID |
22
+ | `name` | `string` | Display name |
23
+ | `description` | `string` | Description |
24
+ | `type` | `string` | Type code listed below |
25
+ | `typeName` | `string` | Human-readable type name |
26
+ | `enabled` | `boolean` | Whether the navigation is active |
27
+
28
+ ## Get a navigation object
29
+
30
+ ```typescript
31
+ const navigation = await t4.navigation.get(181);
32
+ console.log(navigation.name); // 'A-Z Navigation Demo'
33
+ console.log(navigation.type); // 'a-to-z'
34
+ console.log(navigation.enabled); // true
35
+ console.log(navigation.cachingEnabled); // false
36
+ console.log(navigation.previewEnabled); // true
37
+ console.log(navigation.properties); // properties vary by type
38
+ ```
39
+
40
+ Type-specific properties use JavaScript booleans, numbers, and arrays. The SDK omits internal and derived fields.
41
+
42
+ | Shared property | Mutable | Description |
43
+ |---|---|---|
44
+ | `name` | yes | Display name |
45
+ | `description` | yes | Description |
46
+ | `enabled` | yes | Whether the navigation is active |
47
+ | `cachingEnabled` | yes | Whether output caching is enabled |
48
+ | `previewEnabled` | yes | Whether preview mode is enabled |
49
+ | `properties` | yes | Type-specific configuration |
50
+
51
+ ## Create a navigation object
52
+
53
+ ```typescript
54
+ await t4.navigation.create({
55
+ type: 'breadcrumbs',
56
+ name: 'Main Breadcrumbs',
57
+ description: 'Site breadcrumb trail',
58
+ properties: {
59
+ separator: ' > ',
60
+ useLinks: true,
61
+ hideHome: true,
62
+ },
63
+ });
64
+ ```
65
+
66
+ Only `type` and `name` are required. Properties have default values.
67
+
68
+ ## Update a navigation object
69
+
70
+ ### Direct update
71
+
72
+ ```typescript
73
+ const navigation = await t4.navigation.update(181, {
74
+ name: 'Renamed',
75
+ enabled: false,
76
+ properties: {
77
+ beforeHtml: '<div>',
78
+ },
79
+ });
80
+ ```
81
+
82
+ `update()` merges `properties` with existing values. Pass only the keys to change:
83
+
84
+ ```typescript
85
+ await t4.navigation.update(10, {
86
+ properties: { separator: ' / ' },
87
+ });
88
+ ```
89
+
90
+ Every other property remains unchanged. A navigation object's `type` cannot change after creation, so `update()` does not accept it.
91
+
92
+ ### Mutable item
93
+
94
+ ```typescript
95
+ const navigation = await t4.navigation.get(181);
96
+ navigation.name = 'Renamed';
97
+ navigation.enabled = false;
98
+ navigation.properties.beforeHtml = '<div>';
99
+ await navigation.save();
100
+ ```
101
+
102
+ ## Delete a navigation object
103
+
104
+ ```typescript
105
+ await t4.navigation.delete(181);
106
+ ```
107
+
108
+ ## Navigation types
109
+
110
+ | Type name | Code | Guide |
111
+ |---|---|---|
112
+ | A to Z Navigation | `a-to-z` | [Details](./navigation/a-to-z.md) |
113
+ | Breadcrumbs | `breadcrumbs` | [Details](./navigation/breadcrumbs.md) |
114
+ | CSS Selector | `css-selector` | [Details](./navigation/css-selector.md) |
115
+ | Generate File | `generate-file` | [Details](./navigation/generate-file.md) |
116
+ | Keyword Search Content | `keyword-search` | [Details](./navigation/keyword-search.md) |
117
+ | Language Switcher | `language-switcher` | [Details](./navigation/language-switcher.md) |
118
+ | Link Menu | `link-menu` | [Details](./navigation/link-menu.md) |
119
+ | Pagination | `pagination` | [Details](./navigation/pagination.md) |
120
+ | Previous/Next Fulltext Content | `previous-next-fulltext` | [Details](./navigation/previous-next-fulltext.md) |
121
+ | Publish to One File | `publish-to-one-file` | [Details](./navigation/publish-to-one-file.md) |
122
+ | Related Content | `related-content` | [Details](./navigation/related-content.md) |
123
+ | Related Section Branch | `related-section-branch` | [Details](./navigation/related-section-branch.md) |
124
+ | Return to Index | `return-to-index` | [Details](./navigation/return-to-index.md) |
125
+ | Section Details | `section-details` | [Details](./navigation/section-details.md) |
126
+ | Section Iterator | `section-iterator` | [Details](./navigation/section-iterator.md) |
127
+ | Section Meta Info | `section-meta-info` | [Details](./navigation/section-meta-info.md) |
128
+ | Site Map | `site-map` | [Details](./navigation/site-map.md) |
129
+ | Top Content | `top-content` | [Details](./navigation/top-content.md) |
130
+ | Top Stories | `top-stories` | [Details](./navigation/top-stories.md) |
131
+
132
+ ---
133
+
134
+ **Previous:** [Channels](./channels.md) · **Next:** [Handlebars](./handlebars.md)
@@ -0,0 +1,71 @@
1
+ # Page Layouts
2
+
3
+ Use `t4.pageLayouts` to manage page layout code, syntax, processors, and file extensions.
4
+
5
+ ## List and read page layouts
6
+
7
+ ```typescript
8
+ const layouts = await t4.pageLayouts.list();
9
+ // [{ id: 5, name: 'Main Layout', description: 'Default page layout' }]
10
+
11
+ const layout = await t4.pageLayouts.get(5);
12
+ ```
13
+
14
+ A full page layout includes:
15
+
16
+ | Property | Example or meaning |
17
+ |---|---|
18
+ | `name` | Layout name |
19
+ | `description` | Layout description |
20
+ | `headerCode` | Header markup or code |
21
+ | `footerCode` | Footer markup or code |
22
+ | `fileExtension` | Output file extension |
23
+ | `syntax` | Syntax such as `'HTML/XML'` |
24
+ | `processor` | Processor such as `'handlebars'` |
25
+
26
+ ## Create a page layout
27
+
28
+ ```typescript
29
+ await t4.pageLayouts.create({
30
+ name: 'My Layout',
31
+ description: 'A custom page layout',
32
+ headerCode: '<!DOCTYPE html><html><head></head><body>',
33
+ footerCode: '</body></html>',
34
+ syntax: 'HTML/XML', // optional
35
+ processor: 'handlebars', // optional; default: 'handlebars'
36
+ fileExtension: 'html', // optional
37
+ });
38
+ ```
39
+
40
+ Processor options are `'handlebars'`, `'t4-tags'`, and `'programmable-layouts'`. The default is `'handlebars'`.
41
+
42
+ ## Update a page layout
43
+
44
+ ### Direct update
45
+
46
+ ```typescript
47
+ await t4.pageLayouts.update(5, {
48
+ name: 'Renamed',
49
+ headerCode: '<!-- updated -->',
50
+ });
51
+ ```
52
+
53
+ ### Mutable item
54
+
55
+ ```typescript
56
+ const layout = await t4.pageLayouts.get(5);
57
+ layout.name = 'Renamed';
58
+ layout.headerCode = '<!-- updated -->';
59
+ layout.processor = 't4-tags';
60
+ await layout.save();
61
+ ```
62
+
63
+ ## Delete a page layout
64
+
65
+ ```typescript
66
+ await t4.pageLayouts.delete(5);
67
+ ```
68
+
69
+ ---
70
+
71
+ **Previous:** [Groups & Users](./groups-and-users.md) · **Next:** [Media](./media.md)
@@ -0,0 +1,224 @@
1
+ # Sections
2
+
3
+ `t4.section(id)` creates a lightweight `SectionRef` without making an API request. Use the reference to read or change that section.
4
+
5
+ ## Contents
6
+
7
+ - [Read and update a section](#read-and-update-a-section)
8
+ - [Create, delete, purge, or move](#create-delete-purge-or-move)
9
+ - [Navigate the section tree](#navigate-the-section-tree)
10
+ - [Manage section configuration](#manage-section-configuration)
11
+ - [Publish](#publish)
12
+
13
+ ## Read and update a section
14
+
15
+ ```typescript
16
+ const section = await t4.section(233).get();
17
+ ```
18
+
19
+ `get()` returns a mutable `SectionItem`:
20
+
21
+ | Property | Type | Mutable | Description |
22
+ |---|---|---|---|
23
+ | `id` | `number` | no | Section ID |
24
+ | `parentId` | `number \| null` | no | Parent section ID |
25
+ | `name` | `string` | yes | Section name |
26
+ | `show` | `boolean` | yes | Visible in navigation |
27
+ | `status` | `string` | yes | `'approved'`, `'pending'`, or `'inactive'` |
28
+ | `outputUri` | `string` | yes | Output URI for publishing |
29
+ | `filename` | `string` | yes | Output filename |
30
+ | `archive` | `boolean` | yes | Whether this is an archive section |
31
+ | `path` | `string \| null` | no | Breadcrumb path (`'Home » Site » Section'`) |
32
+ | `pathMembers` | `number[]` | no | Section IDs in the path |
33
+ | `lastModified` | `Date \| null` | no | Last modification date |
34
+ | `accessControl` | `{ active, enabled }` | no | Access control state |
35
+ | `customFields` | `Record<string, unknown> \| null` | yes | Resolved metadata content fields, or `null` |
36
+
37
+ ### Direct update
38
+
39
+ Use `update()` when you already know the values to change:
40
+
41
+ ```typescript
42
+ await t4.section(233).update({
43
+ name: 'Renamed',
44
+ show: false,
45
+ status: 'pending',
46
+ customFields: {
47
+ Title: 'New Title'
48
+ },
49
+ });
50
+ ```
51
+
52
+ ### Mutable item
53
+
54
+ Use `get()` and `save()` when you need to inspect the current section first:
55
+
56
+ ```typescript
57
+ const section = await t4.section(233).get();
58
+ section.name = 'Renamed Section';
59
+ section.show = false;
60
+ section.outputUri = 'new-uri';
61
+ await section.save();
62
+ ```
63
+ `customFields` is `null` only when the instance has no section metadata content type configured at all. When a metadata type exists, `customFields` is an object (empty if no fields are set).
64
+
65
+ The SDK will throw when no metadata content type is configured on the instance and you attempt add customFields.
66
+
67
+ ## Create, delete, purge, or move
68
+
69
+ ### Create a child section
70
+
71
+ ```typescript
72
+ const child = await t4.section(233).addSection({
73
+ name: 'New Section',
74
+ show: true, // default: true
75
+ status: 'approved', // default: 'approved'
76
+ customFields: { Title: 'Custom Title' }, // optional
77
+ });
78
+ ```
79
+
80
+ The new section inherits channels, page layouts, access control, and metadata types from its parent.
81
+
82
+ When the instance has a section metadata content type configured, `addSection()` always creates a metadata content instance for the new section, whether or not you pass `customFields`.
83
+
84
+ ### Delete, purge, or move
85
+
86
+ ```typescript
87
+ await t4.section(500).delete(); // soft delete: sets status to inactive
88
+ await t4.section(500).purge(); // permanent removal; section must be inactive first
89
+ await t4.section(500).move(233); // move under section 233
90
+ ```
91
+
92
+ ## Navigate the section tree
93
+
94
+ ### Direct children
95
+
96
+ Use `subsections()` for a one-level lookup:
97
+
98
+ ```typescript
99
+ const children = await t4.section(233).subsections();
100
+ // [{ id: 500, name: 'Child', lastModified: Date }]
101
+ ```
102
+
103
+ ### Full tree or subtree
104
+
105
+ ```typescript
106
+ const tree = await t4.siteStructure.tree(); // full site structure
107
+ const subTree = await t4.section(6758).tree(); // subtree from section 6758
108
+ ```
109
+
110
+ Tree nodes contain `id`, `name`, `status`, and optional `children`. `siteStructure.tree()` retrieves the entire hierarchy in one request, so prefer `subsections()` for lighter lookups on large sites.
111
+
112
+ ## Manage section configuration
113
+
114
+ ### Channels
115
+
116
+ ```typescript
117
+ const channels = await t4.section(233).channels();
118
+ // [{ id: 1, name: 'Default Channel' }]
119
+ ```
120
+
121
+ ### Owner
122
+
123
+ ```typescript
124
+ const owner = await t4.section(233).owner();
125
+ // { id: 30, type: 'contributor', username: 'j.smith',
126
+ // firstName: 'Jane', lastName: 'Smith', emailAddress: 'jane@example.com' }
127
+ ```
128
+
129
+ `type` is the user's role: `'admin'`, `'power-user'`, `'moderator'`, `'contributor'`, or `'visitor'`.
130
+
131
+ ### Metadata
132
+
133
+ ```typescript
134
+ const meta = await t4.section(233).metaDatas();
135
+ // { 'og:title': 'Page Title', 'description': 'A description' }
136
+
137
+ await t4.section(233).setMetaDatas({
138
+ 'og:title': 'New Title',
139
+ 'description': 'Updated description',
140
+ });
141
+ ```
142
+
143
+ `setMetaDatas()` merges the supplied values with existing metadata. It does not replace the whole object. Invalid tag names produce an error that lists the valid options.
144
+
145
+ ### Page layouts
146
+
147
+ ```typescript
148
+ const layouts = await t4.section(233).pageLayouts();
149
+ // [
150
+ // {
151
+ // channel: { id: 1, name: 'Default Channel' },
152
+ // pageLayout: { id: 5, name: 'Main Layout', inherited: false },
153
+ // childPageLayout: { id: 10, name: 'Child Layout' },
154
+ // },
155
+ // {
156
+ // channel: { id: 3, name: 'Preview' },
157
+ // pageLayout: { id: 3446, name: 'Preview Layout', inherited: true },
158
+ // childPageLayout: null,
159
+ // },
160
+ // ]
161
+ ```
162
+
163
+ | Value | Meaning |
164
+ |---|---|
165
+ | `pageLayout` | Layout applied to this section. `inherited: true` means it comes from a parent. |
166
+ | `childPageLayout` | Layout that descendant sections inherit. |
167
+
168
+ Set layouts by channel. The operation is additive, so it changes only the channels you pass:
169
+
170
+ ```typescript
171
+ await t4.section(233).setPageLayouts([
172
+ { channelId: 1, pageLayout: 99 },
173
+ { channelId: 3, childPageLayout: 200 },
174
+ ]);
175
+
176
+ await t4.section(233).setPageLayouts([
177
+ { channelId: 1, pageLayout: null }, // clear this layout
178
+ ]);
179
+ ```
180
+
181
+ ### Edit rights
182
+
183
+ ```typescript
184
+ const rights = await t4.section(233).editRights();
185
+ // {
186
+ // users: [{ id, username, firstName, lastName, emailAddress, inherited: false }],
187
+ // groups: [{ id, name, inherited: true }]
188
+ // }
189
+
190
+ await t4.section(233).setEditRights({ users: [30, 61], groups: [1] });
191
+ await t4.section(233).removeEditRights({ users: [30] });
192
+ ```
193
+
194
+ `setEditRights()` adds and deduplicates rights.
195
+
196
+ ### Content types
197
+
198
+ ```typescript
199
+ const types = await t4.section(233).contentTypes();
200
+ // [{ id: 44, name: 'Article', description: '...', scope: 'branch' }]
201
+
202
+ await t4.section(233).setContentTypes([
203
+ { id: 44, scope: 'branch' },
204
+ { id: 343, scope: 'section' },
205
+ ]);
206
+
207
+ await t4.section(233).removeContentTypes([44]);
208
+ ```
209
+
210
+ `setContentTypes()` merges the supplied types with the existing configuration.
211
+
212
+ ## Publish
213
+
214
+ ```typescript
215
+ await t4.section(237).publish(); // single section; selects the channel if there is only one
216
+ await t4.section(237).publish({ branch: true }); // entire branch
217
+ await t4.section(237).publish({ channelId: 1, branch: true }); // selected channel
218
+ ```
219
+
220
+ When a section belongs to multiple channels, you must supply `channelId`. Otherwise, the SDK throws an error that lists the available channels.
221
+
222
+ ---
223
+
224
+ **Previous:** [Getting Started](./getting-started.md) · **Next:** [Content](./content.md)
@@ -0,0 +1,124 @@
1
+ # TypeScript Reference
2
+
3
+ The package exports its public classes, interfaces, and type aliases. Import runtime values normally and use `import type` for type-only imports.
4
+
5
+ ## Runtime exports
6
+
7
+ ```typescript
8
+ import {
9
+ T4Client,
10
+ T4ApiError,
11
+ ContentItem,
12
+ SectionItem,
13
+ SectionRef,
14
+ SiteStructure,
15
+ MediaCategoryRef,
16
+ MediaCategoryItem,
17
+ MediaItem,
18
+ MediaLibrary,
19
+ ContentType,
20
+ Layout,
21
+ List,
22
+ Group,
23
+ User,
24
+ PageLayout,
25
+ MediaType,
26
+ MediaTypeResource,
27
+ NavigationResource,
28
+ NavigationObject,
29
+ Channel,
30
+ ChannelResource,
31
+ Handlebars,
32
+ HandlebarsItem,
33
+ HandlebarsContentResource,
34
+ NAVIGATION_TYPE_NAMES,
35
+ } from '@terminalfour/terminalfour-js';
36
+ ```
37
+
38
+ ## Type-only exports
39
+
40
+ ```typescript
41
+ import type {
42
+ // Client configuration
43
+ T4ClientConfig,
44
+ LanguageOption,
45
+
46
+ // Content
47
+ ContentDTO,
48
+ CreateContentData,
49
+ UpdateContentData,
50
+ DateInput,
51
+
52
+ // Content types
53
+ ContentTypeData,
54
+ ContentTypeFieldDef,
55
+
56
+ // Sections
57
+ AddSectionData,
58
+ HierarchyNode,
59
+ GetTreeOptions,
60
+ SectionTreeNode,
61
+ Owner,
62
+
63
+ // Media
64
+ FileInput,
65
+ MediaFileInput,
66
+ MediaListItem,
67
+ MediaCategoryNode,
68
+ MediaElementUpload,
69
+ SectionContentLinkInput,
70
+
71
+ // Media types
72
+ MediaTypeLayout,
73
+ MediaTypeData,
74
+
75
+ // Navigation
76
+ NavigationType,
77
+ NavigationSummary,
78
+
79
+ // Channels
80
+ ChannelSummary,
81
+ ChannelLanguage,
82
+ Microsite,
83
+
84
+ // Lists
85
+ ListSummary,
86
+ ListItemData,
87
+
88
+ // Groups
89
+ GroupData,
90
+ GroupMember,
91
+
92
+ // Users
93
+ UserData,
94
+ AuthMethods,
95
+ AuthMethodValue,
96
+
97
+ // Page layouts
98
+ PageLayoutSummary,
99
+
100
+ // Handlebars
101
+ HandlebarsItemSummary,
102
+ HelperSummary,
103
+ PartialSummary,
104
+ Helper,
105
+ Partial,
106
+ } from '@terminalfour/terminalfour-js';
107
+ ```
108
+
109
+ ## Module formats
110
+
111
+ The package supports `import` with ESM and `require` with CommonJS. TypeScript declaration files (`.d.ts`) are included for both output formats.
112
+
113
+ The shared `tsconfig.json` uses the ES2020 module mode so editors can check source files that use dynamic imports. `tsconfig.cjs.json` overrides that setting with CommonJS for the CJS build.
114
+
115
+ ## Build and test
116
+
117
+ ```bash
118
+ npm run build # writes dual ESM/CJS output to dist/
119
+ npm test # runs Vitest
120
+ ```
121
+
122
+ ---
123
+
124
+ **Previous:** [Error Handling](./error-handling.md)
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@terminalfour/terminalfour-js",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "JavaScript / TypeScript SDK for the Terminalfour Web Services REST API",
5
+ "keywords": [
6
+ "terminalfour",
7
+ "t4",
8
+ "cms",
9
+ "sdk",
10
+ "rest-api",
11
+ "content-management",
12
+ "typescript"
13
+ ],
14
+ "homepage": "https://github.com/TERMINALFOUR/terminalfour-js#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/TERMINALFOUR/terminalfour-js/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/TERMINALFOUR/terminalfour-js.git"
21
+ },
22
+ "author": "Terminalfour Solutions Limited",
23
+ "main": "dist/cjs/index.js",
24
+ "module": "dist/esm/index.js",
25
+ "types": "dist/esm/index.d.ts",
26
+ "type": "module",
27
+ "exports": {
28
+ ".": {
29
+ "import": {
30
+ "types": "./dist/esm/index.d.ts",
31
+ "default": "./dist/esm/index.js"
32
+ },
33
+ "require": {
34
+ "types": "./dist/cjs/index.d.ts",
35
+ "default": "./dist/cjs/index.js"
36
+ }
37
+ }
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "docs",
42
+ "README.md",
43
+ "LICENSE.md"
44
+ ],
45
+ "engines": {
46
+ "node": ">=18"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "scripts": {
52
+ "clean": "rm -rf dist",
53
+ "build": "npm run clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
54
+ "test": "vitest --run",
55
+ "prepublishOnly": "npm run test && npm run build"
56
+ },
57
+ "devDependencies": {
58
+ "@types/node": "^25.5.2",
59
+ "fast-check": "^4.1.1",
60
+ "typescript": "^5.7.0",
61
+ "vitest": "^3.2.1"
62
+ },
63
+ "license": "Elastic-2.0"
64
+ }