@stackbit/cms-core 0.0.3
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/annotator/html.d.ts +1 -0
- package/dist/annotator/html.js +54 -0
- package/dist/annotator/html.js.map +1 -0
- package/dist/annotator/index.d.ts +13 -0
- package/dist/annotator/index.js +120 -0
- package/dist/annotator/index.js.map +1 -0
- package/dist/annotator/react.d.ts +1 -0
- package/dist/annotator/react.js +53 -0
- package/dist/annotator/react.js.map +1 -0
- package/dist/consts.d.ts +27 -0
- package/dist/consts.js +43 -0
- package/dist/consts.js.map +1 -0
- package/dist/encoder.d.ts +8 -0
- package/dist/encoder.js +272 -0
- package/dist/encoder.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/stackbit/index.d.ts +4 -0
- package/dist/stackbit/index.js +54 -0
- package/dist/stackbit/index.js.map +1 -0
- package/dist/utils/index.d.ts +172 -0
- package/dist/utils/index.js +928 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +43 -0
- package/src/annotator/html.js +55 -0
- package/src/annotator/index.js +135 -0
- package/src/annotator/react.js +56 -0
- package/src/consts.js +41 -0
- package/src/encoder.js +315 -0
- package/src/index.js +13 -0
- package/src/stackbit/index.js +55 -0
- package/src/utils/index.js +997 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const encodeData = require('./encoder');
|
|
3
|
+
const stackbit = require('./stackbit');
|
|
4
|
+
const annotator = require('./annotator');
|
|
5
|
+
const utils = require('./utils');
|
|
6
|
+
const consts = require('./consts');
|
|
7
|
+
module.exports = {
|
|
8
|
+
utils,
|
|
9
|
+
consts,
|
|
10
|
+
annotator,
|
|
11
|
+
encodeData,
|
|
12
|
+
stackbit
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAAA,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AACzC,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEnC,MAAM,CAAC,OAAO,GAAG;IACb,KAAK;IACL,MAAM;IACN,SAAS;IACT,UAAU;IACV,QAAQ;CACX,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const _ = require('lodash');
|
|
3
|
+
const { loadConfig, isListDataModel } = require('@stackbit/sdk');
|
|
4
|
+
module.exports = {
|
|
5
|
+
fetchAndConvertSchema
|
|
6
|
+
};
|
|
7
|
+
function fetchAndConvertSchema(options) {
|
|
8
|
+
return loadConfig({ dirPath: options.dirPath }).then(({ config, errors }) => {
|
|
9
|
+
if (!config) {
|
|
10
|
+
return { schema: {}, errors };
|
|
11
|
+
}
|
|
12
|
+
wrapListDataModels(config);
|
|
13
|
+
const schema = _.pick(config, [
|
|
14
|
+
'stackbitVersion',
|
|
15
|
+
'ssgName',
|
|
16
|
+
'ssgVersion',
|
|
17
|
+
'nodeVersion',
|
|
18
|
+
'devCommand',
|
|
19
|
+
'cmsName',
|
|
20
|
+
'import',
|
|
21
|
+
'publishDir',
|
|
22
|
+
'staticDir',
|
|
23
|
+
'uploadDir',
|
|
24
|
+
'assets',
|
|
25
|
+
'dataDir',
|
|
26
|
+
'pagesDir',
|
|
27
|
+
'pageLayoutKey',
|
|
28
|
+
'objectTypeKey',
|
|
29
|
+
'excludePages',
|
|
30
|
+
'logicFields',
|
|
31
|
+
'contentModels',
|
|
32
|
+
'modelsSource',
|
|
33
|
+
'models',
|
|
34
|
+
'presets'
|
|
35
|
+
]);
|
|
36
|
+
return { schema, errors };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function wrapListDataModels(config) {
|
|
40
|
+
_.forEach(config.models, (model) => {
|
|
41
|
+
if (!isListDataModel(model)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
_.set(model, 'fields', [
|
|
45
|
+
{
|
|
46
|
+
type: 'list',
|
|
47
|
+
name: 'items',
|
|
48
|
+
items: model.items
|
|
49
|
+
}
|
|
50
|
+
]);
|
|
51
|
+
_.unset(model, 'items');
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stackbit/index.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEjE,MAAM,CAAC,OAAO,GAAG;IACb,qBAAqB;CACxB,CAAC;AAEF,SAAS,qBAAqB,CAAC,OAAO;IAClC,OAAO,UAAU,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;QACxE,IAAI,CAAC,MAAM,EAAE;YACT,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;SACjC;QACD,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;YAC1B,iBAAiB;YACjB,SAAS;YACT,YAAY;YACZ,aAAa;YACb,YAAY;YACZ,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,WAAW;YACX,WAAW;YACX,QAAQ;YACR,SAAS;YACT,UAAU;YACV,eAAe;YACf,eAAe;YACf,cAAc;YACd,aAAa;YACb,eAAe;YACf,cAAc;YACd,QAAQ;YACR,SAAS;SACZ,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAM;IAC9B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAC/B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE;YACzB,OAAO;SACV;QACD,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE;YACnB;gBACI,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,KAAK,CAAC,KAAK;aACrB;SACJ,CAAC,CAAC;QACH,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterates over array items and invokes callback function for each of them.
|
|
3
|
+
* The callback must return a promise and is called with three parameters: array item,
|
|
4
|
+
* item index, array itself. Callbacks are invoked serially, such that callback for the
|
|
5
|
+
* following item will not be called until the promise returned from the previous callback
|
|
6
|
+
* is not fulfilled.
|
|
7
|
+
*
|
|
8
|
+
* @param {array} array
|
|
9
|
+
* @param {function} callback
|
|
10
|
+
* @param {object} [thisArg]
|
|
11
|
+
* @return {Promise<any>}
|
|
12
|
+
*/
|
|
13
|
+
export function forEachPromise(array: any, callback: Function, thisArg?: object | undefined): Promise<any>;
|
|
14
|
+
export function mapPromise(array: any, callback: any, thisArg: any): Promise<any>;
|
|
15
|
+
export function reducePromise(array: any, callback: any, initValue: any, thisArg: any): Promise<any>;
|
|
16
|
+
export function findPromise(array: any, callback: any, thisArg: any): Promise<any>;
|
|
17
|
+
export function promiseAllMap(array: any, limit: any, interval: any, callback: any, thisArg: any): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Recursively copies files from source to target directories.
|
|
20
|
+
* The optional "options" argument is an object with an optional "processNunjucksFile"
|
|
21
|
+
* and "filePathMap" fields.
|
|
22
|
+
*
|
|
23
|
+
* If "processNunjucksFile" function is passed, it will be invoked for every file with ".njk"
|
|
24
|
+
* extension with a filepath relative to the sourceDir as its single argument.
|
|
25
|
+
* This function should return the result of processing Nunjucks template.
|
|
26
|
+
*
|
|
27
|
+
* Files named _gitignore will be copied as .gitignore
|
|
28
|
+
*
|
|
29
|
+
* @param {string} sourceDir
|
|
30
|
+
* @param {string} targetDir
|
|
31
|
+
* @param {object} [options]
|
|
32
|
+
* @param {Function} options.processNunjucksFile Function that receives filePath
|
|
33
|
+
* relative to sourceDir and returns processed file data to be stored inside targetDir
|
|
34
|
+
* @param {object} options.filePathMap Map between source and target file paths.
|
|
35
|
+
* If mapped value is null, the file will not be copied.
|
|
36
|
+
*/
|
|
37
|
+
export function copyFilesRecursively(sourceDir: string, targetDir: string, options?: {
|
|
38
|
+
processNunjucksFile: Function;
|
|
39
|
+
filePathMap: object;
|
|
40
|
+
} | undefined, _internalOptions: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* Copies the value at a sourcePath of the sourceObject to a targetPath of the targetObject.
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} sourceObject
|
|
45
|
+
* @param {String} sourcePath
|
|
46
|
+
* @param {Object} targetObject
|
|
47
|
+
* @param {String} targetPath
|
|
48
|
+
* @param {Function} [transform]
|
|
49
|
+
*/
|
|
50
|
+
export function copy(sourceObject: Object, sourcePath: string, targetObject: Object, targetPath: string, transform?: Function | undefined): void;
|
|
51
|
+
export function copyDefault(sourceObject: any, sourcePath: any, targetObject: any, targetPath: any, transform: any): void;
|
|
52
|
+
export function mergeAtPath(object: any, path: any, source: any): any;
|
|
53
|
+
export function omitByNil(object: any): any;
|
|
54
|
+
export function rename(object: any, oldPath: any, newPath: any): void;
|
|
55
|
+
export function append(object: any, path: any, value: any): void;
|
|
56
|
+
export function concat(object: any, path: any, value: any): void;
|
|
57
|
+
export function indent(str: any, indent: any, indentFirst?: boolean): any;
|
|
58
|
+
export function pascalCase(str: any): any;
|
|
59
|
+
export function readDirRec(dir: any, options: any): Promise<any>;
|
|
60
|
+
export function readDirRecSync(dir: any, options: any): any[];
|
|
61
|
+
export function readDirGlob(dir: any, options: any): Promise<any>;
|
|
62
|
+
export function fieldPathToString(fieldPath: any): any;
|
|
63
|
+
export function hrtimeAndPrint(time: any): string | undefined;
|
|
64
|
+
export function printHRTime(time: any): string | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Recursively iterates over elements of a collection and invokes iteratee for each element.
|
|
67
|
+
*
|
|
68
|
+
* @param {*} value The value to iterate
|
|
69
|
+
* @param {Function} iteratee The iteratee function
|
|
70
|
+
* @param {string|number} key The key of the `value` if the `object` is an Object, or the index of the `value` if the `object` is an Array
|
|
71
|
+
* @param {Object} object The parent object of `value`.
|
|
72
|
+
*/
|
|
73
|
+
export function forEachDeep(value: any, iteratee: Function, key: string | number, object: Object): void;
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @param {*} value
|
|
77
|
+
* @param {Function} iteratee Function (value: any, fieldPath: Array, stack: Array)
|
|
78
|
+
* @param {object} [options]
|
|
79
|
+
* @param {boolean} options.iterateCollections. Default: true
|
|
80
|
+
* @param {boolean} options.iterateScalars. Default: true
|
|
81
|
+
* @returns {*}
|
|
82
|
+
*/
|
|
83
|
+
export function mapDeep(value: any, iteratee: Function, options?: object | undefined, _keyPath: any, _objectStack: any): any;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the value at the first path of object having non undefined value.
|
|
86
|
+
* If all paths resolve to undefined values, the defaultValue is returned.
|
|
87
|
+
*
|
|
88
|
+
* @param {Object} object The object to query.
|
|
89
|
+
* @param {Array<String | Array<String>>} paths The property paths to search for.
|
|
90
|
+
* @param {*} [defaultValue] The value returned if all paths resolve to undefined values
|
|
91
|
+
* @returns {*}
|
|
92
|
+
*/
|
|
93
|
+
export function getFirst(object: Object, paths: Array<string | Array<string>>, defaultValue?: any): any;
|
|
94
|
+
export function getFirstExistingFile(fileNames: any, inputDir: any): Promise<any>;
|
|
95
|
+
export function parseFirstExistingFile(fileNames: any, inputDir: any): Promise<any>;
|
|
96
|
+
export function getFirstExistingFileSync(fileNames: any, inputDir: any): any;
|
|
97
|
+
export function parseFirstExistingFileSync(fileNames: any, inputDir: any): any;
|
|
98
|
+
export function parseFile(filePath: any): any;
|
|
99
|
+
export function parseFileSync(filePath: any): any;
|
|
100
|
+
export function parseDataByFilePath(string: any, filePath: any): any;
|
|
101
|
+
export function outputData(filePath: any, data: any): any;
|
|
102
|
+
export function outputDataSync(filePath: any, data: any): void;
|
|
103
|
+
export function outputDataIfNeeded(filePath: any, data: any): Promise<boolean>;
|
|
104
|
+
export function stringifyDataByFilePath(data: any, filePath: any): any;
|
|
105
|
+
export function parseMarkdownWithFrontMatter(string: any): {
|
|
106
|
+
frontmatter: null;
|
|
107
|
+
markdown: any;
|
|
108
|
+
};
|
|
109
|
+
export function deepFreeze(obj: any): any;
|
|
110
|
+
export function failFunctionWithTag(tag: any): (message: any) => never;
|
|
111
|
+
export function assertFunctionWithFail(fail: any): (value: any, message: any) => void;
|
|
112
|
+
export function createLogger(scope: any, transport: any): {};
|
|
113
|
+
export function logObject(object: any, title: any): void;
|
|
114
|
+
export function joinPathAndGlob(pathStr: any, glob: any): any;
|
|
115
|
+
export function globToArray(glob: any): any;
|
|
116
|
+
/**
|
|
117
|
+
* Inverse of _.toPath()
|
|
118
|
+
*
|
|
119
|
+
* fromPath(['foo', 'hello.world', 'bar'])
|
|
120
|
+
* => 'foo["hello.world"].bar'
|
|
121
|
+
*
|
|
122
|
+
* @param {Array} pathArray
|
|
123
|
+
* @return {String}
|
|
124
|
+
*/
|
|
125
|
+
export function fromPath(pathArray: any[]): string;
|
|
126
|
+
export function omitDeep(object: any, paths: any): any;
|
|
127
|
+
/**
|
|
128
|
+
* Reduces the provided `data` using the provided reducer function `reducerFunc`
|
|
129
|
+
* into an object with `data` and `errors` attributes.
|
|
130
|
+
*
|
|
131
|
+
* For every item in the provided `data, the reducer function is invoked with
|
|
132
|
+
* `value` and `key` arguments. The reducer function should return an object
|
|
133
|
+
* with optional `data` and `error` properties, or `null`.
|
|
134
|
+
*
|
|
135
|
+
* ```
|
|
136
|
+
* reducerFunc(value, key) => { data, errors }
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* When reducer function returns an object with a `data` property, its value
|
|
140
|
+
* is added to the `data` property of final result. If the original `data` is an
|
|
141
|
+
* object, then the `data` returned by the reducer function is added under the
|
|
142
|
+
* same `key` that was passed to the reducer function. If the original `data` is
|
|
143
|
+
* an array, then the value is pushed to the reduced data.
|
|
144
|
+
* If `data` property is missing, the reduced data will not include that item.
|
|
145
|
+
*
|
|
146
|
+
* When reducer function returns an object with `errors`, which can be an array
|
|
147
|
+
* of error messages or a single error message, these errors are added to the
|
|
148
|
+
* reduced result under `errors` property.
|
|
149
|
+
*
|
|
150
|
+
* @param {Array|Object} data
|
|
151
|
+
* @param {Function} reducerFunc
|
|
152
|
+
* @return {{data: Array|Object, errors: Array}}
|
|
153
|
+
*/
|
|
154
|
+
export function dataReducerSync(data: any[] | Object, reducerFunc: Function): {
|
|
155
|
+
data: any[] | Object;
|
|
156
|
+
errors: any[];
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Same as dataReducerSync but receives asynchronous reducerFunc
|
|
160
|
+
*
|
|
161
|
+
* @param {Array|Object} data
|
|
162
|
+
* @param {Function} reducerFunc
|
|
163
|
+
* @return {{data: Array|Object, errors: Array}}
|
|
164
|
+
*/
|
|
165
|
+
export function dataReducer(data: any[] | Object, reducerFunc: Function): {
|
|
166
|
+
data: any[] | Object;
|
|
167
|
+
errors: any[];
|
|
168
|
+
};
|
|
169
|
+
export function encodeJsx(data: any): any;
|
|
170
|
+
export function decodeJsx(data: any): any;
|
|
171
|
+
export function replaceInRange(str: any, range: any, stringToInsert: any): any;
|
|
172
|
+
export function isRelevantReactData(data: any): any;
|