@stackbit/types
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -59,5 +59,5 @@ import type { ContentSourceInterface } from './content-source'; | ||
mapDocuments?: (options: { | ||
documents: Document[]; | ||
documents: DocumentWithSource[]; | ||
models: ModelWithSource[]; | ||
}) => Document[]; | ||
}) => DocumentWithSource[]; | ||
/** @deprecated */ | ||
@@ -152,2 +152,6 @@ models?: NamelessModelMap; | ||
}; | ||
export declare type DocumentWithSource = Document & { | ||
srcType: string; | ||
srcProjectId: string; | ||
}; | ||
export declare type NamelessModelMap = Record<string, NamelessModel>; | ||
@@ -154,0 +158,0 @@ export declare type NamelessModel = DistributeNamelessModels<Model>; |
@@ -40,3 +40,3 @@ import type { FieldType } from './model-fields'; | ||
export declare type DocumentFieldSpecificProps = DocumentValueFieldProps | DocumentObjectFieldProps | DocumentModelFieldProps | DocumentReferenceFieldProps | DocumentListFieldProps | DocumentRichTextFieldProps | DocumentImageFieldProps; | ||
export declare type FindByType<Union extends { | ||
declare type FindByType<Union extends { | ||
type: FieldType; | ||
@@ -176,2 +176,3 @@ }, Type extends FieldType> = Union extends { | ||
}; | ||
export {}; | ||
//# sourceMappingURL=content-source-document.d.ts.map |
@@ -8,2 +8,10 @@ /** | ||
export declare type FieldSpecificProps = FieldBasicProps | FieldEnumProps | FieldImageProps | FieldNumberProps | FieldObjectProps | FieldModelProps | FieldReferenceProps | FieldStyleProps | FieldListProps; | ||
declare type FindByType<Union extends { | ||
type: FieldType; | ||
}, Type extends FieldType> = Union extends { | ||
type: Type; | ||
} ? Union : never; | ||
export declare type FieldForType<Type extends FieldType> = FindByType<Field, Type>; | ||
export declare type FieldSpecificPropsForType<Type extends FieldType> = FindByType<FieldSpecificProps, Type>; | ||
export declare type FieldSpecificPropsForField<T extends Field> = FindByType<FieldSpecificProps, T['type']>; | ||
export declare type FieldBasic = FieldCommonProps & FieldBasicProps; | ||
@@ -107,3 +115,3 @@ export declare type FieldEnum = FieldCommonProps & FieldEnumProps; | ||
export declare type FieldListProps = FieldListItemsBasicProps | FieldListItemsEnumProps | FieldListItemsImageProps | FieldListItemsNumberProps | FieldListItemsObjectProps | FieldListItemsModelProps | FieldListItemsReferenceProps; | ||
export declare type FieldListItems = NonNullable<FieldListProps['items']>; | ||
export declare type FieldListItems = FieldListProps['items']; | ||
export interface FieldListCommonProps { | ||
@@ -113,23 +121,24 @@ type: 'list'; | ||
export interface FieldListItemsBasicProps extends FieldListCommonProps { | ||
items?: FieldBasicProps; | ||
items: FieldBasicProps; | ||
} | ||
export interface FieldListItemsEnumProps extends FieldListCommonProps { | ||
items?: FieldEnumProps; | ||
items: FieldEnumProps; | ||
controlType?: 'checkbox'; | ||
} | ||
export interface FieldListItemsImageProps extends FieldListCommonProps { | ||
items?: FieldImageProps; | ||
items: FieldImageProps; | ||
} | ||
export interface FieldListItemsNumberProps extends FieldListCommonProps { | ||
items?: FieldNumberProps; | ||
items: FieldNumberProps; | ||
} | ||
export interface FieldListItemsObjectProps extends FieldListCommonProps { | ||
items?: FieldObjectProps; | ||
items: FieldObjectProps; | ||
} | ||
export interface FieldListItemsModelProps extends FieldListCommonProps { | ||
items?: FieldModelProps; | ||
items: FieldModelProps; | ||
} | ||
export interface FieldListItemsReferenceProps extends FieldListCommonProps { | ||
items?: FieldReferenceProps; | ||
items: FieldReferenceProps; | ||
} | ||
export {}; | ||
//# sourceMappingURL=model-fields.d.ts.map |
@@ -31,5 +31,3 @@ /** | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
/** @deprecated */ | ||
export interface ConfigModel extends ModelCommonFields { | ||
@@ -36,0 +34,0 @@ type: 'config'; |
import type { FieldType } from './model-fields'; | ||
import type { StackbitConfig } from './config'; | ||
import type { AssetFileField, AssetFileFieldLocalized, DocumentField, DocumentFieldForType, DocumentFieldLocalized, DocumentFieldNonLocalizedForType } from './content-source-document'; | ||
@@ -44,2 +45,3 @@ export declare type Simplify<T> = { | ||
export declare function getLocalizedFieldForLocale<Type extends FieldType>(field: DocumentFieldForType<Type>, locale?: string): DocumentFieldNonLocalizedForType<Type> | null; | ||
export declare function defineStackbitConfig(stackbitConfig: StackbitConfig): StackbitConfig; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getLocalizedFieldForLocale = exports.isLocalizedField = void 0; | ||
exports.defineStackbitConfig = exports.getLocalizedFieldForLocale = exports.isLocalizedField = void 0; | ||
function isLocalizedField(field) { | ||
@@ -64,2 +64,6 @@ return !!field.localized; | ||
exports.getLocalizedFieldForLocale = getLocalizedFieldForLocale; | ||
function defineStackbitConfig(stackbitConfig) { | ||
return stackbitConfig; | ||
} | ||
exports.defineStackbitConfig = defineStackbitConfig; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@stackbit/types", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Types for Stackbit config and Content Source Interface", | ||
@@ -42,3 +42,3 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "88cad3911fc80f3241d96daea898c0bea69d59ce" | ||
"gitHead": "627eb38e1d72fe5719347701da240af8b3cc15d7" | ||
} |
@@ -67,3 +67,3 @@ import type { ContentSourceInterface } from './content-source'; | ||
mapModels?: (options: { models: ModelWithSource[] }) => ModelWithSource[]; | ||
mapDocuments?: (options: { documents: Document[]; models: ModelWithSource[] }) => Document[]; | ||
mapDocuments?: (options: { documents: DocumentWithSource[]; models: ModelWithSource[] }) => DocumentWithSource[]; | ||
@@ -161,13 +161,14 @@ /** @deprecated */ | ||
name?: string; | ||
passthrough?: string[] | ||
passthrough?: string[]; | ||
watch?: { | ||
reinstallPackages?: string[]; | ||
} | ||
}; | ||
logPatterns?: { | ||
up?: string[]; | ||
} | ||
} | ||
}; | ||
}; | ||
} | ||
export type ModelWithSource = Model & { srcType: string; srcProjectId: string }; | ||
export type DocumentWithSource = Document & { srcType: string; srcProjectId: string }; | ||
@@ -174,0 +175,0 @@ export type NamelessModelMap = Record<string, NamelessModel>; |
@@ -86,3 +86,3 @@ import type { FieldType } from './model-fields'; | ||
export type FindByType<Union extends { type: FieldType }, Type extends FieldType> = Union extends { type: Type } | ||
type FindByType<Union extends { type: FieldType }, Type extends FieldType> = Union extends { type: Type } | ||
? Union | ||
@@ -89,0 +89,0 @@ : never; |
@@ -31,2 +31,7 @@ /** | ||
type FindByType<Union extends { type: FieldType }, Type extends FieldType> = Union extends { type: Type } ? Union : never; | ||
export type FieldForType<Type extends FieldType> = FindByType<Field, Type>; | ||
export type FieldSpecificPropsForType<Type extends FieldType> = FindByType<FieldSpecificProps, Type>; | ||
export type FieldSpecificPropsForField<T extends Field> = FindByType<FieldSpecificProps, T['type']>; | ||
export type FieldBasic = FieldCommonProps & FieldBasicProps; | ||
@@ -173,3 +178,3 @@ export type FieldEnum = FieldCommonProps & FieldEnumProps; | ||
export type FieldListItems = NonNullable<FieldListProps['items']>; | ||
export type FieldListItems = FieldListProps['items']; | ||
@@ -181,7 +186,7 @@ export interface FieldListCommonProps { | ||
export interface FieldListItemsBasicProps extends FieldListCommonProps { | ||
items?: FieldBasicProps; | ||
items: FieldBasicProps; | ||
} | ||
export interface FieldListItemsEnumProps extends FieldListCommonProps { | ||
items?: FieldEnumProps; | ||
items: FieldEnumProps; | ||
controlType?: 'checkbox'; | ||
@@ -191,19 +196,19 @@ } | ||
export interface FieldListItemsImageProps extends FieldListCommonProps { | ||
items?: FieldImageProps; | ||
items: FieldImageProps; | ||
} | ||
export interface FieldListItemsNumberProps extends FieldListCommonProps { | ||
items?: FieldNumberProps; | ||
items: FieldNumberProps; | ||
} | ||
export interface FieldListItemsObjectProps extends FieldListCommonProps { | ||
items?: FieldObjectProps; | ||
items: FieldObjectProps; | ||
} | ||
export interface FieldListItemsModelProps extends FieldListCommonProps { | ||
items?: FieldModelProps; | ||
items: FieldModelProps; | ||
} | ||
export interface FieldListItemsReferenceProps extends FieldListCommonProps { | ||
items?: FieldReferenceProps; | ||
items: FieldReferenceProps; | ||
} |
@@ -37,5 +37,3 @@ /** | ||
/** | ||
* @deprecated | ||
*/ | ||
/** @deprecated */ | ||
export interface ConfigModel extends ModelCommonFields { | ||
@@ -42,0 +40,0 @@ type: 'config'; |
import type { FieldType } from './model-fields'; | ||
import type { StackbitConfig } from './config'; | ||
import type { | ||
@@ -70,6 +71,6 @@ AssetFileField, | ||
} | ||
return { | ||
return ({ | ||
...base, | ||
...localizedField | ||
} as unknown as DocumentFieldNonLocalizedForType<Type>; | ||
} as unknown) as DocumentFieldNonLocalizedForType<Type>; | ||
} else { | ||
@@ -79,1 +80,5 @@ return field; | ||
} | ||
export function defineStackbitConfig(stackbitConfig: StackbitConfig) { | ||
return stackbitConfig; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
106677
2156
0