@strapi/content-type-builder 5.45.1 → 5.46.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.
@@ -2,12 +2,20 @@
2
2
  /**
3
3
  * Translates and fades in from a specified direction.
4
4
  */
5
- export declare const AnimatedBox: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<Omit<import("@strapi/design-system").TransientBoxProps & {
5
+ export declare const AnimatedBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
6
6
  children?: import("react").ReactNode;
7
7
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
8
8
  ref?: any;
9
9
  }, "ref"> & {
10
10
  ref?: any;
11
- }, {
11
+ }, "$direction"> & {
12
12
  $direction?: "left" | "up" | undefined;
13
- }>> & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
13
+ }, never> & Partial<Pick<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
14
+ children?: import("react").ReactNode;
15
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
16
+ ref?: any;
17
+ }, "ref"> & {
18
+ ref?: any;
19
+ }, "$direction"> & {
20
+ $direction?: "left" | "up" | undefined;
21
+ }, never>>> & string & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
@@ -26,13 +26,19 @@ interface ContentProps extends React.ComponentPropsWithoutRef<typeof Box> {
26
26
  export declare const Input: {
27
27
  Root: ({ children, isLoading, ...props }: InputRootProps) => import("react/jsx-runtime").JSX.Element;
28
28
  Header: ({ children, ...props }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
29
- HeaderItem: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
29
+ HeaderItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
30
30
  children?: import("react").ReactNode;
31
31
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
32
32
  ref?: any;
33
33
  }, "ref"> & {
34
34
  ref?: any;
35
- }, never>> & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
35
+ }, never> & Partial<Pick<Omit<import("@strapi/design-system").TransientBoxProps & {
36
+ children?: import("react").ReactNode;
37
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
38
+ ref?: any;
39
+ }, "ref"> & {
40
+ ref?: any;
41
+ }, never>>> & string & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
36
42
  Attachments: ({ children, gap, ...props }: InputAttachmentsProps) => import("react/jsx-runtime").JSX.Element;
37
43
  Content: ({ children, disclaimer, error, ...props }: ContentProps) => import("react/jsx-runtime").JSX.Element;
38
44
  Actions: ({ children }: {
@@ -1,8 +1,14 @@
1
1
  /// <reference types="react" />
2
- export declare const OptionBoxWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
2
+ export declare const OptionBoxWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
3
3
  children?: import("react").ReactNode;
4
4
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
5
5
  ref?: any;
6
6
  }, "ref"> & {
7
7
  ref?: any;
8
- }, never>> & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
8
+ }, never> & Partial<Pick<Omit<import("@strapi/design-system").TransientBoxProps & {
9
+ children?: import("react").ReactNode;
10
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
11
+ ref?: any;
12
+ }, "ref"> & {
13
+ ref?: any;
14
+ }, never>>> & string & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
@@ -2,12 +2,17 @@
2
2
  import type { AnyAttribute, Component, ContentType } from '../types';
3
3
  import type { DraggableAttributes, DraggableSyntheticListeners } from '@dnd-kit/core';
4
4
  import type { UID } from '@strapi/types';
5
- export declare const GridWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
5
+ export declare const GridWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
6
6
  ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
7
- }, {
7
+ }, "$isOverlay" | "$isDragging"> & {
8
8
  $isOverlay?: boolean | undefined;
9
9
  $isDragging?: boolean | undefined;
10
- }>> & Omit<(<C extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: import("react").PropsWithoutRef<import("@strapi/design-system").FlexProps<C>> & import("react").RefAttributes<unknown>) => import("react").ReactNode), keyof import("react").Component<any, {}, any>>;
10
+ }, never> & Partial<Pick<import("styled-components").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
11
+ ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
12
+ }, "$isOverlay" | "$isDragging"> & {
13
+ $isOverlay?: boolean | undefined;
14
+ $isDragging?: boolean | undefined;
15
+ }, never>>> & string & Omit<(<C extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: import("react").PropsWithoutRef<import("@strapi/design-system").FlexProps<C>> & import("react").RefAttributes<unknown>) => import("react").ReactNode), keyof import("react").Component<any, {}, any>>;
11
16
  export type AttributeRowProps = {
12
17
  item: {
13
18
  id: string;
@@ -1,11 +1,20 @@
1
1
  /// <reference types="react" />
2
- export declare const ComponentRow: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<Omit<import("@strapi/design-system").TransientBoxProps & {
2
+ export declare const ComponentRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
3
3
  children?: import("react").ReactNode;
4
4
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
5
5
  ref?: any;
6
6
  }, "ref"> & {
7
7
  ref?: any;
8
- }, {
8
+ }, "$isFromDynamicZone" | "$isChildOfDynamicZone"> & {
9
9
  $isFromDynamicZone?: boolean | undefined;
10
10
  $isChildOfDynamicZone?: boolean | undefined;
11
- }>> & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
11
+ }, never> & Partial<Pick<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
12
+ children?: import("react").ReactNode;
13
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
14
+ ref?: any;
15
+ }, "ref"> & {
16
+ ref?: any;
17
+ }, "$isFromDynamicZone" | "$isChildOfDynamicZone"> & {
18
+ $isFromDynamicZone?: boolean | undefined;
19
+ $isChildOfDynamicZone?: boolean | undefined;
20
+ }, never>>> & string & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
- declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
2
+ declare const Wrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
3
3
  ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
4
- }, never>> & Omit<(<C extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: import("react").PropsWithoutRef<import("@strapi/design-system").FlexProps<C>> & import("react").RefAttributes<unknown>) => import("react").ReactNode), keyof import("react").Component<any, {}, any>>;
4
+ }, never> & Partial<Pick<Omit<Omit<import("@strapi/design-system").FlexProps<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>>, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
5
+ ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
6
+ }, never>>> & string & Omit<(<C extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "div">(props: import("react").PropsWithoutRef<import("@strapi/design-system").FlexProps<C>> & import("react").RefAttributes<unknown>) => import("react").ReactNode), keyof import("react").Component<any, {}, any>>;
5
7
  export { Wrapper };
@@ -1,13 +1,19 @@
1
1
  /// <reference types="react" />
2
2
  import type { Component, ContentType } from '../types';
3
3
  import type { UID } from '@strapi/types';
4
- export declare const ListGrid: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
4
+ export declare const ListGrid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
5
5
  children?: import("react").ReactNode;
6
6
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
7
7
  ref?: any;
8
8
  }, "ref"> & {
9
9
  ref?: any;
10
- }, never>> & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
10
+ }, never> & Partial<Pick<Omit<import("@strapi/design-system").TransientBoxProps & {
11
+ children?: import("react").ReactNode;
12
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
13
+ ref?: any;
14
+ }, "ref"> & {
15
+ ref?: any;
16
+ }, never>>> & string & Omit<import("@strapi/design-system").BoxComponent<"div">, keyof import("react").Component<any, {}, any>>;
11
17
  type ListProps = {
12
18
  addComponentToDZ?: () => void;
13
19
  firstLoopComponentUid?: UID.Component | null;
@@ -1,22 +1,38 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxComponent, FlexComponent } from '@strapi/design-system';
3
- declare const Wrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
3
+ declare const Wrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
4
4
  children?: import("react").ReactNode;
5
5
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
6
6
  ref?: any;
7
7
  }, "ref"> & {
8
8
  ref?: any;
9
- }, never>> & Omit<BoxComponent, keyof import("react").Component<any, {}, any>>;
10
- declare const IconWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").Substitute<Omit<import("@strapi/design-system").TransientBoxProps & {
9
+ }, never> & Partial<Pick<Omit<import("@strapi/design-system").TransientBoxProps & {
11
10
  children?: import("react").ReactNode;
12
11
  } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
13
12
  ref?: any;
14
13
  }, "ref"> & {
15
14
  ref?: any;
16
- }, {
15
+ }, never>>> & string & Omit<BoxComponent, keyof import("react").Component<any, {}, any>>;
16
+ declare const IconWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
17
+ children?: import("react").ReactNode;
18
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
19
+ ref?: any;
20
+ }, "ref"> & {
21
+ ref?: any;
22
+ }, "$isSelected"> & {
23
+ $isSelected: boolean;
24
+ }, never> & Partial<Pick<import("styled-components").FastOmit<Omit<import("@strapi/design-system").TransientBoxProps & {
25
+ children?: import("react").ReactNode;
26
+ } & import("@strapi/design-system/dist/types").AsProp<import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements>> & Omit<Omit<any, "ref">, "children" | keyof import("@strapi/design-system/dist/types").AsProp<C> | keyof import("@strapi/design-system").TransientBoxProps> & {
27
+ ref?: any;
28
+ }, "ref"> & {
29
+ ref?: any;
30
+ }, "$isSelected"> & {
17
31
  $isSelected: boolean;
18
- }>> & Omit<BoxComponent<"button">, keyof import("react").Component<any, {}, any>>;
19
- declare const InfosWrapper: import("styled-components").IStyledComponent<"web", import("styled-components/dist/types").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<"div">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
32
+ }, never>>> & string & Omit<BoxComponent<"button">, keyof import("react").Component<any, {}, any>>;
33
+ declare const InfosWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<Omit<import("@strapi/design-system").FlexProps<"div">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
34
+ ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
35
+ }, never> & Partial<Pick<Omit<Omit<import("@strapi/design-system").FlexProps<"div">, "ref"> & import("react").RefAttributes<unknown>, "ref"> & {
20
36
  ref?: ((instance: unknown) => void) | import("react").RefObject<unknown> | null | undefined;
21
- }, never>> & Omit<FlexComponent, keyof import("react").Component<any, {}, any>>;
37
+ }, never>>> & string & Omit<FlexComponent, keyof import("react").Component<any, {}, any>>;
22
38
  export { IconWrapper, InfosWrapper, Wrapper };
@@ -11,7 +11,7 @@ export declare const formatCondition: (condition: any, availableFields: Array<{
11
11
  }>, attributeName: string) => string;
12
12
  export declare const getAvailableConditionFields: (attributes: AnyAttribute[], currentFieldName: string) => {
13
13
  name: string;
14
- type: "string" | "boolean" | "time" | "media" | "text" | "date" | "email" | "password" | "decimal" | "component" | "relation" | "biginteger" | "blocks" | "datetime" | "dynamiczone" | "enumeration" | "float" | "integer" | "json" | "richtext" | "timestamp" | "uid";
14
+ type: "string" | "boolean" | "time" | "text" | "media" | "date" | "email" | "password" | "decimal" | "component" | "relation" | "biginteger" | "blocks" | "datetime" | "dynamiczone" | "enumeration" | "float" | "integer" | "json" | "richtext" | "timestamp" | "uid";
15
15
  enum: string[] | undefined;
16
16
  }[];
17
17
  export {};
@@ -5,6 +5,23 @@ var index = require('../utils/index.js');
5
5
  var contentType = require('./validation/content-type.js');
6
6
  var contentTypes$1 = require('../services/content-types.js');
7
7
 
8
+ /**
9
+ * Telemetry uses a bounded HTTP timeout (~1s in the metrics sender); cap how long we defer
10
+ * dev reload so a stuck client cannot block restart indefinitely.
11
+ */ const RELOAD_AFTER_TELEMETRY_MAX_MS = 2500;
12
+ const scheduleReloadAfterOutboundTelemetry = (sendPromise)=>{
13
+ setImmediate(()=>{
14
+ const settled = sendPromise.catch(()=>{});
15
+ Promise.race([
16
+ settled,
17
+ new Promise((resolve)=>{
18
+ setTimeout(resolve, RELOAD_AFTER_TELEMETRY_MAX_MS);
19
+ })
20
+ ]).catch(()=>{}).finally(()=>{
21
+ strapi.reload();
22
+ });
23
+ });
24
+ };
8
25
  var contentTypes = {
9
26
  async getContentTypes (ctx) {
10
27
  const { kind } = ctx.query;
@@ -60,12 +77,8 @@ var contentTypes = {
60
77
  kind: contentType.kind
61
78
  }
62
79
  };
63
- if (_.isEmpty(strapi.apis)) {
64
- await strapi.telemetry.send('didCreateFirstContentType', metricsPayload);
65
- } else {
66
- await strapi.telemetry.send('didCreateContentType', metricsPayload);
67
- }
68
- setImmediate(()=>strapi.reload());
80
+ const telemetryPromise = _.isEmpty(strapi.apis) ? strapi.telemetry.send('didCreateFirstContentType', metricsPayload) : strapi.telemetry.send('didCreateContentType', metricsPayload);
81
+ scheduleReloadAfterOutboundTelemetry(telemetryPromise);
69
82
  ctx.send({
70
83
  data: {
71
84
  uid: contentType.uid
@@ -73,11 +86,11 @@ var contentTypes = {
73
86
  }, 201);
74
87
  } catch (err) {
75
88
  strapi.log.error(err);
76
- await strapi.telemetry.send('didNotCreateContentType', {
89
+ strapi.telemetry.send('didNotCreateContentType', {
77
90
  eventProperties: {
78
91
  error: err.message || err
79
92
  }
80
- });
93
+ }).catch(()=>{});
81
94
  ctx.send({
82
95
  error: err.message || 'Unknown error'
83
96
  }, 400);
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.js","sources":["../../../server/src/controllers/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Context } from 'koa';\nimport type {} from 'koa-body';\nimport type { Internal } from '@strapi/types';\nimport { getService } from '../utils';\nimport {\n validateContentTypeInput,\n validateUpdateContentTypeInput,\n validateKind,\n} from './validation/content-type';\nimport { isContentTypeVisible } from '../services/content-types';\n\nexport default {\n async getContentTypes(ctx: Context) {\n const { kind } = ctx.query;\n\n try {\n await validateKind(kind);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n const contentTypeService = getService('content-types');\n\n const contentTypes = Object.keys(strapi.contentTypes)\n .filter(\n (uid) =>\n !kind ||\n _.get(strapi.contentTypes[uid as Internal.UID.ContentType], 'kind', 'collectionType') ===\n kind\n )\n .map((uid) =>\n contentTypeService.formatContentType(strapi.contentTypes[uid as Internal.UID.ContentType])\n );\n\n ctx.send({\n data: contentTypes,\n });\n },\n\n getContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n const contentType = strapi.contentTypes[uid];\n\n if (!contentType) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n if (!isContentTypeVisible(contentType)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n const contentTypeService = getService('content-types');\n\n ctx.send({ data: contentTypeService.formatContentType(contentType) });\n },\n\n async createContentType(ctx: Context) {\n const body = ctx.request.body as any;\n\n try {\n await validateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const contentType = await contentTypeService.createContentType({\n contentType: body.contentType,\n components: body.components,\n });\n\n const metricsPayload = {\n eventProperties: {\n kind: contentType.kind,\n },\n };\n\n if (_.isEmpty(strapi.apis)) {\n await strapi.telemetry.send('didCreateFirstContentType', metricsPayload);\n } else {\n await strapi.telemetry.send('didCreateContentType', metricsPayload);\n }\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: contentType.uid } }, 201);\n } catch (err) {\n strapi.log.error(err);\n await strapi.telemetry.send('didNotCreateContentType', {\n eventProperties: { error: (err as Error).message || err },\n });\n ctx.send({ error: (err as Error).message || 'Unknown error' }, 400);\n }\n },\n\n async updateContentType(ctx: Context) {\n const { uid } = ctx.params;\n const body = ctx.request.body as any;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n await validateUpdateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.editContentType(uid, {\n contentType: body.contentType,\n components: body.components,\n });\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } }, 201);\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n\n async deleteContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.deleteContentType(uid);\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } });\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n};\n"],"names":["getContentTypes","ctx","kind","query","validateKind","error","send","contentTypeService","getService","contentTypes","Object","keys","strapi","filter","uid","_","get","map","formatContentType","data","getContentType","params","contentType","isContentTypeVisible","createContentType","body","request","validateContentTypeInput","reload","isWatching","components","metricsPayload","eventProperties","isEmpty","apis","telemetry","setImmediate","err","log","message","updateContentType","has","validateUpdateContentTypeInput","component","editContentType","deleteContentType"],"mappings":";;;;;;;AAYA,mBAAe;AACb,IAAA,MAAMA,iBAAgBC,GAAY,EAAA;AAChC,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,IAAIE,KAAK;QAE1B,IAAI;AACF,YAAA,MAAMC,wBAAAA,CAAaF,IAAAA,CAAAA;AACrB,QAAA,CAAA,CAAE,OAAOG,KAAAA,EAAO;YACd,OAAOJ,GAAAA,CAAIK,IAAI,CAAC;AAAED,gBAAAA;aAAM,EAAG,GAAA,CAAA;AAC7B,QAAA;AAEA,QAAA,MAAME,qBAAqBC,gBAAAA,CAAW,eAAA,CAAA;AAEtC,QAAA,MAAMC,YAAAA,GAAeC,MAAAA,CAAOC,IAAI,CAACC,OAAOH,YAAY,CAAA,CACjDI,MAAM,CACL,CAACC,GAAAA,GACC,CAACZ,IAAAA,IACDa,CAAAA,CAAEC,GAAG,CAACJ,MAAAA,CAAOH,YAAY,CAACK,GAAAA,CAAgC,EAAE,MAAA,EAAQ,gBAAA,CAAA,KAClEZ,MAELe,GAAG,CAAC,CAACH,GAAAA,GACJP,mBAAmBW,iBAAiB,CAACN,MAAAA,CAAOH,YAAY,CAACK,GAAAA,CAAgC,CAAA,CAAA;AAG7Fb,QAAAA,GAAAA,CAAIK,IAAI,CAAC;YACPa,IAAAA,EAAMV;AACR,SAAA,CAAA;AACF,IAAA,CAAA;AAE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AG,EAAE,GAAGb,IAAIoB,MAAM;AAE1B,QAAA,IAAI,CAACN,CAAAA,CAAE0B,GAAG,CAAC7B,MAAAA,CAAOH,YAAY,EAAEK,GAAAA,CAAAA,EAAM;YACpC,OAAOb,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAO;aAAuB,EAAG,GAAA,CAAA;AACrD,QAAA;QAEA,IAAI;YACFO,MAAAA,CAAOgB,MAAM,CAACC,UAAU,GAAG,KAAA;AAE3B,YAAA,MAAMtB,qBAAqBC,gBAAAA,CAAW,eAAA,CAAA;AAEtC,YAAA,MAAMmC,SAAAA,GAAY,MAAMpC,kBAAAA,CAAmBsC,iBAAiB,CAAC/B,GAAAA,CAAAA;YAE7DsB,YAAAA,CAAa,IAAMxB,OAAOgB,MAAM,EAAA,CAAA;AAEhC3B,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAEa,IAAAA,EAAM;AAAEL,oBAAAA,GAAAA,EAAK6B,UAAU7B;AAAI;AAAE,aAAA,CAAA;AAC1C,QAAA,CAAA,CAAE,OAAOT,KAAAA,EAAO;YACdO,MAAAA,CAAO0B,GAAG,CAACjC,KAAK,CAACA,KAAAA,CAAAA;AACjBJ,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAQA,OAAiBkC,OAAAA,IAAW;aAAgB,EAAG,GAAA,CAAA;AACpE,QAAA;AACF,IAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"content-types.js","sources":["../../../server/src/controllers/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Context } from 'koa';\nimport type {} from 'koa-body';\nimport type { Internal } from '@strapi/types';\nimport { getService } from '../utils';\nimport {\n validateContentTypeInput,\n validateUpdateContentTypeInput,\n validateKind,\n} from './validation/content-type';\nimport { isContentTypeVisible } from '../services/content-types';\n\n/**\n * Telemetry uses a bounded HTTP timeout (~1s in the metrics sender); cap how long we defer\n * dev reload so a stuck client cannot block restart indefinitely.\n */\nconst RELOAD_AFTER_TELEMETRY_MAX_MS = 2500;\n\nconst scheduleReloadAfterOutboundTelemetry = (sendPromise: Promise<unknown>): void => {\n setImmediate(() => {\n const settled = sendPromise.catch(() => {});\n Promise.race([\n settled,\n new Promise<void>((resolve) => {\n setTimeout(resolve, RELOAD_AFTER_TELEMETRY_MAX_MS);\n }),\n ])\n .catch(() => {})\n .finally(() => {\n strapi.reload();\n });\n });\n};\n\nexport default {\n async getContentTypes(ctx: Context) {\n const { kind } = ctx.query;\n\n try {\n await validateKind(kind);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n const contentTypeService = getService('content-types');\n\n const contentTypes = Object.keys(strapi.contentTypes)\n .filter(\n (uid) =>\n !kind ||\n _.get(strapi.contentTypes[uid as Internal.UID.ContentType], 'kind', 'collectionType') ===\n kind\n )\n .map((uid) =>\n contentTypeService.formatContentType(strapi.contentTypes[uid as Internal.UID.ContentType])\n );\n\n ctx.send({\n data: contentTypes,\n });\n },\n\n getContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n const contentType = strapi.contentTypes[uid];\n\n if (!contentType) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n if (!isContentTypeVisible(contentType)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n const contentTypeService = getService('content-types');\n\n ctx.send({ data: contentTypeService.formatContentType(contentType) });\n },\n\n async createContentType(ctx: Context) {\n const body = ctx.request.body as any;\n\n try {\n await validateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const contentType = await contentTypeService.createContentType({\n contentType: body.contentType,\n components: body.components,\n });\n\n const metricsPayload = {\n eventProperties: {\n kind: contentType.kind,\n },\n };\n\n const telemetryPromise = _.isEmpty(strapi.apis)\n ? strapi.telemetry.send('didCreateFirstContentType', metricsPayload)\n : strapi.telemetry.send('didCreateContentType', metricsPayload);\n\n scheduleReloadAfterOutboundTelemetry(telemetryPromise);\n\n ctx.send({ data: { uid: contentType.uid } }, 201);\n } catch (err) {\n strapi.log.error(err);\n strapi.telemetry\n .send('didNotCreateContentType', {\n eventProperties: { error: (err as Error).message || err },\n })\n .catch(() => {});\n ctx.send({ error: (err as Error).message || 'Unknown error' }, 400);\n }\n },\n\n async updateContentType(ctx: Context) {\n const { uid } = ctx.params;\n const body = ctx.request.body as any;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n await validateUpdateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.editContentType(uid, {\n contentType: body.contentType,\n components: body.components,\n });\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } }, 201);\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n\n async deleteContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.deleteContentType(uid);\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } });\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n};\n"],"names":["RELOAD_AFTER_TELEMETRY_MAX_MS","scheduleReloadAfterOutboundTelemetry","sendPromise","setImmediate","settled","catch","Promise","race","resolve","setTimeout","finally","strapi","reload","getContentTypes","ctx","kind","query","validateKind","error","send","contentTypeService","getService","contentTypes","Object","keys","filter","uid","_","get","map","formatContentType","data","getContentType","params","contentType","isContentTypeVisible","createContentType","body","request","validateContentTypeInput","isWatching","components","metricsPayload","eventProperties","telemetryPromise","isEmpty","apis","telemetry","err","log","message","updateContentType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CAAC;gBAAED,KAAAA,EAAQA,OAAiBgC,OAAAA,IAAW;aAAgB,EAAG,GAAA,CAAA;AACpE,QAAA;AACF,IAAA,CAAA;AAEA,IAAA,MAAMM,mBAAkB1C,GAAY,EAAA;AAClC,QAAA,MAAM,EAAEY,GAAG,EAAE,GAAGZ,IAAImB,MAAM;AAE1B,QAAA,IAAI,CAACN,CAAAA,CAAEyB,GAAG,CAACzC,MAAAA,CAAOW,YAAY,EAAEI,GAAAA,CAAAA,EAAM;YACpC,OAAOZ,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAO;aAAuB,EAAG,GAAA,CAAA;AACrD,QAAA;QAEA,IAAI;YACFP,MAAAA,CAAOC,MAAM,CAAC4B,UAAU,GAAG,KAAA;AAE3B,YAAA,MAAMpB,qBAAqBC,gBAAAA,CAAW,eAAA,CAAA;AAEtC,YAAA,MAAMiC,SAAAA,GAAY,MAAMlC,kBAAAA,CAAmBoC,iBAAiB,CAAC9B,GAAAA,CAAAA;YAE7DvB,YAAAA,CAAa,IAAMQ,OAAOC,MAAM,EAAA,CAAA;AAEhCE,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAEY,IAAAA,EAAM;AAAEL,oBAAAA,GAAAA,EAAK4B,UAAU5B;AAAI;AAAE,aAAA,CAAA;AAC1C,QAAA,CAAA,CAAE,OAAOR,KAAAA,EAAO;YACdP,MAAAA,CAAOsC,GAAG,CAAC/B,KAAK,CAACA,KAAAA,CAAAA;AACjBJ,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAQA,OAAiBgC,OAAAA,IAAW;aAAgB,EAAG,GAAA,CAAA;AACpE,QAAA;AACF,IAAA;AACF,CAAA;;;;"}
@@ -3,6 +3,23 @@ import { getService } from '../utils/index.mjs';
3
3
  import { validateUpdateContentTypeInput, validateContentTypeInput, validateKind } from './validation/content-type.mjs';
4
4
  import { isContentTypeVisible } from '../services/content-types.mjs';
5
5
 
6
+ /**
7
+ * Telemetry uses a bounded HTTP timeout (~1s in the metrics sender); cap how long we defer
8
+ * dev reload so a stuck client cannot block restart indefinitely.
9
+ */ const RELOAD_AFTER_TELEMETRY_MAX_MS = 2500;
10
+ const scheduleReloadAfterOutboundTelemetry = (sendPromise)=>{
11
+ setImmediate(()=>{
12
+ const settled = sendPromise.catch(()=>{});
13
+ Promise.race([
14
+ settled,
15
+ new Promise((resolve)=>{
16
+ setTimeout(resolve, RELOAD_AFTER_TELEMETRY_MAX_MS);
17
+ })
18
+ ]).catch(()=>{}).finally(()=>{
19
+ strapi.reload();
20
+ });
21
+ });
22
+ };
6
23
  var contentTypes = {
7
24
  async getContentTypes (ctx) {
8
25
  const { kind } = ctx.query;
@@ -58,12 +75,8 @@ var contentTypes = {
58
75
  kind: contentType.kind
59
76
  }
60
77
  };
61
- if (_.isEmpty(strapi.apis)) {
62
- await strapi.telemetry.send('didCreateFirstContentType', metricsPayload);
63
- } else {
64
- await strapi.telemetry.send('didCreateContentType', metricsPayload);
65
- }
66
- setImmediate(()=>strapi.reload());
78
+ const telemetryPromise = _.isEmpty(strapi.apis) ? strapi.telemetry.send('didCreateFirstContentType', metricsPayload) : strapi.telemetry.send('didCreateContentType', metricsPayload);
79
+ scheduleReloadAfterOutboundTelemetry(telemetryPromise);
67
80
  ctx.send({
68
81
  data: {
69
82
  uid: contentType.uid
@@ -71,11 +84,11 @@ var contentTypes = {
71
84
  }, 201);
72
85
  } catch (err) {
73
86
  strapi.log.error(err);
74
- await strapi.telemetry.send('didNotCreateContentType', {
87
+ strapi.telemetry.send('didNotCreateContentType', {
75
88
  eventProperties: {
76
89
  error: err.message || err
77
90
  }
78
- });
91
+ }).catch(()=>{});
79
92
  ctx.send({
80
93
  error: err.message || 'Unknown error'
81
94
  }, 400);
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.mjs","sources":["../../../server/src/controllers/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Context } from 'koa';\nimport type {} from 'koa-body';\nimport type { Internal } from '@strapi/types';\nimport { getService } from '../utils';\nimport {\n validateContentTypeInput,\n validateUpdateContentTypeInput,\n validateKind,\n} from './validation/content-type';\nimport { isContentTypeVisible } from '../services/content-types';\n\nexport default {\n async getContentTypes(ctx: Context) {\n const { kind } = ctx.query;\n\n try {\n await validateKind(kind);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n const contentTypeService = getService('content-types');\n\n const contentTypes = Object.keys(strapi.contentTypes)\n .filter(\n (uid) =>\n !kind ||\n _.get(strapi.contentTypes[uid as Internal.UID.ContentType], 'kind', 'collectionType') ===\n kind\n )\n .map((uid) =>\n contentTypeService.formatContentType(strapi.contentTypes[uid as Internal.UID.ContentType])\n );\n\n ctx.send({\n data: contentTypes,\n });\n },\n\n getContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n const contentType = strapi.contentTypes[uid];\n\n if (!contentType) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n if (!isContentTypeVisible(contentType)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n const contentTypeService = getService('content-types');\n\n ctx.send({ data: contentTypeService.formatContentType(contentType) });\n },\n\n async createContentType(ctx: Context) {\n const body = ctx.request.body as any;\n\n try {\n await validateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const contentType = await contentTypeService.createContentType({\n contentType: body.contentType,\n components: body.components,\n });\n\n const metricsPayload = {\n eventProperties: {\n kind: contentType.kind,\n },\n };\n\n if (_.isEmpty(strapi.apis)) {\n await strapi.telemetry.send('didCreateFirstContentType', metricsPayload);\n } else {\n await strapi.telemetry.send('didCreateContentType', metricsPayload);\n }\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: contentType.uid } }, 201);\n } catch (err) {\n strapi.log.error(err);\n await strapi.telemetry.send('didNotCreateContentType', {\n eventProperties: { error: (err as Error).message || err },\n });\n ctx.send({ error: (err as Error).message || 'Unknown error' }, 400);\n }\n },\n\n async updateContentType(ctx: Context) {\n const { uid } = ctx.params;\n const body = ctx.request.body as any;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n await validateUpdateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.editContentType(uid, {\n contentType: body.contentType,\n components: body.components,\n });\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } }, 201);\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n\n async deleteContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.deleteContentType(uid);\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } });\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n};\n"],"names":["getContentTypes","ctx","kind","query","validateKind","error","send","contentTypeService","getService","contentTypes","Object","keys","strapi","filter","uid","_","get","map","formatContentType","data","getContentType","params","contentType","isContentTypeVisible","createContentType","body","request","validateContentTypeInput","reload","isWatching","components","metricsPayload","eventProperties","isEmpty","apis","telemetry","setImmediate","err","log","message","updateContentType","has","validateUpdateContentTypeInput","component","editContentType","deleteContentType"],"mappings":";;;;;AAYA,mBAAe;AACb,IAAA,MAAMA,iBAAgBC,GAAY,EAAA;AAChC,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,IAAIE,KAAK;QAE1B,IAAI;AACF,YAAA,MAAMC,YAAAA,CAAaF,IAAAA,CAAAA;AACrB,QAAA,CAAA,CAAE,OAAOG,KAAAA,EAAO;YACd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AC1C,QAAA,CAAA,CAAE,OAAOT,KAAAA,EAAO;YACdO,MAAAA,CAAO0B,GAAG,CAACjC,KAAK,CAACA,KAAAA,CAAAA;AACjBJ,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAQA,OAAiBkC,OAAAA,IAAW;aAAgB,EAAG,GAAA,CAAA;AACpE,QAAA;AACF,IAAA;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"content-types.mjs","sources":["../../../server/src/controllers/content-types.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Context } from 'koa';\nimport type {} from 'koa-body';\nimport type { Internal } from '@strapi/types';\nimport { getService } from '../utils';\nimport {\n validateContentTypeInput,\n validateUpdateContentTypeInput,\n validateKind,\n} from './validation/content-type';\nimport { isContentTypeVisible } from '../services/content-types';\n\n/**\n * Telemetry uses a bounded HTTP timeout (~1s in the metrics sender); cap how long we defer\n * dev reload so a stuck client cannot block restart indefinitely.\n */\nconst RELOAD_AFTER_TELEMETRY_MAX_MS = 2500;\n\nconst scheduleReloadAfterOutboundTelemetry = (sendPromise: Promise<unknown>): void => {\n setImmediate(() => {\n const settled = sendPromise.catch(() => {});\n Promise.race([\n settled,\n new Promise<void>((resolve) => {\n setTimeout(resolve, RELOAD_AFTER_TELEMETRY_MAX_MS);\n }),\n ])\n .catch(() => {})\n .finally(() => {\n strapi.reload();\n });\n });\n};\n\nexport default {\n async getContentTypes(ctx: Context) {\n const { kind } = ctx.query;\n\n try {\n await validateKind(kind);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n const contentTypeService = getService('content-types');\n\n const contentTypes = Object.keys(strapi.contentTypes)\n .filter(\n (uid) =>\n !kind ||\n _.get(strapi.contentTypes[uid as Internal.UID.ContentType], 'kind', 'collectionType') ===\n kind\n )\n .map((uid) =>\n contentTypeService.formatContentType(strapi.contentTypes[uid as Internal.UID.ContentType])\n );\n\n ctx.send({\n data: contentTypes,\n });\n },\n\n getContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n const contentType = strapi.contentTypes[uid];\n\n if (!contentType) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n if (!isContentTypeVisible(contentType)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n const contentTypeService = getService('content-types');\n\n ctx.send({ data: contentTypeService.formatContentType(contentType) });\n },\n\n async createContentType(ctx: Context) {\n const body = ctx.request.body as any;\n\n try {\n await validateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const contentType = await contentTypeService.createContentType({\n contentType: body.contentType,\n components: body.components,\n });\n\n const metricsPayload = {\n eventProperties: {\n kind: contentType.kind,\n },\n };\n\n const telemetryPromise = _.isEmpty(strapi.apis)\n ? strapi.telemetry.send('didCreateFirstContentType', metricsPayload)\n : strapi.telemetry.send('didCreateContentType', metricsPayload);\n\n scheduleReloadAfterOutboundTelemetry(telemetryPromise);\n\n ctx.send({ data: { uid: contentType.uid } }, 201);\n } catch (err) {\n strapi.log.error(err);\n strapi.telemetry\n .send('didNotCreateContentType', {\n eventProperties: { error: (err as Error).message || err },\n })\n .catch(() => {});\n ctx.send({ error: (err as Error).message || 'Unknown error' }, 400);\n }\n },\n\n async updateContentType(ctx: Context) {\n const { uid } = ctx.params;\n const body = ctx.request.body as any;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n await validateUpdateContentTypeInput(body);\n } catch (error) {\n return ctx.send({ error }, 400);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.editContentType(uid, {\n contentType: body.contentType,\n components: body.components,\n });\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } }, 201);\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n\n async deleteContentType(ctx: Context) {\n const { uid } = ctx.params;\n\n if (!_.has(strapi.contentTypes, uid)) {\n return ctx.send({ error: 'contentType.notFound' }, 404);\n }\n\n try {\n strapi.reload.isWatching = false;\n\n const contentTypeService = getService('content-types');\n\n const component = await contentTypeService.deleteContentType(uid);\n\n setImmediate(() => strapi.reload());\n\n ctx.send({ data: { uid: component.uid } });\n } catch (error) {\n strapi.log.error(error);\n ctx.send({ error: (error as Error)?.message || 'Unknown error' }, 400);\n }\n },\n};\n"],"names":["RELOAD_AFTER_TELEMETRY_MAX_MS","scheduleReloadAfterOutboundTelemetry","sendPromise","setImmediate","settled","catch","Promise","race","resolve","setTimeout","finally","strapi","reload","getContentTypes","ctx","kind","query","validateKind","error","send","contentTypeService","getService","contentTypes","Object","keys","filter","uid","_","get","map","formatContentType","data","getContentType","params","contentType","isContentTypeVisible","createContentType","body","request","validateContentTypeInput","isWatching","components","metricsPayload","eventProperties","telemetryPromise","isEmpty","apis","telemetry","err","log","message","updateContentType","has","validateUpdateContentTypeInput","component","editContentType","deleteContentType"],"mappings":";;;;;AAYA;;;AAGC,IACD,MAAMA,6BAAAA,GAAgC,IAAA;AAEtC,MAAMC,uCAAuC,CAACC,WAAAA,GAAAA;IAC5CC,YAAAA,CAAa,IAAA;AACX,QAAA,MAAMC,OAAAA,GAAUF,WAAAA,CAAYG,KAAK,CAAC,IAAA,CAAO,CAAA,CAAA;AACzCC,QAAAA,OAAAA,CAAQC,IAAI,CAAC;AACXH,YAAAA,OAAAA;AACA,YAAA,IAAIE,QAAc,CAACE,OAAAA,GAAAA;AACjBC,gBAAAA,UAAAA,CAAWD,OAAAA,EAASR,6BAAAA,CAAAA;AACtB,YAAA,CAAA;AACD,SAAA,CAAA,CACEK,KAAK,CAAC,IAAA,CAAO,CAAA,CAAA,CACbK,OAAO,CAAC,IAAA;AACPC,YAAAA,MAAAA,CAAOC,MAAM,EAAA;AACf,QAAA,CAAA,CAAA;AACJ,IAAA,CAAA,CAAA;AACF,CAAA;AAEA,mBAAe;AAC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Aa,IAAMQ,OAAOC,MAAM,EAAA,CAAA;AAEhCE,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAEY,IAAAA,EAAM;AAAEL,oBAAAA,GAAAA,EAAK4B,UAAU5B;AAAI;AAAE,aAAA,CAAA;AAC1C,QAAA,CAAA,CAAE,OAAOR,KAAAA,EAAO;YACdP,MAAAA,CAAOsC,GAAG,CAAC/B,KAAK,CAACA,KAAAA,CAAAA;AACjBJ,YAAAA,GAAAA,CAAIK,IAAI,CAAC;gBAAED,KAAAA,EAAQA,OAAiBgC,OAAAA,IAAW;aAAgB,EAAG,GAAA,CAAA;AACpE,QAAA;AACF,IAAA;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/content-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;yBAYN,OAAO;wBA2Bd,OAAO;2BAkBE,OAAO;2BA2CP,OAAO;2BAiCP,OAAO;;AA1HtC,wBAgJE"}
1
+ {"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../../server/src/controllers/content-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;;yBAkCN,OAAO;wBA2Bd,OAAO;2BAkBE,OAAO;2BA2CP,OAAO;2BAiCP,OAAO;;AA1HtC,wBAgJE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/content-type-builder",
3
- "version": "5.45.1",
3
+ "version": "5.46.1",
4
4
  "description": "Create and manage content types",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -73,9 +73,9 @@
73
73
  "@reduxjs/toolkit": "1.9.7",
74
74
  "@sindresorhus/slugify": "1.1.0",
75
75
  "@strapi/design-system": "2.2.0",
76
- "@strapi/generators": "5.45.1",
76
+ "@strapi/generators": "5.46.1",
77
77
  "@strapi/icons": "2.2.0",
78
- "@strapi/utils": "5.45.1",
78
+ "@strapi/utils": "5.46.1",
79
79
  "ai": "5.0.52",
80
80
  "date-fns": "2.30.0",
81
81
  "fs-extra": "11.3.4",
@@ -93,8 +93,8 @@
93
93
  "zod": "3.25.67"
94
94
  },
95
95
  "devDependencies": {
96
- "@strapi/admin": "5.45.1",
97
- "@strapi/types": "5.45.1",
96
+ "@strapi/admin": "5.46.1",
97
+ "@strapi/types": "5.46.1",
98
98
  "@testing-library/dom": "10.4.1",
99
99
  "@testing-library/react": "16.3.0",
100
100
  "@testing-library/user-event": "14.6.1",
@@ -107,7 +107,7 @@
107
107
  "react-dom": "18.3.1",
108
108
  "react-query": "3.39.3",
109
109
  "react-router-dom": "6.30.3",
110
- "styled-components": "6.1.8"
110
+ "styled-components": "6.4.1"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "@strapi/admin": "^5.0.0",