@jpmorganchase/mosaic-cli 0.1.0-beta.49 → 0.1.0-beta.51
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/chunk-CJK4LE4J.mjs +1 -0
- package/dist/chunk-K55TON6E.mjs +1 -0
- package/dist/chunk-KZGMXFBX.mjs +1 -0
- package/dist/chunk-WXWWLCIL.mjs +1 -0
- package/dist/index.mjs +1 -1
- package/dist/plugins/mosaicAdminPlugin.d.ts +15 -0
- package/dist/plugins/mosaicAdminPlugin.mjs +1 -0
- package/dist/plugins/mosaicFastifyPlugin.d.ts +20 -0
- package/dist/plugins/mosaicFastifyPlugin.mjs +1 -0
- package/dist/plugins/mosaicWorkflowsPlugin.d.ts +18 -0
- package/dist/plugins/mosaicWorkflowsPlugin.mjs +1 -0
- package/dist/serve.d.ts +4 -1
- package/dist/serve.mjs +1 -1
- package/package.json +9 -7
- package/dist/chunk-JVO4K3RX.mjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u,b as p}from"./chunk-AY5WSHSM.mjs";import g from"fastify-plugin";function S(a,l,h){let{prefix:r}=l,{config:f,fs:y,core:m}=a.mosaic;a.get(`/${r}/config`,async(i,e)=>{e.header("Content-Type","application/json");let s=f.sources.map(t=>{let n=t?.options,c=n?.credentials;if(c&&t.modulePath==="@jpmorganchase/mosaic-source-git-repo"){let d=c.split(":")||[];d.length>0&&(t.options=p(u({},n),{credentials:`${d[0]}: ********`}))}return t}),o=p(u({},f),{sources:s});e.send(o)}),a.get(`/${r}/content/dump`,(i,e)=>{e.header("Content-Type","application/json"),e.send(y.toJSON())}),a.get(`/${r}/sources/list`,async(i,e)=>{e.header("Content-Type","application/json");let o=(await m.listSources()).map(t=>{let n=f.sources[t.index],c=n?.options;if(c?.credentials&&n.modulePath==="@jpmorganchase/mosaic-source-git-repo"){let d=c.credentials?.split(":")||[];d.length>0&&(n.options=p(u({},c),{credentials:`${d[0]}: ********`}))}return p(u({name:t.name},n),{pluginErrors:t.pluginErrors})});e.send(o)}),a.put(`/${r}/source/stop`,async(i,e)=>{e.header("Content-Type","application/text");let{name:s}=i.body;if(s)try{await m.stopSource(String(s)),e.send(`${s} stopped successfully.`)}catch(o){console.error(o),e.status(500).send(`${s} not stopped. Check you have the right name!`)}else e.status(500).send("No source name provided.")}),a.put(`/${r}/source/restart`,async(i,e)=>{e.header("Content-Type","application/text");let{name:s}=i.body;if(s)try{await m.restartSource(String(s)),e.send(`${s} restarted successfully.`)}catch(o){console.error(o),e.status(500).send(`${s} not restarted. Check you have the right name!`)}else e.status(500).send("No source name provided.")}),a.post(`/${r}/source/add`,async(i,e)=>{try{let{definition:s,isPreview:o=!0}=i.body;if(e.header("Content-Type","application/text"),!l.enableSourcePush)throw new Error("Source push is disabled.");if(!s)throw new Error("Source definition is required");if(o){let n=`preview-${s.namespace}`;s.namespace=n}let t=await m.addSource(s);e.send(t!==void 0?`Source ${t.id.description} added successfully`:"Unable to add source")}catch(s){console.error(s),e.status(500).send(s.message)}}),h()}var q=g(S,{fastify:"4.x",name:"fastify-mosaic-admin",dependencies:["fastify-mosaic"]});export{q as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-CJK4LE4J.mjs";import{a as s}from"./chunk-KZGMXFBX.mjs";import{a as e}from"./chunk-WXWWLCIL.mjs";import n from"fastify";import c from"cors";import m from"@fastify/middie";var g="_mosaic_",r=n({logger:!1});async function l(i,t,o){await r.register(m),await r.register(s,{config:i,scope:o}),await r.register(e),await r.register(a,{prefix:g,enableSourcePush:i.enableSourcePush}),r.use(c()),await(async()=>{try{await r.listen({port:t}),console.log(`[Mosaic] Listening on port ${t}${Array.isArray(o)?` (scoped to ${o.join(", ")})`:""}`)}catch(f){r.log.error(f),process.exit(1)}})()}export{r as a,l as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"fastify-plugin";import l from"@jpmorganchase/mosaic-core";import e from"path";async function u(n,f){let{config:c,scope:r}=f,o=new l(c);await o.start();let i=Array.isArray(r)?o.filesystem.scope(r):o.filesystem;n.decorate("mosaic",{config:c,core:o,fs:i}),n.get("/*",async(t,s)=>{try{if(await i.promises.exists(t.url))if((await i.promises.stat(t.url)).isDirectory())await i.promises.exists(e.join(t.url,"index"))?(s.header("Content-Type","application/json"),s.status(302).send({redirect:e.join(t.url,"index")})):s.status(404);else{let a=await i.promises.realpath(t.url);e.extname(a)===".mdx"?s.header("Content-Type","text/mdx"):e.extname(a)===".json"?s.header("Content-Type","application/json"):e.extname(a)===".xml"&&s.header("Content-Type","application/xml");let m=await i.promises.readFile(t.url);s.send(m)}else s.status(404)}catch(a){console.error(a),s.status(500)}})}var g=p(u,{fastify:"4.x",name:"fastify-mosaic"});export{g as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import w from"fastify-plugin";import d from"path";function y(r,l,a){let{fs:s,core:n}=r.mosaic;r.post("/workflows",async(f,t)=>{try{let{user:o,route:e,markdown:c,name:i}=f.body;if(!i)throw new Error("Workflow name is required");if(await s.promises.exists(e)){let p=(await s.promises.stat(e)).isDirectory()?d.posix.join(e,"index"):e,m=await s.promises.realpath(p),u=await n.triggerWorkflow(i,m,{user:o,markdown:c});t.header("Content-Type","application/json"),t.send(u)}}catch(o){console.error(o),t.status(500).send(o.message)}}),a()}var x=w(y,{fastify:"4.x",name:"fastify-mosaic-workflows",dependencies:["fastify-mosaic"]});export{x as a};
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as e}from"./chunk-J73DKLHI.mjs";import{
|
|
2
|
+
import{a as e}from"./chunk-J73DKLHI.mjs";import{b as s}from"./chunk-K55TON6E.mjs";import{a as p}from"./chunk-P3RXN7HU.mjs";import{a as n}from"./chunk-VIYGD5XX.mjs";import"./chunk-CJK4LE4J.mjs";import"./chunk-KZGMXFBX.mjs";import"./chunk-WXWWLCIL.mjs";import"./chunk-AY5WSHSM.mjs";import{program as r}from"commander";import i from"path";import{pathToFileURL as a}from"url";r.option("-c, --config <string>","Config path").option("-o, --out <string>","Output directory",".tmp/.mosaic-build").option("-s, --scope <strings>","Command separated namespaces").option("-p, --port <number>","Port to serve on","8080").option("-n, --name <string>","Snapshot name").option("-S, --snapshot <string>","Snapshot path");r.parse();var o=r.opts(),t;if(o.config!==void 0){if(t=await import(a(i.resolve(process.cwd(),o.config)).toString()),!t)throw new Error(`[Mosaic] could not find config file at ${i.resolve(process.cwd(),o.config)}.`)}else throw new Error("[Mosaic] no config file provided");r.args[0]==="build"&&e(t.default,i.resolve(process.cwd(),o.out),o);r.args[0]==="serve"&&s(t.default,o.port,o.scope&&o.scope.split(","));r.args[0]==="upload"&&p(i.resolve(process.cwd(),o.snapshot));r.args[0]==="deploy"&&n(t.default,o);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
export interface FastifyMosaicAdminPluginOptions {
|
|
3
|
+
prefix: string;
|
|
4
|
+
enableSourcePush?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface AdminRequestBodyType {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
declare function mosaicAdmin(fastify: FastifyInstance, options: FastifyMosaicAdminPluginOptions, next: any): void;
|
|
10
|
+
/**
|
|
11
|
+
* Fastify plugin that adds support for the Mosaic Admin API routes
|
|
12
|
+
* https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/admin/index
|
|
13
|
+
*/
|
|
14
|
+
declare const _default: typeof mosaicAdmin;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-CJK4LE4J.mjs";import"../chunk-AY5WSHSM.mjs";export{a as default};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
import MosaicCore from '@jpmorganchase/mosaic-core';
|
|
3
|
+
import { MosaicConfig, IUnionVolume } from '@jpmorganchase/mosaic-types';
|
|
4
|
+
export interface FastifyMosaicPluginOptions {
|
|
5
|
+
config: MosaicConfig;
|
|
6
|
+
scope?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface FastifyMosaic {
|
|
9
|
+
config: MosaicConfig;
|
|
10
|
+
core: MosaicCore;
|
|
11
|
+
fs: IUnionVolume;
|
|
12
|
+
}
|
|
13
|
+
declare function fastifyMosaic(fastify: FastifyInstance, options: FastifyMosaicPluginOptions): Promise<void>;
|
|
14
|
+
declare module 'fastify' {
|
|
15
|
+
interface FastifyInstance {
|
|
16
|
+
mosaic: FastifyMosaic;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
declare const _default: typeof fastifyMosaic;
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-KZGMXFBX.mjs";import"../chunk-AY5WSHSM.mjs";export{a as default};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
export interface FastifyMosaicAdminPluginOptions {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
enableSourcePush?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface WorkflowRequestBodyType {
|
|
7
|
+
user: string;
|
|
8
|
+
route: string;
|
|
9
|
+
markdown: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
declare function mosaicWorkflows(fastify: FastifyInstance, _options: any, next: any): void;
|
|
13
|
+
/**
|
|
14
|
+
* Fastify plugin that adds support for the Mosaic Admin API routes
|
|
15
|
+
* https://mosaic-mosaic-dev-team.vercel.app/mosaic/configure/admin/index
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: typeof mosaicWorkflows;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"../chunk-WXWWLCIL.mjs";import"../chunk-AY5WSHSM.mjs";export{a as default};
|
package/dist/serve.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import Fastify from 'fastify';
|
|
1
3
|
import { MosaicConfig } from '@jpmorganchase/mosaic-types';
|
|
2
|
-
export
|
|
4
|
+
export declare const server: Fastify.FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault> & PromiseLike<Fastify.FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>>;
|
|
5
|
+
export default function serve(config: MosaicConfig, port: number, scope?: string[]): Promise<void>;
|
package/dist/serve.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a,b}from"./chunk-K55TON6E.mjs";import"./chunk-CJK4LE4J.mjs";import"./chunk-KZGMXFBX.mjs";import"./chunk-WXWWLCIL.mjs";import"./chunk-AY5WSHSM.mjs";export{b as default,a as server};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-cli",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.51",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic command line scripts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,21 +37,23 @@
|
|
|
37
37
|
"directory": "packages/cli"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@jpmorganchase/mosaic-types": "^0.1.0-beta.
|
|
40
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.51",
|
|
41
41
|
"esbuild": "0.14.35",
|
|
42
42
|
"esbuild-node-externals": "^1.0.2",
|
|
43
43
|
"fast-glob": "^3.2.7"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@jpmorganchase/mosaic-core": "^0.1.0-beta.
|
|
47
|
-
"@jpmorganchase/mosaic-plugins": "^0.1.0-beta.
|
|
48
|
-
"@jpmorganchase/mosaic-standard-generator": "^0.1.0-beta.
|
|
49
|
-
"@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.
|
|
46
|
+
"@jpmorganchase/mosaic-core": "^0.1.0-beta.51",
|
|
47
|
+
"@jpmorganchase/mosaic-plugins": "^0.1.0-beta.51",
|
|
48
|
+
"@jpmorganchase/mosaic-standard-generator": "^0.1.0-beta.51",
|
|
49
|
+
"@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.51",
|
|
50
50
|
"@aws-sdk/client-s3": "^3.359.0",
|
|
51
|
+
"@fastify/middie": "^8.3.0",
|
|
51
52
|
"commander": "^9.4.1",
|
|
52
53
|
"cors": "^2.8.5",
|
|
53
54
|
"deepmerge": "^4.2.2",
|
|
54
|
-
"
|
|
55
|
+
"fastify": "^4.23.2",
|
|
56
|
+
"fastify-plugin": "^4.5.1",
|
|
55
57
|
"fs-extra": "^10.1.0",
|
|
56
58
|
"globby": "^13.1.3",
|
|
57
59
|
"mkdirp": "^1.0.4"
|
package/dist/chunk-JVO4K3RX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as y,b as f}from"./chunk-AY5WSHSM.mjs";import w from"express";import x from"cors";import p from"path";import _ from"@jpmorganchase/mosaic-core";var n=w();async function j(m,h,u){n.listen(h,()=>{console.log(`[Mosaic] Listening on port ${h}${Array.isArray(u)?` (scoped to ${u.join(", ")})`:""}`)});let r=new _(m);await r.start();let a=Array.isArray(u)?r.filesystem.scope(u):r.filesystem;n.use(x(),w.json()),n.get("/_mosaic_/sources/list",async(s,e)=>{e.contentType("application/json");let o=(await r.listSources()).map(c=>{let i=m.sources[c.index],d=i.options;if(d?.credentials&&i.modulePath==="@jpmorganchase/mosaic-source-git-repo"){let l=d.credentials?.split(":")||[];l.length>0&&(i.options=f(y({},d),{credentials:`${l[0]}: ********`}))}return f(y({name:c.name},i),{pluginErrors:c.pluginErrors})});e.send(o)}),n.get("/_mosaic_/config",async(s,e)=>{e.contentType("application/json"),e.send(m)}),n.get("/_mosaic_/content/dump",async(s,e)=>{e.contentType("application/json"),e.send(a.toJSON())}),n.put("/_mosaic_/source/stop",async(s,e)=>{e.contentType("application/text");let{name:t}=s.body;if(t)try{await r.stopSource(String(t)),e.send(`${t} stopped successfully.`)}catch(o){console.error(o),e.status(500).send(`${t} not stopped. Check you have the right name!`)}}),n.put("/_mosaic_/source/restart",async(s,e)=>{e.contentType("application/text");let{name:t}=s.body;if(t)try{await r.restartSource(String(t)),e.send(`${t} restarted successfully.`)}catch(o){console.error(o),e.status(500).send(`${t} not restarted. Check you have the right name!`)}}),n.get("/**",async(s,e)=>{try{if(await a.promises.exists(s.path))if((await a.promises.stat(s.path)).isDirectory())await a.promises.exists(p.join(s.path,"index"))?e.status(302).json({redirect:p.join(s.path,"index")}):e.status(404).end();else{let t=await a.promises.realpath(s.path);p.extname(t)===".mdx"?e.contentType("text/mdx"):p.extname(t)===".json"?e.contentType("application/json"):p.extname(t)===".xml"&&e.contentType("application/xml");let o=await a.promises.readFile(s.path);e.send(o)}else e.status(404).end()}catch(t){console.error(t),e.status(500).end()}}),n.post("/workflows",async(s,e)=>{try{let{user:t,route:o,markdown:c,name:i}=s.body;if(!i)throw new Error("Workflow name is required");if(await a.promises.exists(o)){let d=(await a.promises.stat(o)).isDirectory()?p.posix.join(o,"index"):o,l=await a.promises.realpath(d),g=await r.triggerWorkflow(i,l,{user:t,markdown:c});e.contentType("application/json"),e.send(g)}}catch(t){console.error(t),e.status(500).send(t.message).end()}}),n.post("/sources/add",async(s,e)=>{try{let{definition:t,isPreview:o=!0}=s.body;if(process.env.MOSAIC_ENABLE_SOURCE_PUSH!=="true")throw new Error("Source push is disabled.");if(!t)throw new Error("Source definition is required");if(o){let i=`preview-${t.namespace}`;t.namespace=i}let c=await r.addSource(t);e.send(c!==void 0?`Source ${c.id.description} added successfully`:"Unable to add source")}catch(t){console.error(t),e.status(500).send(t.message).end()}})}export{j as a};
|