UNPKG

2.54 kBTypeScriptView Raw
1export default mosaic;
2export type FileObject = {
3 /**
4 * - the location of the file on disk
5 */
6 filepath: string;
7 /**
8 * - the file content
9 */
10 content: string;
11};
12export type Server = {
13 /**
14 * - the port to serve on
15 */
16 port?: string;
17 /**
18 * - An optional static path
19 */
20 staticPath?: string;
21 /**
22 * - A dictionary of key value pairs, where each key is the name of a route path, and the value is the string content that should be served for that route
23 */
24 routes: {
25 [x: string]: string;
26 };
27};
28export type OutputMapFn = any;
29/**
30 * - Mosaic configuration
31 */
32export type Config = {
33 /**
34 * - a dictionary of key value pairs where key is the name of a set of files and value is a glob pattern describing the location of those files on disk
35 */
36 input: {
37 [x: string]: string;
38 };
39 /**
40 * - an array of functions to be called in series in order to transform the input
41 */
42 transform: Function[];
43 /**
44 * - a function that takes the output of the transform pipeline and then returns an FileObject array representing the files to be saved to disk
45 */
46 output: any;
47 /**
48 * - optionally serve files using an express server
49 */
50 serve?: Server;
51};
52/**
53 * @typedef {object} FileObject
54 * @property {string} filepath - the location of the file on disk
55 * @property {string} content - the file content
56 */
57/**
58 *
59 * @typedef {object} Server
60 * @property {string} [port=3000] - the port to serve on
61 * @property {string} [staticPath] - An optional static path
62 * @property {Object.<string, string>} routes - A dictionary of key value pairs, where each key is the name of a route path, and the value is the string content that should be served for that route
63 *
64 */
65/**
66 * @typedef OutputMapFn
67 *
68 * @returns {FileObject[]}
69 */
70/**
71 *
72 * @typedef {Object} Config - Mosaic configuration
73 * @property {Object.<string,string>} input - a dictionary of key value pairs where key is the name of a set of files and value is a glob pattern describing the location of those files on disk
74 * @property {function[]} transform - an array of functions to be called in series in order to transform the input
75 * @property {OutputMapFn} output - a function that takes the output of the transform pipeline and then returns an FileObject array representing the files to be saved to disk
76 * @property {Server} [serve] - optionally serve files using an express server
77 *
78 */
79/**
80 *
81 * @param {Config} config
82 *
83 * @returns {Promise<void>}
84 */
85declare function mosaic(config: Config): Promise<void>;