Socket
Socket
Sign inDemoInstall

@stackbit/types

Package Overview
Dependencies
Maintainers
12
Versions
291
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackbit/types - npm Package Compare versions

Comparing version 0.5.2-develop.1 to 0.5.2-staging.1

dist/asset-source.d.ts

4

dist/config.d.ts

@@ -6,2 +6,3 @@ import type { ContentSourceInterface } from './content-source';

import { SidebarButton } from './sidebar-button';
import { AssetSource } from './asset-source';
export interface StackbitConfig {

@@ -63,3 +64,4 @@ /**

experimental?: Experimental;
contentSources?: ContentSourceInterface<any, any, any>[];
contentSources?: ContentSourceInterface<any, any, any, any>[];
assetSources?: AssetSource[];
mapModels?: (options: {

@@ -66,0 +68,0 @@ models: ModelWithSource[];

@@ -116,26 +116,45 @@ import { FieldType, StyleProps } from './model-fields';

}
export declare type DocumentImageField = DocumentImageFieldNonLocalized | DocumentImageFieldLocalized;
export interface DocumentImageFieldNonLocalized {
export declare type DocumentImageField = DocumentImageURLField | DocumentImageSourcedField;
export declare type DocumentImageURLField = DocumentImageURLFieldNonLocalized | DocumentImageURLFieldLocalized;
export declare type DocumentImageSourcedField = DocumentImageSourcedFieldNonLocalized | DocumentImageSourcedFieldLocalized;
export declare type DocumentImageFieldNonLocalized = DocumentImageURLFieldNonLocalized | DocumentImageSourcedFieldNonLocalized;
export declare type DocumentImageFieldLocalized = DocumentImageURLFieldLocalized | DocumentImageSourcedFieldLocalized;
export interface DocumentImageURLFieldNonLocalized {
type: 'image';
localized?: false;
source?: string;
sourceData?: any;
fields: {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
source?: never;
sourceData?: never;
fields: ImageFields;
}
export interface DocumentImageFieldLocalized {
export interface DocumentImageURLFieldLocalized {
type: 'image';
localized: true;
source?: string;
sourceData?: any;
source?: never;
locales: Record<string, {
locale: string;
fields: {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
sourceData?: never;
fields: ImageFields;
}>;
}
export interface DocumentImageSourcedFieldNonLocalized {
type: 'image';
localized?: false;
source: string;
sourceData: any;
fields?: never;
}
export interface DocumentImageSourcedFieldLocalized {
type: 'image';
localized: true;
source: string;
locales: Record<string, {
locale: string;
sourceData: any;
fields?: never;
}>;
}
export declare type ImageFields = {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
export declare type DocumentObjectField = DocumentObjectFieldNonLocalized | DocumentObjectFieldLocalized;

@@ -142,0 +161,0 @@ export interface DocumentObjectFieldNonLocalized {

@@ -21,3 +21,3 @@ /// <reference types="node" />

* cache the custom data with the rest of the {@link Schema} data. The cached
* {@link Schema} can be acquired using the {@link InitOptions.cache.getSchema}
* {@link Schema} can be retrieved using the {@link InitOptions.cache.getSchema}
* method provided to the {@link init} method.

@@ -32,10 +32,9 @@ * - `UserContext`: A generic type defining user-specific context properties

* cache the custom data with the rest of the {@link Document} data. The cached
* {@link Document} can be acquired using the {@link InitOptions.cache.getDocuments}
* {@link Document} can be retrieved using the {@link InitOptions.cache.getDocuments}
* and {@link InitOptions.cache.getDocumentById} methods provided to the
* {@link init} method.
* - `AssetContext`: A generic type the content source instance may use to store
* custom data in the {@link Asset.context} property. Stackbit will cache this
* data with the rest of the {@link Asset}. Stackbit will cache the custom
* data with the rest of the {@link Asset} data. The cached {@link Asset} can
* be acquired using the {@link InitOptions.cache.getAssets} and
* custom data in the {@link Asset.context} property. Stackbit will cache the
* custom data with the rest of the {@link Asset} data. The cached {@link Asset}
* can be retrieved using the {@link InitOptions.cache.getAssets} and
* {@link InitOptions.cache.getAssetById} methods provided to the {@link init}

@@ -96,9 +95,2 @@ * method.

*
* This method should start watching for content and schema changes using
* any available synchronization technique. For example, the content source
* may start polling the underlying API, set up server-to-server listeners
* or webhooks. When the content source module detects a change in the
* content or the schema, it should call the {@link InitOptions.cache.updateContent}
* or the {@link InitOptions.cache.invalidateSchema} callbacks.
*
* The content source instance should remain stateless and should not store

@@ -294,3 +286,3 @@ * models, documents, or assets. After initializing the content source,

* The `createDocument` method should create a document in the underlying
* content source and return the created document as a Stackbit Document.
* content source and return the id of the created document.
*

@@ -297,0 +289,0 @@ * @param {Object} options

@@ -10,5 +10,7 @@ export * from './config';

export * from './content-source-operation';
export * from './asset-source';
export * from './utils';
export * from './utility-types';
export * from './sidebar-button';
export * from './config-delegate';
//# sourceMappingURL=index.d.ts.map

@@ -26,5 +26,7 @@ "use strict";

__exportStar(require("./content-source-operation"), exports);
__exportStar(require("./asset-source"), exports);
__exportStar(require("./utils"), exports);
__exportStar(require("./utility-types"), exports);
__exportStar(require("./sidebar-button"), exports);
__exportStar(require("./config-delegate"), exports);
//# sourceMappingURL=index.js.map
import type { Version } from './content-source';
import type { FieldType, Field, FieldForType } from './model-fields';
import type { FieldType, Field, FieldForType, FieldSpecificProps, FieldSpecificPropsForType } from './model-fields';
import type { StackbitConfig } from './config';
import type { AssetFileField, AssetFileFieldLocalized } from './content-source-document';
import type { DocumentField, DocumentFieldForType, DocumentFieldLocalized, DocumentFieldNonLocalizedForType } from './content-source-document-fields';
export declare type Simplify<T> = {
[K in keyof T]: T[K];
};
export declare function getInterfaceVersion(): Promise<any>;

@@ -54,4 +51,5 @@ export declare function getVersion(options?: {

export declare function isModelFieldOneOfFieldTypes<T extends FieldType>(modelField: Field, fieldTypes: ReadonlyArray<T>): modelField is FieldForType<T>;
export declare function isModelFieldSpecificPropsOneOfFieldTypes<T extends FieldType>(modelField: FieldSpecificProps, fieldTypes: ReadonlyArray<T>): modelField is FieldSpecificPropsForType<T>;
export declare function isDocumentFieldOneOfFieldTypes<T extends FieldType>(documentField: DocumentField, fieldTypes: ReadonlyArray<T>): documentField is DocumentFieldForType<T>;
export declare function defineStackbitConfig(stackbitConfig: StackbitConfig): StackbitConfig;
//# sourceMappingURL=utils.d.ts.map

@@ -29,3 +29,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.defineStackbitConfig = exports.isDocumentFieldOneOfFieldTypes = exports.isModelFieldOneOfFieldTypes = exports.isOneOfFieldTypes = exports.getLocalizedFieldForLocale = exports.isLocalizedField = exports.getVersion = exports.getInterfaceVersion = void 0;
exports.defineStackbitConfig = exports.isDocumentFieldOneOfFieldTypes = exports.isModelFieldSpecificPropsOneOfFieldTypes = exports.isModelFieldOneOfFieldTypes = exports.isOneOfFieldTypes = exports.getLocalizedFieldForLocale = exports.isLocalizedField = exports.getVersion = exports.getInterfaceVersion = void 0;
const path_1 = __importDefault(require("path"));

@@ -126,2 +126,6 @@ async function getInterfaceVersion() {

exports.isModelFieldOneOfFieldTypes = isModelFieldOneOfFieldTypes;
function isModelFieldSpecificPropsOneOfFieldTypes(modelField, fieldTypes) {
return fieldTypes.includes(modelField.type);
}
exports.isModelFieldSpecificPropsOneOfFieldTypes = isModelFieldSpecificPropsOneOfFieldTypes;
function isDocumentFieldOneOfFieldTypes(documentField, fieldTypes) {

@@ -128,0 +132,0 @@ return fieldTypes.includes(documentField.type);

{
"name": "@stackbit/types",
"version": "0.5.2-develop.1",
"version": "0.5.2-staging.1",
"description": "Types for Stackbit config and Content Source Interface",

@@ -42,3 +42,3 @@ "main": "dist/index.js",

},
"gitHead": "66fa5aa4a47535f97733faa7bde403f22f942446"
"gitHead": "56fbbb28ee77ce4a3bf528bd00af43996de26d6f"
}

@@ -6,2 +6,3 @@ import type { ContentSourceInterface } from './content-source';

import { SidebarButton } from './sidebar-button';
import { AssetSource } from './asset-source';

@@ -74,3 +75,4 @@ export interface StackbitConfig {

contentSources?: ContentSourceInterface<any, any, any>[];
contentSources?: ContentSourceInterface<any, any, any, any>[];
assetSources?: AssetSource[];
mapModels?: (options: { models: ModelWithSource[] }) => ModelWithSource[];

@@ -77,0 +79,0 @@ mapDocuments?: (options: { documents: DocumentWithSource[]; models: ModelWithSource[] }) => DocumentWithSource[];

@@ -235,20 +235,20 @@ import { FieldType, StyleProps } from './model-fields';

// image
export type DocumentImageField = DocumentImageFieldNonLocalized | DocumentImageFieldLocalized;
export type DocumentImageField = DocumentImageURLField | DocumentImageSourcedField;
export type DocumentImageURLField = DocumentImageURLFieldNonLocalized | DocumentImageURLFieldLocalized;
export type DocumentImageSourcedField = DocumentImageSourcedFieldNonLocalized | DocumentImageSourcedFieldLocalized;
export type DocumentImageFieldNonLocalized = DocumentImageURLFieldNonLocalized | DocumentImageSourcedFieldNonLocalized;
export type DocumentImageFieldLocalized = DocumentImageURLFieldLocalized | DocumentImageSourcedFieldLocalized;
export interface DocumentImageFieldNonLocalized {
export interface DocumentImageURLFieldNonLocalized {
type: 'image';
localized?: false;
source?: string;
sourceData?: any;
fields: {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
source?: never;
sourceData?: never;
fields: ImageFields;
}
export interface DocumentImageFieldLocalized {
export interface DocumentImageURLFieldLocalized {
type: 'image';
localized: true;
source?: string;
sourceData?: any;
source?: never;
locales: Record<

@@ -258,6 +258,4 @@ string,

locale: string;
fields: {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
sourceData?: never;
fields: ImageFields;
}

@@ -267,2 +265,29 @@ >;

export interface DocumentImageSourcedFieldNonLocalized {
type: 'image';
localized?: false;
source: string;
sourceData: any;
fields?: never;
}
export interface DocumentImageSourcedFieldLocalized {
type: 'image';
localized: true;
source: string;
locales: Record<
string,
{
locale: string;
sourceData: any;
fields?: never;
}
>;
}
export type ImageFields = {
title: DocumentStringLikeFieldForType<'string'>;
url: DocumentStringLikeFieldForType<'string'>;
};
// object

@@ -269,0 +294,0 @@ export type DocumentObjectField = DocumentObjectFieldNonLocalized | DocumentObjectFieldLocalized;

@@ -20,3 +20,3 @@ import type { ChildProcessWithoutNullStreams } from 'child_process';

* cache the custom data with the rest of the {@link Schema} data. The cached
* {@link Schema} can be acquired using the {@link InitOptions.cache.getSchema}
* {@link Schema} can be retrieved using the {@link InitOptions.cache.getSchema}
* method provided to the {@link init} method.

@@ -31,10 +31,9 @@ * - `UserContext`: A generic type defining user-specific context properties

* cache the custom data with the rest of the {@link Document} data. The cached
* {@link Document} can be acquired using the {@link InitOptions.cache.getDocuments}
* {@link Document} can be retrieved using the {@link InitOptions.cache.getDocuments}
* and {@link InitOptions.cache.getDocumentById} methods provided to the
* {@link init} method.
* - `AssetContext`: A generic type the content source instance may use to store
* custom data in the {@link Asset.context} property. Stackbit will cache this
* data with the rest of the {@link Asset}. Stackbit will cache the custom
* data with the rest of the {@link Asset} data. The cached {@link Asset} can
* be acquired using the {@link InitOptions.cache.getAssets} and
* custom data in the {@link Asset.context} property. Stackbit will cache the
* custom data with the rest of the {@link Asset} data. The cached {@link Asset}
* can be retrieved using the {@link InitOptions.cache.getAssets} and
* {@link InitOptions.cache.getAssetById} methods provided to the {@link init}

@@ -105,9 +104,2 @@ * method.

*
* This method should start watching for content and schema changes using
* any available synchronization technique. For example, the content source
* may start polling the underlying API, set up server-to-server listeners
* or webhooks. When the content source module detects a change in the
* content or the schema, it should call the {@link InitOptions.cache.updateContent}
* or the {@link InitOptions.cache.invalidateSchema} callbacks.
*
* The content source instance should remain stateless and should not store

@@ -305,3 +297,3 @@ * models, documents, or assets. After initializing the content source,

* The `createDocument` method should create a document in the underlying
* content source and return the created document as a Stackbit Document.
* content source and return the id of the created document.
*

@@ -308,0 +300,0 @@ * @param {Object} options

@@ -10,4 +10,6 @@ export * from './config';

export * from './content-source-operation';
export * from './asset-source';
export * from './utils';
export * from './utility-types';
export * from './sidebar-button';
export * from './config-delegate';
import path from 'path';
import type { Version } from './content-source';
import type { FieldType, Field, FieldForType } from './model-fields';
import type { FieldType, Field, FieldForType, FieldSpecificProps, FieldSpecificPropsForType } from './model-fields';
import type { StackbitConfig } from './config';

@@ -13,6 +13,2 @@ import type { AssetFileField, AssetFileFieldLocalized } from './content-source-document';

export type Simplify<T> = {
[K in keyof T]: T[K];
};
export async function getInterfaceVersion() {

@@ -123,2 +119,9 @@ const packageJson = await import(path.join(__dirname, '../package.json'));

export function isModelFieldSpecificPropsOneOfFieldTypes<T extends FieldType>(
modelField: FieldSpecificProps,
fieldTypes: ReadonlyArray<T>
): modelField is FieldSpecificPropsForType<T> {
return fieldTypes.includes(modelField.type as T);
}
export function isDocumentFieldOneOfFieldTypes<T extends FieldType>(

@@ -125,0 +128,0 @@ documentField: DocumentField,

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc