Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types not working in ESM mode #2341

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/create-contentful-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { encodeCPAResponse } from '@contentful/content-source-maps'
import { AxiosInstance, createRequestConfig, errorHandler } from 'contentful-sdk-core'
import { CreateClientParams } from './contentful'
import { CreateClientParams } from './contentful.js'
import { GetGlobalOptions } from './create-global-options.js'
import pagedSync from './paged-sync.js'
import type {
Expand All @@ -28,16 +28,16 @@ import type {
import normalizeSearchParameters from './utils/normalize-search-parameters.js'
import normalizeSelect from './utils/normalize-select.js'
import resolveCircular from './utils/resolve-circular.js'
import getQuerySelectionSet from './utils/query-selection-set'
import getQuerySelectionSet from './utils/query-selection-set.js'
import validateTimestamp from './utils/validate-timestamp.js'
import { ChainOptions, ModifiersFromOptions } from './utils/client-helpers.js'
import {
checkIncludeContentSourceMapsParamIsAllowed,
validateLocaleParam,
validateRemoveUnresolvedParam,
validateResolveLinksParam,
} from './utils/validate-params'
import validateSearchParameters from './utils/validate-search-parameters'
} from './utils/validate-params.js'
import validateSearchParameters from './utils/validate-search-parameters.js'

const ASSET_KEY_MAX_LIFETIME = 48 * 60 * 60

Expand Down
10 changes: 5 additions & 5 deletions lib/types/asset.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ContentfulCollection } from './collection'
import { LocaleCode } from './locale'
import { Metadata } from './metadata'
import { EntitySys } from './sys'
import { ChainModifiers } from './client'
import { ContentfulCollection } from './collection.js'
import { LocaleCode } from './locale.js'
import { Metadata } from './metadata.js'
import { EntitySys } from './sys.js'
import { ChainModifiers } from './client.js'

/**
* @category Asset
Expand Down
18 changes: 9 additions & 9 deletions lib/types/client.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { ContentType, ContentTypeCollection } from './content-type'
import { Space } from './space'
import { LocaleCode, LocaleCollection } from './locale'
import { ContentType, ContentTypeCollection } from './content-type.js'
import { Space } from './space.js'
import { LocaleCode, LocaleCollection } from './locale.js'
import {
AssetQueries,
AssetsQueries,
EntriesQueries,
EntryQueries,
EntrySkeletonType,
TagQueries,
} from './query'
import { SyncCollection, SyncOptions, SyncQuery } from './sync'
import { Tag, TagCollection } from './tag'
import { AssetKey } from './asset-key'
import { Entry, EntryCollection } from './entry'
import { Asset, AssetCollection, AssetFields } from './asset'
} from './query/index.js'
import { SyncCollection, SyncOptions, SyncQuery } from './sync.js'
import { Tag, TagCollection } from './tag.js'
import { AssetKey } from './asset-key.js'
import { Entry, EntryCollection } from './entry.js'
import { Asset, AssetCollection, AssetFields } from './asset.js'

/**
* Client chain modifiers used in all types that depend on the client configuration.
Expand Down
4 changes: 2 additions & 2 deletions lib/types/collection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AssetSys } from './asset'
import { EntrySys } from './entry'
import { AssetSys } from './asset.js'
import { EntrySys } from './entry.js'

/**
* A wrapper object containing additional information for
Expand Down
8 changes: 4 additions & 4 deletions lib/types/content-type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ContentfulCollection } from './collection'
import { EntryFields } from './entry'
import { SpaceLink, EnvironmentLink } from './link'
import { BaseSys } from './sys'
import { ContentfulCollection } from './collection.js'
import { EntryFields } from './entry.js'
import { SpaceLink, EnvironmentLink } from './link.js'
import { BaseSys } from './sys.js'
import type { BLOCKS, INLINES } from '@contentful/rich-text-types'

/**
Expand Down
18 changes: 9 additions & 9 deletions lib/types/entry.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Document as RichTextDocument } from '@contentful/rich-text-types'
import { Asset } from './asset'
import { ContentfulCollection } from './collection'
import { ContentTypeLink, UnresolvedLink } from './link'
import { LocaleCode } from './locale'
import { Metadata } from './metadata'
import { EntrySkeletonType } from './query'
import { EntitySys } from './sys'
import { Asset } from './asset.js'
import { ContentfulCollection } from './collection.js'
import { ContentTypeLink, UnresolvedLink } from './link.js'
import { LocaleCode } from './locale.js'
import { Metadata } from './metadata.js'
import { EntrySkeletonType } from './query/index.js'
import { EntitySys } from './sys.js'
import { JsonArray, JsonObject } from 'type-fest'
import { ResourceLink } from './resource-link'
import { ChainModifiers } from './client'
import { ResourceLink } from './resource-link.js'
import { ChainModifiers } from './client.js'

/**
* System managed metadata for entries
Expand Down
2 changes: 1 addition & 1 deletion lib/types/link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResourceLink } from './resource-link'
import { ResourceLink } from './resource-link.js'

/**
* @category Link
Expand Down
4 changes: 2 additions & 2 deletions lib/types/locale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContentfulCollection } from './collection'
import { BaseSys } from './sys'
import { ContentfulCollection } from './collection.js'
import { BaseSys } from './sys.js'

/**
* @category Entity
Expand Down
2 changes: 1 addition & 1 deletion lib/types/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TagLink, TaxonomyConceptLink } from './link'
import { TagLink, TaxonomyConceptLink } from './link.js'

/**
* User-controlled metadata
Expand Down
4 changes: 2 additions & 2 deletions lib/types/query/equality.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFields, EntryFieldType, EntryFieldTypes } from '../entry'
import { ConditionalQueries, EntryFieldsConditionalQueries, EntrySkeletonType } from './util'
import { EntryFields, EntryFieldType, EntryFieldTypes } from '../entry.js'
import { ConditionalQueries, EntryFieldsConditionalQueries, EntrySkeletonType } from './util.js'

type SupportedTypes =
| EntryFields.Symbol
Expand Down
6 changes: 3 additions & 3 deletions lib/types/query/existence.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EntryField, EntryFieldType } from '../entry'
import { ConditionalFixedQueries, FieldsType, EntrySkeletonType } from './util'
import { AssetDetails, AssetFile } from '../asset'
import { EntryField, EntryFieldType } from '../entry.js'
import { ConditionalFixedQueries, FieldsType, EntrySkeletonType } from './util.js'
import { AssetDetails, AssetFile } from '../asset.js'

/**
* Check for existence of provided fields
Expand Down
2 changes: 1 addition & 1 deletion lib/types/query/location.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConditionalPick } from 'type-fest'
import { EntryFieldTypes } from '../entry'
import { EntryFieldTypes } from '../entry.js'

type Types = EntryFieldTypes.Location | undefined

Expand Down
8 changes: 4 additions & 4 deletions lib/types/query/order.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EntrySkeletonType, FieldsType } from './util'
import { EntryFields, EntryFieldType, EntryFieldTypes, EntrySys } from '../entry'
import { AssetSys } from '../asset'
import { EntrySkeletonType, FieldsType } from './util.js'
import { EntryFields, EntryFieldType, EntryFieldTypes, EntrySys } from '../entry.js'
import { AssetSys } from '../asset.js'
import { ConditionalPick } from 'type-fest'
import { TagSys } from '../tag'
import { TagSys } from '../tag.js'

export type SupportedTypes =
| EntryFields.Symbol
Expand Down
34 changes: 17 additions & 17 deletions lib/types/query/query.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { AssetDetails, AssetFile, AssetMimeType, AssetSys } from '../asset'
import { ChainModifiers } from '../client'
import { EntrySys } from '../entry'
import { TagLink, TaxonomyConceptLink } from '../link'
import { Metadata } from '../metadata'
import { TagSys } from '../tag'
import { AssetDetails, AssetFile, AssetMimeType, AssetSys } from '../asset.js'
import { ChainModifiers } from '../client.js'
import { EntrySys } from '../entry.js'
import { TagLink, TaxonomyConceptLink } from '../link.js'
import { Metadata } from '../metadata.js'
import { TagSys } from '../tag.js'
import {
EntryFieldsEqualityFilter,
EntryFieldsInequalityFilter,
EqualityFilter,
InequalityFilter,
} from './equality'
import { EntryFieldsExistenceFilter, ExistenceFilter } from './existence'
import { LocationSearchFilters } from './location'
} from './equality.js'
import { EntryFieldsExistenceFilter, ExistenceFilter } from './existence.js'
import { LocationSearchFilters } from './location.js'
import {
AssetOrderFilter,
EntryOrderFilter,
EntryOrderFilterWithFields,
TagOrderFilter,
} from './order'
import { EntryFieldsRangeFilters, RangeFilters } from './range'
import { ReferenceSearchFilters } from './reference'
import { EntryFieldsFullTextSearchFilters, FullTextSearchFilters } from './search'
import { AssetSelectFilter, EntrySelectFilter, EntrySelectFilterWithFields } from './select'
import { EntryFieldsSetFilter } from './set'
import { EntryFieldsSubsetFilters, SubsetFilters } from './subset'
} from './order.js'
import { EntryFieldsRangeFilters, RangeFilters } from './range.js'
import { ReferenceSearchFilters } from './reference.js'
import { EntryFieldsFullTextSearchFilters, FullTextSearchFilters } from './search.js'
import { AssetSelectFilter, EntrySelectFilter, EntrySelectFilterWithFields } from './select.js'
import { EntryFieldsSetFilter } from './set.js'
import { EntryFieldsSubsetFilters, SubsetFilters } from './subset.js'
import {
ConditionalFixedQueries,
ConditionalListQueries,
EntrySkeletonType,
FieldsType,
} from './util'
} from './util.js'

export type FixedPagedOptions = {
skip?: number
Expand Down
4 changes: 2 additions & 2 deletions lib/types/query/range.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFields, EntryFieldType, EntryFieldTypes } from '../entry'
import { ConditionalQueries, EntryFieldsConditionalQueries, EntrySkeletonType } from './util'
import { EntryFields, EntryFieldType, EntryFieldTypes } from '../entry.js'
import { ConditionalQueries, EntryFieldsConditionalQueries, EntrySkeletonType } from './util.js'

type RangeFilterTypes = 'lt' | 'lte' | 'gt' | 'gte'

Expand Down
2 changes: 1 addition & 1 deletion lib/types/query/reference.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EntryFieldTypes } from '../entry'
import { EntryFieldTypes } from '../entry.js'
import { ConditionalPick } from 'type-fest'

type SupportedTypes =
Expand Down
4 changes: 2 additions & 2 deletions lib/types/query/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFields, EntryFieldTypes } from '../entry'
import { ConditionalFixedQueries, FieldsType } from './util'
import { EntryFields, EntryFieldTypes } from '../entry.js'
import { ConditionalFixedQueries, FieldsType } from './util.js'

type SupportedTypes =
| EntryFields.Text
Expand Down
8 changes: 4 additions & 4 deletions lib/types/query/select.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FieldsType } from './util'
import { EntrySys } from '../entry'
import { AssetSys } from '../asset'
import { Metadata } from '../metadata'
import { FieldsType } from './util.js'
import { EntrySys } from '../entry.js'
import { AssetSys } from '../asset.js'
import { Metadata } from '../metadata.js'

export type SelectFilterPaths<
Fields extends FieldsType,
Expand Down
4 changes: 2 additions & 2 deletions lib/types/query/set.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFieldType, EntryFieldTypes } from '..'
import { EntryFieldsConditionalListQueries } from './util'
import { EntryFieldType, EntryFieldTypes } from '../index.js'
import { EntryFieldsConditionalListQueries } from './util.js'

type SupportedTypes =
| EntryFieldTypes.Symbol
Expand Down
4 changes: 2 additions & 2 deletions lib/types/query/subset.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EntryFields, EntryFieldType, EntryFieldTypes } from '..'
import { ConditionalListQueries, EntryFieldsConditionalListQueries } from './util'
import { EntryFields, EntryFieldType, EntryFieldTypes } from '../index.js'
import { ConditionalListQueries, EntryFieldsConditionalListQueries } from './util.js'

type SubsetFilterTypes = 'in' | 'nin'

Expand Down
2 changes: 1 addition & 1 deletion lib/types/query/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConditionalPick } from 'type-fest'
import { BaseFieldMap, EntryFieldType, EntryFieldTypes } from '../entry'
import { BaseFieldMap, EntryFieldType, EntryFieldTypes } from '../entry.js'

/**
* @category Entity
Expand Down
4 changes: 2 additions & 2 deletions lib/types/space.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Locale } from './locale'
import { BaseSys } from './sys'
import { Locale } from './locale.js'
import { BaseSys } from './sys.js'

/**
* System managed metadata for spaces
Expand Down
12 changes: 6 additions & 6 deletions lib/types/sync.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Asset } from './asset'
import { Entry } from './entry'
import { EntitySys } from './sys'
import { EntrySkeletonType } from './query'
import { LocaleCode } from './locale'
import { ChainModifiers } from './client'
import { Asset } from './asset.js'
import { Entry } from './entry.js'
import { EntitySys } from './sys.js'
import { EntrySkeletonType } from './query/index.js'
import { LocaleCode } from './locale.js'
import { ChainModifiers } from './client.js'

/**
* @category Sync
Expand Down
4 changes: 2 additions & 2 deletions lib/types/sys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ContentSourceMapsLookup, CPAContentSourceMaps } from '@contentful/content-source-maps'
import { EntryFields } from './entry'
import { EnvironmentLink, SpaceLink } from './link'
import { EntryFields } from './entry.js'
import { EnvironmentLink, SpaceLink } from './link.js'

/**
* Definition of common part of system managed metadata
Expand Down
6 changes: 3 additions & 3 deletions lib/types/tag.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EntitySys } from './sys'
import { ContentfulCollection } from './collection'
import { UserLink } from './link'
import { EntitySys } from './sys.js'
import { ContentfulCollection } from './collection.js'
import { UserLink } from './link.js'

/**
* System managed metadata for tags
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/client-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainModifiers } from '../types/client'
import { ChainModifiers } from '../types/client.js'

export type ChainOption<Modifiers extends ChainModifiers = ChainModifiers> = {
withoutLinkResolution: ChainModifiers extends Modifiers
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/normalize-select.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getQuerySelectionSet from './query-selection-set'
import getQuerySelectionSet from './query-selection-set.js'

/*
* sdk relies heavily on sys metadata
Expand Down