Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackbit/cms-core

Package Overview
Dependencies
Maintainers
13
Versions
454
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackbit/cms-core - npm Package Compare versions

Comparing version 0.0.19-alpha.1 to 0.0.19

dist/utils/lazy-poller.d.ts

1

dist/annotator/html.d.ts
export function createAnnotations(filePath: any, data: any, logger: any): Promise<any[] | null>;
//# sourceMappingURL=html.d.ts.map

@@ -1,3 +0,3 @@

export function annotateDir(inputDir: any, outputDir: any, logger: any, options?: {}): Promise<any[]>;
export function annotateFiles(filePaths: any, inputDir: any, outputDir: any, logger: any, options?: {}): Promise<any[]>;
export function annotateDir(inputDir: any, outputDir: any, logger: any, options?: {}): Promise<any>;
export function annotateFiles(filePaths: any, inputDir: any, outputDir: any, logger: any, options?: {}): Promise<any>;
export function decodeSourcemap(attributes: any): {

@@ -14,2 +14,1 @@ file: any;

} | undefined;
//# sourceMappingURL=index.d.ts.map
export function createAnnotations(filePath: any, data: any, logger: any): Promise<any[] | null>;
//# sourceMappingURL=react.d.ts.map

@@ -1,3 +0,10 @@

import type { ImageModel } from '@stackbit/sdk';
export declare const IMAGE_MODEL: ImageModel;
//# sourceMappingURL=common-schema.d.ts.map
export namespace IMAGE_MODEL {
const type: string;
const name: string;
const label: string;
const labelField: string;
const fields: {
name: string;
type: string;
}[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IMAGE_MODEL = void 0;
exports.IMAGE_MODEL = {
const IMAGE_MODEL = {
type: 'image',

@@ -14,2 +12,5 @@ name: '__image_model',

};
module.exports = {
IMAGE_MODEL
};
//# sourceMappingURL=common-schema.js.map

@@ -28,2 +28,1 @@ export declare const RICH_TEXT_NODE_TYPES: {

export declare const LOADER_EXCLUDED_DIRS: string[];
//# sourceMappingURL=consts.d.ts.map

@@ -1,37 +0,8 @@

export declare type FieldData = Record<string, FieldDataRootItem>;
export interface FieldDataItem {
type: 'object';
srcObjectLabel: string;
srcModelName: string;
srcModelLabel: string;
fields: Record<string, any>;
}
export interface FieldDataRootItem extends Omit<FieldDataItem, 'type'> {
type: 'object' | 'image' | 'file';
srcType: string;
srcProjectId: string;
srcProjectUrl: string;
srcEnvironment: string;
srcObjectId: string;
srcObjectUrl: string;
isChanged: boolean;
status: 'modified' | 'added' | 'deleted' | 'published';
createdAt: string;
createdBy?: string;
updatedAt: string;
updatedBy?: string[];
}
export interface EncodingResult {
fieldData: FieldData;
encodedData?: any[];
hashedData?: Record<string, any>;
fieldDataPaths?: string[];
}
export interface EncodeDataOptions {
data: any[];
prevEncodingResult?: EncodingResult | null;
export = encodeData;
declare function encodeData({ data, prevEncodingResult, delegate }: {
data: any;
prevEncodingResult: any;
delegate: any;
encodeDelimiter: string;
}
export default function encodeData({ data, prevEncodingResult, delegate }: EncodeDataOptions): EncodingResult;
//# sourceMappingURL=encoder.d.ts.map
}): {
fieldData: any;
};
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
const consts = __importStar(require("./consts"));
const utils_1 = require("./utils");
const _ = require('lodash');
const consts = require('./consts');
const { mergeAtPath, omitByNil } = require('./utils');
function mapObjectFields({ data, model, fieldDataPath, fieldDataPathsInverted, fieldModelPath, encodeValue, delegate }) {

@@ -35,4 +12,4 @@ if (!fieldModelPath) {

const fields = delegate.getItemFields(data, model);
return lodash_1.default.reduce(fields, (accum, field) => {
const fieldModel = lodash_1.default.find(model.fields, { name: field.name });
return _.reduce(fields, (accum, field) => {
const fieldModel = _.find(model.fields, { name: field.name });
// if field model wasn't found ignore this field

@@ -43,11 +20,11 @@ if (!fieldModel) {

// don't include const fields
if (lodash_1.default.has(fieldModel, 'const')) {
if (_.has(fieldModel, 'const')) {
return accum;
}
let childFieldModelPath;
if (lodash_1.default.get(model, 'isList') && field.name === 'items') {
if (_.get(model, 'isList') && field.name === 'items') {
childFieldModelPath = fieldModelPath;
}
else {
childFieldModelPath = lodash_1.default.concat(fieldModelPath, field.name);
childFieldModelPath = _.concat(fieldModelPath, field.name);
}

@@ -57,7 +34,7 @@ const fieldPath = ['fields', field.name];

const localePath = fieldModel.localized ? ['locales', localizedField.locale] : [];
const fullFieldDataPath = lodash_1.default.concat(fieldPath, localePath);
const fullFieldDataPath = _.concat(fieldPath, localePath);
const mappedData = mapField({
fieldValue: localizedField.value,
fieldModel: fieldModel,
fieldDataPath: lodash_1.default.concat(fieldDataPath, fullFieldDataPath),
fieldDataPath: _.concat(fieldDataPath, fullFieldDataPath),
fieldDataPaths: accum.fieldDataPaths,

@@ -72,12 +49,12 @@ fieldDataPathsInverted: fieldDataPathsInverted,

return {
fieldData: (0, utils_1.mergeAtPath)(accum.fieldData, fullFieldDataPath, (0, utils_1.omitByNil)(mappedData.fieldData))
fieldData: mergeAtPath(accum.fieldData, fullFieldDataPath, omitByNil(mappedData.fieldData))
};
};
// always create 'fields' as object, even for objects that have field names as numbers
lodash_1.default.setWith(accum.fieldData, fieldPath, fieldModelToFieldData(fieldModel), Object);
_.setWith(accum.fieldData, fieldPath, fieldModelToFieldData(fieldModel), Object);
if (fieldModel.localized) {
accum = mapLocalizedField(accum, { locale: '_unset' });
}
if (lodash_1.default.has(field, 'locales')) {
return lodash_1.default.reduce(field.locales, (accum, localizedField) => {
if (_.has(field, 'locales')) {
return _.reduce(field.locales, (accum, localizedField) => {
return mapLocalizedField(accum, localizedField);

@@ -92,3 +69,3 @@ }, accum);

function mapField({ fieldValue, fieldModel, fieldDataPath, fieldModelPath, delegate }) {
if (lodash_1.default.includes(consts.SIMPLE_VALUE_FIELDS, fieldModel.type)) {
if (_.includes(consts.SIMPLE_VALUE_FIELDS, fieldModel.type)) {
return {

@@ -104,5 +81,5 @@ fieldData: { value: fieldValue }

else if (fieldModel.type === 'list') {
const itemsModel = lodash_1.default.get(fieldModel, 'items');
const itemsModel = _.get(fieldModel, 'items');
let getListItemModel;
if (lodash_1.default.isArray(itemsModel)) {
if (_.isArray(itemsModel)) {
// in Sanity, list items may have multiple types, in this case, 'items' will be an array

@@ -113,6 +90,6 @@ getListItemModel = (listItem, fieldModel) => delegate.getItemTypeForListItem(listItem, fieldModel);

// get the type of list items, if type is not defined, set string as it is the default
const listItemsType = lodash_1.default.get(itemsModel, 'type', 'string');
getListItemModel = lodash_1.default.constant(lodash_1.default.defaults({}, itemsModel, { type: listItemsType }));
const listItemsType = _.get(itemsModel, 'type', 'string');
getListItemModel = _.constant(_.defaults({}, itemsModel, { type: listItemsType }));
}
return lodash_1.default.reduce(fieldValue, (accum, listItem, listIdx) => {
return _.reduce(fieldValue, (accum, listItem, listIdx) => {
const itemModel = getListItemModel(listItem, fieldModel);

@@ -122,3 +99,3 @@ let mappedData;

mappedData = unresolvedModel();
accum.fieldData.items = lodash_1.default.concat(accum.fieldData.items, mappedData.fieldData);
accum.fieldData.items = _.concat(accum.fieldData.items, mappedData.fieldData);
}

@@ -129,7 +106,7 @@ else {

fieldModel: itemModel,
fieldDataPath: lodash_1.default.concat(fieldDataPath, ['items', listIdx]),
fieldDataPath: _.concat(fieldDataPath, ['items', listIdx]),
fieldModelPath: fieldModelPath,
delegate
});
accum.fieldData.items = lodash_1.default.concat(accum.fieldData.items, fieldModelToFieldData(itemModel, mappedData.fieldData));
accum.fieldData.items = _.concat(accum.fieldData.items, fieldModelToFieldData(itemModel, mappedData.fieldData));
}

@@ -179,5 +156,5 @@ return {

}
const fieldModels = lodash_1.default.get(fieldModel, 'models', []);
const fieldModels = _.get(fieldModel, 'models', []);
const modelsByName = delegate.getModelsByName();
const model = fieldModels.length === 1 ? lodash_1.default.get(modelsByName, fieldModels[0]) : delegate.getModelForItemOfModelsType(fieldValue);
const model = fieldModels.length === 1 ? _.get(modelsByName, fieldModels[0]) : delegate.getModelForItemOfModelsType(fieldValue);
if (!model) {

@@ -198,8 +175,8 @@ return unresolvedModel();

if (encodedField) {
if (lodash_1.default.has(encodedField, 'fieldData')) {
lodash_1.default.assign(fieldData, encodedField.fieldData);
if (_.has(encodedField, 'fieldData')) {
_.assign(fieldData, encodedField.fieldData);
}
}
return {
fieldData: (0, utils_1.omitByNil)(fieldData)
fieldData: omitByNil(fieldData)
};

@@ -210,3 +187,3 @@ }

const type = ['reference', 'model'].includes(fieldModel.type) ? 'object' : fieldModel.type;
return (0, utils_1.omitByNil)(lodash_1.default.assign({
return omitByNil(_.assign({
type: type,

@@ -227,4 +204,4 @@ label: fieldModel.label,

? {
options: lodash_1.default.get(fieldModel, 'options', []),
source: lodash_1.default.get(fieldModel, 'source')
options: _.get(fieldModel, 'options', []),
source: _.get(fieldModel, 'source')
}

@@ -236,9 +213,9 @@ : null, overrides));

if (fieldType === 'reference' || fieldType === 'model') {
return lodash_1.default.clone(lodash_1.default.get(fieldModel, 'models', []));
return _.clone(_.get(fieldModel, 'models', []));
}
else if (fieldModel.type === 'list') {
const itemsModel = lodash_1.default.get(fieldModel, 'items');
const itemsModel = _.get(fieldModel, 'items');
// in Sanity, array can have items of multiple types
if (lodash_1.default.isArray(itemsModel)) {
return Array.from(lodash_1.default.reduce(itemsModel, (accum, itemModel) => {
if (_.isArray(itemsModel)) {
return Array.from(_.reduce(itemsModel, (accum, itemModel) => {
return new Set([...accum, ...(getFieldModelNames(itemModel) || [])]);

@@ -278,3 +255,3 @@ }, new Set()));

// scan model instances and replace their 'data' with an identity-mapped data
return lodash_1.default.reduce(data, (accum, item) => {
return _.reduce(data, (accum, item) => {
const model = delegate.getModelForRootItem(item);

@@ -296,10 +273,10 @@ if (!model) {

return {
fieldData: lodash_1.default.assign(accum.fieldData, { [itemId]: mappedData.fieldData })
fieldData: _.assign(accum.fieldData, { [itemId]: mappedData.fieldData })
};
}, {
fieldData: lodash_1.default.get(prevEncodingResult, 'fieldData', {})
fieldData: _.get(prevEncodingResult, 'fieldData', {})
});
}
function encodeData({ data, prevEncodingResult, delegate }) {
data = lodash_1.default.cloneDeep(data);
data = _.cloneDeep(data);
const mappedData = mapData(data, prevEncodingResult, delegate);

@@ -310,3 +287,3 @@ return {

}
exports.default = encodeData;
module.exports = encodeData;
//# sourceMappingURL=encoder.js.map

@@ -1,11 +0,6 @@

export * as stackbit from './stackbit';
export * as annotator from './annotator';
export * as utils from './utils';
export * as consts from './consts';
export * from './common/common-schema';
export * from './content-store';
export * as ContentSourceTypes from './content-source-interface';
export * as ContentStoreTypes from './content-store-types';
export { default as encodeData } from './encoder';
export * from './encoder';
//# sourceMappingURL=index.d.ts.map
import utils = require("./utils");
import consts = require("./consts");
import annotator = require("./annotator");
import encodeData = require("./encoder");
import stackbit = require("./stackbit");
export { utils, consts, annotator, encodeData, stackbit };
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
const encodeData = require('./encoder');
const stackbit = require('./stackbit');
const annotator = require('./annotator');
const utils = require('./utils');
const consts = require('./consts');
module.exports = {
utils,
consts,
annotator,
encodeData,
stackbit
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodeData = exports.ContentStoreTypes = exports.ContentSourceTypes = exports.consts = exports.utils = exports.annotator = exports.stackbit = void 0;
exports.stackbit = __importStar(require("./stackbit"));
exports.annotator = __importStar(require("./annotator"));
exports.utils = __importStar(require("./utils"));
exports.consts = __importStar(require("./consts"));
__exportStar(require("./common/common-schema"), exports);
__exportStar(require("./content-store"), exports);
exports.ContentSourceTypes = __importStar(require("./content-source-interface"));
exports.ContentStoreTypes = __importStar(require("./content-store-types"));
var encoder_1 = require("./encoder");
Object.defineProperty(exports, "encodeData", { enumerable: true, get: function () { return __importDefault(encoder_1).default; } });
__exportStar(require("./encoder"), exports);
//# sourceMappingURL=index.js.map

@@ -1,8 +0,4 @@

import { Config } from '@stackbit/sdk';
export declare function fetchAndConvertSchema(options: {
dirPath: string;
}): Promise<{
schema: Config;
errors: Error[];
export function fetchAndConvertSchema(options: any): Promise<{
schema: any;
errors: import("@stackbit/sdk").ConfigError[];
}>;
//# sourceMappingURL=index.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
const _ = require('lodash');
const { loadConfig, isListDataModel } = require('@stackbit/sdk');
module.exports = {
fetchAndConvertSchema
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchAndConvertSchema = void 0;
const lodash_1 = __importDefault(require("lodash"));
const sdk_1 = require("@stackbit/sdk");
function fetchAndConvertSchema(options) {
return (0, sdk_1.loadConfig)({ dirPath: options.dirPath }).then(({ config, errors }) => {
return loadConfig({ dirPath: options.dirPath }).then(({ config, errors }) => {
if (!config) {

@@ -15,3 +13,3 @@ return { schema: {}, errors };

wrapListDataModels(config);
const schema = lodash_1.default.pick(config, [
const schema = _.pick(config, [
'stackbitVersion',

@@ -42,9 +40,8 @@ 'ssgName',

}
exports.fetchAndConvertSchema = fetchAndConvertSchema;
function wrapListDataModels(config) {
lodash_1.default.forEach(config.models, (model) => {
if (!(0, sdk_1.isListDataModel)(model)) {
_.forEach(config.models, (model) => {
if (!isListDataModel(model)) {
return;
}
lodash_1.default.set(model, 'fields', [
_.set(model, 'fields', [
{

@@ -56,5 +53,5 @@ type: 'list',

]);
lodash_1.default.unset(model, 'items');
_.unset(model, 'items');
});
}
//# sourceMappingURL=index.js.map

@@ -53,3 +53,3 @@ /**

export function mergeAtPath(object: any, path: any, source: any): any;
export function omitByNil(object: any): Partial<any>;
export function omitByNil(object: any): any;
export function rename(object: any, oldPath: any, newPath: any): void;

@@ -59,7 +59,7 @@ export function append(object: any, path: any, value: any): void;

export function indent(str: any, indent: any, indentFirst?: boolean): any;
export function pascalCase(str: any): string;
export function readDirRec(dir: any, options: any): Promise<any[]>;
export function pascalCase(str: any): any;
export function readDirRec(dir: any, options: any): Promise<any>;
export function readDirRecSync(dir: any, options: any): any[];
export function readDirGlob(dir: any, options: any): Promise<any>;
export function fieldPathToString(fieldPath: any): string;
export function fieldPathToString(fieldPath: any): any;
export function hrtimeAndPrint(time: any): string | undefined;

@@ -98,3 +98,3 @@ export function printHRTime(time: any): string | undefined;

export function parseFirstExistingFile(fileNames: any, inputDir: any): Promise<any>;
export function getFirstExistingFileSync(fileNames: any, inputDir: any): string;
export function getFirstExistingFileSync(fileNames: any, inputDir: any): any;
export function parseFirstExistingFileSync(fileNames: any, inputDir: any): any;

@@ -117,4 +117,4 @@ export function parseFile(filePath: any): any;

export function logObject(object: any, title: any): void;
export function joinPathAndGlob(pathStr: any, glob: any): string[];
export function globToArray(glob: any): never[];
export function joinPathAndGlob(pathStr: any, glob: any): any;
export function globToArray(glob: any): any;
/**

@@ -178,2 +178,1 @@ * Inverse of _.toPath()

export function convertToPosixFilePath(filePath: any): any;
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,3 @@ export const FIELD_TYPES: string[];

export function isReferenceField(field: any): boolean;
export function isCustomModelField(field: any, modelsByName: any): boolean;
export function isCustomModelField(field: any, modelsByName: any): any;
export function isListField(field: any): boolean;

@@ -12,3 +12,3 @@ export function isListOfObjectsField(field: any): boolean;

export function isListOfModelsField(field: any): boolean;
export function isListOfCustomModelField(field: any): boolean;
export function isListOfCustomModelField(field: any): any;
export function isListOfReferenceField(field: any): boolean;

@@ -89,2 +89,1 @@ /**

export function getNormalizedModelType(stackbitModel: any): any;
//# sourceMappingURL=schema-utils.d.ts.map
{
"name": "@stackbit/cms-core",
"version": "0.0.19-alpha.1",
"version": "0.0.19",
"description": "stackbit-dev",

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

"devDependencies": {
"@types/lodash": "^4.14.182",
"jest": "^27.4.7",

@@ -32,4 +31,3 @@ "prettier": "^2.5.1",

"@iarna/toml": "^2.2.3",
"@stackbit/sdk": "^0.2.36-alpha.0",
"@stackbit/utils": "^0.2.4-alpha.0",
"@stackbit/sdk": "^0.2.37",
"chalk": "^4.0.1",

@@ -44,7 +42,5 @@ "esm": "^3.2.25",

"moment": "^2.29.1",
"parse5": "^6.0.1",
"sanitize-filename": "^1.6.3",
"slugify": "^1.6.5"
"parse5": "^6.0.1"
},
"gitHead": "320bb64ea35d20b488c1ed75f673d58b010519a4"
"gitHead": "2102ed599336f5b42c03e91636176d7e79b3fdde"
}

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