@se-studio/contentful-rest-api 1.0.37 → 1.0.38

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.
package/dist/index.d.ts CHANGED
@@ -61,7 +61,6 @@ interface BaseArticleTypeFields {
61
61
  name: EntryFieldTypes.Symbol;
62
62
  slug: EntryFieldTypes.Symbol;
63
63
  indexPageName: EntryFieldTypes.Symbol;
64
- indexPageSlug: EntryFieldTypes.Symbol;
65
64
  indexPageDescription: EntryFieldTypes.Symbol;
66
65
  featuredImage: EntryFieldTypes.AssetLink;
67
66
  menu?: EntryFieldTypes.EntryLink<BaseNavigationSkeleton>;
@@ -324,7 +323,6 @@ interface BaseCustomTypeFields {
324
323
  name: EntryFieldTypes.Symbol;
325
324
  slug: EntryFieldTypes.Symbol;
326
325
  indexPageName: EntryFieldTypes.Symbol;
327
- indexPageSlug: EntryFieldTypes.Symbol;
328
326
  indexPageDescription: EntryFieldTypes.Symbol;
329
327
  featuredImage: EntryFieldTypes.AssetLink;
330
328
  menu?: EntryFieldTypes.EntryLink<BaseNavigationSkeleton>;
@@ -448,7 +446,7 @@ declare function contentfulArticleRest(context: BaseConverterContext, config: Co
448
446
  interface ArticleTypeFetchOptions extends FetchOptions {
449
447
  customType?: string;
450
448
  }
451
- declare function contentfulArticleTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: ArticleTypeFetchOptions): Promise<CmsResponse<IBaseArticleType | null>>;
449
+ declare function contentfulArticleTypeRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: ArticleTypeFetchOptions): Promise<CmsResponse<IBaseArticleType | null>>;
452
450
 
453
451
  interface ContentfulResponse<T = any> {
454
452
  sys: {
@@ -526,7 +524,7 @@ declare function createDownloadHandler(config: DownloadHandlerConfig): (_request
526
524
 
527
525
  declare function createBaseConverterContext(urlCalculators: UrlCalculators): BaseConverterContext;
528
526
 
529
- declare function contentfulCustomTypeRest(context: BaseConverterContext, config: ContentfulConfig, indexPageSlug: string, options?: FetchOptions): Promise<CmsResponse<IBaseCustomType | null>>;
527
+ declare function contentfulCustomTypeRest(context: BaseConverterContext, config: ContentfulConfig, slug: string, options?: FetchOptions): Promise<CmsResponse<IBaseCustomType | null>>;
530
528
 
531
529
  type DefaultChainModifier = 'WITHOUT_LINK_RESOLUTION';
532
530
  interface IContentfulRichText {
package/dist/index.js CHANGED
@@ -1323,9 +1323,9 @@ async function contentfulArticleRest(context, config, slug, articleTypeSlug, opt
1323
1323
 
1324
1324
  // src/api/article-type.ts
1325
1325
  init_utils();
1326
- async function contentfulArticleTypeRest(context, config, indexPageSlug, options) {
1326
+ async function contentfulArticleTypeRest(context, config, slug, options) {
1327
1327
  const client = getContentfulClient(config, options?.preview);
1328
- const articleTypeCacheTags = getCacheTags("articleType", indexPageSlug, options?.preview);
1328
+ const articleTypeCacheTags = getCacheTags("articleType", slug, options?.preview);
1329
1329
  const customTypeCacheTags = options?.customType ? getCacheTags("customType", options.customType, options?.preview) : [];
1330
1330
  const requestOptions = {
1331
1331
  ...options,
@@ -1338,7 +1338,7 @@ async function contentfulArticleTypeRest(context, config, indexPageSlug, options
1338
1338
  const articleTypePromise = client.getEntries(
1339
1339
  {
1340
1340
  content_type: "articleType",
1341
- "fields.indexPageSlug": indexPageSlug,
1341
+ "fields.slug": slug,
1342
1342
  include: 10,
1343
1343
  locale: options?.locale,
1344
1344
  limit: 1
@@ -1391,7 +1391,7 @@ async function contentfulArticleTypeRest(context, config, indexPageSlug, options
1391
1391
  if (fullContext.errors.length > 0 && typeof process !== "undefined" && process.env?.NODE_ENV === "production") {
1392
1392
  console.error(`CMS conversion errors for articleType:`, {
1393
1393
  entryId: articleTypeEntry.sys.id,
1394
- indexPageSlug,
1394
+ slug,
1395
1395
  errors: fullContext.errors
1396
1396
  });
1397
1397
  }
@@ -2037,29 +2037,25 @@ function baseArticleTypeLinkConverter(context, entry) {
2037
2037
  `Invalid content type: expected "articleType", got "${sys.contentType.sys.id}"`
2038
2038
  );
2039
2039
  }
2040
+ const { name, featuredImage, slug, ...simpleFields } = fields;
2040
2041
  return createInternalLink(
2041
2042
  sys.id,
2042
2043
  {
2043
- cmsLabel: fields.name,
2044
- title: fields.name,
2045
- featuredImage: fields.featuredImage,
2046
- backgroundColour: fields.backgroundColour,
2047
- textColour: fields.textColour,
2048
- indexed: fields.indexed,
2049
- hidden: fields.hidden,
2050
- slug: fields.slug
2044
+ cmsLabel: name,
2045
+ title: name,
2046
+ featuredImage,
2047
+ slug,
2048
+ ...simpleFields
2051
2049
  },
2052
2050
  context,
2053
- context.urlCalculators.articleType(fields.slug),
2054
- "ArticleType",
2055
- { indexPageSlug: fields.indexPageSlug }
2051
+ context.urlCalculators.articleType(slug),
2052
+ "ArticleType"
2056
2053
  );
2057
2054
  }
2058
2055
  function baseArticleTypeConverter(context, entry, customTypeEntry) {
2059
2056
  const { sys, fields } = entry;
2060
2057
  const { id } = sys;
2061
2058
  const {
2062
- indexPageSlug,
2063
2059
  indexPageName,
2064
2060
  indexPageDescription,
2065
2061
  featuredImage,
@@ -2069,13 +2065,13 @@ function baseArticleTypeConverter(context, entry, customTypeEntry) {
2069
2065
  indexPageTopContent: topContentLinks,
2070
2066
  structuredData,
2071
2067
  indexPageStructuredData,
2072
- slug: _slug,
2068
+ slug,
2073
2069
  ...other
2074
2070
  } = fields;
2075
2071
  const customType = customTypeEntry ? context.customTypeResolver(context, customTypeEntry) : void 0;
2076
2072
  let template = templateLink ? resolveTemplate(context, templateLink) : null;
2077
- if (!template && customTypeEntry?.fields.indexPageTemplate) {
2078
- template = resolveTemplate(context, customTypeEntry.fields.indexPageTemplate);
2073
+ if (!template && customTypeEntry?.fields.template) {
2074
+ template = resolveTemplate(context, customTypeEntry.fields.template);
2079
2075
  }
2080
2076
  const menu = menuLink ? resolveNavigation(context, menuLink) : customTypeEntry?.fields.menu ? resolveNavigation(context, customTypeEntry.fields.menu) : template?.menu;
2081
2077
  const footer = footerLink ? resolveNavigation(context, footerLink) : customTypeEntry?.fields.footer ? resolveNavigation(context, customTypeEntry.fields.footer) : template?.footer;
@@ -2093,7 +2089,7 @@ function baseArticleTypeConverter(context, entry, customTypeEntry) {
2093
2089
  const articleType = {
2094
2090
  type: "Article type",
2095
2091
  id,
2096
- slug: indexPageSlug,
2092
+ slug,
2097
2093
  title: makeContentfulTitle(indexPageName, sys.id),
2098
2094
  description: makeContentfulDescription(indexPageDescription, sys.id),
2099
2095
  featuredImage: lookupAsset(context, featuredImage),
@@ -2223,7 +2219,6 @@ function baseCustomTypeConverter(context, entry) {
2223
2219
  const { id } = sys;
2224
2220
  const {
2225
2221
  slug,
2226
- indexPageSlug,
2227
2222
  indexPageName,
2228
2223
  indexPageDescription,
2229
2224
  featuredImage,
@@ -2251,7 +2246,6 @@ function baseCustomTypeConverter(context, entry) {
2251
2246
  type: "Custom type",
2252
2247
  id,
2253
2248
  slug,
2254
- indexPageSlug,
2255
2249
  indexPageName: makeContentfulTitle(indexPageName, sys.id),
2256
2250
  indexPageDescription: makeContentfulDescription(indexPageDescription, sys.id),
2257
2251
  title: makeContentfulTitle(indexPageName, sys.id),
@@ -2287,10 +2281,10 @@ function baseCustomTypeLinkConverter(context, entry) {
2287
2281
  textColour: fields.textColour,
2288
2282
  indexed: fields.indexed,
2289
2283
  hidden: fields.hidden,
2290
- slug: fields.indexPageSlug
2284
+ slug: fields.slug
2291
2285
  },
2292
2286
  context,
2293
- context.urlCalculators.customType(fields.indexPageSlug),
2287
+ context.urlCalculators.customType(fields.slug),
2294
2288
  "CustomType"
2295
2289
  );
2296
2290
  }
@@ -2720,17 +2714,17 @@ function createBaseConverterContext(urlCalculators) {
2720
2714
  }
2721
2715
 
2722
2716
  // src/api/custom-type.ts
2723
- async function contentfulCustomTypeRest(context, config, indexPageSlug, options) {
2717
+ async function contentfulCustomTypeRest(context, config, slug, options) {
2724
2718
  return fetchSingleEntity(
2725
2719
  context,
2726
2720
  config,
2727
2721
  {
2728
2722
  contentType: "customType",
2729
2723
  cacheTagType: "customType",
2730
- cacheTagIdentifier: indexPageSlug,
2731
- query: { "fields.indexPageSlug": indexPageSlug },
2724
+ cacheTagIdentifier: slug,
2725
+ query: { "fields.slug": slug },
2732
2726
  resolver: (ctx, entry) => ctx.customTypeResolver(ctx, entry),
2733
- errorLogContext: { indexPageSlug }
2727
+ errorLogContext: { slug }
2734
2728
  },
2735
2729
  options
2736
2730
  );
@@ -3024,7 +3018,7 @@ async function getPreviewEntryInfo(context, config, entryId, options) {
3024
3018
  };
3025
3019
  }
3026
3020
  case "articleType": {
3027
- const slug = fields.indexPageSlug ?? fields.slug;
3021
+ const slug = fields.slug;
3028
3022
  if (!slug) return null;
3029
3023
  return {
3030
3024
  contentType: "articleType",
@@ -3054,7 +3048,7 @@ async function getPreviewEntryInfo(context, config, entryId, options) {
3054
3048
  };
3055
3049
  }
3056
3050
  case "customType": {
3057
- const slug = fields.indexPageSlug ?? fields.slug;
3051
+ const slug = fields.slug;
3058
3052
  if (!slug) return null;
3059
3053
  return {
3060
3054
  contentType: "customType",
@@ -3351,13 +3345,9 @@ init_utils();
3351
3345
  var defaultLocale = "en-US";
3352
3346
  var articleTypeHandler = {
3353
3347
  extract: (data) => ({
3354
- slug: data.fields?.slug?.[defaultLocale],
3355
- indexPageSlug: data.fields?.indexPageSlug?.[defaultLocale]
3348
+ slug: data.fields?.slug?.[defaultLocale]
3356
3349
  }),
3357
- makeTags: (extracted) => [
3358
- extracted.slug ? articleTypeTag(extracted.slug) : void 0,
3359
- extracted.indexPageSlug ? articleTypeIndexTag(extracted.indexPageSlug) : void 0
3360
- ],
3350
+ makeTags: (extracted) => [extracted.slug ? articleTypeIndexTag(extracted.slug) : void 0],
3361
3351
  getGlobalTags: () => [ArticleTypeTag, ArticleTypeIndexTag]
3362
3352
  };
3363
3353
  var articleHandler = {