@terminalfour/terminalfour-js 1.0.0 → 1.0.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.
@@ -242,7 +242,13 @@ export declare class ContentTypeResource {
242
242
  /** Field names to remove from the content type */
243
243
  removeFields?: string[];
244
244
  }): Promise<ContentType>;
245
- /** Deletes a content type by ID. */
245
+ /**
246
+ * Deletes a content type by ID.
247
+ *
248
+ * System content types (`type === 30`) are managed by T4 and back core
249
+ * features; deleting one can break the instance, so this is blocked with a
250
+ * clear error. There is no override.
251
+ */
246
252
  delete(id: number): Promise<void>;
247
253
  /** Creates a new content type. */
248
254
  create(data: {
@@ -822,8 +822,23 @@ class ContentTypeResource {
822
822
  await ct.save();
823
823
  return ct;
824
824
  }
825
- /** Deletes a content type by ID. */
825
+ /**
826
+ * Deletes a content type by ID.
827
+ *
828
+ * System content types (`type === 30`) are managed by T4 and back core
829
+ * features; deleting one can break the instance, so this is blocked with a
830
+ * clear error. There is no override.
831
+ */
826
832
  async delete(id) {
833
+ const raw = await this.httpClient.request({
834
+ method: 'GET',
835
+ path: `/contenttype/${id}`,
836
+ });
837
+ if (raw.type === SYSTEM_CONTENT_TYPE) {
838
+ const name = (0, utils_js_1.decodeHtmlEntities)(raw.alias || raw.name);
839
+ throw new Error(`Cannot delete content type "${name}" (${id}) because it is a system content type. ` +
840
+ 'Deleting system content types is not allowed.');
841
+ }
827
842
  await this.httpClient.request({
828
843
  method: 'DELETE',
829
844
  path: `/contenttype/${id}`,
@@ -242,7 +242,13 @@ export declare class ContentTypeResource {
242
242
  /** Field names to remove from the content type */
243
243
  removeFields?: string[];
244
244
  }): Promise<ContentType>;
245
- /** Deletes a content type by ID. */
245
+ /**
246
+ * Deletes a content type by ID.
247
+ *
248
+ * System content types (`type === 30`) are managed by T4 and back core
249
+ * features; deleting one can break the instance, so this is blocked with a
250
+ * clear error. There is no override.
251
+ */
246
252
  delete(id: number): Promise<void>;
247
253
  /** Creates a new content type. */
248
254
  create(data: {
@@ -817,8 +817,23 @@ export class ContentTypeResource {
817
817
  await ct.save();
818
818
  return ct;
819
819
  }
820
- /** Deletes a content type by ID. */
820
+ /**
821
+ * Deletes a content type by ID.
822
+ *
823
+ * System content types (`type === 30`) are managed by T4 and back core
824
+ * features; deleting one can break the instance, so this is blocked with a
825
+ * clear error. There is no override.
826
+ */
821
827
  async delete(id) {
828
+ const raw = await this.httpClient.request({
829
+ method: 'GET',
830
+ path: `/contenttype/${id}`,
831
+ });
832
+ if (raw.type === SYSTEM_CONTENT_TYPE) {
833
+ const name = decodeHtmlEntities(raw.alias || raw.name);
834
+ throw new Error(`Cannot delete content type "${name}" (${id}) because it is a system content type. ` +
835
+ 'Deleting system content types is not allowed.');
836
+ }
822
837
  await this.httpClient.request({
823
838
  method: 'DELETE',
824
839
  path: `/contenttype/${id}`,
@@ -231,6 +231,8 @@ Delete a content type through the resource:
231
231
  await t4.contentTypes.delete(44);
232
232
  ```
233
233
 
234
+ System content types cannot be deleted — see [System content types](#system-content-types) below.
235
+
234
236
  ## System content types
235
237
 
236
238
  System content types are managed by T4 and back core features. Removing or renaming their elements can break the instance, so the SDK blocks both on `save()` (and through `update({ removeFields })`):
@@ -249,10 +251,22 @@ On a system content type you can still:
249
251
  - Change an element's `maxSize`
250
252
  - Change the content type's `description` and any element's `description`
251
253
 
252
- Two system content types are exempt, because removing and renaming their elements is safe: the **Section Metadata** content type and the **Extended User** content type. On those two, removal and renaming work exactly like a regular content type.
254
+ Two system content types are exempt from the element removal and renaming guard, because removing and renaming their elements is safe: the **Section Metadata** content type and the **Extended User** content type. On those two, removal and renaming work exactly like a regular content type.
253
255
 
254
256
  The check runs when you call `save()` or `update()`, not when you call `removeField()`. Because `removeField()` only stages the change in memory, nothing is sent to T4 when the guard blocks a save.
255
257
 
258
+ ### Deleting a system content type is always blocked
259
+
260
+ `delete()` refuses to delete **any** system content type, with no exceptions. Deleting a system content type outright (rather than editing its elements) can break instance-wide features, so there is no override:
261
+
262
+ ```typescript
263
+ await t4.contentTypes.delete(systemTypeId);
264
+ // Error: Cannot delete content type "..." (<id>) because it is a system
265
+ // content type. Deleting system content types is not allowed.
266
+ ```
267
+
268
+ `delete()` fetches the content type first to check its type; if it is a system content type, nothing is deleted.
269
+
256
270
  ## Manage content layouts
257
271
 
258
272
  Access layouts through `layouts` on a `ContentType`. Layout operations use names; layout IDs are not exposed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terminalfour/terminalfour-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "JavaScript / TypeScript SDK for the Terminalfour Web Services REST API",
5
5
  "keywords": [
6
6
  "terminalfour",
@@ -59,7 +59,7 @@
59
59
  "@types/node": "^25.5.2",
60
60
  "fast-check": "^4.1.1",
61
61
  "typescript": "^5.7.0",
62
- "vitest": "^3.2.1"
62
+ "vitest": "^5.0.0"
63
63
  },
64
64
  "license": "Elastic-2.0"
65
65
  }