@jpmorganchase/mosaic-cli 0.1.0-beta.89 → 0.1.0-beta.90

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/build.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-ND7PMTGH.mjs";import"./chunk-DYNA3PMW.mjs";export{a as default};
1
+ import{a}from"./chunk-5Q7PLJAC.mjs";export{a as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-W2D77KDI.mjs";import{a as c}from"./chunk-FCNWFPGR.mjs";import{a as s}from"./chunk-Y6WPZ5AX.mjs";import{a}from"./chunk-LHAYZMT5.mjs";import f from"fastify";import p from"cors";import g from"@fastify/middie";var l="_mosaic_",r=f({logger:!1,pluginTimeout:2e4});async function u(o,t,i){let m=await c(o);await r.register(g),await r.register(a,{config:o,scope:i,mosaic:m}),await r.register(e),await r.register(s,{prefix:l,enableSourcePush:o.enableSourcePush}),r.use(p()),await(async()=>{try{await r.listen({port:t}),console.log(`[Mosaic] Listening on port ${t}${Array.isArray(i)?` (scoped to ${i.join(", ")})`:""}`)}catch(n){r.log.error(n),process.exit(1)}})()}export{r as a,u as b};
1
+ import{a as e}from"./chunk-XZI6BLBY.mjs";import{a as c}from"./chunk-FCNWFPGR.mjs";import{a as s}from"./chunk-A623VBSD.mjs";import{a}from"./chunk-KX3ED265.mjs";import f from"fastify";import p from"cors";import g from"@fastify/middie";var l="_mosaic_",r=f({logger:!1,pluginTimeout:2e4});async function u(o,t,i){let m=await c(o);await r.register(g),await r.register(a,{config:o,scope:i,mosaic:m}),await r.register(e),await r.register(s,{prefix:l,enableSourcePush:o.enableSourcePush}),r.use(p()),await(async()=>{try{await r.listen({port:t}),console.log(`[Mosaic] Listening on port ${t}${Array.isArray(i)?` (scoped to ${i.join(", ")})`:""}`)}catch(n){r.log.error(n),process.exit(1)}})()}export{r as a,u as b};
@@ -0,0 +1 @@
1
+ import e from"path";import{globby as w}from"globby";import o from"fs";async function j(r,s){let{mode:p,platform:c}=r.deployment;if(p==="snapshot-file"&&c==="vercel"){console.info("[Mosaic] deployment platform is vercel...adding snapshot files to site output trace");let i=process.cwd(),n=e.posix.join(i,".next"),l=s.out,f=s.name??new Date().toISOString();o.existsSync(n)||console.warn("[Mosaic] unable to update nextjs trace file. Build the site before generating the snapshot");let t=e.posix.join(n,"server","pages","[...route].js.nft.json"),m=await w(`**/${l}/${f}/**`,{cwd:i,onlyFiles:!0}),a=JSON.parse(await o.promises.readFile(t,"utf-8"));m.forEach(d=>{let u=e.posix.dirname(t),h=e.posix.relative(u,e.posix.resolve(d));a.files.push(h)}),await o.promises.writeFile(t,JSON.stringify(a))}}export{j as a};
@@ -0,0 +1,3 @@
1
+ import r from"node:fs";import e from"node:path";import S from"deepmerge";import j from"@jpmorganchase/mosaic-core";async function x(o,w,u){o.plugins=o.plugins.filter(({runTimeOnly:i})=>!i),o.sources=o.sources.map(i=>({...i,options:{...i.options,cache:!1}}));let p=u.scope&&u.scope.split(","),l=new j(o),t=e.posix.join(w,u.name??new Date().toISOString());try{let i=await r.promises.readdir(t);await Promise.all(i.map(f=>r.promises.rm(e.join(t,f))))}catch{await r.promises.mkdir(t,{recursive:!0})}await l.start();let d=Array.isArray(p)?l.filesystem.scope(p):l.filesystem,h=0;l.onSourceUpdate(async()=>{try{if(++h===o.sources.length){let i=d.symlinksToJSON(),f=await d.promises.glob("**",{cwd:"/",onlyFiles:!0});for(let s of f){let a=await d.promises.readFile(String(s),{includeConflicts:!0}),c=a[0];if(a.length>1)if(e.posix.extname(String(s))===".json"){console.warn(`'${s}' returned multiple files at the same location. Since the files were JSON dot files, they were merged using \`deepmerge\`.`);let n=a.map(m=>JSON.parse(String(m)));c=Buffer.from(JSON.stringify(S(n[0],n[1])))}else throw new Error(`'${s}' returned multiple files at the same location, this will result in overwritten data in the output. Aborting build.
2
+
3
+ Try using \`--scope\` to just output certain namespaced sources, or adding a \`prefixDir\` to the source options to move the source files into a separate folder.`);await r.promises.mkdir(e.dirname(e.join(t,String(s))),{recursive:!0}),await r.promises.writeFile(e.join(t,String(s)),c)}let y=process.cwd();for(let s in i)if(!s.startsWith("/.tags")){for(let{target:a}of i[s])if(!a.startsWith("/.tags")){await r.promises.mkdir(e.join(t,e.dirname(s)),{recursive:!0});try{!!await r.promises.stat(e.join(t,s))&&(console.error(new Error(`Symlink at '${e.join(t,s)}' already exists. Aborting build.`)),process.exit(1))}catch{let c=e.join(t,a),n=e.join(t,s),m=e.basename(n),g=e.relative(e.dirname(n),c);process.chdir(e.dirname(n)),r.existsSync(m)&&r.unlinkSync(m),await r.promises.symlink(g,m)}}}process.chdir(y),console.log(`[Mosaic] filesystem for ${Array.isArray(p)?p.length:o.sources.length} source(s) written to disk at '${t}'`),l.stop()}}catch(i){console.error(i),process.exit(1)}})}export{x as a};
@@ -0,0 +1 @@
1
+ import m from"fastify-plugin";function h(a,f,l){let{prefix:r}=f,{config:p,fs:y,core:u}=a.mosaic;a.get(`/${r}/config`,async(i,e)=>{e.header("Content-Type","application/json");let s=p.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={...n,credentials:`${d[0]}: ********`})}return t}),o={...p,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 u.listSources()).map(t=>{let n=p.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={...c,credentials:`${d[0]}: ********`})}return{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 u.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 u.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"),!f.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 u.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)}}),l()}var F=m(h,{fastify:"5.x",name:"fastify-mosaic-admin",dependencies:["fastify-mosaic"]});export{F as a};
@@ -0,0 +1 @@
1
+ import p from"fastify-plugin";import a from"node:path";async function l(n,f){let{config:r,scope:c,mosaic:o}=f,i=Array.isArray(c)?o.filesystem.scope(c):o.filesystem;n.decorate("mosaic",{config:r,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(a.join(t.url,"index"))?(s.header("Content-Type","application/json"),s.status(302).send({redirect:a.posix.join(t.url,"index")})):s.status(404);else{let e=String(await i.promises.realpath(t.url));a.extname(e)===".mdx"?s.header("Content-Type","text/mdx"):a.extname(e)===".json"?s.header("Content-Type","application/json"):a.extname(e)===".xml"&&s.header("Content-Type","application/xml");let m=await i.promises.readFile(t.url);s.send(m)}else s.status(404)}catch(e){console.error(e),s.status(500)}})}var x=p(l,{fastify:"5.x",name:"fastify-mosaic"});export{x as a};
@@ -0,0 +1 @@
1
+ import d from"fastify-plugin";import l from"node:path";import y from"md5";import R from"@fastify/websocket";async function S(t,O){await t.register(R);let{fs:a,core:c}=t.mosaic;t.get("/workflows",{websocket:!0},s=>{s.on("message",async g=>{if(s.OPEN)try{let{type:i,route:e,name:o,user:r,...p}=JSON.parse(g.toString());o||s.send(JSON.stringify({status:"ERROR",message:"Workflow name is required"})),r||s.send(JSON.stringify({status:"ERROR",message:"Workflow must be run for a user"}));let u=r.id||r.sid,w=y(`${u.toLowerCase()} - ${o.toLowerCase()}`),n=(f,m)=>s.send(JSON.stringify({status:m,message:f,channel:w}));if(await a.promises.exists(e)){let f=(await a.promises.stat(e)).isDirectory()?l.posix.join(e,"index"):e,m=await a.promises.realpath(f);c.triggerWorkflow(n,o,m,{user:r,...p}),n(`Workflow ${o} has started`,"SUCCESS")}else n(`${e} not found`,"ERROR")}catch(i){console.error(i),s.send(JSON.stringify({status:"ERROR",message:i.message}))}})})}var E=d(S,{fastify:"5.x",name:"fastify-mosaic-workflows",dependencies:["fastify-mosaic"]});export{E as a};
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as e}from"./chunk-ND7PMTGH.mjs";import{b as s}from"./chunk-47LY3HTJ.mjs";import"./chunk-W2D77KDI.mjs";import{a as p}from"./chunk-P3RXN7HU.mjs";import{a as n}from"./chunk-VIYGD5XX.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-Y6WPZ5AX.mjs";import"./chunk-LHAYZMT5.mjs";import"./chunk-DYNA3PMW.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);
2
+ import{a as e}from"./chunk-5Q7PLJAC.mjs";import{b as s}from"./chunk-3CHKQJYA.mjs";import"./chunk-XZI6BLBY.mjs";import{a as p}from"./chunk-P3RXN7HU.mjs";import{a as n}from"./chunk-4JWFWIG4.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-A623VBSD.mjs";import"./chunk-KX3ED265.mjs";import{program as r}from"commander";import i from"node:path";import{pathToFileURL as a}from"node: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);
@@ -1 +1 @@
1
- import{a}from"../chunk-FCNWFPGR.mjs";import"../chunk-DYNA3PMW.mjs";export{a as createMosaicInstance};
1
+ import{a}from"../chunk-FCNWFPGR.mjs";export{a as createMosaicInstance};
@@ -1 +1 @@
1
- import{a}from"../chunk-Y6WPZ5AX.mjs";import"../chunk-DYNA3PMW.mjs";export{a as default};
1
+ import{a}from"../chunk-A623VBSD.mjs";export{a as default};
@@ -1 +1 @@
1
- import{a}from"../chunk-LHAYZMT5.mjs";import"../chunk-DYNA3PMW.mjs";export{a as default};
1
+ import{a}from"../chunk-KX3ED265.mjs";export{a as default};
@@ -1 +1 @@
1
- import{a}from"../chunk-W2D77KDI.mjs";import"../chunk-DYNA3PMW.mjs";export{a as default};
1
+ import{a}from"../chunk-XZI6BLBY.mjs";export{a as default};
package/dist/serve.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
1
  import Fastify from 'fastify';
3
2
  import { MosaicConfig } from '@jpmorganchase/mosaic-types';
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>>;
3
+ export declare const server: Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault> & PromiseLike<Fastify.FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, Fastify.FastifyBaseLogger, Fastify.FastifyTypeProviderDefault>> & {
4
+ __linterBrands: "SafePromiseLike";
5
+ };
5
6
  export default function serve(config: MosaicConfig, port: number, scope?: string[]): Promise<void>;
package/dist/serve.mjs CHANGED
@@ -1 +1 @@
1
- import{a,b}from"./chunk-47LY3HTJ.mjs";import"./chunk-W2D77KDI.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-Y6WPZ5AX.mjs";import"./chunk-LHAYZMT5.mjs";import"./chunk-DYNA3PMW.mjs";export{b as default,a as server};
1
+ import{a,b}from"./chunk-3CHKQJYA.mjs";import"./chunk-XZI6BLBY.mjs";import"./chunk-FCNWFPGR.mjs";import"./chunk-A623VBSD.mjs";import"./chunk-KX3ED265.mjs";export{b as default,a as server};
@@ -1 +1 @@
1
- import{a}from"./chunk-P3RXN7HU.mjs";import"./chunk-DYNA3PMW.mjs";export{a as default};
1
+ import{a}from"./chunk-P3RXN7HU.mjs";export{a as default};
@@ -1 +1 @@
1
- import{a}from"./chunk-VIYGD5XX.mjs";import"./chunk-DYNA3PMW.mjs";export{a as updateTraceFile};
1
+ import{a}from"./chunk-4JWFWIG4.mjs";export{a as updateTraceFile};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpmorganchase/mosaic-cli",
3
- "version": "0.1.0-beta.89",
3
+ "version": "0.1.0-beta.90",
4
4
  "author": "",
5
5
  "description": "Mosaic command line scripts",
6
6
  "license": "Apache-2.0",
@@ -26,7 +26,7 @@
26
26
  "scripts": {
27
27
  "build": "npm-run-all --parallel build:*",
28
28
  "build:types": "tsc",
29
- "build:cli": "node ./scripts/bundle.js",
29
+ "build:cli": "node ./scripts/bundle.mjs",
30
30
  "clean": "rm -fr dist",
31
31
  "docker:build": "docker build . --tag mosaic-fs:latest",
32
32
  "docker:start": "docker run -it --rm --ipc=host -p 8080:8080 --mount source=docs,destination=/app/docs --network mosaic-net --name mosaic-fs mosaic-fs:latest",
@@ -38,26 +38,25 @@
38
38
  "directory": "packages/cli"
39
39
  },
40
40
  "devDependencies": {
41
- "@jpmorganchase/mosaic-types": "^0.1.0-beta.89",
42
- "esbuild": "0.14.35",
41
+ "@jpmorganchase/mosaic-types": "^0.1.0-beta.90",
42
+ "esbuild": "0.25.0",
43
43
  "esbuild-node-externals": "^1.0.2",
44
44
  "fast-glob": "^3.2.7",
45
45
  "@types/ws": "^8.5.7"
46
46
  },
47
47
  "dependencies": {
48
- "@jpmorganchase/mosaic-core": "^0.1.0-beta.89",
49
- "@jpmorganchase/mosaic-plugins": "^0.1.0-beta.89",
50
- "@jpmorganchase/mosaic-standard-generator": "^0.1.0-beta.89",
51
- "@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.89",
48
+ "@jpmorganchase/mosaic-core": "^0.1.0-beta.90",
49
+ "@jpmorganchase/mosaic-plugins": "^0.1.0-beta.90",
50
+ "@jpmorganchase/mosaic-standard-generator": "^0.1.0-beta.90",
51
+ "@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.90",
52
52
  "@aws-sdk/client-s3": "^3.645.0",
53
- "@fastify/middie": "^8.3.0",
54
- "@fastify/websocket": "^8.2.0",
53
+ "@fastify/middie": "^9.0.0",
54
+ "@fastify/websocket": "^11.0.0",
55
55
  "commander": "^9.4.1",
56
56
  "cors": "^2.8.5",
57
57
  "deepmerge": "^4.2.2",
58
- "fastify": "^4.23.2",
59
- "fastify-plugin": "^4.5.1",
60
- "fs-extra": "^10.1.0",
58
+ "fastify": "^5.0.0",
59
+ "fastify-plugin": "^5.0.0",
61
60
  "globby": "^13.1.3",
62
61
  "md5": "*",
63
62
  "mkdirp": "^1.0.4"
@@ -1 +0,0 @@
1
- var i=Object.defineProperty,j=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var e=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var f=(a,b,c)=>b in a?i(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c,l=(a,b)=>{for(var c in b||(b={}))g.call(b,c)&&f(a,c,b[c]);if(e)for(var c of e(b))h.call(b,c)&&f(a,c,b[c]);return a},m=(a,b)=>j(a,k(b));var n=(a,b)=>{var c={};for(var d in a)g.call(a,d)&&b.indexOf(d)<0&&(c[d]=a[d]);if(a!=null&&e)for(var d of e(a))b.indexOf(d)<0&&h.call(a,d)&&(c[d]=a[d]);return c};export{l as a,m as b,n as c};
@@ -1 +0,0 @@
1
- import p from"fastify-plugin";import a from"path";async function l(n,f){let{config:r,scope:c,mosaic:o}=f,i=Array.isArray(c)?o.filesystem.scope(c):o.filesystem;n.decorate("mosaic",{config:r,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(a.join(t.url,"index"))?(s.header("Content-Type","application/json"),s.status(302).send({redirect:a.posix.join(t.url,"index")})):s.status(404);else{let e=String(await i.promises.realpath(t.url));a.extname(e)===".mdx"?s.header("Content-Type","text/mdx"):a.extname(e)===".json"?s.header("Content-Type","application/json"):a.extname(e)===".xml"&&s.header("Content-Type","application/xml");let m=await i.promises.readFile(t.url);s.send(m)}else s.status(404)}catch(e){console.error(e),s.status(500)}})}var x=p(l,{fastify:"4.x",name:"fastify-mosaic"});export{x as a};
@@ -1,3 +0,0 @@
1
- import{a as d,b as w}from"./chunk-DYNA3PMW.mjs";import n from"fs";import e from"path";import k from"deepmerge";import h from"fs-extra";import b from"@jpmorganchase/mosaic-core";async function F(r,y,u){r.plugins=r.plugins.filter(({runTimeOnly:i})=>!i),r.sources=r.sources.map(i=>w(d({},i),{options:w(d({},i.options),{cache:!1})}));let p=u.scope&&u.scope.split(","),l=new b(r),s=e.posix.join(y,u.name??new Date().toISOString());await h.emptyDir(s),await l.start();let f=Array.isArray(p)?l.filesystem.scope(p):l.filesystem,g=0;l.onSourceUpdate(async()=>{try{if(++g===r.sources.length){let i=f.symlinksToJSON(),S=await f.promises.glob("**",{cwd:"/",onlyFiles:!0});for(let t of S){let o=await f.promises.readFile(String(t),{includeConflicts:!0}),c=o[0];if(o.length>1)if(e.posix.extname(String(t))===".json"){console.warn(`'${t}' returned multiple files at the same location. Since the files were JSON dot files, they were merged using \`deepmerge\`.`);let a=o.map(m=>JSON.parse(String(m)));c=Buffer.from(JSON.stringify(k(a[0],a[1])))}else throw new Error(`'${t}' returned multiple files at the same location, this will result in overwritten data in the output. Aborting build.
2
-
3
- Try using \`--scope\` to just output certain namespaced sources, or adding a \`prefixDir\` to the source options to move the source files into a separate folder.`);await n.promises.mkdir(e.dirname(e.join(s,String(t))),{recursive:!0}),await n.promises.writeFile(e.join(s,String(t)),c)}let x=process.cwd();for(let t in i)if(!t.startsWith("/.tags")){for(let{target:o}of i[t])if(!o.startsWith("/.tags")){await h.ensureDir(e.join(s,e.dirname(t)));try{!!await n.promises.stat(e.join(s,t))&&(console.error(new Error(`Symlink at '${e.join(s,t)}' already exists. Aborting build.`)),process.exit(1))}catch{let c=e.join(s,o),a=e.join(s,t),m=e.basename(a),j=e.relative(e.dirname(a),c);process.chdir(e.dirname(a)),n.existsSync(m)&&n.unlinkSync(m),await n.promises.symlink(j,m)}}}process.chdir(x),console.log(`[Mosaic] filesystem for ${Array.isArray(p)?p.length:r.sources.length} source(s) written to disk at '${s}'`),l.stop()}}catch(i){console.error(i),process.exit(1)}})}export{F as a};
@@ -1 +0,0 @@
1
- import e from"path";import{globby as x}from"globby";import o from"fs-extra";async function j(r,s){let{mode:p,platform:c}=r.deployment;if(p==="snapshot-file"&&c==="vercel"){console.info("[Mosaic] deployment platform is vercel...adding snapshot files to site output trace");let i=process.cwd(),n=e.posix.join(i,".next"),l=s.out,f=s.name??new Date().toISOString();o.existsSync(n)||console.warn("[Mosaic] unable to update nextjs trace file. Build the site before generating the snapshot");let t=e.posix.join(n,"server","pages","[...route].js.nft.json"),m=await x(`**/${l}/${f}/**`,{cwd:i,onlyFiles:!0}),a=JSON.parse(await o.promises.readFile(t,"utf-8"));m.forEach(d=>{let u=e.posix.dirname(t),h=e.posix.relative(u,e.posix.resolve(d));a.files.push(h)}),await o.promises.writeFile(t,JSON.stringify(a))}}export{j as a};
@@ -1 +0,0 @@
1
- import{a as g,c as p}from"./chunk-DYNA3PMW.mjs";import y from"fastify-plugin";import R from"path";import S from"md5";import O from"@fastify/websocket";async function W(t,h){await t.register(O);let{fs:a,core:u}=t.mosaic;t.get("/workflows",{websocket:!0},s=>{s.socket.on("message",async w=>{if(s.socket.OPEN)try{let c=JSON.parse(w.toString()),{type:i,route:e,name:o,user:r}=c,d=p(c,["type","route","name","user"]);o||s.socket.send(JSON.stringify({status:"ERROR",message:"Workflow name is required"})),r||s.socket.send(JSON.stringify({status:"ERROR",message:"Workflow must be run for a user"}));let k=r.id||r.sid,l=S(`${k.toLowerCase()} - ${o.toLowerCase()}`),n=(f,m)=>s.socket.send(JSON.stringify({status:m,message:f,channel:l}));if(await a.promises.exists(e)){let f=(await a.promises.stat(e)).isDirectory()?R.posix.join(e,"index"):e,m=await a.promises.realpath(f);u.triggerWorkflow(n,o,m,g({user:r},d)),n(`Workflow ${o} has started`,"SUCCESS")}else n(`${e} not found`,"ERROR")}catch(i){console.error(i),s.socket.send(JSON.stringify({status:"ERROR",message:i.message}))}})})}var b=y(W,{fastify:"4.x",name:"fastify-mosaic-workflows",dependencies:["fastify-mosaic"]});export{b as a};
@@ -1 +0,0 @@
1
- import{a as u,b as p}from"./chunk-DYNA3PMW.mjs";import g from"fastify-plugin";function F(a,y,m){let{prefix:r}=y,{config:l,fs:h,core:f}=a.mosaic;a.get(`/${r}/config`,async(i,e)=>{e.header("Content-Type","application/json");let s=l.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({},l),{sources:s});e.send(o)}),a.get(`/${r}/content/dump`,(i,e)=>{e.header("Content-Type","application/json"),e.send(h.toJSON())}),a.get(`/${r}/sources/list`,async(i,e)=>{e.header("Content-Type","application/json");let o=(await f.listSources()).map(t=>{let n=l.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 f.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 f.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"),!y.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 f.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)}}),m()}var S=g(F,{fastify:"4.x",name:"fastify-mosaic-admin",dependencies:["fastify-mosaic"]});export{S as a};