sharetribe-cli 1.15.0 → 1.15.1

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/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import{Command as bt}from"commander";import{readFileSync as Rt}from"node:fs";import{fileURLToPath as xt}from"node:url";import{dirname as qt,join as Tt}from"node:path";import{readFileSync as ye}from"node:fs";import{fileURLToPath as Ee}from"node:url";import{dirname as U,join as Se}from"node:path";function ke(){let r=Ee(import.meta.url),t=U(r);for(;t!=="/";)try{let e=Se(t,"package.json");return ye(e,"utf-8")}catch{t=U(t)}throw new Error("Could not find package.json")}function V(){let r=JSON.parse(ke());console.log(r.version)}import ve from"inquirer";import{writeAuth as Ae}from"sharetribe-flex-build-sdk";async function H(){let r=await ve.prompt([{type:"password",name:"apiKey",message:"Enter API key:",mask:"*",validate:t=>!t||t.trim().length===0?"API key cannot be empty":!0}]);Ae({apiKey:r.apiKey}),console.log("Successfully logged in.")}import{clearAuth as we}from"sharetribe-flex-build-sdk";async function J(){await we(),console.log("Successfully logged out.")}import{listProcesses as Ce,listProcessVersions as Pe}from"sharetribe-flex-build-sdk";import I from"chalk";function E(r,t){if(t.length===0)return;let e={};for(let n of r)e[n]=n.length+1;for(let n of t)for(let i of r){let a=n[i]||"";e[i]=Math.max(e[i]||0,a.length)}console.log("");let o=r.map((n,i)=>{let a=e[n]||0,m=n.padEnd(a+1);return i===r.length-1?m:m+" "}).join("");console.log(I.bold.black(o));for(let n of t){let a=r.map((m,p)=>{let l=n[m]||"",d=e[m]||0,f=l.padEnd(d+1);return p===r.length-1?f:f+" "}).join("");console.log(a)}console.log("")}function c(r){console.error(I.red(`Error: ${r}`))}function h(r){console.log(I.green(r))}function Ie(r){try{let t=new Date(r),e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return r}}async function O(r,t){try{if(t){let e=await Pe(void 0,r,t);if(e.length===0){console.log(`No versions found for process: ${t}`);return}let s=e.map(o=>({Created:Ie(o.createdAt),Version:o.version.toString(),Aliases:o.aliases?.join(", ")||"",Transactions:o.transactionCount?.toString()||"0"}));E(["Created","Version","Aliases","Transactions"],s)}else{let e=await Ce(void 0,r);if(e.length===0){console.log("No processes found.");return}let s=e.map(o=>({Name:o.name,"Latest version":o.version?.toString()||""}));E(["Name","Latest version"],s)}}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to list processes"),process.exit(1)}}import{createProcess as Oe}from"sharetribe-flex-build-sdk";import{readFileSync as be}from"node:fs";import{join as Re}from"node:path";async function b(r,t,e){try{let s=Re(e,"process.edn"),o=be(s,"utf-8"),n=await Oe(void 0,r,t,o);h(`Process ${n.name} successfully created with version ${n.version}.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to create process"),process.exit(1)}}import{pushProcess as xe}from"sharetribe-flex-build-sdk";import{readFileSync as R,readdirSync as qe}from"node:fs";import{join as k}from"node:path";function Te(r){let t=k(r,"templates"),e=[];try{let s=qe(t);for(let o of s){let n=k(t,o),i=k(n,`${o}-html.html`),a=k(n,`${o}-subject.txt`);try{let m=R(i,"utf-8"),p=R(a,"utf-8");e.push({name:o,html:m,subject:p})}catch{}}}catch{}return e}async function x(r,t,e){try{let s=k(e,"process.edn"),o=R(s,"utf-8"),n=Te(e),i=await xe(void 0,r,t,o,n);i.noChanges?console.log("No changes"):h(`Version ${i.version} successfully saved for process ${t}.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to push process"),process.exit(1)}}import{getProcess as De}from"sharetribe-flex-build-sdk";import{writeFileSync as q,mkdirSync as T}from"node:fs";import{join as v}from"node:path";async function D(r,t,e,s,o){try{let n=await De(void 0,r,t,{version:s,alias:o});if(!n.definition)throw new Error("No process definition in response");let{existsSync:i}=await import("node:fs"),a=i(e);T(e,{recursive:!0}),a||console.error(`Creating a new directory: ${e}`);let m=v(e,"process.edn");q(m,n.definition,"utf-8");let p=n.emailTemplates||[];if(p&&Array.isArray(p)&&p.length>0){let l=v(e,"templates");T(l,{recursive:!0});for(let d of p){let f=d.name,A=d.html,K=d.subject;if(f){let C=v(l,f);if(T(C,{recursive:!0}),A){let P=v(C,`${f}-html.html`);q(P,A,"utf-8")}if(K){let P=v(C,`${f}-subject.txt`);q(P,K,"utf-8")}}}}console.error(`Saved process to ${e}`)}catch(n){n&&typeof n=="object"&&"message"in n?c(n.message):c("Failed to pull process"),process.exit(1)}}import{createAlias as _e,updateAlias as Me,deleteAlias as Le}from"sharetribe-flex-build-sdk";async function _(r,t,e,s){try{let o=await _e(void 0,r,t,e,s);h(`Alias ${o.alias} successfully created to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to create alias"),process.exit(1)}}async function M(r,t,e,s){try{let o=await Me(void 0,r,t,e,s);h(`Alias ${o.alias} successfully updated to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to update alias"),process.exit(1)}}async function L(r,t,e){try{let s=await Le(void 0,r,t,e);h(`Alias ${s.alias} successfully deleted.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to delete alias"),process.exit(1)}}import{deployProcess as Ne,parseProcessFile as je}from"sharetribe-flex-build-sdk";import{readFileSync as $e}from"node:fs";import{join as Fe}from"node:path";async function N(r,t,e,s){try{let o=Fe(e,"process.edn"),n=$e(o,"utf-8"),i=je(n),a=await Ne(void 0,r,{process:t,alias:s,path:o,processDefinition:i});a.processCreated&&h(`Process ${t} successfully created.`),h(`Version ${a.version} successfully saved for process ${t}.`),a.aliasCreated?h(`Alias ${a.alias} successfully created to point to version ${a.version}.`):h(`Alias ${a.alias} successfully updated to point to version ${a.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to create/push process and alias"),process.exit(1)}}function W(r){let t=r.command("process").description("describe a process file").option("--path <PROCESS_DIR>","path to the directory where the process.edn file is").option("--transition <TRANSITION_NAME>","transition name, e.g. transition/request to get more details of it").action(async e=>{e.path?(console.log(`Describing process at: ${e.path}`),e.transition&&console.log(`Transition: ${e.transition}`),console.log("Process description not yet implemented")):t.outputHelp()});t.command("list").description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await O(s,e.process)}),t.command("create").description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await b(s,e.process,e.path)}),t.command("push").description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await x(s,e.process,e.path)}),t.command("pull").description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await D(s,e.process,e.path,e.version,e.alias)}),t.command("create-alias").description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").allowUnknownOption(!1).action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await _(s,e.process,parseInt(e.version),e.alias)}),t.command("update-alias").description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await M(s,e.process,parseInt(e.version),e.alias)}),t.command("delete-alias").description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await L(s,e.process,e.alias)}),t.command("deploy").description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await N(s,e.process,e.path,e.alias)}),r.command("process-list",{hidden:!0}).description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await O(s,e.process)}),r.command("process-create",{hidden:!0}).description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await b(s,e.process,e.path)}),r.command("process-push",{hidden:!0}).description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await x(s,e.process,e.path)}),r.command("process-pull",{hidden:!0}).description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await D(s,e.process,e.path,e.version,e.alias)}),r.command("process-create-alias",{hidden:!0}).description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await _(s,e.process,parseInt(e.version),e.alias)}),r.command("process-update-alias",{hidden:!0}).description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await M(s,e.process,parseInt(e.version),e.alias)}),r.command("process-delete-alias",{hidden:!0}).description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await L(s,e.process,e.alias)}),r.command("process-deploy",{hidden:!0}).description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await N(s,e.process,e.path,e.alias)})}import{listSearchSchemas as Ke,setSearchSchema as Ue,unsetSearchSchema as Ve}from"sharetribe-flex-build-sdk";var B={metadata:"Metadata",private:"Private data",protected:"Protected data",public:"Public data"};async function He(r,t){try{await Ue(void 0,r,{key:t.key,scope:t.scope,type:t.type,doc:t.doc,defaultValue:t.default,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",s=B[t.scope]||t.scope;console.log(`${s} schema, ${t.key} is successfully set for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to set search schema"),process.exit(1)}}async function Je(r,t){try{await Ve(void 0,r,{key:t.key,scope:t.scope,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",s=B[t.scope]||t.scope;console.log(`${s} schema, ${t.key} is successfully unset for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to unset search schema"),process.exit(1)}}function We(r){return r==null?"":Array.isArray(r)?r.join(", "):String(r)}async function Be(r){try{let t=await Ke(void 0,r);if(t.length===0){console.log("No search schemas found.");return}let e=t.map(i=>({"Schema for":i.schemaFor,Scope:i.scope,Key:i.key,Type:i.type,"Default value":We(i.defaultValue),Doc:i.doc||""})).sort((i,a)=>i["Schema for"]!==a["Schema for"]?i["Schema for"].localeCompare(a["Schema for"]):i.Scope!==a.Scope?i.Scope.localeCompare(a.Scope):i.Key.localeCompare(a.Key)),s=["Schema for","Scope","Key","Type","Default value","Doc"],o={};for(let i of s)o[i]=i.length+1;for(let i of e)for(let a of s){let m=i[a]||"";o[a]=Math.max(o[a],m.length)}console.log("");let n=s.map((i,a)=>{let m=o[i]||0,p=i.padEnd(m);return a===s.length-1?p+" ":p+" "});console.log(n.join(""));for(let i of e){let a=s.map((m,p)=>{let l=i[m]||"",d=o[m]||0,f=l.padEnd(d);return p===s.length-1?f+" ":f+" "});console.log(a.join(""))}console.log("")}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to list search schemas"),process.exit(1)}}function G(r){let t=r.command("search").description("list all search schemas").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Be(s)});t.command("set").description("set search schema").requiredOption("--key <KEY>","schema key").requiredOption("--scope <SCOPE>","schema scope").requiredOption("--type <TYPE>","value type (enum, multi-enum, boolean, long, or text)").option("--doc <DOC>","description of the schema").option("--default <DEFAULT>","default value for search if value is not set").option("--schema-for <SCHEMA_FOR>","subject of the schema (listing, userProfile, or transaction)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await He(s,{key:e.key,scope:e.scope,type:e.type,doc:e.doc,default:e.default,schemaFor:e.schemaFor})}),t.command("unset").description("unset search schema").requiredOption("--key <KEY>","schema key").requiredOption("--scope <SCOPE>","schema scope").option("--schema-for <SCHEMA_FOR>","subject of the schema (listing, userProfile, or transaction)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Je(s,{key:e.key,scope:e.scope,schemaFor:e.schemaFor})})}import{pullAssets as Ge,pushAssets as Qe}from"sharetribe-flex-build-sdk";import{readFileSync as Q,writeFileSync as Y,existsSync as S,mkdirSync as j,readdirSync as Ye,statSync as $,unlinkSync as Xe}from"node:fs";import{join as y,dirname as ze}from"node:path";import{createHash as Ze}from"node:crypto";import g from"jsedn";function X(r){let t=y(r,".flex-cli","asset-meta.edn");if(!S(t))return null;try{let e=Q(t,"utf-8"),s=g.parse(e),o=s.at(g.kw(":version")),n=s.at(g.kw(":assets")),i=[];if(n&&n.val)for(let a of n.val)i.push({path:a.at(g.kw(":path")),"content-hash":a.at(g.kw(":content-hash"))});return{version:o,assets:i}}catch{return null}}function z(r,t){let e=y(r,".flex-cli");S(e)||j(e,{recursive:!0});let s=t.assets.map(i=>new g.Map([g.kw(":path"),i.path,g.kw(":content-hash"),i["content-hash"]])),o=new g.Map([g.kw(":version"),t.version,g.kw(":assets"),new g.Vector(s)]),n=y(r,".flex-cli","asset-meta.edn");Y(n,g.encode(o),"utf-8")}function Z(r){return Ze("sha1").update(r).digest("hex")}function et(r){let t=[];function e(s,o=""){let n=Ye(s);for(let i of n){if(i===".flex-cli")continue;let a=y(s,i),m=o?y(o,i):i,p=$(a);if(p.isDirectory())e(a,m);else if(p.isFile()){let l=Q(a),d=Z(l);t.push({path:m,data:l,hash:d})}}}return e(r),t}function tt(r){for(let t of r)if(t.path.endsWith(".json"))try{JSON.parse(t.data.toString("utf-8"))}catch(e){throw new Error(`Invalid JSON in ${t.path}: ${e}`)}}async function st(r,t,e,s){try{if(S(t)||j(t,{recursive:!0}),!$(t).isDirectory())throw new Error(`${t} is not a directory`);let n=await Ge(void 0,r,e?{version:e}:void 0),i=n.version,a=X(t);if(a&&a.version===i&&n.assets.length===a.assets.length){console.log("Assets are up to date.");return}let m=[];for(let p of n.assets){let l=y(t,p.path),d=ze(l);S(d)||j(d,{recursive:!0});let f=Buffer.from(p.dataRaw,"base64");Y(l,f);let A=Z(f);m.push({path:p.path,"content-hash":p.contentHash||A})}if(s&&a){let p=new Set(n.assets.map(l=>l.path));for(let l of a.assets)if(!p.has(l.path)){let d=y(t,l.path);S(d)&&Xe(d)}}z(t,{version:i,assets:m}),console.log(`Version ${i} successfully pulled.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to pull assets"),process.exit(1)}}async function rt(r,t,e){try{if(!S(t)||!$(t).isDirectory())throw new Error(`${t} is not a valid directory`);let s=X(t),o=s?.version||"nil",n=et(t);tt(n);let i=[],a=new Map(n.map(l=>[l.path,l])),m=new Map((s?.assets||[]).map(l=>[l.path,l["content-hash"]]));for(let[l,d]of a){let f=m.get(l);(!f||f!==d.hash)&&i.push({path:l,op:"upsert",data:d.data})}if(e&&s)for(let l of s.assets)a.has(l.path)||i.push({path:l.path,op:"delete"});if(i.length===0){console.log("Assets are up to date.");return}let p=await Qe(void 0,r,o,i);z(t,{version:p.version,assets:p.assets.map(l=>({path:l.path,"content-hash":l.contentHash}))}),console.log(`New version ${p.version} successfully created.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to push assets"),process.exit(1)}}function ee(r){let t=r.command("assets").description("manage marketplace assets");t.command("pull").description("pull assets from remote").requiredOption("--path <PATH>","path to directory where assets will be stored").option("--version <VERSION>","version of assets to pull").option("--prune","delete local files no longer present as remote assets").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await st(s,e.path,e.version,e.prune)}),t.command("push").description("push assets to remote").requiredOption("--path <PATH>","path to directory with assets").option("--prune","delete remote assets no longer present locally").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await rt(s,e.path,e.prune)})}import{sendNotification as ot,previewNotification as nt}from"sharetribe-flex-build-sdk";import{readFileSync as F,existsSync as w,statSync as it}from"node:fs";import{join as te}from"node:path";import{createServer as at}from"node:http";function se(r){if(!w(r)||!it(r).isDirectory())throw new Error(`Template directory not found: ${r}`);let t=te(r,"template.html"),e=te(r,"template-subject.txt");if(!w(t))throw new Error(`template.html not found in ${r}`);if(!w(e))throw new Error(`template-subject.txt not found in ${r}`);let s=F(t,"utf-8"),o=F(e,"utf-8").trim();return{html:s,subject:o}}function re(r){if(!r)return;if(!w(r))throw new Error(`Context file not found: ${r}`);let t=F(r,"utf-8");try{return JSON.parse(t)}catch(e){throw new Error(`Invalid JSON in context file: ${e}`)}}async function ct(r,t,e){try{let s=se(t),o=re(e),n=await ot(void 0,r,{template:s,context:o});console.log(`Preview successfully sent to ${n.adminEmail}`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to send notification"),process.exit(1)}}async function lt(r,t,e){try{let s=se(t),o=re(e);console.log(`Template: ${t}`),console.log(`Subject: ${s.subject}`),console.log(""),console.log("Starting preview server at http://localhost:3535"),console.log("Press Ctrl+C to stop"),console.log("");let n=null,i=async()=>{try{let l=(await nt(void 0,r,{template:s,context:o})).html,d=`<title>${s.subject}</title>`;l.includes("<head>")?n=l.replace("<head>",`<head>
4
- ${d}`):l.includes("<html>")?n=l.replace("<html>",`<html>
5
- <head>${d}</head>`):n=`<html><head>${d}</head><body>${l}</body></html>`}catch(p){n=`
3
+ import{Command as _t}from"commander";import{readFileSync as Lt}from"node:fs";import{fileURLToPath as Nt}from"node:url";import{dirname as $t,join as jt}from"node:path";import{readFileSync as Se}from"node:fs";import{fileURLToPath as ke}from"node:url";import{dirname as V,join as ve}from"node:path";function Ae(){let r=ke(import.meta.url),t=V(r);for(;t!=="/";)try{let e=ve(t,"package.json");return Se(e,"utf-8")}catch{t=V(t)}throw new Error("Could not find package.json")}function H(){let r=JSON.parse(Ae());console.log(r.version)}import we from"inquirer";import{writeAuth as Ce}from"sharetribe-flex-build-sdk";async function J(){let r=await we.prompt([{type:"password",name:"apiKey",message:"Enter API key:",mask:"*",validate:t=>!t||t.trim().length===0?"API key cannot be empty":!0}]);Ce({apiKey:r.apiKey}),console.log("Successfully logged in.")}import{clearAuth as Pe}from"sharetribe-flex-build-sdk";async function B(){await Pe(),console.log("Successfully logged out.")}import{listProcesses as Ie,listProcessVersions as Oe}from"sharetribe-flex-build-sdk";import O from"chalk";function S(r,t){if(t.length===0)return;let e={};for(let n of r)e[n]=n.length+1;for(let n of t)for(let i of r){let a=n[i]||"";e[i]=Math.max(e[i]||0,a.length)}console.log("");let o=r.map((n,i)=>{let a=e[n]||0,m=n.padEnd(a+1);return i===r.length-1?m:m+" "}).join("");console.log(O.bold.black(o));for(let n of t){let a=r.map((m,l)=>{let d=n[m]||"",p=e[m]||0,u=d.padEnd(p+1);return l===r.length-1?u:u+" "}).join("");console.log(a)}console.log("")}function c(r){console.error(O.red(`Error: ${r}`))}function h(r){console.log(O.green(r))}function be(r){try{let t=new Date(r),e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return r}}async function b(r,t){try{if(t){let e=await Oe(void 0,r,t);if(e.length===0){console.log(`No versions found for process: ${t}`);return}let s=e.map(o=>({Created:be(o.createdAt),Version:o.version.toString(),Aliases:o.aliases?.join(", ")||"",Transactions:o.transactionCount?.toString()||"0"}));S(["Created","Version","Aliases","Transactions"],s)}else{let e=await Ie(void 0,r);if(e.length===0){console.log("No processes found.");return}let s=e.map(o=>({Name:o.name,"Latest version":o.version?.toString()||""}));S(["Name","Latest version"],s)}}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to list processes"),process.exit(1)}}import{createProcess as xe}from"sharetribe-flex-build-sdk";import{readFileSync as Re}from"node:fs";import{join as qe}from"node:path";async function x(r,t,e){try{let s=qe(e,"process.edn"),o=Re(s,"utf-8"),n=await xe(void 0,r,t,o);h(`Process ${n.name} successfully created with version ${n.version}.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to create process"),process.exit(1)}}import{pushProcess as Te}from"sharetribe-flex-build-sdk";import{readFileSync as R,readdirSync as Me}from"node:fs";import{join as A}from"node:path";function De(r){let t=A(r,"templates"),e=[];try{let s=Me(t);for(let o of s){let n=A(t,o),i=A(n,`${o}-html.html`),a=A(n,`${o}-subject.txt`);try{let m=R(i,"utf-8"),l=R(a,"utf-8");e.push({name:o,html:m,subject:l})}catch{}}}catch{}return e}async function q(r,t,e){try{let s=A(e,"process.edn"),o=R(s,"utf-8"),n=De(e),i=await Te(void 0,r,t,o,n);i.noChanges?console.log("No changes"):h(`Version ${i.version} successfully saved for process ${t}.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to push process"),process.exit(1)}}import{getProcess as _e}from"sharetribe-flex-build-sdk";import{writeFileSync as T,mkdirSync as M}from"node:fs";import{join as w}from"node:path";async function D(r,t,e,s,o){try{let n=await _e(void 0,r,t,{version:s,alias:o});if(!n.definition)throw new Error("No process definition in response");let{existsSync:i}=await import("node:fs"),a=i(e);M(e,{recursive:!0}),a||console.error(`Creating a new directory: ${e}`);let m=w(e,"process.edn");T(m,n.definition,"utf-8");let l=n.emailTemplates||[];if(l&&Array.isArray(l)&&l.length>0){let d=w(e,"templates");M(d,{recursive:!0});for(let p of l){let u=p.name,y=p.html,U=p.subject;if(u){let P=w(d,u);if(M(P,{recursive:!0}),y){let I=w(P,`${u}-html.html`);T(I,y,"utf-8")}if(U){let I=w(P,`${u}-subject.txt`);T(I,U,"utf-8")}}}}console.error(`Saved process to ${e}`)}catch(n){n&&typeof n=="object"&&"message"in n?c(n.message):c("Failed to pull process"),process.exit(1)}}import{createAlias as Le,updateAlias as Ne,deleteAlias as $e}from"sharetribe-flex-build-sdk";async function _(r,t,e,s){try{let o=await Le(void 0,r,t,e,s);h(`Alias ${o.alias} successfully created to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to create alias"),process.exit(1)}}async function L(r,t,e,s){try{let o=await Ne(void 0,r,t,e,s);h(`Alias ${o.alias} successfully updated to point to version ${o.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to update alias"),process.exit(1)}}async function N(r,t,e){try{let s=await $e(void 0,r,t,e);h(`Alias ${s.alias} successfully deleted.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to delete alias"),process.exit(1)}}import{deployProcess as je,parseProcessFile as Fe}from"sharetribe-flex-build-sdk";import{readFileSync as Ke}from"node:fs";import{join as Ue}from"node:path";async function $(r,t,e,s){try{let o=Ue(e,"process.edn"),n=Ke(o,"utf-8"),i=Fe(n),a=await je(void 0,r,{process:t,alias:s,path:o,processDefinition:i});a.processCreated&&h(`Process ${t} successfully created.`),h(`Version ${a.version} successfully saved for process ${t}.`),a.aliasCreated?h(`Alias ${a.alias} successfully created to point to version ${a.version}.`):h(`Alias ${a.alias} successfully updated to point to version ${a.version}.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to create/push process and alias"),process.exit(1)}}function W(r){let t=r.command("process").description("describe a process file").option("--path <PROCESS_DIR>","path to the directory where the process.edn file is").option("--transition <TRANSITION_NAME>","transition name, e.g. transition/request to get more details of it").action(async e=>{e.path?(console.log(`Describing process at: ${e.path}`),e.transition&&console.log(`Transition: ${e.transition}`),console.log("Process description not yet implemented")):t.outputHelp()});t.command("list").description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await b(s,e.process)}),t.command("create").description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await x(s,e.process,e.path)}),t.command("push").description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await q(s,e.process,e.path)}),t.command("pull").description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await D(s,e.process,e.path,e.version,e.alias)}),t.command("create-alias").description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").allowUnknownOption(!1).action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await _(s,e.process,parseInt(e.version),e.alias)}),t.command("update-alias").description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await L(s,e.process,parseInt(e.version),e.alias)}),t.command("delete-alias").description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await N(s,e.process,e.alias)}),t.command("deploy").description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await $(s,e.process,e.path,e.alias)}),r.command("process-list",{hidden:!0}).description("list all transaction processes").option("--process <PROCESS_NAME>","print version and alias info of a specific process").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await b(s,e.process)}),r.command("process-create",{hidden:!0}).description("create a new transaction process").requiredOption("--process <PROCESS_NAME>","name for the new process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await x(s,e.process,e.path)}),r.command("process-push",{hidden:!0}).description("push a process file to the remote").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory where the process.edn file is").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await q(s,e.process,e.path)}),r.command("process-pull",{hidden:!0}).description("fetch a process file").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path where to save the process").option("--version <VERSION_NUM>","version number").option("--alias <PROCESS_ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await D(s,e.process,e.path,e.version,e.alias)}),r.command("process-create-alias",{hidden:!0}).description("create a new alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await _(s,e.process,parseInt(e.version),e.alias)}),r.command("process-update-alias",{hidden:!0}).description("update an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--version <VERSION_NUM>","version number").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await L(s,e.process,parseInt(e.version),e.alias)}),r.command("process-delete-alias",{hidden:!0}).description("delete an existing alias").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await N(s,e.process,e.alias)}),r.command("process-deploy",{hidden:!0}).description("deploy a process file with alias (create/push + alias create/update)").requiredOption("--process <PROCESS_NAME>","name of the process").requiredOption("--path <LOCAL_PROCESS_DIR>","path to the directory with the process files").requiredOption("--alias <ALIAS>","alias name").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await $(s,e.process,e.path,e.alias)})}import{listSearchSchemas as Ve,setSearchSchema as He,unsetSearchSchema as Je}from"sharetribe-flex-build-sdk";var G={metadata:"Metadata",private:"Private data",protected:"Protected data",public:"Public data"};async function Be(r,t){try{await He(void 0,r,{key:t.key,scope:t.scope,type:t.type,doc:t.doc,defaultValue:t.default,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",s=G[t.scope]||t.scope;console.log(`${s} schema, ${t.key} is successfully set for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to set search schema"),process.exit(1)}}async function We(r,t){try{await Je(void 0,r,{key:t.key,scope:t.scope,schemaFor:t.schemaFor});let e=t.schemaFor||"listing",s=G[t.scope]||t.scope;console.log(`${s} schema, ${t.key} is successfully unset for ${e}.`)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to unset search schema"),process.exit(1)}}function Ge(r){return r==null?"":Array.isArray(r)?r.join(", "):String(r)}async function Qe(r){try{let t=await Ve(void 0,r);if(t.length===0){console.log("No search schemas found.");return}let e=t.map(i=>({"Schema for":i.schemaFor,Scope:i.scope,Key:i.key,Type:i.type,"Default value":Ge(i.defaultValue),Doc:i.doc||""})).sort((i,a)=>i["Schema for"]!==a["Schema for"]?i["Schema for"].localeCompare(a["Schema for"]):i.Scope!==a.Scope?i.Scope.localeCompare(a.Scope):i.Key.localeCompare(a.Key)),s=["Schema for","Scope","Key","Type","Default value","Doc"],o={};for(let i of s)o[i]=i.length+1;for(let i of e)for(let a of s){let m=i[a]||"";o[a]=Math.max(o[a],m.length)}console.log("");let n=s.map((i,a)=>{let m=o[i]||0,l=i.padEnd(m);return a===s.length-1?l+" ":l+" "});console.log(n.join(""));for(let i of e){let a=s.map((m,l)=>{let d=i[m]||"",p=o[m]||0,u=d.padEnd(p);return l===s.length-1?u+" ":u+" "});console.log(a.join(""))}console.log("")}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to list search schemas"),process.exit(1)}}function Q(r){let t=r.command("search").description("list all search schemas").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Qe(s)});t.command("set").description("set search schema").requiredOption("--key <KEY>","schema key").requiredOption("--scope <SCOPE>","schema scope").requiredOption("--type <TYPE>","value type (enum, multi-enum, boolean, long, or text)").option("--doc <DOC>","description of the schema").option("--default <DEFAULT>","default value for search if value is not set").option("--schema-for <SCHEMA_FOR>","subject of the schema (listing, userProfile, or transaction)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Be(s,{key:e.key,scope:e.scope,type:e.type,doc:e.doc,default:e.default,schemaFor:e.schemaFor})}),t.command("unset").description("unset search schema").requiredOption("--key <KEY>","schema key").requiredOption("--scope <SCOPE>","schema scope").option("--schema-for <SCHEMA_FOR>","subject of the schema (listing, userProfile, or transaction)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await We(s,{key:e.key,scope:e.scope,schemaFor:e.schemaFor})})}import{pullAssets as Ye,pushAssets as Xe}from"sharetribe-flex-build-sdk";import{readFileSync as Y,writeFileSync as X,existsSync as k,mkdirSync as j,readdirSync as ze,statSync as F,unlinkSync as Ze}from"node:fs";import{join as E,dirname as et}from"node:path";import{createHash as tt}from"node:crypto";import st from"chalk";import g from"jsedn";function z(r){let t=E(r,".flex-cli","asset-meta.edn");if(!k(t))return null;try{let e=Y(t,"utf-8"),s=g.parse(e),o=s.at(g.kw(":version")),n=s.at(g.kw(":assets")),i=[];if(n&&n.val)for(let a of n.val)i.push({path:a.at(g.kw(":path")),"content-hash":a.at(g.kw(":content-hash"))});return{version:o,assets:i}}catch{return null}}function Z(r,t){let e=E(r,".flex-cli");k(e)||j(e,{recursive:!0});let s=t.assets.map(i=>new g.Map([g.kw(":path"),i.path,g.kw(":content-hash"),i["content-hash"]])),o=new g.Map([g.kw(":version"),t.version,g.kw(":assets"),new g.Vector(s)]),n=E(r,".flex-cli","asset-meta.edn");X(n,g.encode(o),"utf-8")}function ee(r){let t=Buffer.from(`${r.length}|`,"utf-8");return tt("sha1").update(t).update(r).digest("hex")}function rt(r){let t=[];function e(s,o=""){let n=ze(s);for(let i of n){if(i===".flex-cli")continue;let a=E(s,i),m=o?E(o,i):i,l=F(a);if(l.isDirectory())e(a,m);else if(l.isFile()){let d=Y(a),p=ee(d);t.push({path:m,data:d,hash:p})}}}return e(r),t}function ot(r){for(let t of r)if(t.path.endsWith(".json"))try{JSON.parse(t.data.toString("utf-8"))}catch(e){throw new Error(`Invalid JSON in ${t.path}: ${e}`)}}async function nt(r,t,e,s){try{if(k(t)||j(t,{recursive:!0}),!F(t).isDirectory())throw new Error(`${t} is not a directory`);let n=await Ye(void 0,r,e?{version:e}:void 0),i=n.version,a=z(t);if(a&&a.version===i&&n.assets.length===a.assets.length){console.log("Assets are up to date.");return}let m=[];for(let l of n.assets){let d=E(t,l.path),p=et(d);k(p)||j(p,{recursive:!0});let u=Buffer.from(l.dataRaw,"base64");X(d,u);let y=ee(u);m.push({path:l.path,"content-hash":l.contentHash||y})}if(s&&a){let l=new Set(n.assets.map(d=>d.path));for(let d of a.assets)if(!l.has(d.path)){let p=E(t,d.path);k(p)&&Ze(p)}}Z(t,{version:i,assets:m}),console.log(`Version ${i} successfully pulled.`)}catch(o){o&&typeof o=="object"&&"message"in o?c(o.message):c("Failed to pull assets"),process.exit(1)}}async function it(r,t,e){try{if(!k(t)||!F(t).isDirectory())throw new Error(`${t} is not a valid directory`);let s=z(t),o=s?.version||"nil",n=rt(t);ot(n);let i=[],a=new Map(n.map(p=>[p.path,p])),m=new Map((s?.assets||[]).map(p=>[p.path,p["content-hash"]]));for(let[p,u]of a){let y=m.get(p);(!y||y!==u.hash)&&i.push({path:p,op:"upsert",data:u.data})}if(e&&s)for(let p of s.assets)a.has(p.path)||i.push({path:p.path,op:"delete"});if(i.length===0){console.log("Assets are up to date.");return}let l=i.filter(p=>p.op==="upsert").map(p=>p.path);l.length>0&&console.log(st.green(`Uploading changed assets: ${l.join(", ")}`));let d=await Xe(void 0,r,o,i);Z(t,{version:d.version,assets:d.assets.map(p=>({path:p.path,"content-hash":p.contentHash}))}),console.log(`New version ${d.version} successfully created.`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to push assets"),process.exit(1)}}function te(r){let t=r.command("assets").description("manage marketplace assets");t.command("pull").description("pull assets from remote").requiredOption("--path <PATH>","path to directory where assets will be stored").option("--version <VERSION>","version of assets to pull").option("--prune","delete local files no longer present as remote assets").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await nt(s,e.path,e.version,e.prune)}),t.command("push").description("push assets to remote").requiredOption("--path <PATH>","path to directory with assets").option("--prune","delete remote assets no longer present locally").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await it(s,e.path,e.prune)})}import{sendNotification as at,previewNotification as ct}from"sharetribe-flex-build-sdk";import{readFileSync as K,existsSync as C,statSync as lt}from"node:fs";import{join as se}from"node:path";import{createServer as pt}from"node:http";function re(r){if(!C(r)||!lt(r).isDirectory())throw new Error(`Template directory not found: ${r}`);let t=se(r,"template.html"),e=se(r,"template-subject.txt");if(!C(t))throw new Error(`template.html not found in ${r}`);if(!C(e))throw new Error(`template-subject.txt not found in ${r}`);let s=K(t,"utf-8"),o=K(e,"utf-8").trim();return{html:s,subject:o}}function oe(r){if(!r)return;if(!C(r))throw new Error(`Context file not found: ${r}`);let t=K(r,"utf-8");try{return JSON.parse(t)}catch(e){throw new Error(`Invalid JSON in context file: ${e}`)}}async function mt(r,t,e){try{let s=re(t),o=oe(e),n=await at(void 0,r,{template:s,context:o});console.log(`Preview successfully sent to ${n.adminEmail}`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to send notification"),process.exit(1)}}async function dt(r,t,e){try{let s=re(t),o=oe(e);console.log(`Template: ${t}`),console.log(`Subject: ${s.subject}`),console.log(""),console.log("Starting preview server at http://localhost:3535"),console.log("Press Ctrl+C to stop"),console.log("");let n=null,i=async()=>{try{let d=(await ct(void 0,r,{template:s,context:o})).html,p=`<title>${s.subject}</title>`;d.includes("<head>")?n=d.replace("<head>",`<head>
4
+ ${p}`):d.includes("<html>")?n=d.replace("<html>",`<html>
5
+ <head>${p}</head>`):n=`<html><head>${p}</head><body>${d}</body></html>`}catch(l){n=`
6
6
  <html>
7
7
  <head><title>Error</title></head>
8
8
  <body style="font-family: sans-serif; padding: 20px;">
9
9
  <h1 style="color: #d32f2f;">Error</h1>
10
- <pre style="background: #f5f5f5; padding: 15px; border-radius: 4px;">${p&&typeof p=="object"&&"message"in p?p.message:"Failed to preview notification"}</pre>
10
+ <pre style="background: #f5f5f5; padding: 15px; border-radius: 4px;">${l&&typeof l=="object"&&"message"in l?l.message:"Failed to preview notification"}</pre>
11
11
  </body>
12
12
  </html>
13
- `}};await i();let a=at(async(p,l)=>{p.url==="/"||p.url===""?(await i(),l.writeHead(200,{"Content-Type":"text/html"}),l.end(n)):(l.writeHead(404,{"Content-Type":"text/plain"}),l.end("Not Found"))});a.listen(3535,()=>{console.log("Preview server started. Open http://localhost:3535 in your browser.")});let m=()=>{console.log(`
14
- Shutting down preview server...`),a.close(()=>{process.exit(0)})};process.on("SIGINT",m),process.on("SIGTERM",m)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to preview notification"),process.exit(1)}}function oe(r){let t=r.command("notifications").description("manage email notifications");t.command("preview").description("render a preview of an email template").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await lt(s,e.template,e.context)}),t.command("send").description("send a preview of an email template to the logged in admin").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await ct(s,e.template,e.context)})}import{getListingApprovalStatus as pt,enableListingApproval as mt,disableListingApproval as dt}from"sharetribe-flex-build-sdk";async function ft(r){try{(await pt(void 0,r)).enabled?console.log(`Listing approvals are enabled in ${r}`):console.log(`Listing approvals are disabled in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to get listing approval status"),process.exit(1)}}async function ut(r){try{await mt(void 0,r),console.log(`Successfully enabled listing approvals in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to enable listing approvals"),process.exit(1)}}async function ht(r){try{await dt(void 0,r),console.log(`Successfully disabled listing approvals in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to disable listing approvals"),process.exit(1)}}function ne(r){let t=r.command("listing-approval").description("manage listing approvals (DEPRECATED - use Console instead)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await ft(s)}),t.command("enable").description("enable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await ut(s)}),t.command("disable").description("disable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await ht(s)})}import{queryEvents as gt,pollEvents as yt}from"sharetribe-flex-build-sdk";function ie(r){if([r.sequenceId!==void 0,r.afterSeqId!==void 0,r.beforeSeqId!==void 0,r.afterTs!==void 0,r.beforeTs!==void 0].filter(Boolean).length>1)throw new Error("Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified");if(r.resourceId&&r.relatedResourceId)throw new Error("Only one of --resource or --related-resource can be specified")}function ae(r){try{let t=new Date(r),e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return r}}async function Et(r,t){try{ie(t);let e=await gt(void 0,r,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,sequenceId:t.sequenceId,afterSeqId:t.afterSeqId,beforeSeqId:t.beforeSeqId,afterTs:t.afterTs,beforeTs:t.beforeTs,limit:t.limit});if(e.length===0){console.log("No events found.");return}if(t.json)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n))}else if(t.jsonPretty)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n,null,2))}else E(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],e.map(s=>{let o=s.auditEmails?.userEmail||s.auditEmails?.adminEmail||"",n=s.source?.replace("source/","")||"";return{"Seq ID":s.sequenceId.toString(),"Resource ID":s.resourceId,"Event type":s.eventType,"Created at local time":ae(s.createdAt),Source:n,Actor:o}}))}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to query events"),process.exit(1)}}async function St(r,t){try{ie(t),console.log("Tailing events... Press Ctrl+C to stop"),console.log("");let e=yt(void 0,r,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,limit:t.limit||10},o=>{if(t.json)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a))}else if(t.jsonPretty)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a,null,2))}else E(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],o.map(n=>{let i=n.auditEmails?.userEmail||n.auditEmails?.adminEmail||"",a=n.source?.replace("source/","")||"";return{"Seq ID":n.sequenceId.toString(),"Resource ID":n.resourceId,"Event type":n.eventType,"Created at local time":ae(n.createdAt),Source:a,Actor:i}}))},5e3),s=()=>{console.log(`
15
- Stopping tail...`),e(),process.exit(0)};process.on("SIGINT",s),process.on("SIGTERM",s)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to tail events"),process.exit(1)}}function ce(r){let t=r.command("events").description("Get a list of events.").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("--seqid <SEQUENCE_ID>","get event with specific sequence ID",parseInt).option("--after-seqid <SEQUENCE_ID>","show events after sequence ID (exclusive)",parseInt).option("--before-seqid <SEQUENCE_ID>","show events before sequence ID (exclusive)",parseInt).option("--after-ts <TIMESTAMP>","show events after timestamp").option("--before-ts <TIMESTAMP>","show events before timestamp").option("-l, --limit <NUMBER>","limit results (default: 100, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exit(1)),await Et(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,sequenceId:e.seqid,afterSeqId:e.afterSeqid,beforeSeqId:e.beforeSeqid,afterTs:e.afterTs,beforeTs:e.beforeTs,limit:e.limit||100,json:e.json,jsonPretty:e.jsonPretty})}),t.command("tail").description("Tail events live as they happen").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("-l, --limit <NUMBER>","limit results per poll (default: 10, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exit(1)),await St(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,limit:e.limit||10,json:e.json,jsonPretty:e.jsonPretty})})}import{updateStripeVersion as kt,SUPPORTED_STRIPE_VERSIONS as vt}from"sharetribe-flex-build-sdk";import le from"inquirer";async function At(){return(await le.prompt([{type:"list",name:"version",message:"Select Stripe API version:",choices:[...vt]}])).version}async function wt(){return console.log(""),console.log("WARNING: Changing Stripe API version may affect your integration."),console.log(""),console.log("After updating the Stripe API version, you may need to:"),console.log("- Handle new Capabilities requirements"),console.log("- Update identity verification settings"),console.log(""),console.log("See Stripe documentation for details:"),console.log("https://stripe.com/docs/connect/capabilities-overview"),console.log("https://stripe.com/docs/connect/identity-verification"),console.log(""),(await le.prompt([{type:"confirm",name:"confirmed",message:"Do you want to continue?",default:!1}])).confirmed}async function Ct(r,t,e){try{let s=t;s||(s=await At()),e||await wt()||(console.log("Cancelled."),process.exit(0)),await kt(void 0,r,s),console.log(`Stripe API version successfully changed to ${s}`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to update Stripe API version"),process.exit(1)}}function pe(r){r.command("stripe").description("manage Stripe integration").command("update-version").description("update Stripe API version in use").option("--version <VERSION>","Stripe API version to update to").option("-f, --force","skip confirmation prompt and force update").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Ct(s,e.version,e.force)})}function Pt(r){let t=[],e=!r.parent,s=r.description();if(s&&(t.push(s),t.push("")),e){let a=r.version();a&&(t.push("VERSION"),t.push(` ${a}`),t.push(""))}t.push("USAGE");let o=It(r);t.push(` $ ${o}`),t.push("");let n=de(r),i=r.options.length>0&&!e;if(n.length>0&&!i){t.push("COMMANDS");let a=Math.max(...n.map(m=>m.name.length));for(let m of n){let p=m.name.padEnd(a+2);t.push(` ${p}${m.description}`)}t.push("")}if(!e){let a=r.options;if(a.length>0){t.push("OPTIONS");let m=Math.max(...a.map(p=>me(p).length));for(let p of a){let d=me(p).padEnd(m+2),f=p.description||"";t.push(` ${d}${f}`)}t.push("")}}if(n.length>0&&!i){t.push("Subcommand help:");let a=fe(r);t.push(` $ ${a} help [COMMAND]`)}return t.push(""),t.join(`
16
- `)}function de(r){let t=[],e=r.commands.filter(s=>!s._hidden&&s.name()!=="help");for(let s of e){let o=Ot(s),n=s.commands.filter(i=>!i._hidden);if(s.description()&&t.push({name:o,description:s.description()||""}),n.length>0){let i=de(s);for(let a of i)t.push(a)}}return r.parent||t.unshift({name:"help",description:"display help for Flex CLI"}),t.sort((s,o)=>s.name.localeCompare(o.name)),t}function fe(r){let t=[],e=r;for(;e;)e.name()&&t.unshift(e.name()),e=e.parent;return t.length>0&&(t[0]="sharetribe-cli"),t.join(" ")}function It(r){let t=fe(r),e=r.commands.filter(n=>!n._hidden),s=r.options.length>0;return!r.parent&&e.length>0?`${t} [COMMAND]`:e.length>0&&!s?`${t} [COMMAND]`:t}function Ot(r){let t=[],e=r;for(;e&&e.parent;)e.name()&&t.unshift(e.name()),e=e.parent;return t.join(" ")}function me(r){let e=(r.flags||"").split(/,\s*/),s=[];for(let o of e){let n=o.trim(),i=n.match(/^((?:-{1,2}[\w-]+))\s*[<\[]([^\]>]+)[\]>]/);if(i){let a=i[1],m=i[2];s.push(`${a}=${m}`)}else s.push(n)}return s.join(", ")}function ue(r){r.configureHelp({formatHelp:(t,e)=>Pt(t)})}function he(r){let t=r.findIndex(o=>o==="process");if(t===-1)return r;let e=r[t+1];return e&&["list","create","push","pull","create-alias","update-alias","delete-alias","deploy"].includes(e)?[...r.slice(0,t),`process-${e}`,...r.slice(t+2)]:r}var Dt=xt(import.meta.url),_t=qt(Dt),Mt=JSON.parse(Rt(Tt(_t,"../package.json"),"utf-8")),ge=he(process.argv),u=new bt;ue(u);u.configureOutput({writeOut:r=>process.stdout.write(r+`
13
+ `}};await i();let a=pt(async(l,d)=>{l.url==="/"||l.url===""?(await i(),d.writeHead(200,{"Content-Type":"text/html"}),d.end(n)):(d.writeHead(404,{"Content-Type":"text/plain"}),d.end("Not Found"))});a.listen(3535,()=>{console.log("Preview server started. Open http://localhost:3535 in your browser.")});let m=()=>{console.log(`
14
+ Shutting down preview server...`),a.close(()=>{process.exit(0)})};process.on("SIGINT",m),process.on("SIGTERM",m)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to preview notification"),process.exit(1)}}function ne(r){let t=r.command("notifications").description("manage email notifications");t.command("preview").description("render a preview of an email template").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await dt(s,e.template,e.context)}),t.command("send").description("send a preview of an email template to the logged in admin").requiredOption("--template <TEMPLATE_DIR>","path to template directory").option("--context <CONTEXT_FILE>","path to email rendering context JSON file").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await mt(s,e.template,e.context)})}import{getListingApprovalStatus as ft,enableListingApproval as ut,disableListingApproval as ht}from"sharetribe-flex-build-sdk";async function gt(r){try{(await ft(void 0,r)).enabled?console.log(`Listing approvals are enabled in ${r}`):console.log(`Listing approvals are disabled in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to get listing approval status"),process.exit(1)}}async function yt(r){try{await ut(void 0,r),console.log(`Successfully enabled listing approvals in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to enable listing approvals"),process.exit(1)}}async function Et(r){try{await ht(void 0,r),console.log(`Successfully disabled listing approvals in ${r}`)}catch(t){t&&typeof t=="object"&&"message"in t?c(t.message):c("Failed to disable listing approvals"),process.exit(1)}}function ie(r){let t=r.command("listing-approval").description("manage listing approvals (DEPRECATED - use Console instead)").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await gt(s)}),t.command("enable").description("enable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await yt(s)}),t.command("disable").description("disable listing approvals").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{console.warn("Warning: CLI command `listing-approval` is deprecated. Use Console instead.");let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Et(s)})}import{queryEvents as St,pollEvents as kt}from"sharetribe-flex-build-sdk";function ae(r){if([r.sequenceId!==void 0,r.afterSeqId!==void 0,r.beforeSeqId!==void 0,r.afterTs!==void 0,r.beforeTs!==void 0].filter(Boolean).length>1)throw new Error("Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified");if(r.resourceId&&r.relatedResourceId)throw new Error("Only one of --resource or --related-resource can be specified")}function ce(r){try{let t=new Date(r),e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),n=t.toLocaleTimeString("en-US");return`${e}-${s}-${o} ${n}`}catch{return r}}async function vt(r,t){try{ae(t);let e=await St(void 0,r,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,sequenceId:t.sequenceId,afterSeqId:t.afterSeqId,beforeSeqId:t.beforeSeqId,afterTs:t.afterTs,beforeTs:t.beforeTs,limit:t.limit});if(e.length===0){console.log("No events found.");return}if(t.json)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n))}else if(t.jsonPretty)for(let s of e){let{auditEmails:o,...n}=s;console.log(JSON.stringify(n,null,2))}else S(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],e.map(s=>{let o=s.auditEmails?.userEmail||s.auditEmails?.adminEmail||"",n=s.source?.replace("source/","")||"";return{"Seq ID":s.sequenceId.toString(),"Resource ID":s.resourceId,"Event type":s.eventType,"Created at local time":ce(s.createdAt),Source:n,Actor:o}}))}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to query events"),process.exit(1)}}async function At(r,t){try{ae(t),console.log("Tailing events... Press Ctrl+C to stop"),console.log("");let e=kt(void 0,r,{resourceId:t.resourceId,relatedResourceId:t.relatedResourceId,eventTypes:t.eventTypes,limit:t.limit||10},o=>{if(t.json)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a))}else if(t.jsonPretty)for(let n of o){let{auditEmails:i,...a}=n;console.log(JSON.stringify(a,null,2))}else S(["Seq ID","Resource ID","Event type","Created at local time","Source","Actor"],o.map(n=>{let i=n.auditEmails?.userEmail||n.auditEmails?.adminEmail||"",a=n.source?.replace("source/","")||"";return{"Seq ID":n.sequenceId.toString(),"Resource ID":n.resourceId,"Event type":n.eventType,"Created at local time":ce(n.createdAt),Source:a,Actor:i}}))},5e3),s=()=>{console.log(`
15
+ Stopping tail...`),e(),process.exit(0)};process.on("SIGINT",s),process.on("SIGTERM",s)}catch(e){e&&typeof e=="object"&&"message"in e?c(e.message):c("Failed to tail events"),process.exit(1)}}function le(r){let t=r.command("events").description("Get a list of events.").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("--seqid <SEQUENCE_ID>","get event with specific sequence ID",parseInt).option("--after-seqid <SEQUENCE_ID>","show events after sequence ID (exclusive)",parseInt).option("--before-seqid <SEQUENCE_ID>","show events before sequence ID (exclusive)",parseInt).option("--after-ts <TIMESTAMP>","show events after timestamp").option("--before-ts <TIMESTAMP>","show events before timestamp").option("-l, --limit <NUMBER>","limit results (default: 100, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");t.action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exit(1)),await vt(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,sequenceId:e.seqid,afterSeqId:e.afterSeqid,beforeSeqId:e.beforeSeqid,afterTs:e.afterTs,beforeTs:e.beforeTs,limit:e.limit||100,json:e.json,jsonPretty:e.jsonPretty})}),t.command("tail").description("Tail events live as they happen").option("--resource <RESOURCE_ID>","show events for specific resource ID").option("--related-resource <RELATED_RESOURCE_ID>","show events related to specific resource ID").option("--filter <EVENT_TYPES>","filter by event types (comma-separated)").option("-l, --limit <NUMBER>","limit results per poll (default: 10, max: 100)",parseInt).option("--json","output as single-line JSON strings").option("--json-pretty","output as indented multi-line JSON").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Could not parse arguments:"),console.error("--marketplace is required"),process.exit(1)),await At(s,{resourceId:e.resource,relatedResourceId:e.relatedResource,eventTypes:e.filter,limit:e.limit||10,json:e.json,jsonPretty:e.jsonPretty})})}import{updateStripeVersion as wt,SUPPORTED_STRIPE_VERSIONS as Ct}from"sharetribe-flex-build-sdk";import pe from"inquirer";async function Pt(){return(await pe.prompt([{type:"list",name:"version",message:"Select Stripe API version:",choices:[...Ct]}])).version}async function It(){return console.log(""),console.log("WARNING: Changing Stripe API version may affect your integration."),console.log(""),console.log("After updating the Stripe API version, you may need to:"),console.log("- Handle new Capabilities requirements"),console.log("- Update identity verification settings"),console.log(""),console.log("See Stripe documentation for details:"),console.log("https://stripe.com/docs/connect/capabilities-overview"),console.log("https://stripe.com/docs/connect/identity-verification"),console.log(""),(await pe.prompt([{type:"confirm",name:"confirmed",message:"Do you want to continue?",default:!1}])).confirmed}async function Ot(r,t,e){try{let s=t;s||(s=await Pt()),e||await It()||(console.log("Cancelled."),process.exit(0)),await wt(void 0,r,s),console.log(`Stripe API version successfully changed to ${s}`)}catch(s){s&&typeof s=="object"&&"message"in s?c(s.message):c("Failed to update Stripe API version"),process.exit(1)}}function me(r){r.command("stripe").description("manage Stripe integration").command("update-version").description("update Stripe API version in use").option("--version <VERSION>","Stripe API version to update to").option("-f, --force","skip confirmation prompt and force update").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier").action(async e=>{let s=e.marketplace||r.opts().marketplace;s||(console.error("Error: --marketplace is required"),process.exit(1)),await Ot(s,e.version,e.force)})}import v from"jsedn";import{getConfigMap as bt,readAuth as xt}from"sharetribe-flex-build-sdk";function Rt(r){return r.length<=4?`...${r}`:`...${r.slice(-4)}`}function qt(r){let t=[];for(let[e,s]of Object.entries(r))t.push(v.kw(`:${e}`),s);return new v.Map(t)}function de(){let r=xt(),t=r?.apiKey?Rt(r.apiKey):"No API key set",e=bt(),s=new v.Map([v.kw(":api-key"),t,v.kw(":conf-map"),qt(e)]);console.log(v.encode(s))}function Tt(r){let t=[],e=!r.parent,s=r.description();if(s&&(t.push(s),t.push("")),e){let a=r.version();a&&(t.push("VERSION"),t.push(` ${a}`),t.push(""))}t.push("USAGE");let o=Mt(r);t.push(` $ ${o}`),t.push("");let n=ue(r),i=r.options.length>0&&!e;if(n.length>0&&!i){t.push("COMMANDS");let a=Math.max(...n.map(m=>m.name.length));for(let m of n){let l=m.name.padEnd(a+2);t.push(` ${l}${m.description}`)}t.push("")}if(!e){let a=r.options;if(a.length>0){t.push("OPTIONS");let m=Math.max(...a.map(l=>fe(l).length));for(let l of a){let p=fe(l).padEnd(m+2),u=l.description||"";t.push(` ${p}${u}`)}t.push("")}}if(n.length>0&&!i){t.push("Subcommand help:");let a=he(r);t.push(` $ ${a} help [COMMAND]`)}return t.push(""),t.join(`
16
+ `)}function ue(r){let t=[],e=r.commands.filter(s=>!s._hidden&&s.name()!=="help");for(let s of e){let o=Dt(s),n=s.commands.filter(i=>!i._hidden);if(s.description()&&t.push({name:o,description:s.description()||""}),n.length>0){let i=ue(s);for(let a of i)t.push(a)}}return r.parent||t.unshift({name:"help",description:"display help for Flex CLI"}),t.sort((s,o)=>s.name.localeCompare(o.name)),t}function he(r){let t=[],e=r;for(;e;)e.name()&&t.unshift(e.name()),e=e.parent;return t.length>0&&(t[0]="sharetribe-cli"),t.join(" ")}function Mt(r){let t=he(r),e=r.commands.filter(n=>!n._hidden),s=r.options.length>0;return!r.parent&&e.length>0?`${t} [COMMAND]`:e.length>0&&!s?`${t} [COMMAND]`:t}function Dt(r){let t=[],e=r;for(;e&&e.parent;)e.name()&&t.unshift(e.name()),e=e.parent;return t.join(" ")}function fe(r){let e=(r.flags||"").split(/,\s*/),s=[];for(let o of e){let n=o.trim(),i=n.match(/^((?:-{1,2}[\w-]+))\s*[<\[]([^\]>]+)[\]>]/);if(i){let a=i[1],m=i[2];s.push(`${a}=${m}`)}else s.push(n)}return s.join(", ")}function ge(r){r.configureHelp({formatHelp:(t,e)=>Tt(t)})}function ye(r){let t=r.findIndex(o=>o==="process");if(t===-1)return r;let e=r[t+1];return e&&["list","create","push","pull","create-alias","update-alias","delete-alias","deploy"].includes(e)?[...r.slice(0,t),`process-${e}`,...r.slice(t+2)]:r}var Ft=Nt(import.meta.url),Kt=$t(Ft),Ut=JSON.parse(Lt(jt(Kt,"../package.json"),"utf-8")),Ee=ye(process.argv),f=new _t;ge(f);f.configureOutput({writeOut:r=>process.stdout.write(r+`
17
17
  `),writeErr:r=>process.stderr.write(r+`
18
- `)});u.name("sharetribe-cli").description("CLI to interact with Sharetribe Flex").version(Mt.version,"-V","output the version number").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");u.command("version").description("show version").action(()=>{V()});u.command("login").description("log in with API key").action(async()=>{await H()});u.command("logout").description("logout").action(async()=>{await J()});W(u);G(u);ee(u);oe(u);ne(u);ce(u);pe(u);u.command("help [command...]").description("display help for Flex CLI").action(r=>{if(!r||r.length===0){u.outputHelp();return}let t=u;for(let e of r){let s=t.commands.find(o=>o.name()===e);s||(console.error(`Unknown command: ${r.join(" ")}`),process.exit(1)),t=s}t.outputHelp()});ge.slice(2).length?u.parse(ge):u.outputHelp();
18
+ `)});f.name("sharetribe-cli").description("CLI to interact with Sharetribe Flex").version(Ut.version,"-V","output the version number").option("-m, --marketplace <MARKETPLACE_ID>","marketplace identifier");f.command("version").description("show version").action(()=>{H()});f.command("login").description("log in with API key").action(async()=>{await J()});f.command("logout").description("logout").action(async()=>{await B()});f.command("debug").description("display debug info").action(()=>{de()});W(f);Q(f);te(f);ne(f);ie(f);le(f);me(f);f.command("help [command...]").description("display help for Flex CLI").action(r=>{if(!r||r.length===0){f.outputHelp();return}let t=f;for(let e of r){let s=t.commands.find(o=>o.name()===e);s||(console.error(`Unknown command: ${r.join(" ")}`),process.exit(1)),t=s}t.outputHelp()});Ee.slice(2).length?f.parse(Ee):f.outputHelp();
19
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/commands/version.ts", "../src/commands/login.ts", "../src/commands/logout.ts", "../src/commands/process/list.ts", "../src/util/output.ts", "../src/commands/process/create.ts", "../src/commands/process/push.ts", "../src/commands/process/pull.ts", "../src/commands/process/aliases.ts", "../src/commands/process/combined.ts", "../src/commands/process/index.ts", "../src/commands/search/index.ts", "../src/commands/assets/index.ts", "../src/commands/notifications/index.ts", "../src/commands/listing-approval.ts", "../src/commands/events/index.ts", "../src/commands/stripe/index.ts", "../src/util/help-formatter.ts", "../src/util/command-router.ts"],
4
- "sourcesContent": ["/**\n * Sharetribe CLI - Unofficial 100% compatible implementation\n *\n * Main entry point for the CLI application\n */\n\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport { version } from './commands/version.js';\nimport { login } from './commands/login.js';\nimport { logout } from './commands/logout.js';\nimport { registerProcessCommands } from './commands/process/index.js';\nimport { registerSearchCommands } from './commands/search/index.js';\nimport { registerAssetsCommands } from './commands/assets/index.js';\nimport { registerNotificationsCommands } from './commands/notifications/index.js';\nimport { registerListingApprovalCommand } from './commands/listing-approval.js';\nimport { registerEventsCommand } from './commands/events/index.js';\nimport { registerStripeCommands } from './commands/stripe/index.js';\nimport { configureHelp } from './util/help-formatter.js';\nimport { routeProcessCommand } from './util/command-router.js';\n\n// Get package.json for version info\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '../package.json'), 'utf-8')\n);\n\n// Route argv to handle process subcommands\nconst routedArgv = routeProcessCommand(process.argv);\n\nconst program = new Command();\n\n// Configure custom help formatter to match flex-cli\nconfigureHelp(program);\n\n// Configure output to add trailing newline (flex-cli behavior)\nprogram.configureOutput({\n writeOut: (str) => process.stdout.write(str + '\\n'),\n writeErr: (str) => process.stderr.write(str + '\\n'),\n});\n\n// Configure the main program\nprogram\n .name('sharetribe-cli')\n .description('CLI to interact with Sharetribe Flex')\n .version(packageJson.version, '-V', 'output the version number')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n// Register commands\n\n// version command\nprogram\n .command('version')\n .description('show version')\n .action(() => {\n version();\n });\n\n// login command\nprogram\n .command('login')\n .description('log in with API key')\n .action(async () => {\n await login();\n });\n\n// logout command\nprogram\n .command('logout')\n .description('logout')\n .action(async () => {\n await logout();\n });\n\n// Register process commands\nregisterProcessCommands(program);\n\n// Register search commands\nregisterSearchCommands(program);\n\n// Register assets commands\nregisterAssetsCommands(program);\n\n// Register notifications commands\nregisterNotificationsCommands(program);\n\n// Register listing-approval command\nregisterListingApprovalCommand(program);\n\n// Register events command\nregisterEventsCommand(program);\n\n// Register stripe commands\nregisterStripeCommands(program);\n\n// Register custom help command (to support \"help process list\" syntax)\nprogram\n .command('help [command...]')\n .description('display help for Flex CLI')\n .action((commandPath: string[]) => {\n if (!commandPath || commandPath.length === 0) {\n program.outputHelp();\n return;\n }\n\n // Navigate to the nested command\n let targetCmd: Command = program;\n for (const cmdName of commandPath) {\n const subCmd = targetCmd.commands.find(c => c.name() === cmdName);\n if (!subCmd) {\n console.error(`Unknown command: ${commandPath.join(' ')}`);\n process.exit(1);\n }\n targetCmd = subCmd;\n }\n\n // Show help for the target command\n targetCmd.outputHelp();\n });\n\n// If no command specified, show help and exit with status 0\nif (!routedArgv.slice(2).length) {\n program.outputHelp();\n // Don't call process.exit() - let Commander handle it naturally with exitOverride\n} else {\n // Parse command line arguments with routed argv\n program.parse(routedArgv);\n}\n", "/**\n * Version command - displays the CLI version\n *\n * Must match flex-cli output format exactly\n */\n\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\n/**\n * Finds package.json by traversing up from current file\n */\nfunction findPackageJson(): string {\n const __filename = fileURLToPath(import.meta.url);\n let currentDir = dirname(__filename);\n\n // Traverse up to find package.json\n while (currentDir !== '/') {\n try {\n const pkgPath = join(currentDir, 'package.json');\n const content = readFileSync(pkgPath, 'utf-8');\n return content;\n } catch {\n currentDir = dirname(currentDir);\n }\n }\n\n throw new Error('Could not find package.json');\n}\n\n/**\n * Displays the version of the CLI\n *\n * Output must match flex-cli exactly\n */\nexport function version(): void {\n const packageJson = JSON.parse(findPackageJson());\n console.log(packageJson.version);\n}\n", "/**\n * Login command - interactive API key authentication\n *\n * Must match flex-cli behavior exactly:\n * - Prompt for API key\n * - Store in ~/.config/flex-cli/auth.edn\n * - Display admin email on success\n */\n\nimport inquirer from 'inquirer';\nimport { writeAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the login command\n *\n * Prompts for API key and stores it in auth.edn\n */\nexport async function login(): Promise<void> {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n name: 'apiKey',\n message: 'Enter API key:',\n mask: '*',\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return 'API key cannot be empty';\n }\n return true;\n },\n },\n ]);\n\n // Store the API key\n writeAuth({ apiKey: answers.apiKey });\n\n // TODO: Validate API key by making a test request to get admin email\n // For now, just confirm storage\n console.log('Successfully logged in.');\n\n // Note: flex-cli displays admin email after successful login\n // We'll need to implement API client to fetch this\n}\n", "/**\n * Logout command - clears authentication\n *\n * Must match flex-cli behavior exactly\n */\n\nimport { clearAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the logout command\n *\n * Clears auth.edn file\n */\nexport async function logout(): Promise<void> {\n await clearAuth();\n console.log('Successfully logged out.');\n}\n", "/**\n * Process list command - lists all transaction processes\n */\n\nimport {\n listProcesses as sdkListProcesses,\n listProcessVersions as sdkListProcessVersions,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\n\n/**\n * Formats timestamp to match flex-cli format for process list\n */\nfunction formatProcessTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Lists all processes for a marketplace\n */\nexport async function listProcesses(marketplace: string, processName?: string): Promise<void> {\n try {\n // If processName is specified, show version history for that process\n if (processName) {\n const versions = await sdkListProcessVersions(undefined, marketplace, processName);\n\n if (versions.length === 0) {\n console.log(`No versions found for process: ${processName}`);\n return;\n }\n\n const versionRows = versions.map((v) => ({\n 'Created': formatProcessTimestamp(v.createdAt),\n 'Version': v.version.toString(),\n 'Aliases': v.aliases?.join(', ') || '',\n 'Transactions': v.transactionCount?.toString() || '0',\n }));\n\n printTable(['Created', 'Version', 'Aliases', 'Transactions'], versionRows);\n } else {\n // List all processes\n const processes = await sdkListProcesses(undefined, marketplace);\n\n if (processes.length === 0) {\n console.log('No processes found.');\n return;\n }\n\n const processRows = processes.map((p) => ({\n 'Name': p.name,\n 'Latest version': p.version?.toString() || '',\n }));\n\n printTable(['Name', 'Latest version'], processRows);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list processes');\n }\n process.exit(1);\n }\n}\n", "/**\n * Output formatting utilities\n *\n * Must match flex-cli output format exactly\n */\n\nimport chalk from 'chalk';\n\n/**\n * Prints a table with headers and rows\n *\n * Matches flex-cli table formatting exactly\n */\nexport function printTable(headers: string[], rows: Array<Record<string, string>>): void {\n if (rows.length === 0) {\n return;\n }\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const header of headers) {\n widths[header] = header.length + 1; // +1 to match flex-cli keyword string behavior\n }\n\n for (const row of rows) {\n for (const header of headers) {\n const value = row[header] || '';\n widths[header] = Math.max(widths[header] || 0, value.length);\n }\n }\n\n // Print empty line before table (like flex-cli)\n console.log('');\n\n // Print header with bold formatting\n // flex-cli format: each column padded to (max_width + 1), with single space separator between columns\n // Last column: padding but no separator (interpose doesn't add separator after last element)\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const headerRow = headerParts.join('');\n console.log(chalk.bold.black(headerRow));\n\n // Print rows with same formatting\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const rowStr = rowParts.join('');\n console.log(rowStr);\n }\n\n // Print empty line after table (like flex-cli)\n console.log('');\n}\n\n/**\n * Prints an error message\n */\nexport function printError(message: string): void {\n console.error(chalk.red(`Error: ${message}`));\n}\n\n/**\n * Prints a success message\n */\nexport function printSuccess(message: string): void {\n console.log(chalk.green(message));\n}\n\n/**\n * Prints a warning message\n */\nexport function printWarning(message: string): void {\n console.log(chalk.yellow(`Warning: ${message}`));\n}\n", "/**\n * Process create command\n */\n\nimport { createProcess as sdkCreateProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Creates a new transaction process\n */\nexport async function createProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n\n const result = await sdkCreateProcess(undefined, marketplace, processName, processContent);\n\n printSuccess(\n `Process ${result.name} successfully created with version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process push command\n */\n\nimport { pushProcess as sdkPushProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Reads email templates from the templates directory\n */\nfunction readTemplates(path: string): Array<{ name: string; html: string; subject: string }> {\n const templatesDir = join(path, 'templates');\n const templates: Array<{ name: string; html: string; subject: string }> = [];\n\n try {\n const templateDirs = readdirSync(templatesDir);\n for (const templateName of templateDirs) {\n const templatePath = join(templatesDir, templateName);\n const htmlFile = join(templatePath, `${templateName}-html.html`);\n const subjectFile = join(templatePath, `${templateName}-subject.txt`);\n\n try {\n const html = readFileSync(htmlFile, 'utf-8');\n const subject = readFileSync(subjectFile, 'utf-8');\n templates.push({ name: templateName, html, subject });\n } catch {\n // Skip if files don't exist\n }\n }\n } catch {\n // No templates directory - return empty array\n }\n\n return templates;\n}\n\n/**\n * Pushes a new version of an existing process\n */\nexport async function pushProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n const templates = readTemplates(path);\n\n const result = await sdkPushProcess(undefined, marketplace, processName, processContent, templates);\n\n if (result.noChanges) {\n console.log('No changes');\n } else {\n printSuccess(`Version ${result.version} successfully saved for process ${processName}.`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process pull command\n */\n\nimport { getProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Pulls a process from the server\n */\nexport async function pullProcess(\n marketplace: string,\n processName: string,\n path: string,\n version?: string,\n alias?: string\n): Promise<void> {\n try {\n const process = await getProcess(undefined, marketplace, processName, { version, alias });\n\n if (!process.definition) {\n throw new Error('No process definition in response');\n }\n\n // Ensure directory exists (print message if creating new directory)\n const { existsSync } = await import('node:fs');\n const dirExists = existsSync(path);\n mkdirSync(path, { recursive: true });\n\n if (!dirExists) {\n console.error(`Creating a new directory: ${path}`);\n }\n\n // Write process.edn file\n const processFilePath = join(path, 'process.edn');\n writeFileSync(processFilePath, process.definition, 'utf-8');\n\n // Write email templates if they exist\n const templates = process.emailTemplates || [];\n\n if (templates && Array.isArray(templates) && templates.length > 0) {\n const templatesDir = join(path, 'templates');\n mkdirSync(templatesDir, { recursive: true });\n\n for (const template of templates) {\n const templateName = template.name;\n const htmlContent = template.html;\n const subjectContent = template.subject;\n\n if (templateName) {\n // Create subdirectory for this template\n const templateSubdir = join(templatesDir, templateName);\n mkdirSync(templateSubdir, { recursive: true });\n\n // Write HTML file\n if (htmlContent) {\n const htmlPath = join(templateSubdir, `${templateName}-html.html`);\n writeFileSync(htmlPath, htmlContent, 'utf-8');\n }\n\n // Write subject file\n if (subjectContent) {\n const subjectPath = join(templateSubdir, `${templateName}-subject.txt`);\n writeFileSync(subjectPath, subjectContent, 'utf-8');\n }\n }\n }\n }\n\n console.error(`Saved process to ${path}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process alias commands\n */\n\nimport {\n createAlias as sdkCreateAlias,\n updateAlias as sdkUpdateAlias,\n deleteAlias as sdkDeleteAlias\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\n\n/**\n * Creates a process alias\n */\nexport async function createAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkCreateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully created to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create alias');\n }\n process.exit(1);\n }\n}\n\n/**\n * Updates a process alias\n */\nexport async function updateAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkUpdateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully updated to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update alias');\n }\n process.exit(1);\n }\n}\n\n/**\n * Deletes a process alias\n */\nexport async function deleteAlias(\n marketplace: string,\n processName: string,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkDeleteAlias(undefined, marketplace, processName, alias);\n\n printSuccess(`Alias ${result.alias} successfully deleted.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to delete alias');\n }\n process.exit(1);\n }\n}\n", "/**\n * Combined process command - create-or-push-and-create-or-update-alias\n *\n * This is the enhanced \"superset\" feature that combines multiple operations\n * into one atomic command\n */\n\nimport { deployProcess as sdkDeployProcess, parseProcessFile } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Creates or pushes a process and creates or updates an alias\n *\n * This is an atomic operation that:\n * 1. Tries to push a new version (create-version)\n * 2. If process doesn't exist, creates it\n * 3. Then creates or updates the alias\n */\nexport async function createOrPushAndCreateOrUpdateAlias(\n marketplace: string,\n processName: string,\n path: string,\n alias: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n const processDefinition = parseProcessFile(processContent);\n\n const result = await sdkDeployProcess(\n undefined, // Use auth from file\n marketplace,\n {\n process: processName,\n alias,\n path: processFilePath,\n processDefinition,\n }\n );\n\n if (result.processCreated) {\n printSuccess(`Process ${processName} successfully created.`);\n }\n\n printSuccess(`Version ${result.version} successfully saved for process ${processName}.`);\n\n if (result.aliasCreated) {\n printSuccess(`Alias ${result.alias} successfully created to point to version ${result.version}.`);\n } else {\n printSuccess(`Alias ${result.alias} successfully updated to point to version ${result.version}.`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create/push process and alias');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process command - main entry point for process subcommands\n */\n\nimport { Command } from 'commander';\nimport { listProcesses } from './list.js';\nimport { createProcess } from './create.js';\nimport { pushProcess } from './push.js';\nimport { pullProcess } from './pull.js';\nimport { createAlias, updateAlias, deleteAlias } from './aliases.js';\nimport { createOrPushAndCreateOrUpdateAlias } from './combined.js';\n\n/**\n * Registers all process subcommands\n */\nexport function registerProcessCommands(program: Command): void {\n // Register the parent 'process' command for help display\n const processCmd = program\n .command('process')\n .description('describe a process file')\n .option('--path <PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('--transition <TRANSITION_NAME>', 'transition name, e.g. transition/request to get more details of it')\n .action(async (options) => {\n // Process describe functionality\n if (options.path) {\n console.log(`Describing process at: ${options.path}`);\n if (options.transition) {\n console.log(`Transition: ${options.transition}`);\n }\n // TODO: Implement actual process file parsing and description\n console.log('Process description not yet implemented');\n } else {\n // If no options, show help\n processCmd.outputHelp();\n }\n });\n\n // Register subcommands - these are registered as BOTH subcommands (for help) and top-level (for routing)\n\n // process list (as subcommand)\n processCmd\n .command('list')\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listProcesses(marketplace, options.process);\n });\n\n // process create\n processCmd\n .command('create')\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n // process push\n processCmd\n .command('push')\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n // process pull\n processCmd\n .command('pull')\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n // process create-alias\n processCmd\n .command('create-alias')\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .allowUnknownOption(false)\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process update-alias\n processCmd\n .command('update-alias')\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process delete-alias\n processCmd\n .command('delete-alias')\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n // process deploy (combined command: create-or-push-and-create-or-update-alias)\n processCmd\n .command('deploy')\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n\n // Register top-level command aliases for routing (hidden from help)\n // These handle the routed commands like 'process-pull' that avoid Commander's parent/child option conflicts\n\n program\n .command('process-list', { hidden: true })\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listProcesses(marketplace, options.process);\n });\n\n program\n .command('process-create', { hidden: true })\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-push', { hidden: true })\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-pull', { hidden: true })\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n program\n .command('process-create-alias', { hidden: true })\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-update-alias', { hidden: true })\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-delete-alias', { hidden: true })\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n program\n .command('process-deploy', { hidden: true })\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n}\n", "/**\n * Search command - manage search schemas\n */\n\nimport { Command } from 'commander';\nimport {\n listSearchSchemas as sdkListSearchSchemas,\n setSearchSchema as sdkSetSearchSchema,\n unsetSearchSchema as sdkUnsetSearchSchema,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\ninterface SetSchemaOptions {\n key: string;\n scope: string;\n type: string;\n doc?: string;\n default?: string;\n schemaFor?: string;\n}\n\ninterface UnsetSchemaOptions {\n key: string;\n scope: string;\n schemaFor?: string;\n}\n\n/**\n * Scope label mapping\n */\nconst SCOPE_LABELS: Record<string, string> = {\n metadata: 'Metadata',\n private: 'Private data',\n protected: 'Protected data',\n public: 'Public data',\n};\n\n/**\n * Sets a search schema field\n */\nasync function setSearchSchema(marketplace: string, opts: SetSchemaOptions): Promise<void> {\n try {\n await sdkSetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n defaultValue: opts.default,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully set for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to set search schema');\n }\n process.exit(1);\n }\n}\n\n/**\n * Unsets a search schema field\n */\nasync function unsetSearchSchema(marketplace: string, opts: UnsetSchemaOptions): Promise<void> {\n try {\n await sdkUnsetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully unset for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to unset search schema');\n }\n process.exit(1);\n }\n}\n\n/**\n * Converts default value to display string\n */\nfunction getDefaultValueLabel(value: unknown): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value.join(', ');\n }\n\n return String(value);\n}\n\n/**\n * Lists all search schemas\n */\nasync function listSearchSchemas(marketplace: string): Promise<void> {\n try {\n const schemas = await sdkListSearchSchemas(undefined, marketplace);\n\n if (schemas.length === 0) {\n console.log('No search schemas found.');\n return;\n }\n\n // Map and sort the data (by schema-for, scope, key)\n const rows = schemas\n .map((s) => ({\n 'Schema for': s.schemaFor,\n 'Scope': s.scope,\n 'Key': s.key,\n 'Type': s.type,\n 'Default value': getDefaultValueLabel(s.defaultValue),\n 'Doc': s.doc || '',\n }))\n .sort((a, b) => {\n // Sort by schema-for, then scope, then key\n if (a['Schema for'] !== b['Schema for']) {\n return a['Schema for'].localeCompare(b['Schema for']);\n }\n if (a['Scope'] !== b['Scope']) {\n return a['Scope'].localeCompare(b['Scope']);\n }\n return a['Key'].localeCompare(b['Key']);\n });\n\n // Print table using flex-cli compatible formatting\n const headers = ['Schema for', 'Scope', 'Key', 'Type', 'Default value', 'Doc'];\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const h of headers) {\n widths[h] = h.length + 1;\n }\n for (const row of rows) {\n for (const h of headers) {\n const value = row[h] || '';\n widths[h] = Math.max(widths[h], value.length);\n }\n }\n\n // Print empty line before table\n console.log('');\n\n // Print header\n // flex-cli search format: each column padded to max_width, with 2 space separator between columns\n // Last column: padding with trailing space\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(headerParts.join(''));\n\n // Print rows\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(rowParts.join(''));\n }\n\n // Print empty line after table\n console.log('');\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list search schemas');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers search commands\n */\nexport function registerSearchCommands(program: Command): void {\n const searchCmd = program\n .command('search')\n .description('list all search schemas')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listSearchSchemas(marketplace);\n });\n\n // search set\n searchCmd\n .command('set')\n .description('set search schema')\n .requiredOption('--key <KEY>', 'schema key')\n .requiredOption('--scope <SCOPE>', 'schema scope')\n .requiredOption('--type <TYPE>', 'value type (enum, multi-enum, boolean, long, or text)')\n .option('--doc <DOC>', 'description of the schema')\n .option('--default <DEFAULT>', 'default value for search if value is not set')\n .option('--schema-for <SCHEMA_FOR>', 'subject of the schema (listing, userProfile, or transaction)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await setSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n default: opts.default,\n schemaFor: opts.schemaFor,\n });\n });\n\n // search unset\n searchCmd\n .command('unset')\n .description('unset search schema')\n .requiredOption('--key <KEY>', 'schema key')\n .requiredOption('--scope <SCOPE>', 'schema scope')\n .option('--schema-for <SCHEMA_FOR>', 'subject of the schema (listing, userProfile, or transaction)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await unsetSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n });\n}\n", "/**\n * Assets commands - manage marketplace assets\n */\n\nimport { Command } from 'commander';\nimport {\n pullAssets as sdkPullAssets,\n pushAssets as sdkPushAssets,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport edn from 'jsedn';\n\n\ninterface AssetMetadata {\n version: string;\n assets: Array<{ path: string; 'content-hash': string }>;\n}\n\n/**\n * Reads asset metadata from .flex-cli/asset-meta.edn\n */\nfunction readAssetMetadata(basePath: string): AssetMetadata | null {\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n if (!existsSync(metaPath)) {\n return null;\n }\n\n try {\n const content = readFileSync(metaPath, 'utf-8');\n const parsed = edn.parse(content);\n\n // Convert EDN map to JavaScript object\n const version = parsed.at(edn.kw(':version'));\n const assets = parsed.at(edn.kw(':assets'));\n\n const assetList: Array<{ path: string; 'content-hash': string }> = [];\n if (assets && assets.val) {\n for (const asset of assets.val) {\n assetList.push({\n path: asset.at(edn.kw(':path')),\n 'content-hash': asset.at(edn.kw(':content-hash')),\n });\n }\n }\n\n return { version, assets: assetList };\n } catch {\n return null;\n }\n}\n\n/**\n * Writes asset metadata to .flex-cli/asset-meta.edn\n */\nfunction writeAssetMetadata(basePath: string, metadata: AssetMetadata): void {\n const metaDir = join(basePath, '.flex-cli');\n if (!existsSync(metaDir)) {\n mkdirSync(metaDir, { recursive: true });\n }\n\n const assets = metadata.assets.map(a =>\n new edn.Map([\n edn.kw(':path'), a.path,\n edn.kw(':content-hash'), a['content-hash']\n ])\n );\n\n const ednMap = new edn.Map([\n edn.kw(':version'), metadata.version,\n edn.kw(':assets'), new edn.Vector(assets)\n ]);\n\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n writeFileSync(metaPath, edn.encode(ednMap), 'utf-8');\n}\n\n/**\n * Calculates SHA-1 hash of file content\n */\nfunction calculateHash(data: Buffer): string {\n return createHash('sha1').update(data).digest('hex');\n}\n\n/**\n * Reads all assets from a directory\n */\nfunction readLocalAssets(basePath: string): Array<{ path: string; data: Buffer; hash: string }> {\n const assets: Array<{ path: string; data: Buffer; hash: string }> = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue; // Skip metadata directory\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n const data = readFileSync(fullPath);\n const hash = calculateHash(data);\n assets.push({ path: relPath, data, hash });\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Validates JSON files\n */\nfunction validateJsonAssets(assets: Array<{ path: string; data: Buffer }>): void {\n for (const asset of assets) {\n if (asset.path.endsWith('.json')) {\n try {\n JSON.parse(asset.data.toString('utf-8'));\n } catch (error) {\n throw new Error(`Invalid JSON in ${asset.path}: ${error}`);\n }\n }\n }\n}\n\n/**\n * Pulls assets from remote\n */\nasync function pullAssets(\n marketplace: string,\n path: string,\n version?: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n\n const stat = statSync(path);\n if (!stat.isDirectory()) {\n throw new Error(`${path} is not a directory`);\n }\n\n // Fetch assets from API\n const result = await sdkPullAssets(undefined, marketplace, version ? { version } : undefined);\n const remoteVersion = result.version;\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n\n // Check if up to date\n if (currentMeta && currentMeta.version === remoteVersion && result.assets.length === currentMeta.assets.length) {\n console.log('Assets are up to date.');\n return;\n }\n\n // Write assets to disk\n const newAssets: Array<{ path: string; 'content-hash': string }> = [];\n for (const asset of result.assets) {\n const assetPath = join(path, asset.path);\n const assetDir = dirname(assetPath);\n\n if (!existsSync(assetDir)) {\n mkdirSync(assetDir, { recursive: true });\n }\n\n // Decode base64 data\n const data = Buffer.from(asset.dataRaw, 'base64');\n writeFileSync(assetPath, data);\n\n const hash = calculateHash(data);\n newAssets.push({ path: asset.path, 'content-hash': asset.contentHash || hash });\n }\n\n // Prune deleted assets if requested\n if (prune && currentMeta) {\n const remotePaths = new Set(result.assets.map(a => a.path));\n for (const localAsset of currentMeta.assets) {\n if (!remotePaths.has(localAsset.path)) {\n const assetPath = join(path, localAsset.path);\n if (existsSync(assetPath)) {\n unlinkSync(assetPath);\n }\n }\n }\n }\n\n // Update metadata\n writeAssetMetadata(path, {\n version: remoteVersion,\n assets: newAssets,\n });\n\n console.log(`Version ${remoteVersion} successfully pulled.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull assets');\n }\n process.exit(1);\n }\n}\n\n/**\n * Pushes assets to remote\n */\nasync function pushAssets(\n marketplace: string,\n path: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path) || !statSync(path).isDirectory()) {\n throw new Error(`${path} is not a valid directory`);\n }\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n const currentVersion = currentMeta?.version || 'nil';\n\n // Read local assets\n const localAssets = readLocalAssets(path);\n\n // Validate JSON files\n validateJsonAssets(localAssets);\n\n // Build operations\n const operations: Array<{\n path: string;\n op: 'upsert' | 'delete';\n data?: Buffer;\n }> = [];\n\n // Find assets to upsert (new or changed)\n const localAssetMap = new Map(localAssets.map(a => [a.path, a]));\n const currentAssetMap = new Map((currentMeta?.assets || []).map(a => [a.path, a['content-hash']]));\n\n for (const [assetPath, asset] of localAssetMap) {\n const currentHash = currentAssetMap.get(assetPath);\n if (!currentHash || currentHash !== asset.hash) {\n operations.push({\n path: assetPath,\n op: 'upsert',\n data: asset.data,\n });\n }\n }\n\n // Find assets to delete (if prune enabled)\n if (prune && currentMeta) {\n for (const currentAsset of currentMeta.assets) {\n if (!localAssetMap.has(currentAsset.path)) {\n operations.push({\n path: currentAsset.path,\n op: 'delete',\n });\n }\n }\n }\n\n // Check if there are any changes\n if (operations.length === 0) {\n console.log('Assets are up to date.');\n return;\n }\n\n // Upload to API\n const result = await sdkPushAssets(undefined, marketplace, currentVersion, operations);\n\n // Update local metadata\n writeAssetMetadata(path, {\n version: result.version,\n assets: result.assets.map(a => ({\n path: a.path,\n 'content-hash': a.contentHash,\n })),\n });\n\n console.log(`New version ${result.version} successfully created.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push assets');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers assets commands\n */\nexport function registerAssetsCommands(program: Command): void {\n const assetsCmd = program.command('assets').description('manage marketplace assets');\n\n // assets pull\n assetsCmd\n .command('pull')\n .description('pull assets from remote')\n .requiredOption('--path <PATH>', 'path to directory where assets will be stored')\n .option('--version <VERSION>', 'version of assets to pull')\n .option('--prune', 'delete local files no longer present as remote assets')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullAssets(marketplace, opts.path, opts.version, opts.prune);\n });\n\n // assets push\n assetsCmd\n .command('push')\n .description('push assets to remote')\n .requiredOption('--path <PATH>', 'path to directory with assets')\n .option('--prune', 'delete remote assets no longer present locally')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushAssets(marketplace, opts.path, opts.prune);\n });\n}\n", "/**\n * Notifications commands - manage email notifications\n */\n\nimport { Command } from 'commander';\nimport {\n sendNotification as sdkSendNotification,\n previewNotification as sdkPreviewNotification,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createServer, IncomingMessage, ServerResponse } from 'node:http';\n\n\n/**\n * Reads a notification template from a directory\n */\nfunction readTemplate(templatePath: string): { html: string; subject: string } {\n if (!existsSync(templatePath) || !statSync(templatePath).isDirectory()) {\n throw new Error(`Template directory not found: ${templatePath}`);\n }\n\n const htmlPath = join(templatePath, 'template.html');\n const subjectPath = join(templatePath, 'template-subject.txt');\n\n if (!existsSync(htmlPath)) {\n throw new Error(`template.html not found in ${templatePath}`);\n }\n\n if (!existsSync(subjectPath)) {\n throw new Error(`template-subject.txt not found in ${templatePath}`);\n }\n\n const html = readFileSync(htmlPath, 'utf-8');\n const subject = readFileSync(subjectPath, 'utf-8').trim();\n\n return { html, subject };\n}\n\n/**\n * Reads template context JSON file\n */\nfunction readContext(contextPath?: string): unknown {\n if (!contextPath) {\n return undefined;\n }\n\n if (!existsSync(contextPath)) {\n throw new Error(`Context file not found: ${contextPath}`);\n }\n\n const content = readFileSync(contextPath, 'utf-8');\n try {\n return JSON.parse(content);\n } catch (error) {\n throw new Error(`Invalid JSON in context file: ${error}`);\n }\n}\n\n/**\n * Sends a preview email to the marketplace admin\n */\nasync function sendNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n const result = await sdkSendNotification(undefined, marketplace, { template, context });\n\n console.log(`Preview successfully sent to ${result.adminEmail}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to send notification');\n }\n process.exit(1);\n }\n}\n\n/**\n * Previews a notification in the browser\n */\nasync function previewNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n console.log(`Template: ${templatePath}`);\n console.log(`Subject: ${template.subject}`);\n console.log('');\n console.log('Starting preview server at http://localhost:3535');\n console.log('Press Ctrl+C to stop');\n console.log('');\n\n let previewHtml: string | null = null;\n\n // Fetch preview from API\n const fetchPreview = async () => {\n try {\n const result = await sdkPreviewNotification(undefined, marketplace, { template, context });\n\n // Inject title into HTML\n const html = result.html;\n const titleTag = `<title>${template.subject}</title>`;\n\n if (html.includes('<head>')) {\n previewHtml = html.replace('<head>', `<head>\\n${titleTag}`);\n } else if (html.includes('<html>')) {\n previewHtml = html.replace('<html>', `<html>\\n<head>${titleTag}</head>`);\n } else {\n previewHtml = `<html><head>${titleTag}</head><body>${html}</body></html>`;\n }\n } catch (error) {\n const errorMessage = error && typeof error === 'object' && 'message' in error\n ? (error.message as string)\n : 'Failed to preview notification';\n\n previewHtml = `\n <html>\n <head><title>Error</title></head>\n <body style=\"font-family: sans-serif; padding: 20px;\">\n <h1 style=\"color: #d32f2f;\">Error</h1>\n <pre style=\"background: #f5f5f5; padding: 15px; border-radius: 4px;\">${errorMessage}</pre>\n </body>\n </html>\n `;\n }\n };\n\n // Initial fetch\n await fetchPreview();\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/' || req.url === '') {\n // Refresh preview on each request\n await fetchPreview();\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(previewHtml);\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not Found');\n }\n });\n\n server.listen(3535, () => {\n console.log('Preview server started. Open http://localhost:3535 in your browser.');\n });\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nShutting down preview server...');\n server.close(() => {\n process.exit(0);\n });\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to preview notification');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers notifications commands\n */\nexport function registerNotificationsCommands(program: Command): void {\n const notificationsCmd = program\n .command('notifications')\n .description('manage email notifications');\n\n // notifications preview\n notificationsCmd\n .command('preview')\n .description('render a preview of an email template')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await previewNotification(marketplace, opts.template, opts.context);\n });\n\n // notifications send\n notificationsCmd\n .command('send')\n .description('send a preview of an email template to the logged in admin')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await sendNotification(marketplace, opts.template, opts.context);\n });\n}\n", "/**\n * Listing approval command - DEPRECATED\n *\n * This command is deprecated and should not be used.\n * Use the Sharetribe Console instead.\n */\n\nimport { Command } from 'commander';\nimport {\n getListingApprovalStatus as sdkGetStatus,\n enableListingApproval as sdkEnable,\n disableListingApproval as sdkDisable,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../util/output.js';\n\n/**\n * Gets current listing approval status\n */\nasync function getStatus(marketplace: string): Promise<void> {\n try {\n const result = await sdkGetStatus(undefined, marketplace);\n\n if (result.enabled) {\n console.log(`Listing approvals are enabled in ${marketplace}`);\n } else {\n console.log(`Listing approvals are disabled in ${marketplace}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to get listing approval status');\n }\n process.exit(1);\n }\n}\n\n/**\n * Enables listing approvals\n */\nasync function enableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkEnable(undefined, marketplace);\n console.log(`Successfully enabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to enable listing approvals');\n }\n process.exit(1);\n }\n}\n\n/**\n * Disables listing approvals\n */\nasync function disableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkDisable(undefined, marketplace);\n console.log(`Successfully disabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to disable listing approvals');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers listing-approval command\n */\nexport function registerListingApprovalCommand(program: Command): void {\n const cmd = program\n .command('listing-approval')\n .description('manage listing approvals (DEPRECATED - use Console instead)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - show status\n cmd.action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await getStatus(marketplace);\n });\n\n // Enable subcommand\n cmd\n .command('enable')\n .description('enable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await enableApprovals(marketplace);\n });\n\n // Disable subcommand\n cmd\n .command('disable')\n .description('disable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await disableApprovals(marketplace);\n });\n}\n", "/**\n * Events command - query marketplace events\n */\n\nimport { Command } from 'commander';\nimport { printTable, printError } from '../../util/output.js';\nimport {\n queryEvents as sdkQueryEvents,\n pollEvents as sdkPollEvents,\n type EventData as SdkEventData\n} from 'sharetribe-flex-build-sdk';\n\ninterface EventsQueryOptions {\n resourceId?: string;\n relatedResourceId?: string;\n eventTypes?: string;\n sequenceId?: number;\n afterSeqId?: number;\n beforeSeqId?: number;\n afterTs?: string;\n beforeTs?: string;\n limit?: number;\n json?: boolean;\n jsonPretty?: boolean;\n}\n\n/**\n * Validates query parameters\n */\nfunction validateParams(opts: EventsQueryOptions): void {\n const exclusiveParams = [\n opts.sequenceId !== undefined,\n opts.afterSeqId !== undefined,\n opts.beforeSeqId !== undefined,\n opts.afterTs !== undefined,\n opts.beforeTs !== undefined,\n ];\n\n if (exclusiveParams.filter(Boolean).length > 1) {\n throw new Error(\n 'Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified'\n );\n }\n\n if (opts.resourceId && opts.relatedResourceId) {\n throw new Error('Only one of --resource or --related-resource can be specified');\n }\n}\n\n/**\n * Formats timestamp to match flex-cli format: YYYY-MM-DD H:MM:SS AM/PM\n */\nfunction formatTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Queries events from API\n */\nasync function queryEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n const events = await sdkQueryEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n sequenceId: opts.sequenceId,\n afterSeqId: opts.afterSeqId,\n beforeSeqId: opts.beforeSeqId,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit,\n }\n );\n\n if (events.length === 0) {\n console.log('No events found.');\n return;\n }\n\n // Output format\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to query events');\n }\n process.exit(1);\n }\n}\n\n/**\n * Tails events (live streaming)\n */\nasync function tailEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n console.log('Tailing events... Press Ctrl+C to stop');\n console.log('');\n\n const stopPolling = sdkPollEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n limit: opts.limit || 10,\n },\n (events: SdkEventData[]) => {\n // Output events\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n },\n 5000 // 5 second poll interval\n );\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nStopping tail...');\n stopPolling();\n process.exit(0);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to tail events');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers events command\n */\nexport function registerEventsCommand(program: Command): void {\n const cmd = program\n .command('events')\n .description('Get a list of events.')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('--seqid <SEQUENCE_ID>', 'get event with specific sequence ID', parseInt)\n .option('--after-seqid <SEQUENCE_ID>', 'show events after sequence ID (exclusive)', parseInt)\n .option('--before-seqid <SEQUENCE_ID>', 'show events before sequence ID (exclusive)', parseInt)\n .option('--after-ts <TIMESTAMP>', 'show events after timestamp')\n .option('--before-ts <TIMESTAMP>', 'show events before timestamp')\n .option('-l, --limit <NUMBER>', 'limit results (default: 100, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - query\n cmd.action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exit(1);\n }\n\n await queryEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n sequenceId: opts.seqid,\n afterSeqId: opts.afterSeqid,\n beforeSeqId: opts.beforeSeqid,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit || 100,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n\n // tail subcommand\n cmd\n .command('tail')\n .description('Tail events live as they happen')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('-l, --limit <NUMBER>', 'limit results per poll (default: 10, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exit(1);\n }\n\n await tailEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n limit: opts.limit || 10,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n}\n", "/**\n * Stripe command - manage Stripe integration\n */\n\nimport { Command } from 'commander';\nimport { updateStripeVersion as sdkUpdateStripeVersion, SUPPORTED_STRIPE_VERSIONS } from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport inquirer from 'inquirer';\n\n\n/**\n * Prompts for version selection\n */\nasync function promptForVersion(): Promise<string> {\n const answers = await inquirer.prompt([\n {\n type: 'list',\n name: 'version',\n message: 'Select Stripe API version:',\n choices: [...SUPPORTED_STRIPE_VERSIONS],\n },\n ]);\n\n return answers.version;\n}\n\n/**\n * Prompts for confirmation\n */\nasync function promptForConfirmation(): Promise<boolean> {\n console.log('');\n console.log('WARNING: Changing Stripe API version may affect your integration.');\n console.log('');\n console.log('After updating the Stripe API version, you may need to:');\n console.log('- Handle new Capabilities requirements');\n console.log('- Update identity verification settings');\n console.log('');\n console.log('See Stripe documentation for details:');\n console.log('https://stripe.com/docs/connect/capabilities-overview');\n console.log('https://stripe.com/docs/connect/identity-verification');\n console.log('');\n\n const answers = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirmed',\n message: 'Do you want to continue?',\n default: false,\n },\n ]);\n\n return answers.confirmed;\n}\n\n/**\n * Updates Stripe API version\n */\nasync function updateStripeVersion(\n marketplace: string,\n version?: string,\n force?: boolean\n): Promise<void> {\n try {\n // Get version if not provided\n let selectedVersion = version;\n if (!selectedVersion) {\n selectedVersion = await promptForVersion();\n }\n\n // Get confirmation unless --force flag is used\n if (!force) {\n const confirmed = await promptForConfirmation();\n if (!confirmed) {\n console.log('Cancelled.');\n process.exit(0);\n }\n }\n\n // Update via API (SDK validates version)\n await sdkUpdateStripeVersion(undefined, marketplace, selectedVersion);\n\n console.log(`Stripe API version successfully changed to ${selectedVersion}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update Stripe API version');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers stripe commands\n */\nexport function registerStripeCommands(program: Command): void {\n const stripeCmd = program.command('stripe').description('manage Stripe integration');\n\n // stripe update-version\n stripeCmd\n .command('update-version')\n .description('update Stripe API version in use')\n .option('--version <VERSION>', 'Stripe API version to update to')\n .option('-f, --force', 'skip confirmation prompt and force update')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateStripeVersion(marketplace, opts.version, opts.force);\n });\n}\n", "/**\n * Custom help formatter to match flex-cli output exactly\n */\n\nimport { Command, Help } from 'commander';\nimport chalk from 'chalk';\n\n/**\n * Formats help text to match flex-cli style\n *\n * flex-cli format:\n * - Description (no label)\n * - VERSION section (for main help only)\n * - USAGE section\n * - COMMANDS section (flattened list of all leaf commands)\n * - OPTIONS section (for subcommands only, not main)\n * - Subcommand help instructions\n *\n * @param cmd - Commander command instance\n * @returns Formatted help text matching flex-cli\n */\nexport function formatHelp(cmd: Command): string {\n const parts: string[] = [];\n const isRootCommand = !cmd.parent;\n\n // Description (no label, just the text)\n const description = cmd.description();\n if (description) {\n parts.push(description);\n parts.push('');\n }\n\n // VERSION section (only for root command)\n if (isRootCommand) {\n const version = cmd.version();\n if (version) {\n parts.push('VERSION');\n parts.push(` ${version}`);\n parts.push('');\n }\n }\n\n // USAGE section\n parts.push('USAGE');\n const usage = formatUsage(cmd);\n parts.push(` $ ${usage}`);\n parts.push('');\n\n // COMMANDS section\n // Note: If command has an action (options), don't show COMMANDS section (like flex-cli)\n const allCommands = collectAllLeafCommands(cmd);\n const hasAction = cmd.options.length > 0 && !isRootCommand;\n\n if (allCommands.length > 0 && !hasAction) {\n parts.push('COMMANDS');\n\n // Calculate max command name length for alignment\n const maxLength = Math.max(...allCommands.map(c => c.name.length));\n\n for (const cmdInfo of allCommands) {\n const paddedName = cmdInfo.name.padEnd(maxLength + 2);\n parts.push(` ${paddedName}${cmdInfo.description}`);\n }\n parts.push('');\n }\n\n // OPTIONS section (only for subcommands, not root)\n if (!isRootCommand) {\n const options = cmd.options;\n if (options.length > 0) {\n parts.push('OPTIONS');\n\n // Calculate max option flags length for alignment\n const maxFlagsLength = Math.max(...options.map(opt => formatOptionFlags(opt).length));\n\n for (const opt of options) {\n const flags = formatOptionFlags(opt);\n const paddedFlags = flags.padEnd(maxFlagsLength + 2);\n const desc = opt.description || '';\n parts.push(` ${paddedFlags}${desc}`);\n }\n parts.push('');\n }\n }\n\n // Subcommand help instructions (only for main and group commands without actions)\n if (allCommands.length > 0 && !hasAction) {\n parts.push('Subcommand help:');\n const cmdName = getCommandName(cmd);\n parts.push(` $ ${cmdName} help [COMMAND]`);\n }\n\n // Always add empty line at end to match flex-cli\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Recursively collects all commands (both parent and leaf commands)\n *\n * flex-cli shows ALL commands, including parent commands that have their own actions\n * Example: both \"events\" and \"events tail\" are shown\n *\n * @param cmd - Commander command instance\n * @returns Array of command info objects with name and description\n */\nfunction collectAllLeafCommands(cmd: Command): Array<{ name: string; description: string }> {\n const results: Array<{ name: string; description: string }> = [];\n const commands = cmd.commands.filter(c => !c._hidden && c.name() !== 'help');\n\n for (const subCmd of commands) {\n const fullName = getCommandFullName(subCmd);\n const subCommands = subCmd.commands.filter(c => !c._hidden);\n\n // Add this command if it has an action or description\n if (subCmd.description()) {\n results.push({\n name: fullName,\n description: subCmd.description() || ''\n });\n }\n\n // If it has subcommands, recurse and add those too\n if (subCommands.length > 0) {\n const subResults = collectAllLeafCommands(subCmd);\n for (const sub of subResults) {\n results.push(sub);\n }\n }\n }\n\n // Add \"help\" command at the beginning if this is root\n if (!cmd.parent) {\n results.unshift({\n name: 'help',\n description: 'display help for Flex CLI'\n });\n }\n\n // Sort alphabetically by command name\n results.sort((a, b) => a.name.localeCompare(b.name));\n\n return results;\n}\n\n/**\n * Gets the command name for usage (flex-cli vs sharetribe-cli)\n *\n * @param cmd - Commander command instance\n * @returns Command name (e.g., \"sharetribe-cli\" or \"sharetribe-cli process\")\n */\nfunction getCommandName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n // Replace first name with \"sharetribe-cli\" (or \"flex-cli\" for reference)\n if (names.length > 0) {\n names[0] = 'sharetribe-cli';\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats the USAGE line\n *\n * @param cmd - Commander command instance\n * @returns Usage string (e.g., \"sharetribe-cli [COMMAND]\" or \"sharetribe-cli process list\")\n */\nfunction formatUsage(cmd: Command): string {\n const cmdName = getCommandName(cmd);\n const commands = cmd.commands.filter(c => !c._hidden);\n const hasOptions = cmd.options.length > 0;\n const isRoot = !cmd.parent;\n\n // Root command always shows [COMMAND] if it has subcommands\n if (isRoot && commands.length > 0) {\n return `${cmdName} [COMMAND]`;\n }\n\n // If command has options (its own action), don't show [COMMAND] even if it has subcommands\n // This matches flex-cli behavior for commands like \"process\" which have both action and subcommands\n if (commands.length > 0 && !hasOptions) {\n // Has subcommands but no action\n return `${cmdName} [COMMAND]`;\n } else {\n // Leaf command or command with action - just show the command path\n return cmdName;\n }\n}\n\n/**\n * Gets the full command name including parent path\n *\n * @param cmd - Commander command instance\n * @returns Full command name (e.g., \"process list\" or \"events tail\")\n */\nfunction getCommandFullName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current && current.parent) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats option flags for display\n *\n * @param opt - Commander option instance\n * @returns Formatted flags string (e.g., \"-m, --marketplace=MARKETPLACE_ID\")\n */\nfunction formatOptionFlags(opt: any): string {\n // Commander option flags are in opt.flags (e.g., \"-m, --marketplace <MARKETPLACE_ID>\")\n // We need to parse and reformat this to match flex-cli style\n const flagsStr = opt.flags || '';\n\n // Parse the flags string\n // Format: \"-m, --marketplace <VALUE>\" or \"--flag\" or \"-f\"\n const parts = flagsStr.split(/,\\s*/);\n const formatted: string[] = [];\n\n for (const part of parts) {\n const trimmed = part.trim();\n\n // Check if it has a value placeholder (angle brackets or square brackets)\n const valueMatch = trimmed.match(/^((?:-{1,2}[\\w-]+))\\s*[<\\[]([^\\]>]+)[\\]>]/);\n if (valueMatch) {\n // Has a value: \"-m <MARKETPLACE_ID>\" or \"--marketplace <MARKETPLACE_ID>\"\n const flag = valueMatch[1];\n const valueName = valueMatch[2];\n formatted.push(`${flag}=${valueName}`);\n } else {\n // No value: just the flag\n formatted.push(trimmed);\n }\n }\n\n return formatted.join(', ');\n}\n\n/**\n * Configures Commander.js to use custom help formatter\n *\n * @param program - Commander program instance\n */\nexport function configureHelp(program: Command): void {\n program.configureHelp({\n formatHelp: (cmd: Command, helper: Help) => {\n return formatHelp(cmd);\n }\n });\n}\n", "/**\n * Custom command router to handle Commander.js limitations\n *\n * Commander.js cannot handle parent and child commands with the same option names.\n * This router intercepts argv and routes to the correct command handler.\n */\n\n/**\n * Routes process subcommands to avoid Commander parent/child option conflicts\n *\n * This is necessary because Commander validates parent command options before\n * subcommand actions run, causing conflicts when both use --path.\n */\nexport function routeProcessCommand(argv: string[]): string[] {\n // Check if this is a process subcommand\n const processIndex = argv.findIndex(arg => arg === 'process');\n if (processIndex === -1) {\n return argv;\n }\n\n // Check for subcommands\n const nextArg = argv[processIndex + 1];\n const subcommands = ['list', 'create', 'push', 'pull', 'create-alias', 'update-alias', 'delete-alias', 'deploy'];\n\n if (nextArg && subcommands.includes(nextArg)) {\n // This is a subcommand - remove 'process' from argv and make the subcommand top-level\n // e.g. ['node', 'cli', 'process', 'pull', ...] => ['node', 'cli', 'process-pull', ...]\n const newArgv = [\n ...argv.slice(0, processIndex),\n `process-${nextArg}`,\n ...argv.slice(processIndex + 2)\n ];\n\n // Special handling: If this is an alias command with --version option,\n // we need to filter out the global --version flag from program\n // by ensuring the routed command is properly isolated\n return newArgv;\n }\n\n return argv;\n}\n"],
5
- "mappings": ";;AAMA,OAAS,WAAAA,OAAe,YACxB,OAAS,gBAAAC,OAAoB,UAC7B,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,GAAS,QAAAC,OAAY,YCH9B,OAAS,gBAAAC,OAAoB,UAC7B,OAAS,iBAAAC,OAAqB,WAC9B,OAAS,WAAAC,EAAS,QAAAC,OAAY,YAK9B,SAASC,IAA0B,CACjC,IAAMC,EAAaJ,GAAc,YAAY,GAAG,EAC5CK,EAAaJ,EAAQG,CAAU,EAGnC,KAAOC,IAAe,KACpB,GAAI,CACF,IAAMC,EAAUJ,GAAKG,EAAY,cAAc,EAE/C,OADgBN,GAAaO,E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AW,EACnB,MACF,CAGA,IAAIe,EAAqBf,EACzB,QAAWgB,KAAWF,EAAa,CACjC,IAAMG,EAASF,EAAU,SAAS,KAAKG,GAAKA,EAAE,KAAK,IAAMF,CAAO,EAC3DC,IACH,QAAQ,MAAM,oBAAoBH,EAAY,KAAK,GAAG,CAAC,EAAE,EACzD,QAAQ,KAAK,CAAC,GAEhBC,EAAYE,CACd,CAGAF,EAAU,WAAW,CACvB,CAAC,EAGEjB,GAAW,MAAM,CAAC,EAAE,OAKvBE,EAAQ,MAAMF,EAAU,EAJxBE,EAAQ,WAAW",
6
- "names": ["Command", "readFileSync", "fileURLToPath", "dirname", "join", "readFileSync", "fileURLToPath", "dirname", "join", "findPackageJson", "__filename", "currentDir", "pkgPath", "version", "packageJson", "inquirer", "writeAuth", "login", "answers", "input", "clearAuth", "logout", "sdkListProcesses", "sdkListProcessVersions", "chalk", "printTable", "headers", "rows", "widths", "header", "row", "value", "headerRow", "h", "width", "padded", "rowStr", "i", "printError", "message", "printSuccess", "formatProcessTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "listProcesses", "marketplace", "processName", "versions", "sdkListProcessVersions", "versionRows", "v", "printTable", "processes", "sdkListProcesses", "processRows", "p", "error", "printError", "sdkCreateProcess", "readFileSync", "join", "createProcess", "marketplace", "processName", "path", "processFilePath", "processContent", "result", "sdkCreateProcess", "printSuccess", "error", "printError", "sdkPushProcess", "readFileSync", "readdirSync", "join", "readTemplates", "path", "templatesDir", "templates", "templateDirs", "templateName", "templatePath", "htmlFile", "subjectFile", "html", "subject", "pushProcess", "marketplace", "processName", "processFilePath", "processContent", "result", "sdkPushProcess", "printSuccess", "error", "printError", "getProcess", "writeFileSync", "mkdirSync", "join", "pullProcess", "marketplace", "processName", "path", "version", "alias", "process", "getProcess", "existsSync", "dirExists", "processFilePath", "templates", "templatesDir", "template", "templateName", "htmlContent", "subjectContent", "templateSubdir", "htmlPath", "subjectPath", "error", "printError", "sdkCreateAlias", "sdkUpdateAlias", "sdkDeleteAlias", "createAlias", "marketplace", "processName", "version", "alias", "result", "sdkCreateAlias", "printSuccess", "error", "printError", "updateAlias", "sdkUpdateAlias", "deleteAlias", "sdkDeleteAlias", "sdkDeployProcess", "parseProcessFile", "readFileSync", "join", "createOrPushAndCreateOrUpdateAlias", "marketplace", "processName", "path", "alias", "processFilePath", "processContent", "processDefinition", "parseProcessFile", "result", "sdkDeployProcess", "printSuccess", "error", "printError", "registerProcessCommands", "program", "processCmd", "options", "marketplace", "listProcesses", "createProcess", "pushProcess", "pullProcess", "createAlias", "updateAlias", "deleteAlias", "createOrPushAndCreateOrUpdateAlias", "sdkListSearchSchemas", "sdkSetSearchSchema", "sdkUnsetSearchSchema", "SCOPE_LABELS", "setSearchSchema", "marketplace", "opts", "sdkSetSearchSchema", "schemaFor", "scopeLabel", "error", "printError", "unsetSearchSchema", "sdkUnsetSearchSchema", "getDefaultValueLabel", "value", "listSearchSchemas", "schemas", "sdkListSearchSchemas", "rows", "s", "a", "b", "headers", "widths", "h", "row", "headerParts", "i", "width", "padded", "rowParts", "registerSearchCommands", "program", "searchCmd", "options", "sdkPullAssets", "sdkPushAssets", "readFileSync", "writeFileSync", "existsSync", "mkdirSync", "readdirSync", "statSync", "unlinkSync", "join", "dirname", "createHash", "edn", "readAssetMetadata", "basePath", "metaPath", "content", "parsed", "version", "assets", "assetList", "asset", "writeAssetMetadata", "metadata", "metaDir", "a", "ednMap", "calculateHash", "data", "readLocalAssets", "scanDir", "dir", "relativePath", "entries", "entry", "fullPath", "relPath", "stat", "hash", "validateJsonAssets", "error", "pullAssets", "marketplace", "path", "prune", "result", "sdkPullAssets", "remoteVersion", "currentMeta", "newAssets", "assetPath", "assetDir", "remotePaths", "localAsset", "printError", "pushAssets", "currentVersion", "localAssets", "operations", "localAssetMap", "currentAssetMap", "currentHash", "currentAsset", "sdkPushAssets", "registerAssetsCommands", "program", "assetsCmd", "opts", "sdkSendNotification", "sdkPreviewNotification", "readFileSync", "existsSync", "statSync", "join", "createServer", "readTemplate", "templatePath", "htmlPath", "subjectPath", "html", "subject", "readContext", "contextPath", "content", "error", "sendNotification", "marketplace", "template", "context", "result", "sdkSendNotification", "printError", "previewNotification", "previewHtml", "fetchPreview", "sdkPreviewNotification", "titleTag", "server", "req", "res", "shutdown", "registerNotificationsCommands", "program", "notificationsCmd", "opts", "sdkGetStatus", "sdkEnable", "sdkDisable", "getStatus", "marketplace", "sdkGetStatus", "error", "printError", "enableApprovals", "sdkEnable", "disableApprovals", "sdkDisable", "registerListingApprovalCommand", "program", "cmd", "opts", "sdkQueryEvents", "sdkPollEvents", "validateParams", "opts", "formatTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "queryEvents", "marketplace", "events", "event", "auditEmails", "eventWithoutEmails", "printTable", "actor", "source", "error", "printError", "tailEvents", "stopPolling", "shutdown", "registerEventsCommand", "program", "cmd", "sdkUpdateStripeVersion", "SUPPORTED_STRIPE_VERSIONS", "inquirer", "promptForVersion", "SUPPORTED_STRIPE_VERSIONS", "promptForConfirmation", "updateStripeVersion", "marketplace", "version", "force", "selectedVersion", "sdkUpdateStripeVersion", "error", "printError", "registerStripeCommands", "program", "opts", "formatHelp", "cmd", "parts", "isRootCommand", "description", "version", "usage", "formatUsage", "allCommands", "collectAllLeafCommands", "hasAction", "maxLength", "c", "cmdInfo", "paddedName", "options", "maxFlagsLength", "opt", "formatOptionFlags", "paddedFlags", "desc", "cmdName", "getCommandName", "results", "commands", "subCmd", "fullName", "getCommandFullName", "subCommands", "subResults", "sub", "a", "b", "names", "current", "hasOptions", "formatted", "part", "trimmed", "valueMatch", "flag", "valueName", "configureHelp", "program", "helper", "routeProcessCommand", "argv", "processIndex", "arg", "nextArg", "__filename", "fileURLToPath", "__dirname", "dirname", "packageJson", "readFileSync", "join", "routedArgv", "routeProcessCommand", "program", "Command", "configureHelp", "str", "version", "login", "logout", "registerProcessCommands", "registerSearchCommands", "registerAssetsCommands", "registerNotificationsCommands", "registerListingApprovalCommand", "registerEventsCommand", "registerStripeCommands", "commandPath", "targetCmd", "cmdName", "subCmd", "c"]
3
+ "sources": ["../src/index.ts", "../src/commands/version.ts", "../src/commands/login.ts", "../src/commands/logout.ts", "../src/commands/process/list.ts", "../src/util/output.ts", "../src/commands/process/create.ts", "../src/commands/process/push.ts", "../src/commands/process/pull.ts", "../src/commands/process/aliases.ts", "../src/commands/process/combined.ts", "../src/commands/process/index.ts", "../src/commands/search/index.ts", "../src/commands/assets/index.ts", "../src/commands/notifications/index.ts", "../src/commands/listing-approval.ts", "../src/commands/events/index.ts", "../src/commands/stripe/index.ts", "../src/commands/debug.ts", "../src/util/help-formatter.ts", "../src/util/command-router.ts"],
4
+ "sourcesContent": ["/**\n * Sharetribe CLI - Unofficial 100% compatible implementation\n *\n * Main entry point for the CLI application\n */\n\nimport { Command } from 'commander';\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\nimport { version } from './commands/version.js';\nimport { login } from './commands/login.js';\nimport { logout } from './commands/logout.js';\nimport { registerProcessCommands } from './commands/process/index.js';\nimport { registerSearchCommands } from './commands/search/index.js';\nimport { registerAssetsCommands } from './commands/assets/index.js';\nimport { registerNotificationsCommands } from './commands/notifications/index.js';\nimport { registerListingApprovalCommand } from './commands/listing-approval.js';\nimport { registerEventsCommand } from './commands/events/index.js';\nimport { registerStripeCommands } from './commands/stripe/index.js';\nimport { debug } from './commands/debug.js';\nimport { configureHelp } from './util/help-formatter.js';\nimport { routeProcessCommand } from './util/command-router.js';\n\n// Get package.json for version info\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst packageJson = JSON.parse(\n readFileSync(join(__dirname, '../package.json'), 'utf-8')\n);\n\n// Route argv to handle process subcommands\nconst routedArgv = routeProcessCommand(process.argv);\n\nconst program = new Command();\n\n// Configure custom help formatter to match flex-cli\nconfigureHelp(program);\n\n// Configure output to add trailing newline (flex-cli behavior)\nprogram.configureOutput({\n writeOut: (str) => process.stdout.write(str + '\\n'),\n writeErr: (str) => process.stderr.write(str + '\\n'),\n});\n\n// Configure the main program\nprogram\n .name('sharetribe-cli')\n .description('CLI to interact with Sharetribe Flex')\n .version(packageJson.version, '-V', 'output the version number')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n// Register commands\n\n// version command\nprogram\n .command('version')\n .description('show version')\n .action(() => {\n version();\n });\n\n// login command\nprogram\n .command('login')\n .description('log in with API key')\n .action(async () => {\n await login();\n });\n\n// logout command\nprogram\n .command('logout')\n .description('logout')\n .action(async () => {\n await logout();\n });\n\n// debug command\nprogram\n .command('debug')\n .description('display debug info')\n .action(() => {\n debug();\n });\n\n// Register process commands\nregisterProcessCommands(program);\n\n// Register search commands\nregisterSearchCommands(program);\n\n// Register assets commands\nregisterAssetsCommands(program);\n\n// Register notifications commands\nregisterNotificationsCommands(program);\n\n// Register listing-approval command\nregisterListingApprovalCommand(program);\n\n// Register events command\nregisterEventsCommand(program);\n\n// Register stripe commands\nregisterStripeCommands(program);\n\n// Register custom help command (to support \"help process list\" syntax)\nprogram\n .command('help [command...]')\n .description('display help for Flex CLI')\n .action((commandPath: string[]) => {\n if (!commandPath || commandPath.length === 0) {\n program.outputHelp();\n return;\n }\n\n // Navigate to the nested command\n let targetCmd: Command = program;\n for (const cmdName of commandPath) {\n const subCmd = targetCmd.commands.find(c => c.name() === cmdName);\n if (!subCmd) {\n console.error(`Unknown command: ${commandPath.join(' ')}`);\n process.exit(1);\n }\n targetCmd = subCmd;\n }\n\n // Show help for the target command\n targetCmd.outputHelp();\n });\n\n// If no command specified, show help and exit with status 0\nif (!routedArgv.slice(2).length) {\n program.outputHelp();\n // Don't call process.exit() - let Commander handle it naturally with exitOverride\n} else {\n // Parse command line arguments with routed argv\n program.parse(routedArgv);\n}\n", "/**\n * Version command - displays the CLI version\n *\n * Must match flex-cli output format exactly\n */\n\nimport { readFileSync } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\nimport { dirname, join } from 'node:path';\n\n/**\n * Finds package.json by traversing up from current file\n */\nfunction findPackageJson(): string {\n const __filename = fileURLToPath(import.meta.url);\n let currentDir = dirname(__filename);\n\n // Traverse up to find package.json\n while (currentDir !== '/') {\n try {\n const pkgPath = join(currentDir, 'package.json');\n const content = readFileSync(pkgPath, 'utf-8');\n return content;\n } catch {\n currentDir = dirname(currentDir);\n }\n }\n\n throw new Error('Could not find package.json');\n}\n\n/**\n * Displays the version of the CLI\n *\n * Output must match flex-cli exactly\n */\nexport function version(): void {\n const packageJson = JSON.parse(findPackageJson());\n console.log(packageJson.version);\n}\n", "/**\n * Login command - interactive API key authentication\n *\n * Must match flex-cli behavior exactly:\n * - Prompt for API key\n * - Store in ~/.config/flex-cli/auth.edn\n * - Display admin email on success\n */\n\nimport inquirer from 'inquirer';\nimport { writeAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the login command\n *\n * Prompts for API key and stores it in auth.edn\n */\nexport async function login(): Promise<void> {\n const answers = await inquirer.prompt([\n {\n type: 'password',\n name: 'apiKey',\n message: 'Enter API key:',\n mask: '*',\n validate: (input: string) => {\n if (!input || input.trim().length === 0) {\n return 'API key cannot be empty';\n }\n return true;\n },\n },\n ]);\n\n // Store the API key\n writeAuth({ apiKey: answers.apiKey });\n\n // TODO: Validate API key by making a test request to get admin email\n // For now, just confirm storage\n console.log('Successfully logged in.');\n\n // Note: flex-cli displays admin email after successful login\n // We'll need to implement API client to fetch this\n}\n", "/**\n * Logout command - clears authentication\n *\n * Must match flex-cli behavior exactly\n */\n\nimport { clearAuth } from 'sharetribe-flex-build-sdk';\n\n/**\n * Executes the logout command\n *\n * Clears auth.edn file\n */\nexport async function logout(): Promise<void> {\n await clearAuth();\n console.log('Successfully logged out.');\n}\n", "/**\n * Process list command - lists all transaction processes\n */\n\nimport {\n listProcesses as sdkListProcesses,\n listProcessVersions as sdkListProcessVersions,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\n\n/**\n * Formats timestamp to match flex-cli format for process list\n */\nfunction formatProcessTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Lists all processes for a marketplace\n */\nexport async function listProcesses(marketplace: string, processName?: string): Promise<void> {\n try {\n // If processName is specified, show version history for that process\n if (processName) {\n const versions = await sdkListProcessVersions(undefined, marketplace, processName);\n\n if (versions.length === 0) {\n console.log(`No versions found for process: ${processName}`);\n return;\n }\n\n const versionRows = versions.map((v) => ({\n 'Created': formatProcessTimestamp(v.createdAt),\n 'Version': v.version.toString(),\n 'Aliases': v.aliases?.join(', ') || '',\n 'Transactions': v.transactionCount?.toString() || '0',\n }));\n\n printTable(['Created', 'Version', 'Aliases', 'Transactions'], versionRows);\n } else {\n // List all processes\n const processes = await sdkListProcesses(undefined, marketplace);\n\n if (processes.length === 0) {\n console.log('No processes found.');\n return;\n }\n\n const processRows = processes.map((p) => ({\n 'Name': p.name,\n 'Latest version': p.version?.toString() || '',\n }));\n\n printTable(['Name', 'Latest version'], processRows);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list processes');\n }\n process.exit(1);\n }\n}\n", "/**\n * Output formatting utilities\n *\n * Must match flex-cli output format exactly\n */\n\nimport chalk from 'chalk';\n\n/**\n * Prints a table with headers and rows\n *\n * Matches flex-cli table formatting exactly\n */\nexport function printTable(headers: string[], rows: Array<Record<string, string>>): void {\n if (rows.length === 0) {\n return;\n }\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const header of headers) {\n widths[header] = header.length + 1; // +1 to match flex-cli keyword string behavior\n }\n\n for (const row of rows) {\n for (const header of headers) {\n const value = row[header] || '';\n widths[header] = Math.max(widths[header] || 0, value.length);\n }\n }\n\n // Print empty line before table (like flex-cli)\n console.log('');\n\n // Print header with bold formatting\n // flex-cli format: each column padded to (max_width + 1), with single space separator between columns\n // Last column: padding but no separator (interpose doesn't add separator after last element)\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const headerRow = headerParts.join('');\n console.log(chalk.bold.black(headerRow));\n\n // Print rows with same formatting\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width + 1);\n return i === headers.length - 1 ? padded : padded + ' ';\n });\n const rowStr = rowParts.join('');\n console.log(rowStr);\n }\n\n // Print empty line after table (like flex-cli)\n console.log('');\n}\n\n/**\n * Prints an error message\n */\nexport function printError(message: string): void {\n console.error(chalk.red(`Error: ${message}`));\n}\n\n/**\n * Prints a success message\n */\nexport function printSuccess(message: string): void {\n console.log(chalk.green(message));\n}\n\n/**\n * Prints a warning message\n */\nexport function printWarning(message: string): void {\n console.log(chalk.yellow(`Warning: ${message}`));\n}\n", "/**\n * Process create command\n */\n\nimport { createProcess as sdkCreateProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Creates a new transaction process\n */\nexport async function createProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n\n const result = await sdkCreateProcess(undefined, marketplace, processName, processContent);\n\n printSuccess(\n `Process ${result.name} successfully created with version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process push command\n */\n\nimport { pushProcess as sdkPushProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync, readdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Reads email templates from the templates directory\n */\nfunction readTemplates(path: string): Array<{ name: string; html: string; subject: string }> {\n const templatesDir = join(path, 'templates');\n const templates: Array<{ name: string; html: string; subject: string }> = [];\n\n try {\n const templateDirs = readdirSync(templatesDir);\n for (const templateName of templateDirs) {\n const templatePath = join(templatesDir, templateName);\n const htmlFile = join(templatePath, `${templateName}-html.html`);\n const subjectFile = join(templatePath, `${templateName}-subject.txt`);\n\n try {\n const html = readFileSync(htmlFile, 'utf-8');\n const subject = readFileSync(subjectFile, 'utf-8');\n templates.push({ name: templateName, html, subject });\n } catch {\n // Skip if files don't exist\n }\n }\n } catch {\n // No templates directory - return empty array\n }\n\n return templates;\n}\n\n/**\n * Pushes a new version of an existing process\n */\nexport async function pushProcess(\n marketplace: string,\n processName: string,\n path: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n const templates = readTemplates(path);\n\n const result = await sdkPushProcess(undefined, marketplace, processName, processContent, templates);\n\n if (result.noChanges) {\n console.log('No changes');\n } else {\n printSuccess(`Version ${result.version} successfully saved for process ${processName}.`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process pull command\n */\n\nimport { getProcess } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Pulls a process from the server\n */\nexport async function pullProcess(\n marketplace: string,\n processName: string,\n path: string,\n version?: string,\n alias?: string\n): Promise<void> {\n try {\n const process = await getProcess(undefined, marketplace, processName, { version, alias });\n\n if (!process.definition) {\n throw new Error('No process definition in response');\n }\n\n // Ensure directory exists (print message if creating new directory)\n const { existsSync } = await import('node:fs');\n const dirExists = existsSync(path);\n mkdirSync(path, { recursive: true });\n\n if (!dirExists) {\n console.error(`Creating a new directory: ${path}`);\n }\n\n // Write process.edn file\n const processFilePath = join(path, 'process.edn');\n writeFileSync(processFilePath, process.definition, 'utf-8');\n\n // Write email templates if they exist\n const templates = process.emailTemplates || [];\n\n if (templates && Array.isArray(templates) && templates.length > 0) {\n const templatesDir = join(path, 'templates');\n mkdirSync(templatesDir, { recursive: true });\n\n for (const template of templates) {\n const templateName = template.name;\n const htmlContent = template.html;\n const subjectContent = template.subject;\n\n if (templateName) {\n // Create subdirectory for this template\n const templateSubdir = join(templatesDir, templateName);\n mkdirSync(templateSubdir, { recursive: true });\n\n // Write HTML file\n if (htmlContent) {\n const htmlPath = join(templateSubdir, `${templateName}-html.html`);\n writeFileSync(htmlPath, htmlContent, 'utf-8');\n }\n\n // Write subject file\n if (subjectContent) {\n const subjectPath = join(templateSubdir, `${templateName}-subject.txt`);\n writeFileSync(subjectPath, subjectContent, 'utf-8');\n }\n }\n }\n }\n\n console.error(`Saved process to ${path}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull process');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process alias commands\n */\n\nimport {\n createAlias as sdkCreateAlias,\n updateAlias as sdkUpdateAlias,\n deleteAlias as sdkDeleteAlias\n} from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\n\n/**\n * Creates a process alias\n */\nexport async function createAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkCreateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully created to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create alias');\n }\n process.exit(1);\n }\n}\n\n/**\n * Updates a process alias\n */\nexport async function updateAlias(\n marketplace: string,\n processName: string,\n version: number,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkUpdateAlias(undefined, marketplace, processName, version, alias);\n\n printSuccess(\n `Alias ${result.alias} successfully updated to point to version ${result.version}.`\n );\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update alias');\n }\n process.exit(1);\n }\n}\n\n/**\n * Deletes a process alias\n */\nexport async function deleteAlias(\n marketplace: string,\n processName: string,\n alias: string\n): Promise<void> {\n try {\n const result = await sdkDeleteAlias(undefined, marketplace, processName, alias);\n\n printSuccess(`Alias ${result.alias} successfully deleted.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to delete alias');\n }\n process.exit(1);\n }\n}\n", "/**\n * Combined process command - create-or-push-and-create-or-update-alias\n *\n * This is the enhanced \"superset\" feature that combines multiple operations\n * into one atomic command\n */\n\nimport { deployProcess as sdkDeployProcess, parseProcessFile } from 'sharetribe-flex-build-sdk';\nimport { printError, printSuccess } from '../../util/output.js';\nimport { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Creates or pushes a process and creates or updates an alias\n *\n * This is an atomic operation that:\n * 1. Tries to push a new version (create-version)\n * 2. If process doesn't exist, creates it\n * 3. Then creates or updates the alias\n */\nexport async function createOrPushAndCreateOrUpdateAlias(\n marketplace: string,\n processName: string,\n path: string,\n alias: string\n): Promise<void> {\n try {\n const processFilePath = join(path, 'process.edn');\n const processContent = readFileSync(processFilePath, 'utf-8');\n const processDefinition = parseProcessFile(processContent);\n\n const result = await sdkDeployProcess(\n undefined, // Use auth from file\n marketplace,\n {\n process: processName,\n alias,\n path: processFilePath,\n processDefinition,\n }\n );\n\n if (result.processCreated) {\n printSuccess(`Process ${processName} successfully created.`);\n }\n\n printSuccess(`Version ${result.version} successfully saved for process ${processName}.`);\n\n if (result.aliasCreated) {\n printSuccess(`Alias ${result.alias} successfully created to point to version ${result.version}.`);\n } else {\n printSuccess(`Alias ${result.alias} successfully updated to point to version ${result.version}.`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to create/push process and alias');\n }\n process.exit(1);\n }\n}\n", "/**\n * Process command - main entry point for process subcommands\n */\n\nimport { Command } from 'commander';\nimport { listProcesses } from './list.js';\nimport { createProcess } from './create.js';\nimport { pushProcess } from './push.js';\nimport { pullProcess } from './pull.js';\nimport { createAlias, updateAlias, deleteAlias } from './aliases.js';\nimport { createOrPushAndCreateOrUpdateAlias } from './combined.js';\n\n/**\n * Registers all process subcommands\n */\nexport function registerProcessCommands(program: Command): void {\n // Register the parent 'process' command for help display\n const processCmd = program\n .command('process')\n .description('describe a process file')\n .option('--path <PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('--transition <TRANSITION_NAME>', 'transition name, e.g. transition/request to get more details of it')\n .action(async (options) => {\n // Process describe functionality\n if (options.path) {\n console.log(`Describing process at: ${options.path}`);\n if (options.transition) {\n console.log(`Transition: ${options.transition}`);\n }\n // TODO: Implement actual process file parsing and description\n console.log('Process description not yet implemented');\n } else {\n // If no options, show help\n processCmd.outputHelp();\n }\n });\n\n // Register subcommands - these are registered as BOTH subcommands (for help) and top-level (for routing)\n\n // process list (as subcommand)\n processCmd\n .command('list')\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listProcesses(marketplace, options.process);\n });\n\n // process create\n processCmd\n .command('create')\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n // process push\n processCmd\n .command('push')\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n // process pull\n processCmd\n .command('pull')\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n // process create-alias\n processCmd\n .command('create-alias')\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .allowUnknownOption(false)\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process update-alias\n processCmd\n .command('update-alias')\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n // process delete-alias\n processCmd\n .command('delete-alias')\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n // process deploy (combined command: create-or-push-and-create-or-update-alias)\n processCmd\n .command('deploy')\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n\n // Register top-level command aliases for routing (hidden from help)\n // These handle the routed commands like 'process-pull' that avoid Commander's parent/child option conflicts\n\n program\n .command('process-list', { hidden: true })\n .description('list all transaction processes')\n .option('--process <PROCESS_NAME>', 'print version and alias info of a specific process')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listProcesses(marketplace, options.process);\n });\n\n program\n .command('process-create', { hidden: true })\n .description('create a new transaction process')\n .requiredOption('--process <PROCESS_NAME>', 'name for the new process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-push', { hidden: true })\n .description('push a process file to the remote')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory where the process.edn file is')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushProcess(marketplace, options.process, options.path);\n });\n\n program\n .command('process-pull', { hidden: true })\n .description('fetch a process file')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path where to save the process')\n .option('--version <VERSION_NUM>', 'version number')\n .option('--alias <PROCESS_ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullProcess(marketplace, options.process, options.path, options.version, options.alias);\n });\n\n program\n .command('process-create-alias', { hidden: true })\n .description('create a new alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-update-alias', { hidden: true })\n .description('update an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--version <VERSION_NUM>', 'version number')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateAlias(marketplace, options.process, parseInt(options.version), options.alias);\n });\n\n program\n .command('process-delete-alias', { hidden: true })\n .description('delete an existing alias')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await deleteAlias(marketplace, options.process, options.alias);\n });\n\n program\n .command('process-deploy', { hidden: true })\n .description('deploy a process file with alias (create/push + alias create/update)')\n .requiredOption('--process <PROCESS_NAME>', 'name of the process')\n .requiredOption('--path <LOCAL_PROCESS_DIR>', 'path to the directory with the process files')\n .requiredOption('--alias <ALIAS>', 'alias name')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await createOrPushAndCreateOrUpdateAlias(\n marketplace,\n options.process,\n options.path,\n options.alias\n );\n });\n}\n", "/**\n * Search command - manage search schemas\n */\n\nimport { Command } from 'commander';\nimport {\n listSearchSchemas as sdkListSearchSchemas,\n setSearchSchema as sdkSetSearchSchema,\n unsetSearchSchema as sdkUnsetSearchSchema,\n} from 'sharetribe-flex-build-sdk';\nimport { printTable, printError } from '../../util/output.js';\n\ninterface SetSchemaOptions {\n key: string;\n scope: string;\n type: string;\n doc?: string;\n default?: string;\n schemaFor?: string;\n}\n\ninterface UnsetSchemaOptions {\n key: string;\n scope: string;\n schemaFor?: string;\n}\n\n/**\n * Scope label mapping\n */\nconst SCOPE_LABELS: Record<string, string> = {\n metadata: 'Metadata',\n private: 'Private data',\n protected: 'Protected data',\n public: 'Public data',\n};\n\n/**\n * Sets a search schema field\n */\nasync function setSearchSchema(marketplace: string, opts: SetSchemaOptions): Promise<void> {\n try {\n await sdkSetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n defaultValue: opts.default,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully set for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to set search schema');\n }\n process.exit(1);\n }\n}\n\n/**\n * Unsets a search schema field\n */\nasync function unsetSearchSchema(marketplace: string, opts: UnsetSchemaOptions): Promise<void> {\n try {\n await sdkUnsetSearchSchema(undefined, marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n\n const schemaFor = opts.schemaFor || 'listing';\n const scopeLabel = SCOPE_LABELS[opts.scope] || opts.scope;\n console.log(`${scopeLabel} schema, ${opts.key} is successfully unset for ${schemaFor}.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to unset search schema');\n }\n process.exit(1);\n }\n}\n\n/**\n * Converts default value to display string\n */\nfunction getDefaultValueLabel(value: unknown): string {\n if (value === undefined || value === null) {\n return '';\n }\n\n if (Array.isArray(value)) {\n return value.join(', ');\n }\n\n return String(value);\n}\n\n/**\n * Lists all search schemas\n */\nasync function listSearchSchemas(marketplace: string): Promise<void> {\n try {\n const schemas = await sdkListSearchSchemas(undefined, marketplace);\n\n if (schemas.length === 0) {\n console.log('No search schemas found.');\n return;\n }\n\n // Map and sort the data (by schema-for, scope, key)\n const rows = schemas\n .map((s) => ({\n 'Schema for': s.schemaFor,\n 'Scope': s.scope,\n 'Key': s.key,\n 'Type': s.type,\n 'Default value': getDefaultValueLabel(s.defaultValue),\n 'Doc': s.doc || '',\n }))\n .sort((a, b) => {\n // Sort by schema-for, then scope, then key\n if (a['Schema for'] !== b['Schema for']) {\n return a['Schema for'].localeCompare(b['Schema for']);\n }\n if (a['Scope'] !== b['Scope']) {\n return a['Scope'].localeCompare(b['Scope']);\n }\n return a['Key'].localeCompare(b['Key']);\n });\n\n // Print table using flex-cli compatible formatting\n const headers = ['Schema for', 'Scope', 'Key', 'Type', 'Default value', 'Doc'];\n\n // Calculate column widths\n // flex-cli uses keywords (e.g., :version) which when stringified include the ':' prefix\n // To match flex-cli widths, we add 1 to header length to simulate the ':' prefix\n const widths: Record<string, number> = {};\n for (const h of headers) {\n widths[h] = h.length + 1;\n }\n for (const row of rows) {\n for (const h of headers) {\n const value = row[h] || '';\n widths[h] = Math.max(widths[h], value.length);\n }\n }\n\n // Print empty line before table\n console.log('');\n\n // Print header\n // flex-cli search format: each column padded to max_width, with 2 space separator between columns\n // Last column: padding with trailing space\n const headerParts = headers.map((h, i) => {\n const width = widths[h] || 0;\n const padded = h.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(headerParts.join(''));\n\n // Print rows\n for (const row of rows) {\n const rowParts = headers.map((h, i) => {\n const value = row[h] || '';\n const width = widths[h] || 0;\n const padded = value.padEnd(width);\n return i === headers.length - 1 ? padded + ' ' : padded + ' ';\n });\n console.log(rowParts.join(''));\n }\n\n // Print empty line after table\n console.log('');\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to list search schemas');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers search commands\n */\nexport function registerSearchCommands(program: Command): void {\n const searchCmd = program\n .command('search')\n .description('list all search schemas')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (options) => {\n const marketplace = options.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await listSearchSchemas(marketplace);\n });\n\n // search set\n searchCmd\n .command('set')\n .description('set search schema')\n .requiredOption('--key <KEY>', 'schema key')\n .requiredOption('--scope <SCOPE>', 'schema scope')\n .requiredOption('--type <TYPE>', 'value type (enum, multi-enum, boolean, long, or text)')\n .option('--doc <DOC>', 'description of the schema')\n .option('--default <DEFAULT>', 'default value for search if value is not set')\n .option('--schema-for <SCHEMA_FOR>', 'subject of the schema (listing, userProfile, or transaction)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await setSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n type: opts.type,\n doc: opts.doc,\n default: opts.default,\n schemaFor: opts.schemaFor,\n });\n });\n\n // search unset\n searchCmd\n .command('unset')\n .description('unset search schema')\n .requiredOption('--key <KEY>', 'schema key')\n .requiredOption('--scope <SCOPE>', 'schema scope')\n .option('--schema-for <SCHEMA_FOR>', 'subject of the schema (listing, userProfile, or transaction)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await unsetSearchSchema(marketplace, {\n key: opts.key,\n scope: opts.scope,\n schemaFor: opts.schemaFor,\n });\n });\n}\n", "/**\n * Assets commands - manage marketplace assets\n */\n\nimport { Command } from 'commander';\nimport {\n pullAssets as sdkPullAssets,\n pushAssets as sdkPushAssets,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync } from 'node:fs';\nimport { join, dirname } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport chalk from 'chalk';\nimport edn from 'jsedn';\n\n\ninterface AssetMetadata {\n version: string;\n assets: Array<{ path: string; 'content-hash': string }>;\n}\n\n/**\n * Reads asset metadata from .flex-cli/asset-meta.edn\n */\nfunction readAssetMetadata(basePath: string): AssetMetadata | null {\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n if (!existsSync(metaPath)) {\n return null;\n }\n\n try {\n const content = readFileSync(metaPath, 'utf-8');\n const parsed = edn.parse(content);\n\n // Convert EDN map to JavaScript object\n const version = parsed.at(edn.kw(':version'));\n const assets = parsed.at(edn.kw(':assets'));\n\n const assetList: Array<{ path: string; 'content-hash': string }> = [];\n if (assets && assets.val) {\n for (const asset of assets.val) {\n assetList.push({\n path: asset.at(edn.kw(':path')),\n 'content-hash': asset.at(edn.kw(':content-hash')),\n });\n }\n }\n\n return { version, assets: assetList };\n } catch {\n return null;\n }\n}\n\n/**\n * Writes asset metadata to .flex-cli/asset-meta.edn\n */\nfunction writeAssetMetadata(basePath: string, metadata: AssetMetadata): void {\n const metaDir = join(basePath, '.flex-cli');\n if (!existsSync(metaDir)) {\n mkdirSync(metaDir, { recursive: true });\n }\n\n const assets = metadata.assets.map(a =>\n new edn.Map([\n edn.kw(':path'), a.path,\n edn.kw(':content-hash'), a['content-hash']\n ])\n );\n\n const ednMap = new edn.Map([\n edn.kw(':version'), metadata.version,\n edn.kw(':assets'), new edn.Vector(assets)\n ]);\n\n const metaPath = join(basePath, '.flex-cli', 'asset-meta.edn');\n writeFileSync(metaPath, edn.encode(ednMap), 'utf-8');\n}\n\n/**\n * Calculates SHA-1 hash of file content\n */\nfunction calculateHash(data: Buffer): string {\n const prefix = Buffer.from(`${data.length}|`, 'utf-8');\n return createHash('sha1').update(prefix).update(data).digest('hex');\n}\n\n/**\n * Reads all assets from a directory\n */\nfunction readLocalAssets(basePath: string): Array<{ path: string; data: Buffer; hash: string }> {\n const assets: Array<{ path: string; data: Buffer; hash: string }> = [];\n\n function scanDir(dir: string, relativePath: string = '') {\n const entries = readdirSync(dir);\n\n for (const entry of entries) {\n if (entry === '.flex-cli') continue; // Skip metadata directory\n\n const fullPath = join(dir, entry);\n const relPath = relativePath ? join(relativePath, entry) : entry;\n const stat = statSync(fullPath);\n\n if (stat.isDirectory()) {\n scanDir(fullPath, relPath);\n } else if (stat.isFile()) {\n const data = readFileSync(fullPath);\n const hash = calculateHash(data);\n assets.push({ path: relPath, data, hash });\n }\n }\n }\n\n scanDir(basePath);\n return assets;\n}\n\n/**\n * Validates JSON files\n */\nfunction validateJsonAssets(assets: Array<{ path: string; data: Buffer }>): void {\n for (const asset of assets) {\n if (asset.path.endsWith('.json')) {\n try {\n JSON.parse(asset.data.toString('utf-8'));\n } catch (error) {\n throw new Error(`Invalid JSON in ${asset.path}: ${error}`);\n }\n }\n }\n}\n\n/**\n * Pulls assets from remote\n */\nasync function pullAssets(\n marketplace: string,\n path: string,\n version?: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path)) {\n mkdirSync(path, { recursive: true });\n }\n\n const stat = statSync(path);\n if (!stat.isDirectory()) {\n throw new Error(`${path} is not a directory`);\n }\n\n // Fetch assets from API\n const result = await sdkPullAssets(undefined, marketplace, version ? { version } : undefined);\n const remoteVersion = result.version;\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n\n // Check if up to date\n if (currentMeta && currentMeta.version === remoteVersion && result.assets.length === currentMeta.assets.length) {\n console.log('Assets are up to date.');\n return;\n }\n\n // Write assets to disk\n const newAssets: Array<{ path: string; 'content-hash': string }> = [];\n for (const asset of result.assets) {\n const assetPath = join(path, asset.path);\n const assetDir = dirname(assetPath);\n\n if (!existsSync(assetDir)) {\n mkdirSync(assetDir, { recursive: true });\n }\n\n // Decode base64 data\n const data = Buffer.from(asset.dataRaw, 'base64');\n writeFileSync(assetPath, data);\n\n const hash = calculateHash(data);\n newAssets.push({ path: asset.path, 'content-hash': asset.contentHash || hash });\n }\n\n // Prune deleted assets if requested\n if (prune && currentMeta) {\n const remotePaths = new Set(result.assets.map(a => a.path));\n for (const localAsset of currentMeta.assets) {\n if (!remotePaths.has(localAsset.path)) {\n const assetPath = join(path, localAsset.path);\n if (existsSync(assetPath)) {\n unlinkSync(assetPath);\n }\n }\n }\n }\n\n // Update metadata\n writeAssetMetadata(path, {\n version: remoteVersion,\n assets: newAssets,\n });\n\n console.log(`Version ${remoteVersion} successfully pulled.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to pull assets');\n }\n process.exit(1);\n }\n}\n\n/**\n * Pushes assets to remote\n */\nasync function pushAssets(\n marketplace: string,\n path: string,\n prune?: boolean\n): Promise<void> {\n try {\n // Validate path\n if (!existsSync(path) || !statSync(path).isDirectory()) {\n throw new Error(`${path} is not a valid directory`);\n }\n\n // Read current metadata\n const currentMeta = readAssetMetadata(path);\n const currentVersion = currentMeta?.version || 'nil';\n\n // Read local assets\n const localAssets = readLocalAssets(path);\n\n // Validate JSON files\n validateJsonAssets(localAssets);\n\n // Build operations\n const operations: Array<{\n path: string;\n op: 'upsert' | 'delete';\n data?: Buffer;\n }> = [];\n\n // Find assets to upsert (new or changed)\n const localAssetMap = new Map(localAssets.map(a => [a.path, a]));\n const currentAssetMap = new Map((currentMeta?.assets || []).map(a => [a.path, a['content-hash']]));\n\n for (const [assetPath, asset] of localAssetMap) {\n const currentHash = currentAssetMap.get(assetPath);\n if (!currentHash || currentHash !== asset.hash) {\n operations.push({\n path: assetPath,\n op: 'upsert',\n data: asset.data,\n });\n }\n }\n\n // Find assets to delete (if prune enabled)\n if (prune && currentMeta) {\n for (const currentAsset of currentMeta.assets) {\n if (!localAssetMap.has(currentAsset.path)) {\n operations.push({\n path: currentAsset.path,\n op: 'delete',\n });\n }\n }\n }\n\n // Check if there are any changes\n if (operations.length === 0) {\n console.log('Assets are up to date.');\n return;\n }\n\n const changedAssetPaths = operations\n .filter(op => op.op === 'upsert')\n .map(op => op.path);\n if (changedAssetPaths.length > 0) {\n console.log(chalk.green(`Uploading changed assets: ${changedAssetPaths.join(', ')}`));\n }\n\n // Upload to API\n const result = await sdkPushAssets(undefined, marketplace, currentVersion, operations);\n\n // Update local metadata\n writeAssetMetadata(path, {\n version: result.version,\n assets: result.assets.map(a => ({\n path: a.path,\n 'content-hash': a.contentHash,\n })),\n });\n\n console.log(`New version ${result.version} successfully created.`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to push assets');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers assets commands\n */\nexport function registerAssetsCommands(program: Command): void {\n const assetsCmd = program.command('assets').description('manage marketplace assets');\n\n // assets pull\n assetsCmd\n .command('pull')\n .description('pull assets from remote')\n .requiredOption('--path <PATH>', 'path to directory where assets will be stored')\n .option('--version <VERSION>', 'version of assets to pull')\n .option('--prune', 'delete local files no longer present as remote assets')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pullAssets(marketplace, opts.path, opts.version, opts.prune);\n });\n\n // assets push\n assetsCmd\n .command('push')\n .description('push assets to remote')\n .requiredOption('--path <PATH>', 'path to directory with assets')\n .option('--prune', 'delete remote assets no longer present locally')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await pushAssets(marketplace, opts.path, opts.prune);\n });\n}\n", "/**\n * Notifications commands - manage email notifications\n */\n\nimport { Command } from 'commander';\nimport {\n sendNotification as sdkSendNotification,\n previewNotification as sdkPreviewNotification,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport { readFileSync, existsSync, statSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { createServer, IncomingMessage, ServerResponse } from 'node:http';\n\n\n/**\n * Reads a notification template from a directory\n */\nfunction readTemplate(templatePath: string): { html: string; subject: string } {\n if (!existsSync(templatePath) || !statSync(templatePath).isDirectory()) {\n throw new Error(`Template directory not found: ${templatePath}`);\n }\n\n const htmlPath = join(templatePath, 'template.html');\n const subjectPath = join(templatePath, 'template-subject.txt');\n\n if (!existsSync(htmlPath)) {\n throw new Error(`template.html not found in ${templatePath}`);\n }\n\n if (!existsSync(subjectPath)) {\n throw new Error(`template-subject.txt not found in ${templatePath}`);\n }\n\n const html = readFileSync(htmlPath, 'utf-8');\n const subject = readFileSync(subjectPath, 'utf-8').trim();\n\n return { html, subject };\n}\n\n/**\n * Reads template context JSON file\n */\nfunction readContext(contextPath?: string): unknown {\n if (!contextPath) {\n return undefined;\n }\n\n if (!existsSync(contextPath)) {\n throw new Error(`Context file not found: ${contextPath}`);\n }\n\n const content = readFileSync(contextPath, 'utf-8');\n try {\n return JSON.parse(content);\n } catch (error) {\n throw new Error(`Invalid JSON in context file: ${error}`);\n }\n}\n\n/**\n * Sends a preview email to the marketplace admin\n */\nasync function sendNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n const result = await sdkSendNotification(undefined, marketplace, { template, context });\n\n console.log(`Preview successfully sent to ${result.adminEmail}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to send notification');\n }\n process.exit(1);\n }\n}\n\n/**\n * Previews a notification in the browser\n */\nasync function previewNotification(\n marketplace: string,\n templatePath: string,\n contextPath?: string\n): Promise<void> {\n try {\n const template = readTemplate(templatePath);\n const context = readContext(contextPath);\n\n console.log(`Template: ${templatePath}`);\n console.log(`Subject: ${template.subject}`);\n console.log('');\n console.log('Starting preview server at http://localhost:3535');\n console.log('Press Ctrl+C to stop');\n console.log('');\n\n let previewHtml: string | null = null;\n\n // Fetch preview from API\n const fetchPreview = async () => {\n try {\n const result = await sdkPreviewNotification(undefined, marketplace, { template, context });\n\n // Inject title into HTML\n const html = result.html;\n const titleTag = `<title>${template.subject}</title>`;\n\n if (html.includes('<head>')) {\n previewHtml = html.replace('<head>', `<head>\\n${titleTag}`);\n } else if (html.includes('<html>')) {\n previewHtml = html.replace('<html>', `<html>\\n<head>${titleTag}</head>`);\n } else {\n previewHtml = `<html><head>${titleTag}</head><body>${html}</body></html>`;\n }\n } catch (error) {\n const errorMessage = error && typeof error === 'object' && 'message' in error\n ? (error.message as string)\n : 'Failed to preview notification';\n\n previewHtml = `\n <html>\n <head><title>Error</title></head>\n <body style=\"font-family: sans-serif; padding: 20px;\">\n <h1 style=\"color: #d32f2f;\">Error</h1>\n <pre style=\"background: #f5f5f5; padding: 15px; border-radius: 4px;\">${errorMessage}</pre>\n </body>\n </html>\n `;\n }\n };\n\n // Initial fetch\n await fetchPreview();\n\n // Create HTTP server\n const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/' || req.url === '') {\n // Refresh preview on each request\n await fetchPreview();\n\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(previewHtml);\n } else {\n res.writeHead(404, { 'Content-Type': 'text/plain' });\n res.end('Not Found');\n }\n });\n\n server.listen(3535, () => {\n console.log('Preview server started. Open http://localhost:3535 in your browser.');\n });\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nShutting down preview server...');\n server.close(() => {\n process.exit(0);\n });\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to preview notification');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers notifications commands\n */\nexport function registerNotificationsCommands(program: Command): void {\n const notificationsCmd = program\n .command('notifications')\n .description('manage email notifications');\n\n // notifications preview\n notificationsCmd\n .command('preview')\n .description('render a preview of an email template')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await previewNotification(marketplace, opts.template, opts.context);\n });\n\n // notifications send\n notificationsCmd\n .command('send')\n .description('send a preview of an email template to the logged in admin')\n .requiredOption('--template <TEMPLATE_DIR>', 'path to template directory')\n .option('--context <CONTEXT_FILE>', 'path to email rendering context JSON file')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await sendNotification(marketplace, opts.template, opts.context);\n });\n}\n", "/**\n * Listing approval command - DEPRECATED\n *\n * This command is deprecated and should not be used.\n * Use the Sharetribe Console instead.\n */\n\nimport { Command } from 'commander';\nimport {\n getListingApprovalStatus as sdkGetStatus,\n enableListingApproval as sdkEnable,\n disableListingApproval as sdkDisable,\n} from 'sharetribe-flex-build-sdk';\nimport { printError } from '../util/output.js';\n\n/**\n * Gets current listing approval status\n */\nasync function getStatus(marketplace: string): Promise<void> {\n try {\n const result = await sdkGetStatus(undefined, marketplace);\n\n if (result.enabled) {\n console.log(`Listing approvals are enabled in ${marketplace}`);\n } else {\n console.log(`Listing approvals are disabled in ${marketplace}`);\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to get listing approval status');\n }\n process.exit(1);\n }\n}\n\n/**\n * Enables listing approvals\n */\nasync function enableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkEnable(undefined, marketplace);\n console.log(`Successfully enabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to enable listing approvals');\n }\n process.exit(1);\n }\n}\n\n/**\n * Disables listing approvals\n */\nasync function disableApprovals(marketplace: string): Promise<void> {\n try {\n await sdkDisable(undefined, marketplace);\n console.log(`Successfully disabled listing approvals in ${marketplace}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to disable listing approvals');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers listing-approval command\n */\nexport function registerListingApprovalCommand(program: Command): void {\n const cmd = program\n .command('listing-approval')\n .description('manage listing approvals (DEPRECATED - use Console instead)')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - show status\n cmd.action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await getStatus(marketplace);\n });\n\n // Enable subcommand\n cmd\n .command('enable')\n .description('enable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await enableApprovals(marketplace);\n });\n\n // Disable subcommand\n cmd\n .command('disable')\n .description('disable listing approvals')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n console.warn('Warning: CLI command `listing-approval` is deprecated. Use Console instead.');\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await disableApprovals(marketplace);\n });\n}\n", "/**\n * Events command - query marketplace events\n */\n\nimport { Command } from 'commander';\nimport { printTable, printError } from '../../util/output.js';\nimport {\n queryEvents as sdkQueryEvents,\n pollEvents as sdkPollEvents,\n type EventData as SdkEventData\n} from 'sharetribe-flex-build-sdk';\n\ninterface EventsQueryOptions {\n resourceId?: string;\n relatedResourceId?: string;\n eventTypes?: string;\n sequenceId?: number;\n afterSeqId?: number;\n beforeSeqId?: number;\n afterTs?: string;\n beforeTs?: string;\n limit?: number;\n json?: boolean;\n jsonPretty?: boolean;\n}\n\n/**\n * Validates query parameters\n */\nfunction validateParams(opts: EventsQueryOptions): void {\n const exclusiveParams = [\n opts.sequenceId !== undefined,\n opts.afterSeqId !== undefined,\n opts.beforeSeqId !== undefined,\n opts.afterTs !== undefined,\n opts.beforeTs !== undefined,\n ];\n\n if (exclusiveParams.filter(Boolean).length > 1) {\n throw new Error(\n 'Only one of --seqid, --after-seqid, --before-seqid, --after-ts, or --before-ts can be specified'\n );\n }\n\n if (opts.resourceId && opts.relatedResourceId) {\n throw new Error('Only one of --resource or --related-resource can be specified');\n }\n}\n\n/**\n * Formats timestamp to match flex-cli format: YYYY-MM-DD H:MM:SS AM/PM\n */\nfunction formatTimestamp(timestamp: string): string {\n try {\n const date = new Date(timestamp);\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n const timeString = date.toLocaleTimeString('en-US');\n\n return `${year}-${month}-${day} ${timeString}`;\n } catch {\n return timestamp;\n }\n}\n\n/**\n * Queries events from API\n */\nasync function queryEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n const events = await sdkQueryEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n sequenceId: opts.sequenceId,\n afterSeqId: opts.afterSeqId,\n beforeSeqId: opts.beforeSeqId,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit,\n }\n );\n\n if (events.length === 0) {\n console.log('No events found.');\n return;\n }\n\n // Output format\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to query events');\n }\n process.exit(1);\n }\n}\n\n/**\n * Tails events (live streaming)\n */\nasync function tailEvents(\n marketplace: string,\n opts: EventsQueryOptions\n): Promise<void> {\n try {\n validateParams(opts);\n\n console.log('Tailing events... Press Ctrl+C to stop');\n console.log('');\n\n const stopPolling = sdkPollEvents(\n undefined, // Use auth from file\n marketplace,\n {\n resourceId: opts.resourceId,\n relatedResourceId: opts.relatedResourceId,\n eventTypes: opts.eventTypes,\n limit: opts.limit || 10,\n },\n (events: SdkEventData[]) => {\n // Output events\n if (opts.json) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails));\n }\n } else if (opts.jsonPretty) {\n for (const event of events) {\n // Exclude auditEmails to match flex-cli JSON format\n const { auditEmails, ...eventWithoutEmails } = event;\n console.log(JSON.stringify(eventWithoutEmails, null, 2));\n }\n } else {\n printTable(\n ['Seq ID', 'Resource ID', 'Event type', 'Created at local time', 'Source', 'Actor'],\n events.map((event) => {\n const actor = event.auditEmails?.userEmail || event.auditEmails?.adminEmail || '';\n const source = event.source?.replace('source/', '') || '';\n\n return {\n 'Seq ID': event.sequenceId.toString(),\n 'Resource ID': event.resourceId,\n 'Event type': event.eventType,\n 'Created at local time': formatTimestamp(event.createdAt),\n 'Source': source,\n 'Actor': actor,\n };\n })\n );\n }\n },\n 5000 // 5 second poll interval\n );\n\n // Handle graceful shutdown\n const shutdown = () => {\n console.log('\\nStopping tail...');\n stopPolling();\n process.exit(0);\n };\n\n process.on('SIGINT', shutdown);\n process.on('SIGTERM', shutdown);\n\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to tail events');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers events command\n */\nexport function registerEventsCommand(program: Command): void {\n const cmd = program\n .command('events')\n .description('Get a list of events.')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('--seqid <SEQUENCE_ID>', 'get event with specific sequence ID', parseInt)\n .option('--after-seqid <SEQUENCE_ID>', 'show events after sequence ID (exclusive)', parseInt)\n .option('--before-seqid <SEQUENCE_ID>', 'show events before sequence ID (exclusive)', parseInt)\n .option('--after-ts <TIMESTAMP>', 'show events after timestamp')\n .option('--before-ts <TIMESTAMP>', 'show events before timestamp')\n .option('-l, --limit <NUMBER>', 'limit results (default: 100, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier');\n\n // Default action - query\n cmd.action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exit(1);\n }\n\n await queryEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n sequenceId: opts.seqid,\n afterSeqId: opts.afterSeqid,\n beforeSeqId: opts.beforeSeqid,\n afterTs: opts.afterTs,\n beforeTs: opts.beforeTs,\n limit: opts.limit || 100,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n\n // tail subcommand\n cmd\n .command('tail')\n .description('Tail events live as they happen')\n .option('--resource <RESOURCE_ID>', 'show events for specific resource ID')\n .option('--related-resource <RELATED_RESOURCE_ID>', 'show events related to specific resource ID')\n .option('--filter <EVENT_TYPES>', 'filter by event types (comma-separated)')\n .option('-l, --limit <NUMBER>', 'limit results per poll (default: 10, max: 100)', parseInt)\n .option('--json', 'output as single-line JSON strings')\n .option('--json-pretty', 'output as indented multi-line JSON')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Could not parse arguments:');\n console.error('--marketplace is required');\n process.exit(1);\n }\n\n await tailEvents(marketplace, {\n resourceId: opts.resource,\n relatedResourceId: opts.relatedResource,\n eventTypes: opts.filter,\n limit: opts.limit || 10,\n json: opts.json,\n jsonPretty: opts.jsonPretty,\n });\n });\n}\n", "/**\n * Stripe command - manage Stripe integration\n */\n\nimport { Command } from 'commander';\nimport { updateStripeVersion as sdkUpdateStripeVersion, SUPPORTED_STRIPE_VERSIONS } from 'sharetribe-flex-build-sdk';\nimport { printError } from '../../util/output.js';\nimport inquirer from 'inquirer';\n\n\n/**\n * Prompts for version selection\n */\nasync function promptForVersion(): Promise<string> {\n const answers = await inquirer.prompt([\n {\n type: 'list',\n name: 'version',\n message: 'Select Stripe API version:',\n choices: [...SUPPORTED_STRIPE_VERSIONS],\n },\n ]);\n\n return answers.version;\n}\n\n/**\n * Prompts for confirmation\n */\nasync function promptForConfirmation(): Promise<boolean> {\n console.log('');\n console.log('WARNING: Changing Stripe API version may affect your integration.');\n console.log('');\n console.log('After updating the Stripe API version, you may need to:');\n console.log('- Handle new Capabilities requirements');\n console.log('- Update identity verification settings');\n console.log('');\n console.log('See Stripe documentation for details:');\n console.log('https://stripe.com/docs/connect/capabilities-overview');\n console.log('https://stripe.com/docs/connect/identity-verification');\n console.log('');\n\n const answers = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'confirmed',\n message: 'Do you want to continue?',\n default: false,\n },\n ]);\n\n return answers.confirmed;\n}\n\n/**\n * Updates Stripe API version\n */\nasync function updateStripeVersion(\n marketplace: string,\n version?: string,\n force?: boolean\n): Promise<void> {\n try {\n // Get version if not provided\n let selectedVersion = version;\n if (!selectedVersion) {\n selectedVersion = await promptForVersion();\n }\n\n // Get confirmation unless --force flag is used\n if (!force) {\n const confirmed = await promptForConfirmation();\n if (!confirmed) {\n console.log('Cancelled.');\n process.exit(0);\n }\n }\n\n // Update via API (SDK validates version)\n await sdkUpdateStripeVersion(undefined, marketplace, selectedVersion);\n\n console.log(`Stripe API version successfully changed to ${selectedVersion}`);\n } catch (error) {\n if (error && typeof error === 'object' && 'message' in error) {\n printError(error.message as string);\n } else {\n printError('Failed to update Stripe API version');\n }\n process.exit(1);\n }\n}\n\n/**\n * Registers stripe commands\n */\nexport function registerStripeCommands(program: Command): void {\n const stripeCmd = program.command('stripe').description('manage Stripe integration');\n\n // stripe update-version\n stripeCmd\n .command('update-version')\n .description('update Stripe API version in use')\n .option('--version <VERSION>', 'Stripe API version to update to')\n .option('-f, --force', 'skip confirmation prompt and force update')\n .option('-m, --marketplace <MARKETPLACE_ID>', 'marketplace identifier')\n .action(async (opts) => {\n const marketplace = opts.marketplace || program.opts().marketplace;\n if (!marketplace) {\n console.error('Error: --marketplace is required');\n process.exit(1);\n }\n await updateStripeVersion(marketplace, opts.version, opts.force);\n });\n}\n", "/**\n * Debug command - display config and auth info\n */\n\nimport edn from 'jsedn';\nimport { getConfigMap, readAuth } from 'sharetribe-flex-build-sdk';\n\nfunction maskLast4(value: string): string {\n if (value.length <= 4) {\n return `...${value}`;\n }\n return `...${value.slice(-4)}`;\n}\n\nfunction toEdnMap(record: Record<string, string>): edn.Map {\n const entries: Array<unknown> = [];\n for (const [key, value] of Object.entries(record)) {\n entries.push(edn.kw(`:${key}`), value);\n }\n return new edn.Map(entries);\n}\n\nexport function debug(): void {\n const auth = readAuth();\n const apiKey = auth?.apiKey ? maskLast4(auth.apiKey) : 'No API key set';\n const confMap = getConfigMap();\n\n const payload = new edn.Map([\n edn.kw(':api-key'),\n apiKey,\n edn.kw(':conf-map'),\n toEdnMap(confMap),\n ]);\n\n console.log(edn.encode(payload));\n}\n", "/**\n * Custom help formatter to match flex-cli output exactly\n */\n\nimport { Command, Help } from 'commander';\nimport chalk from 'chalk';\n\n/**\n * Formats help text to match flex-cli style\n *\n * flex-cli format:\n * - Description (no label)\n * - VERSION section (for main help only)\n * - USAGE section\n * - COMMANDS section (flattened list of all leaf commands)\n * - OPTIONS section (for subcommands only, not main)\n * - Subcommand help instructions\n *\n * @param cmd - Commander command instance\n * @returns Formatted help text matching flex-cli\n */\nexport function formatHelp(cmd: Command): string {\n const parts: string[] = [];\n const isRootCommand = !cmd.parent;\n\n // Description (no label, just the text)\n const description = cmd.description();\n if (description) {\n parts.push(description);\n parts.push('');\n }\n\n // VERSION section (only for root command)\n if (isRootCommand) {\n const version = cmd.version();\n if (version) {\n parts.push('VERSION');\n parts.push(` ${version}`);\n parts.push('');\n }\n }\n\n // USAGE section\n parts.push('USAGE');\n const usage = formatUsage(cmd);\n parts.push(` $ ${usage}`);\n parts.push('');\n\n // COMMANDS section\n // Note: If command has an action (options), don't show COMMANDS section (like flex-cli)\n const allCommands = collectAllLeafCommands(cmd);\n const hasAction = cmd.options.length > 0 && !isRootCommand;\n\n if (allCommands.length > 0 && !hasAction) {\n parts.push('COMMANDS');\n\n // Calculate max command name length for alignment\n const maxLength = Math.max(...allCommands.map(c => c.name.length));\n\n for (const cmdInfo of allCommands) {\n const paddedName = cmdInfo.name.padEnd(maxLength + 2);\n parts.push(` ${paddedName}${cmdInfo.description}`);\n }\n parts.push('');\n }\n\n // OPTIONS section (only for subcommands, not root)\n if (!isRootCommand) {\n const options = cmd.options;\n if (options.length > 0) {\n parts.push('OPTIONS');\n\n // Calculate max option flags length for alignment\n const maxFlagsLength = Math.max(...options.map(opt => formatOptionFlags(opt).length));\n\n for (const opt of options) {\n const flags = formatOptionFlags(opt);\n const paddedFlags = flags.padEnd(maxFlagsLength + 2);\n const desc = opt.description || '';\n parts.push(` ${paddedFlags}${desc}`);\n }\n parts.push('');\n }\n }\n\n // Subcommand help instructions (only for main and group commands without actions)\n if (allCommands.length > 0 && !hasAction) {\n parts.push('Subcommand help:');\n const cmdName = getCommandName(cmd);\n parts.push(` $ ${cmdName} help [COMMAND]`);\n }\n\n // Always add empty line at end to match flex-cli\n parts.push('');\n\n return parts.join('\\n');\n}\n\n/**\n * Recursively collects all commands (both parent and leaf commands)\n *\n * flex-cli shows ALL commands, including parent commands that have their own actions\n * Example: both \"events\" and \"events tail\" are shown\n *\n * @param cmd - Commander command instance\n * @returns Array of command info objects with name and description\n */\nfunction collectAllLeafCommands(cmd: Command): Array<{ name: string; description: string }> {\n const results: Array<{ name: string; description: string }> = [];\n const commands = cmd.commands.filter(c => !c._hidden && c.name() !== 'help');\n\n for (const subCmd of commands) {\n const fullName = getCommandFullName(subCmd);\n const subCommands = subCmd.commands.filter(c => !c._hidden);\n\n // Add this command if it has an action or description\n if (subCmd.description()) {\n results.push({\n name: fullName,\n description: subCmd.description() || ''\n });\n }\n\n // If it has subcommands, recurse and add those too\n if (subCommands.length > 0) {\n const subResults = collectAllLeafCommands(subCmd);\n for (const sub of subResults) {\n results.push(sub);\n }\n }\n }\n\n // Add \"help\" command at the beginning if this is root\n if (!cmd.parent) {\n results.unshift({\n name: 'help',\n description: 'display help for Flex CLI'\n });\n }\n\n // Sort alphabetically by command name\n results.sort((a, b) => a.name.localeCompare(b.name));\n\n return results;\n}\n\n/**\n * Gets the command name for usage (flex-cli vs sharetribe-cli)\n *\n * @param cmd - Commander command instance\n * @returns Command name (e.g., \"sharetribe-cli\" or \"sharetribe-cli process\")\n */\nfunction getCommandName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n // Replace first name with \"sharetribe-cli\" (or \"flex-cli\" for reference)\n if (names.length > 0) {\n names[0] = 'sharetribe-cli';\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats the USAGE line\n *\n * @param cmd - Commander command instance\n * @returns Usage string (e.g., \"sharetribe-cli [COMMAND]\" or \"sharetribe-cli process list\")\n */\nfunction formatUsage(cmd: Command): string {\n const cmdName = getCommandName(cmd);\n const commands = cmd.commands.filter(c => !c._hidden);\n const hasOptions = cmd.options.length > 0;\n const isRoot = !cmd.parent;\n\n // Root command always shows [COMMAND] if it has subcommands\n if (isRoot && commands.length > 0) {\n return `${cmdName} [COMMAND]`;\n }\n\n // If command has options (its own action), don't show [COMMAND] even if it has subcommands\n // This matches flex-cli behavior for commands like \"process\" which have both action and subcommands\n if (commands.length > 0 && !hasOptions) {\n // Has subcommands but no action\n return `${cmdName} [COMMAND]`;\n } else {\n // Leaf command or command with action - just show the command path\n return cmdName;\n }\n}\n\n/**\n * Gets the full command name including parent path\n *\n * @param cmd - Commander command instance\n * @returns Full command name (e.g., \"process list\" or \"events tail\")\n */\nfunction getCommandFullName(cmd: Command): string {\n const names: string[] = [];\n let current: Command | null = cmd;\n\n while (current && current.parent) {\n if (current.name()) {\n names.unshift(current.name());\n }\n current = current.parent;\n }\n\n return names.join(' ');\n}\n\n/**\n * Formats option flags for display\n *\n * @param opt - Commander option instance\n * @returns Formatted flags string (e.g., \"-m, --marketplace=MARKETPLACE_ID\")\n */\nfunction formatOptionFlags(opt: any): string {\n // Commander option flags are in opt.flags (e.g., \"-m, --marketplace <MARKETPLACE_ID>\")\n // We need to parse and reformat this to match flex-cli style\n const flagsStr = opt.flags || '';\n\n // Parse the flags string\n // Format: \"-m, --marketplace <VALUE>\" or \"--flag\" or \"-f\"\n const parts = flagsStr.split(/,\\s*/);\n const formatted: string[] = [];\n\n for (const part of parts) {\n const trimmed = part.trim();\n\n // Check if it has a value placeholder (angle brackets or square brackets)\n const valueMatch = trimmed.match(/^((?:-{1,2}[\\w-]+))\\s*[<\\[]([^\\]>]+)[\\]>]/);\n if (valueMatch) {\n // Has a value: \"-m <MARKETPLACE_ID>\" or \"--marketplace <MARKETPLACE_ID>\"\n const flag = valueMatch[1];\n const valueName = valueMatch[2];\n formatted.push(`${flag}=${valueName}`);\n } else {\n // No value: just the flag\n formatted.push(trimmed);\n }\n }\n\n return formatted.join(', ');\n}\n\n/**\n * Configures Commander.js to use custom help formatter\n *\n * @param program - Commander program instance\n */\nexport function configureHelp(program: Command): void {\n program.configureHelp({\n formatHelp: (cmd: Command, helper: Help) => {\n return formatHelp(cmd);\n }\n });\n}\n", "/**\n * Custom command router to handle Commander.js limitations\n *\n * Commander.js cannot handle parent and child commands with the same option names.\n * This router intercepts argv and routes to the correct command handler.\n */\n\n/**\n * Routes process subcommands to avoid Commander parent/child option conflicts\n *\n * This is necessary because Commander validates parent command options before\n * subcommand actions run, causing conflicts when both use --path.\n */\nexport function routeProcessCommand(argv: string[]): string[] {\n // Check if this is a process subcommand\n const processIndex = argv.findIndex(arg => arg === 'process');\n if (processIndex === -1) {\n return argv;\n }\n\n // Check for subcommands\n const nextArg = argv[processIndex + 1];\n const subcommands = ['list', 'create', 'push', 'pull', 'create-alias', 'update-alias', 'delete-alias', 'deploy'];\n\n if (nextArg && subcommands.includes(nextArg)) {\n // This is a subcommand - remove 'process' from argv and make the subcommand top-level\n // e.g. ['node', 'cli', 'process', 'pull', ...] => ['node', 'cli', 'process-pull', ...]\n const newArgv = [\n ...argv.slice(0, processIndex),\n `process-${nextArg}`,\n ...argv.slice(processIndex + 2)\n ];\n\n // Special handling: If this is an alias command with --version option,\n // we need to filter out the global --version flag from program\n // by ensuring the routed command is properly isolated\n return newArgv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EAGHC,EAAwBR,CAAO,EAG/BS,EAAuBT,CAAO,EAG9BU,GAAuBV,CAAO,EAG9BW,GAA8BX,CAAO,EAGrCY,GAA+BZ,CAAO,EAGtCa,GAAsBb,CAAO,EAG7Bc,GAAuBd,CAAO,EAG9BA,EACG,QAAQ,mBAAmB,EAC3B,YAAY,2BAA2B,EACvC,OAAQe,GAA0B,CACjC,GAAI,CAACA,GAAeA,EAAY,SAAW,EAAG,CAC5Cf,EAAQ,WAAW,EACnB,MACF,CAGA,IAAIgB,EAAqBhB,EACzB,QAAWiB,KAAWF,EAAa,CACjC,IAAMG,EAASF,EAAU,SAAS,KAAKG,GAAKA,EAAE,KAAK,IAAMF,CAAO,EAC3DC,IACH,QAAQ,MAAM,oBAAoBH,EAAY,KAAK,GAAG,CAAC,EAAE,EACzD,QAAQ,KAAK,CAAC,GAEhBC,EAAYE,CACd,CAGAF,EAAU,WAAW,CACvB,CAAC,EAGElB,GAAW,MAAM,CAAC,EAAE,OAKvBE,EAAQ,MAAMF,EAAU,EAJxBE,EAAQ,WAAW",
6
+ "names": ["Command", "readFileSync", "fileURLToPath", "dirname", "join", "readFileSync", "fileURLToPath", "dirname", "join", "findPackageJson", "__filename", "currentDir", "pkgPath", "version", "packageJson", "inquirer", "writeAuth", "login", "answers", "input", "clearAuth", "logout", "sdkListProcesses", "sdkListProcessVersions", "chalk", "printTable", "headers", "rows", "widths", "header", "row", "value", "headerRow", "h", "width", "padded", "rowStr", "i", "printError", "message", "printSuccess", "formatProcessTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "listProcesses", "marketplace", "processName", "versions", "sdkListProcessVersions", "versionRows", "v", "printTable", "processes", "sdkListProcesses", "processRows", "p", "error", "printError", "sdkCreateProcess", "readFileSync", "join", "createProcess", "marketplace", "processName", "path", "processFilePath", "processContent", "result", "sdkCreateProcess", "printSuccess", "error", "printError", "sdkPushProcess", "readFileSync", "readdirSync", "join", "readTemplates", "path", "templatesDir", "templates", "templateDirs", "templateName", "templatePath", "htmlFile", "subjectFile", "html", "subject", "pushProcess", "marketplace", "processName", "processFilePath", "processContent", "result", "sdkPushProcess", "printSuccess", "error", "printError", "getProcess", "writeFileSync", "mkdirSync", "join", "pullProcess", "marketplace", "processName", "path", "version", "alias", "process", "getProcess", "existsSync", "dirExists", "processFilePath", "templates", "templatesDir", "template", "templateName", "htmlContent", "subjectContent", "templateSubdir", "htmlPath", "subjectPath", "error", "printError", "sdkCreateAlias", "sdkUpdateAlias", "sdkDeleteAlias", "createAlias", "marketplace", "processName", "version", "alias", "result", "sdkCreateAlias", "printSuccess", "error", "printError", "updateAlias", "sdkUpdateAlias", "deleteAlias", "sdkDeleteAlias", "sdkDeployProcess", "parseProcessFile", "readFileSync", "join", "createOrPushAndCreateOrUpdateAlias", "marketplace", "processName", "path", "alias", "processFilePath", "processContent", "processDefinition", "parseProcessFile", "result", "sdkDeployProcess", "printSuccess", "error", "printError", "registerProcessCommands", "program", "processCmd", "options", "marketplace", "listProcesses", "createProcess", "pushProcess", "pullProcess", "createAlias", "updateAlias", "deleteAlias", "createOrPushAndCreateOrUpdateAlias", "sdkListSearchSchemas", "sdkSetSearchSchema", "sdkUnsetSearchSchema", "SCOPE_LABELS", "setSearchSchema", "marketplace", "opts", "sdkSetSearchSchema", "schemaFor", "scopeLabel", "error", "printError", "unsetSearchSchema", "sdkUnsetSearchSchema", "getDefaultValueLabel", "value", "listSearchSchemas", "schemas", "sdkListSearchSchemas", "rows", "s", "a", "b", "headers", "widths", "h", "row", "headerParts", "i", "width", "padded", "rowParts", "registerSearchCommands", "program", "searchCmd", "options", "sdkPullAssets", "sdkPushAssets", "readFileSync", "writeFileSync", "existsSync", "mkdirSync", "readdirSync", "statSync", "unlinkSync", "join", "dirname", "createHash", "chalk", "edn", "readAssetMetadata", "basePath", "metaPath", "content", "parsed", "version", "assets", "assetList", "asset", "writeAssetMetadata", "metadata", "metaDir", "a", "ednMap", "calculateHash", "data", "prefix", "readLocalAssets", "scanDir", "dir", "relativePath", "entries", "entry", "fullPath", "relPath", "stat", "hash", "validateJsonAssets", "error", "pullAssets", "marketplace", "path", "prune", "result", "sdkPullAssets", "remoteVersion", "currentMeta", "newAssets", "assetPath", "assetDir", "remotePaths", "localAsset", "printError", "pushAssets", "currentVersion", "localAssets", "operations", "localAssetMap", "currentAssetMap", "currentHash", "currentAsset", "changedAssetPaths", "op", "sdkPushAssets", "registerAssetsCommands", "program", "assetsCmd", "opts", "sdkSendNotification", "sdkPreviewNotification", "readFileSync", "existsSync", "statSync", "join", "createServer", "readTemplate", "templatePath", "htmlPath", "subjectPath", "html", "subject", "readContext", "contextPath", "content", "error", "sendNotification", "marketplace", "template", "context", "result", "sdkSendNotification", "printError", "previewNotification", "previewHtml", "fetchPreview", "sdkPreviewNotification", "titleTag", "server", "req", "res", "shutdown", "registerNotificationsCommands", "program", "notificationsCmd", "opts", "sdkGetStatus", "sdkEnable", "sdkDisable", "getStatus", "marketplace", "sdkGetStatus", "error", "printError", "enableApprovals", "sdkEnable", "disableApprovals", "sdkDisable", "registerListingApprovalCommand", "program", "cmd", "opts", "sdkQueryEvents", "sdkPollEvents", "validateParams", "opts", "formatTimestamp", "timestamp", "date", "year", "month", "day", "timeString", "queryEvents", "marketplace", "events", "event", "auditEmails", "eventWithoutEmails", "printTable", "actor", "source", "error", "printError", "tailEvents", "stopPolling", "shutdown", "registerEventsCommand", "program", "cmd", "sdkUpdateStripeVersion", "SUPPORTED_STRIPE_VERSIONS", "inquirer", "promptForVersion", "SUPPORTED_STRIPE_VERSIONS", "promptForConfirmation", "updateStripeVersion", "marketplace", "version", "force", "selectedVersion", "sdkUpdateStripeVersion", "error", "printError", "registerStripeCommands", "program", "opts", "edn", "getConfigMap", "readAuth", "maskLast4", "value", "toEdnMap", "record", "entries", "key", "debug", "auth", "apiKey", "confMap", "payload", "formatHelp", "cmd", "parts", "isRootCommand", "description", "version", "usage", "formatUsage", "allCommands", "collectAllLeafCommands", "hasAction", "maxLength", "c", "cmdInfo", "paddedName", "options", "maxFlagsLength", "opt", "formatOptionFlags", "paddedFlags", "desc", "cmdName", "getCommandName", "results", "commands", "subCmd", "fullName", "getCommandFullName", "subCommands", "subResults", "sub", "a", "b", "names", "current", "hasOptions", "formatted", "part", "trimmed", "valueMatch", "flag", "valueName", "configureHelp", "program", "helper", "routeProcessCommand", "argv", "processIndex", "arg", "nextArg", "__filename", "fileURLToPath", "__dirname", "dirname", "packageJson", "readFileSync", "join", "routedArgv", "routeProcessCommand", "program", "Command", "configureHelp", "str", "version", "login", "logout", "debug", "registerProcessCommands", "registerSearchCommands", "registerAssetsCommands", "registerNotificationsCommands", "registerListingApprovalCommand", "registerEventsCommand", "registerStripeCommands", "commandPath", "targetCmd", "cmdName", "subCmd", "c"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sharetribe-cli",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "description": "Unofficial Sharetribe CLI - 100% compatible with flex-cli",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -41,7 +41,7 @@
41
41
  "commander": "^12.1.0",
42
42
  "inquirer": "^9.2.23",
43
43
  "jsedn": "^0.4.1",
44
- "sharetribe-flex-build-sdk": "1.15.0",
44
+ "sharetribe-flex-build-sdk": "^1.15.1",
45
45
  "yargs": "^18.0.0"
46
46
  },
47
47
  "devDependencies": {
@@ -11,6 +11,7 @@ import { printError } from '../../util/output.js';
11
11
  import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, statSync, unlinkSync } from 'node:fs';
12
12
  import { join, dirname } from 'node:path';
13
13
  import { createHash } from 'node:crypto';
14
+ import chalk from 'chalk';
14
15
  import edn from 'jsedn';
15
16
 
16
17
 
@@ -81,7 +82,8 @@ function writeAssetMetadata(basePath: string, metadata: AssetMetadata): void {
81
82
  * Calculates SHA-1 hash of file content
82
83
  */
83
84
  function calculateHash(data: Buffer): string {
84
- return createHash('sha1').update(data).digest('hex');
85
+ const prefix = Buffer.from(`${data.length}|`, 'utf-8');
86
+ return createHash('sha1').update(prefix).update(data).digest('hex');
85
87
  }
86
88
 
87
89
  /**
@@ -274,6 +276,13 @@ async function pushAssets(
274
276
  return;
275
277
  }
276
278
 
279
+ const changedAssetPaths = operations
280
+ .filter(op => op.op === 'upsert')
281
+ .map(op => op.path);
282
+ if (changedAssetPaths.length > 0) {
283
+ console.log(chalk.green(`Uploading changed assets: ${changedAssetPaths.join(', ')}`));
284
+ }
285
+
277
286
  // Upload to API
278
287
  const result = await sdkPushAssets(undefined, marketplace, currentVersion, operations);
279
288
 
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Debug command - display config and auth info
3
+ */
4
+
5
+ import edn from 'jsedn';
6
+ import { getConfigMap, readAuth } from 'sharetribe-flex-build-sdk';
7
+
8
+ function maskLast4(value: string): string {
9
+ if (value.length <= 4) {
10
+ return `...${value}`;
11
+ }
12
+ return `...${value.slice(-4)}`;
13
+ }
14
+
15
+ function toEdnMap(record: Record<string, string>): edn.Map {
16
+ const entries: Array<unknown> = [];
17
+ for (const [key, value] of Object.entries(record)) {
18
+ entries.push(edn.kw(`:${key}`), value);
19
+ }
20
+ return new edn.Map(entries);
21
+ }
22
+
23
+ export function debug(): void {
24
+ const auth = readAuth();
25
+ const apiKey = auth?.apiKey ? maskLast4(auth.apiKey) : 'No API key set';
26
+ const confMap = getConfigMap();
27
+
28
+ const payload = new edn.Map([
29
+ edn.kw(':api-key'),
30
+ apiKey,
31
+ edn.kw(':conf-map'),
32
+ toEdnMap(confMap),
33
+ ]);
34
+
35
+ console.log(edn.encode(payload));
36
+ }
package/src/index.ts CHANGED
@@ -18,6 +18,7 @@ import { registerNotificationsCommands } from './commands/notifications/index.js
18
18
  import { registerListingApprovalCommand } from './commands/listing-approval.js';
19
19
  import { registerEventsCommand } from './commands/events/index.js';
20
20
  import { registerStripeCommands } from './commands/stripe/index.js';
21
+ import { debug } from './commands/debug.js';
21
22
  import { configureHelp } from './util/help-formatter.js';
22
23
  import { routeProcessCommand } from './util/command-router.js';
23
24
 
@@ -75,6 +76,14 @@ program
75
76
  await logout();
76
77
  });
77
78
 
79
+ // debug command
80
+ program
81
+ .command('debug')
82
+ .description('display debug info')
83
+ .action(() => {
84
+ debug();
85
+ });
86
+
78
87
  // Register process commands
79
88
  registerProcessCommands(program);
80
89
 
@@ -12,12 +12,18 @@ const MARKETPLACE = 'expertapplication-dev';
12
12
  /**
13
13
  * Executes a CLI command and returns output (stdout + stderr combined)
14
14
  */
15
- function runCli(command: string, cli: 'flex' | 'sharetribe'): string {
15
+ function runCli(
16
+ command: string,
17
+ cli: 'flex' | 'sharetribe',
18
+ envOverrides?: Record<string, string>
19
+ ): string {
16
20
  const cliName = cli === 'flex' ? 'flex-cli' : 'sharetribe-cli';
21
+ const env = envOverrides ? { ...process.env, ...envOverrides } : process.env;
17
22
  try {
18
23
  return execSync(`${cliName} ${command}`, {
19
24
  encoding: 'utf-8',
20
25
  stdio: ['pipe', 'pipe', 'pipe'],
26
+ env,
21
27
  });
22
28
  } catch (error) {
23
29
  if (error instanceof Error && 'stdout' in error && 'stderr' in error) {
@@ -84,6 +90,29 @@ describe('Strict Byte-by-Byte Comparison Tests', () => {
84
90
  });
85
91
  });
86
92
 
93
+ describe('debug command', () => {
94
+ it('debug output matches flex-cli when available', () => {
95
+ const apiBaseUrl = 'https://example.invalid/build-api';
96
+ const flexOutput = runCli('debug', 'flex', {
97
+ FLEX_API_BASE_URL: apiBaseUrl,
98
+ });
99
+ const shareOutput = runCli('debug', 'sharetribe', {
100
+ FLEX_API_BASE_URL: apiBaseUrl,
101
+ });
102
+
103
+ const flexMissingDebug =
104
+ flexOutput.includes('Command not found: debug') ||
105
+ flexOutput.includes('unknown command');
106
+
107
+ if (flexMissingDebug) {
108
+ expect(shareOutput).toContain(apiBaseUrl);
109
+ expect(shareOutput).not.toContain('Command not found: debug');
110
+ } else {
111
+ expect(shareOutput).toBe(flexOutput);
112
+ }
113
+ });
114
+ });
115
+
87
116
  describe('table output format', () => {
88
117
  it('process list --process has exact column spacing', () => {
89
118
  const flexOutput = runCli(`process list --marketplace ${MARKETPLACE} --process=default-purchase`, 'flex');
@@ -134,7 +163,7 @@ describe('Strict Byte-by-Byte Comparison Tests', () => {
134
163
  for (const line of lines) {
135
164
  expect(() => JSON.parse(line)).not.toThrow();
136
165
  }
137
- });
166
+ }, 15000);
138
167
 
139
168
  it('events --json structure matches flex-cli', () => {
140
169
  const flexOutput = runCli(`events --marketplace ${MARKETPLACE} --json --limit 3`, 'flex');
@@ -555,7 +584,7 @@ describe('Strict Byte-by-Byte Comparison Tests', () => {
555
584
  expect(unsetShareOutput).toBe(unsetFlexOutput);
556
585
  expect(setShareOutput).toBe(setFlexOutput);
557
586
  expect(verifyShareOutput).toBe(verifyFlexOutput);
558
- }, 15000);
587
+ }, 30000);
559
588
 
560
589
  it('events tail can be started and stopped', () => {
561
590
  // This test verifies events tail starts correctly with timeout