contentful-management 12.6.0-dev.2 → 12.6.0-dev.3

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.
@@ -15,7 +15,7 @@ const create = (http, params, rawData, headers) => {
15
15
  const data = copy(rawData);
16
16
  return post(http, getBaseUrl(params), data, { headers });
17
17
  };
18
- const update = (http, params, rawData, headers) => {
18
+ const upsert = (http, params, rawData, headers) => {
19
19
  const { sys, ...body } = copy(rawData);
20
20
  return put(http, getBaseUrl(params) + `/${params.fragmentId}`, body, {
21
21
  headers: {
@@ -46,5 +46,5 @@ const unpublish = (http, params, headers) => {
46
46
  });
47
47
  };
48
48
 
49
- export { create, del, get, getMany, publish, unpublish, update };
49
+ export { create, del, get, getMany, publish, unpublish, upsert };
50
50
  //# sourceMappingURL=fragment.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"common-types.mjs","sources":["../../lib/common-types.ts"],"sourcesContent":[null],"names":[],"mappings":"AA80GA;IACY;AAAZ,CAAA,UAAY,+BAA+B,EAAA;AACzC,IAAA,+BAAA,CAAA,4BAAA,CAAA,GAAA,uDAAoF;AACtF,CAAC,EAFW,+BAA+B,KAA/B,+BAA+B,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"common-types.mjs","sources":["../../lib/common-types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAi1GA;IACY;AAAZ,CAAA,UAAY,+BAA+B,EAAA;AACzC,IAAA,+BAAA,CAAA,4BAAA,CAAA,GAAA,uDAAoF;AACtF,CAAC,EAFW,+BAA+B,KAA/B,+BAA+B,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -602,7 +602,7 @@ const createPlainClient = (makeRequest, defaults) => {
602
602
  getMany: wrap(wrapParams, 'Fragment', 'getMany'),
603
603
  get: wrap(wrapParams, 'Fragment', 'get'),
604
604
  create: wrap(wrapParams, 'Fragment', 'create'),
605
- update: wrap(wrapParams, 'Fragment', 'update'),
605
+ upsert: wrap(wrapParams, 'Fragment', 'upsert'),
606
606
  delete: wrap(wrapParams, 'Fragment', 'delete'),
607
607
  publish: wrap(wrapParams, 'Fragment', 'publish'),
608
608
  unpublish: wrap(wrapParams, 'Fragment', 'unpublish'),
@@ -2,7 +2,7 @@ import type { RestEndpoint } from '../types';
2
2
  export declare const getMany: RestEndpoint<'Fragment', 'getMany'>;
3
3
  export declare const get: RestEndpoint<'Fragment', 'get'>;
4
4
  export declare const create: RestEndpoint<'Fragment', 'create'>;
5
- export declare const update: RestEndpoint<'Fragment', 'update'>;
5
+ export declare const upsert: RestEndpoint<'Fragment', 'upsert'>;
6
6
  export declare const del: RestEndpoint<'Fragment', 'delete'>;
7
7
  export declare const publish: RestEndpoint<'Fragment', 'publish'>;
8
8
  export declare const unpublish: RestEndpoint<'Fragment', 'unpublish'>;
@@ -15,7 +15,7 @@ const create = (http, params, rawData, headers) => {
15
15
  const data = copy(rawData);
16
16
  return post(http, getBaseUrl(params), data, { headers });
17
17
  };
18
- const update = (http, params, rawData, headers) => {
18
+ const upsert = (http, params, rawData, headers) => {
19
19
  const { sys, ...body } = copy(rawData);
20
20
  return put(http, getBaseUrl(params) + `/${params.fragmentId}`, body, {
21
21
  headers: {
@@ -46,5 +46,5 @@ const unpublish = (http, params, headers) => {
46
46
  });
47
47
  };
48
48
 
49
- export { create, del, get, getMany, publish, unpublish, update };
49
+ export { create, del, get, getMany, publish, unpublish, upsert };
50
50
  //# sourceMappingURL=fragment.js.map
@@ -17,7 +17,7 @@ import type { AvailableLicenseProps } from './entities/available-license';
17
17
  import type { BulkActionProps, BulkActionPublishPayload, BulkActionUnpublishPayload, BulkActionV2Payload, BulkActionValidatePayload, PublishBulkActionV2Payload, UnpublishBulkActionV2Payload, ValidateBulkActionV2Payload } from './entities/bulk-action';
18
18
  import type { CommentProps, CreateCommentParams, CreateCommentProps, DeleteCommentParams, GetCommentParentEntityParams, GetManyCommentsParams, PlainTextBodyFormat, RichTextBodyFormat, RichTextCommentBodyPayload, RichTextCommentProps, UpdateCommentParams, UpdateCommentProps } from './entities/comment';
19
19
  import type { ComponentTypeProps, ComponentTypeQueryOptions, CreateComponentTypeProps, UpsertComponentTypeProps } from './entities/component-type';
20
- import type { CreateFragmentProps, FragmentProps, FragmentQueryOptions, UpdateFragmentProps } from './entities/fragment';
20
+ import type { CreateFragmentProps, FragmentProps, FragmentQueryOptions, UpsertFragmentProps } from './entities/fragment';
21
21
  import type { CreateTemplateProps, TemplateProps, TemplateQueryOptions, UpsertTemplateProps } from './entities/template';
22
22
  import type { CreateExperienceProps, UpsertExperienceProps, ExperienceLocalePublishPayload, ExperienceProps, ExperienceQueryOptions } from './entities/experience';
23
23
  import type { ContentTypeProps, CreateContentTypeProps } from './entities/content-type';
@@ -142,7 +142,19 @@ export type DiscriminatedUnionDataTypeDefinition = BaseDataTypeDefinition & {
142
142
  };
143
143
  export type DataTypeDefinition = PrimitiveDataTypeDefinition | RichTextDataTypeDefinition | ArrayDataTypeDefinition | RecordDataTypeDefinition | TypeRefDataTypeDefinition | LiteralDataTypeDefinition | DiscriminatedUnionDataTypeDefinition;
144
144
  export type PointerExpressionValue = string | {
145
+ $from: string | {
146
+ source: string;
147
+ select?: PointerExpressionValue;
148
+ };
149
+ } | {
145
150
  $literal: JsonValue;
151
+ } | {
152
+ $object: Record<string, PointerExpressionValue>;
153
+ } | {
154
+ $on: {
155
+ type: Record<string, PointerExpressionValue>;
156
+ default?: PointerExpressionValue;
157
+ };
146
158
  } | {
147
159
  [key: string]: PointerExpressionValue;
148
160
  };
@@ -712,7 +724,7 @@ type MRInternal<UA extends boolean> = {
712
724
  (opts: MROpts<'Fragment', 'getMany', UA>): MRReturn<'Fragment', 'getMany'>;
713
725
  (opts: MROpts<'Fragment', 'get', UA>): MRReturn<'Fragment', 'get'>;
714
726
  (opts: MROpts<'Fragment', 'create', UA>): MRReturn<'Fragment', 'create'>;
715
- (opts: MROpts<'Fragment', 'update', UA>): MRReturn<'Fragment', 'update'>;
727
+ (opts: MROpts<'Fragment', 'upsert', UA>): MRReturn<'Fragment', 'upsert'>;
716
728
  (opts: MROpts<'Fragment', 'delete', UA>): MRReturn<'Fragment', 'delete'>;
717
729
  (opts: MROpts<'Fragment', 'publish', UA>): MRReturn<'Fragment', 'publish'>;
718
730
  (opts: MROpts<'Fragment', 'unpublish', UA>): MRReturn<'Fragment', 'unpublish'>;
@@ -2944,9 +2956,9 @@ export type MRActions = {
2944
2956
  payload: CreateFragmentProps;
2945
2957
  return: FragmentProps;
2946
2958
  };
2947
- update: {
2959
+ upsert: {
2948
2960
  params: GetFragmentParams;
2949
- payload: UpdateFragmentProps;
2961
+ payload: UpsertFragmentProps;
2950
2962
  return: FragmentProps;
2951
2963
  };
2952
2964
  delete: {
@@ -1 +1 @@
1
- {"version":3,"file":"common-types.js","sources":["../../lib/common-types.ts"],"sourcesContent":[null],"names":[],"mappings":"AA80GA;IACY;AAAZ,CAAA,UAAY,+BAA+B,EAAA;AACzC,IAAA,+BAAA,CAAA,4BAAA,CAAA,GAAA,uDAAoF;AACtF,CAAC,EAFW,+BAA+B,KAA/B,+BAA+B,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"common-types.js","sources":["../../lib/common-types.ts"],"sourcesContent":[null],"names":[],"mappings":"AAi1GA;IACY;AAAZ,CAAA,UAAY,+BAA+B,EAAA;AACzC,IAAA,+BAAA,CAAA,4BAAA,CAAA,GAAA,uDAAoF;AACtF,CAAC,EAFW,+BAA+B,KAA/B,+BAA+B,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -52,9 +52,6 @@ export type TokenBackedDesignProperty = DesignPropertyCommonFields & {
52
52
  allowedResources?: DesignTokenAllowedResource[];
53
53
  };
54
54
  export type ComponentTypeDesignProperty = StringDesignProperty | BooleanDesignProperty | TokenBackedDesignProperty;
55
- export type ComponentTypeDimensionKeyMap = {
56
- designProperties: Record<string, Record<string, string>>;
57
- };
58
55
  export type ContentPropertyPointerValue = `$contentProperties/${string}`;
59
56
  export type DesignPropertyPointerValue = `$designProperties/${string}`;
60
57
  export type ManualDesignValue = {
@@ -91,6 +88,7 @@ export type SlotNode = {
91
88
  };
92
89
  export type TreeNode = ComponentNode | FragmentNode | SlotNode;
93
90
  export type DataAssemblyLink = ResourceLink<'Contentful:DataAssembly'>;
91
+ export declare const COMPONENT_TYPE_ALLOWED_RESOURCE_SOURCE: "crn:contentful:::experience:spaces/$self/environments/$self";
94
92
  export type ComponentTypeSlotDefinition = {
95
93
  id: string;
96
94
  name: string;
@@ -103,7 +101,7 @@ export type ComponentTypeSlotDefinition = {
103
101
  }>;
104
102
  allowedResources?: Array<{
105
103
  type: 'Contentful:ComponentType';
106
- source: string;
104
+ source: typeof COMPONENT_TYPE_ALLOWED_RESOURCE_SOURCE;
107
105
  allowedTypes: string[];
108
106
  }>;
109
107
  };
@@ -134,7 +132,6 @@ export type ComponentTypeProps = {
134
132
  viewports: ComponentTypeViewport[];
135
133
  contentProperties: ComponentTypeContentProperty[];
136
134
  designProperties: ComponentTypeDesignProperty[];
137
- dimensionKeyMap: ComponentTypeDimensionKeyMap;
138
135
  componentTree?: TreeNode[];
139
136
  slots?: ComponentTypeSlotDefinition[];
140
137
  metadata?: ExoMetadataProps;
@@ -1,28 +1,30 @@
1
1
  import type { CursorPaginationParams, DataTypeDefinition, ExoCursorPaginatedCollectionProp, Link, MetadataProps, PointerExpressionValue, ResourceLink } from '../common-types';
2
- export type DataAssemblyDataTypeField = DataTypeDefinition & {
2
+ export declare const SAME_SPACE_CONTENT_SOURCE: "crn:contentful:::content:spaces/$self/environments/$self";
3
+ export type CanonicalDataAssemblyDataTypeField = DataTypeDefinition & {
3
4
  id: string;
4
5
  name: string;
5
- source?: string;
6
6
  };
7
- export type DataAssemblyLinkParameter = {
8
- name?: string;
9
- description?: string;
10
- type: 'Link';
11
- linkType: string;
12
- allowedContentTypes: string[];
7
+ export type LegacyDataAssemblyDataTypeField = {
8
+ id: string;
9
+ name: string;
10
+ type: string;
11
+ required?: boolean;
12
+ source?: string;
13
+ ref?: unknown;
13
14
  };
15
+ export type DataAssemblyDataTypeField = CanonicalDataAssemblyDataTypeField | LegacyDataAssemblyDataTypeField;
14
16
  export type DataAssemblyResourceLinkParameter = {
15
17
  name?: string;
16
18
  description?: string;
17
19
  type: 'ResourceLink';
18
- linkType: string;
20
+ linkType: 'Contentful:Entry';
19
21
  allowedResources: Array<{
20
- type: string;
21
- source: string;
22
+ type: 'Contentful:Entry';
23
+ source: typeof SAME_SPACE_CONTENT_SOURCE;
22
24
  allowedTypes: string[];
23
25
  }>;
24
26
  };
25
- export type DataAssemblyParameterConfig = Record<string, DataAssemblyLinkParameter | DataAssemblyResourceLinkParameter>;
27
+ export type DataAssemblyParameterConfig = Record<string, DataAssemblyResourceLinkParameter>;
26
28
  export type DataAssemblyGraphQLResolver = {
27
29
  source: 'Contentful:GraphQL';
28
30
  query: string;
@@ -35,7 +37,7 @@ export type DataAssemblyNestedResolver = {
35
37
  };
36
38
  export type DataAssemblyResolverDefinition = DataAssemblyGraphQLResolver | DataAssemblyNestedResolver;
37
39
  export type DataAssemblyResolverConfig = Record<string, DataAssemblyResolverDefinition>;
38
- export type DataAssemblyReturnMappingConfig = Record<string, PointerExpressionValue>;
40
+ export type DataAssemblyReturnMappingConfig = PointerExpressionValue;
39
41
  export type DataAssemblySys = {
40
42
  id: string;
41
43
  type: 'DataAssembly';
@@ -1,10 +1,5 @@
1
1
  import type { CursorPaginationParams, ExoCursorPaginatedCollectionProp, ExperienceMetadataProps, ExoQueryFilters, Link, ResourceLink } from '../common-types';
2
2
  import type { ComponentTypeViewport, DimensionedDesignPropertyValue, FragmentNode } from './component-type';
3
- export type ExperienceDimensionKeyMap = {
4
- designProperties: Record<string, {
5
- breakpoint: string;
6
- }>;
7
- };
8
3
  export type ExperienceContentBindings = {
9
4
  sys: ResourceLink<'Contentful:DataAssembly'>['sys'];
10
5
  parameters: Record<string, ResourceLink<string>>;
@@ -38,7 +33,6 @@ type ExperienceCommonProps = {
38
33
  description: string;
39
34
  viewports: ComponentTypeViewport[];
40
35
  designProperties: Record<string, DimensionedDesignPropertyValue>;
41
- dimensionKeyMap: ExperienceDimensionKeyMap;
42
36
  contentBindings?: ExperienceContentBindings;
43
37
  metadata?: ExperienceMetadataProps;
44
38
  slots?: Record<string, Array<FragmentNode | InlineFragmentNode>>;
@@ -1,7 +1,7 @@
1
1
  import type { Except } from 'type-fest';
2
2
  import type { CursorPaginationParams, ExoCursorPaginatedCollectionProp, ExoQueryFilters, ExperienceMetadataProps, Link, ResourceLink } from '../common-types';
3
3
  import type { ComponentTypeViewport, DimensionedDesignPropertyValue, FragmentNode } from './component-type';
4
- import type { ExperienceContentBindings, ExperienceDimensionKeyMap, InlineFragmentNode } from './experience';
4
+ import type { ExperienceContentBindings, InlineFragmentNode } from './experience';
5
5
  export type FragmentSys = {
6
6
  id: string;
7
7
  type: 'Fragment';
@@ -31,7 +31,6 @@ export type FragmentProps = {
31
31
  description: string;
32
32
  viewports: ComponentTypeViewport[];
33
33
  designProperties: Record<string, DimensionedDesignPropertyValue>;
34
- dimensionKeyMap: ExperienceDimensionKeyMap;
35
34
  contentBindings?: ExperienceContentBindings;
36
35
  metadata?: ExperienceMetadataProps;
37
36
  slots?: Record<string, Array<FragmentNode | InlineFragmentNode>>;
@@ -39,11 +38,11 @@ export type FragmentProps = {
39
38
  export type CreateFragmentProps = Except<FragmentProps, 'sys'> & {
40
39
  componentType: ResourceLink<'Contentful:ComponentType'>;
41
40
  };
42
- export type UpdateFragmentProps = Omit<FragmentProps, 'sys'> & {
41
+ export type UpsertFragmentProps = Omit<FragmentProps, 'sys'> & {
43
42
  sys: {
44
43
  id: string;
45
44
  type: 'Fragment';
46
- version: number;
45
+ version?: number;
47
46
  };
48
47
  componentType?: ResourceLink<'Contentful:ComponentType'>;
49
48
  };
@@ -1,6 +1,6 @@
1
1
  import type { Except } from 'type-fest';
2
2
  import type { CursorPaginationParams, ExoCursorPaginatedCollectionProp, ExoMetadataProps, ExoQueryFilters, Link } from '../common-types';
3
- import type { ComponentTypeContentProperty, ComponentTypeDesignProperty, ComponentTypeDimensionKeyMap, ComponentTypeSlotDefinition, ComponentTypeViewport, DataAssemblyLink, TreeNode } from './component-type';
3
+ import type { ComponentTypeContentProperty, ComponentTypeDesignProperty, ComponentTypeSlotDefinition, ComponentTypeViewport, DataAssemblyLink, TreeNode } from './component-type';
4
4
  export type TemplateSys = {
5
5
  id: string;
6
6
  type: 'Template';
@@ -28,7 +28,6 @@ export type TemplateProps = {
28
28
  viewports: ComponentTypeViewport[];
29
29
  contentProperties: ComponentTypeContentProperty[];
30
30
  designProperties: ComponentTypeDesignProperty[];
31
- dimensionKeyMap: ComponentTypeDimensionKeyMap;
32
31
  componentTree?: TreeNode[];
33
32
  slots?: ComponentTypeSlotDefinition[];
34
33
  metadata?: ExoMetadataProps;
@@ -59,7 +59,6 @@ export type ComponentTypePlainClientAPI = {
59
59
  * viewports: [],
60
60
  * contentProperties: [],
61
61
  * designProperties: [],
62
- * dimensionKeyMap: { designProperties: {} },
63
62
  * });
64
63
  * ```
65
64
  */
@@ -57,7 +57,6 @@ export type ExperiencePlainClientAPI = {
57
57
  * viewports: [],
58
58
  * contentProperties: {},
59
59
  * designProperties: {},
60
- * dimensionKeyMap: { designProperties: {} },
61
60
  * });
62
61
  * ```
63
62
  */
@@ -1,5 +1,5 @@
1
1
  import type { ExoCursorPaginatedCollectionProp, GetFragmentParams, GetSpaceEnvironmentParams } from '../../common-types';
2
- import type { CreateFragmentProps, FragmentProps, FragmentQueryOptions, UpdateFragmentProps } from '../../entities/fragment';
2
+ import type { CreateFragmentProps, FragmentProps, FragmentQueryOptions, UpsertFragmentProps } from '../../entities/fragment';
3
3
  import type { OptionalDefaults } from '../wrappers/wrap';
4
4
  export type FragmentPlainClientAPI = {
5
5
  /**
@@ -56,28 +56,27 @@ export type FragmentPlainClientAPI = {
56
56
  * componentType: { sys: { type: 'Link', linkType: 'ComponentType', id: '<component_type_id>' } },
57
57
  * viewports: [],
58
58
  * designProperties: {},
59
- * dimensionKeyMap: { designProperties: {} },
60
59
  * });
61
60
  * ```
62
61
  */
63
62
  create(params: OptionalDefaults<GetSpaceEnvironmentParams>, data: CreateFragmentProps): Promise<FragmentProps>;
64
63
  /**
65
- * Updates a fragment with PUT
64
+ * Upserts a fragment (creates or updates via PUT)
66
65
  * @param params the space, environment, and fragment IDs
67
- * @param data the fragment data (including sys.version)
68
- * @returns the updated fragment
66
+ * @param data the fragment data to upsert (include sys.version for updates, omit for creates)
67
+ * @returns the upserted fragment
69
68
  * @throws if the request fails, or the space, environment, or fragment is not found
70
69
  * @internal - Experimental endpoint, subject to breaking changes without notice
71
70
  * @example
72
71
  * ```javascript
73
- * const fragment = await client.fragment.update({
72
+ * const fragment = await client.fragment.upsert({
74
73
  * spaceId: '<space_id>',
75
74
  * environmentId: '<environment_id>',
76
75
  * fragmentId: '<fragment_id>',
77
76
  * }, fragmentData);
78
77
  * ```
79
78
  */
80
- update(params: OptionalDefaults<GetFragmentParams>, data: UpdateFragmentProps): Promise<FragmentProps>;
79
+ upsert(params: OptionalDefaults<GetFragmentParams>, data: UpsertFragmentProps): Promise<FragmentProps>;
81
80
  /**
82
81
  * Deletes a fragment
83
82
  * @param params the space, environment, and fragment IDs
@@ -56,7 +56,6 @@ export type TemplatePlainClientAPI = {
56
56
  * viewports: [],
57
57
  * contentProperties: [],
58
58
  * designProperties: [],
59
- * dimensionKeyMap: { designProperties: {} },
60
59
  * });
61
60
  * ```
62
61
  */
@@ -602,7 +602,7 @@ const createPlainClient = (makeRequest, defaults) => {
602
602
  getMany: wrap(wrapParams, 'Fragment', 'getMany'),
603
603
  get: wrap(wrapParams, 'Fragment', 'get'),
604
604
  create: wrap(wrapParams, 'Fragment', 'create'),
605
- update: wrap(wrapParams, 'Fragment', 'update'),
605
+ upsert: wrap(wrapParams, 'Fragment', 'upsert'),
606
606
  delete: wrap(wrapParams, 'Fragment', 'delete'),
607
607
  publish: wrap(wrapParams, 'Fragment', 'publish'),
608
608
  unpublish: wrap(wrapParams, 'Fragment', 'unpublish'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentful-management",
3
- "version": "12.6.0-dev.2",
3
+ "version": "12.6.0-dev.3",
4
4
  "description": "Client for Contentful's Content Management API",
5
5
  "homepage": "https://www.contentful.com/developers/documentation/content-management-api/",
6
6
  "exports": {